| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_reader.h" | 5 #include "remoting/protocol/rtp_video_reader.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 "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/proto/video.pb.h" | 10 #include "remoting/proto/video.pb.h" |
| 11 #include "remoting/protocol/session.h" | 11 #include "remoting/protocol/session.h" |
| 12 | 12 |
| 13 namespace remoting { | 13 namespace remoting { |
| 14 namespace protocol { | 14 namespace protocol { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 const int kMaxPacketsInQueue = 1024; | 17 const int kMaxPacketsInQueue = 1024; |
| 18 const int kReceiverReportsIntervalMs = 1000; | 18 const int kReceiverReportsIntervalMs = 1000; |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 RtpVideoReader::PacketsQueueEntry::PacketsQueueEntry() | 21 RtpVideoReader::PacketsQueueEntry::PacketsQueueEntry() |
| 22 : received(false), | 22 : received(false), |
| 23 packet(NULL) { | 23 packet(NULL) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 RtpVideoReader::RtpVideoReader(base::MessageLoopProxy* message_loop) | 26 RtpVideoReader::RtpVideoReader(base::MessageLoopProxy* message_loop) |
| 27 : initialized_(false), | 27 : session_(NULL), |
| 28 initialized_(false), |
| 28 rtcp_writer_(message_loop), | 29 rtcp_writer_(message_loop), |
| 29 last_sequence_number_(0), | 30 last_sequence_number_(0), |
| 30 video_stub_(NULL) { | 31 video_stub_(NULL) { |
| 31 } | 32 } |
| 32 | 33 |
| 33 RtpVideoReader::~RtpVideoReader() { | 34 RtpVideoReader::~RtpVideoReader() { |
| 35 if (session_) { |
| 36 session_->CancelChannelCreation(kVideoRtpChannelName); |
| 37 session_->CancelChannelCreation(kVideoRtcpChannelName); |
| 38 } |
| 34 ResetQueue(); | 39 ResetQueue(); |
| 35 } | 40 } |
| 36 | 41 |
| 37 void RtpVideoReader::Init(protocol::Session* session, | 42 void RtpVideoReader::Init(protocol::Session* session, |
| 38 VideoStub* video_stub, | 43 VideoStub* video_stub, |
| 39 const InitializedCallback& callback) { | 44 const InitializedCallback& callback) { |
| 45 session_ = session; |
| 40 initialized_callback_ = callback; | 46 initialized_callback_ = callback; |
| 41 video_stub_ = video_stub; | 47 video_stub_ = video_stub; |
| 42 | 48 |
| 43 session->CreateDatagramChannel( | 49 session_->CreateDatagramChannel( |
| 44 kVideoRtpChannelName, | 50 kVideoRtpChannelName, |
| 45 base::Bind(&RtpVideoReader::OnChannelReady, | 51 base::Bind(&RtpVideoReader::OnChannelReady, |
| 46 base::Unretained(this), true)); | 52 base::Unretained(this), true)); |
| 47 session->CreateDatagramChannel( | 53 session_->CreateDatagramChannel( |
| 48 kVideoRtcpChannelName, | 54 kVideoRtcpChannelName, |
| 49 base::Bind(&RtpVideoReader::OnChannelReady, | 55 base::Bind(&RtpVideoReader::OnChannelReady, |
| 50 base::Unretained(this), false)); | 56 base::Unretained(this), false)); |
| 51 } | 57 } |
| 52 | 58 |
| 53 void RtpVideoReader::OnChannelReady(bool rtp, net::Socket* socket) { | 59 void RtpVideoReader::OnChannelReady(bool rtp, net::Socket* socket) { |
| 54 if (!socket) { | 60 if (!socket) { |
| 55 if (!initialized_) { | 61 if (!initialized_) { |
| 56 initialized_ = true; | 62 initialized_ = true; |
| 57 initialized_callback_.Run(false); | 63 initialized_callback_.Run(false); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 RtcpReceiverReport report; | 228 RtcpReceiverReport report; |
| 223 rtp_reader_.GetReceiverReport(&report); | 229 rtp_reader_.GetReceiverReport(&report); |
| 224 rtcp_writer_.SendReport(report); | 230 rtcp_writer_.SendReport(report); |
| 225 | 231 |
| 226 last_receiver_report_ = now; | 232 last_receiver_report_ = now; |
| 227 } | 233 } |
| 228 } | 234 } |
| 229 | 235 |
| 230 } // namespace protocol | 236 } // namespace protocol |
| 231 } // namespace remoting | 237 } // namespace remoting |
| OLD | NEW |