Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: media/cast/rtcp/rtcp_sender.h

Issue 388663003: Cast: Reshuffle files under media/cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing includes Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/cast/rtcp/rtcp_receiver_unittest.cc ('k') | media/cast/rtcp/rtcp_sender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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.
4
5 #ifndef MEDIA_CAST_RTCP_RTCP_SENDER_H_
6 #define MEDIA_CAST_RTCP_RTCP_SENDER_H_
7
8 #include <deque>
9 #include <list>
10 #include <string>
11
12 #include "media/cast/cast_config.h"
13 #include "media/cast/cast_defines.h"
14 #include "media/cast/rtcp/receiver_rtcp_event_subscriber.h"
15 #include "media/cast/rtcp/rtcp.h"
16 #include "media/cast/rtcp/rtcp_defines.h"
17 #include "media/cast/transport/cast_transport_defines.h"
18 #include "media/cast/transport/rtcp/rtcp_builder.h"
19
20 namespace media {
21 namespace cast {
22
23 // We limit the size of receiver logs to avoid queuing up packets.
24 const size_t kMaxReceiverLogBytes = 200;
25
26 // The determines how long to hold receiver log events, based on how
27 // many "receiver log message reports" ago the events were sent.
28 const size_t kReceiveLogMessageHistorySize = 20;
29
30 // This determines when to send events the second time.
31 const size_t kFirstRedundancyOffset = 10;
32 COMPILE_ASSERT(kFirstRedundancyOffset > 0 &&
33 kFirstRedundancyOffset <= kReceiveLogMessageHistorySize,
34 redundancy_offset_out_of_range);
35
36 // When to send events the third time.
37 const size_t kSecondRedundancyOffset = 20;
38 COMPILE_ASSERT(kSecondRedundancyOffset >
39 kFirstRedundancyOffset && kSecondRedundancyOffset <=
40 kReceiveLogMessageHistorySize,
41 redundancy_offset_out_of_range);
42
43 // TODO(mikhal): Resolve duplication between this and RtcpBuilder.
44 class RtcpSender {
45 public:
46 RtcpSender(scoped_refptr<CastEnvironment> cast_environment,
47 transport::PacedPacketSender* outgoing_transport,
48 uint32 sending_ssrc,
49 const std::string& c_name);
50
51 virtual ~RtcpSender();
52
53 void SendRtcpFromRtpReceiver(
54 uint32 packet_type_flags,
55 const transport::RtcpReportBlock* report_block,
56 const RtcpReceiverReferenceTimeReport* rrtr,
57 const RtcpCastMessage* cast_message,
58 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events,
59 base::TimeDelta target_delay);
60
61 private:
62 void BuildRR(const transport::RtcpReportBlock* report_block,
63 Packet* packet) const;
64
65 void AddReportBlocks(const transport::RtcpReportBlock& report_block,
66 Packet* packet) const;
67
68 void BuildSdec(Packet* packet) const;
69
70 void BuildPli(uint32 remote_ssrc, Packet* packet) const;
71
72 void BuildRemb(const RtcpRembMessage* remb, Packet* packet) const;
73
74 void BuildRpsi(const RtcpRpsiMessage* rpsi, Packet* packet) const;
75
76 void BuildNack(const RtcpNackMessage* nack, Packet* packet) const;
77
78 void BuildBye(Packet* packet) const;
79
80 void BuildRrtr(const RtcpReceiverReferenceTimeReport* rrtr,
81 Packet* packet) const;
82
83 void BuildCast(const RtcpCastMessage* cast_message,
84 base::TimeDelta target_delay,
85 Packet* packet) const;
86
87 void BuildReceiverLog(
88 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events,
89 Packet* packet);
90
91 bool BuildRtcpReceiverLogMessage(
92 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events,
93 size_t start_size,
94 RtcpReceiverLogMessage* receiver_log_message,
95 size_t* number_of_frames,
96 size_t* total_number_of_messages_to_send,
97 size_t* rtcp_log_size);
98
99 inline void BitrateToRembExponentBitrate(uint32 bitrate,
100 uint8* exponent,
101 uint32* mantissa) const {
102 // 6 bit exponent and a 18 bit mantissa.
103 *exponent = 0;
104 for (int i = 0; i < 64; ++i) {
105 if (bitrate <= (262143u << i)) {
106 *exponent = i;
107 break;
108 }
109 }
110 *mantissa = (bitrate >> *exponent);
111 }
112
113 const uint32 ssrc_;
114 const std::string c_name_;
115
116 // Not owned by this class.
117 transport::PacedPacketSender* const transport_;
118 scoped_refptr<CastEnvironment> cast_environment_;
119
120 std::deque<RtcpReceiverLogMessage> rtcp_events_history_;
121
122 DISALLOW_COPY_AND_ASSIGN(RtcpSender);
123 };
124
125 } // namespace cast
126 } // namespace media
127 #endif // MEDIA_CAST_RTCP_RTCP_SENDER_H_
OLDNEW
« no previous file with comments | « media/cast/rtcp/rtcp_receiver_unittest.cc ('k') | media/cast/rtcp/rtcp_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698