Commit c9db0ad3 authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

[RTCInsertableStreams] Propagate configuration to RTCPeerConnection

This CL propagates the insertable streams configuration fields from
RTCConfiguration to RTCPeerConnection and RTCPeerConnectionHandler.
These will be used in follow-up CLs to initialize senders and receivers.

Bug: 1052765
Change-Id: If510641f91e6ce7c0ac7fbde1f0aa2d0c94d3e7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066850
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarHarald Alvestrand <hta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744674}
parent ef3591b5
...@@ -139,13 +139,17 @@ PeerConnectionDependencyFactory::GetInstance() { ...@@ -139,13 +139,17 @@ PeerConnectionDependencyFactory::GetInstance() {
std::unique_ptr<RTCPeerConnectionHandlerPlatform> std::unique_ptr<RTCPeerConnectionHandlerPlatform>
PeerConnectionDependencyFactory::CreateRTCPeerConnectionHandler( PeerConnectionDependencyFactory::CreateRTCPeerConnectionHandler(
RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient* client,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { scoped_refptr<base::SingleThreadTaskRunner> task_runner,
bool force_encoded_audio_insertable_streams,
bool force_encoded_video_insertable_streams) {
// Save histogram data so we can see how much PeerConnection is used. // Save histogram data so we can see how much PeerConnection is used.
// The histogram counts the number of calls to the JS API // The histogram counts the number of calls to the JS API
// RTCPeerConnection. // RTCPeerConnection.
UpdateWebRTCMethodCount(RTCAPIName::kRTCPeerConnection); UpdateWebRTCMethodCount(RTCAPIName::kRTCPeerConnection);
return std::make_unique<RTCPeerConnectionHandler>(client, this, task_runner); return std::make_unique<RTCPeerConnectionHandler>(
client, this, task_runner, force_encoded_audio_insertable_streams,
force_encoded_video_insertable_streams);
} }
const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& const scoped_refptr<webrtc::PeerConnectionFactoryInterface>&
......
...@@ -56,7 +56,9 @@ class MODULES_EXPORT PeerConnectionDependencyFactory ...@@ -56,7 +56,9 @@ class MODULES_EXPORT PeerConnectionDependencyFactory
std::unique_ptr<RTCPeerConnectionHandlerPlatform> std::unique_ptr<RTCPeerConnectionHandlerPlatform>
CreateRTCPeerConnectionHandler( CreateRTCPeerConnectionHandler(
RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient* client,
scoped_refptr<base::SingleThreadTaskRunner> task_runner); scoped_refptr<base::SingleThreadTaskRunner> task_runner,
bool force_encoded_audio_insertable_streams,
bool force_encoded_video_insertable_streams);
// Create a proxy object for a VideoTrackSource that makes sure it's called on // Create a proxy object for a VideoTrackSource that makes sure it's called on
// the correct threads. // the correct threads.
......
...@@ -25,8 +25,9 @@ TEST_F(PeerConnectionDependencyFactoryTest, CreateRTCPeerConnectionHandler) { ...@@ -25,8 +25,9 @@ TEST_F(PeerConnectionDependencyFactoryTest, CreateRTCPeerConnectionHandler) {
MockRTCPeerConnectionHandlerClient client_jsep; MockRTCPeerConnectionHandlerClient client_jsep;
std::unique_ptr<RTCPeerConnectionHandlerPlatform> pc_handler( std::unique_ptr<RTCPeerConnectionHandlerPlatform> pc_handler(
dependency_factory_->CreateRTCPeerConnectionHandler( dependency_factory_->CreateRTCPeerConnectionHandler(
&client_jsep, &client_jsep, blink::scheduler::GetSingleThreadTaskRunnerForTesting(),
blink::scheduler::GetSingleThreadTaskRunnerForTesting())); /*force_encoded_audio_insertable_streams=*/false,
/*force_encoded_video_insertable_streams=*/false));
EXPECT_TRUE(pc_handler); EXPECT_TRUE(pc_handler);
} }
......
...@@ -123,7 +123,9 @@ class MockPeerConnectionHandler : public RTCPeerConnectionHandler { ...@@ -123,7 +123,9 @@ class MockPeerConnectionHandler : public RTCPeerConnectionHandler {
: RTCPeerConnectionHandler( : RTCPeerConnectionHandler(
&client_, &client_,
&dependency_factory_, &dependency_factory_,
blink::scheduler::GetSingleThreadTaskRunnerForTesting()) {} blink::scheduler::GetSingleThreadTaskRunnerForTesting(),
/*force_encoded_audio_insertable_streams=*/false,
/*force_encoded_video_insertable_streams=*/false) {}
MOCK_METHOD0(CloseClientPeerConnection, void()); MOCK_METHOD0(CloseClientPeerConnection, void());
private: private:
......
...@@ -689,7 +689,9 @@ RTCPeerConnection* RTCPeerConnection::Create( ...@@ -689,7 +689,9 @@ RTCPeerConnection* RTCPeerConnection::Create(
RTCPeerConnection* peer_connection = MakeGarbageCollected<RTCPeerConnection>( RTCPeerConnection* peer_connection = MakeGarbageCollected<RTCPeerConnection>(
context, std::move(configuration), rtc_configuration->hasSdpSemantics(), context, std::move(configuration), rtc_configuration->hasSdpSemantics(),
constraints, exception_state); rtc_configuration->forceEncodedAudioInsertableStreams(),
rtc_configuration->forceEncodedVideoInsertableStreams(), constraints,
exception_state);
if (exception_state.HadException()) if (exception_state.HadException())
return nullptr; return nullptr;
...@@ -728,6 +730,8 @@ RTCPeerConnection::RTCPeerConnection( ...@@ -728,6 +730,8 @@ RTCPeerConnection::RTCPeerConnection(
ExecutionContext* context, ExecutionContext* context,
webrtc::PeerConnectionInterface::RTCConfiguration configuration, webrtc::PeerConnectionInterface::RTCConfiguration configuration,
bool sdp_semantics_specified, bool sdp_semantics_specified,
bool force_encoded_audio_insertable_streams,
bool force_encoded_video_insertable_streams,
MediaConstraints constraints, MediaConstraints constraints,
ExceptionState& exception_state) ExceptionState& exception_state)
: ExecutionContextLifecycleObserver(context), : ExecutionContextLifecycleObserver(context),
...@@ -745,7 +749,11 @@ RTCPeerConnection::RTCPeerConnection( ...@@ -745,7 +749,11 @@ RTCPeerConnection::RTCPeerConnection(
sdp_semantics_specified_(sdp_semantics_specified), sdp_semantics_specified_(sdp_semantics_specified),
blink_webrtc_time_diff_( blink_webrtc_time_diff_(
base::TimeTicks::Now() - base::TimeTicks() - base::TimeTicks::Now() - base::TimeTicks() -
base::TimeDelta::FromMicroseconds(rtc::TimeMicros())) { base::TimeDelta::FromMicroseconds(rtc::TimeMicros())),
force_encoded_audio_insertable_streams_(
force_encoded_audio_insertable_streams),
force_encoded_video_insertable_streams_(
force_encoded_video_insertable_streams) {
Document* document = Document::From(GetExecutionContext()); Document* document = Document::From(GetExecutionContext());
InstanceCounters::IncrementCounter( InstanceCounters::IncrementCounter(
...@@ -777,7 +785,9 @@ RTCPeerConnection::RTCPeerConnection( ...@@ -777,7 +785,9 @@ RTCPeerConnection::RTCPeerConnection(
peer_handler_ = peer_handler_ =
PeerConnectionDependencyFactory::GetInstance() PeerConnectionDependencyFactory::GetInstance()
->CreateRTCPeerConnectionHandler( ->CreateRTCPeerConnectionHandler(
this, document->GetTaskRunner(TaskType::kInternalMedia)); this, document->GetTaskRunner(TaskType::kInternalMedia),
force_encoded_audio_insertable_streams_,
force_encoded_video_insertable_streams_);
} }
if (!peer_handler_) { if (!peer_handler_) {
......
...@@ -134,6 +134,8 @@ class MODULES_EXPORT RTCPeerConnection final ...@@ -134,6 +134,8 @@ class MODULES_EXPORT RTCPeerConnection final
RTCPeerConnection(ExecutionContext*, RTCPeerConnection(ExecutionContext*,
webrtc::PeerConnectionInterface::RTCConfiguration, webrtc::PeerConnectionInterface::RTCConfiguration,
bool sdp_semantics_specified, bool sdp_semantics_specified,
bool force_encoded_audio_insertable_streams,
bool force_encoded_video_insertable_streams,
MediaConstraints, MediaConstraints,
ExceptionState&); ExceptionState&);
~RTCPeerConnection() override; ~RTCPeerConnection() override;
...@@ -399,6 +401,14 @@ class MODULES_EXPORT RTCPeerConnection final ...@@ -399,6 +401,14 @@ class MODULES_EXPORT RTCPeerConnection final
webrtc::SdpSemantics sdp_semantics() { return sdp_semantics_; } webrtc::SdpSemantics sdp_semantics() { return sdp_semantics_; }
bool force_encoded_audio_insertable_streams() {
return force_encoded_audio_insertable_streams_;
}
bool force_encoded_video_insertable_streams() {
return force_encoded_video_insertable_streams_;
}
void Trace(Visitor*) override; void Trace(Visitor*) override;
base::TimeTicks WebRtcTimestampToBlinkTimestamp( base::TimeTicks WebRtcTimestampToBlinkTimestamp(
...@@ -623,6 +633,10 @@ class MODULES_EXPORT RTCPeerConnection final ...@@ -623,6 +633,10 @@ class MODULES_EXPORT RTCPeerConnection final
// Blink and WebRTC timestamp diff. // Blink and WebRTC timestamp diff.
const base::TimeDelta blink_webrtc_time_diff_; const base::TimeDelta blink_webrtc_time_diff_;
// Insertable streams.
bool force_encoded_audio_insertable_streams_;
bool force_encoded_video_insertable_streams_;
}; };
} // namespace blink } // namespace blink
......
...@@ -1057,7 +1057,9 @@ class RTCPeerConnectionHandler::Observer ...@@ -1057,7 +1057,9 @@ class RTCPeerConnectionHandler::Observer
RTCPeerConnectionHandler::RTCPeerConnectionHandler( RTCPeerConnectionHandler::RTCPeerConnectionHandler(
RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient* client,
blink::PeerConnectionDependencyFactory* dependency_factory, blink::PeerConnectionDependencyFactory* dependency_factory,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) scoped_refptr<base::SingleThreadTaskRunner> task_runner,
bool force_encoded_audio_insertable_streams,
bool force_encoded_video_insertable_streams)
: initialize_called_(false), : initialize_called_(false),
client_(client), client_(client),
is_closed_(false), is_closed_(false),
...@@ -1066,6 +1068,10 @@ RTCPeerConnectionHandler::RTCPeerConnectionHandler( ...@@ -1066,6 +1068,10 @@ RTCPeerConnectionHandler::RTCPeerConnectionHandler(
base::MakeRefCounted<blink::WebRtcMediaStreamTrackAdapterMap>( base::MakeRefCounted<blink::WebRtcMediaStreamTrackAdapterMap>(
dependency_factory_, dependency_factory_,
task_runner)), task_runner)),
force_encoded_audio_insertable_streams_(
force_encoded_audio_insertable_streams),
force_encoded_video_insertable_streams_(
force_encoded_video_insertable_streams),
task_runner_(std::move(task_runner)) { task_runner_(std::move(task_runner)) {
CHECK(client_); CHECK(client_);
......
...@@ -90,7 +90,9 @@ class MODULES_EXPORT RTCPeerConnectionHandler ...@@ -90,7 +90,9 @@ class MODULES_EXPORT RTCPeerConnectionHandler
RTCPeerConnectionHandler( RTCPeerConnectionHandler(
RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient* client,
blink::PeerConnectionDependencyFactory* dependency_factory, blink::PeerConnectionDependencyFactory* dependency_factory,
scoped_refptr<base::SingleThreadTaskRunner> task_runner); scoped_refptr<base::SingleThreadTaskRunner> task_runner,
bool force_encoded_audio_insertable_streams,
bool force_encoded_video_insertable_streams);
~RTCPeerConnectionHandler() override; ~RTCPeerConnectionHandler() override;
// Initialize method only used for unit test. // Initialize method only used for unit test.
...@@ -197,6 +199,14 @@ class MODULES_EXPORT RTCPeerConnectionHandler ...@@ -197,6 +199,14 @@ class MODULES_EXPORT RTCPeerConnectionHandler
// WebRTC event log fragments sent back from PeerConnection land here. // WebRTC event log fragments sent back from PeerConnection land here.
void OnWebRtcEventLogWrite(const WTF::Vector<uint8_t>& output); void OnWebRtcEventLogWrite(const WTF::Vector<uint8_t>& output);
bool force_encoded_audio_insertable_streams() {
return force_encoded_audio_insertable_streams_;
}
bool force_encoded_video_insertable_streams() {
return force_encoded_video_insertable_streams_;
}
protected: protected:
webrtc::PeerConnectionInterface* native_peer_connection() { webrtc::PeerConnectionInterface* native_peer_connection() {
return native_peer_connection_.get(); return native_peer_connection_.get();
...@@ -403,6 +413,8 @@ class MODULES_EXPORT RTCPeerConnectionHandler ...@@ -403,6 +413,8 @@ class MODULES_EXPORT RTCPeerConnectionHandler
// used when constructing the PeerConnection carry over when // used when constructing the PeerConnection carry over when
// SetConfiguration is called. // SetConfiguration is called.
webrtc::PeerConnectionInterface::RTCConfiguration configuration_; webrtc::PeerConnectionInterface::RTCConfiguration configuration_;
bool force_encoded_audio_insertable_streams_;
bool force_encoded_video_insertable_streams_;
// Record info about the first SessionDescription from the local and // Record info about the first SessionDescription from the local and
// remote side to record UMA stats once both are set. We only check // remote side to record UMA stats once both are set. We only check
......
...@@ -254,11 +254,15 @@ class RTCPeerConnectionHandlerUnderTest : public RTCPeerConnectionHandler { ...@@ -254,11 +254,15 @@ class RTCPeerConnectionHandlerUnderTest : public RTCPeerConnectionHandler {
public: public:
RTCPeerConnectionHandlerUnderTest( RTCPeerConnectionHandlerUnderTest(
RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient* client,
blink::PeerConnectionDependencyFactory* dependency_factory) blink::PeerConnectionDependencyFactory* dependency_factory,
bool force_encoded_audio_insertable_streams = false,
bool force_encoded_video_insertable_streams = false)
: RTCPeerConnectionHandler( : RTCPeerConnectionHandler(
client, client,
dependency_factory, dependency_factory,
blink::scheduler::GetSingleThreadTaskRunnerForTesting()) {} blink::scheduler::GetSingleThreadTaskRunnerForTesting(),
force_encoded_audio_insertable_streams,
force_encoded_video_insertable_streams) {}
blink::MockPeerConnectionImpl* native_peer_connection() { blink::MockPeerConnectionImpl* native_peer_connection() {
return static_cast<blink::MockPeerConnectionImpl*>( return static_cast<blink::MockPeerConnectionImpl*>(
...@@ -1273,4 +1277,19 @@ TEST_F(RTCPeerConnectionHandlerTest, CreateDataChannel) { ...@@ -1273,4 +1277,19 @@ TEST_F(RTCPeerConnectionHandlerTest, CreateDataChannel) {
EXPECT_EQ(label.Utf8(), channel->label()); EXPECT_EQ(label.Utf8(), channel->label());
} }
TEST_F(RTCPeerConnectionHandlerTest, CheckInsertableStreamsConfig) {
for (bool force_encoded_audio_insertable_streams : {true, false}) {
for (bool force_encoded_video_insertable_streams : {true, false}) {
auto handler = std::make_unique<RTCPeerConnectionHandlerUnderTest>(
mock_client_.get(), mock_dependency_factory_.get(),
force_encoded_audio_insertable_streams,
force_encoded_video_insertable_streams);
EXPECT_EQ(handler->force_encoded_audio_insertable_streams(),
force_encoded_audio_insertable_streams);
EXPECT_EQ(handler->force_encoded_video_insertable_streams(),
force_encoded_video_insertable_streams);
}
}
}
} // namespace blink } // namespace blink
...@@ -379,10 +379,17 @@ static const char* kOfferSdpPlanBMultipleAudioTracks = ...@@ -379,10 +379,17 @@ static const char* kOfferSdpPlanBMultipleAudioTracks =
class RTCPeerConnectionTest : public testing::Test { class RTCPeerConnectionTest : public testing::Test {
public: public:
RTCPeerConnection* CreatePC(V8TestingScope& scope, RTCPeerConnection* CreatePC(
const String& sdpSemantics = String()) { V8TestingScope& scope,
const String& sdpSemantics = String(),
bool force_encoded_audio_insertable_streams = false,
bool force_encoded_video_insertable_streams = false) {
RTCConfiguration* config = RTCConfiguration::Create(); RTCConfiguration* config = RTCConfiguration::Create();
config->setSdpSemantics(sdpSemantics); config->setSdpSemantics(sdpSemantics);
config->setForceEncodedAudioInsertableStreams(
force_encoded_audio_insertable_streams);
config->setForceEncodedVideoInsertableStreams(
force_encoded_video_insertable_streams);
RTCIceServer* ice_server = RTCIceServer::Create(); RTCIceServer* ice_server = RTCIceServer::Create();
ice_server->setUrl("stun:fake.stun.url"); ice_server->setUrl("stun:fake.stun.url");
HeapVector<Member<RTCIceServer>> ice_servers; HeapVector<Member<RTCIceServer>> ice_servers;
...@@ -643,6 +650,21 @@ TEST_F(RTCPeerConnectionTest, CheckForComplexSdpWithSdpSemanticsUnspecified) { ...@@ -643,6 +650,21 @@ TEST_F(RTCPeerConnectionTest, CheckForComplexSdpWithSdpSemanticsUnspecified) {
ASSERT_FALSE(pc->CheckForComplexSdp(sdp).has_value()); ASSERT_FALSE(pc->CheckForComplexSdp(sdp).has_value());
} }
TEST_F(RTCPeerConnectionTest, CheckInsertableStreamsConfig) {
for (bool force_encoded_audio_insertable_streams : {true, false}) {
for (bool force_encoded_video_insertable_streams : {true, false}) {
V8TestingScope scope;
Persistent<RTCPeerConnection> pc =
CreatePC(scope, String(), force_encoded_audio_insertable_streams,
force_encoded_video_insertable_streams);
EXPECT_EQ(pc->force_encoded_audio_insertable_streams(),
force_encoded_audio_insertable_streams);
EXPECT_EQ(pc->force_encoded_video_insertable_streams(),
force_encoded_video_insertable_streams);
}
}
}
enum class AsyncOperationAction { enum class AsyncOperationAction {
kLeavePending, kLeavePending,
kResolve, kResolve,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment