mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Move MediaConstraintsInterface to sdk/, and make it a concrete class
Bug: webrtc:9239 Change-Id: I545ebf59b078dd94bc466886616dd374e4b2e226 Reviewed-on: https://webrtc-review.googlesource.com/c/122502 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26682}
This commit is contained in:
parent
1d7bf89ad6
commit
dac03d9bb0
20 changed files with 211 additions and 394 deletions
1
BUILD.gn
1
BUILD.gn
|
@ -496,6 +496,7 @@ if (rtc_include_tests) {
|
||||||
"rtc_base:sigslot_unittest",
|
"rtc_base:sigslot_unittest",
|
||||||
"rtc_base:weak_ptr_unittests",
|
"rtc_base:weak_ptr_unittests",
|
||||||
"rtc_base/experiments:experiments_unittests",
|
"rtc_base/experiments:experiments_unittests",
|
||||||
|
"sdk:sdk_tests",
|
||||||
"test/scenario/network:network_emulation_unittests",
|
"test/scenario/network:network_emulation_unittests",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
15
api/BUILD.gn
15
api/BUILD.gn
|
@ -86,8 +86,6 @@ rtc_static_library("libjingle_peerconnection_api") {
|
||||||
"jsep_ice_candidate.cc",
|
"jsep_ice_candidate.cc",
|
||||||
"jsep_ice_candidate.h",
|
"jsep_ice_candidate.h",
|
||||||
"jsep_session_description.h",
|
"jsep_session_description.h",
|
||||||
"media_constraints_interface.cc",
|
|
||||||
"media_constraints_interface.h",
|
|
||||||
"media_stream_interface.cc",
|
"media_stream_interface.cc",
|
||||||
"media_stream_interface.h",
|
"media_stream_interface.h",
|
||||||
"media_stream_proxy.h",
|
"media_stream_proxy.h",
|
||||||
|
@ -364,19 +362,6 @@ rtc_source_set("ice_transport_factory") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_source_set("libjingle_peerconnection_test_api") {
|
|
||||||
visibility = [ "*" ]
|
|
||||||
testonly = true
|
|
||||||
sources = [
|
|
||||||
"test/fake_constraints.h",
|
|
||||||
]
|
|
||||||
|
|
||||||
deps = [
|
|
||||||
":libjingle_peerconnection_api",
|
|
||||||
"../rtc_base:rtc_base_approved",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc_source_set("neteq_simulator_api") {
|
rtc_source_set("neteq_simulator_api") {
|
||||||
visibility = [ "*" ]
|
visibility = [ "*" ]
|
||||||
sources = [
|
sources = [
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2012 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef API_TEST_FAKE_CONSTRAINTS_H_
|
|
||||||
#define API_TEST_FAKE_CONSTRAINTS_H_
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "api/media_constraints_interface.h"
|
|
||||||
#include "rtc_base/string_encode.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
class FakeConstraints : public webrtc::MediaConstraintsInterface {
|
|
||||||
public:
|
|
||||||
FakeConstraints() {}
|
|
||||||
virtual ~FakeConstraints() {}
|
|
||||||
|
|
||||||
virtual const Constraints& GetMandatory() const { return mandatory_; }
|
|
||||||
|
|
||||||
virtual const Constraints& GetOptional() const { return optional_; }
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void AddMandatory(const std::string& key, const T& value) {
|
|
||||||
mandatory_.push_back(Constraint(key, rtc::ToString(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void SetMandatory(const std::string& key, const T& value) {
|
|
||||||
std::string value_str;
|
|
||||||
if (mandatory_.FindFirst(key, &value_str)) {
|
|
||||||
for (Constraints::iterator iter = mandatory_.begin();
|
|
||||||
iter != mandatory_.end(); ++iter) {
|
|
||||||
if (iter->key == key) {
|
|
||||||
mandatory_.erase(iter);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mandatory_.push_back(Constraint(key, rtc::ToString(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void AddOptional(const std::string& key, const T& value) {
|
|
||||||
optional_.push_back(Constraint(key, rtc::ToString(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetMandatoryReceiveAudio(bool enable) {
|
|
||||||
SetMandatory(MediaConstraintsInterface::kOfferToReceiveAudio, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetMandatoryReceiveVideo(bool enable) {
|
|
||||||
SetMandatory(MediaConstraintsInterface::kOfferToReceiveVideo, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetMandatoryUseRtpMux(bool enable) {
|
|
||||||
SetMandatory(MediaConstraintsInterface::kUseRtpMux, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetMandatoryIceRestart(bool enable) {
|
|
||||||
SetMandatory(MediaConstraintsInterface::kIceRestart, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetAllowRtpDataChannels() {
|
|
||||||
SetMandatory(MediaConstraintsInterface::kEnableRtpDataChannels, true);
|
|
||||||
SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetOptionalVAD(bool enable) {
|
|
||||||
AddOptional(MediaConstraintsInterface::kVoiceActivityDetection, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetAllowDtlsSctpDataChannels() {
|
|
||||||
SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Constraints mandatory_;
|
|
||||||
Constraints optional_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // API_TEST_FAKE_CONSTRAINTS_H_
|
|
|
@ -415,7 +415,6 @@ if (rtc_include_tests) {
|
||||||
"../api:audio_options_api",
|
"../api:audio_options_api",
|
||||||
"../api:create_peerconnection_factory",
|
"../api:create_peerconnection_factory",
|
||||||
"../api:libjingle_peerconnection_api",
|
"../api:libjingle_peerconnection_api",
|
||||||
"../api:libjingle_peerconnection_test_api",
|
|
||||||
"../api:rtc_stats_api",
|
"../api:rtc_stats_api",
|
||||||
"../api:scoped_refptr",
|
"../api:scoped_refptr",
|
||||||
"../api/audio:audio_mixer_api",
|
"../api/audio:audio_mixer_api",
|
||||||
|
@ -462,7 +461,6 @@ if (rtc_include_tests) {
|
||||||
"ice_server_parsing_unittest.cc",
|
"ice_server_parsing_unittest.cc",
|
||||||
"jsep_session_description_unittest.cc",
|
"jsep_session_description_unittest.cc",
|
||||||
"local_audio_source_unittest.cc",
|
"local_audio_source_unittest.cc",
|
||||||
"media_constraints_interface_unittest.cc",
|
|
||||||
"media_stream_unittest.cc",
|
"media_stream_unittest.cc",
|
||||||
"peer_connection_bundle_unittest.cc",
|
"peer_connection_bundle_unittest.cc",
|
||||||
"peer_connection_crypto_unittest.cc",
|
"peer_connection_crypto_unittest.cc",
|
||||||
|
@ -546,7 +544,6 @@ if (rtc_include_tests) {
|
||||||
"..:webrtc_common",
|
"..:webrtc_common",
|
||||||
"../api:callfactory_api",
|
"../api:callfactory_api",
|
||||||
"../api:fake_media_transport",
|
"../api:fake_media_transport",
|
||||||
"../api:libjingle_peerconnection_test_api",
|
|
||||||
"../api:rtc_stats_api",
|
"../api:rtc_stats_api",
|
||||||
"../api/audio_codecs:audio_codecs_api",
|
"../api/audio_codecs:audio_codecs_api",
|
||||||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "api/fec_controller.h"
|
#include "api/fec_controller.h"
|
||||||
#include "api/media_constraints_interface.h"
|
|
||||||
#include "api/media_stream_proxy.h"
|
#include "api/media_stream_proxy.h"
|
||||||
#include "api/media_stream_track_proxy.h"
|
#include "api/media_stream_track_proxy.h"
|
||||||
#include "api/media_transport_interface.h"
|
#include "api/media_transport_interface.h"
|
||||||
|
|
25
sdk/BUILD.gn
25
sdk/BUILD.gn
|
@ -27,6 +27,29 @@ group("sdk") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtc_source_set("media_constraints") {
|
||||||
|
sources = [
|
||||||
|
"media_constraints.cc",
|
||||||
|
"media_constraints.h",
|
||||||
|
]
|
||||||
|
deps = [
|
||||||
|
"../api:audio_options_api",
|
||||||
|
"../api:libjingle_peerconnection_api",
|
||||||
|
"//third_party/abseil-cpp/absl/types:optional",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
rtc_source_set("sdk_tests") {
|
||||||
|
testonly = true
|
||||||
|
sources = [
|
||||||
|
"media_constraints_unittest.cc",
|
||||||
|
]
|
||||||
|
deps = [
|
||||||
|
":media_constraints",
|
||||||
|
"../test:test_support",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
if (is_ios || is_mac) {
|
if (is_ios || is_mac) {
|
||||||
config("common_config_objc") {
|
config("common_config_objc") {
|
||||||
include_dirs = [
|
include_dirs = [
|
||||||
|
@ -668,7 +691,7 @@ if (is_ios || is_mac) {
|
||||||
deps = [
|
deps = [
|
||||||
":base_objc",
|
":base_objc",
|
||||||
":helpers_objc",
|
":helpers_objc",
|
||||||
"../api:libjingle_peerconnection_api",
|
":media_constraints",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -752,6 +752,7 @@ if (is_android) {
|
||||||
":logging_jni",
|
":logging_jni",
|
||||||
":native_api_jni",
|
":native_api_jni",
|
||||||
":native_api_stacktrace",
|
":native_api_stacktrace",
|
||||||
|
"..:media_constraints",
|
||||||
"../..:webrtc_common",
|
"../..:webrtc_common",
|
||||||
"../../api:libjingle_peerconnection_api",
|
"../../api:libjingle_peerconnection_api",
|
||||||
"../../api/video_codecs:video_codecs_api",
|
"../../api/video_codecs:video_codecs_api",
|
||||||
|
|
|
@ -21,10 +21,10 @@ namespace jni {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Helper for translating a List<Pair<String, String>> to a Constraints.
|
// Helper for translating a List<Pair<String, String>> to a Constraints.
|
||||||
MediaConstraintsInterface::Constraints PopulateConstraintsFromJavaPairList(
|
MediaConstraints::Constraints PopulateConstraintsFromJavaPairList(
|
||||||
JNIEnv* env,
|
JNIEnv* env,
|
||||||
const JavaRef<jobject>& j_list) {
|
const JavaRef<jobject>& j_list) {
|
||||||
MediaConstraintsInterface::Constraints constraints;
|
MediaConstraints::Constraints constraints;
|
||||||
for (const JavaRef<jobject>& entry : Iterable(env, j_list)) {
|
for (const JavaRef<jobject>& entry : Iterable(env, j_list)) {
|
||||||
constraints.emplace_back(
|
constraints.emplace_back(
|
||||||
JavaToStdString(env, Java_KeyValuePair_getKey(env, entry)),
|
JavaToStdString(env, Java_KeyValuePair_getKey(env, entry)),
|
||||||
|
@ -33,34 +33,17 @@ MediaConstraintsInterface::Constraints PopulateConstraintsFromJavaPairList(
|
||||||
return constraints;
|
return constraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapper for a Java MediaConstraints object. Copies all needed data so when
|
|
||||||
// the constructor returns the Java object is no longer needed.
|
|
||||||
class MediaConstraintsJni : public MediaConstraintsInterface {
|
|
||||||
public:
|
|
||||||
MediaConstraintsJni(JNIEnv* env, const JavaRef<jobject>& j_constraints)
|
|
||||||
: mandatory_(PopulateConstraintsFromJavaPairList(
|
|
||||||
env,
|
|
||||||
Java_MediaConstraints_getMandatory(env, j_constraints))),
|
|
||||||
optional_(PopulateConstraintsFromJavaPairList(
|
|
||||||
env,
|
|
||||||
Java_MediaConstraints_getOptional(env, j_constraints))) {}
|
|
||||||
~MediaConstraintsJni() override = default;
|
|
||||||
|
|
||||||
// MediaConstraintsInterface.
|
|
||||||
const Constraints& GetMandatory() const override { return mandatory_; }
|
|
||||||
const Constraints& GetOptional() const override { return optional_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Constraints mandatory_;
|
|
||||||
const Constraints optional_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<MediaConstraintsInterface> JavaToNativeMediaConstraints(
|
// Copies all needed data so Java object is no longer needed at return.
|
||||||
|
std::unique_ptr<MediaConstraints> JavaToNativeMediaConstraints(
|
||||||
JNIEnv* env,
|
JNIEnv* env,
|
||||||
const JavaRef<jobject>& j_constraints) {
|
const JavaRef<jobject>& j_constraints) {
|
||||||
return absl::make_unique<MediaConstraintsJni>(env, j_constraints);
|
return absl::make_unique<MediaConstraints>(
|
||||||
|
PopulateConstraintsFromJavaPairList(
|
||||||
|
env, Java_MediaConstraints_getMandatory(env, j_constraints)),
|
||||||
|
PopulateConstraintsFromJavaPairList(
|
||||||
|
env, Java_MediaConstraints_getOptional(env, j_constraints)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace jni
|
} // namespace jni
|
||||||
|
|
|
@ -14,13 +14,13 @@
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/media_constraints_interface.h"
|
|
||||||
#include "sdk/android/native_api/jni/scoped_java_ref.h"
|
#include "sdk/android/native_api/jni/scoped_java_ref.h"
|
||||||
|
#include "sdk/media_constraints.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace jni {
|
namespace jni {
|
||||||
|
|
||||||
std::unique_ptr<MediaConstraintsInterface> JavaToNativeMediaConstraints(
|
std::unique_ptr<MediaConstraints> JavaToNativeMediaConstraints(
|
||||||
JNIEnv* env,
|
JNIEnv* env,
|
||||||
const JavaRef<jobject>& j_constraints);
|
const JavaRef<jobject>& j_constraints);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "api/media_constraints_interface.h"
|
|
||||||
#include "api/peer_connection_interface.h"
|
#include "api/peer_connection_interface.h"
|
||||||
#include "api/rtp_receiver_interface.h"
|
#include "api/rtp_receiver_interface.h"
|
||||||
#include "api/rtp_sender_interface.h"
|
#include "api/rtp_sender_interface.h"
|
||||||
|
@ -411,7 +410,7 @@ OwnedPeerConnection::OwnedPeerConnection(
|
||||||
OwnedPeerConnection::OwnedPeerConnection(
|
OwnedPeerConnection::OwnedPeerConnection(
|
||||||
rtc::scoped_refptr<PeerConnectionInterface> peer_connection,
|
rtc::scoped_refptr<PeerConnectionInterface> peer_connection,
|
||||||
std::unique_ptr<PeerConnectionObserver> observer,
|
std::unique_ptr<PeerConnectionObserver> observer,
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints)
|
std::unique_ptr<MediaConstraints> constraints)
|
||||||
: peer_connection_(peer_connection),
|
: peer_connection_(peer_connection),
|
||||||
observer_(std::move(observer)),
|
observer_(std::move(observer)),
|
||||||
constraints_(std::move(constraints)) {}
|
constraints_(std::move(constraints)) {}
|
||||||
|
@ -482,7 +481,7 @@ static void JNI_PeerConnection_CreateOffer(
|
||||||
const JavaParamRef<jobject>& j_pc,
|
const JavaParamRef<jobject>& j_pc,
|
||||||
const JavaParamRef<jobject>& j_observer,
|
const JavaParamRef<jobject>& j_observer,
|
||||||
const JavaParamRef<jobject>& j_constraints) {
|
const JavaParamRef<jobject>& j_constraints) {
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints =
|
std::unique_ptr<MediaConstraints> constraints =
|
||||||
JavaToNativeMediaConstraints(jni, j_constraints);
|
JavaToNativeMediaConstraints(jni, j_constraints);
|
||||||
rtc::scoped_refptr<CreateSdpObserverJni> observer(
|
rtc::scoped_refptr<CreateSdpObserverJni> observer(
|
||||||
new rtc::RefCountedObject<CreateSdpObserverJni>(jni, j_observer,
|
new rtc::RefCountedObject<CreateSdpObserverJni>(jni, j_observer,
|
||||||
|
@ -497,7 +496,7 @@ static void JNI_PeerConnection_CreateAnswer(
|
||||||
const JavaParamRef<jobject>& j_pc,
|
const JavaParamRef<jobject>& j_pc,
|
||||||
const JavaParamRef<jobject>& j_observer,
|
const JavaParamRef<jobject>& j_observer,
|
||||||
const JavaParamRef<jobject>& j_constraints) {
|
const JavaParamRef<jobject>& j_constraints) {
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints =
|
std::unique_ptr<MediaConstraints> constraints =
|
||||||
JavaToNativeMediaConstraints(jni, j_constraints);
|
JavaToNativeMediaConstraints(jni, j_constraints);
|
||||||
rtc::scoped_refptr<CreateSdpObserverJni> observer(
|
rtc::scoped_refptr<CreateSdpObserverJni> observer(
|
||||||
new rtc::RefCountedObject<CreateSdpObserverJni>(jni, j_observer,
|
new rtc::RefCountedObject<CreateSdpObserverJni>(jni, j_observer,
|
||||||
|
|
|
@ -108,18 +108,16 @@ class OwnedPeerConnection {
|
||||||
OwnedPeerConnection(
|
OwnedPeerConnection(
|
||||||
rtc::scoped_refptr<PeerConnectionInterface> peer_connection,
|
rtc::scoped_refptr<PeerConnectionInterface> peer_connection,
|
||||||
std::unique_ptr<PeerConnectionObserver> observer,
|
std::unique_ptr<PeerConnectionObserver> observer,
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints);
|
std::unique_ptr<MediaConstraints> constraints);
|
||||||
~OwnedPeerConnection();
|
~OwnedPeerConnection();
|
||||||
|
|
||||||
PeerConnectionInterface* pc() const { return peer_connection_.get(); }
|
PeerConnectionInterface* pc() const { return peer_connection_.get(); }
|
||||||
const MediaConstraintsInterface* constraints() const {
|
const MediaConstraints* constraints() const { return constraints_.get(); }
|
||||||
return constraints_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rtc::scoped_refptr<PeerConnectionInterface> peer_connection_;
|
rtc::scoped_refptr<PeerConnectionInterface> peer_connection_;
|
||||||
std::unique_ptr<PeerConnectionObserver> observer_;
|
std::unique_ptr<PeerConnectionObserver> observer_;
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints_;
|
std::unique_ptr<MediaConstraints> constraints_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace jni
|
} // namespace jni
|
||||||
|
|
|
@ -370,7 +370,7 @@ static jlong JNI_PeerConnectionFactory_CreateAudioSource(
|
||||||
JNIEnv* jni,
|
JNIEnv* jni,
|
||||||
jlong native_factory,
|
jlong native_factory,
|
||||||
const JavaParamRef<jobject>& j_constraints) {
|
const JavaParamRef<jobject>& j_constraints) {
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints =
|
std::unique_ptr<MediaConstraints> constraints =
|
||||||
JavaToNativeMediaConstraints(jni, j_constraints);
|
JavaToNativeMediaConstraints(jni, j_constraints);
|
||||||
cricket::AudioOptions options;
|
cricket::AudioOptions options;
|
||||||
CopyConstraintsIntoAudioOptions(constraints.get(), &options);
|
CopyConstraintsIntoAudioOptions(constraints.get(), &options);
|
||||||
|
@ -437,7 +437,7 @@ static jlong JNI_PeerConnectionFactory_CreatePeerConnection(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints;
|
std::unique_ptr<MediaConstraints> constraints;
|
||||||
if (!j_constraints.is_null()) {
|
if (!j_constraints.is_null()) {
|
||||||
constraints = JavaToNativeMediaConstraints(jni, j_constraints);
|
constraints = JavaToNativeMediaConstraints(jni, j_constraints);
|
||||||
CopyConstraintsIntoRtcConfiguration(constraints.get(), &rtc_config);
|
CopyConstraintsIntoRtcConfiguration(constraints.get(), &rtc_config);
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "api/media_constraints_interface.h"
|
|
||||||
#include "sdk/android/generated_peerconnection_jni/jni/SdpObserver_jni.h"
|
#include "sdk/android/generated_peerconnection_jni/jni/SdpObserver_jni.h"
|
||||||
#include "sdk/android/native_api/jni/java_types.h"
|
#include "sdk/android/native_api/jni/java_types.h"
|
||||||
#include "sdk/android/src/jni/jni_helpers.h"
|
#include "sdk/android/src/jni/jni_helpers.h"
|
||||||
|
#include "sdk/media_constraints.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace jni {
|
namespace jni {
|
||||||
|
@ -23,7 +23,7 @@ namespace jni {
|
||||||
CreateSdpObserverJni::CreateSdpObserverJni(
|
CreateSdpObserverJni::CreateSdpObserverJni(
|
||||||
JNIEnv* env,
|
JNIEnv* env,
|
||||||
const JavaRef<jobject>& j_observer,
|
const JavaRef<jobject>& j_observer,
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints)
|
std::unique_ptr<MediaConstraints> constraints)
|
||||||
: j_observer_global_(env, j_observer),
|
: j_observer_global_(env, j_observer),
|
||||||
constraints_(std::move(constraints)) {}
|
constraints_(std::move(constraints)) {}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ void CreateSdpObserverJni::OnFailure(webrtc::RTCError error) {
|
||||||
SetSdpObserverJni::SetSdpObserverJni(
|
SetSdpObserverJni::SetSdpObserverJni(
|
||||||
JNIEnv* env,
|
JNIEnv* env,
|
||||||
const JavaRef<jobject>& j_observer,
|
const JavaRef<jobject>& j_observer,
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints)
|
std::unique_ptr<MediaConstraints> constraints)
|
||||||
: j_observer_global_(env, j_observer),
|
: j_observer_global_(env, j_observer),
|
||||||
constraints_(std::move(constraints)) {}
|
constraints_(std::move(constraints)) {}
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "api/media_constraints_interface.h"
|
|
||||||
#include "api/peer_connection_interface.h"
|
#include "api/peer_connection_interface.h"
|
||||||
#include "sdk/android/src/jni/jni_helpers.h"
|
#include "sdk/android/src/jni/jni_helpers.h"
|
||||||
#include "sdk/android/src/jni/pc/session_description.h"
|
#include "sdk/android/src/jni/pc/session_description.h"
|
||||||
|
#include "sdk/media_constraints.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace jni {
|
namespace jni {
|
||||||
|
@ -26,34 +26,34 @@ class CreateSdpObserverJni : public CreateSessionDescriptionObserver {
|
||||||
public:
|
public:
|
||||||
CreateSdpObserverJni(JNIEnv* env,
|
CreateSdpObserverJni(JNIEnv* env,
|
||||||
const JavaRef<jobject>& j_observer,
|
const JavaRef<jobject>& j_observer,
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints);
|
std::unique_ptr<MediaConstraints> constraints);
|
||||||
~CreateSdpObserverJni() override;
|
~CreateSdpObserverJni() override;
|
||||||
|
|
||||||
MediaConstraintsInterface* constraints() { return constraints_.get(); }
|
MediaConstraints* constraints() { return constraints_.get(); }
|
||||||
|
|
||||||
void OnSuccess(SessionDescriptionInterface* desc) override;
|
void OnSuccess(SessionDescriptionInterface* desc) override;
|
||||||
void OnFailure(RTCError error) override;
|
void OnFailure(RTCError error) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ScopedJavaGlobalRef<jobject> j_observer_global_;
|
const ScopedJavaGlobalRef<jobject> j_observer_global_;
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints_;
|
std::unique_ptr<MediaConstraints> constraints_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SetSdpObserverJni : public SetSessionDescriptionObserver {
|
class SetSdpObserverJni : public SetSessionDescriptionObserver {
|
||||||
public:
|
public:
|
||||||
SetSdpObserverJni(JNIEnv* env,
|
SetSdpObserverJni(JNIEnv* env,
|
||||||
const JavaRef<jobject>& j_observer,
|
const JavaRef<jobject>& j_observer,
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints);
|
std::unique_ptr<MediaConstraints> constraints);
|
||||||
~SetSdpObserverJni() override;
|
~SetSdpObserverJni() override;
|
||||||
|
|
||||||
MediaConstraintsInterface* constraints() { return constraints_.get(); }
|
MediaConstraints* constraints() { return constraints_.get(); }
|
||||||
|
|
||||||
void OnSuccess() override;
|
void OnSuccess() override;
|
||||||
void OnFailure(RTCError error) override;
|
void OnFailure(RTCError error) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ScopedJavaGlobalRef<jobject> j_observer_global_;
|
const ScopedJavaGlobalRef<jobject> j_observer_global_;
|
||||||
std::unique_ptr<MediaConstraintsInterface> constraints_;
|
std::unique_ptr<MediaConstraints> constraints_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace jni
|
} // namespace jni
|
||||||
|
|
|
@ -8,13 +8,12 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "api/media_constraints_interface.h"
|
#include "sdk/media_constraints.h"
|
||||||
|
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/peer_connection_interface.h"
|
#include "api/peer_connection_interface.h"
|
||||||
#include "media/base/media_config.h"
|
|
||||||
#include "rtc_base/string_encode.h"
|
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Find the highest-priority instance of the T-valued constraint named by
|
// Find the highest-priority instance of the T-valued constraint named by
|
||||||
|
@ -28,7 +27,7 @@ namespace {
|
||||||
// first instance has an unrecognized value are not handled precisely in
|
// first instance has an unrecognized value are not handled precisely in
|
||||||
// accordance with the specification.
|
// accordance with the specification.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool FindConstraint(const webrtc::MediaConstraintsInterface* constraints,
|
bool FindConstraint(const MediaConstraints* constraints,
|
||||||
const std::string& key,
|
const std::string& key,
|
||||||
T* value,
|
T* value,
|
||||||
size_t* mandatory_constraints) {
|
size_t* mandatory_constraints) {
|
||||||
|
@ -41,7 +40,7 @@ bool FindConstraint(const webrtc::MediaConstraintsInterface* constraints,
|
||||||
|
|
||||||
// Specialization for std::string, since a string doesn't need conversion.
|
// Specialization for std::string, since a string doesn't need conversion.
|
||||||
template <>
|
template <>
|
||||||
bool FindConstraint(const webrtc::MediaConstraintsInterface* constraints,
|
bool FindConstraint(const MediaConstraints* constraints,
|
||||||
const std::string& key,
|
const std::string& key,
|
||||||
std::string* value,
|
std::string* value,
|
||||||
size_t* mandatory_constraints) {
|
size_t* mandatory_constraints) {
|
||||||
|
@ -60,10 +59,24 @@ bool FindConstraint(const webrtc::MediaConstraintsInterface* constraints,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FindConstraint(const MediaConstraints* constraints,
|
||||||
|
const std::string& key,
|
||||||
|
bool* value,
|
||||||
|
size_t* mandatory_constraints) {
|
||||||
|
return FindConstraint<bool>(constraints, key, value, mandatory_constraints);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FindConstraint(const MediaConstraints* constraints,
|
||||||
|
const std::string& key,
|
||||||
|
int* value,
|
||||||
|
size_t* mandatory_constraints) {
|
||||||
|
return FindConstraint<int>(constraints, key, value, mandatory_constraints);
|
||||||
|
}
|
||||||
|
|
||||||
// Converts a constraint (mandatory takes precedence over optional) to an
|
// Converts a constraint (mandatory takes precedence over optional) to an
|
||||||
// absl::optional.
|
// absl::optional.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void ConstraintToOptional(const webrtc::MediaConstraintsInterface* constraints,
|
void ConstraintToOptional(const MediaConstraints* constraints,
|
||||||
const std::string& key,
|
const std::string& key,
|
||||||
absl::optional<T>* value_out) {
|
absl::optional<T>* value_out) {
|
||||||
T value;
|
T value;
|
||||||
|
@ -74,72 +87,59 @@ void ConstraintToOptional(const webrtc::MediaConstraintsInterface* constraints,
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace webrtc {
|
const char MediaConstraints::kValueTrue[] = "true";
|
||||||
|
const char MediaConstraints::kValueFalse[] = "false";
|
||||||
const char MediaConstraintsInterface::kValueTrue[] = "true";
|
|
||||||
const char MediaConstraintsInterface::kValueFalse[] = "false";
|
|
||||||
|
|
||||||
// Constraints declared as static members in mediastreaminterface.h
|
// Constraints declared as static members in mediastreaminterface.h
|
||||||
|
|
||||||
// Audio constraints.
|
// Audio constraints.
|
||||||
const char MediaConstraintsInterface::kGoogEchoCancellation[] =
|
const char MediaConstraints::kGoogEchoCancellation[] = "googEchoCancellation";
|
||||||
"googEchoCancellation";
|
const char MediaConstraints::kExtendedFilterEchoCancellation[] =
|
||||||
const char MediaConstraintsInterface::kExtendedFilterEchoCancellation[] =
|
|
||||||
"googEchoCancellation2";
|
"googEchoCancellation2";
|
||||||
const char MediaConstraintsInterface::kDAEchoCancellation[] =
|
const char MediaConstraints::kDAEchoCancellation[] = "googDAEchoCancellation";
|
||||||
"googDAEchoCancellation";
|
const char MediaConstraints::kAutoGainControl[] = "googAutoGainControl";
|
||||||
const char MediaConstraintsInterface::kAutoGainControl[] =
|
const char MediaConstraints::kExperimentalAutoGainControl[] =
|
||||||
"googAutoGainControl";
|
|
||||||
const char MediaConstraintsInterface::kExperimentalAutoGainControl[] =
|
|
||||||
"googAutoGainControl2";
|
"googAutoGainControl2";
|
||||||
const char MediaConstraintsInterface::kNoiseSuppression[] =
|
const char MediaConstraints::kNoiseSuppression[] = "googNoiseSuppression";
|
||||||
"googNoiseSuppression";
|
const char MediaConstraints::kExperimentalNoiseSuppression[] =
|
||||||
const char MediaConstraintsInterface::kExperimentalNoiseSuppression[] =
|
|
||||||
"googNoiseSuppression2";
|
"googNoiseSuppression2";
|
||||||
const char MediaConstraintsInterface::kHighpassFilter[] = "googHighpassFilter";
|
const char MediaConstraints::kHighpassFilter[] = "googHighpassFilter";
|
||||||
const char MediaConstraintsInterface::kTypingNoiseDetection[] =
|
const char MediaConstraints::kTypingNoiseDetection[] =
|
||||||
"googTypingNoiseDetection";
|
"googTypingNoiseDetection";
|
||||||
const char MediaConstraintsInterface::kAudioMirroring[] = "googAudioMirroring";
|
const char MediaConstraints::kAudioMirroring[] = "googAudioMirroring";
|
||||||
const char MediaConstraintsInterface::kAudioNetworkAdaptorConfig[] =
|
const char MediaConstraints::kAudioNetworkAdaptorConfig[] =
|
||||||
"googAudioNetworkAdaptorConfig";
|
"googAudioNetworkAdaptorConfig";
|
||||||
|
|
||||||
// Constraint keys for CreateOffer / CreateAnswer defined in W3C specification.
|
// Constraint keys for CreateOffer / CreateAnswer defined in W3C specification.
|
||||||
const char MediaConstraintsInterface::kOfferToReceiveAudio[] =
|
const char MediaConstraints::kOfferToReceiveAudio[] = "OfferToReceiveAudio";
|
||||||
"OfferToReceiveAudio";
|
const char MediaConstraints::kOfferToReceiveVideo[] = "OfferToReceiveVideo";
|
||||||
const char MediaConstraintsInterface::kOfferToReceiveVideo[] =
|
const char MediaConstraints::kVoiceActivityDetection[] =
|
||||||
"OfferToReceiveVideo";
|
|
||||||
const char MediaConstraintsInterface::kVoiceActivityDetection[] =
|
|
||||||
"VoiceActivityDetection";
|
"VoiceActivityDetection";
|
||||||
const char MediaConstraintsInterface::kIceRestart[] = "IceRestart";
|
const char MediaConstraints::kIceRestart[] = "IceRestart";
|
||||||
// Google specific constraint for BUNDLE enable/disable.
|
// Google specific constraint for BUNDLE enable/disable.
|
||||||
const char MediaConstraintsInterface::kUseRtpMux[] = "googUseRtpMUX";
|
const char MediaConstraints::kUseRtpMux[] = "googUseRtpMUX";
|
||||||
|
|
||||||
// Below constraints should be used during PeerConnection construction.
|
// Below constraints should be used during PeerConnection construction.
|
||||||
const char MediaConstraintsInterface::kEnableDtlsSrtp[] =
|
const char MediaConstraints::kEnableDtlsSrtp[] = "DtlsSrtpKeyAgreement";
|
||||||
"DtlsSrtpKeyAgreement";
|
const char MediaConstraints::kEnableRtpDataChannels[] = "RtpDataChannels";
|
||||||
const char MediaConstraintsInterface::kEnableRtpDataChannels[] =
|
|
||||||
"RtpDataChannels";
|
|
||||||
// Google-specific constraint keys.
|
// Google-specific constraint keys.
|
||||||
const char MediaConstraintsInterface::kEnableDscp[] = "googDscp";
|
const char MediaConstraints::kEnableDscp[] = "googDscp";
|
||||||
const char MediaConstraintsInterface::kEnableIPv6[] = "googIPv6";
|
const char MediaConstraints::kEnableIPv6[] = "googIPv6";
|
||||||
const char MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate[] =
|
const char MediaConstraints::kEnableVideoSuspendBelowMinBitrate[] =
|
||||||
"googSuspendBelowMinBitrate";
|
"googSuspendBelowMinBitrate";
|
||||||
const char MediaConstraintsInterface::kCombinedAudioVideoBwe[] =
|
const char MediaConstraints::kCombinedAudioVideoBwe[] =
|
||||||
"googCombinedAudioVideoBwe";
|
"googCombinedAudioVideoBwe";
|
||||||
const char MediaConstraintsInterface::kScreencastMinBitrate[] =
|
const char MediaConstraints::kScreencastMinBitrate[] =
|
||||||
"googScreencastMinBitrate";
|
"googScreencastMinBitrate";
|
||||||
// TODO(ronghuawu): Remove once cpu overuse detection is stable.
|
// TODO(ronghuawu): Remove once cpu overuse detection is stable.
|
||||||
const char MediaConstraintsInterface::kCpuOveruseDetection[] =
|
const char MediaConstraints::kCpuOveruseDetection[] = "googCpuOveruseDetection";
|
||||||
"googCpuOveruseDetection";
|
|
||||||
|
|
||||||
const char MediaConstraintsInterface::kNumSimulcastLayers[] =
|
const char MediaConstraints::kNumSimulcastLayers[] = "googNumSimulcastLayers";
|
||||||
"googNumSimulcastLayers";
|
|
||||||
|
|
||||||
// Set |value| to the value associated with the first appearance of |key|, or
|
// Set |value| to the value associated with the first appearance of |key|, or
|
||||||
// return false if |key| is not found.
|
// return false if |key| is not found.
|
||||||
bool MediaConstraintsInterface::Constraints::FindFirst(
|
bool MediaConstraints::Constraints::FindFirst(const std::string& key,
|
||||||
const std::string& key,
|
std::string* value) const {
|
||||||
std::string* value) const {
|
|
||||||
for (Constraints::const_iterator iter = begin(); iter != end(); ++iter) {
|
for (Constraints::const_iterator iter = begin(); iter != end(); ++iter) {
|
||||||
if (iter->key == key) {
|
if (iter->key == key) {
|
||||||
*value = iter->value;
|
*value = iter->value;
|
||||||
|
@ -149,22 +149,8 @@ bool MediaConstraintsInterface::Constraints::FindFirst(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FindConstraint(const MediaConstraintsInterface* constraints,
|
|
||||||
const std::string& key,
|
|
||||||
bool* value,
|
|
||||||
size_t* mandatory_constraints) {
|
|
||||||
return ::FindConstraint<bool>(constraints, key, value, mandatory_constraints);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FindConstraint(const MediaConstraintsInterface* constraints,
|
|
||||||
const std::string& key,
|
|
||||||
int* value,
|
|
||||||
size_t* mandatory_constraints) {
|
|
||||||
return ::FindConstraint<int>(constraints, key, value, mandatory_constraints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CopyConstraintsIntoRtcConfiguration(
|
void CopyConstraintsIntoRtcConfiguration(
|
||||||
const MediaConstraintsInterface* constraints,
|
const MediaConstraints* constraints,
|
||||||
PeerConnectionInterface::RTCConfiguration* configuration) {
|
PeerConnectionInterface::RTCConfiguration* configuration) {
|
||||||
// Copy info from constraints into configuration, if present.
|
// Copy info from constraints into configuration, if present.
|
||||||
if (!constraints) {
|
if (!constraints) {
|
||||||
|
@ -172,72 +158,64 @@ void CopyConstraintsIntoRtcConfiguration(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool enable_ipv6;
|
bool enable_ipv6;
|
||||||
if (FindConstraint(constraints, MediaConstraintsInterface::kEnableIPv6,
|
if (FindConstraint(constraints, MediaConstraints::kEnableIPv6, &enable_ipv6,
|
||||||
&enable_ipv6, nullptr)) {
|
nullptr)) {
|
||||||
configuration->disable_ipv6 = !enable_ipv6;
|
configuration->disable_ipv6 = !enable_ipv6;
|
||||||
}
|
}
|
||||||
FindConstraint(constraints, MediaConstraintsInterface::kEnableDscp,
|
FindConstraint(constraints, MediaConstraints::kEnableDscp,
|
||||||
&configuration->media_config.enable_dscp, nullptr);
|
&configuration->media_config.enable_dscp, nullptr);
|
||||||
FindConstraint(constraints, MediaConstraintsInterface::kCpuOveruseDetection,
|
FindConstraint(constraints, MediaConstraints::kCpuOveruseDetection,
|
||||||
&configuration->media_config.video.enable_cpu_adaptation,
|
&configuration->media_config.video.enable_cpu_adaptation,
|
||||||
nullptr);
|
nullptr);
|
||||||
FindConstraint(constraints, MediaConstraintsInterface::kEnableRtpDataChannels,
|
FindConstraint(constraints, MediaConstraints::kEnableRtpDataChannels,
|
||||||
&configuration->enable_rtp_data_channel, nullptr);
|
&configuration->enable_rtp_data_channel, nullptr);
|
||||||
// Find Suspend Below Min Bitrate constraint.
|
// Find Suspend Below Min Bitrate constraint.
|
||||||
FindConstraint(constraints,
|
FindConstraint(
|
||||||
MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate,
|
constraints, MediaConstraints::kEnableVideoSuspendBelowMinBitrate,
|
||||||
&configuration->media_config.video.suspend_below_min_bitrate,
|
&configuration->media_config.video.suspend_below_min_bitrate, nullptr);
|
||||||
nullptr);
|
|
||||||
ConstraintToOptional<int>(constraints,
|
ConstraintToOptional<int>(constraints,
|
||||||
MediaConstraintsInterface::kScreencastMinBitrate,
|
MediaConstraints::kScreencastMinBitrate,
|
||||||
&configuration->screencast_min_bitrate);
|
&configuration->screencast_min_bitrate);
|
||||||
ConstraintToOptional<bool>(constraints,
|
ConstraintToOptional<bool>(constraints,
|
||||||
MediaConstraintsInterface::kCombinedAudioVideoBwe,
|
MediaConstraints::kCombinedAudioVideoBwe,
|
||||||
&configuration->combined_audio_video_bwe);
|
&configuration->combined_audio_video_bwe);
|
||||||
ConstraintToOptional<bool>(constraints,
|
ConstraintToOptional<bool>(constraints, MediaConstraints::kEnableDtlsSrtp,
|
||||||
MediaConstraintsInterface::kEnableDtlsSrtp,
|
|
||||||
&configuration->enable_dtls_srtp);
|
&configuration->enable_dtls_srtp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyConstraintsIntoAudioOptions(
|
void CopyConstraintsIntoAudioOptions(const MediaConstraints* constraints,
|
||||||
const MediaConstraintsInterface* constraints,
|
cricket::AudioOptions* options) {
|
||||||
cricket::AudioOptions* options) {
|
|
||||||
if (!constraints) {
|
if (!constraints) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstraintToOptional<bool>(constraints,
|
ConstraintToOptional<bool>(constraints,
|
||||||
MediaConstraintsInterface::kGoogEchoCancellation,
|
MediaConstraints::kGoogEchoCancellation,
|
||||||
&options->echo_cancellation);
|
&options->echo_cancellation);
|
||||||
ConstraintToOptional<bool>(
|
|
||||||
constraints, MediaConstraintsInterface::kExtendedFilterEchoCancellation,
|
|
||||||
&options->extended_filter_aec);
|
|
||||||
ConstraintToOptional<bool>(constraints,
|
ConstraintToOptional<bool>(constraints,
|
||||||
MediaConstraintsInterface::kDAEchoCancellation,
|
MediaConstraints::kExtendedFilterEchoCancellation,
|
||||||
|
&options->extended_filter_aec);
|
||||||
|
ConstraintToOptional<bool>(constraints, MediaConstraints::kDAEchoCancellation,
|
||||||
&options->delay_agnostic_aec);
|
&options->delay_agnostic_aec);
|
||||||
ConstraintToOptional<bool>(constraints,
|
ConstraintToOptional<bool>(constraints, MediaConstraints::kAutoGainControl,
|
||||||
MediaConstraintsInterface::kAutoGainControl,
|
|
||||||
&options->auto_gain_control);
|
&options->auto_gain_control);
|
||||||
ConstraintToOptional<bool>(
|
|
||||||
constraints, MediaConstraintsInterface::kExperimentalAutoGainControl,
|
|
||||||
&options->experimental_agc);
|
|
||||||
ConstraintToOptional<bool>(constraints,
|
ConstraintToOptional<bool>(constraints,
|
||||||
MediaConstraintsInterface::kNoiseSuppression,
|
MediaConstraints::kExperimentalAutoGainControl,
|
||||||
|
&options->experimental_agc);
|
||||||
|
ConstraintToOptional<bool>(constraints, MediaConstraints::kNoiseSuppression,
|
||||||
&options->noise_suppression);
|
&options->noise_suppression);
|
||||||
ConstraintToOptional<bool>(
|
|
||||||
constraints, MediaConstraintsInterface::kExperimentalNoiseSuppression,
|
|
||||||
&options->experimental_ns);
|
|
||||||
ConstraintToOptional<bool>(constraints,
|
ConstraintToOptional<bool>(constraints,
|
||||||
MediaConstraintsInterface::kHighpassFilter,
|
MediaConstraints::kExperimentalNoiseSuppression,
|
||||||
|
&options->experimental_ns);
|
||||||
|
ConstraintToOptional<bool>(constraints, MediaConstraints::kHighpassFilter,
|
||||||
&options->highpass_filter);
|
&options->highpass_filter);
|
||||||
ConstraintToOptional<bool>(constraints,
|
ConstraintToOptional<bool>(constraints,
|
||||||
MediaConstraintsInterface::kTypingNoiseDetection,
|
MediaConstraints::kTypingNoiseDetection,
|
||||||
&options->typing_detection);
|
&options->typing_detection);
|
||||||
ConstraintToOptional<bool>(constraints,
|
ConstraintToOptional<bool>(constraints, MediaConstraints::kAudioMirroring,
|
||||||
MediaConstraintsInterface::kAudioMirroring,
|
|
||||||
&options->stereo_swapping);
|
&options->stereo_swapping);
|
||||||
ConstraintToOptional<std::string>(
|
ConstraintToOptional<std::string>(
|
||||||
constraints, MediaConstraintsInterface::kAudioNetworkAdaptorConfig,
|
constraints, MediaConstraints::kAudioNetworkAdaptorConfig,
|
||||||
&options->audio_network_adaptor_config);
|
&options->audio_network_adaptor_config);
|
||||||
// When |kAudioNetworkAdaptorConfig| is defined, it both means that audio
|
// When |kAudioNetworkAdaptorConfig| is defined, it both means that audio
|
||||||
// network adaptor is desired, and provides the config string.
|
// network adaptor is desired, and provides the config string.
|
||||||
|
@ -247,7 +225,7 @@ void CopyConstraintsIntoAudioOptions(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CopyConstraintsIntoOfferAnswerOptions(
|
bool CopyConstraintsIntoOfferAnswerOptions(
|
||||||
const MediaConstraintsInterface* constraints,
|
const MediaConstraints* constraints,
|
||||||
PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options) {
|
PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options) {
|
||||||
if (!constraints) {
|
if (!constraints) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -256,40 +234,36 @@ bool CopyConstraintsIntoOfferAnswerOptions(
|
||||||
bool value = false;
|
bool value = false;
|
||||||
size_t mandatory_constraints_satisfied = 0;
|
size_t mandatory_constraints_satisfied = 0;
|
||||||
|
|
||||||
if (FindConstraint(constraints,
|
if (FindConstraint(constraints, MediaConstraints::kOfferToReceiveAudio,
|
||||||
MediaConstraintsInterface::kOfferToReceiveAudio, &value,
|
&value, &mandatory_constraints_satisfied)) {
|
||||||
&mandatory_constraints_satisfied)) {
|
|
||||||
offer_answer_options->offer_to_receive_audio =
|
offer_answer_options->offer_to_receive_audio =
|
||||||
value ? PeerConnectionInterface::RTCOfferAnswerOptions::
|
value ? PeerConnectionInterface::RTCOfferAnswerOptions::
|
||||||
kOfferToReceiveMediaTrue
|
kOfferToReceiveMediaTrue
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FindConstraint(constraints,
|
if (FindConstraint(constraints, MediaConstraints::kOfferToReceiveVideo,
|
||||||
MediaConstraintsInterface::kOfferToReceiveVideo, &value,
|
&value, &mandatory_constraints_satisfied)) {
|
||||||
&mandatory_constraints_satisfied)) {
|
|
||||||
offer_answer_options->offer_to_receive_video =
|
offer_answer_options->offer_to_receive_video =
|
||||||
value ? PeerConnectionInterface::RTCOfferAnswerOptions::
|
value ? PeerConnectionInterface::RTCOfferAnswerOptions::
|
||||||
kOfferToReceiveMediaTrue
|
kOfferToReceiveMediaTrue
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
if (FindConstraint(constraints,
|
if (FindConstraint(constraints, MediaConstraints::kVoiceActivityDetection,
|
||||||
MediaConstraintsInterface::kVoiceActivityDetection, &value,
|
&value, &mandatory_constraints_satisfied)) {
|
||||||
&mandatory_constraints_satisfied)) {
|
|
||||||
offer_answer_options->voice_activity_detection = value;
|
offer_answer_options->voice_activity_detection = value;
|
||||||
}
|
}
|
||||||
if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value,
|
if (FindConstraint(constraints, MediaConstraints::kUseRtpMux, &value,
|
||||||
&mandatory_constraints_satisfied)) {
|
&mandatory_constraints_satisfied)) {
|
||||||
offer_answer_options->use_rtp_mux = value;
|
offer_answer_options->use_rtp_mux = value;
|
||||||
}
|
}
|
||||||
if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart,
|
if (FindConstraint(constraints, MediaConstraints::kIceRestart, &value,
|
||||||
&value, &mandatory_constraints_satisfied)) {
|
&mandatory_constraints_satisfied)) {
|
||||||
offer_answer_options->ice_restart = value;
|
offer_answer_options->ice_restart = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int layers;
|
int layers;
|
||||||
if (FindConstraint(constraints,
|
if (FindConstraint(constraints, MediaConstraints::kNumSimulcastLayers,
|
||||||
MediaConstraintsInterface::kNumSimulcastLayers,
|
|
||||||
&layers, &mandatory_constraints_satisfied)) {
|
&layers, &mandatory_constraints_satisfied)) {
|
||||||
offer_answer_options->num_simulcast_layers = layers;
|
offer_answer_options->num_simulcast_layers = layers;
|
||||||
}
|
}
|
|
@ -8,21 +8,17 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// This file contains the interface for MediaConstraints, corresponding to
|
|
||||||
// the definition at
|
|
||||||
// http://www.w3.org/TR/mediacapture-streams/#mediastreamconstraints and also
|
|
||||||
// used in WebRTC: http://dev.w3.org/2011/webrtc/editor/webrtc.html#constraints.
|
|
||||||
|
|
||||||
// Implementation of the w3c constraints spec is the responsibility of the
|
// Implementation of the w3c constraints spec is the responsibility of the
|
||||||
// browser. Chrome no longer uses the constraints api declared here, and it will
|
// browser. Chrome no longer uses the constraints api declared here, and it will
|
||||||
// be removed from WebRTC.
|
// be removed from WebRTC.
|
||||||
// https://bugs.chromium.org/p/webrtc/issues/detail?id=9239
|
// https://bugs.chromium.org/p/webrtc/issues/detail?id=9239
|
||||||
|
|
||||||
#ifndef API_MEDIA_CONSTRAINTS_INTERFACE_H_
|
#ifndef SDK_MEDIA_CONSTRAINTS_H_
|
||||||
#define API_MEDIA_CONSTRAINTS_INTERFACE_H_
|
#define SDK_MEDIA_CONSTRAINTS_H_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "api/audio_options.h"
|
#include "api/audio_options.h"
|
||||||
|
@ -30,13 +26,12 @@
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
// Interface used for passing arguments about media constraints
|
// Class representing constraints, as used by the android and objc apis.
|
||||||
// to the MediaStream and PeerConnection implementation.
|
|
||||||
//
|
//
|
||||||
// Constraints may be either "mandatory", which means that unless satisfied,
|
// Constraints may be either "mandatory", which means that unless satisfied,
|
||||||
// the method taking the constraints should fail, or "optional", which means
|
// the method taking the constraints should fail, or "optional", which means
|
||||||
// they may not be satisfied..
|
// they may not be satisfied..
|
||||||
class MediaConstraintsInterface {
|
class MediaConstraints {
|
||||||
public:
|
public:
|
||||||
struct Constraint {
|
struct Constraint {
|
||||||
Constraint() {}
|
Constraint() {}
|
||||||
|
@ -48,9 +43,17 @@ class MediaConstraintsInterface {
|
||||||
|
|
||||||
class Constraints : public std::vector<Constraint> {
|
class Constraints : public std::vector<Constraint> {
|
||||||
public:
|
public:
|
||||||
|
Constraints() = default;
|
||||||
|
Constraints(std::initializer_list<Constraint> l)
|
||||||
|
: std::vector<Constraint>(l) {}
|
||||||
|
|
||||||
bool FindFirst(const std::string& key, std::string* value) const;
|
bool FindFirst(const std::string& key, std::string* value) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MediaConstraints() = default;
|
||||||
|
MediaConstraints(Constraints mandatory, Constraints optional)
|
||||||
|
: mandatory_(std::move(mandatory)), optional_(std::move(optional)) {}
|
||||||
|
|
||||||
// Constraint keys used by a local audio source.
|
// Constraint keys used by a local audio source.
|
||||||
|
|
||||||
// These keys are google specific.
|
// These keys are google specific.
|
||||||
|
@ -104,36 +107,29 @@ class MediaConstraintsInterface {
|
||||||
// (see RTCOfferAnswerOptions::num_simulcast_layers).
|
// (see RTCOfferAnswerOptions::num_simulcast_layers).
|
||||||
static const char kNumSimulcastLayers[];
|
static const char kNumSimulcastLayers[];
|
||||||
|
|
||||||
virtual ~MediaConstraintsInterface() = default;
|
~MediaConstraints() = default;
|
||||||
|
|
||||||
virtual const Constraints& GetMandatory() const = 0;
|
const Constraints& GetMandatory() const { return mandatory_; }
|
||||||
virtual const Constraints& GetOptional() const = 0;
|
const Constraints& GetOptional() const { return optional_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Constraints mandatory_ = {};
|
||||||
|
const Constraints optional_ = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
bool FindConstraint(const MediaConstraintsInterface* constraints,
|
|
||||||
const std::string& key,
|
|
||||||
bool* value,
|
|
||||||
size_t* mandatory_constraints);
|
|
||||||
|
|
||||||
bool FindConstraint(const MediaConstraintsInterface* constraints,
|
|
||||||
const std::string& key,
|
|
||||||
int* value,
|
|
||||||
size_t* mandatory_constraints);
|
|
||||||
|
|
||||||
// Copy all relevant constraints into an RTCConfiguration object.
|
// Copy all relevant constraints into an RTCConfiguration object.
|
||||||
void CopyConstraintsIntoRtcConfiguration(
|
void CopyConstraintsIntoRtcConfiguration(
|
||||||
const MediaConstraintsInterface* constraints,
|
const MediaConstraints* constraints,
|
||||||
PeerConnectionInterface::RTCConfiguration* configuration);
|
PeerConnectionInterface::RTCConfiguration* configuration);
|
||||||
|
|
||||||
// Copy all relevant constraints into an AudioOptions object.
|
// Copy all relevant constraints into an AudioOptions object.
|
||||||
void CopyConstraintsIntoAudioOptions(
|
void CopyConstraintsIntoAudioOptions(const MediaConstraints* constraints,
|
||||||
const MediaConstraintsInterface* constraints,
|
cricket::AudioOptions* options);
|
||||||
cricket::AudioOptions* options);
|
|
||||||
|
|
||||||
bool CopyConstraintsIntoOfferAnswerOptions(
|
bool CopyConstraintsIntoOfferAnswerOptions(
|
||||||
const MediaConstraintsInterface* constraints,
|
const MediaConstraints* constraints,
|
||||||
PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options);
|
PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options);
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // API_MEDIA_CONSTRAINTS_INTERFACE_H_
|
#endif // SDK_MEDIA_CONSTRAINTS_H_
|
|
@ -8,11 +8,8 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "api/media_constraints_interface.h"
|
#include "sdk/media_constraints.h"
|
||||||
|
|
||||||
#include "absl/types/optional.h"
|
|
||||||
#include "api/test/fake_constraints.h"
|
|
||||||
#include "media/base/media_config.h"
|
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
@ -33,34 +30,40 @@ bool Matches(const PeerConnectionInterface::RTCConfiguration& a,
|
||||||
a.media_config == b.media_config;
|
a.media_config == b.media_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MediaConstraintsInterface, CopyConstraintsIntoRtcConfiguration) {
|
TEST(MediaConstraints, CopyConstraintsIntoRtcConfiguration) {
|
||||||
FakeConstraints constraints;
|
const MediaConstraints constraints_empty;
|
||||||
PeerConnectionInterface::RTCConfiguration old_configuration;
|
PeerConnectionInterface::RTCConfiguration old_configuration;
|
||||||
PeerConnectionInterface::RTCConfiguration configuration;
|
PeerConnectionInterface::RTCConfiguration configuration;
|
||||||
|
|
||||||
CopyConstraintsIntoRtcConfiguration(&constraints, &configuration);
|
CopyConstraintsIntoRtcConfiguration(&constraints_empty, &configuration);
|
||||||
EXPECT_TRUE(Matches(old_configuration, configuration));
|
EXPECT_TRUE(Matches(old_configuration, configuration));
|
||||||
|
|
||||||
constraints.SetMandatory(MediaConstraintsInterface::kEnableIPv6, "true");
|
const MediaConstraints constraits_enable_ipv6(
|
||||||
CopyConstraintsIntoRtcConfiguration(&constraints, &configuration);
|
{MediaConstraints::Constraint(MediaConstraints::kEnableIPv6, "true")},
|
||||||
|
{});
|
||||||
|
CopyConstraintsIntoRtcConfiguration(&constraits_enable_ipv6, &configuration);
|
||||||
EXPECT_FALSE(configuration.disable_ipv6);
|
EXPECT_FALSE(configuration.disable_ipv6);
|
||||||
constraints.SetMandatory(MediaConstraintsInterface::kEnableIPv6, "false");
|
const MediaConstraints constraints_disable_ipv6(
|
||||||
CopyConstraintsIntoRtcConfiguration(&constraints, &configuration);
|
{MediaConstraints::Constraint(MediaConstraints::kEnableIPv6, "false")},
|
||||||
|
{});
|
||||||
|
CopyConstraintsIntoRtcConfiguration(&constraints_disable_ipv6,
|
||||||
|
&configuration);
|
||||||
EXPECT_TRUE(configuration.disable_ipv6);
|
EXPECT_TRUE(configuration.disable_ipv6);
|
||||||
|
|
||||||
constraints.SetMandatory(MediaConstraintsInterface::kScreencastMinBitrate,
|
const MediaConstraints constraints_screencast(
|
||||||
27);
|
{MediaConstraints::Constraint(MediaConstraints::kScreencastMinBitrate,
|
||||||
CopyConstraintsIntoRtcConfiguration(&constraints, &configuration);
|
"27")},
|
||||||
|
{});
|
||||||
|
CopyConstraintsIntoRtcConfiguration(&constraints_screencast, &configuration);
|
||||||
EXPECT_TRUE(configuration.screencast_min_bitrate);
|
EXPECT_TRUE(configuration.screencast_min_bitrate);
|
||||||
EXPECT_EQ(27, *(configuration.screencast_min_bitrate));
|
EXPECT_EQ(27, *(configuration.screencast_min_bitrate));
|
||||||
|
|
||||||
// An empty set of constraints will not overwrite
|
// An empty set of constraints will not overwrite
|
||||||
// values that are already present.
|
// values that are already present.
|
||||||
constraints = FakeConstraints();
|
|
||||||
configuration = old_configuration;
|
configuration = old_configuration;
|
||||||
configuration.enable_dtls_srtp = true;
|
configuration.enable_dtls_srtp = true;
|
||||||
configuration.audio_jitter_buffer_max_packets = 34;
|
configuration.audio_jitter_buffer_max_packets = 34;
|
||||||
CopyConstraintsIntoRtcConfiguration(&constraints, &configuration);
|
CopyConstraintsIntoRtcConfiguration(&constraints_empty, &configuration);
|
||||||
EXPECT_EQ(34, configuration.audio_jitter_buffer_max_packets);
|
EXPECT_EQ(34, configuration.audio_jitter_buffer_max_packets);
|
||||||
ASSERT_TRUE(configuration.enable_dtls_srtp);
|
ASSERT_TRUE(configuration.enable_dtls_srtp);
|
||||||
EXPECT_TRUE(*(configuration.enable_dtls_srtp));
|
EXPECT_TRUE(*(configuration.enable_dtls_srtp));
|
|
@ -12,25 +12,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/media_constraints_interface.h"
|
#include "sdk/media_constraints.h"
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
class MediaConstraints : public MediaConstraintsInterface {
|
|
||||||
public:
|
|
||||||
~MediaConstraints() override;
|
|
||||||
MediaConstraints();
|
|
||||||
MediaConstraints(const MediaConstraintsInterface::Constraints& mandatory,
|
|
||||||
const MediaConstraintsInterface::Constraints& optional);
|
|
||||||
const Constraints& GetMandatory() const override;
|
|
||||||
const Constraints& GetOptional() const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
MediaConstraintsInterface::Constraints mandatory_;
|
|
||||||
MediaConstraintsInterface::Constraints optional_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@ -43,8 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
- (std::unique_ptr<webrtc::MediaConstraints>)nativeConstraints;
|
- (std::unique_ptr<webrtc::MediaConstraints>)nativeConstraints;
|
||||||
|
|
||||||
/** Return a native Constraints object representing these constraints */
|
/** Return a native Constraints object representing these constraints */
|
||||||
+ (webrtc::MediaConstraintsInterface::Constraints)nativeConstraintsForConstraints:
|
+ (webrtc::MediaConstraints::Constraints)nativeConstraintsForConstraints:
|
||||||
(NSDictionary<NSString*, NSString*>*)constraints;
|
(NSDictionary<NSString*, NSString*>*)constraints;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -14,46 +14,19 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
NSString * const kRTCMediaConstraintsAudioNetworkAdaptorConfig =
|
NSString *const kRTCMediaConstraintsAudioNetworkAdaptorConfig =
|
||||||
@(webrtc::MediaConstraintsInterface::kAudioNetworkAdaptorConfig);
|
@(webrtc::MediaConstraints::kAudioNetworkAdaptorConfig);
|
||||||
|
|
||||||
NSString * const kRTCMediaConstraintsIceRestart =
|
NSString *const kRTCMediaConstraintsIceRestart = @(webrtc::MediaConstraints::kIceRestart);
|
||||||
@(webrtc::MediaConstraintsInterface::kIceRestart);
|
NSString *const kRTCMediaConstraintsOfferToReceiveAudio =
|
||||||
NSString * const kRTCMediaConstraintsOfferToReceiveAudio =
|
@(webrtc::MediaConstraints::kOfferToReceiveAudio);
|
||||||
@(webrtc::MediaConstraintsInterface::kOfferToReceiveAudio);
|
NSString *const kRTCMediaConstraintsOfferToReceiveVideo =
|
||||||
NSString * const kRTCMediaConstraintsOfferToReceiveVideo =
|
@(webrtc::MediaConstraints::kOfferToReceiveVideo);
|
||||||
@(webrtc::MediaConstraintsInterface::kOfferToReceiveVideo);
|
NSString *const kRTCMediaConstraintsVoiceActivityDetection =
|
||||||
NSString * const kRTCMediaConstraintsVoiceActivityDetection =
|
@(webrtc::MediaConstraints::kVoiceActivityDetection);
|
||||||
@(webrtc::MediaConstraintsInterface::kVoiceActivityDetection);
|
|
||||||
|
|
||||||
NSString * const kRTCMediaConstraintsValueTrue =
|
|
||||||
@(webrtc::MediaConstraintsInterface::kValueTrue);
|
|
||||||
NSString * const kRTCMediaConstraintsValueFalse =
|
|
||||||
@(webrtc::MediaConstraintsInterface::kValueFalse);
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
MediaConstraints::~MediaConstraints() {}
|
|
||||||
|
|
||||||
MediaConstraints::MediaConstraints() {}
|
|
||||||
|
|
||||||
MediaConstraints::MediaConstraints(
|
|
||||||
const MediaConstraintsInterface::Constraints& mandatory,
|
|
||||||
const MediaConstraintsInterface::Constraints& optional)
|
|
||||||
: mandatory_(mandatory), optional_(optional) {}
|
|
||||||
|
|
||||||
const MediaConstraintsInterface::Constraints&
|
|
||||||
MediaConstraints::GetMandatory() const {
|
|
||||||
return mandatory_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MediaConstraintsInterface::Constraints&
|
|
||||||
MediaConstraints::GetOptional() const {
|
|
||||||
return optional_;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
|
NSString *const kRTCMediaConstraintsValueTrue = @(webrtc::MediaConstraints::kValueTrue);
|
||||||
|
NSString *const kRTCMediaConstraintsValueFalse = @(webrtc::MediaConstraints::kValueFalse);
|
||||||
|
|
||||||
@implementation RTCMediaConstraints {
|
@implementation RTCMediaConstraints {
|
||||||
NSDictionary<NSString *, NSString *> *_mandatory;
|
NSDictionary<NSString *, NSString *> *_mandatory;
|
||||||
|
@ -82,9 +55,9 @@ MediaConstraints::GetOptional() const {
|
||||||
#pragma mark - Private
|
#pragma mark - Private
|
||||||
|
|
||||||
- (std::unique_ptr<webrtc::MediaConstraints>)nativeConstraints {
|
- (std::unique_ptr<webrtc::MediaConstraints>)nativeConstraints {
|
||||||
webrtc::MediaConstraintsInterface::Constraints mandatory =
|
webrtc::MediaConstraints::Constraints mandatory =
|
||||||
[[self class] nativeConstraintsForConstraints:_mandatory];
|
[[self class] nativeConstraintsForConstraints:_mandatory];
|
||||||
webrtc::MediaConstraintsInterface::Constraints optional =
|
webrtc::MediaConstraints::Constraints optional =
|
||||||
[[self class] nativeConstraintsForConstraints:_optional];
|
[[self class] nativeConstraintsForConstraints:_optional];
|
||||||
|
|
||||||
webrtc::MediaConstraints *nativeConstraints =
|
webrtc::MediaConstraints *nativeConstraints =
|
||||||
|
@ -92,10 +65,9 @@ MediaConstraints::GetOptional() const {
|
||||||
return std::unique_ptr<webrtc::MediaConstraints>(nativeConstraints);
|
return std::unique_ptr<webrtc::MediaConstraints>(nativeConstraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (webrtc::MediaConstraintsInterface::Constraints)
|
+ (webrtc::MediaConstraints::Constraints)nativeConstraintsForConstraints:
|
||||||
nativeConstraintsForConstraints:
|
(NSDictionary<NSString *, NSString *> *)constraints {
|
||||||
(NSDictionary<NSString *, NSString *> *)constraints {
|
webrtc::MediaConstraints::Constraints nativeConstraints;
|
||||||
webrtc::MediaConstraintsInterface::Constraints nativeConstraints;
|
|
||||||
for (NSString *key in constraints) {
|
for (NSString *key in constraints) {
|
||||||
NSAssert([key isKindOfClass:[NSString class]],
|
NSAssert([key isKindOfClass:[NSString class]],
|
||||||
@"%@ is not an NSString.", key);
|
@"%@ is not an NSString.", key);
|
||||||
|
@ -107,11 +79,10 @@ MediaConstraints::GetOptional() const {
|
||||||
NSData *charData = [[NSData alloc] initWithBase64EncodedString:value options:0];
|
NSData *charData = [[NSData alloc] initWithBase64EncodedString:value options:0];
|
||||||
std::string configValue =
|
std::string configValue =
|
||||||
std::string(reinterpret_cast<const char *>(charData.bytes), charData.length);
|
std::string(reinterpret_cast<const char *>(charData.bytes), charData.length);
|
||||||
nativeConstraints.push_back(webrtc::MediaConstraintsInterface::Constraint(
|
nativeConstraints.push_back(webrtc::MediaConstraints::Constraint(key.stdString, configValue));
|
||||||
key.stdString, configValue));
|
|
||||||
} else {
|
} else {
|
||||||
nativeConstraints.push_back(webrtc::MediaConstraintsInterface::Constraint(
|
nativeConstraints.push_back(
|
||||||
key.stdString, value.stdString));
|
webrtc::MediaConstraints::Constraint(key.stdString, value.stdString));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nativeConstraints;
|
return nativeConstraints;
|
||||||
|
|
|
@ -34,18 +34,15 @@
|
||||||
std::unique_ptr<webrtc::MediaConstraints> nativeConstraints =
|
std::unique_ptr<webrtc::MediaConstraints> nativeConstraints =
|
||||||
[constraints nativeConstraints];
|
[constraints nativeConstraints];
|
||||||
|
|
||||||
webrtc::MediaConstraintsInterface::Constraints nativeMandatory =
|
webrtc::MediaConstraints::Constraints nativeMandatory = nativeConstraints->GetMandatory();
|
||||||
nativeConstraints->GetMandatory();
|
|
||||||
[self expectConstraints:mandatory inNativeConstraints:nativeMandatory];
|
[self expectConstraints:mandatory inNativeConstraints:nativeMandatory];
|
||||||
|
|
||||||
webrtc::MediaConstraintsInterface::Constraints nativeOptional =
|
webrtc::MediaConstraints::Constraints nativeOptional = nativeConstraints->GetOptional();
|
||||||
nativeConstraints->GetOptional();
|
|
||||||
[self expectConstraints:optional inNativeConstraints:nativeOptional];
|
[self expectConstraints:optional inNativeConstraints:nativeOptional];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)expectConstraints:(NSDictionary *)constraints
|
- (void)expectConstraints:(NSDictionary *)constraints
|
||||||
inNativeConstraints:
|
inNativeConstraints:(webrtc::MediaConstraints::Constraints)nativeConstraints {
|
||||||
(webrtc::MediaConstraintsInterface::Constraints)nativeConstraints {
|
|
||||||
EXPECT_EQ(constraints.count, nativeConstraints.size());
|
EXPECT_EQ(constraints.count, nativeConstraints.size());
|
||||||
|
|
||||||
for (NSString *key in constraints) {
|
for (NSString *key in constraints) {
|
||||||
|
|
Loading…
Reference in a new issue