diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-03 04:17:09 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-03 04:17:09 +0000 |
commit | 14fd1a60acdd439f80bdfc0aeb86761ba649db79 (patch) | |
tree | 5bfbcefbd8776ca6a4d810a75601d8bf62d91a7c /remoting/host | |
parent | 07f1ceeabc0cf63ed8d7ae7aa8d1ff04dda02584 (diff) | |
download | chromium_src-14fd1a60acdd439f80bdfc0aeb86761ba649db79.zip chromium_src-14fd1a60acdd439f80bdfc0aeb86761ba649db79.tar.gz chromium_src-14fd1a60acdd439f80bdfc0aeb86761ba649db79.tar.bz2 |
Add VideoReader and VideoWriter interfaces.
Implemented VideoReader and VideoWriter for RTP and Protobuf.
BUG=53986
TEST=None
Review URL: http://codereview.chromium.org/4229003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/chromoting_host.cc | 34 | ||||
-rw-r--r-- | remoting/host/chromoting_host.h | 7 | ||||
-rw-r--r-- | remoting/host/client_connection.cc | 16 | ||||
-rw-r--r-- | remoting/host/client_connection.h | 4 | ||||
-rw-r--r-- | remoting/host/mock_objects.h | 2 | ||||
-rw-r--r-- | remoting/host/simple_host_process.cc | 25 |
6 files changed, 45 insertions, 43 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 21a95be..d77e23c 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -9,24 +9,26 @@ #include "build/build_config.h" #include "remoting/base/constants.h" #include "remoting/base/encoder.h" +#include "remoting/base/encoder_verbatim.h" +#include "remoting/base/encoder_vp8.h" +#include "remoting/base/encoder_zlib.h" #include "remoting/host/chromoting_host_context.h" #include "remoting/host/capturer.h" #include "remoting/host/event_executor.h" #include "remoting/host/host_config.h" #include "remoting/host/session_manager.h" #include "remoting/protocol/jingle_chromotocol_server.h" +#include "remoting/protocol/chromotocol_config.h" namespace remoting { ChromotingHost::ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config, Capturer* capturer, - Encoder* encoder, EventExecutor* executor) : context_(context), config_(config), capturer_(capturer), - encoder_(encoder), executor_(executor), state_(kInitial) { } @@ -140,12 +142,14 @@ void ChromotingHost::OnClientConnected(ClientConnection* client) { // Then we create a SessionManager passing the message loops that // it should run on. DCHECK(capturer_.get()); - DCHECK(encoder_.get()); + + Encoder* encoder = CreateEncoder(client->connection()->config()); + session_ = new SessionManager(context_->capture_message_loop(), context_->encode_message_loop(), context_->main_message_loop(), - capturer_.get(), - encoder_.get()); + capturer_.release(), + encoder); } // Immediately add the client and start the session. @@ -285,4 +289,24 @@ void ChromotingHost::OnServerClosed() { // Don't need to do anything here. } +// TODO(sergeyu): Move this to SessionManager? +Encoder* ChromotingHost::CreateEncoder(const ChromotocolConfig* config) { + const ChannelConfig& video_config = config->video_config(); + + if (video_config.codec == ChannelConfig::CODEC_VERBATIM) { + return new remoting::EncoderVerbatim(); + } else if (video_config.codec == ChannelConfig::CODEC_ZIP) { + return new remoting::EncoderZlib(); + } + // TODO(sergeyu): Enable VP8 on ARM builds. +#if !defined(ARCH_CPU_ARM_FAMILY) + else if (video_config.codec == ChannelConfig::CODEC_VP8) { + return new remoting::EncoderVp8(); + } +#endif + + return NULL; +} + + } // namespace remoting diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index 158daa4..911a9d3 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -24,6 +24,7 @@ namespace remoting { class Capturer; class ChromotingHostContext; +class ChromotocolConfig; class Encoder; class EventExecutor; class MutableHostConfig; @@ -59,7 +60,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, public JingleClient::Callback { public: ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config, - Capturer* capturer, Encoder* encoder, EventExecutor* executor); + Capturer* capturer, EventExecutor* executor); virtual ~ChromotingHost(); // Asynchronously start the host process. @@ -113,6 +114,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, // Callback for ChromotocolServer::Close(). void OnServerClosed(); + // Creates encoder for the specified configuration. + Encoder* CreateEncoder(const ChromotocolConfig* config); + // The context that the chromoting host runs on. ChromotingHostContext* context_; @@ -122,7 +126,6 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, // constructed this is set to NULL. scoped_ptr<Capturer> capturer_; - // Encoder to be used by the SessionManager. Once the SessionManager is // constructed this is set to NULL. scoped_ptr<Encoder> encoder_; diff --git a/remoting/host/client_connection.cc b/remoting/host/client_connection.cc index e325bf7..8d68d6d 100644 --- a/remoting/host/client_connection.cc +++ b/remoting/host/client_connection.cc @@ -52,7 +52,7 @@ void ClientConnection::SendInitClientMessage(int width, int height) { msg.mutable_init_client()->set_width(width); msg.mutable_init_client()->set_height(height); DCHECK(msg.IsInitialized()); - video_writer_.SendMessage(msg); + control_writer_.SendMessage(msg); } void ClientConnection::SendVideoPacket(const VideoPacket& packet) { @@ -62,18 +62,12 @@ void ClientConnection::SendVideoPacket(const VideoPacket& packet) { if (!connection_) return; - ChromotingHostMessage* message = new ChromotingHostMessage(); - // TODO(sergeyu): avoid memcopy here. - *message->mutable_video_packet() = packet; - - video_writer_.SendMessage(*message); - - delete message; + video_writer_->SendPacket(packet); } int ClientConnection::GetPendingUpdateStreamMessages() { DCHECK_EQ(loop_, MessageLoop::current()); - return video_writer_.GetPendingMessages(); + return video_writer_->GetPendingPackets(); } void ClientConnection::Disconnect() { @@ -91,10 +85,12 @@ ClientConnection::ClientConnection() {} void ClientConnection::OnConnectionStateChange( ChromotocolConnection::State state) { if (state == ChromotocolConnection::CONNECTED) { + control_writer_.Init(connection_->control_channel()); event_reader_.Init<ChromotingClientMessage>( connection_->event_channel(), NewCallback(this, &ClientConnection::OnMessageReceived)); - video_writer_.Init(connection_->video_channel()); + video_writer_.reset(VideoWriter::Create(connection_->config())); + video_writer_->Init(connection_); } loop_->PostTask(FROM_HERE, diff --git a/remoting/host/client_connection.h b/remoting/host/client_connection.h index 38e383c..6f9deca 100644 --- a/remoting/host/client_connection.h +++ b/remoting/host/client_connection.h @@ -15,6 +15,7 @@ #include "remoting/protocol/chromotocol_connection.h" #include "remoting/protocol/message_reader.h" #include "remoting/protocol/stream_writer.h" +#include "remoting/protocol/video_writer.h" namespace remoting { @@ -100,8 +101,9 @@ class ClientConnection : public base::RefCountedThreadSafe<ClientConnection> { // The libjingle channel used to send and receive data from the remote client. scoped_refptr<ChromotocolConnection> connection_; + ControlStreamWriter control_writer_; MessageReader event_reader_; - VideoStreamWriter video_writer_; + scoped_ptr<VideoWriter> video_writer_; // The message loop that this object runs on. MessageLoop* loop_; diff --git a/remoting/host/mock_objects.h b/remoting/host/mock_objects.h index 428bd74..79b8d6f 100644 --- a/remoting/host/mock_objects.h +++ b/remoting/host/mock_objects.h @@ -45,7 +45,7 @@ class MockClientConnection : public ClientConnection { public: MockClientConnection(){} - MOCK_METHOD1(Init, void(ChromotingConnection* connection)); + MOCK_METHOD1(Init, void(ChromotocolConnection* connection)); MOCK_METHOD2(SendInitClientMessage, void(int width, int height)); MOCK_METHOD1(SendVideoPacket, void(const VideoPacket& packet)); MOCK_METHOD0(GetPendingUpdateStreamMessages, int()); diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index 2733850..98d9303 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -28,9 +28,6 @@ #include "base/path_service.h" #include "base/thread.h" #include "media/base/media.h" -#include "remoting/base/encoder_verbatim.h" -#include "remoting/base/encoder_vp8.h" -#include "remoting/base/encoder_zlib.h" #include "remoting/base/tracer.h" #include "remoting/host/capturer_fake.h" #include "remoting/host/chromoting_host.h" @@ -65,8 +62,6 @@ void ShutdownTask(MessageLoop* message_loop) { const std::string kFakeSwitchName = "fake"; const std::string kConfigSwitchName = "config"; -const std::string kVerbatimSwitchName = "verbatim"; -const std::string kVp8SwitchName = "vp8"; int main(int argc, char** argv) { // Needed for the Mac, so we don't leak objects when threads are created. @@ -80,7 +75,6 @@ int main(int argc, char** argv) { base::EnsureNSPRInit(); scoped_ptr<remoting::Capturer> capturer; - scoped_ptr<remoting::Encoder> encoder; scoped_ptr<remoting::EventExecutor> event_handler; #if defined(OS_WIN) capturer.reset(new remoting::CapturerGdi()); @@ -92,12 +86,9 @@ int main(int argc, char** argv) { capturer.reset(new remoting::CapturerMac()); event_handler.reset(new remoting::EventExecutorMac(capturer.get())); #endif - encoder.reset(new remoting::EncoderZlib()); - // Check the argument to see if we should use a fake capturer and encoder. + // Check the argument to see if we should use a fake capturer. bool fake = cmd_line->HasSwitch(kFakeSwitchName); - bool verbatim = cmd_line->HasSwitch(kVerbatimSwitchName); - bool vp8 = cmd_line->HasSwitch(kVp8SwitchName); #if defined(OS_WIN) std::wstring home_path = GetEnvironmentVar(kHomeDrive); @@ -117,19 +108,6 @@ int main(int argc, char** argv) { capturer.reset(new remoting::CapturerFake()); } - if (verbatim) { - LOG(INFO) << "Using the verbatim encoder."; - encoder.reset(new remoting::EncoderVerbatim()); - } - - // TODO(sergeyu): Enable VP8 on ARM builds. -#if !defined(ARCH_CPU_ARM_FAMILY) - if (vp8) { - LOG(INFO) << "Using the verbatim encoder."; - encoder.reset(new remoting::EncoderVp8()); - } -#endif - base::Thread file_io_thread("FileIO"); file_io_thread.Start(); @@ -156,7 +134,6 @@ int main(int argc, char** argv) { new remoting::ChromotingHost(&context, config, capturer.release(), - encoder.release(), event_handler.release())); // Let the chromoting host run until the shutdown task is executed. |