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
3 // found in the LICENSE file.
5 #include "remoting/protocol/rtcp_writer.h"
7 #include "net/base/io_buffer.h"
8 #include "net/base/net_errors.h"
9 #include "remoting/base/compound_buffer.h"
10 #include "remoting/protocol/buffered_socket_writer.h"
11 #include "remoting/protocol/rtp_utils.h"
16 RtcpWriter::RtcpWriter(base::MessageLoopProxy
* message_loop
)
17 : buffered_rtcp_writer_(new BufferedDatagramWriter(message_loop
)) {
20 RtcpWriter::~RtcpWriter() {
23 void RtcpWriter::Close() {
24 buffered_rtcp_writer_
->Close();
27 // Initializes the writer. Must be called on the thread the sockets
29 void RtcpWriter::Init(net::Socket
* socket
) {
30 buffered_rtcp_writer_
->Init(
31 socket
, BufferedSocketWriter::WriteFailedCallback());
34 void RtcpWriter::SendReport(const RtcpReceiverReport
& report
) {
35 int size
= GetRtcpReceiverReportSize(report
);
36 net::IOBufferWithSize
* buffer
= new net::IOBufferWithSize(size
);
38 PackRtcpReceiverReport(report
, reinterpret_cast<uint8
*>(buffer
->data()),
41 buffered_rtcp_writer_
->Write(buffer
, base::Closure());
44 } // namespace protocol
45 } // namespace remoting