summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu <sergeyu@chromium.org>2016-01-05 15:36:44 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-05 23:37:58 +0000
commit0b57073aeb86bb2ed5977d873f0276aa03a7f6f3 (patch)
tree2bcafc3b094273bba4addfa617c29fcda0110ff0 /remoting
parent2ad80c25c9a20d0dad00305ba10cf26dc4128e36 (diff)
downloadchromium_src-0b57073aeb86bb2ed5977d873f0276aa03a7f6f3.zip
chromium_src-0b57073aeb86bb2ed5977d873f0276aa03a7f6f3.tar.gz
chromium_src-0b57073aeb86bb2ed5977d873f0276aa03a7f6f3.tar.bz2
Pass VideoRenderer interface to ConnectionToHost.
WebrtcConnectionToHost will need to access VideoRenderer to be able to render incoming video frames. Previously it was taking VideoStub which accepts only encoded frame. BUG=547158 Review URL: https://codereview.chromium.org/1559933003 Cr-Commit-Position: refs/heads/master@{#367692}
Diffstat (limited to 'remoting')
-rw-r--r--remoting/client/chromoting_client.cc3
-rw-r--r--remoting/protocol/BUILD.gn2
-rw-r--r--remoting/protocol/connection_to_host.h4
-rw-r--r--remoting/protocol/connection_unittest.cc5
-rw-r--r--remoting/protocol/fake_connection_to_host.cc3
-rw-r--r--remoting/protocol/fake_connection_to_host.h2
-rw-r--r--remoting/protocol/fake_video_renderer.cc40
-rw-r--r--remoting/protocol/fake_video_renderer.h45
-rw-r--r--remoting/protocol/ice_connection_to_host.cc27
-rw-r--r--remoting/protocol/ice_connection_to_host.h3
-rw-r--r--remoting/protocol/webrtc_connection_to_host.cc2
-rw-r--r--remoting/protocol/webrtc_connection_to_host.h2
-rw-r--r--remoting/remoting_test.gypi2
13 files changed, 120 insertions, 20 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index ed4ce78..67973e2 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -67,7 +67,7 @@ void ChromotingClient::Start(
connection_->set_client_stub(this);
connection_->set_clipboard_stub(this);
- connection_->set_video_stub(video_renderer_->GetVideoStub());
+ connection_->set_video_renderer(video_renderer_);
connection_->set_audio_stub(audio_decode_scheduler_.get());
session_manager_.reset(new protocol::JingleSessionManager(signal_strategy));
@@ -209,7 +209,6 @@ void ChromotingClient::OnAuthenticated() {
DCHECK(thread_checker_.CalledOnValidThread());
// Initialize the decoder.
- video_renderer_->OnSessionConfig(connection_->config());
if (connection_->config().is_audio_enabled())
audio_decode_scheduler_->Initialize(connection_->config());
}
diff --git a/remoting/protocol/BUILD.gn b/remoting/protocol/BUILD.gn
index 14934aa..c9f30f3 100644
--- a/remoting/protocol/BUILD.gn
+++ b/remoting/protocol/BUILD.gn
@@ -73,6 +73,8 @@ source_set("test_support") {
"fake_session.h",
"fake_stream_socket.cc",
"fake_stream_socket.h",
+ "fake_video_renderer.cc",
+ "fake_video_renderer.h",
"protocol_mock_objects.cc",
"protocol_mock_objects.h",
]
diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h
index d92905b..575f1da 100644
--- a/remoting/protocol/connection_to_host.h
+++ b/remoting/protocol/connection_to_host.h
@@ -24,7 +24,7 @@ class Session;
class SessionConfig;
class TransportContext;
struct TransportRoute;
-class VideoStub;
+class VideoRenderer;
class ConnectionToHost {
public:
@@ -70,7 +70,7 @@ class ConnectionToHost {
// is called.
virtual void set_client_stub(ClientStub* client_stub) = 0;
virtual void set_clipboard_stub(ClipboardStub* clipboard_stub) = 0;
- virtual void set_video_stub(VideoStub* video_stub) = 0;
+ virtual void set_video_renderer(VideoRenderer* video_renderer) = 0;
// If no audio stub is specified then audio will not be requested.
virtual void set_audio_stub(AudioStub* audio_stub) = 0;
diff --git a/remoting/protocol/connection_unittest.cc b/remoting/protocol/connection_unittest.cc
index b5be849..a67727c 100644
--- a/remoting/protocol/connection_unittest.cc
+++ b/remoting/protocol/connection_unittest.cc
@@ -10,6 +10,7 @@
#include "base/run_loop.h"
#include "remoting/base/constants.h"
#include "remoting/protocol/fake_session.h"
+#include "remoting/protocol/fake_video_renderer.h"
#include "remoting/protocol/ice_connection_to_client.h"
#include "remoting/protocol/ice_connection_to_host.h"
#include "remoting/protocol/protocol_mock_objects.h"
@@ -90,7 +91,7 @@ class ConnectionTest : public testing::Test,
// Setup client side.
client_connection_->set_client_stub(&client_stub_);
client_connection_->set_clipboard_stub(&client_clipboard_stub_);
- client_connection_->set_video_stub(&client_video_stub_);
+ client_connection_->set_video_renderer(&client_video_renderer_);
}
void Connect() {
@@ -167,7 +168,7 @@ class ConnectionTest : public testing::Test,
MockConnectionToHostEventCallback client_event_handler_;
MockClientStub client_stub_;
MockClipboardStub client_clipboard_stub_;
- MockVideoStub client_video_stub_;
+ FakeVideoRenderer client_video_renderer_;
scoped_ptr<ConnectionToHost> client_connection_;
FakeSession* client_session_; // Owned by |client_connection_|.
scoped_ptr<FakeSession> owned_client_session_;
diff --git a/remoting/protocol/fake_connection_to_host.cc b/remoting/protocol/fake_connection_to_host.cc
index cbec769..36703ee 100644
--- a/remoting/protocol/fake_connection_to_host.cc
+++ b/remoting/protocol/fake_connection_to_host.cc
@@ -19,7 +19,8 @@ void FakeConnectionToHost::set_client_stub(protocol::ClientStub* client_stub) {}
void FakeConnectionToHost::set_clipboard_stub(
protocol::ClipboardStub* clipboard_stub) {}
-void FakeConnectionToHost::set_video_stub(protocol::VideoStub* video_stub) {}
+void FakeConnectionToHost::set_video_renderer(
+ protocol::VideoRenderer* video_renderer) {}
void FakeConnectionToHost::set_audio_stub(protocol::AudioStub* audio_stub) {}
diff --git a/remoting/protocol/fake_connection_to_host.h b/remoting/protocol/fake_connection_to_host.h
index 62f93b1..082a95f 100644
--- a/remoting/protocol/fake_connection_to_host.h
+++ b/remoting/protocol/fake_connection_to_host.h
@@ -22,7 +22,7 @@ class FakeConnectionToHost : public protocol::ConnectionToHost {
// ConnectionToHost interface.
void set_client_stub(protocol::ClientStub* client_stub) override;
void set_clipboard_stub(protocol::ClipboardStub* clipboard_stub) override;
- void set_video_stub(protocol::VideoStub* video_stub) override;
+ void set_video_renderer(protocol::VideoRenderer* video_renderer) override;
void set_audio_stub(protocol::AudioStub* audio_stub) override;
void Connect(scoped_ptr<protocol::Session> session,
scoped_refptr<protocol::TransportContext> transport_context,
diff --git a/remoting/protocol/fake_video_renderer.cc b/remoting/protocol/fake_video_renderer.cc
new file mode 100644
index 0000000..faecf9b
--- /dev/null
+++ b/remoting/protocol/fake_video_renderer.cc
@@ -0,0 +1,40 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/fake_video_renderer.h"
+
+#include <utility>
+
+#include "base/callback.h"
+#include "base/logging.h"
+#include "remoting/proto/video.pb.h"
+
+namespace remoting {
+namespace protocol {
+
+FakeVideoStub::FakeVideoStub() {}
+FakeVideoStub::~FakeVideoStub() {}
+
+void FakeVideoStub::ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet,
+ const base::Closure& done) {
+ received_packets_.push_back(std::move(video_packet));
+ done.Run();
+}
+
+FakeVideoRenderer::FakeVideoRenderer() {}
+FakeVideoRenderer::~FakeVideoRenderer() {}
+
+void FakeVideoRenderer::OnSessionConfig(const SessionConfig& config) {}
+
+FakeVideoStub* FakeVideoRenderer::GetVideoStub() {
+ return &video_stub_;
+}
+
+FrameConsumer* FakeVideoRenderer::GetFrameConsumer() {
+ NOTIMPLEMENTED();
+ return nullptr;
+}
+
+} // namespace protocol
+} // namespace remoting
diff --git a/remoting/protocol/fake_video_renderer.h b/remoting/protocol/fake_video_renderer.h
new file mode 100644
index 0000000..a23f748
--- /dev/null
+++ b/remoting/protocol/fake_video_renderer.h
@@ -0,0 +1,45 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_PROTOCOL_FAKE_VIDEO_RENDERER_H_
+#define REMOTING_PROTOCOL_FAKE_VIDEO_RENDERER_H_
+
+#include <list>
+
+#include "remoting/protocol/video_renderer.h"
+#include "remoting/protocol/video_stub.h"
+
+namespace remoting {
+namespace protocol {
+
+class FakeVideoStub : public VideoStub {
+ public:
+ FakeVideoStub();
+ ~FakeVideoStub() override;
+
+ // VideoStub interface.
+ void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet,
+ const base::Closure& done) override;
+ private:
+ std::list<scoped_ptr<VideoPacket>> received_packets_;
+};
+
+class FakeVideoRenderer : public VideoRenderer {
+ public:
+ FakeVideoRenderer();
+ ~FakeVideoRenderer() override;
+
+ // VideoRenderer interface.
+ void OnSessionConfig(const SessionConfig& config) override;
+ FakeVideoStub* GetVideoStub() override;
+ FrameConsumer* GetFrameConsumer() override;
+
+ private:
+ FakeVideoStub video_stub_;
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_FAKE_VIDEO_RENDERER_H_
diff --git a/remoting/protocol/ice_connection_to_host.cc b/remoting/protocol/ice_connection_to_host.cc
index ddb77c7..28e5e62 100644
--- a/remoting/protocol/ice_connection_to_host.cc
+++ b/remoting/protocol/ice_connection_to_host.cc
@@ -21,7 +21,7 @@
#include "remoting/protocol/errors.h"
#include "remoting/protocol/ice_transport.h"
#include "remoting/protocol/transport_context.h"
-#include "remoting/protocol/video_stub.h"
+#include "remoting/protocol/video_renderer.h"
namespace remoting {
namespace protocol {
@@ -35,7 +35,7 @@ void IceConnectionToHost::Connect(
HostEventCallback* event_callback) {
DCHECK(client_stub_);
DCHECK(clipboard_stub_);
- DCHECK(monitored_video_stub_);
+ DCHECK(video_renderer_);
transport_.reset(new IceTransport(transport_context, this));
@@ -73,13 +73,10 @@ void IceConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) {
clipboard_stub_ = clipboard_stub;
}
-void IceConnectionToHost::set_video_stub(VideoStub* video_stub) {
- DCHECK(video_stub);
- monitored_video_stub_.reset(new MonitoredVideoStub(
- video_stub, base::TimeDelta::FromSeconds(
- MonitoredVideoStub::kConnectivityCheckDelaySeconds),
- base::Bind(&IceConnectionToHost::OnVideoChannelStatus,
- base::Unretained(this))));
+void IceConnectionToHost::set_video_renderer(VideoRenderer* video_renderer) {
+ DCHECK(video_renderer);
+ DCHECK(!monitored_video_stub_);
+ video_renderer_ = video_renderer;
}
void IceConnectionToHost::set_audio_stub(AudioStub* audio_stub) {
@@ -101,19 +98,31 @@ void IceConnectionToHost::OnSessionStateChange(Session::State state) {
case Session::AUTHENTICATED:
SetState(AUTHENTICATED, OK);
+
+ // Setup control channel.
control_dispatcher_.reset(new ClientControlDispatcher());
control_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(),
this);
control_dispatcher_->set_client_stub(client_stub_);
control_dispatcher_->set_clipboard_stub(clipboard_stub_);
+ // Setup event channel.
event_dispatcher_.reset(new ClientEventDispatcher());
event_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(), this);
+ // Configure video pipeline.
+ video_renderer_->OnSessionConfig(session_->config());
+ monitored_video_stub_.reset(new MonitoredVideoStub(
+ video_renderer_->GetVideoStub(),
+ base::TimeDelta::FromSeconds(
+ MonitoredVideoStub::kConnectivityCheckDelaySeconds),
+ base::Bind(&IceConnectionToHost::OnVideoChannelStatus,
+ base::Unretained(this))));
video_dispatcher_.reset(
new ClientVideoDispatcher(monitored_video_stub_.get()));
video_dispatcher_->Init(transport_->GetStreamChannelFactory(), this);
+ // Configure audio pipeline if necessary.
if (session_->config().is_audio_enabled()) {
audio_reader_.reset(new AudioReader(audio_stub_));
audio_reader_->Init(transport_->GetMultiplexedChannelFactory(), this);
diff --git a/remoting/protocol/ice_connection_to_host.h b/remoting/protocol/ice_connection_to_host.h
index 6cc8e15..717106c 100644
--- a/remoting/protocol/ice_connection_to_host.h
+++ b/remoting/protocol/ice_connection_to_host.h
@@ -45,7 +45,7 @@ class IceConnectionToHost : public ConnectionToHost,
// ConnectionToHost interface.
void set_client_stub(ClientStub* client_stub) override;
void set_clipboard_stub(ClipboardStub* clipboard_stub) override;
- void set_video_stub(VideoStub* video_stub) override;
+ void set_video_renderer(VideoRenderer* video_renderer) override;
void set_audio_stub(AudioStub* audio_stub) override;
void Connect(scoped_ptr<Session> session,
scoped_refptr<TransportContext> transport_context,
@@ -87,6 +87,7 @@ class IceConnectionToHost : public ConnectionToHost,
// Stub for incoming messages.
ClientStub* client_stub_ = nullptr;
ClipboardStub* clipboard_stub_ = nullptr;
+ VideoRenderer* video_renderer_ = nullptr;
AudioStub* audio_stub_ = nullptr;
scoped_ptr<Session> session_;
diff --git a/remoting/protocol/webrtc_connection_to_host.cc b/remoting/protocol/webrtc_connection_to_host.cc
index 43b7a4f..0ca6e7c 100644
--- a/remoting/protocol/webrtc_connection_to_host.cc
+++ b/remoting/protocol/webrtc_connection_to_host.cc
@@ -63,7 +63,7 @@ void WebrtcConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) {
clipboard_stub_ = clipboard_stub;
}
-void WebrtcConnectionToHost::set_video_stub(VideoStub* video_stub) {
+void WebrtcConnectionToHost::set_video_renderer(VideoRenderer* video_renderer) {
NOTIMPLEMENTED();
}
diff --git a/remoting/protocol/webrtc_connection_to_host.h b/remoting/protocol/webrtc_connection_to_host.h
index 79b97e0..f8afd4f 100644
--- a/remoting/protocol/webrtc_connection_to_host.h
+++ b/remoting/protocol/webrtc_connection_to_host.h
@@ -35,7 +35,7 @@ class WebrtcConnectionToHost : public ConnectionToHost,
// ConnectionToHost interface.
void set_client_stub(ClientStub* client_stub) override;
void set_clipboard_stub(ClipboardStub* clipboard_stub) override;
- void set_video_stub(VideoStub* video_stub) override;
+ void set_video_renderer(VideoRenderer* video_renderer) override;
void set_audio_stub(AudioStub* audio_stub) override;
void Connect(scoped_ptr<Session> session,
scoped_refptr<TransportContext> transport_context,
diff --git a/remoting/remoting_test.gypi b/remoting/remoting_test.gypi
index 7f86751..fe8edf4 100644
--- a/remoting/remoting_test.gypi
+++ b/remoting/remoting_test.gypi
@@ -44,6 +44,8 @@
'protocol/fake_session.h',
'protocol/fake_stream_socket.cc',
'protocol/fake_stream_socket.h',
+ 'protocol/fake_video_renderer.cc',
+ 'protocol/fake_video_renderer.h',
'protocol/protocol_mock_objects.cc',
'protocol/protocol_mock_objects.h',
'protocol/test_event_matchers.h',