Home | History | Annotate | Download | only in rtp
      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_FRAMER_FRAME_BUFFER
      6 #define MEDIA_CAST_FRAMER_FRAME_BUFFER
      7 
      8 #include <map>
      9 #include <vector>
     10 
     11 #include "media/cast/cast_config.h"
     12 #include "media/cast/net/rtp/rtp_receiver_defines.h"
     13 
     14 namespace media {
     15 namespace cast {
     16 
     17 typedef std::map<uint16, std::vector<uint8> > PacketMap;
     18 
     19 class FrameBuffer {
     20  public:
     21   FrameBuffer();
     22   ~FrameBuffer();
     23   bool InsertPacket(const uint8* payload_data,
     24                     size_t payload_size,
     25                     const RtpCastHeader& rtp_header);
     26   bool Complete() const;
     27 
     28   void GetMissingPackets(bool newest_frame, PacketIdSet* missing_packets) const;
     29 
     30   // If a frame is complete, sets the frame IDs and RTP timestamp in |frame|,
     31   // and also copies the data from all packets into the data field in |frame|.
     32   // Returns true if the frame was complete; false if incomplete and |frame|
     33   // remains unchanged.
     34   bool AssembleEncodedFrame(EncodedFrame* frame) const;
     35 
     36   bool is_key_frame() const { return is_key_frame_; }
     37   uint32 last_referenced_frame_id() const { return last_referenced_frame_id_; }
     38   uint32 frame_id() const { return frame_id_; }
     39 
     40  private:
     41   uint32 frame_id_;
     42   uint16 max_packet_id_;
     43   uint16 num_packets_received_;
     44   uint16 max_seen_packet_id_;
     45   uint16 new_playout_delay_ms_;
     46   bool is_key_frame_;
     47   size_t total_data_size_;
     48   uint32 last_referenced_frame_id_;
     49   uint32 rtp_timestamp_;
     50   PacketMap packets_;
     51 
     52   DISALLOW_COPY_AND_ASSIGN(FrameBuffer);
     53 };
     54 
     55 }  // namespace cast
     56 }  // namespace media
     57 
     58 #endif  // MEDIA_CAST_FRAMER_FRAME_BUFFER
     59