blob: b0d0d12e024fa88c21a5f6135ccd8c4c9bd5a18f [file] [log] [blame]
philipelc707ab72016-04-01 02:01:54 -07001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_
12#define WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_
13
philipel02447bc2016-05-13 06:01:03 -070014#include "webrtc/common_types.h"
15#include "webrtc/modules/include/module_common_types.h"
philipel552866c2016-07-04 16:18:55 +020016#include "webrtc/modules/video_coding/encoded_frame.h"
philipelc707ab72016-04-01 02:01:54 -070017
18namespace webrtc {
19namespace video_coding {
20
philipel552866c2016-07-04 16:18:55 +020021class FrameObject : public webrtc::VCMEncodedFrame {
philipelc707ab72016-04-01 02:01:54 -070022 public:
philipelf4139332016-04-20 10:26:34 +020023 static const uint8_t kMaxFrameReferences = 5;
24
philipela1059872016-05-09 11:41:48 +020025 FrameObject();
26
philipelc707ab72016-04-01 02:01:54 -070027 virtual bool GetBitstream(uint8_t* destination) const = 0;
28 virtual ~FrameObject() {}
philipelf4139332016-04-20 10:26:34 +020029
philipela1059872016-05-09 11:41:48 +020030 // The tuple (|picture_id|, |spatial_layer|) uniquely identifies a frame
31 // object. For codec types that don't necessarily have picture ids they
32 // have to be constructed from the header data relevant to that codec.
philipelf4139332016-04-20 10:26:34 +020033 uint16_t picture_id;
philipela1059872016-05-09 11:41:48 +020034 uint8_t spatial_layer;
philipelbe7a9e52016-05-19 12:19:35 +020035 uint32_t timestamp;
philipela1059872016-05-09 11:41:48 +020036
philipelf4139332016-04-20 10:26:34 +020037 size_t num_references;
philipelf4139332016-04-20 10:26:34 +020038 uint16_t references[kMaxFrameReferences];
philipela1059872016-05-09 11:41:48 +020039 bool inter_layer_predicted;
philipel5ceaaae2016-05-24 10:20:47 +020040
41 size_t size;
philipelc707ab72016-04-01 02:01:54 -070042};
43
44class PacketBuffer;
45
46class RtpFrameObject : public FrameObject {
47 public:
48 RtpFrameObject(PacketBuffer* packet_buffer,
philipel02447bc2016-05-13 06:01:03 -070049 uint16_t first_seq_num,
philipel5ceaaae2016-05-24 10:20:47 +020050 uint16_t last_seq_num,
51 size_t frame_size,
52 int times_nacked);
philipelf4139332016-04-20 10:26:34 +020053
philipelc707ab72016-04-01 02:01:54 -070054 ~RtpFrameObject();
philipelf4139332016-04-20 10:26:34 +020055 uint16_t first_seq_num() const;
56 uint16_t last_seq_num() const;
philipel5ceaaae2016-05-24 10:20:47 +020057 int times_nacked() const;
philipel552866c2016-07-04 16:18:55 +020058 enum FrameType frame_type() const;
philipel02447bc2016-05-13 06:01:03 -070059 VideoCodecType codec_type() const;
philipelc707ab72016-04-01 02:01:54 -070060 bool GetBitstream(uint8_t* destination) const override;
philipel02447bc2016-05-13 06:01:03 -070061 RTPVideoTypeHeader* GetCodecHeader() const;
philipelc707ab72016-04-01 02:01:54 -070062
63 private:
64 PacketBuffer* packet_buffer_;
philipel552866c2016-07-04 16:18:55 +020065 enum FrameType frame_type_;
philipel02447bc2016-05-13 06:01:03 -070066 VideoCodecType codec_type_;
67 uint16_t first_seq_num_;
68 uint16_t last_seq_num_;
philipel5ceaaae2016-05-24 10:20:47 +020069
70 // Equal to times nacked of the packet with the highet times nacked
71 // belonging to this frame.
72 int times_nacked_;
philipelc707ab72016-04-01 02:01:54 -070073};
74
75} // namespace video_coding
76} // namespace webrtc
77
78#endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_