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

Side by Side Diff: remoting/protocol/ice_connection_to_host.cc

Issue 1559933003: Pass VideoRenderer interface to ConnectionToHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_frame_consumer
Patch Set: Created 4 years, 11 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
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/ice_connection_to_host.h" 5 #include "remoting/protocol/ice_connection_to_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "remoting/base/constants.h" 12 #include "remoting/base/constants.h"
13 #include "remoting/protocol/audio_reader.h" 13 #include "remoting/protocol/audio_reader.h"
14 #include "remoting/protocol/audio_stub.h" 14 #include "remoting/protocol/audio_stub.h"
15 #include "remoting/protocol/auth_util.h" 15 #include "remoting/protocol/auth_util.h"
16 #include "remoting/protocol/client_control_dispatcher.h" 16 #include "remoting/protocol/client_control_dispatcher.h"
17 #include "remoting/protocol/client_event_dispatcher.h" 17 #include "remoting/protocol/client_event_dispatcher.h"
18 #include "remoting/protocol/client_stub.h" 18 #include "remoting/protocol/client_stub.h"
19 #include "remoting/protocol/client_video_dispatcher.h" 19 #include "remoting/protocol/client_video_dispatcher.h"
20 #include "remoting/protocol/clipboard_stub.h" 20 #include "remoting/protocol/clipboard_stub.h"
21 #include "remoting/protocol/errors.h" 21 #include "remoting/protocol/errors.h"
22 #include "remoting/protocol/ice_transport.h" 22 #include "remoting/protocol/ice_transport.h"
23 #include "remoting/protocol/transport_context.h" 23 #include "remoting/protocol/transport_context.h"
24 #include "remoting/protocol/video_stub.h" 24 #include "remoting/protocol/video_renderer.h"
25 25
26 namespace remoting { 26 namespace remoting {
27 namespace protocol { 27 namespace protocol {
28 28
29 IceConnectionToHost::IceConnectionToHost() {} 29 IceConnectionToHost::IceConnectionToHost() {}
30 IceConnectionToHost::~IceConnectionToHost() {} 30 IceConnectionToHost::~IceConnectionToHost() {}
31 31
32 void IceConnectionToHost::Connect( 32 void IceConnectionToHost::Connect(
33 scoped_ptr<Session> session, 33 scoped_ptr<Session> session,
34 scoped_refptr<TransportContext> transport_context, 34 scoped_refptr<TransportContext> transport_context,
35 HostEventCallback* event_callback) { 35 HostEventCallback* event_callback) {
36 DCHECK(client_stub_); 36 DCHECK(client_stub_);
37 DCHECK(clipboard_stub_); 37 DCHECK(clipboard_stub_);
38 DCHECK(monitored_video_stub_); 38 DCHECK(video_renderer_);
39 39
40 transport_.reset(new IceTransport(transport_context, this)); 40 transport_.reset(new IceTransport(transport_context, this));
41 41
42 session_ = std::move(session); 42 session_ = std::move(session);
43 session_->SetEventHandler(this); 43 session_->SetEventHandler(this);
44 session_->SetTransport(transport_.get()); 44 session_->SetTransport(transport_.get());
45 45
46 event_callback_ = event_callback; 46 event_callback_ = event_callback;
47 47
48 SetState(CONNECTING, OK); 48 SetState(CONNECTING, OK);
(...skipping 17 matching lines...) Expand all
66 } 66 }
67 67
68 void IceConnectionToHost::set_client_stub(ClientStub* client_stub) { 68 void IceConnectionToHost::set_client_stub(ClientStub* client_stub) {
69 client_stub_ = client_stub; 69 client_stub_ = client_stub;
70 } 70 }
71 71
72 void IceConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) { 72 void IceConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) {
73 clipboard_stub_ = clipboard_stub; 73 clipboard_stub_ = clipboard_stub;
74 } 74 }
75 75
76 void IceConnectionToHost::set_video_stub(VideoStub* video_stub) { 76 void IceConnectionToHost::set_video_renderer(VideoRenderer* video_renderer) {
77 DCHECK(video_stub); 77 DCHECK(video_renderer);
78 monitored_video_stub_.reset(new MonitoredVideoStub( 78 DCHECK(!monitored_video_stub_);
79 video_stub, base::TimeDelta::FromSeconds( 79 video_renderer_ = video_renderer;
80 MonitoredVideoStub::kConnectivityCheckDelaySeconds),
81 base::Bind(&IceConnectionToHost::OnVideoChannelStatus,
82 base::Unretained(this))));
83 } 80 }
84 81
85 void IceConnectionToHost::set_audio_stub(AudioStub* audio_stub) { 82 void IceConnectionToHost::set_audio_stub(AudioStub* audio_stub) {
86 audio_stub_ = audio_stub; 83 audio_stub_ = audio_stub;
87 } 84 }
88 85
89 void IceConnectionToHost::OnSessionStateChange(Session::State state) { 86 void IceConnectionToHost::OnSessionStateChange(Session::State state) {
90 DCHECK(CalledOnValidThread()); 87 DCHECK(CalledOnValidThread());
91 DCHECK(event_callback_); 88 DCHECK(event_callback_);
92 89
93 switch (state) { 90 switch (state) {
94 case Session::INITIALIZING: 91 case Session::INITIALIZING:
95 case Session::CONNECTING: 92 case Session::CONNECTING:
96 case Session::ACCEPTING: 93 case Session::ACCEPTING:
97 case Session::ACCEPTED: 94 case Session::ACCEPTED:
98 case Session::AUTHENTICATING: 95 case Session::AUTHENTICATING:
99 // Don't care about these events. 96 // Don't care about these events.
100 break; 97 break;
101 98
102 case Session::AUTHENTICATED: 99 case Session::AUTHENTICATED:
103 SetState(AUTHENTICATED, OK); 100 SetState(AUTHENTICATED, OK);
101
102 // Setup control channel.
104 control_dispatcher_.reset(new ClientControlDispatcher()); 103 control_dispatcher_.reset(new ClientControlDispatcher());
105 control_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(), 104 control_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(),
106 this); 105 this);
107 control_dispatcher_->set_client_stub(client_stub_); 106 control_dispatcher_->set_client_stub(client_stub_);
108 control_dispatcher_->set_clipboard_stub(clipboard_stub_); 107 control_dispatcher_->set_clipboard_stub(clipboard_stub_);
109 108
109 // Setup event channel.
110 event_dispatcher_.reset(new ClientEventDispatcher()); 110 event_dispatcher_.reset(new ClientEventDispatcher());
111 event_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(), this); 111 event_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(), this);
112 112
113 // Configure video pipeline.
114 video_renderer_->OnSessionConfig(session_->config());
115 monitored_video_stub_.reset(new MonitoredVideoStub(
116 video_renderer_->GetVideoStub(),
117 base::TimeDelta::FromSeconds(
118 MonitoredVideoStub::kConnectivityCheckDelaySeconds),
119 base::Bind(&IceConnectionToHost::OnVideoChannelStatus,
120 base::Unretained(this))));
113 video_dispatcher_.reset( 121 video_dispatcher_.reset(
114 new ClientVideoDispatcher(monitored_video_stub_.get())); 122 new ClientVideoDispatcher(monitored_video_stub_.get()));
115 video_dispatcher_->Init(transport_->GetStreamChannelFactory(), this); 123 video_dispatcher_->Init(transport_->GetStreamChannelFactory(), this);
116 124
125 // Configure audio pipeline if necessary.
117 if (session_->config().is_audio_enabled()) { 126 if (session_->config().is_audio_enabled()) {
118 audio_reader_.reset(new AudioReader(audio_stub_)); 127 audio_reader_.reset(new AudioReader(audio_stub_));
119 audio_reader_->Init(transport_->GetMultiplexedChannelFactory(), this); 128 audio_reader_->Init(transport_->GetMultiplexedChannelFactory(), this);
120 } 129 }
121 break; 130 break;
122 131
123 case Session::CLOSED: 132 case Session::CLOSED:
124 CloseChannels(); 133 CloseChannels();
125 SetState(CLOSED, OK); 134 SetState(CLOSED, OK);
126 break; 135 break;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 225
217 if (state != state_) { 226 if (state != state_) {
218 state_ = state; 227 state_ = state;
219 error_ = error; 228 error_ = error;
220 event_callback_->OnConnectionState(state_, error_); 229 event_callback_->OnConnectionState(state_, error_);
221 } 230 }
222 } 231 }
223 232
224 } // namespace protocol 233 } // namespace protocol
225 } // namespace remoting 234 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/ice_connection_to_host.h ('k') | remoting/protocol/webrtc_connection_to_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698