Commit 8168b6ba authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Switch PeerConnectionDependencyFactory away from std::string

Instead, WTF::String is used.

BUG=787254
R=haraken@chromium.org

Change-Id: I046b6309b56e5d7664b0e7983d712aa3b21a12a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1988289Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#728522}
parent df9ad50a
......@@ -260,8 +260,8 @@ MediaStreamVideoWebRtcSink::MediaStreamVideoWebRtcSink(
// PeerConnectionFactory::CreateVideoTrack doesn't do reference counting.
video_source_proxy_ =
factory->CreateVideoTrackSourceProxy(video_source_.get());
video_track_ = factory->CreateLocalVideoTrack(track.Id().Utf8(),
video_source_proxy_.get());
video_track_ =
factory->CreateLocalVideoTrack(track.Id(), video_source_proxy_.get());
video_track_->set_content_hint(
ContentHintTypeToWebRtcContentHint(track.ContentHint()));
......
......@@ -404,35 +404,34 @@ MockPeerConnectionDependencyFactory::CreateVideoTrackSourceProxy(
}
scoped_refptr<webrtc::MediaStreamInterface>
MockPeerConnectionDependencyFactory::CreateLocalMediaStream(
const std::string& label) {
return new rtc::RefCountedObject<MockMediaStream>(label);
const String& label) {
return new rtc::RefCountedObject<MockMediaStream>(label.Utf8());
}
scoped_refptr<webrtc::VideoTrackInterface>
MockPeerConnectionDependencyFactory::CreateLocalVideoTrack(
const std::string& id,
const String& id,
webrtc::VideoTrackSourceInterface* source) {
scoped_refptr<webrtc::VideoTrackInterface> track(
new rtc::RefCountedObject<MockWebRtcVideoTrack>(id, source));
new rtc::RefCountedObject<MockWebRtcVideoTrack>(id.Utf8(), source));
return track;
}
SessionDescriptionInterface*
MockPeerConnectionDependencyFactory::CreateSessionDescription(
const std::string& type,
const std::string& sdp,
const String& type,
const String& sdp,
webrtc::SdpParseError* error) {
if (fail_to_create_session_description_)
return nullptr;
return new MockSessionDescription(type, sdp);
return new MockSessionDescription(type.Utf8(), sdp.Utf8());
}
webrtc::IceCandidateInterface*
MockPeerConnectionDependencyFactory::CreateIceCandidate(
const std::string& sdp_mid,
int sdp_mline_index,
const std::string& sdp) {
return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp);
MockPeerConnectionDependencyFactory::CreateIceCandidate(const String& sdp_mid,
int sdp_mline_index,
const String& sdp) {
return new MockIceCandidate(sdp_mid.Utf8(), sdp_mline_index, sdp.Utf8());
}
scoped_refptr<base::SingleThreadTaskRunner>
......
......@@ -172,18 +172,17 @@ class MockPeerConnectionDependencyFactory
scoped_refptr<webrtc::VideoTrackSourceInterface> CreateVideoTrackSourceProxy(
webrtc::VideoTrackSourceInterface* source) override;
scoped_refptr<webrtc::MediaStreamInterface> CreateLocalMediaStream(
const std::string& label) override;
const String& label) override;
scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack(
const std::string& id,
const String& id,
webrtc::VideoTrackSourceInterface* source) override;
webrtc::SessionDescriptionInterface* CreateSessionDescription(
const std::string& type,
const std::string& sdp,
const String& type,
const String& sdp,
webrtc::SdpParseError* error) override;
webrtc::IceCandidateInterface* CreateIceCandidate(
const std::string& sdp_mid,
int sdp_mline_index,
const std::string& sdp) override;
webrtc::IceCandidateInterface* CreateIceCandidate(const String& sdp_mid,
int sdp_mline_index,
const String& sdp) override;
scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcSignalingTaskRunner()
override;
......
......@@ -7,6 +7,7 @@
#include <stddef.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
......@@ -74,13 +75,12 @@ enum WebRTCIPHandlingPolicy {
DISABLE_NON_PROXIED_UDP,
};
WebRTCIPHandlingPolicy GetWebRTCIPHandlingPolicy(
const std::string& preference) {
if (preference == blink::kWebRTCIPHandlingDefaultPublicAndPrivateInterfaces)
WebRTCIPHandlingPolicy GetWebRTCIPHandlingPolicy(const String& preference) {
if (preference == kWebRTCIPHandlingDefaultPublicAndPrivateInterfaces)
return DEFAULT_PUBLIC_AND_PRIVATE_INTERFACES;
if (preference == blink::kWebRTCIPHandlingDefaultPublicInterfaceOnly)
if (preference == kWebRTCIPHandlingDefaultPublicInterfaceOnly)
return DEFAULT_PUBLIC_INTERFACE_ONLY;
if (preference == blink::kWebRTCIPHandlingDisableNonProxiedUdp)
if (preference == kWebRTCIPHandlingDisableNonProxiedUdp)
return DISABLE_NON_PROXIED_UDP;
return DEFAULT;
}
......@@ -399,14 +399,14 @@ PeerConnectionDependencyFactory::CreatePortAllocator(
// detached, it is impossible for RTCPeerConnectionHandler to outlive the
// frame. Therefore using a raw pointer of |media_permission| is safe here.
media::MediaPermission* media_permission = nullptr;
if (!blink::Platform::Current()->ShouldEnforceWebRTCRoutingPreferences()) {
if (!Platform::Current()->ShouldEnforceWebRTCRoutingPreferences()) {
port_config.enable_multiple_routes = true;
port_config.enable_nonproxied_udp = true;
VLOG(3) << "WebRTC routing preferences will not be enforced";
} else {
if (web_frame && web_frame->View()) {
blink::WebString webrtc_ip_handling_policy;
blink::Platform::Current()->GetWebRTCRendererPreferences(
WebString webrtc_ip_handling_policy;
Platform::Current()->GetWebRTCRendererPreferences(
web_frame, &webrtc_ip_handling_policy, &min_port, &max_port,
&allow_mdns_obfuscation);
......@@ -415,7 +415,7 @@ PeerConnectionDependencyFactory::CreatePortAllocator(
// collected depends on if mic/camera permission is granted for this
// origin.
WebRTCIPHandlingPolicy policy =
GetWebRTCIPHandlingPolicy(webrtc_ip_handling_policy.Utf8());
GetWebRTCIPHandlingPolicy(webrtc_ip_handling_policy);
switch (policy) {
// TODO(guoweis): specify the flag of disabling local candidate
// collection when webrtc is updated.
......@@ -484,9 +484,8 @@ PeerConnectionDependencyFactory::CreateAsyncResolverFactory() {
}
scoped_refptr<webrtc::MediaStreamInterface>
PeerConnectionDependencyFactory::CreateLocalMediaStream(
const std::string& label) {
return GetPcFactory()->CreateLocalMediaStream(label).get();
PeerConnectionDependencyFactory::CreateLocalMediaStream(const String& label) {
return GetPcFactory()->CreateLocalMediaStream(label.Utf8()).get();
}
scoped_refptr<webrtc::VideoTrackSourceInterface>
......@@ -504,24 +503,25 @@ PeerConnectionDependencyFactory::CreateVideoTrackSourceProxy(
scoped_refptr<webrtc::VideoTrackInterface>
PeerConnectionDependencyFactory::CreateLocalVideoTrack(
const std::string& id,
const String& id,
webrtc::VideoTrackSourceInterface* source) {
return GetPcFactory()->CreateVideoTrack(id, source).get();
return GetPcFactory()->CreateVideoTrack(id.Utf8(), source).get();
}
webrtc::SessionDescriptionInterface*
PeerConnectionDependencyFactory::CreateSessionDescription(
const std::string& type,
const std::string& sdp,
const String& type,
const String& sdp,
webrtc::SdpParseError* error) {
return webrtc::CreateSessionDescription(type, sdp, error);
return webrtc::CreateSessionDescription(type.Utf8(), sdp.Utf8(), error);
}
webrtc::IceCandidateInterface*
PeerConnectionDependencyFactory::CreateIceCandidate(const std::string& sdp_mid,
PeerConnectionDependencyFactory::CreateIceCandidate(const String& sdp_mid,
int sdp_mline_index,
const std::string& sdp) {
return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp, nullptr);
const String& sdp) {
return webrtc::CreateIceCandidate(sdp_mid.Utf8(), sdp_mline_index, sdp.Utf8(),
nullptr);
}
blink::WebRtcAudioDeviceImpl*
......@@ -632,8 +632,7 @@ void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() {
}
std::unique_ptr<webrtc::RtpCapabilities>
PeerConnectionDependencyFactory::GetSenderCapabilities(
const std::string& kind) {
PeerConnectionDependencyFactory::GetSenderCapabilities(const String& kind) {
if (kind == "audio") {
return std::make_unique<webrtc::RtpCapabilities>(
GetPcFactory()->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_AUDIO));
......@@ -645,8 +644,7 @@ PeerConnectionDependencyFactory::GetSenderCapabilities(
}
std::unique_ptr<webrtc::RtpCapabilities>
PeerConnectionDependencyFactory::GetReceiverCapabilities(
const std::string& kind) {
PeerConnectionDependencyFactory::GetReceiverCapabilities(const String& kind) {
if (kind == "audio") {
return std::make_unique<webrtc::RtpCapabilities>(
GetPcFactory()->GetRtpReceiverCapabilities(cricket::MEDIA_TYPE_AUDIO));
......
......@@ -5,8 +5,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_PEERCONNECTION_PEER_CONNECTION_DEPENDENCY_FACTORY_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_PEERCONNECTION_PEER_CONNECTION_DEPENDENCY_FACTORY_H_
#include <string>
#include "base/macros.h"
#include "base/message_loop/message_loop_current.h"
#include "base/single_thread_task_runner.h"
......@@ -71,11 +69,11 @@ class MODULES_EXPORT PeerConnectionDependencyFactory
// Asks the PeerConnection factory to create a Local MediaStream object.
virtual scoped_refptr<webrtc::MediaStreamInterface> CreateLocalMediaStream(
const std::string& label);
const String& label);
// Asks the PeerConnection factory to create a Local VideoTrack object.
virtual scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack(
const std::string& id,
const String& id,
webrtc::VideoTrackSourceInterface* source);
// Asks the libjingle PeerConnection factory to create a libjingle
......@@ -98,22 +96,22 @@ class MODULES_EXPORT PeerConnectionDependencyFactory
// Creates a libjingle representation of a Session description. Used by a
// RTCPeerConnectionHandler instance.
virtual webrtc::SessionDescriptionInterface* CreateSessionDescription(
const std::string& type,
const std::string& sdp,
const String& type,
const String& sdp,
webrtc::SdpParseError* error);
// Creates a libjingle representation of an ice candidate.
virtual webrtc::IceCandidateInterface* CreateIceCandidate(
const std::string& sdp_mid,
const String& sdp_mid,
int sdp_mline_index,
const std::string& sdp);
const String& sdp);
// Returns the most optimistic view of the capabilities of the system for
// sending or receiving media of the given kind ("audio" or "video").
virtual std::unique_ptr<webrtc::RtpCapabilities> GetSenderCapabilities(
const std::string& kind);
const String& kind);
virtual std::unique_ptr<webrtc::RtpCapabilities> GetReceiverCapabilities(
const std::string& kind);
const String& kind);
blink::WebRtcAudioDeviceImpl* GetWebRtcAudioDevice();
......
......@@ -1552,11 +1552,11 @@ void RTCPeerConnectionHandler::AddICECandidate(
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::addICECandidate");
std::unique_ptr<webrtc::IceCandidateInterface> native_candidate(
dependency_factory_->CreateIceCandidate(
candidate->SdpMid().Utf8(),
candidate->SdpMid(),
candidate->SdpMLineIndex()
? static_cast<int>(*candidate->SdpMLineIndex())
: -1,
candidate->Candidate().Utf8()));
candidate->Candidate()));
auto callback_on_task_runner =
[](base::WeakPtr<RTCPeerConnectionHandler> handler_weak_ptr,
......@@ -2446,8 +2446,7 @@ RTCPeerConnectionHandler::CreateNativeSessionDescription(
const String& type,
webrtc::SdpParseError* error) {
webrtc::SessionDescriptionInterface* native_desc =
dependency_factory_->CreateSessionDescription(type.Utf8(), sdp.Utf8(),
error);
dependency_factory_->CreateSessionDescription(type, sdp, error);
LOG_IF(ERROR, !native_desc) << "Failed to create native session description."
<< " Type: " << type << " SDP: " << sdp;
......
......@@ -309,8 +309,7 @@ class RTCPeerConnectionHandlerTest : public ::testing::Test {
}
// Creates a WebKit local MediaStream.
blink::WebMediaStream CreateLocalMediaStream(
const std::string& stream_label) {
WebMediaStream CreateLocalMediaStream(const std::string& stream_label) {
std::string video_track_label("video-label");
std::string audio_track_label("audio-label");
blink::WebMediaStreamSource blink_audio_source;
......@@ -373,18 +372,18 @@ class RTCPeerConnectionHandlerTest : public ::testing::Test {
// Creates a remote MediaStream and adds it to the mocked native
// peer connection.
rtc::scoped_refptr<webrtc::MediaStreamInterface> AddRemoteMockMediaStream(
const std::string& stream_label,
const std::string& video_track_label,
const std::string& audio_track_label) {
const String& stream_label,
const String& video_track_label,
const String& audio_track_label) {
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream(
mock_dependency_factory_->CreateLocalMediaStream(stream_label).get());
if (!video_track_label.empty()) {
if (!video_track_label.IsEmpty()) {
InvokeAddTrack(
stream, blink::MockWebRtcVideoTrack::Create(video_track_label).get());
stream, MockWebRtcVideoTrack::Create(video_track_label.Utf8()).get());
}
if (!audio_track_label.empty()) {
if (!audio_track_label.IsEmpty()) {
InvokeAddTrack(
stream, blink::MockWebRtcAudioTrack::Create(audio_track_label).get());
stream, MockWebRtcAudioTrack::Create(audio_track_label.Utf8()).get());
}
mock_peer_connection_->AddRemoteStream(stream);
return stream;
......
......@@ -193,7 +193,7 @@ RTCRtpCapabilities* RTCRtpReceiver::getCapabilities(const String& kind) {
std::unique_ptr<webrtc::RtpCapabilities> rtc_capabilities =
PeerConnectionDependencyFactory::GetInstance()->GetSenderCapabilities(
kind.Utf8());
kind);
HeapVector<Member<RTCRtpCodecCapability>> codecs;
codecs.ReserveInitialCapacity(
......
......@@ -580,7 +580,7 @@ RTCRtpCapabilities* RTCRtpSender::getCapabilities(const String& kind) {
std::unique_ptr<webrtc::RtpCapabilities> rtc_capabilities =
PeerConnectionDependencyFactory::GetInstance()->GetSenderCapabilities(
kind.Utf8());
kind);
HeapVector<Member<RTCRtpCodecCapability>> codecs;
codecs.ReserveInitialCapacity(
......
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