blob: 5b299e673c3c903bfd27c1079a261c2b3a4b4ed9 [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();
philipelb4d31082016-07-11 08:46:29 -070026 virtual ~FrameObject() {}
philipela1059872016-05-09 11:41:48 +020027
philipelc707ab72016-04-01 02:01:54 -070028 virtual bool GetBitstream(uint8_t* destination) const = 0;
philipelb4d31082016-07-11 08:46:29 -070029
30 // The capture timestamp of this frame.
31 virtual uint32_t Timestamp() const = 0;
32
33 // When this frame was received.
34 virtual int64_t ReceivedTime() const = 0;
35
36 // When this frame should be rendered.
37 virtual int64_t RenderTime() const = 0;
38
philipelf4139332016-04-20 10:26:34 +020039
philipela1059872016-05-09 11:41:48 +020040 // The tuple (|picture_id|, |spatial_layer|) uniquely identifies a frame
41 // object. For codec types that don't necessarily have picture ids they
42 // have to be constructed from the header data relevant to that codec.
philipelf4139332016-04-20 10:26:34 +020043 uint16_t picture_id;
philipela1059872016-05-09 11:41:48 +020044 uint8_t spatial_layer;
philipelbe7a9e52016-05-19 12:19:35 +020045 uint32_t timestamp;
philipela1059872016-05-09 11:41:48 +020046
philipelf4139332016-04-20 10:26:34 +020047 size_t num_references;
philipelf4139332016-04-20 10:26:34 +020048 uint16_t references[kMaxFrameReferences];
philipela1059872016-05-09 11:41:48 +020049 bool inter_layer_predicted;
philipel5ceaaae2016-05-24 10:20:47 +020050
51 size_t size;
philipelc707ab72016-04-01 02:01:54 -070052};
53
54class PacketBuffer;
55
56class RtpFrameObject : public FrameObject {
57 public:
58 RtpFrameObject(PacketBuffer* packet_buffer,
philipel02447bc2016-05-13 06:01:03 -070059 uint16_t first_seq_num,
philipel5ceaaae2016-05-24 10:20:47 +020060 uint16_t last_seq_num,
61 size_t frame_size,
philipelb4d31082016-07-11 08:46:29 -070062 int times_nacked,
63 int64_t received_time);
philipelf4139332016-04-20 10:26:34 +020064
philipelc707ab72016-04-01 02:01:54 -070065 ~RtpFrameObject();
philipelf4139332016-04-20 10:26:34 +020066 uint16_t first_seq_num() const;
67 uint16_t last_seq_num() const;
philipel5ceaaae2016-05-24 10:20:47 +020068 int times_nacked() const;
philipel552866c2016-07-04 16:18:55 +020069 enum FrameType frame_type() const;
philipel02447bc2016-05-13 06:01:03 -070070 VideoCodecType codec_type() const;
philipelc707ab72016-04-01 02:01:54 -070071 bool GetBitstream(uint8_t* destination) const override;
philipelb4d31082016-07-11 08:46:29 -070072 uint32_t Timestamp() const override;
73 int64_t ReceivedTime() const override;
74 int64_t RenderTime() const override;
philipel02447bc2016-05-13 06:01:03 -070075 RTPVideoTypeHeader* GetCodecHeader() const;
philipelc707ab72016-04-01 02:01:54 -070076
77 private:
78 PacketBuffer* packet_buffer_;
philipel552866c2016-07-04 16:18:55 +020079 enum FrameType frame_type_;
philipel02447bc2016-05-13 06:01:03 -070080 VideoCodecType codec_type_;
81 uint16_t first_seq_num_;
82 uint16_t last_seq_num_;
philipelb4d31082016-07-11 08:46:29 -070083 uint32_t timestamp_;
84 int64_t received_time_;
philipel5ceaaae2016-05-24 10:20:47 +020085
86 // Equal to times nacked of the packet with the highet times nacked
87 // belonging to this frame.
88 int times_nacked_;
philipelc707ab72016-04-01 02:01:54 -070089};
90
91} // namespace video_coding
92} // namespace webrtc
93
94#endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_