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_writer.h" | 5 #include "remoting/protocol/rtp_writer.h" |
6 | 6 |
7 #include "net/base/io_buffer.h" | 7 #include "net/base/io_buffer.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "remoting/base/compound_buffer.h" | 9 #include "remoting/base/compound_buffer.h" |
10 #include "remoting/protocol/rtp_utils.h" | 10 #include "remoting/protocol/rtp_utils.h" |
11 | 11 |
12 namespace remoting { | 12 namespace remoting { |
13 namespace protocol { | 13 namespace protocol { |
14 | 14 |
15 namespace { | 15 namespace { |
16 const uint8 kRtpPayloadTypePrivate = 96; | 16 const uint8 kRtpPayloadTypePrivate = 96; |
17 } // namespace | 17 } // namespace |
18 | 18 |
19 RtpWriter::RtpWriter() | 19 RtpWriter::RtpWriter(base::MessageLoopProxy* message_loop) |
20 : last_packet_number_(0) { | 20 : last_packet_number_(0), |
| 21 buffered_rtp_writer_(new BufferedDatagramWriter(message_loop)) { |
21 } | 22 } |
22 | 23 |
23 RtpWriter::~RtpWriter() { } | 24 RtpWriter::~RtpWriter() { } |
24 | 25 |
25 // Initializes the writer. Must be called on the thread the sockets belong | 26 // Initializes the writer. Must be called on the thread the sockets belong |
26 // to. | 27 // to. |
27 void RtpWriter::Init(net::Socket* rtp_socket) { | 28 void RtpWriter::Init(net::Socket* rtp_socket) { |
28 buffered_rtp_writer_ = new BufferedDatagramWriter(); | |
29 buffered_rtp_writer_->Init(rtp_socket, NULL); | 29 buffered_rtp_writer_->Init(rtp_socket, NULL); |
30 } | 30 } |
31 | 31 |
32 void RtpWriter::Close() { | 32 void RtpWriter::Close() { |
33 buffered_rtp_writer_->Close(); | 33 buffered_rtp_writer_->Close(); |
34 } | 34 } |
35 | 35 |
36 void RtpWriter::SendPacket(uint32 timestamp, bool marker, | 36 void RtpWriter::SendPacket(uint32 timestamp, bool marker, |
37 const Vp8Descriptor& vp8_descriptor, | 37 const Vp8Descriptor& vp8_descriptor, |
38 const CompoundBuffer& payload) { | 38 const CompoundBuffer& payload) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // And write the packet. | 75 // And write the packet. |
76 buffered_rtp_writer_->Write(buffer, NULL); | 76 buffered_rtp_writer_->Write(buffer, NULL); |
77 } | 77 } |
78 | 78 |
79 int RtpWriter::GetPendingPackets() { | 79 int RtpWriter::GetPendingPackets() { |
80 return buffered_rtp_writer_->GetBufferChunks(); | 80 return buffered_rtp_writer_->GetBufferChunks(); |
81 } | 81 } |
82 | 82 |
83 } // namespace protocol | 83 } // namespace protocol |
84 } // namespace remoting | 84 } // namespace remoting |
OLD | NEW |