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" |
11 #include "remoting/base/constants.h" | 11 #include "remoting/base/constants.h" |
12 #include "remoting/proto/video.pb.h" | 12 #include "remoting/proto/video.pb.h" |
13 #include "remoting/protocol/rtp_writer.h" | 13 #include "remoting/protocol/rtp_writer.h" |
14 #include "remoting/protocol/session.h" | 14 #include "remoting/protocol/session.h" |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 namespace protocol { | 17 namespace protocol { |
18 | 18 |
19 namespace { | 19 namespace { |
20 const int kMtu = 1200; | 20 const int kMtu = 1200; |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 RtpVideoWriter::RtpVideoWriter(base::MessageLoopProxy* message_loop) | 23 RtpVideoWriter::RtpVideoWriter(base::MessageLoopProxy* message_loop) |
24 : initialized_(false), | 24 : session_(NULL), |
| 25 initialized_(false), |
25 rtp_writer_(message_loop) { | 26 rtp_writer_(message_loop) { |
26 } | 27 } |
27 | 28 |
28 RtpVideoWriter::~RtpVideoWriter() { | 29 RtpVideoWriter::~RtpVideoWriter() { |
29 Close(); | 30 Close(); |
30 } | 31 } |
31 | 32 |
32 void RtpVideoWriter::Init(protocol::Session* session, | 33 void RtpVideoWriter::Init(protocol::Session* session, |
33 const InitializedCallback& callback) { | 34 const InitializedCallback& callback) { |
| 35 session_ = session; |
34 initialized_callback_ = callback; | 36 initialized_callback_ = callback; |
35 session->CreateDatagramChannel( | 37 session->CreateDatagramChannel( |
36 kVideoRtpChannelName, | 38 kVideoRtpChannelName, |
37 base::Bind(&RtpVideoWriter::OnChannelReady, | 39 base::Bind(&RtpVideoWriter::OnChannelReady, |
38 base::Unretained(this), true)); | 40 base::Unretained(this), true)); |
39 session->CreateDatagramChannel( | 41 session->CreateDatagramChannel( |
40 kVideoRtcpChannelName, | 42 kVideoRtcpChannelName, |
41 base::Bind(&RtpVideoWriter::OnChannelReady, | 43 base::Bind(&RtpVideoWriter::OnChannelReady, |
42 base::Unretained(this), false)); | 44 base::Unretained(this), false)); |
43 } | 45 } |
(...skipping 21 matching lines...) Expand all Loading... |
65 DCHECK(!initialized_); | 67 DCHECK(!initialized_); |
66 initialized_ = true; | 68 initialized_ = true; |
67 initialized_callback_.Run(true); | 69 initialized_callback_.Run(true); |
68 } | 70 } |
69 } | 71 } |
70 | 72 |
71 void RtpVideoWriter::Close() { | 73 void RtpVideoWriter::Close() { |
72 rtp_writer_.Close(); | 74 rtp_writer_.Close(); |
73 rtp_channel_.reset(); | 75 rtp_channel_.reset(); |
74 rtcp_channel_.reset(); | 76 rtcp_channel_.reset(); |
| 77 if (session_) { |
| 78 session_->CancelChannelCreation(kVideoRtpChannelName); |
| 79 session_->CancelChannelCreation(kVideoRtcpChannelName); |
| 80 session_ = NULL; |
| 81 } |
75 } | 82 } |
76 | 83 |
77 void RtpVideoWriter::ProcessVideoPacket(const VideoPacket* packet, | 84 void RtpVideoWriter::ProcessVideoPacket(const VideoPacket* packet, |
78 const base::Closure& done) { | 85 const base::Closure& done) { |
79 CHECK(packet->format().encoding() == VideoPacketFormat::ENCODING_VP8) | 86 CHECK(packet->format().encoding() == VideoPacketFormat::ENCODING_VP8) |
80 << "Only VP8 is supported in RTP."; | 87 << "Only VP8 is supported in RTP."; |
81 | 88 |
82 CompoundBuffer payload; | 89 CompoundBuffer payload; |
83 // TODO(sergeyu): This copy would not be necessary CompoundBuffer was used | 90 // TODO(sergeyu): This copy would not be necessary CompoundBuffer was used |
84 // inside of VideoPacket. | 91 // inside of VideoPacket. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 138 |
132 done.Run(); | 139 done.Run(); |
133 } | 140 } |
134 | 141 |
135 int RtpVideoWriter::GetPendingPackets() { | 142 int RtpVideoWriter::GetPendingPackets() { |
136 return rtp_writer_.GetPendingPackets(); | 143 return rtp_writer_.GetPendingPackets(); |
137 } | 144 } |
138 | 145 |
139 } // namespace protocol | 146 } // namespace protocol |
140 } // namespace remoting | 147 } // namespace remoting |
OLD | NEW |