Add explicit |forceOnlineSignin| to user pod status
[chromium-blink-merge.git] / media / cast / framer / frame_id_map.h
blobdb3d3de093b44ada2e75ba1fc2c6509d9c2e8059
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_FRAMER_FRAME_ID_MAP_H_
6 #define MEDIA_CAST_FRAMER_FRAME_ID_MAP_H_
8 #include <map>
9 #include <set>
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "media/cast/cast_config.h"
14 #include "media/cast/rtcp/rtcp_defines.h"
15 #include "media/cast/rtp_receiver/rtp_receiver_defines.h"
17 namespace media {
18 namespace cast {
20 class FrameInfo {
21 public:
22 FrameInfo(uint32 frame_id,
23 uint32 referenced_frame_id,
24 uint16 max_packet_id,
25 bool key_frame);
26 ~FrameInfo();
28 PacketType InsertPacket(uint16 packet_id);
29 bool Complete() const;
30 void GetMissingPackets(bool newest_frame,
31 PacketIdSet* missing_packets) const;
33 bool is_key_frame() const { return is_key_frame_; }
34 uint32 frame_id() const { return frame_id_; }
35 uint32 referenced_frame_id() const { return referenced_frame_id_; }
37 private:
38 const bool is_key_frame_;
39 const uint32 frame_id_;
40 const uint32 referenced_frame_id_;
42 uint16 max_received_packet_id_;
43 PacketIdSet missing_packets_;
45 DISALLOW_COPY_AND_ASSIGN(FrameInfo);
48 typedef std::map<uint32, linked_ptr<FrameInfo> > FrameMap;
50 class FrameIdMap {
51 public:
52 FrameIdMap();
53 ~FrameIdMap();
55 PacketType InsertPacket(const RtpCastHeader& rtp_header);
57 bool Empty() const;
58 bool FrameExists(uint32 frame_id) const;
59 uint32 NewestFrameId() const;
61 void RemoveOldFrames(uint32 frame_id);
62 void Clear();
64 // Identifies the next frame to be released (rendered).
65 bool NextContinuousFrame(uint32* frame_id) const;
66 uint32 LastContinuousFrame() const;
68 bool NextAudioFrameAllowingMissingFrames(uint32* frame_id) const;
69 bool NextVideoFrameAllowingSkippingFrames(uint32* frame_id) const;
71 int NumberOfCompleteFrames() const;
72 void GetMissingPackets(uint32 frame_id,
73 bool last_frame,
74 PacketIdSet* missing_packets) const;
76 private:
77 bool ContinuousFrame(FrameInfo* frame) const;
78 bool DecodableVideoFrame(FrameInfo* frame) const;
80 FrameMap frame_map_;
81 bool waiting_for_key_;
82 uint32 last_released_frame_;
83 uint32 newest_frame_id_;
85 DISALLOW_COPY_AND_ASSIGN(FrameIdMap);
88 } // namespace cast
89 } // namespace media
91 #endif // MEDIA_CAST_FRAMER_FRAME_ID_MAP_H_