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 25 matching lines...) Expand all Loading... |
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) = 0; |
45 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) = 0; | 45 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) = 0; |
| 46 virtual void CancelSendingPacket(const PacketKey& packet_key) = 0; |
46 | 47 |
47 virtual ~PacedPacketSender() {} | 48 virtual ~PacedPacketSender() {} |
48 | 49 |
49 static PacketKey MakePacketKey(const base::TimeTicks& ticks, | 50 static PacketKey MakePacketKey(const base::TimeTicks& ticks, |
50 uint32 ssrc, | 51 uint32 ssrc, |
51 uint16 packet_id); | 52 uint16 packet_id); |
52 }; | 53 }; |
53 | 54 |
54 class PacedSender : public PacedPacketSender, | 55 class PacedSender : public PacedPacketSender, |
55 public base::NonThreadSafe, | 56 public base::NonThreadSafe, |
(...skipping 10 matching lines...) Expand all Loading... |
66 virtual ~PacedSender(); | 67 virtual ~PacedSender(); |
67 | 68 |
68 // These must be called before non-RTCP packets are sent. | 69 // These must be called before non-RTCP packets are sent. |
69 void RegisterAudioSsrc(uint32 audio_ssrc); | 70 void RegisterAudioSsrc(uint32 audio_ssrc); |
70 void RegisterVideoSsrc(uint32 video_ssrc); | 71 void RegisterVideoSsrc(uint32 video_ssrc); |
71 | 72 |
72 // PacedPacketSender implementation. | 73 // PacedPacketSender implementation. |
73 virtual bool SendPackets(const SendPacketVector& packets) OVERRIDE; | 74 virtual bool SendPackets(const SendPacketVector& packets) OVERRIDE; |
74 virtual bool ResendPackets(const SendPacketVector& packets) OVERRIDE; | 75 virtual bool ResendPackets(const SendPacketVector& packets) OVERRIDE; |
75 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) OVERRIDE; | 76 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) OVERRIDE; |
| 77 virtual void CancelSendingPacket(const PacketKey& packet_key) OVERRIDE; |
76 | 78 |
77 private: | 79 private: |
78 // Actually sends the packets to the transport. | 80 // Actually sends the packets to the transport. |
79 void SendStoredPackets(); | 81 void SendStoredPackets(); |
80 void LogPacketEvent(const Packet& packet, bool retransmit); | 82 void LogPacketEvent(const Packet& packet, bool retransmit); |
81 | 83 |
82 enum PacketType { | 84 enum PacketType { |
83 PacketType_RTCP, | 85 PacketType_RTCP, |
84 PacketType_Resend, | 86 PacketType_Resend, |
85 PacketType_Normal | 87 PacketType_Normal |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 base::WeakPtrFactory<PacedSender> weak_factory_; | 133 base::WeakPtrFactory<PacedSender> weak_factory_; |
132 | 134 |
133 DISALLOW_COPY_AND_ASSIGN(PacedSender); | 135 DISALLOW_COPY_AND_ASSIGN(PacedSender); |
134 }; | 136 }; |
135 | 137 |
136 } // namespace transport | 138 } // namespace transport |
137 } // namespace cast | 139 } // namespace cast |
138 } // namespace media | 140 } // namespace media |
139 | 141 |
140 #endif // MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ | 142 #endif // MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ |
OLD | NEW |