Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: remoting/protocol/webrtc_transport.cc

Issue 2371323007: Add audio support in WebrtcConnectionToHost, audio unittest (Closed)
Patch Set: more reliable test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/webrtc_transport.h ('k') | remoting/protocol/webrtc_video_renderer_adapter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/webrtc_transport.cc
diff --git a/remoting/protocol/webrtc_transport.cc b/remoting/protocol/webrtc_transport.cc
index afa408592e47af22a31e257e45f5ac5c0018ad31..604f5d9bd3fbbc16a57aeee1026e17f28c74b9c4 100644
--- a/remoting/protocol/webrtc_transport.cc
+++ b/remoting/protocol/webrtc_transport.cc
@@ -146,11 +146,10 @@ class WebrtcTransport::PeerConnectionWrapper
std::unique_ptr<cricket::PortAllocator> port_allocator,
base::WeakPtr<WebrtcTransport> transport)
: transport_(transport) {
- scoped_refptr<WebrtcAudioModule> audio_module =
- new rtc::RefCountedObject<WebrtcAudioModule>();
+ audio_module_ = new rtc::RefCountedObject<WebrtcAudioModule>();
peer_connection_factory_ = webrtc::CreatePeerConnectionFactory(
- worker_thread, rtc::Thread::Current(), audio_module.get(),
+ worker_thread, rtc::Thread::Current(), audio_module_.get(),
encoder_factory.release(), nullptr);
webrtc::FakeConstraints constraints;
@@ -162,6 +161,10 @@ class WebrtcTransport::PeerConnectionWrapper
}
virtual ~PeerConnectionWrapper() { peer_connection_->Close(); }
+ WebrtcAudioModule* audio_module() {
+ return audio_module_.get();
+ }
+
webrtc::PeerConnectionInterface* peer_connection() {
return peer_connection_.get();
}
@@ -225,12 +228,21 @@ WebrtcTransport::WebrtcTransport(
rtc::Thread* worker_thread,
scoped_refptr<TransportContext> transport_context,
EventHandler* event_handler)
- : worker_thread_(worker_thread),
- transport_context_(transport_context),
+ : transport_context_(transport_context),
event_handler_(event_handler),
handshake_hmac_(crypto::HMAC::SHA256),
weak_factory_(this) {
transport_context_->set_relay_mode(TransportContext::RelayMode::TURN);
+
+ video_encoder_factory_ = new WebrtcDummyVideoEncoderFactory();
+ std::unique_ptr<cricket::PortAllocator> port_allocator =
+ transport_context_->port_allocator_factory()->CreatePortAllocator(
+ transport_context_);
+
+ // Takes ownership of video_encoder_factory_.
+ peer_connection_wrapper_.reset(new PeerConnectionWrapper(
+ worker_thread, base::WrapUnique(video_encoder_factory_),
+ std::move(port_allocator), weak_factory_.GetWeakPtr()));
}
WebrtcTransport::~WebrtcTransport() {
@@ -249,6 +261,12 @@ WebrtcTransport::peer_connection_factory() {
: nullptr;
}
+WebrtcAudioModule* WebrtcTransport::audio_module() {
+ return peer_connection_wrapper_
+ ? peer_connection_wrapper_->audio_module()
+ : nullptr;
+}
+
std::unique_ptr<MessagePipe> WebrtcTransport::CreateOutgoingChannel(
const std::string& name) {
webrtc::DataChannelInit config;
@@ -274,16 +292,6 @@ void WebrtcTransport::Start(
LOG(FATAL) << "HMAC::Init() failed.";
}
- video_encoder_factory_ = new WebrtcDummyVideoEncoderFactory();
- std::unique_ptr<cricket::PortAllocator> port_allocator =
- transport_context_->port_allocator_factory()->CreatePortAllocator(
- transport_context_);
-
- // Takes ownership of video_encoder_factory_.
- peer_connection_wrapper_.reset(new PeerConnectionWrapper(
- worker_thread_, base::WrapUnique(video_encoder_factory_),
- std::move(port_allocator), weak_factory_.GetWeakPtr()));
-
event_handler_->OnWebrtcTransportConnecting();
if (transport_context_->role() == TransportRole::SERVER)
@@ -434,6 +442,13 @@ void WebrtcTransport::OnLocalSessionDescriptionCreated(
}
description_sdp = NormalizeSessionDescription(description_sdp);
+ // Update SDP format to use stereo for opus codec.
+ std::string opus_line = "a=rtpmap:111 opus/48000/2\n";
+ std::string opus_line_with_bitrate =
+ opus_line + "a=fmtp:111 stereo=1; x-google-min-bitrate=160\n";
+ base::ReplaceSubstringsAfterOffset(&description_sdp, 0, opus_line,
+ opus_line_with_bitrate);
+
// Format and send the session description to the peer.
std::unique_ptr<XmlElement> transport_info(
new XmlElement(QName(kTransportNamespace, "transport"), true));
« no previous file with comments | « remoting/protocol/webrtc_transport.h ('k') | remoting/protocol/webrtc_video_renderer_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698