diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-09 22:31:43 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-09 22:31:43 +0000 |
commit | 19c28bfec867442cc416fa5a3108418e01c714fb (patch) | |
tree | e832b7ec5f9792c27152470d1b44046ff5a2fc6f /remoting/protocol/rtp_video_writer.cc | |
parent | 8ec98cd25edd4f9329c0acefd98d4b6f69e4632d (diff) | |
download | chromium_src-19c28bfec867442cc416fa5a3108418e01c714fb.zip chromium_src-19c28bfec867442cc416fa5a3108418e01c714fb.tar.gz chromium_src-19c28bfec867442cc416fa5a3108418e01c714fb.tar.bz2 |
Remove video_channel() from Session interface
BUG=None
TEST=Unittests.
Review URL: http://codereview.chromium.org/7508044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol/rtp_video_writer.cc')
-rw-r--r-- | remoting/protocol/rtp_video_writer.cc | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/remoting/protocol/rtp_video_writer.cc b/remoting/protocol/rtp_video_writer.cc index d5d4b75..2a0f950 100644 --- a/remoting/protocol/rtp_video_writer.cc +++ b/remoting/protocol/rtp_video_writer.cc @@ -4,9 +4,11 @@ #include "remoting/protocol/rtp_video_writer.h" +#include "base/bind.h" #include "base/task.h" #include "net/base/io_buffer.h" #include "remoting/base/compound_buffer.h" +#include "remoting/base/constants.h" #include "remoting/proto/video.pb.h" #include "remoting/protocol/rtp_writer.h" #include "remoting/protocol/session.h" @@ -18,18 +20,56 @@ namespace { const int kMtu = 1200; } // namespace -RtpVideoWriter::RtpVideoWriter() { } +RtpVideoWriter::RtpVideoWriter() + : initialized_(false) { +} RtpVideoWriter::~RtpVideoWriter() { Close(); } -void RtpVideoWriter::Init(protocol::Session* session) { - rtp_writer_.Init(session->video_rtp_channel()); +void RtpVideoWriter::Init(protocol::Session* session, + const InitializedCallback& callback) { + initialized_callback_ = callback; + session->CreateDatagramChannel( + kVideoRtpChannelName, + base::Bind(&RtpVideoWriter::OnChannelReady, base::Unretained(this))); + session->CreateDatagramChannel( + kVideoRtcpChannelName, + base::Bind(&RtpVideoWriter::OnChannelReady, base::Unretained(this))); +} + +void RtpVideoWriter::OnChannelReady(const std::string& name, + net::Socket* socket) { + if (!socket) { + if (!initialized_) { + initialized_ = true; + initialized_callback_.Run(false); + } + return; + } + + if (name == kVideoRtpChannelName) { + DCHECK(!rtp_channel_.get()); + rtp_channel_.reset(socket); + rtp_writer_.Init(socket); + } else if (name == kVideoRtcpChannelName) { + DCHECK(!rtcp_channel_.get()); + rtcp_channel_.reset(socket); + // TODO(sergeyu): Use RTCP channel somehow. + } + + if (rtp_channel_.get() && rtcp_channel_.get()) { + DCHECK(!initialized_); + initialized_ = true; + initialized_callback_.Run(true); + } } void RtpVideoWriter::Close() { rtp_writer_.Close(); + rtp_channel_.reset(); + rtcp_channel_.reset(); } void RtpVideoWriter::ProcessVideoPacket(const VideoPacket* packet, Task* done) { |