diff options
author | wez <wez@chromium.org> | 2015-02-13 18:00:05 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-14 02:00:51 +0000 |
commit | d97a44290b2134a57b76e74c374587e3bd4072bb (patch) | |
tree | 619f21142752eb2ef5c8d9071ec7fdafa4590d9d /remoting | |
parent | 6c6a223b13104785a78622175798be8a46af0b18 (diff) | |
download | chromium_src-d97a44290b2134a57b76e74c374587e3bd4072bb.zip chromium_src-d97a44290b2134a57b76e74c374587e3bd4072bb.tar.gz chromium_src-d97a44290b2134a57b76e74c374587e3bd4072bb.tar.bz2 |
Decompose VideoRenderer from VideoStub.
Switch from inheritance to composition, to allow implementations to be
more modular.
Review URL: https://codereview.chromium.org/910343002
Cr-Commit-Position: refs/heads/master@{#316360}
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/chromoting_client.cc | 2 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_video_renderer_2d.cc | 6 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_video_renderer_2d.h | 5 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_video_renderer_3d.cc | 4 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_video_renderer_3d.h | 9 | ||||
-rw-r--r-- | remoting/client/software_video_renderer.cc | 4 | ||||
-rw-r--r-- | remoting/client/software_video_renderer.h | 7 | ||||
-rw-r--r-- | remoting/client/video_renderer.h | 10 | ||||
-rw-r--r-- | remoting/test/protocol_perftest.cc | 4 |
9 files changed, 39 insertions, 12 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index 17a95e1..1ad7223 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -60,7 +60,7 @@ void ChromotingClient::Start( connection_.set_client_stub(this); connection_.set_clipboard_stub(this); - connection_.set_video_stub(video_renderer_); + connection_.set_video_stub(video_renderer_->GetVideoStub()); connection_.set_audio_stub(audio_decode_scheduler_.get()); connection_.Connect(signal_strategy, transport_factory.Pass(), diff --git a/remoting/client/plugin/pepper_video_renderer_2d.cc b/remoting/client/plugin/pepper_video_renderer_2d.cc index 6f3816d..959c0b5 100644 --- a/remoting/client/plugin/pepper_video_renderer_2d.cc +++ b/remoting/client/plugin/pepper_video_renderer_2d.cc @@ -192,12 +192,10 @@ ChromotingStats* PepperVideoRenderer2D::GetStats() { return software_video_renderer_->GetStats(); } -void PepperVideoRenderer2D::ProcessVideoPacket( - scoped_ptr<VideoPacket> video_packet, - const base::Closure& done) { +protocol::VideoStub* PepperVideoRenderer2D::GetVideoStub() { DCHECK(CalledOnValidThread()); - software_video_renderer_->ProcessVideoPacket(video_packet.Pass(), done); + return software_video_renderer_->GetVideoStub(); } void PepperVideoRenderer2D::ApplyBuffer(const webrtc::DesktopSize& view_size, diff --git a/remoting/client/plugin/pepper_video_renderer_2d.h b/remoting/client/plugin/pepper_video_renderer_2d.h index e217994..8b19475 100644 --- a/remoting/client/plugin/pepper_video_renderer_2d.h +++ b/remoting/client/plugin/pepper_video_renderer_2d.h @@ -47,10 +47,11 @@ class PepperVideoRenderer2D : public PepperVideoRenderer, const ClientContext& context, EventHandler* event_handler) override; void OnViewChanged(const pp::View& view) override; + + // VideoRenderer interface. void OnSessionConfig(const protocol::SessionConfig& config) override; ChromotingStats* GetStats() override; - void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, - const base::Closure& done) override; + protocol::VideoStub* GetVideoStub() override; private: // FrameConsumer implementation. diff --git a/remoting/client/plugin/pepper_video_renderer_3d.cc b/remoting/client/plugin/pepper_video_renderer_3d.cc index de2d65a..91f0677 100644 --- a/remoting/client/plugin/pepper_video_renderer_3d.cc +++ b/remoting/client/plugin/pepper_video_renderer_3d.cc @@ -177,6 +177,10 @@ ChromotingStats* PepperVideoRenderer3D::GetStats() { return &stats_; } +protocol::VideoStub* PepperVideoRenderer3D::GetVideoStub() { + return this; +} + void PepperVideoRenderer3D::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, const base::Closure& done) { base::ScopedClosureRunner done_runner(done); diff --git a/remoting/client/plugin/pepper_video_renderer_3d.h b/remoting/client/plugin/pepper_video_renderer_3d.h index 473d4f3..b5d77aa 100644 --- a/remoting/client/plugin/pepper_video_renderer_3d.h +++ b/remoting/client/plugin/pepper_video_renderer_3d.h @@ -17,6 +17,7 @@ #include "ppapi/utility/completion_callback_factory.h" #include "remoting/client/chromoting_stats.h" #include "remoting/client/plugin/pepper_video_renderer.h" +#include "remoting/protocol/video_stub.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" @@ -26,7 +27,8 @@ namespace remoting { // PepperVideoRenderer that uses the PPB_VideoDecoder interface for video // decoding and Graphics3D for rendering. -class PepperVideoRenderer3D : public PepperVideoRenderer { +class PepperVideoRenderer3D : public PepperVideoRenderer, + public protocol::VideoStub { public: PepperVideoRenderer3D(); ~PepperVideoRenderer3D() override; @@ -36,8 +38,13 @@ class PepperVideoRenderer3D : public PepperVideoRenderer { const ClientContext& context, EventHandler* event_handler) override; void OnViewChanged(const pp::View& view) override; + + // VideoRenderer interface. void OnSessionConfig(const protocol::SessionConfig& config) override; ChromotingStats* GetStats() override; + protocol::VideoStub* GetVideoStub() override; + + // protocol::VideoStub interface. void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, const base::Closure& done) override; diff --git a/remoting/client/software_video_renderer.cc b/remoting/client/software_video_renderer.cc index 49c7683..0be8b49 100644 --- a/remoting/client/software_video_renderer.cc +++ b/remoting/client/software_video_renderer.cc @@ -341,6 +341,10 @@ ChromotingStats* SoftwareVideoRenderer::GetStats() { return &stats_; } +protocol::VideoStub* SoftwareVideoRenderer::GetVideoStub() { + return this; +} + void SoftwareVideoRenderer::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, const base::Closure& done) { DCHECK(CalledOnValidThread()); diff --git a/remoting/client/software_video_renderer.h b/remoting/client/software_video_renderer.h index 6843432..11be6dc 100644 --- a/remoting/client/software_video_renderer.h +++ b/remoting/client/software_video_renderer.h @@ -11,6 +11,7 @@ #include "remoting/client/frame_consumer_proxy.h" #include "remoting/client/frame_producer.h" #include "remoting/client/video_renderer.h" +#include "remoting/protocol/video_stub.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" namespace base { @@ -27,6 +28,7 @@ class ChromotingStats; // called on the main thread. Owned must ensure that this class outlives // FrameConsumer (which calls FrameProducer interface). class SoftwareVideoRenderer : public VideoRenderer, + public protocol::VideoStub, public FrameProducer, public base::NonThreadSafe { public: @@ -41,9 +43,12 @@ class SoftwareVideoRenderer : public VideoRenderer, scoped_refptr<FrameConsumerProxy> consumer); ~SoftwareVideoRenderer() override; - // VideoRenderer implementation. + // VideoRenderer interface. void OnSessionConfig(const protocol::SessionConfig& config) override; ChromotingStats* GetStats() override; + protocol::VideoStub* GetVideoStub() override; + + // protocol::VideoStub interface. void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, const base::Closure& done) override; diff --git a/remoting/client/video_renderer.h b/remoting/client/video_renderer.h index 8ba04f0..221c824 100644 --- a/remoting/client/video_renderer.h +++ b/remoting/client/video_renderer.h @@ -5,26 +5,30 @@ #ifndef REMOTING_CLIENT_VIDEO_RENDERER_H_ #define REMOTING_CLIENT_VIDEO_RENDERER_H_ -#include "remoting/protocol/video_stub.h" - namespace remoting { class ChromotingStats; namespace protocol { class SessionConfig; +class VideoStub; } // namespace protocol; // VideoRenderer is responsible for decoding and displaying incoming video // stream. -class VideoRenderer : public protocol::VideoStub { +class VideoRenderer { public: + virtual ~VideoRenderer() {} + // Configures the renderer with the supplied |config|. This must be called // exactly once before video data is supplied to the renderer. virtual void OnSessionConfig(const protocol::SessionConfig& config) = 0; // Return the statistics recorded by this client. virtual ChromotingStats* GetStats() = 0; + + // Returns the VideoStub interface of this renderer. + virtual protocol::VideoStub* GetVideoStub() = 0; }; } // namespace remoting diff --git a/remoting/test/protocol_perftest.cc b/remoting/test/protocol_perftest.cc index f5edd8fd..d08b117 100644 --- a/remoting/test/protocol_perftest.cc +++ b/remoting/test/protocol_perftest.cc @@ -75,6 +75,7 @@ class ProtocolPerfTest public testing::WithParamInterface<NetworkPerformanceParams>, public ClientUserInterface, public VideoRenderer, + public protocol::VideoStub, public HostStatusObserver { public: ProtocolPerfTest() @@ -119,6 +120,9 @@ class ProtocolPerfTest // VideoRenderer interface. void OnSessionConfig(const protocol::SessionConfig& config) override {} ChromotingStats* GetStats() override { return nullptr; } + protocol::VideoStub* GetVideoStub() override { return this; } + + // protocol::VideoStub interface. void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, const base::Closure& done) override { if (video_packet->data().empty()) { |