summaryrefslogtreecommitdiff
path: root/media/cast/framer/frame_buffer.h
blob: 5ca9a514a83bfbf061a49f03d65c2305af58749b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 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_BUFFER
#define MEDIA_CAST_FRAMER_FRAME_BUFFER

#include <map>
#include <vector>

#include "media/cast/cast_config.h"
#include "media/cast/rtp_common/rtp_defines.h"

namespace media {
namespace cast {

typedef std::map<uint16, std::vector<uint8> > PacketMap;

class FrameBuffer {
 public:
  FrameBuffer();
  ~FrameBuffer();
  void InsertPacket(const uint8* payload_data,
                    size_t payload_size,
                    const RtpCastHeader& rtp_header);
  bool Complete() const;

  bool GetEncodedAudioFrame(EncodedAudioFrame* audio_frame,
                            uint32* rtp_timestamp) const;

  bool GetEncodedVideoFrame(EncodedVideoFrame* video_frame,
                            uint32* rtp_timestamp) const;

  bool is_key_frame() const { return is_key_frame_; }

  uint32 last_referenced_frame_id() const { return last_referenced_frame_id_; }

 private:
  uint32 frame_id_;
  uint16 max_packet_id_;
  uint16 num_packets_received_;
  bool is_key_frame_;
  size_t total_data_size_;
  uint32 last_referenced_frame_id_;
  uint32 rtp_timestamp_;
  PacketMap packets_;

  DISALLOW_COPY_AND_ASSIGN(FrameBuffer);
};

}  // namespace cast
}  // namespace media

#endif  // MEDIA_CAST_FRAMER_FRAME_BUFFER