Commit ad3996ca authored by Florent Castelli's avatar Florent Castelli Committed by Commit Bot

Onion-soup WebRTCConfiguration to matching WebRTC type

Also moved the translation from default sdp semantics and its counter
to the PeerConnection from the handler.

Bug: 787254
Change-Id: Iea26f6500ebcdfdeb862596861580b21c9eba903
Reviewed-on: https://chromium-review.googlesource.com/1177754Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Florent Castelli <orphis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584713}
parent f92191b7
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "content/renderer/media/webrtc/webrtc_media_stream_track_adapter_map.h" #include "content/renderer/media/webrtc/webrtc_media_stream_track_adapter_map.h"
#include "ipc/ipc_platform_file.h" #include "ipc/ipc_platform_file.h"
#include "third_party/blink/public/platform/web_media_stream_source.h" #include "third_party/blink/public/platform/web_media_stream_source.h"
#include "third_party/blink/public/platform/web_rtc_configuration.h"
#include "third_party/blink/public/platform/web_rtc_peer_connection_handler.h" #include "third_party/blink/public/platform/web_rtc_peer_connection_handler.h"
#include "third_party/blink/public/platform/web_rtc_stats_request.h" #include "third_party/blink/public/platform/web_rtc_stats_request.h"
#include "third_party/blink/public/platform/web_rtc_stats_response.h" #include "third_party/blink/public/platform/web_rtc_stats_response.h"
...@@ -103,15 +102,15 @@ class CONTENT_EXPORT RTCPeerConnectionHandler ...@@ -103,15 +102,15 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
// Initialize method only used for unit test. // Initialize method only used for unit test.
bool InitializeForTest( bool InitializeForTest(
const blink::WebRTCConfiguration& server_configuration, const webrtc::PeerConnectionInterface::RTCConfiguration&
server_configuration,
const blink::WebMediaConstraints& options, const blink::WebMediaConstraints& options,
const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker); const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker);
// blink::WebRTCPeerConnectionHandler implementation // blink::WebRTCPeerConnectionHandler implementation
bool Initialize( bool Initialize(const webrtc::PeerConnectionInterface::RTCConfiguration&
const blink::WebRTCConfiguration& server_configuration, server_configuration,
const blink::WebMediaConstraints& options, const blink::WebMediaConstraints& options) override;
blink::WebRTCSdpSemantics original_sdp_semantics_value) override;
void CreateOffer(const blink::WebRTCSessionDescriptionRequest& request, void CreateOffer(const blink::WebRTCSessionDescriptionRequest& request,
const blink::WebMediaConstraints& options) override; const blink::WebMediaConstraints& options) override;
...@@ -138,7 +137,8 @@ class CONTENT_EXPORT RTCPeerConnectionHandler ...@@ -138,7 +137,8 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
blink::WebRTCSessionDescription PendingRemoteDescription() override; blink::WebRTCSessionDescription PendingRemoteDescription() override;
webrtc::RTCErrorType SetConfiguration( webrtc::RTCErrorType SetConfiguration(
const blink::WebRTCConfiguration& configuration) override; const webrtc::PeerConnectionInterface::RTCConfiguration& configuration)
override;
bool AddICECandidate( bool AddICECandidate(
scoped_refptr<blink::WebRTCICECandidate> candidate) override; scoped_refptr<blink::WebRTCICECandidate> candidate) override;
bool AddICECandidate( bool AddICECandidate(
...@@ -340,11 +340,7 @@ class CONTENT_EXPORT RTCPeerConnectionHandler ...@@ -340,11 +340,7 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
// In Plan B, senders and receivers are added or removed independently of one // In Plan B, senders and receivers are added or removed independently of one
// another. In Unified Plan, senders and receivers are created in pairs as // another. In Unified Plan, senders and receivers are created in pairs as
// transceivers. Transceivers may become inactive, but are never removed. // transceivers. Transceivers may become inactive, but are never removed.
// The value of this member affects the behavior of some methods and what
// information is surfaced from webrtc. After Initialize(), this is the actual
// mode used, meaning "kDefault" is no longer a valid value.
// TODO(hbos): Implement transceiver behaviors. https://crbug.com/777617 // TODO(hbos): Implement transceiver behaviors. https://crbug.com/777617
blink::WebRTCSdpSemantics sdp_semantics_;
// Content layer correspondents of |webrtc::RtpSenderInterface|. // Content layer correspondents of |webrtc::RtpSenderInterface|.
std::vector<std::unique_ptr<RTCRtpSender>> rtp_senders_; std::vector<std::unique_ptr<RTCRtpSender>> rtp_senders_;
// Content layer correspondents of |webrtc::RtpReceiverInterface|. // Content layer correspondents of |webrtc::RtpReceiverInterface|.
......
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include "third_party/blink/public/platform/web_media_stream.h" #include "third_party/blink/public/platform/web_media_stream.h"
#include "third_party/blink/public/platform/web_media_stream_source.h" #include "third_party/blink/public/platform/web_media_stream_source.h"
#include "third_party/blink/public/platform/web_media_stream_track.h" #include "third_party/blink/public/platform/web_media_stream_track.h"
#include "third_party/blink/public/platform/web_rtc_configuration.h"
#include "third_party/blink/public/platform/web_rtc_data_channel_handler.h" #include "third_party/blink/public/platform/web_rtc_data_channel_handler.h"
#include "third_party/blink/public/platform/web_rtc_data_channel_init.h" #include "third_party/blink/public/platform/web_rtc_data_channel_init.h"
#include "third_party/blink/public/platform/web_rtc_dtmf_sender_handler.h" #include "third_party/blink/public/platform/web_rtc_dtmf_sender_handler.h"
...@@ -279,8 +278,8 @@ class RTCPeerConnectionHandlerTest : public ::testing::Test { ...@@ -279,8 +278,8 @@ class RTCPeerConnectionHandlerTest : public ::testing::Test {
mock_dependency_factory_.reset(new MockPeerConnectionDependencyFactory()); mock_dependency_factory_.reset(new MockPeerConnectionDependencyFactory());
pc_handler_ = CreateRTCPeerConnectionHandlerUnderTest(); pc_handler_ = CreateRTCPeerConnectionHandlerUnderTest();
mock_tracker_.reset(new NiceMock<MockPeerConnectionTracker>()); mock_tracker_.reset(new NiceMock<MockPeerConnectionTracker>());
blink::WebRTCConfiguration config; webrtc::PeerConnectionInterface::RTCConfiguration config;
config.sdp_semantics = blink::WebRTCSdpSemantics::kPlanB; config.sdp_semantics = webrtc::SdpSemantics::kPlanB;
blink::WebMediaConstraints constraints; blink::WebMediaConstraints constraints;
EXPECT_TRUE(pc_handler_->InitializeForTest( EXPECT_TRUE(pc_handler_->InitializeForTest(
config, constraints, mock_tracker_.get()->AsWeakPtr())); config, constraints, mock_tracker_.get()->AsWeakPtr()));
...@@ -764,22 +763,19 @@ TEST_F(RTCPeerConnectionHandlerTest, setRemoteDescriptionParseError) { ...@@ -764,22 +763,19 @@ TEST_F(RTCPeerConnectionHandlerTest, setRemoteDescriptionParseError) {
} }
TEST_F(RTCPeerConnectionHandlerTest, setConfiguration) { TEST_F(RTCPeerConnectionHandlerTest, setConfiguration) {
blink::WebRTCConfiguration config; webrtc::PeerConnectionInterface::RTCConfiguration config;
config.sdp_semantics = blink::WebRTCSdpSemantics::kPlanB; config.sdp_semantics = webrtc::SdpSemantics::kPlanB;
EXPECT_CALL(*mock_tracker_.get(), EXPECT_CALL(*mock_tracker_.get(),
TrackSetConfiguration(pc_handler_.get(), _)); TrackSetConfiguration(pc_handler_.get(), _));
// TODO(perkj): Test that the parameters in |config| can be translated when a
// WebRTCConfiguration can be constructed. It's WebKit class and can't be
// initialized from a test.
EXPECT_EQ(webrtc::RTCErrorType::NONE, pc_handler_->SetConfiguration(config)); EXPECT_EQ(webrtc::RTCErrorType::NONE, pc_handler_->SetConfiguration(config));
} }
// Test that when an error occurs in SetConfiguration, it's converted to a // Test that when an error occurs in SetConfiguration, it's converted to a
// blink error and false is returned. // blink error and false is returned.
TEST_F(RTCPeerConnectionHandlerTest, setConfigurationError) { TEST_F(RTCPeerConnectionHandlerTest, setConfigurationError) {
blink::WebRTCConfiguration config; webrtc::PeerConnectionInterface::RTCConfiguration config;
config.sdp_semantics = blink::WebRTCSdpSemantics::kPlanB; config.sdp_semantics = webrtc::SdpSemantics::kPlanB;
mock_peer_connection_->set_setconfiguration_error_type( mock_peer_connection_->set_setconfiguration_error_type(
webrtc::RTCErrorType::INVALID_MODIFICATION); webrtc::RTCErrorType::INVALID_MODIFICATION);
......
...@@ -329,7 +329,6 @@ source_set("blink_headers") { ...@@ -329,7 +329,6 @@ source_set("blink_headers") {
"platform/web_rtc_answer_options.h", "platform/web_rtc_answer_options.h",
"platform/web_rtc_api_name.h", "platform/web_rtc_api_name.h",
"platform/web_rtc_certificate_generator.h", "platform/web_rtc_certificate_generator.h",
"platform/web_rtc_configuration.h",
"platform/web_rtc_data_channel_handler.h", "platform/web_rtc_data_channel_handler.h",
"platform/web_rtc_data_channel_handler_client.h", "platform/web_rtc_data_channel_handler_client.h",
"platform/web_rtc_data_channel_init.h", "platform/web_rtc_data_channel_init.h",
......
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_CONFIGURATION_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_CONFIGURATION_H_
#include "third_party/blink/public/platform/web_common.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/webrtc/api/peerconnectioninterface.h"
#include <memory>
namespace blink {
// This is distinct from webrtc::SdpSemantics to add the kDefault option.
enum class WebRTCSdpSemantics { kDefault, kPlanB, kUnifiedPlan };
struct WebRTCConfiguration {
std::vector<webrtc::PeerConnectionInterface::IceServer> ice_servers;
webrtc::PeerConnectionInterface::IceTransportsType ice_transport_policy =
webrtc::PeerConnectionInterface::kAll;
webrtc::PeerConnectionInterface::BundlePolicy bundle_policy =
webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
webrtc::PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy =
webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
WebVector<rtc::scoped_refptr<rtc::RTCCertificate>> certificates;
int ice_candidate_pool_size = 0;
WebRTCSdpSemantics sdp_semantics = WebRTCSdpSemantics::kDefault;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_CONFIGURATION_H_
...@@ -31,11 +31,11 @@ ...@@ -31,11 +31,11 @@
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_PEER_CONNECTION_HANDLER_H_ #ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_PEER_CONNECTION_HANDLER_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_PEER_CONNECTION_HANDLER_H_ #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_PEER_CONNECTION_HANDLER_H_
#include "third_party/blink/public/platform/web_rtc_configuration.h"
#include "third_party/blink/public/platform/web_rtc_ice_candidate.h" #include "third_party/blink/public/platform/web_rtc_ice_candidate.h"
#include "third_party/blink/public/platform/web_rtc_rtp_transceiver.h" #include "third_party/blink/public/platform/web_rtc_rtp_transceiver.h"
#include "third_party/blink/public/platform/web_rtc_stats.h" #include "third_party/blink/public/platform/web_rtc_stats.h"
#include "third_party/blink/public/platform/web_vector.h" #include "third_party/blink/public/platform/web_vector.h"
#include "third_party/webrtc/api/peerconnectioninterface.h"
#include "third_party/webrtc/api/rtcerror.h" #include "third_party/webrtc/api/rtcerror.h"
#include "third_party/webrtc/api/rtptransceiverinterface.h" #include "third_party/webrtc/api/rtptransceiverinterface.h"
...@@ -57,16 +57,15 @@ class WebRTCSessionDescriptionRequest; ...@@ -57,16 +57,15 @@ class WebRTCSessionDescriptionRequest;
class WebRTCStatsRequest; class WebRTCStatsRequest;
class WebRTCVoidRequest; class WebRTCVoidRequest;
class WebString; class WebString;
struct WebRTCConfiguration;
struct WebRTCDataChannelInit; struct WebRTCDataChannelInit;
class WebRTCPeerConnectionHandler { class WebRTCPeerConnectionHandler {
public: public:
virtual ~WebRTCPeerConnectionHandler() = default; virtual ~WebRTCPeerConnectionHandler() = default;
virtual bool Initialize(const WebRTCConfiguration&, virtual bool Initialize(
const WebMediaConstraints&, const webrtc::PeerConnectionInterface::RTCConfiguration&,
WebRTCSdpSemantics original_sdp_semantics_value) = 0; const WebMediaConstraints&) = 0;
virtual void CreateOffer(const WebRTCSessionDescriptionRequest&, virtual void CreateOffer(const WebRTCSessionDescriptionRequest&,
const WebMediaConstraints&) = 0; const WebMediaConstraints&) = 0;
...@@ -86,7 +85,8 @@ class WebRTCPeerConnectionHandler { ...@@ -86,7 +85,8 @@ class WebRTCPeerConnectionHandler {
virtual WebRTCSessionDescription CurrentRemoteDescription() = 0; virtual WebRTCSessionDescription CurrentRemoteDescription() = 0;
virtual WebRTCSessionDescription PendingLocalDescription() = 0; virtual WebRTCSessionDescription PendingLocalDescription() = 0;
virtual WebRTCSessionDescription PendingRemoteDescription() = 0; virtual WebRTCSessionDescription PendingRemoteDescription() = 0;
virtual webrtc::RTCErrorType SetConfiguration(const WebRTCConfiguration&) = 0; virtual webrtc::RTCErrorType SetConfiguration(
const webrtc::PeerConnectionInterface::RTCConfiguration&) = 0;
// DEPRECATED // DEPRECATED
virtual bool AddICECandidate(scoped_refptr<WebRTCICECandidate>) { virtual bool AddICECandidate(scoped_refptr<WebRTCICECandidate>) {
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <memory> #include <memory>
#include "third_party/blink/public/platform/web_media_constraints.h" #include "third_party/blink/public/platform/web_media_constraints.h"
#include "third_party/blink/public/platform/web_rtc_configuration.h"
#include "third_party/blink/public/platform/web_rtc_peer_connection_handler.h" #include "third_party/blink/public/platform/web_rtc_peer_connection_handler.h"
#include "third_party/blink/public/platform/web_rtc_peer_connection_handler_client.h" #include "third_party/blink/public/platform/web_rtc_peer_connection_handler_client.h"
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h" #include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
...@@ -72,7 +71,6 @@ class V8RTCPeerConnectionErrorCallback; ...@@ -72,7 +71,6 @@ class V8RTCPeerConnectionErrorCallback;
class V8RTCSessionDescriptionCallback; class V8RTCSessionDescriptionCallback;
class V8RTCStatsCallback; class V8RTCStatsCallback;
class V8VoidFunction; class V8VoidFunction;
struct WebRTCConfiguration;
class MODULES_EXPORT RTCPeerConnection final class MODULES_EXPORT RTCPeerConnection final
: public EventTargetWithInlineData, : public EventTargetWithInlineData,
...@@ -288,7 +286,7 @@ class MODULES_EXPORT RTCPeerConnection final ...@@ -288,7 +286,7 @@ class MODULES_EXPORT RTCPeerConnection final
}; };
RTCPeerConnection(ExecutionContext*, RTCPeerConnection(ExecutionContext*,
WebRTCConfiguration, webrtc::PeerConnectionInterface::RTCConfiguration,
WebMediaConstraints, WebMediaConstraints,
ExceptionState&); ExceptionState&);
void Dispose(); void Dispose();
...@@ -442,7 +440,7 @@ class MODULES_EXPORT RTCPeerConnection final ...@@ -442,7 +440,7 @@ class MODULES_EXPORT RTCPeerConnection final
// information is surfaced from webrtc. This has the value "kPlanB" or // information is surfaced from webrtc. This has the value "kPlanB" or
// "kUnifiedPlan", if constructed with "kDefault" it is translated to one or // "kUnifiedPlan", if constructed with "kDefault" it is translated to one or
// the other. // the other.
WebRTCSdpSemantics sdp_semantics_; webrtc::SdpSemantics sdp_semantics_;
}; };
} // namespace blink } // namespace blink
......
...@@ -95,9 +95,9 @@ MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler() = default; ...@@ -95,9 +95,9 @@ MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler() = default;
MockWebRTCPeerConnectionHandler::~MockWebRTCPeerConnectionHandler() = default; MockWebRTCPeerConnectionHandler::~MockWebRTCPeerConnectionHandler() = default;
bool MockWebRTCPeerConnectionHandler::Initialize(const WebRTCConfiguration&, bool MockWebRTCPeerConnectionHandler::Initialize(
const WebMediaConstraints&, const webrtc::PeerConnectionInterface::RTCConfiguration&,
WebRTCSdpSemantics) { const WebMediaConstraints&) {
return true; return true;
} }
...@@ -154,7 +154,7 @@ MockWebRTCPeerConnectionHandler::PendingRemoteDescription() { ...@@ -154,7 +154,7 @@ MockWebRTCPeerConnectionHandler::PendingRemoteDescription() {
} }
webrtc::RTCErrorType MockWebRTCPeerConnectionHandler::SetConfiguration( webrtc::RTCErrorType MockWebRTCPeerConnectionHandler::SetConfiguration(
const WebRTCConfiguration&) { const webrtc::PeerConnectionInterface::RTCConfiguration&) {
return webrtc::RTCErrorType::NONE; return webrtc::RTCErrorType::NONE;
} }
......
...@@ -16,9 +16,8 @@ class MockWebRTCPeerConnectionHandler : public WebRTCPeerConnectionHandler { ...@@ -16,9 +16,8 @@ class MockWebRTCPeerConnectionHandler : public WebRTCPeerConnectionHandler {
MockWebRTCPeerConnectionHandler(); MockWebRTCPeerConnectionHandler();
~MockWebRTCPeerConnectionHandler() override; ~MockWebRTCPeerConnectionHandler() override;
bool Initialize(const WebRTCConfiguration&, bool Initialize(const webrtc::PeerConnectionInterface::RTCConfiguration&,
const WebMediaConstraints&, const WebMediaConstraints&) override;
WebRTCSdpSemantics original_sdp_semantics_value) override;
void CreateOffer(const WebRTCSessionDescriptionRequest&, void CreateOffer(const WebRTCSessionDescriptionRequest&,
const WebMediaConstraints&) override; const WebMediaConstraints&) override;
...@@ -38,7 +37,8 @@ class MockWebRTCPeerConnectionHandler : public WebRTCPeerConnectionHandler { ...@@ -38,7 +37,8 @@ class MockWebRTCPeerConnectionHandler : public WebRTCPeerConnectionHandler {
WebRTCSessionDescription CurrentRemoteDescription() override; WebRTCSessionDescription CurrentRemoteDescription() override;
WebRTCSessionDescription PendingLocalDescription() override; WebRTCSessionDescription PendingLocalDescription() override;
WebRTCSessionDescription PendingRemoteDescription() override; WebRTCSessionDescription PendingRemoteDescription() override;
webrtc::RTCErrorType SetConfiguration(const WebRTCConfiguration&) override; webrtc::RTCErrorType SetConfiguration(
const webrtc::PeerConnectionInterface::RTCConfiguration&) override;
void GetStats(const WebRTCStatsRequest&) override; void GetStats(const WebRTCStatsRequest&) override;
void GetStats(std::unique_ptr<WebRTCStatsReportCallback>) override; void GetStats(std::unique_ptr<WebRTCStatsReportCallback>) override;
webrtc::RTCErrorOr<std::unique_ptr<WebRTCRtpTransceiver>> webrtc::RTCErrorOr<std::unique_ptr<WebRTCRtpTransceiver>>
......
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