Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: remoting/protocol/rtp_video_writer.cc

Issue 7508044: Remove video_channel() from Session interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/rtp_video_writer.h ('k') | remoting/protocol/rtp_video_writer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/rtp_video_writer.cc
diff --git a/remoting/protocol/rtp_video_writer.cc b/remoting/protocol/rtp_video_writer.cc
index d5d4b752236430ea21435c7536f6918910c4b501..2a0f950e95b19165d5d216acee8ace843a64270e 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) {
« no previous file with comments | « remoting/protocol/rtp_video_writer.h ('k') | remoting/protocol/rtp_video_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698