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_TRANSPORT_PACING_PACED_SENDER_H_ | 5 #ifndef MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ |
6 #define MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ | 6 #define MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... | |
34 // 2. The sort order of the PacketKey determines the order that packets | 34 // 2. The sort order of the PacketKey determines the order that packets |
35 // are sent out. Using the capture_time as the first member basically | 35 // are sent out. Using the capture_time as the first member basically |
36 // means that older packets are sent first. | 36 // means that older packets are sent first. |
37 typedef std::pair<base::TimeTicks, std::pair<uint32, uint16> > PacketKey; | 37 typedef std::pair<base::TimeTicks, std::pair<uint32, uint16> > PacketKey; |
38 typedef std::vector<std::pair<PacketKey, PacketRef> > SendPacketVector; | 38 typedef std::vector<std::pair<PacketKey, PacketRef> > SendPacketVector; |
39 | 39 |
40 // We have this pure virtual class to enable mocking. | 40 // We have this pure virtual class to enable mocking. |
41 class PacedPacketSender { | 41 class PacedPacketSender { |
42 public: | 42 public: |
43 virtual bool SendPackets(const SendPacketVector& packets) = 0; | 43 virtual bool SendPackets(const SendPacketVector& packets) = 0; |
44 virtual bool ResendPackets(const SendPacketVector& packets) = 0; | 44 virtual bool ResendPackets(const SendPacketVector& packets, |
45 base::TimeDelta rtt) = 0; | |
45 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) = 0; | 46 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) = 0; |
46 virtual void CancelSendingPacket(const PacketKey& packet_key) = 0; | 47 virtual void CancelSendingPacket(const PacketKey& packet_key) = 0; |
47 | 48 |
48 virtual ~PacedPacketSender() {} | 49 virtual ~PacedPacketSender() {} |
49 | 50 |
50 static PacketKey MakePacketKey(const base::TimeTicks& ticks, | 51 static PacketKey MakePacketKey(const base::TimeTicks& ticks, |
51 uint32 ssrc, | 52 uint32 ssrc, |
52 uint16 packet_id); | 53 uint16 packet_id); |
53 }; | 54 }; |
54 | 55 |
(...skipping 10 matching lines...) Expand all Loading... | |
65 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); | 66 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); |
66 | 67 |
67 virtual ~PacedSender(); | 68 virtual ~PacedSender(); |
68 | 69 |
69 // These must be called before non-RTCP packets are sent. | 70 // These must be called before non-RTCP packets are sent. |
70 void RegisterAudioSsrc(uint32 audio_ssrc); | 71 void RegisterAudioSsrc(uint32 audio_ssrc); |
71 void RegisterVideoSsrc(uint32 video_ssrc); | 72 void RegisterVideoSsrc(uint32 video_ssrc); |
72 | 73 |
73 // PacedPacketSender implementation. | 74 // PacedPacketSender implementation. |
74 virtual bool SendPackets(const SendPacketVector& packets) OVERRIDE; | 75 virtual bool SendPackets(const SendPacketVector& packets) OVERRIDE; |
75 virtual bool ResendPackets(const SendPacketVector& packets) OVERRIDE; | 76 virtual bool ResendPackets(const SendPacketVector& packets, |
77 base::TimeDelta rtt) OVERRIDE; | |
76 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) OVERRIDE; | 78 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) OVERRIDE; |
77 virtual void CancelSendingPacket(const PacketKey& packet_key) OVERRIDE; | 79 virtual void CancelSendingPacket(const PacketKey& packet_key) OVERRIDE; |
78 | 80 |
79 private: | 81 private: |
80 // Actually sends the packets to the transport. | 82 // Actually sends the packets to the transport. |
81 void SendStoredPackets(); | 83 void SendStoredPackets(); |
82 void LogPacketEvent(const Packet& packet, bool retransmit); | 84 void LogPacketEvent(const Packet& packet, bool retransmit); |
83 | 85 |
84 enum PacketType { | 86 enum PacketType { |
85 PacketType_RTCP, | 87 PacketType_RTCP, |
(...skipping 15 matching lines...) Expand all Loading... | |
101 // send more data. | 103 // send more data. |
102 State_BurstFull | 104 State_BurstFull |
103 }; | 105 }; |
104 | 106 |
105 bool empty() const; | 107 bool empty() const; |
106 size_t size() const; | 108 size_t size() const; |
107 | 109 |
108 // Returns the next packet to send. RTCP packets have highest priority, | 110 // Returns the next packet to send. RTCP packets have highest priority, |
109 // resend packets have second highest priority and then comes everything | 111 // resend packets have second highest priority and then comes everything |
110 // else. | 112 // else. |
111 PacketRef GetNextPacket(PacketType* packet_type); | 113 PacketRef GetNextPacket(PacketType* packet_type, |
114 PacketKey* packet_key); | |
112 | 115 |
113 base::TickClock* const clock_; // Not owned by this class. | 116 base::TickClock* const clock_; // Not owned by this class. |
114 LoggingImpl* const logging_; // Not owned by this class. | 117 LoggingImpl* const logging_; // Not owned by this class. |
115 PacketSender* transport_; // Not owned by this class. | 118 PacketSender* transport_; // Not owned by this class. |
116 scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; | 119 scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; |
117 uint32 audio_ssrc_; | 120 uint32 audio_ssrc_; |
118 uint32 video_ssrc_; | 121 uint32 video_ssrc_; |
119 std::map<PacketKey, std::pair<PacketType, PacketRef> > packet_list_; | 122 std::map<PacketKey, std::pair<PacketType, PacketRef> > packet_list_; |
123 std::map<PacketKey, base::TimeTicks> sent_time_; | |
Alpha Left Google
2014/06/18 01:43:32
nit: There should be a typedef.
hubbe
2014/06/18 20:22:28
Why?
Alpha Left Google
2014/06/18 20:39:15
There's once place that does "std::map<PacketKey,
| |
124 std::map<PacketKey, base::TimeTicks> sent_time_buffer_; | |
125 PacketKey in_progress_packet_key_; | |
120 | 126 |
121 // Maximum burst size for the next three bursts. | 127 // Maximum burst size for the next three bursts. |
122 size_t max_burst_size_; | 128 size_t max_burst_size_; |
123 size_t next_max_burst_size_; | 129 size_t next_max_burst_size_; |
124 size_t next_next_max_burst_size_; | 130 size_t next_next_max_burst_size_; |
125 // Number of packets already sent in the current burst. | 131 // Number of packets already sent in the current burst. |
126 size_t current_burst_size_; | 132 size_t current_burst_size_; |
127 // This is when the current burst ends. | 133 // This is when the current burst ends. |
128 base::TimeTicks burst_end_; | 134 base::TimeTicks burst_end_; |
129 | 135 |
130 State state_; | 136 State state_; |
131 | 137 |
132 // NOTE: Weak pointers must be invalidated before all other member variables. | 138 // NOTE: Weak pointers must be invalidated before all other member variables. |
133 base::WeakPtrFactory<PacedSender> weak_factory_; | 139 base::WeakPtrFactory<PacedSender> weak_factory_; |
134 | 140 |
135 DISALLOW_COPY_AND_ASSIGN(PacedSender); | 141 DISALLOW_COPY_AND_ASSIGN(PacedSender); |
136 }; | 142 }; |
137 | 143 |
138 } // namespace transport | 144 } // namespace transport |
139 } // namespace cast | 145 } // namespace cast |
140 } // namespace media | 146 } // namespace media |
141 | 147 |
142 #endif // MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ | 148 #endif // MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ |
OLD | NEW |