OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MEDIA_CAST_RTCP_RTCP_SENDER_H_ | 5 #ifndef MEDIA_CAST_RTCP_RTCP_SENDER_H_ |
6 #define MEDIA_CAST_RTCP_RTCP_SENDER_H_ | 6 #define MEDIA_CAST_RTCP_RTCP_SENDER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "media/cast/cast_config.h" | 12 #include "media/cast/cast_config.h" |
13 #include "media/cast/cast_defines.h" | 13 #include "media/cast/cast_defines.h" |
14 #include "media/cast/rtcp/receiver_rtcp_event_subscriber.h" | 14 #include "media/cast/net/cast_transport_defines.h" |
15 #include "media/cast/rtcp/rtcp.h" | 15 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" |
16 #include "media/cast/rtcp/rtcp_defines.h" | 16 #include "media/cast/net/rtcp/rtcp.h" |
17 #include "media/cast/transport/cast_transport_defines.h" | 17 #include "media/cast/net/rtcp/rtcp_builder.h" |
18 #include "media/cast/transport/rtcp/rtcp_builder.h" | 18 #include "media/cast/net/rtcp/rtcp_defines.h" |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 namespace cast { | 21 namespace cast { |
22 | 22 |
23 // We limit the size of receiver logs to avoid queuing up packets. | 23 // We limit the size of receiver logs to avoid queuing up packets. |
24 const size_t kMaxReceiverLogBytes = 200; | 24 const size_t kMaxReceiverLogBytes = 200; |
25 | 25 |
26 // The determines how long to hold receiver log events, based on how | 26 // The determines how long to hold receiver log events, based on how |
27 // many "receiver log message reports" ago the events were sent. | 27 // many "receiver log message reports" ago the events were sent. |
28 const size_t kReceiveLogMessageHistorySize = 20; | 28 const size_t kReceiveLogMessageHistorySize = 20; |
29 | 29 |
30 // This determines when to send events the second time. | 30 // This determines when to send events the second time. |
31 const size_t kFirstRedundancyOffset = 10; | 31 const size_t kFirstRedundancyOffset = 10; |
32 COMPILE_ASSERT(kFirstRedundancyOffset > 0 && | 32 COMPILE_ASSERT(kFirstRedundancyOffset > 0 && |
33 kFirstRedundancyOffset <= kReceiveLogMessageHistorySize, | 33 kFirstRedundancyOffset <= kReceiveLogMessageHistorySize, |
34 redundancy_offset_out_of_range); | 34 redundancy_offset_out_of_range); |
35 | 35 |
36 // When to send events the third time. | 36 // When to send events the third time. |
37 const size_t kSecondRedundancyOffset = 20; | 37 const size_t kSecondRedundancyOffset = 20; |
38 COMPILE_ASSERT(kSecondRedundancyOffset > | 38 COMPILE_ASSERT(kSecondRedundancyOffset > |
39 kFirstRedundancyOffset && kSecondRedundancyOffset <= | 39 kFirstRedundancyOffset && kSecondRedundancyOffset <= |
40 kReceiveLogMessageHistorySize, | 40 kReceiveLogMessageHistorySize, |
41 redundancy_offset_out_of_range); | 41 redundancy_offset_out_of_range); |
42 | 42 |
43 // TODO(mikhal): Resolve duplication between this and RtcpBuilder. | 43 // TODO(mikhal): Resolve duplication between this and RtcpBuilder. |
44 class RtcpSender { | 44 class RtcpSender { |
45 public: | 45 public: |
46 RtcpSender(scoped_refptr<CastEnvironment> cast_environment, | 46 RtcpSender(scoped_refptr<CastEnvironment> cast_environment, |
47 transport::PacedPacketSender* outgoing_transport, | 47 PacedPacketSender* outgoing_transport, |
48 uint32 sending_ssrc, | 48 uint32 sending_ssrc, |
49 const std::string& c_name); | 49 const std::string& c_name); |
50 | 50 |
51 virtual ~RtcpSender(); | 51 virtual ~RtcpSender(); |
52 | 52 |
53 void SendRtcpFromRtpReceiver( | 53 void SendRtcpFromRtpReceiver( |
54 uint32 packet_type_flags, | 54 uint32 packet_type_flags, |
55 const transport::RtcpReportBlock* report_block, | 55 const RtcpReportBlock* report_block, |
56 const RtcpReceiverReferenceTimeReport* rrtr, | 56 const RtcpReceiverReferenceTimeReport* rrtr, |
57 const RtcpCastMessage* cast_message, | 57 const RtcpCastMessage* cast_message, |
58 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, | 58 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, |
59 base::TimeDelta target_delay); | 59 base::TimeDelta target_delay); |
60 | 60 |
61 private: | 61 private: |
62 void BuildRR(const transport::RtcpReportBlock* report_block, | 62 void BuildRR(const RtcpReportBlock* report_block, |
63 Packet* packet) const; | 63 Packet* packet) const; |
64 | 64 |
65 void AddReportBlocks(const transport::RtcpReportBlock& report_block, | 65 void AddReportBlocks(const RtcpReportBlock& report_block, |
66 Packet* packet) const; | 66 Packet* packet) const; |
67 | 67 |
68 void BuildSdec(Packet* packet) const; | 68 void BuildSdec(Packet* packet) const; |
69 | 69 |
70 void BuildPli(uint32 remote_ssrc, Packet* packet) const; | 70 void BuildPli(uint32 remote_ssrc, Packet* packet) const; |
71 | 71 |
72 void BuildRemb(const RtcpRembMessage* remb, Packet* packet) const; | 72 void BuildRemb(const RtcpRembMessage* remb, Packet* packet) const; |
73 | 73 |
74 void BuildRpsi(const RtcpRpsiMessage* rpsi, Packet* packet) const; | 74 void BuildRpsi(const RtcpRpsiMessage* rpsi, Packet* packet) const; |
75 | 75 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 break; | 107 break; |
108 } | 108 } |
109 } | 109 } |
110 *mantissa = (bitrate >> *exponent); | 110 *mantissa = (bitrate >> *exponent); |
111 } | 111 } |
112 | 112 |
113 const uint32 ssrc_; | 113 const uint32 ssrc_; |
114 const std::string c_name_; | 114 const std::string c_name_; |
115 | 115 |
116 // Not owned by this class. | 116 // Not owned by this class. |
117 transport::PacedPacketSender* const transport_; | 117 PacedPacketSender* const transport_; |
118 scoped_refptr<CastEnvironment> cast_environment_; | 118 scoped_refptr<CastEnvironment> cast_environment_; |
119 | 119 |
120 std::deque<RtcpReceiverLogMessage> rtcp_events_history_; | 120 std::deque<RtcpReceiverLogMessage> rtcp_events_history_; |
121 | 121 |
122 DISALLOW_COPY_AND_ASSIGN(RtcpSender); | 122 DISALLOW_COPY_AND_ASSIGN(RtcpSender); |
123 }; | 123 }; |
124 | 124 |
125 } // namespace cast | 125 } // namespace cast |
126 } // namespace media | 126 } // namespace media |
127 #endif // MEDIA_CAST_RTCP_RTCP_SENDER_H_ | 127 #endif // MEDIA_CAST_RTCP_RTCP_SENDER_H_ |
OLD | NEW |