| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/protocol/rtp_video_writer.h" | 5 #include "remoting/protocol/rtp_video_writer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "remoting/base/compound_buffer.h" | 10 #include "remoting/base/compound_buffer.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 RtpVideoWriter::~RtpVideoWriter() { | 27 RtpVideoWriter::~RtpVideoWriter() { |
| 28 Close(); | 28 Close(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void RtpVideoWriter::Init(protocol::Session* session, | 31 void RtpVideoWriter::Init(protocol::Session* session, |
| 32 const InitializedCallback& callback) { | 32 const InitializedCallback& callback) { |
| 33 initialized_callback_ = callback; | 33 initialized_callback_ = callback; |
| 34 session->CreateDatagramChannel( | 34 session->CreateDatagramChannel( |
| 35 kVideoRtpChannelName, | 35 kVideoRtpChannelName, |
| 36 base::Bind(&RtpVideoWriter::OnChannelReady, base::Unretained(this))); | 36 base::Bind(&RtpVideoWriter::OnChannelReady, |
| 37 base::Unretained(this), true)); |
| 37 session->CreateDatagramChannel( | 38 session->CreateDatagramChannel( |
| 38 kVideoRtcpChannelName, | 39 kVideoRtcpChannelName, |
| 39 base::Bind(&RtpVideoWriter::OnChannelReady, base::Unretained(this))); | 40 base::Bind(&RtpVideoWriter::OnChannelReady, |
| 41 base::Unretained(this), false)); |
| 40 } | 42 } |
| 41 | 43 |
| 42 void RtpVideoWriter::OnChannelReady(const std::string& name, | 44 void RtpVideoWriter::OnChannelReady(bool rtp, net::Socket* socket) { |
| 43 net::Socket* socket) { | |
| 44 if (!socket) { | 45 if (!socket) { |
| 45 if (!initialized_) { | 46 if (!initialized_) { |
| 46 initialized_ = true; | 47 initialized_ = true; |
| 47 initialized_callback_.Run(false); | 48 initialized_callback_.Run(false); |
| 48 } | 49 } |
| 49 return; | 50 return; |
| 50 } | 51 } |
| 51 | 52 |
| 52 if (name == kVideoRtpChannelName) { | 53 if (rtp) { |
| 53 DCHECK(!rtp_channel_.get()); | 54 DCHECK(!rtp_channel_.get()); |
| 54 rtp_channel_.reset(socket); | 55 rtp_channel_.reset(socket); |
| 55 rtp_writer_.Init(socket); | 56 rtp_writer_.Init(socket); |
| 56 } else if (name == kVideoRtcpChannelName) { | 57 } else { |
| 57 DCHECK(!rtcp_channel_.get()); | 58 DCHECK(!rtcp_channel_.get()); |
| 58 rtcp_channel_.reset(socket); | 59 rtcp_channel_.reset(socket); |
| 59 // TODO(sergeyu): Use RTCP channel somehow. | 60 // TODO(sergeyu): Use RTCP channel somehow. |
| 60 } | 61 } |
| 61 | 62 |
| 62 if (rtp_channel_.get() && rtcp_channel_.get()) { | 63 if (rtp_channel_.get() && rtcp_channel_.get()) { |
| 63 DCHECK(!initialized_); | 64 DCHECK(!initialized_); |
| 64 initialized_ = true; | 65 initialized_ = true; |
| 65 initialized_callback_.Run(true); | 66 initialized_callback_.Run(true); |
| 66 } | 67 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 done->Run(); | 130 done->Run(); |
| 130 delete done; | 131 delete done; |
| 131 } | 132 } |
| 132 | 133 |
| 133 int RtpVideoWriter::GetPendingPackets() { | 134 int RtpVideoWriter::GetPendingPackets() { |
| 134 return rtp_writer_.GetPendingPackets(); | 135 return rtp_writer_.GetPendingPackets(); |
| 135 } | 136 } |
| 136 | 137 |
| 137 } // namespace protocol | 138 } // namespace protocol |
| 138 } // namespace remoting | 139 } // namespace remoting |
| OLD | NEW |