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. 4 5 #ifndef MEDIA_CAST_TRANSPORT_RTP_SENDER_PACKET_STORAGE_PACKET_STORAGE_H_ 6 #define MEDIA_CAST_TRANSPORT_RTP_SENDER_PACKET_STORAGE_PACKET_STORAGE_H_ 7 8 #include <deque> 9 #include <list> 10 #include <map> 11 #include <vector> 12 13 #include "base/basictypes.h" 14 #include "base/memory/linked_ptr.h" 15 #include "base/memory/scoped_ptr.h" 16 #include "base/time/tick_clock.h" 17 #include "base/time/time.h" 18 #include "media/cast/transport/cast_transport_config.h" 19 #include "media/cast/transport/cast_transport_defines.h" 20 #include "media/cast/transport/pacing/paced_sender.h" 21 22 namespace media { 23 namespace cast { 24 namespace transport { 25 26 // Stores a list of frames. Each frame consists a list of packets. 27 typedef std::deque<SendPacketVector> FrameQueue; 28 29 class PacketStorage { 30 public: 31 explicit PacketStorage(size_t stored_frames); 32 virtual ~PacketStorage(); 33 34 // Returns true if this class is configured correctly. 35 // (stored frames > 0 && stored_frames < kMaxStoredFrames) 36 bool IsValid() const; 37 38 // Store all of the packets for a frame. 39 void StoreFrame(uint32 frame_id, const SendPacketVector& packets); 40 41 // Returns a list of packets for a frame indexed by a 8-bits ID. 42 // It is the lowest 8 bits of a frame ID. 43 // Returns NULL if the frame cannot be found. 44 const SendPacketVector* GetFrame8(uint8 frame_id_8bits) const; 45 46 // Get the number of stored frames. 47 size_t GetNumberOfStoredFrames() const; 48 49 private: 50 const size_t max_stored_frames_; 51 FrameQueue frames_; 52 uint32 first_frame_id_in_list_; 53 uint32 last_frame_id_in_list_; 54 55 DISALLOW_COPY_AND_ASSIGN(PacketStorage); 56 }; 57 58 } // namespace transport 59 } // namespace cast 60 } // namespace media 61 62 #endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_PACKET_STORAGE_PACKET_STORAGE_H_ 63