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

Side by Side Diff: media/cast/net/rtcp/rtcp_builder.h

Issue 513313004: Cast: Re-factor rtcp_sender.cc into rtcp_builder.cc and do some cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed leaky and unused testing_clock_ Created 6 years, 3 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
« no previous file with comments | « media/cast/net/rtcp/rtcp.cc ('k') | media/cast/net/rtcp/rtcp_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_NET_RTCP_RTCP_SENDER_H_ 5 #ifndef MEDIA_CAST_NET_RTCP_RTCP_BUILDER_H_
6 #define MEDIA_CAST_NET_RTCP_RTCP_SENDER_H_ 6 #define MEDIA_CAST_NET_RTCP_RTCP_BUILDER_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 "base/big_endian.h"
12 #include "media/cast/cast_config.h" 13 #include "media/cast/cast_config.h"
13 #include "media/cast/cast_defines.h" 14 #include "media/cast/cast_defines.h"
14 #include "media/cast/net/cast_transport_defines.h" 15 #include "media/cast/net/cast_transport_defines.h"
15 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" 16 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h"
16 #include "media/cast/net/rtcp/rtcp_defines.h" 17 #include "media/cast/net/rtcp/rtcp_defines.h"
17 18
18 namespace media { 19 namespace media {
19 namespace cast { 20 namespace cast {
20 21
21 // We limit the size of receiver logs to avoid queuing up packets. 22 // We limit the size of receiver logs to avoid queuing up packets.
22 const size_t kMaxReceiverLogBytes = 200; 23 const size_t kMaxReceiverLogBytes = 200;
23 24
24 // The determines how long to hold receiver log events, based on how 25 // The determines how long to hold receiver log events, based on how
25 // many "receiver log message reports" ago the events were sent. 26 // many "receiver log message reports" ago the events were sent.
26 const size_t kReceiveLogMessageHistorySize = 20; 27 const size_t kReceiveLogMessageHistorySize = 20;
27 28
28 // This determines when to send events the second time. 29 // This determines when to send events the second time.
29 const size_t kFirstRedundancyOffset = 10; 30 const size_t kFirstRedundancyOffset = 10;
30 COMPILE_ASSERT(kFirstRedundancyOffset > 0 && 31 COMPILE_ASSERT(kFirstRedundancyOffset > 0 &&
31 kFirstRedundancyOffset <= kReceiveLogMessageHistorySize, 32 kFirstRedundancyOffset <= kReceiveLogMessageHistorySize,
32 redundancy_offset_out_of_range); 33 redundancy_offset_out_of_range);
33 34
34 // When to send events the third time. 35 // When to send events the third time.
35 const size_t kSecondRedundancyOffset = 20; 36 const size_t kSecondRedundancyOffset = 20;
36 COMPILE_ASSERT(kSecondRedundancyOffset > 37 COMPILE_ASSERT(kSecondRedundancyOffset >
37 kFirstRedundancyOffset && kSecondRedundancyOffset <= 38 kFirstRedundancyOffset && kSecondRedundancyOffset <=
38 kReceiveLogMessageHistorySize, 39 kReceiveLogMessageHistorySize,
39 redundancy_offset_out_of_range); 40 redundancy_offset_out_of_range);
40 41
41 class PacedPacketSender;
42 42
43 // TODO(hclam): This should be renamed to RtcpPacketBuilder. The function 43 class RtcpBuilder {
44 // of this class is to only to build a RTCP packet but not to send it.
45 class RtcpSender {
46 public: 44 public:
47 RtcpSender(PacedPacketSender* outgoing_transport, 45 explicit RtcpBuilder(uint32 sending_ssrc);
48 uint32 sending_ssrc); 46 ~RtcpBuilder();
49 ~RtcpSender();
50 47
51 // TODO(hclam): This method should be to build a packet instead of 48 PacketRef BuildRtcpFromReceiver(
52 // sending it.
53 void SendRtcpFromRtpReceiver(
54 const RtcpReportBlock* report_block, 49 const RtcpReportBlock* report_block,
55 const RtcpReceiverReferenceTimeReport* rrtr, 50 const RtcpReceiverReferenceTimeReport* rrtr,
56 const RtcpCastMessage* cast_message, 51 const RtcpCastMessage* cast_message,
57 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, 52 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events,
58 base::TimeDelta target_delay); 53 base::TimeDelta target_delay);
59 54
60 // TODO(hclam): This method should be to build a packet instead of 55 PacketRef BuildRtcpFromSender(const RtcpSenderInfo& sender_info);
61 // sending it.
62 void SendRtcpFromRtpSender(const RtcpSenderInfo& sender_info);
63 56
64 private: 57 private:
65 void BuildRR(const RtcpReportBlock* report_block, 58 void AddRtcpHeader(RtcpPacketFields payload, int format_or_count);
66 Packet* packet) const; 59 void PatchLengthField();
60 void AddRR(const RtcpReportBlock* report_block);
61 void AddReportBlocks(const RtcpReportBlock& report_block);
62 void AddRrtr(const RtcpReceiverReferenceTimeReport* rrtr);
63 void AddCast(const RtcpCastMessage* cast_message,
64 base::TimeDelta target_delay);
65 void AddSR(const RtcpSenderInfo& sender_info);
66 void AddDlrrRb(const RtcpDlrrReportBlock& dlrr);
67 void AddReceiverLog(
68 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events);
67 69
68 void AddReportBlocks(const RtcpReportBlock& report_block, 70 bool GetRtcpReceiverLogMessage(
69 Packet* packet) const; 71 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events,
72 RtcpReceiverLogMessage* receiver_log_message,
73 size_t* total_number_of_messages_to_send);
70 74
71 void BuildRrtr(const RtcpReceiverReferenceTimeReport* rrtr, 75 void Start();
72 Packet* packet) const; 76 PacketRef Finish();
73 77
74 void BuildCast(const RtcpCastMessage* cast_message, 78 base::BigEndianWriter writer_;
75 base::TimeDelta target_delay,
76 Packet* packet) const;
77
78 void BuildSR(const RtcpSenderInfo& sender_info, Packet* packet) const;
79
80 void BuildDlrrRb(const RtcpDlrrReportBlock& dlrr, Packet* packet) const;
81
82 void BuildReceiverLog(
83 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events,
84 Packet* packet);
85
86 bool BuildRtcpReceiverLogMessage(
87 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events,
88 size_t start_size,
89 RtcpReceiverLogMessage* receiver_log_message,
90 size_t* number_of_frames,
91 size_t* total_number_of_messages_to_send,
92 size_t* rtcp_log_size);
93
94 const uint32 ssrc_; 79 const uint32 ssrc_;
95 80 char* ptr_of_length_;
96 // Not owned by this class. 81 PacketRef packet_;
97 PacedPacketSender* const transport_;
98
99 std::deque<RtcpReceiverLogMessage> rtcp_events_history_; 82 std::deque<RtcpReceiverLogMessage> rtcp_events_history_;
100 83
101 DISALLOW_COPY_AND_ASSIGN(RtcpSender); 84 DISALLOW_COPY_AND_ASSIGN(RtcpBuilder);
102 }; 85 };
103 86
104 } // namespace cast 87 } // namespace cast
105 } // namespace media 88 } // namespace media
106 89
107 #endif // MEDIA_CAST_NET_RTCP_RTCP_SENDER_H_ 90 #endif // MEDIA_CAST_NET_RTCP_RTCP_SENDER_H_
OLDNEW
« no previous file with comments | « media/cast/net/rtcp/rtcp.cc ('k') | media/cast/net/rtcp/rtcp_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698