Chromium Code Reviews| Index: media/cast/framer/frame_id_map.h |
| diff --git a/media/cast/framer/frame_id_map.h b/media/cast/framer/frame_id_map.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e238932006a781083ba7672fffea81b20e49f956 |
| --- /dev/null |
| +++ b/media/cast/framer/frame_id_map.h |
| @@ -0,0 +1,91 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_CAST_FRAMER_FRAME_ID_MAP_H_ |
| +#define MEDIA_CAST_FRAMER_FRAME_ID_MAP_H_ |
| + |
| +#include <map> |
| +#include <set> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "media/cast/cast_config.h" |
| +#include "media/cast/rtp_common/rtp_defines.h" |
| + |
| +namespace media { |
| +namespace cast { |
| + |
| +class FrameInfo { |
| + public: |
| + FrameInfo(uint8 frame_id, |
| + uint8 referenced_frame_id, |
| + uint16 max_packet_id, |
| + bool key_frame); |
| + ~FrameInfo(); |
| + |
| + // Returns true if frame is complete after the insert. |
| + bool InsertPacket(uint16 packet_id); |
| + bool Complete() const; |
| + void GetMissingPackets(bool newest_frame, |
| + std::set<uint16>* missing_packets) const; |
| + |
| + bool is_key_frame() const { return is_key_frame_; } |
| + uint8_t frame_id() const { return frame_id_; } |
| + uint8_t referenced_frame_id() const { return referenced_frame_id_; } |
| + |
| + private: |
| + const bool is_key_frame_; |
| + const uint8 frame_id_; |
| + const uint8 referenced_frame_id_; |
| + |
| + uint16 max_received_packet_id_; |
| + 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.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(FrameInfo); |
| +}; |
| + |
| +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.
|
| + |
| +class FrameIdMap { |
| + public: |
| + FrameIdMap(); |
| + ~FrameIdMap(); |
| + |
| + // Returns false if not a valid (old) packet, otherwise returns true. |
| + bool InsertPacket(const RtpCastHeader& rtp_header, bool* complete); |
| + |
| + bool Empty() const; |
| + bool FrameExists(uint8 frame_id) const; |
| + uint8 NewestFrameId() const; |
| + |
| + void RemoveOldFrames(uint8 frame_id); |
| + void Clear(); |
| + |
| + // Identifies the next frame to be released (rendered). |
| + bool NextContinuousFrame(uint8* frame_id) const; |
| + uint8_t LastContinuousFrame() const; |
|
Alpha Left Google
2013/08/28 00:27:31
Should be uint8.
pwestin
2013/08/28 16:40:44
Done.
|
| + |
| + bool NextAudioFrameAllowingMissingFrames(uint8* frame_id) const; |
| + bool NextVideoFrameAllowingSkippingFrames(uint8* frame_id) const; |
| + |
| + int NumberOfCompleteFrames() const; |
| + void GetMissingPackets(uint8 frame_id, |
| + bool last_frame, |
| + std::set<uint16>* missing_packets) const; |
| + |
| + private: |
| + bool ContinuousFrame(FrameInfo* frame) const; |
| + bool DecodableVideoFrame(FrameInfo* frame) const; |
| + |
| + FrameMap frame_map_; |
| + bool waiting_for_key_; |
| + uint8 last_released_frame_; |
| + uint8 newest_frame_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FrameIdMap); |
| +}; |
| + |
| +} // namespace cast |
| +} // namespace media |
| + |
| +#endif // MEDIA_CAST_FRAMER_FRAME_ID_MAP_H_ |