diff options
Diffstat (limited to 'remoting/protocol')
-rw-r--r-- | remoting/protocol/BUILD.gn | 12 | ||||
-rw-r--r-- | remoting/protocol/client_video_dispatcher.cc | 30 | ||||
-rw-r--r-- | remoting/protocol/client_video_dispatcher.h | 39 | ||||
-rw-r--r-- | remoting/protocol/connection_to_client.cc | 15 | ||||
-rw-r--r-- | remoting/protocol/connection_to_client.h | 9 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.cc | 11 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.h | 4 | ||||
-rw-r--r-- | remoting/protocol/host_video_dispatcher.cc | 34 | ||||
-rw-r--r-- | remoting/protocol/host_video_dispatcher.h | 40 | ||||
-rw-r--r-- | remoting/protocol/protobuf_video_reader.cc | 63 | ||||
-rw-r--r-- | remoting/protocol/protobuf_video_reader.h | 57 | ||||
-rw-r--r-- | remoting/protocol/protobuf_video_writer.cc | 70 | ||||
-rw-r--r-- | remoting/protocol/protobuf_video_writer.h | 57 | ||||
-rw-r--r-- | remoting/protocol/video_reader.cc | 38 | ||||
-rw-r--r-- | remoting/protocol/video_reader.h | 49 | ||||
-rw-r--r-- | remoting/protocol/video_writer.cc | 25 | ||||
-rw-r--r-- | remoting/protocol/video_writer.h | 52 |
17 files changed, 169 insertions, 436 deletions
diff --git a/remoting/protocol/BUILD.gn b/remoting/protocol/BUILD.gn index 4a7fa0e..03df5a2 100644 --- a/remoting/protocol/BUILD.gn +++ b/remoting/protocol/BUILD.gn @@ -31,6 +31,8 @@ static_library("protocol") { "client_event_dispatcher.cc", "client_event_dispatcher.h", "client_stub.h", + "client_video_dispatcher.cc", + "client_video_dispatcher.h", "clipboard_echo_filter.cc", "clipboard_echo_filter.h", "clipboard_filter.cc", @@ -51,6 +53,8 @@ static_library("protocol") { "host_event_dispatcher.cc", "host_event_dispatcher.h", "host_stub.h", + "host_video_dispatcher.cc", + "host_video_dispatcher.h", "input_event_tracker.cc", "input_event_tracker.h", "input_filter.cc", @@ -95,10 +99,6 @@ static_library("protocol") { "pairing_host_authenticator.h", "pairing_registry.cc", "pairing_registry.h", - "protobuf_video_reader.cc", - "protobuf_video_reader.h", - "protobuf_video_writer.cc", - "protobuf_video_writer.h", "pseudotcp_channel_factory.cc", "pseudotcp_channel_factory.h", "secure_channel_factory.cc", @@ -123,11 +123,7 @@ static_library("protocol") { "transport.h", "v2_authenticator.cc", "v2_authenticator.h", - "video_reader.cc", - "video_reader.h", "video_stub.h", - "video_writer.cc", - "video_writer.h", "../signaling/iq_sender.cc", "../signaling/iq_sender.h", "../signaling/jingle_info_request.cc", diff --git a/remoting/protocol/client_video_dispatcher.cc b/remoting/protocol/client_video_dispatcher.cc new file mode 100644 index 0000000..bca586c --- /dev/null +++ b/remoting/protocol/client_video_dispatcher.cc @@ -0,0 +1,30 @@ +// Copyright 2014 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/client_video_dispatcher.h" + +#include "base/bind.h" +#include "net/socket/stream_socket.h" +#include "remoting/base/constants.h" +#include "remoting/proto/video.pb.h" +#include "remoting/protocol/video_stub.h" + +namespace remoting { +namespace protocol { + +ClientVideoDispatcher::ClientVideoDispatcher(VideoStub* video_stub) + : ChannelDispatcherBase(kVideoChannelName), + video_stub_(video_stub) { +} + +ClientVideoDispatcher::~ClientVideoDispatcher() { +} + +void ClientVideoDispatcher::OnInitialized() { + reader_.Init(channel(), base::Bind(&VideoStub::ProcessVideoPacket, + base::Unretained(video_stub_))); +} + +} // namespace protocol +} // namespace remoting diff --git a/remoting/protocol/client_video_dispatcher.h b/remoting/protocol/client_video_dispatcher.h new file mode 100644 index 0000000..f62525c6 --- /dev/null +++ b/remoting/protocol/client_video_dispatcher.h @@ -0,0 +1,39 @@ +// Copyright 2014 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_CLIENT_VIDEO_DISPATCHER_H_ +#define REMOTING_PROTOCOL_CLIENT_VIDEO_DISPATCHER_H_ + +#include "base/compiler_specific.h" +#include "remoting/proto/video.pb.h" +#include "remoting/protocol/channel_dispatcher_base.h" +#include "remoting/protocol/message_reader.h" + +namespace remoting { +namespace protocol { + +class VideoStub; + +class ClientVideoDispatcher : public ChannelDispatcherBase { + public: + explicit ClientVideoDispatcher(VideoStub* video_stub); + virtual ~ClientVideoDispatcher(); + + protected: + // ChannelDispatcherBase overrides. + virtual void OnInitialized() OVERRIDE; + + private: + ProtobufMessageReader<VideoPacket> reader_; + + // The stub to which VideoPackets are passed for processing. + VideoStub* video_stub_; + + DISALLOW_COPY_AND_ASSIGN(ClientVideoDispatcher); +}; + +} // namespace protocol +} // namespace remoting + +#endif // REMOTING_PROTOCOL_CLIENT_VIDEO_DISPATCHER_H_ diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc index a6d3143..0da2324 100644 --- a/remoting/protocol/connection_to_client.cc +++ b/remoting/protocol/connection_to_client.cc @@ -12,6 +12,7 @@ #include "remoting/protocol/host_control_dispatcher.h" #include "remoting/protocol/host_event_dispatcher.h" #include "remoting/protocol/host_stub.h" +#include "remoting/protocol/host_video_dispatcher.h" #include "remoting/protocol/input_stub.h" namespace remoting { @@ -56,7 +57,7 @@ void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) { VideoStub* ConnectionToClient::video_stub() { DCHECK(CalledOnValidThread()); - return video_writer_.get(); + return video_dispatcher_.get(); } AudioStub* ConnectionToClient::audio_stub() { @@ -134,9 +135,11 @@ void ConnectionToClient::OnSessionStateChange(Session::State state) { event_dispatcher_->set_sequence_number_callback(base::Bind( &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this))); - video_writer_ = VideoWriter::Create(session_->config()); - video_writer_->Init(session_.get(), base::Bind( - &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); + video_dispatcher_.reset(new HostVideoDispatcher()); + video_dispatcher_->Init( + session_.get(), session_->config().video_config(), + base::Bind(&ConnectionToClient::OnChannelInitialized, + base::Unretained(this))); audio_writer_ = AudioWriter::Create(session_->config()); if (audio_writer_.get()) { @@ -186,7 +189,7 @@ void ConnectionToClient::NotifyIfChannelsReady() { return; if (!event_dispatcher_.get() || !event_dispatcher_->is_connected()) return; - if (!video_writer_.get() || !video_writer_->is_connected()) + if (!video_dispatcher_.get() || !video_dispatcher_->is_connected()) return; if ((!audio_writer_.get() || !audio_writer_->is_connected()) && session_->config().is_audio_enabled()) { @@ -203,7 +206,7 @@ void ConnectionToClient::Close(ErrorCode error) { void ConnectionToClient::CloseChannels() { control_dispatcher_.reset(); event_dispatcher_.reset(); - video_writer_.reset(); + video_dispatcher_.reset(); audio_writer_.reset(); } diff --git a/remoting/protocol/connection_to_client.h b/remoting/protocol/connection_to_client.h index b80e9fd..8fb9a8b 100644 --- a/remoting/protocol/connection_to_client.h +++ b/remoting/protocol/connection_to_client.h @@ -14,17 +14,18 @@ #include "base/threading/non_thread_safe.h" #include "remoting/protocol/audio_writer.h" #include "remoting/protocol/session.h" -#include "remoting/protocol/video_writer.h" namespace remoting { namespace protocol { class ClientStub; class ClipboardStub; -class HostStub; -class InputStub; class HostControlDispatcher; class HostEventDispatcher; +class HostStub; +class HostVideoDispatcher; +class InputStub; +class VideoStub; // This class represents a remote viewer connection to the chromoting // host. It sets up all protocol channels and connects them to the @@ -128,7 +129,7 @@ class ConnectionToClient : public base::NonThreadSafe, scoped_ptr<HostControlDispatcher> control_dispatcher_; scoped_ptr<HostEventDispatcher> event_dispatcher_; - scoped_ptr<VideoWriter> video_writer_; + scoped_ptr<HostVideoDispatcher> video_dispatcher_; scoped_ptr<AudioWriter> audio_writer_; DISALLOW_COPY_AND_ASSIGN(ConnectionToClient); diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc index 71c7764..94f33c8 100644 --- a/remoting/protocol/connection_to_host.cc +++ b/remoting/protocol/connection_to_host.cc @@ -15,11 +15,11 @@ #include "remoting/protocol/client_control_dispatcher.h" #include "remoting/protocol/client_event_dispatcher.h" #include "remoting/protocol/client_stub.h" +#include "remoting/protocol/client_video_dispatcher.h" #include "remoting/protocol/clipboard_stub.h" #include "remoting/protocol/errors.h" #include "remoting/protocol/jingle_session_manager.h" #include "remoting/protocol/transport.h" -#include "remoting/protocol/video_reader.h" #include "remoting/protocol/video_stub.h" namespace remoting { @@ -197,8 +197,9 @@ void ConnectionToHost::OnSessionStateChange( base::Bind(&ConnectionToHost::OnChannelInitialized, base::Unretained(this))); - video_reader_ = VideoReader::Create(session_->config()); - video_reader_->Init(session_.get(), monitored_video_stub_.get(), + video_dispatcher_.reset( + new ClientVideoDispatcher(monitored_video_stub_.get())); + video_dispatcher_->Init(session_.get(), session_->config().video_config(), base::Bind(&ConnectionToHost::OnChannelInitialized, base::Unretained(this))); @@ -263,7 +264,7 @@ void ConnectionToHost::NotifyIfChannelsReady() { return; if (!event_dispatcher_.get() || !event_dispatcher_->is_connected()) return; - if (!video_reader_.get() || !video_reader_->is_connected()) + if (!video_dispatcher_.get() || !video_dispatcher_->is_connected()) return; if ((!audio_reader_.get() || !audio_reader_->is_connected()) && session_->config().is_audio_enabled()) { @@ -288,7 +289,7 @@ void ConnectionToHost::CloseChannels() { event_dispatcher_.reset(); clipboard_forwarder_.set_clipboard_stub(NULL); event_forwarder_.set_input_stub(NULL); - video_reader_.reset(); + video_dispatcher_.reset(); audio_reader_.reset(); } diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h index 33c528c..6d22a83 100644 --- a/remoting/protocol/connection_to_host.h +++ b/remoting/protocol/connection_to_host.h @@ -42,7 +42,7 @@ class HostStub; class InputStub; class SessionConfig; class TransportFactory; -class VideoReader; +class ClientVideoDispatcher; class VideoStub; class ConnectionToHost : public SignalStrategy::Listener, @@ -173,7 +173,7 @@ class ConnectionToHost : public SignalStrategy::Listener, scoped_ptr<Session> session_; scoped_ptr<MonitoredVideoStub> monitored_video_stub_; - scoped_ptr<VideoReader> video_reader_; + scoped_ptr<ClientVideoDispatcher> video_dispatcher_; scoped_ptr<AudioReader> audio_reader_; scoped_ptr<ClientControlDispatcher> control_dispatcher_; scoped_ptr<ClientEventDispatcher> event_dispatcher_; diff --git a/remoting/protocol/host_video_dispatcher.cc b/remoting/protocol/host_video_dispatcher.cc new file mode 100644 index 0000000..08ac857 --- /dev/null +++ b/remoting/protocol/host_video_dispatcher.cc @@ -0,0 +1,34 @@ +// Copyright 2014 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/host_video_dispatcher.h" + +#include "base/bind.h" +#include "net/socket/stream_socket.h" +#include "remoting/base/constants.h" +#include "remoting/proto/video.pb.h" +#include "remoting/protocol/message_serialization.h" + +namespace remoting { +namespace protocol { + +HostVideoDispatcher::HostVideoDispatcher() + : ChannelDispatcherBase(kVideoChannelName) { +} + +HostVideoDispatcher::~HostVideoDispatcher() { +} + +void HostVideoDispatcher::OnInitialized() { + // TODO(sergeyu): Provide WriteFailedCallback for the buffered writer. + writer_.Init(channel(), BufferedSocketWriter::WriteFailedCallback()); +} + +void HostVideoDispatcher::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, + const base::Closure& done) { + writer_.Write(SerializeAndFrameMessage(*packet), done); +} + +} // namespace protocol +} // namespace remoting diff --git a/remoting/protocol/host_video_dispatcher.h b/remoting/protocol/host_video_dispatcher.h new file mode 100644 index 0000000..3c80166 --- /dev/null +++ b/remoting/protocol/host_video_dispatcher.h @@ -0,0 +1,40 @@ +// Copyright 2014 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_HOST_VIDEO_DISPATCHER_H_ +#define REMOTING_PROTOCOL_HOST_VIDEO_DISPATCHER_H_ + +#include <string> + +#include "base/compiler_specific.h" +#include "remoting/protocol/buffered_socket_writer.h" +#include "remoting/protocol/channel_dispatcher_base.h" +#include "remoting/protocol/video_stub.h" + +namespace remoting { +namespace protocol { + +class HostVideoDispatcher : public ChannelDispatcherBase, public VideoStub { + public: + HostVideoDispatcher(); + virtual ~HostVideoDispatcher(); + + // VideoStub interface. + virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, + const base::Closure& done) OVERRIDE; + + protected: + // ChannelDispatcherBase overrides. + virtual void OnInitialized() OVERRIDE; + + private: + BufferedSocketWriter writer_; + + DISALLOW_COPY_AND_ASSIGN(HostVideoDispatcher); +}; + +} // namespace protocol +} // namespace remoting + +#endif // REMOTING_PROTOCOL_HOST_VIDEO_DISPATCHER_H_ diff --git a/remoting/protocol/protobuf_video_reader.cc b/remoting/protocol/protobuf_video_reader.cc deleted file mode 100644 index f566156..0000000 --- a/remoting/protocol/protobuf_video_reader.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2012 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/protobuf_video_reader.h" - -#include "base/bind.h" -#include "net/socket/stream_socket.h" -#include "remoting/base/constants.h" -#include "remoting/proto/video.pb.h" -#include "remoting/protocol/session.h" -#include "remoting/protocol/stream_channel_factory.h" - -namespace remoting { -namespace protocol { - -ProtobufVideoReader::ProtobufVideoReader(VideoPacketFormat::Encoding encoding) - : encoding_(encoding), - channel_factory_(NULL), - video_stub_(NULL) { -} - -ProtobufVideoReader::~ProtobufVideoReader() { - if (channel_factory_) - channel_factory_->CancelChannelCreation(kVideoChannelName); -} - -void ProtobufVideoReader::Init(protocol::Session* session, - VideoStub* video_stub, - const InitializedCallback& callback) { - channel_factory_ = session->GetTransportChannelFactory(); - initialized_callback_ = callback; - video_stub_ = video_stub; - - channel_factory_->CreateChannel( - kVideoChannelName, - base::Bind(&ProtobufVideoReader::OnChannelReady, base::Unretained(this))); -} - -bool ProtobufVideoReader::is_connected() { - return channel_.get() != NULL; -} - -void ProtobufVideoReader::OnChannelReady(scoped_ptr<net::StreamSocket> socket) { - if (!socket.get()) { - initialized_callback_.Run(false); - return; - } - - DCHECK(!channel_.get()); - channel_ = socket.Pass(); - reader_.Init(channel_.get(), base::Bind(&ProtobufVideoReader::OnNewData, - base::Unretained(this))); - initialized_callback_.Run(true); -} - -void ProtobufVideoReader::OnNewData(scoped_ptr<VideoPacket> packet, - const base::Closure& done_task) { - video_stub_->ProcessVideoPacket(packet.Pass(), done_task); -} - -} // namespace protocol -} // namespace remoting diff --git a/remoting/protocol/protobuf_video_reader.h b/remoting/protocol/protobuf_video_reader.h deleted file mode 100644 index ad04273..0000000 --- a/remoting/protocol/protobuf_video_reader.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2012 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_PROTOBUF_VIDEO_READER_H_ -#define REMOTING_PROTOCOL_PROTOBUF_VIDEO_READER_H_ - -#include "base/compiler_specific.h" -#include "remoting/proto/video.pb.h" -#include "remoting/protocol/message_reader.h" -#include "remoting/protocol/video_reader.h" - -namespace net { -class StreamSocket; -} // namespace net - -namespace remoting { -namespace protocol { - -class StreamChannelFactory; -class Session; - -class ProtobufVideoReader : public VideoReader { - public: - ProtobufVideoReader(VideoPacketFormat::Encoding encoding); - virtual ~ProtobufVideoReader(); - - // VideoReader interface. - virtual void Init(protocol::Session* session, - VideoStub* video_stub, - const InitializedCallback& callback) OVERRIDE; - virtual bool is_connected() OVERRIDE; - - private: - void OnChannelReady(scoped_ptr<net::StreamSocket> socket); - void OnNewData(scoped_ptr<VideoPacket> packet, - const base::Closure& done_task); - - InitializedCallback initialized_callback_; - - VideoPacketFormat::Encoding encoding_; - - StreamChannelFactory* channel_factory_; - scoped_ptr<net::StreamSocket> channel_; - - ProtobufMessageReader<VideoPacket> reader_; - - // The stub that processes all received packets. - VideoStub* video_stub_; - - DISALLOW_COPY_AND_ASSIGN(ProtobufVideoReader); -}; - -} // namespace protocol -} // namespace remoting - -#endif // REMOTING_PROTOCOL_PROTOBUF_VIDEO_READER_H_ diff --git a/remoting/protocol/protobuf_video_writer.cc b/remoting/protocol/protobuf_video_writer.cc deleted file mode 100644 index 81f2632..0000000 --- a/remoting/protocol/protobuf_video_writer.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2012 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/protobuf_video_writer.h" - -#include "base/bind.h" -#include "net/socket/stream_socket.h" -#include "remoting/base/constants.h" -#include "remoting/proto/video.pb.h" -#include "remoting/protocol/message_serialization.h" -#include "remoting/protocol/session.h" -#include "remoting/protocol/stream_channel_factory.h" - -namespace remoting { -namespace protocol { - -ProtobufVideoWriter::ProtobufVideoWriter() - : channel_factory_(NULL) { -} - -ProtobufVideoWriter::~ProtobufVideoWriter() { - Close(); -} - -void ProtobufVideoWriter::Init(protocol::Session* session, - const InitializedCallback& callback) { - channel_factory_ = session->GetTransportChannelFactory(); - initialized_callback_ = callback; - - channel_factory_->CreateChannel( - kVideoChannelName, - base::Bind(&ProtobufVideoWriter::OnChannelReady, base::Unretained(this))); -} - -void ProtobufVideoWriter::OnChannelReady(scoped_ptr<net::StreamSocket> socket) { - if (!socket.get()) { - initialized_callback_.Run(false); - return; - } - - DCHECK(!channel_.get()); - channel_ = socket.Pass(); - // TODO(sergeyu): Provide WriteFailedCallback for the buffered writer. - buffered_writer_.Init( - channel_.get(), BufferedSocketWriter::WriteFailedCallback()); - - initialized_callback_.Run(true); -} - -void ProtobufVideoWriter::Close() { - buffered_writer_.Close(); - channel_.reset(); - if (channel_factory_) { - channel_factory_->CancelChannelCreation(kVideoChannelName); - channel_factory_ = NULL; - } -} - -bool ProtobufVideoWriter::is_connected() { - return channel_.get() != NULL; -} - -void ProtobufVideoWriter::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, - const base::Closure& done) { - buffered_writer_.Write(SerializeAndFrameMessage(*packet), done); -} - -} // namespace protocol -} // namespace remoting diff --git a/remoting/protocol/protobuf_video_writer.h b/remoting/protocol/protobuf_video_writer.h deleted file mode 100644 index b139e15..0000000 --- a/remoting/protocol/protobuf_video_writer.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2012 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_PROTOBUF_VIDEO_WRITER_H_ -#define REMOTING_PROTOCOL_PROTOBUF_VIDEO_WRITER_H_ - -#include <string> - -#include "base/compiler_specific.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "remoting/protocol/buffered_socket_writer.h" -#include "remoting/protocol/video_writer.h" - -namespace net { -class StreamSocket; -} // namespace net - -namespace remoting { -namespace protocol { - -class StreamChannelFactory; -class Session; - -class ProtobufVideoWriter : public VideoWriter { - public: - ProtobufVideoWriter(); - virtual ~ProtobufVideoWriter(); - - // VideoWriter interface. - virtual void Init(protocol::Session* session, - const InitializedCallback& callback) OVERRIDE; - virtual void Close() OVERRIDE; - virtual bool is_connected() OVERRIDE; - - // VideoStub interface. - virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, - const base::Closure& done) OVERRIDE; - - private: - void OnChannelReady(scoped_ptr<net::StreamSocket> socket); - - InitializedCallback initialized_callback_; - - StreamChannelFactory* channel_factory_; - scoped_ptr<net::StreamSocket> channel_; - - BufferedSocketWriter buffered_writer_; - - DISALLOW_COPY_AND_ASSIGN(ProtobufVideoWriter); -}; - -} // namespace protocol -} // namespace remoting - -#endif // REMOTING_PROTOCOL_PROTOBUF_VIDEO_WRITER_H_ diff --git a/remoting/protocol/video_reader.cc b/remoting/protocol/video_reader.cc deleted file mode 100644 index 0dfa10a..0000000 --- a/remoting/protocol/video_reader.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012 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/video_reader.h" - -#include "remoting/protocol/session_config.h" -#include "remoting/protocol/protobuf_video_reader.h" - -namespace remoting { -namespace protocol { - -VideoReader::~VideoReader() { } - -// static -scoped_ptr<VideoReader> VideoReader::Create(const SessionConfig& config) { - const ChannelConfig& video_config = config.video_config(); - if (video_config.transport == ChannelConfig::TRANSPORT_STREAM) { - if (video_config.codec == ChannelConfig::CODEC_VP8) { - return scoped_ptr<VideoReader>( - new ProtobufVideoReader(VideoPacketFormat::ENCODING_VP8)); - } else if (video_config.codec == ChannelConfig::CODEC_VP9) { - return scoped_ptr<VideoReader>( - new ProtobufVideoReader(VideoPacketFormat::ENCODING_VP9)); - } else if (video_config.codec == ChannelConfig::CODEC_ZIP) { - return scoped_ptr<VideoReader>( - new ProtobufVideoReader(VideoPacketFormat::ENCODING_ZLIB)); - } else if (video_config.codec == ChannelConfig::CODEC_VERBATIM) { - return scoped_ptr<VideoReader>( - new ProtobufVideoReader(VideoPacketFormat::ENCODING_VERBATIM)); - } - } - NOTREACHED(); - return scoped_ptr<VideoReader>(); -} - -} // namespace protocol -} // namespace remoting diff --git a/remoting/protocol/video_reader.h b/remoting/protocol/video_reader.h deleted file mode 100644 index 63582cf..0000000 --- a/remoting/protocol/video_reader.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2012 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. - -// VideoReader is a generic interface used by ConnectionToHost to read -// video stream. ProtobufVideoReader implements this interface for -// protobuf video stream. - -#ifndef REMOTING_PROTOCOL_VIDEO_READER_H_ -#define REMOTING_PROTOCOL_VIDEO_READER_H_ - -#include "base/callback.h" -#include "base/memory/scoped_ptr.h" -#include "remoting/protocol/video_stub.h" - -namespace remoting { -namespace protocol { - -class Session; -class SessionConfig; - -class VideoReader { - public: - // The callback is called when initialization is finished. The - // parameter is set to true on success. - typedef base::Callback<void(bool)> InitializedCallback; - - virtual ~VideoReader(); - - static scoped_ptr<VideoReader> Create(const SessionConfig& config); - - // Initializies the reader. Doesn't take ownership of either |connection| - // or |video_stub|. - virtual void Init(Session* session, - VideoStub* video_stub, - const InitializedCallback& callback) = 0; - virtual bool is_connected() = 0; - - protected: - VideoReader() { } - - private: - DISALLOW_COPY_AND_ASSIGN(VideoReader); -}; - -} // namespace protocol -} // namespace remoting - -#endif // REMOTING_PROTOCOL_VIDEO_READER_H_ diff --git a/remoting/protocol/video_writer.cc b/remoting/protocol/video_writer.cc deleted file mode 100644 index 736e8ec..0000000 --- a/remoting/protocol/video_writer.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2012 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/video_writer.h" - -#include "remoting/protocol/session_config.h" -#include "remoting/protocol/protobuf_video_writer.h" - -namespace remoting { -namespace protocol { - -VideoWriter::~VideoWriter() { } - -// static -scoped_ptr<VideoWriter> VideoWriter::Create(const SessionConfig& config) { - const ChannelConfig& video_config = config.video_config(); - if (video_config.transport == ChannelConfig::TRANSPORT_STREAM) { - return scoped_ptr<VideoWriter>(new ProtobufVideoWriter()); - } - return scoped_ptr<VideoWriter>(); -} - -} // namespace protocol -} // namespace remoting diff --git a/remoting/protocol/video_writer.h b/remoting/protocol/video_writer.h deleted file mode 100644 index 06bc469..0000000 --- a/remoting/protocol/video_writer.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2012 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. - -// VideoWriter is a generic interface used by ConnectionToClient to -// write into the video stream. ProtobufVideoWriter implements this -// interface for protobuf video streams. - -#ifndef REMOTING_PROTOCOL_VIDEO_WRITER_H_ -#define REMOTING_PROTOCOL_VIDEO_WRITER_H_ - -#include "base/basictypes.h" -#include "base/callback.h" -#include "remoting/protocol/video_stub.h" - -namespace remoting { -namespace protocol { - -class Session; -class SessionConfig; - -class VideoWriter : public VideoStub { - public: - virtual ~VideoWriter(); - - // The callback is called when initialization is finished. The - // parameter is set to true on success. - typedef base::Callback<void(bool)> InitializedCallback; - - static scoped_ptr<VideoWriter> Create(const SessionConfig& config); - - // Initializes the writer. - virtual void Init(Session* session, const InitializedCallback& callback) = 0; - - // Stops writing. Must be called on the network thread before this - // object is destroyed. - virtual void Close() = 0; - - // Returns true if the channel is connected. - virtual bool is_connected() = 0; - - protected: - VideoWriter() { } - - private: - DISALLOW_COPY_AND_ASSIGN(VideoWriter); -}; - -} // namespace protocol -} // namespace remoting - -#endif // REMOTING_PROTOCOL_VIDEO_WRITER_H_ |