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
3// found in the LICENSE file.
4
5#ifndef MEDIA_CAST_NET_RTP_SENDER_PACKET_STORAGE_PACKET_STORAGE_H_
6#define MEDIA_CAST_NET_RTP_SENDER_PACKET_STORAGE_PACKET_STORAGE_H_
7
8#include <deque>
9
10#include "base/basictypes.h"
11#include "media/cast/net/pacing/paced_sender.h"
12
13namespace media {
14namespace cast {
15
16class PacketStorage {
17 public:
18  PacketStorage();
19  virtual ~PacketStorage();
20
21  // Store all of the packets for a frame.
22  void StoreFrame(uint32 frame_id, const SendPacketVector& packets);
23
24  // Release all of the packets for a frame.
25  void ReleaseFrame(uint32 frame_id);
26
27  // Returns a list of packets for a frame indexed by a 8-bits ID.
28  // It is the lowest 8 bits of a frame ID.
29  // Returns NULL if the frame cannot be found.
30  const SendPacketVector* GetFrame8(uint8 frame_id_8bits) const;
31
32  // Get the number of stored frames.
33  size_t GetNumberOfStoredFrames() const;
34
35 private:
36  std::deque<SendPacketVector> frames_;
37  uint32 first_frame_id_in_list_;
38
39  // The number of frames whose packets have been released, but the entry in the
40  // |frames_| queue has not yet been popped.
41  size_t zombie_count_;
42
43  DISALLOW_COPY_AND_ASSIGN(PacketStorage);
44};
45
46}  // namespace cast
47}  // namespace media
48
49#endif  // MEDIA_CAST_NET_RTP_SENDER_PACKET_STORAGE_PACKET_STORAGE_H_
50