Index: remoting/protocol/webrtc_connection_to_host.cc |
diff --git a/remoting/protocol/webrtc_connection_to_host.cc b/remoting/protocol/webrtc_connection_to_host.cc |
index 9733163a3e1cf86e1fd98061531710e50f149a65..351bb8d3535b06540e519069fc2ae0a818280a47 100644 |
--- a/remoting/protocol/webrtc_connection_to_host.cc |
+++ b/remoting/protocol/webrtc_connection_to_host.cc |
@@ -12,7 +12,9 @@ |
#include "remoting/protocol/client_stub.h" |
#include "remoting/protocol/clipboard_stub.h" |
#include "remoting/protocol/transport_context.h" |
+#include "remoting/protocol/video_renderer.h" |
#include "remoting/protocol/webrtc_transport.h" |
+#include "remoting/protocol/webrtc_video_renderer_adapter.h" |
namespace remoting { |
namespace protocol { |
@@ -64,7 +66,7 @@ void WebrtcConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) { |
} |
void WebrtcConnectionToHost::set_video_renderer(VideoRenderer* video_renderer) { |
- NOTIMPLEMENTED(); |
+ video_renderer_ = video_renderer; |
} |
void WebrtcConnectionToHost::set_audio_stub(AudioStub* audio_stub) { |
@@ -88,9 +90,13 @@ void WebrtcConnectionToHost::OnSessionStateChange(Session::State state) { |
break; |
case Session::CLOSED: |
+ CloseChannels(); |
+ SetState(CLOSED, OK); |
+ break; |
+ |
case Session::FAILED: |
CloseChannels(); |
- SetState(CLOSED, state == Session::FAILED ? session_->error() : OK); |
+ SetState(FAILED, session_->error()); |
break; |
} |
} |
@@ -112,6 +118,22 @@ void WebrtcConnectionToHost::OnWebrtcTransportError(ErrorCode error) { |
SetState(FAILED, error); |
} |
+void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamAdded( |
+ scoped_refptr<webrtc::MediaStreamInterface> stream) { |
+ if (video_adapter_) { |
+ LOG(WARNING) |
+ << "Received multiple media streams. Ignoring all except the last one."; |
+ } |
+ video_adapter_.reset(new WebrtcVideoRendererAdapter( |
+ stream, video_renderer_->GetFrameConsumer())); |
+} |
+ |
+void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamRemoved( |
+ scoped_refptr<webrtc::MediaStreamInterface> stream) { |
+ if (video_adapter_ && video_adapter_->label() == stream->label()) |
+ video_adapter_.reset(); |
+} |
+ |
void WebrtcConnectionToHost::OnChannelInitialized( |
ChannelDispatcherBase* channel_dispatcher) { |
NotifyIfChannelsReady(); |