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

Side by Side Diff: remoting/protocol/webrtc_connection_to_host.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 unified diff | Download patch
« no previous file with comments | « remoting/protocol/webrtc_connection_to_host.h ('k') | remoting/protocol/webrtc_transport.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/webrtc_connection_to_host.h" 5 #include "remoting/protocol/webrtc_connection_to_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "jingle/glue/thread_wrapper.h" 10 #include "jingle/glue/thread_wrapper.h"
11 #include "remoting/base/constants.h" 11 #include "remoting/base/constants.h"
12 #include "remoting/protocol/client_control_dispatcher.h" 12 #include "remoting/protocol/client_control_dispatcher.h"
13 #include "remoting/protocol/client_event_dispatcher.h" 13 #include "remoting/protocol/client_event_dispatcher.h"
14 #include "remoting/protocol/client_stub.h" 14 #include "remoting/protocol/client_stub.h"
15 #include "remoting/protocol/clipboard_stub.h" 15 #include "remoting/protocol/clipboard_stub.h"
16 #include "remoting/protocol/message_pipe.h" 16 #include "remoting/protocol/message_pipe.h"
17 #include "remoting/protocol/transport_context.h" 17 #include "remoting/protocol/transport_context.h"
18 #include "remoting/protocol/video_renderer.h" 18 #include "remoting/protocol/video_renderer.h"
19 #include "remoting/protocol/webrtc_audio_module.h"
20 #include "remoting/protocol/webrtc_audio_sink_adapter.h"
19 #include "remoting/protocol/webrtc_transport.h" 21 #include "remoting/protocol/webrtc_transport.h"
20 #include "remoting/protocol/webrtc_video_renderer_adapter.h" 22 #include "remoting/protocol/webrtc_video_renderer_adapter.h"
21 23
22 namespace remoting { 24 namespace remoting {
23 namespace protocol { 25 namespace protocol {
24 26
25 WebrtcConnectionToHost::WebrtcConnectionToHost() {} 27 WebrtcConnectionToHost::WebrtcConnectionToHost() {}
26 WebrtcConnectionToHost::~WebrtcConnectionToHost() {} 28 WebrtcConnectionToHost::~WebrtcConnectionToHost() {}
27 29
28 void WebrtcConnectionToHost::Connect( 30 void WebrtcConnectionToHost::Connect(
29 std::unique_ptr<Session> session, 31 std::unique_ptr<Session> session,
30 scoped_refptr<TransportContext> transport_context, 32 scoped_refptr<TransportContext> transport_context,
31 HostEventCallback* event_callback) { 33 HostEventCallback* event_callback) {
32 DCHECK(client_stub_); 34 DCHECK(client_stub_);
33 DCHECK(clipboard_stub_); 35 DCHECK(clipboard_stub_);
34 36
35 transport_.reset(new WebrtcTransport( 37 transport_.reset(new WebrtcTransport(
36 jingle_glue::JingleThreadWrapper::current(), transport_context, this)); 38 jingle_glue::JingleThreadWrapper::current(), transport_context, this));
37 39
40 transport_->audio_module()->SetAudioTaskRunner(audio_decode_task_runner_);
41
38 session_ = std::move(session); 42 session_ = std::move(session);
39 session_->SetEventHandler(this); 43 session_->SetEventHandler(this);
40 session_->SetTransport(transport_.get()); 44 session_->SetTransport(transport_.get());
41 45
42 event_callback_ = event_callback; 46 event_callback_ = event_callback;
43 47
44 SetState(CONNECTING, OK); 48 SetState(CONNECTING, OK);
45 } 49 }
46 50
47 const SessionConfig& WebrtcConnectionToHost::config() { 51 const SessionConfig& WebrtcConnectionToHost::config() {
(...skipping 19 matching lines...) Expand all
67 void WebrtcConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) { 71 void WebrtcConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) {
68 clipboard_stub_ = clipboard_stub; 72 clipboard_stub_ = clipboard_stub;
69 } 73 }
70 74
71 void WebrtcConnectionToHost::set_video_renderer(VideoRenderer* video_renderer) { 75 void WebrtcConnectionToHost::set_video_renderer(VideoRenderer* video_renderer) {
72 video_renderer_ = video_renderer; 76 video_renderer_ = video_renderer;
73 } 77 }
74 78
75 void WebrtcConnectionToHost::InitializeAudio( 79 void WebrtcConnectionToHost::InitializeAudio(
76 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner, 80 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner,
77 base::WeakPtr<AudioStub> audio_stub) { 81 base::WeakPtr<AudioStub> audio_consumer) {
78 NOTIMPLEMENTED(); 82 audio_decode_task_runner_ = audio_decode_task_runner;
83 audio_consumer_ = audio_consumer;
79 } 84 }
80 85
81 void WebrtcConnectionToHost::OnSessionStateChange(Session::State state) { 86 void WebrtcConnectionToHost::OnSessionStateChange(Session::State state) {
82 DCHECK(event_callback_); 87 DCHECK(event_callback_);
83 88
84 switch (state) { 89 switch (state) {
85 case Session::INITIALIZING: 90 case Session::INITIALIZING:
86 case Session::CONNECTING: 91 case Session::CONNECTING:
87 case Session::ACCEPTING: 92 case Session::ACCEPTING:
88 case Session::ACCEPTED: 93 case Session::ACCEPTED:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 name.substr(strlen(kVideoStatsChannelNamePrefix)); 142 name.substr(strlen(kVideoStatsChannelNamePrefix));
138 GetOrCreateVideoAdapter(video_stream_label) 143 GetOrCreateVideoAdapter(video_stream_label)
139 ->SetVideoStatsChannel(std::move(pipe)); 144 ->SetVideoStatsChannel(std::move(pipe));
140 } else { 145 } else {
141 LOG(WARNING) << "Received unknown incoming data channel " << name; 146 LOG(WARNING) << "Received unknown incoming data channel " << name;
142 } 147 }
143 } 148 }
144 149
145 void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamAdded( 150 void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamAdded(
146 scoped_refptr<webrtc::MediaStreamInterface> stream) { 151 scoped_refptr<webrtc::MediaStreamInterface> stream) {
147 GetOrCreateVideoAdapter(stream->label())->SetMediaStream(stream); 152 if (stream->GetVideoTracks().size() > 0) {
153 GetOrCreateVideoAdapter(stream->label())->SetMediaStream(stream);
154 } else if (stream->GetAudioTracks().size() > 0) {
155 audio_adapter_.reset(new WebrtcAudioSinkAdapter(stream, audio_consumer_));
156 } else {
157 LOG(ERROR) << "Received MediaStream with no video or audio tracks.";
158 }
148 } 159 }
149 160
150 void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamRemoved( 161 void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamRemoved(
151 scoped_refptr<webrtc::MediaStreamInterface> stream) { 162 scoped_refptr<webrtc::MediaStreamInterface> stream) {
152 if (video_adapter_ && video_adapter_->label() == stream->label()) 163 if (video_adapter_ && video_adapter_->label() == stream->label())
153 video_adapter_.reset(); 164 video_adapter_.reset();
154 } 165 }
155 166
156 void WebrtcConnectionToHost::OnChannelInitialized( 167 void WebrtcConnectionToHost::OnChannelInitialized(
157 ChannelDispatcherBase* channel_dispatcher) { 168 ChannelDispatcherBase* channel_dispatcher) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 218
208 if (state != state_) { 219 if (state != state_) {
209 state_ = state; 220 state_ = state;
210 error_ = error; 221 error_ = error;
211 event_callback_->OnConnectionState(state_, error_); 222 event_callback_->OnConnectionState(state_, error_);
212 } 223 }
213 } 224 }
214 225
215 } // namespace protocol 226 } // namespace protocol
216 } // namespace remoting 227 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_connection_to_host.h ('k') | remoting/protocol/webrtc_transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698