X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmedia%2Fcast%2Ftransport%2Frtp_sender%2Fpacket_storage%2Fpacket_storage.h;h=85efc664c48b96f7574d22c456a9c8397651df78;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=40c451d5c0ede061c64a8a7797571c68a63fe4b2;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/media/cast/transport/rtp_sender/packet_storage/packet_storage.h b/src/media/cast/transport/rtp_sender/packet_storage/packet_storage.h index 40c451d..85efc66 100644 --- a/src/media/cast/transport/rtp_sender/packet_storage/packet_storage.h +++ b/src/media/cast/transport/rtp_sender/packet_storage/packet_storage.h @@ -16,39 +16,57 @@ #include "base/time/time.h" #include "media/cast/transport/cast_transport_config.h" #include "media/cast/transport/cast_transport_defines.h" +#include "media/cast/transport/pacing/paced_sender.h" namespace media { namespace cast { namespace transport { class StoredPacket; -typedef std::map > PacketMap; -typedef std::multimap TimeToPacketMap; + +// StorageIndex contains {frame_id, packet_id}. +typedef std::pair StorageIndex; +typedef std::map > PacketMap; + +// Frame IDs are generally stored as 8-bit values when sent over the +// wire. This means that having a history longer than 255 frames makes +// no sense. +const int kMaxStoredFrames = 255; class PacketStorage { public: - static const unsigned int kMaxStoredPackets = 1000; - - PacketStorage(base::TickClock* clock, int max_time_stored_ms); + PacketStorage(int stored_frames); virtual ~PacketStorage(); - void StorePacket(uint32 frame_id, uint16 packet_id, const Packet* packet); + // Returns true if this class is configured correctly. + // (stored frames > 0 && stored_frames < kMaxStoredFrames) + bool IsValid() const; + + void StorePacket(uint32 frame_id, + uint16 packet_id, + const PacketKey& key, + PacketRef packet); // Copies all missing packets into the packet list. - PacketList GetPackets( - const MissingFramesAndPacketsMap& missing_frames_and_packets); + void GetPackets( + const MissingFramesAndPacketsMap& missing_frames_and_packets, + SendPacketVector* packets_to_resend); // Copies packet into the packet list. - bool GetPacket(uint8 frame_id, uint16 packet_id, PacketList* packets); - + bool GetPacket(uint8 frame_id_8bit, + uint16 packet_id, + SendPacketVector* packets); private: - void CleanupOldPackets(base::TimeTicks now); + FRIEND_TEST_ALL_PREFIXES(PacketStorageTest, PacketContent); + + // Same as GetPacket, but takes a 32-bit frame id. + bool GetPacket32(uint32 frame_id, + uint16 packet_id, + SendPacketVector* packets); + void CleanupOldPackets(uint32 current_frame_id); - base::TickClock* const clock_; // Not owned by this class. - base::TimeDelta max_time_stored_; PacketMap stored_packets_; - TimeToPacketMap time_to_packet_map_; - std::list > free_packets_; + int stored_frames_; DISALLOW_COPY_AND_ASSIGN(PacketStorage); };