2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2013 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2018-08-07 12:32:18 +02:00
|
|
|
// Implementation of the w3c constraints spec is the responsibility of the
|
|
|
|
|
// browser. Chrome no longer uses the constraints api declared here, and it will
|
|
|
|
|
// be removed from WebRTC.
|
|
|
|
|
// https://bugs.chromium.org/p/webrtc/issues/detail?id=9239
|
2016-03-04 02:51:39 -08:00
|
|
|
|
2019-02-13 08:52:27 +01:00
|
|
|
#ifndef SDK_MEDIA_CONSTRAINTS_H_
|
|
|
|
|
#define SDK_MEDIA_CONSTRAINTS_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stddef.h>
|
2023-04-20 13:49:21 -07:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
#include <string>
|
2019-02-13 08:52:27 +01:00
|
|
|
#include <utility>
|
2013-07-10 00:45:36 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "api/audio_options.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/peer_connection_interface.h"
|
2016-03-04 02:51:39 -08:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2019-02-13 08:52:27 +01:00
|
|
|
// Class representing constraints, as used by the android and objc apis.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
|
|
|
|
// Constraints may be either "mandatory", which means that unless satisfied,
|
|
|
|
|
// the method taking the constraints should fail, or "optional", which means
|
|
|
|
|
// they may not be satisfied..
|
2019-02-13 08:52:27 +01:00
|
|
|
class MediaConstraints {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
|
|
|
|
struct Constraint {
|
|
|
|
|
Constraint() {}
|
|
|
|
|
Constraint(const std::string& key, const std::string value)
|
|
|
|
|
: key(key), value(value) {}
|
|
|
|
|
std::string key;
|
|
|
|
|
std::string value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Constraints : public std::vector<Constraint> {
|
|
|
|
|
public:
|
2019-02-13 08:52:27 +01:00
|
|
|
Constraints() = default;
|
|
|
|
|
Constraints(std::initializer_list<Constraint> l)
|
|
|
|
|
: std::vector<Constraint>(l) {}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool FindFirst(const std::string& key, std::string* value) const;
|
|
|
|
|
};
|
|
|
|
|
|
2019-02-13 08:52:27 +01:00
|
|
|
MediaConstraints() = default;
|
|
|
|
|
MediaConstraints(Constraints mandatory, Constraints optional)
|
|
|
|
|
: mandatory_(std::move(mandatory)), optional_(std::move(optional)) {}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Constraint keys used by a local audio source.
|
2015-06-23 09:50:47 -07:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// These keys are google specific.
|
2015-06-15 09:14:03 +02:00
|
|
|
static const char kGoogEchoCancellation[]; // googEchoCancellation
|
|
|
|
|
|
2022-02-14 10:21:31 +01:00
|
|
|
static const char kAutoGainControl[]; // googAutoGainControl
|
|
|
|
|
static const char kNoiseSuppression[]; // googNoiseSuppression
|
|
|
|
|
static const char kHighpassFilter[]; // googHighpassFilter
|
2013-10-25 21:18:33 +00:00
|
|
|
static const char kAudioMirroring[]; // googAudioMirroring
|
2016-12-11 02:17:52 -08:00
|
|
|
static const char
|
2022-01-13 17:06:26 +01:00
|
|
|
kAudioNetworkAdaptorConfig[]; // googAudioNetworkAdaptorConfig
|
|
|
|
|
static const char kInitAudioRecordingOnSend[]; // InitAudioRecordingOnSend;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Constraint keys for CreateOffer / CreateAnswer
|
|
|
|
|
// Specified by the W3C PeerConnection spec
|
|
|
|
|
static const char kOfferToReceiveVideo[]; // OfferToReceiveVideo
|
|
|
|
|
static const char kOfferToReceiveAudio[]; // OfferToReceiveAudio
|
|
|
|
|
static const char kVoiceActivityDetection[]; // VoiceActivityDetection
|
|
|
|
|
static const char kIceRestart[]; // IceRestart
|
|
|
|
|
// These keys are google specific.
|
|
|
|
|
static const char kUseRtpMux[]; // googUseRtpMUX
|
|
|
|
|
|
|
|
|
|
// Constraints values.
|
|
|
|
|
static const char kValueTrue[]; // true
|
|
|
|
|
static const char kValueFalse[]; // false
|
|
|
|
|
|
2014-04-02 23:25:15 +00:00
|
|
|
// PeerConnection constraint keys.
|
|
|
|
|
// Google-specific constraint keys.
|
2013-10-31 15:40:38 +00:00
|
|
|
// Temporary pseudo-constraint for enabling DSCP through JS.
|
2014-04-02 23:25:15 +00:00
|
|
|
static const char kEnableDscp[]; // googDscp
|
2014-01-14 10:00:58 +00:00
|
|
|
// Constraint to enable IPv6 through JS.
|
2014-04-02 23:25:15 +00:00
|
|
|
static const char kEnableIPv6[]; // googIPv6
|
2014-03-25 17:09:47 +00:00
|
|
|
// Temporary constraint to enable suspend below min bitrate feature.
|
|
|
|
|
static const char kEnableVideoSuspendBelowMinBitrate[];
|
2014-04-02 23:25:15 +00:00
|
|
|
static const char kScreencastMinBitrate[]; // googScreencastMinBitrate
|
|
|
|
|
static const char kCpuOveruseDetection[]; // googCpuOveruseDetection
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-06-04 15:38:50 +02:00
|
|
|
// Constraint to enable negotiating raw RTP packetization using attribute
|
|
|
|
|
// "a=packetization:<payload_type> raw" in the SDP for all video payload.
|
|
|
|
|
static const char kRawPacketizationForVideoEnabled[];
|
|
|
|
|
|
2018-08-24 10:58:37 +02:00
|
|
|
// Specifies number of simulcast layers for all video tracks
|
|
|
|
|
// with a Plan B offer/answer
|
|
|
|
|
// (see RTCOfferAnswerOptions::num_simulcast_layers).
|
|
|
|
|
static const char kNumSimulcastLayers[];
|
|
|
|
|
|
2019-02-13 08:52:27 +01:00
|
|
|
~MediaConstraints() = default;
|
2017-11-24 11:21:14 +01:00
|
|
|
|
2019-02-13 08:52:27 +01:00
|
|
|
const Constraints& GetMandatory() const { return mandatory_; }
|
|
|
|
|
const Constraints& GetOptional() const { return optional_; }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-02-13 08:52:27 +01:00
|
|
|
private:
|
|
|
|
|
const Constraints mandatory_ = {};
|
|
|
|
|
const Constraints optional_ = {};
|
|
|
|
|
};
|
2016-03-04 02:51:39 -08:00
|
|
|
|
|
|
|
|
// Copy all relevant constraints into an RTCConfiguration object.
|
|
|
|
|
void CopyConstraintsIntoRtcConfiguration(
|
2019-02-13 08:52:27 +01:00
|
|
|
const MediaConstraints* constraints,
|
2016-03-04 02:51:39 -08:00
|
|
|
PeerConnectionInterface::RTCConfiguration* configuration);
|
|
|
|
|
|
2017-01-13 11:47:56 -08:00
|
|
|
// Copy all relevant constraints into an AudioOptions object.
|
2019-02-13 08:52:27 +01:00
|
|
|
void CopyConstraintsIntoAudioOptions(const MediaConstraints* constraints,
|
|
|
|
|
cricket::AudioOptions* options);
|
2017-01-13 11:47:56 -08:00
|
|
|
|
2018-08-07 12:32:18 +02:00
|
|
|
bool CopyConstraintsIntoOfferAnswerOptions(
|
2019-02-13 08:52:27 +01:00
|
|
|
const MediaConstraints* constraints,
|
2018-08-07 12:32:18 +02:00
|
|
|
PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options);
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2019-02-13 08:52:27 +01:00
|
|
|
#endif // SDK_MEDIA_CONSTRAINTS_H_
|