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 <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "media/cast/cast_config.h" | 11 #include "media/cast/cast_config.h" |
12 #include "media/cast/cast_defines.h" | 12 #include "media/cast/cast_defines.h" |
13 #include "media/cast/rtcp/rtcp.h" | 13 #include "media/cast/rtcp/rtcp.h" |
14 #include "media/cast/rtcp/rtcp_defines.h" | 14 #include "media/cast/rtcp/rtcp_defines.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 namespace cast { | 17 namespace cast { |
18 | 18 |
| 19 // TODO(mikhal): Resolve duplication between this and RtcpBuilder. |
19 class RtcpSender { | 20 class RtcpSender { |
20 public: | 21 public: |
21 RtcpSender(scoped_refptr<CastEnvironment> cast_environment, | 22 RtcpSender(scoped_refptr<CastEnvironment> cast_environment, |
22 PacedPacketSender* const paced_packet_sender, | 23 PacedPacketSender* const paced_packet_sender, |
23 uint32 sending_ssrc, | 24 uint32 sending_ssrc, |
24 const std::string& c_name); | 25 const std::string& c_name); |
25 | 26 |
26 virtual ~RtcpSender(); | 27 virtual ~RtcpSender(); |
27 | 28 |
28 void SendRtcpFromRtpSender(uint32 packet_type_flags, | |
29 const RtcpSenderInfo* sender_info, | |
30 const RtcpDlrrReportBlock* dlrr, | |
31 RtcpSenderLogMessage* sender_log); | |
32 | |
33 void SendRtcpFromRtpReceiver(uint32 packet_type_flags, | 29 void SendRtcpFromRtpReceiver(uint32 packet_type_flags, |
34 const RtcpReportBlock* report_block, | 30 const RtcpReportBlock* report_block, |
35 const RtcpReceiverReferenceTimeReport* rrtr, | 31 const RtcpReceiverReferenceTimeReport* rrtr, |
36 const RtcpCastMessage* cast_message, | 32 const RtcpCastMessage* cast_message, |
37 RtcpReceiverLogMessage* receiver_log); | 33 RtcpReceiverLogMessage* receiver_log); |
38 | 34 |
39 enum RtcpPacketType { | 35 enum RtcpPacketType { |
40 kRtcpSr = 0x0002, | 36 kRtcpSr = 0x0002, |
41 kRtcpRr = 0x0004, | 37 kRtcpRr = 0x0004, |
42 kRtcpBye = 0x0008, | 38 kRtcpBye = 0x0008, |
43 kRtcpPli = 0x0010, | 39 kRtcpPli = 0x0010, |
44 kRtcpNack = 0x0020, | 40 kRtcpNack = 0x0020, |
45 kRtcpFir = 0x0040, | 41 kRtcpFir = 0x0040, |
46 kRtcpSrReq = 0x0200, | 42 kRtcpSrReq = 0x0200, |
47 kRtcpDlrr = 0x0400, | 43 kRtcpDlrr = 0x0400, |
48 kRtcpRrtr = 0x0800, | 44 kRtcpRrtr = 0x0800, |
49 kRtcpRpsi = 0x8000, | 45 kRtcpRpsi = 0x8000, |
50 kRtcpRemb = 0x10000, | 46 kRtcpRemb = 0x10000, |
51 kRtcpCast = 0x20000, | 47 kRtcpCast = 0x20000, |
52 kRtcpSenderLog = 0x40000, | 48 kRtcpSenderLog = 0x40000, |
53 kRtcpReceiverLog = 0x80000, | 49 kRtcpReceiverLog = 0x80000, |
54 }; | 50 }; |
55 | 51 |
56 private: | 52 private: |
57 void BuildSR(const RtcpSenderInfo& sender_info, | |
58 const RtcpReportBlock* report_block, | |
59 std::vector<uint8>* packet) const; | |
60 | |
61 void BuildRR(const RtcpReportBlock* report_block, | 53 void BuildRR(const RtcpReportBlock* report_block, |
62 std::vector<uint8>* packet) const; | 54 std::vector<uint8>* packet) const; |
63 | 55 |
64 void AddReportBlocks(const RtcpReportBlock& report_block, | 56 void AddReportBlocks(const RtcpReportBlock& report_block, |
65 std::vector<uint8>* packet) const; | 57 std::vector<uint8>* packet) const; |
66 | 58 |
67 void BuildSdec(std::vector<uint8>* packet) const; | 59 void BuildSdec(std::vector<uint8>* packet) const; |
68 | 60 |
69 void BuildPli(uint32 remote_ssrc, | 61 void BuildPli(uint32 remote_ssrc, |
70 std::vector<uint8>* packet) const; | 62 std::vector<uint8>* packet) const; |
71 | 63 |
72 void BuildRemb(const RtcpRembMessage* remb, | 64 void BuildRemb(const RtcpRembMessage* remb, |
73 std::vector<uint8>* packet) const; | 65 std::vector<uint8>* packet) const; |
74 | 66 |
75 void BuildRpsi(const RtcpRpsiMessage* rpsi, | 67 void BuildRpsi(const RtcpRpsiMessage* rpsi, |
76 std::vector<uint8>* packet) const; | 68 std::vector<uint8>* packet) const; |
77 | 69 |
78 void BuildNack(const RtcpNackMessage* nack, | 70 void BuildNack(const RtcpNackMessage* nack, |
79 std::vector<uint8>* packet) const; | 71 std::vector<uint8>* packet) const; |
80 | 72 |
81 void BuildBye(std::vector<uint8>* packet) const; | 73 void BuildBye(std::vector<uint8>* packet) const; |
82 | 74 |
83 void BuildDlrrRb(const RtcpDlrrReportBlock* dlrr, | |
84 std::vector<uint8>* packet) const; | |
85 | |
86 void BuildRrtr(const RtcpReceiverReferenceTimeReport* rrtr, | 75 void BuildRrtr(const RtcpReceiverReferenceTimeReport* rrtr, |
87 std::vector<uint8>* packet) const; | 76 std::vector<uint8>* packet) const; |
88 | 77 |
89 void BuildCast(const RtcpCastMessage* cast_message, | 78 void BuildCast(const RtcpCastMessage* cast_message, |
90 std::vector<uint8>* packet) const; | 79 std::vector<uint8>* packet) const; |
91 | 80 |
92 void BuildSenderLog(RtcpSenderLogMessage* sender_log_message, | |
93 std::vector<uint8>* packet) const; | |
94 | |
95 void BuildReceiverLog(RtcpReceiverLogMessage* receiver_log_message, | 81 void BuildReceiverLog(RtcpReceiverLogMessage* receiver_log_message, |
96 std::vector<uint8>* packet) const; | 82 std::vector<uint8>* packet) const; |
97 | 83 |
98 inline void BitrateToRembExponentBitrate(uint32 bitrate, | 84 inline void BitrateToRembExponentBitrate(uint32 bitrate, |
99 uint8* exponent, | 85 uint8* exponent, |
100 uint32* mantissa) const { | 86 uint32* mantissa) const { |
101 // 6 bit exponent and a 18 bit mantissa. | 87 // 6 bit exponent and a 18 bit mantissa. |
102 *exponent = 0; | 88 *exponent = 0; |
103 for (int i = 0; i < 64; ++i) { | 89 for (int i = 0; i < 64; ++i) { |
104 if (bitrate <= (262143u << i)) { | 90 if (bitrate <= (262143u << i)) { |
(...skipping 10 matching lines...) Expand all Loading... |
115 // Not owned by this class. | 101 // Not owned by this class. |
116 PacedPacketSender* transport_; | 102 PacedPacketSender* transport_; |
117 scoped_refptr<CastEnvironment> cast_environment_; | 103 scoped_refptr<CastEnvironment> cast_environment_; |
118 | 104 |
119 DISALLOW_COPY_AND_ASSIGN(RtcpSender); | 105 DISALLOW_COPY_AND_ASSIGN(RtcpSender); |
120 }; | 106 }; |
121 | 107 |
122 } // namespace cast | 108 } // namespace cast |
123 } // namespace media | 109 } // namespace media |
124 #endif // MEDIA_CAST_RTCP_RTCP_SENDER_H_ | 110 #endif // MEDIA_CAST_RTCP_RTCP_SENDER_H_ |
OLD | NEW |