Commit 0b57073a authored by sergeyu's avatar sergeyu Committed by Commit bot

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}
parent 2ad80c25
......@@ -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());
}
......
......@@ -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",
]
......
......@@ -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;
......
......@@ -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_;
......
......@@ -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) {}
......
......@@ -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,
......
// 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
// 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_
......@@ -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);
......
......@@ -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_;
......
......@@ -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();
}
......
......@@ -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,
......
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment