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

Unified Diff: remoting/protocol/rtp_video_reader.cc

Issue 7508044: Remove video_channel() from Session interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 5 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
Index: remoting/protocol/rtp_video_reader.cc
diff --git a/remoting/protocol/rtp_video_reader.cc b/remoting/protocol/rtp_video_reader.cc
index b6d9e0bcbd66f67b550b51d48719c941df1db275..9549addd5b575369d317d2dfb7421f4fe148deee 100644
--- a/remoting/protocol/rtp_video_reader.cc
+++ b/remoting/protocol/rtp_video_reader.cc
@@ -4,7 +4,9 @@
#include "remoting/protocol/rtp_video_reader.h"
+#include "base/bind.h"
#include "base/task.h"
+#include "remoting/base/constants.h"
#include "remoting/proto/video.pb.h"
#include "remoting/protocol/session.h"
@@ -22,7 +24,8 @@ RtpVideoReader::PacketsQueueEntry::PacketsQueueEntry()
}
RtpVideoReader::RtpVideoReader()
- : last_sequence_number_(0),
+ : initialized_(false),
+ last_sequence_number_(0),
video_stub_(NULL) {
}
@@ -30,11 +33,47 @@ RtpVideoReader::~RtpVideoReader() {
ResetQueue();
}
-void RtpVideoReader::Init(protocol::Session* session, VideoStub* video_stub) {
- rtp_reader_.Init(session->video_rtp_channel(),
- NewCallback(this, &RtpVideoReader::OnRtpPacket));
- rtcp_writer_.Init(session->video_rtcp_channel());
+void RtpVideoReader::Init(protocol::Session* session,
+ VideoStub* video_stub,
+ const InitializedCallback& callback) {
+ initialized_callback_ = callback;
video_stub_ = video_stub;
+
+ session->CreateDatagramChannel(
+ kVideoRtpChannelName,
+ base::Bind(&RtpVideoReader::OnChannelReady, base::Unretained(this)));
+ session->CreateDatagramChannel(
+ kVideoRtcpChannelName,
+ base::Bind(&RtpVideoReader::OnChannelReady, base::Unretained(this)));
+}
+
+void RtpVideoReader::OnChannelReady(const std::string& name,
+ net::Socket* socket) {
+ if (!socket) {
+ if (!initialized_) {
+ initialized_callback_.Run(false);
+ initialized_ = true;
+ }
+ return;
+ }
+
+ if (name == kVideoRtpChannelName) {
+ DCHECK(!rtp_channel_.get());
+ rtp_channel_.reset(socket);
+ rtp_reader_.Init(socket, NewCallback(this, &RtpVideoReader::OnRtpPacket));
+ } else if (name == kVideoRtcpChannelName) {
+ DCHECK(!rtcp_channel_.get());
+ rtcp_channel_.reset(socket);
+ rtcp_writer_.Init(socket);
+ } else {
+ NOTREACHED();
+ }
+
+ if (rtp_channel_.get() && rtcp_channel_.get()) {
+ DCHECK(!initialized_);
+ initialized_callback_.Run(true);
+ initialized_ = true;
Wez 2011/08/04 23:49:52 Need to set |initialize_| before invoking callback
Sergey Ulanov 2011/08/09 19:41:10 Done.
+ }
}
void RtpVideoReader::ResetQueue() {

Powered by Google App Engine
This is Rietveld 408576698