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

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

Issue 1580823003: Implement client-side video stream support for WebRTC-based protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@packet_options_rem
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/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 "jingle/glue/thread_wrapper.h" 9 #include "jingle/glue/thread_wrapper.h"
10 #include "remoting/protocol/client_control_dispatcher.h" 10 #include "remoting/protocol/client_control_dispatcher.h"
11 #include "remoting/protocol/client_event_dispatcher.h" 11 #include "remoting/protocol/client_event_dispatcher.h"
12 #include "remoting/protocol/client_stub.h" 12 #include "remoting/protocol/client_stub.h"
13 #include "remoting/protocol/clipboard_stub.h" 13 #include "remoting/protocol/clipboard_stub.h"
14 #include "remoting/protocol/transport_context.h" 14 #include "remoting/protocol/transport_context.h"
15 #include "remoting/protocol/video_renderer.h"
15 #include "remoting/protocol/webrtc_transport.h" 16 #include "remoting/protocol/webrtc_transport.h"
17 #include "remoting/protocol/webrtc_video_renderer_adapter.h"
16 18
17 namespace remoting { 19 namespace remoting {
18 namespace protocol { 20 namespace protocol {
19 21
20 WebrtcConnectionToHost::WebrtcConnectionToHost() {} 22 WebrtcConnectionToHost::WebrtcConnectionToHost() {}
21 WebrtcConnectionToHost::~WebrtcConnectionToHost() {} 23 WebrtcConnectionToHost::~WebrtcConnectionToHost() {}
22 24
23 void WebrtcConnectionToHost::Connect( 25 void WebrtcConnectionToHost::Connect(
24 scoped_ptr<Session> session, 26 scoped_ptr<Session> session,
25 scoped_refptr<TransportContext> transport_context, 27 scoped_refptr<TransportContext> transport_context,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 59
58 void WebrtcConnectionToHost::set_client_stub(ClientStub* client_stub) { 60 void WebrtcConnectionToHost::set_client_stub(ClientStub* client_stub) {
59 client_stub_ = client_stub; 61 client_stub_ = client_stub;
60 } 62 }
61 63
62 void WebrtcConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) { 64 void WebrtcConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) {
63 clipboard_stub_ = clipboard_stub; 65 clipboard_stub_ = clipboard_stub;
64 } 66 }
65 67
66 void WebrtcConnectionToHost::set_video_renderer(VideoRenderer* video_renderer) { 68 void WebrtcConnectionToHost::set_video_renderer(VideoRenderer* video_renderer) {
67 NOTIMPLEMENTED(); 69 video_renderer_ = video_renderer;
68 } 70 }
69 71
70 void WebrtcConnectionToHost::set_audio_stub(AudioStub* audio_stub) { 72 void WebrtcConnectionToHost::set_audio_stub(AudioStub* audio_stub) {
71 NOTIMPLEMENTED(); 73 NOTIMPLEMENTED();
72 } 74 }
73 75
74 void WebrtcConnectionToHost::OnSessionStateChange(Session::State state) { 76 void WebrtcConnectionToHost::OnSessionStateChange(Session::State state) {
75 DCHECK(event_callback_); 77 DCHECK(event_callback_);
76 78
77 switch (state) { 79 switch (state) {
78 case Session::INITIALIZING: 80 case Session::INITIALIZING:
79 case Session::CONNECTING: 81 case Session::CONNECTING:
80 case Session::ACCEPTING: 82 case Session::ACCEPTING:
81 case Session::ACCEPTED: 83 case Session::ACCEPTED:
82 case Session::AUTHENTICATING: 84 case Session::AUTHENTICATING:
83 // Don't care about these events. 85 // Don't care about these events.
84 break; 86 break;
85 87
86 case Session::AUTHENTICATED: 88 case Session::AUTHENTICATED:
87 SetState(AUTHENTICATED, OK); 89 SetState(AUTHENTICATED, OK);
88 break; 90 break;
89 91
90 case Session::CLOSED: 92 case Session::CLOSED:
93 CloseChannels();
94 SetState(CLOSED, OK);
95 break;
96
91 case Session::FAILED: 97 case Session::FAILED:
92 CloseChannels(); 98 CloseChannels();
93 SetState(CLOSED, state == Session::FAILED ? session_->error() : OK); 99 SetState(FAILED, session_->error());
94 break; 100 break;
95 } 101 }
96 } 102 }
97 103
98 void WebrtcConnectionToHost::OnWebrtcTransportConnecting() { 104 void WebrtcConnectionToHost::OnWebrtcTransportConnecting() {
99 control_dispatcher_.reset(new ClientControlDispatcher()); 105 control_dispatcher_.reset(new ClientControlDispatcher());
100 control_dispatcher_->Init(transport_->incoming_channel_factory(), this); 106 control_dispatcher_->Init(transport_->incoming_channel_factory(), this);
101 control_dispatcher_->set_client_stub(client_stub_); 107 control_dispatcher_->set_client_stub(client_stub_);
102 control_dispatcher_->set_clipboard_stub(clipboard_stub_); 108 control_dispatcher_->set_clipboard_stub(clipboard_stub_);
103 109
104 event_dispatcher_.reset(new ClientEventDispatcher()); 110 event_dispatcher_.reset(new ClientEventDispatcher());
105 event_dispatcher_->Init(transport_->outgoing_channel_factory(), this); 111 event_dispatcher_->Init(transport_->outgoing_channel_factory(), this);
106 } 112 }
107 113
108 void WebrtcConnectionToHost::OnWebrtcTransportConnected() {} 114 void WebrtcConnectionToHost::OnWebrtcTransportConnected() {}
109 115
110 void WebrtcConnectionToHost::OnWebrtcTransportError(ErrorCode error) { 116 void WebrtcConnectionToHost::OnWebrtcTransportError(ErrorCode error) {
111 CloseChannels(); 117 CloseChannels();
112 SetState(FAILED, error); 118 SetState(FAILED, error);
113 } 119 }
114 120
121 void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamAdded(
122 scoped_refptr<webrtc::MediaStreamInterface> stream) {
123 video_adapter_.reset(new WebrtcVideoRendererAdapter(
124 stream, video_renderer_->GetFrameConsumer()));
Jamie 2016/01/12 21:00:04 Does this add an additional stream, or replace the
Sergey Ulanov 2016/01/12 22:13:45 Done.
125 }
126
127 void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamRemoved(
128 scoped_refptr<webrtc::MediaStreamInterface> stream) {
129 if (video_adapter_ && video_adapter_->label() == stream->label())
130 video_adapter_.reset();
131 }
132
115 void WebrtcConnectionToHost::OnChannelInitialized( 133 void WebrtcConnectionToHost::OnChannelInitialized(
116 ChannelDispatcherBase* channel_dispatcher) { 134 ChannelDispatcherBase* channel_dispatcher) {
117 NotifyIfChannelsReady(); 135 NotifyIfChannelsReady();
118 } 136 }
119 137
120 void WebrtcConnectionToHost::OnChannelError( 138 void WebrtcConnectionToHost::OnChannelError(
121 ChannelDispatcherBase* channel_dispatcher, 139 ChannelDispatcherBase* channel_dispatcher,
122 ErrorCode error) { 140 ErrorCode error) {
123 LOG(ERROR) << "Failed to connect channel " << channel_dispatcher; 141 LOG(ERROR) << "Failed to connect channel " << channel_dispatcher;
124 CloseChannels(); 142 CloseChannels();
(...skipping 29 matching lines...) Expand all
154 172
155 if (state != state_) { 173 if (state != state_) {
156 state_ = state; 174 state_ = state;
157 error_ = error; 175 error_ = error;
158 event_callback_->OnConnectionState(state_, error_); 176 event_callback_->OnConnectionState(state_, error_);
159 } 177 }
160 } 178 }
161 179
162 } // namespace protocol 180 } // namespace protocol
163 } // namespace remoting 181 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698