| 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/rtcp_writer.h" | 5 #include "remoting/protocol/rtcp_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/buffered_socket_writer.h" | 10 #include "remoting/protocol/buffered_socket_writer.h" |
| 11 #include "remoting/protocol/rtp_utils.h" | 11 #include "remoting/protocol/rtp_utils.h" |
| 12 | 12 |
| 13 namespace remoting { | 13 namespace remoting { |
| 14 namespace protocol { | 14 namespace protocol { |
| 15 | 15 |
| 16 RtcpWriter::RtcpWriter(base::MessageLoopProxy* message_loop) | 16 RtcpWriter::RtcpWriter(base::MessageLoopProxy* message_loop) |
| 17 : buffered_rtcp_writer_(new BufferedDatagramWriter(message_loop)) { | 17 : buffered_rtcp_writer_(new BufferedDatagramWriter(message_loop)) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 RtcpWriter::~RtcpWriter() { | 20 RtcpWriter::~RtcpWriter() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 void RtcpWriter::Close() { | 23 void RtcpWriter::Close() { |
| 24 buffered_rtcp_writer_->Close(); | 24 buffered_rtcp_writer_->Close(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 // Initializes the writer. Must be called on the thread the sockets | 27 // Initializes the writer. Must be called on the thread the sockets |
| 28 // belong to. | 28 // belong to. |
| 29 void RtcpWriter::Init(net::Socket* socket) { | 29 void RtcpWriter::Init(net::Socket* socket) { |
| 30 buffered_rtcp_writer_->Init(socket, NULL); | 30 buffered_rtcp_writer_->Init( |
| 31 socket, BufferedSocketWriter::WriteFailedCallback()); |
| 31 } | 32 } |
| 32 | 33 |
| 33 void RtcpWriter::SendReport(const RtcpReceiverReport& report) { | 34 void RtcpWriter::SendReport(const RtcpReceiverReport& report) { |
| 34 int size = GetRtcpReceiverReportSize(report); | 35 int size = GetRtcpReceiverReportSize(report); |
| 35 net::IOBufferWithSize* buffer = new net::IOBufferWithSize(size); | 36 net::IOBufferWithSize* buffer = new net::IOBufferWithSize(size); |
| 36 | 37 |
| 37 PackRtcpReceiverReport(report, reinterpret_cast<uint8*>(buffer->data()), | 38 PackRtcpReceiverReport(report, reinterpret_cast<uint8*>(buffer->data()), |
| 38 size); | 39 size); |
| 39 | 40 |
| 40 buffered_rtcp_writer_->Write(buffer, NULL); | 41 buffered_rtcp_writer_->Write(buffer, base::Closure()); |
| 41 } | 42 } |
| 42 | 43 |
| 43 } // namespace protocol | 44 } // namespace protocol |
| 44 } // namespace remoting | 45 } // namespace remoting |
| OLD | NEW |