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

Side by Side Diff: media/cast/net/pacing/paced_sender.h

Issue 1487223002: Change PacketKey to be unique for each frame packet by including (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | media/cast/net/pacing/paced_sender.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_PACING_PACED_SENDER_H_ 5 #ifndef MEDIA_CAST_NET_PACING_PACED_SENDER_H_
6 #define MEDIA_CAST_NET_PACING_PACED_SENDER_H_ 6 #define MEDIA_CAST_NET_PACING_PACED_SENDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <tuple>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
16 #include "base/time/default_tick_clock.h" 17 #include "base/time/default_tick_clock.h"
17 #include "base/time/tick_clock.h" 18 #include "base/time/tick_clock.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "media/cast/logging/logging_defines.h" 20 #include "media/cast/logging/logging_defines.h"
20 #include "media/cast/net/cast_transport_config.h" 21 #include "media/cast/net/cast_transport_config.h"
21 22
22 namespace media { 23 namespace media {
23 namespace cast { 24 namespace cast {
24 25
25 // Meant to use as defaults for pacer construction. 26 // Meant to use as defaults for pacer construction.
26 static const size_t kTargetBurstSize = 10; 27 static const size_t kTargetBurstSize = 10;
27 static const size_t kMaxBurstSize = 20; 28 static const size_t kMaxBurstSize = 20;
28 29
29 // Use std::pair for free comparison operators.
30 // { capture_time, ssrc, packet_id }
31 // The PacketKey is designed to meet two criteria: 30 // The PacketKey is designed to meet two criteria:
32 // 1. When we re-send the same packet again, we can use the packet key 31 // 1. When we re-send the same packet again, we can use the packet key
33 // to identify it so that we can de-duplicate packets in the queue. 32 // to identify it so that we can de-duplicate packets in the queue.
34 // 2. The sort order of the PacketKey determines the order that packets 33 // 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 34 // are sent out.
36 // means that older packets are sent first. 35 // 3. The PacketKey is unique for each RTP (frame) packet.
37 typedef std::pair<base::TimeTicks, std::pair<uint32, uint16> > PacketKey; 36 struct PacketKey {
37 enum PacketType { RTCP = 0, RTP = 1 };
38
39 PacketType packet_type;
40 uint32 frame_id;
41 uint32 ssrc;
42 uint16 packet_id;
43
44 bool operator<(const PacketKey& key) const {
45 return std::tie(packet_type, frame_id, ssrc, packet_id) <
46 std::tie(key.packet_type, key.frame_id, key.ssrc, key.packet_id);
47 }
48 };
49
38 typedef std::vector<std::pair<PacketKey, PacketRef> > SendPacketVector; 50 typedef std::vector<std::pair<PacketKey, PacketRef> > SendPacketVector;
39 51
40 // Information used to deduplicate retransmission packets. 52 // Information used to deduplicate retransmission packets.
41 // There are two criteria for deduplication. 53 // There are two criteria for deduplication.
42 // 54 //
43 // 1. Using another muxed stream. 55 // 1. Using another muxed stream.
44 // Suppose there are multiple streams muxed and sent via the same 56 // Suppose there are multiple streams muxed and sent via the same
45 // socket. When there is a retransmission request for packet X, we 57 // socket. When there is a retransmission request for packet X, we
46 // will reject the retransmission if there is a packet sent from 58 // will reject the retransmission if there is a packet sent from
47 // another stream just before X but not acked. Typically audio stream 59 // another stream just before X but not acked. Typically audio stream
(...skipping 13 matching lines...) Expand all
61 class PacedPacketSender { 73 class PacedPacketSender {
62 public: 74 public:
63 virtual bool SendPackets(const SendPacketVector& packets) = 0; 75 virtual bool SendPackets(const SendPacketVector& packets) = 0;
64 virtual bool ResendPackets(const SendPacketVector& packets, 76 virtual bool ResendPackets(const SendPacketVector& packets,
65 const DedupInfo& dedup_info) = 0; 77 const DedupInfo& dedup_info) = 0;
66 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) = 0; 78 virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) = 0;
67 virtual void CancelSendingPacket(const PacketKey& packet_key) = 0; 79 virtual void CancelSendingPacket(const PacketKey& packet_key) = 0;
68 80
69 virtual ~PacedPacketSender() {} 81 virtual ~PacedPacketSender() {}
70 82
71 static PacketKey MakePacketKey(const base::TimeTicks& ticks, 83 static PacketKey MakePacketKey(PacketKey::PacketType,
84 uint32 frame_id,
72 uint32 ssrc, 85 uint32 ssrc,
73 uint16 packet_id); 86 uint16 packet_id);
74 }; 87 };
75 88
76 class PacedSender : public PacedPacketSender, 89 class PacedSender : public PacedPacketSender,
77 public base::NonThreadSafe, 90 public base::NonThreadSafe,
78 public base::SupportsWeakPtr<PacedSender> { 91 public base::SupportsWeakPtr<PacedSender> {
79 public: 92 public:
80 // |recent_packet_events| is an externally-owned vector where PacedSender will 93 // |recent_packet_events| is an externally-owned vector where PacedSender will
81 // add PacketEvents related to sending, retransmission, and rejection. The 94 // add PacketEvents related to sending, retransmission, and rejection. The
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // NOTE: Weak pointers must be invalidated before all other member variables. 228 // NOTE: Weak pointers must be invalidated before all other member variables.
216 base::WeakPtrFactory<PacedSender> weak_factory_; 229 base::WeakPtrFactory<PacedSender> weak_factory_;
217 230
218 DISALLOW_COPY_AND_ASSIGN(PacedSender); 231 DISALLOW_COPY_AND_ASSIGN(PacedSender);
219 }; 232 };
220 233
221 } // namespace cast 234 } // namespace cast
222 } // namespace media 235 } // namespace media
223 236
224 #endif // MEDIA_CAST_NET_PACING_PACED_SENDER_H_ 237 #endif // MEDIA_CAST_NET_PACING_PACED_SENDER_H_
OLDNEW
« no previous file with comments | « no previous file | media/cast/net/pacing/paced_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698