Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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_FRAMER_FRAME_ID_MAP_H_ | |
| 6 #define MEDIA_CAST_FRAMER_FRAME_ID_MAP_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <set> | |
| 10 | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "media/cast/cast_config.h" | |
| 13 #include "media/cast/rtp_common/rtp_defines.h" | |
| 14 | |
| 15 namespace media { | |
| 16 namespace cast { | |
| 17 | |
| 18 class FrameInfo { | |
| 19 public: | |
| 20 FrameInfo(uint8 frame_id, | |
| 21 uint8 referenced_frame_id, | |
| 22 uint16 max_packet_id, | |
| 23 bool key_frame); | |
| 24 ~FrameInfo(); | |
| 25 | |
| 26 // Returns true if frame is complete after the insert. | |
| 27 bool InsertPacket(uint16 packet_id); | |
| 28 bool Complete() const; | |
| 29 void GetMissingPackets(bool newest_frame, | |
| 30 std::set<uint16>* missing_packets) const; | |
| 31 | |
| 32 bool is_key_frame() const { return is_key_frame_; } | |
| 33 uint8_t frame_id() const { return frame_id_; } | |
| 34 uint8_t referenced_frame_id() const { return referenced_frame_id_; } | |
| 35 | |
| 36 private: | |
| 37 const bool is_key_frame_; | |
| 38 const uint8 frame_id_; | |
| 39 const uint8 referenced_frame_id_; | |
| 40 | |
| 41 uint16 max_received_packet_id_; | |
| 42 std::set<uint16> missing_packets_; | |
|
Alpha Left Google
2013/08/28 00:27:31
I suggest a typedef for this, e.g. PacketIdSet.
pwestin
2013/08/28 16:40:44
Done.
| |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(FrameInfo); | |
| 45 }; | |
| 46 | |
| 47 typedef std::map<uint8, FrameInfo*> FrameMap; | |
|
Alpha Left Google
2013/08/28 00:27:31
Use std::map<uint8, linked_ptr<FrameInfo> > instea
pwestin
2013/08/28 16:40:44
Done.
| |
| 48 | |
| 49 class FrameIdMap { | |
| 50 public: | |
| 51 FrameIdMap(); | |
| 52 ~FrameIdMap(); | |
| 53 | |
| 54 // Returns false if not a valid (old) packet, otherwise returns true. | |
| 55 bool InsertPacket(const RtpCastHeader& rtp_header, bool* complete); | |
| 56 | |
| 57 bool Empty() const; | |
| 58 bool FrameExists(uint8 frame_id) const; | |
| 59 uint8 NewestFrameId() const; | |
| 60 | |
| 61 void RemoveOldFrames(uint8 frame_id); | |
| 62 void Clear(); | |
| 63 | |
| 64 // Identifies the next frame to be released (rendered). | |
| 65 bool NextContinuousFrame(uint8* frame_id) const; | |
| 66 uint8_t LastContinuousFrame() const; | |
|
Alpha Left Google
2013/08/28 00:27:31
Should be uint8.
pwestin
2013/08/28 16:40:44
Done.
| |
| 67 | |
| 68 bool NextAudioFrameAllowingMissingFrames(uint8* frame_id) const; | |
| 69 bool NextVideoFrameAllowingSkippingFrames(uint8* frame_id) const; | |
| 70 | |
| 71 int NumberOfCompleteFrames() const; | |
| 72 void GetMissingPackets(uint8 frame_id, | |
| 73 bool last_frame, | |
| 74 std::set<uint16>* missing_packets) const; | |
| 75 | |
| 76 private: | |
| 77 bool ContinuousFrame(FrameInfo* frame) const; | |
| 78 bool DecodableVideoFrame(FrameInfo* frame) const; | |
| 79 | |
| 80 FrameMap frame_map_; | |
| 81 bool waiting_for_key_; | |
| 82 uint8 last_released_frame_; | |
| 83 uint8 newest_frame_id_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(FrameIdMap); | |
| 86 }; | |
| 87 | |
| 88 } // namespace cast | |
| 89 } // namespace media | |
| 90 | |
| 91 #endif // MEDIA_CAST_FRAMER_FRAME_ID_MAP_H_ | |
| OLD | NEW |