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
3 // found in the LICENSE file.
5 #ifndef MEDIA_CAST_TRANSPORT_RTP_SENDER_PACKET_STORAGE_PACKET_STORAGE_H_
6 #define MEDIA_CAST_TRANSPORT_RTP_SENDER_PACKET_STORAGE_PACKET_STORAGE_H_
12 #include "base/basictypes.h"
13 #include "base/memory/linked_ptr.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/time/tick_clock.h"
16 #include "base/time/time.h"
17 #include "media/cast/transport/cast_transport_config.h"
18 #include "media/cast/transport/cast_transport_defines.h"
19 #include "media/cast/transport/pacing/paced_sender.h"
27 // StorageIndex contains {frame_id, packet_id}.
28 typedef std::pair<uint32, uint16> StorageIndex;
29 typedef std::map<StorageIndex, std::pair<PacketKey, PacketRef> > PacketMap;
31 // Frame IDs are generally stored as 8-bit values when sent over the
32 // wire. This means that having a history longer than 255 frames makes
34 const int kMaxStoredFrames = 255;
38 PacketStorage(int stored_frames);
39 virtual ~PacketStorage();
41 // Returns true if this class is configured correctly.
42 // (stored frames > 0 && stored_frames < kMaxStoredFrames)
45 void StorePacket(uint32 frame_id,
50 // Copies all missing packets into the packet list.
52 const MissingFramesAndPacketsMap& missing_frames_and_packets,
53 SendPacketVector* packets_to_resend);
55 // Copies packet into the packet list.
56 bool GetPacket(uint8 frame_id_8bit,
58 SendPacketVector* packets);
60 FRIEND_TEST_ALL_PREFIXES(PacketStorageTest, PacketContent);
62 // Same as GetPacket, but takes a 32-bit frame id.
63 bool GetPacket32(uint32 frame_id,
65 SendPacketVector* packets);
66 void CleanupOldPackets(uint32 current_frame_id);
68 PacketMap stored_packets_;
71 DISALLOW_COPY_AND_ASSIGN(PacketStorage);
74 } // namespace transport
78 #endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_PACKET_STORAGE_PACKET_STORAGE_H_