blob: 413cc3391036ac7a68e4c6d27466c1eac736cf6b [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
philipel88488282016-11-03 08:56:54 -070014#include "webrtc/base/optional.h"
philipel02447bc2016-05-13 06:01:03 -070015#include "webrtc/common_types.h"
16#include "webrtc/modules/include/module_common_types.h"
philipel552866c2016-07-04 16:18:55 +020017#include "webrtc/modules/video_coding/encoded_frame.h"
philipelc707ab72016-04-01 02:01:54 -070018
19namespace webrtc {
20namespace video_coding {
21
philipel552866c2016-07-04 16:18:55 +020022class FrameObject : public webrtc::VCMEncodedFrame {
philipelc707ab72016-04-01 02:01:54 -070023 public:
philipelf4139332016-04-20 10:26:34 +020024 static const uint8_t kMaxFrameReferences = 5;
25
philipela1059872016-05-09 11:41:48 +020026 FrameObject();
philipelb4d31082016-07-11 08:46:29 -070027 virtual ~FrameObject() {}
philipela1059872016-05-09 11:41:48 +020028
philipelc707ab72016-04-01 02:01:54 -070029 virtual bool GetBitstream(uint8_t* destination) const = 0;
philipelb4d31082016-07-11 08:46:29 -070030
31 // The capture timestamp of this frame.
32 virtual uint32_t Timestamp() const = 0;
33
34 // When this frame was received.
35 virtual int64_t ReceivedTime() const = 0;
36
37 // When this frame should be rendered.
38 virtual int64_t RenderTime() const = 0;
39
philipele0754302017-01-25 08:56:23 -080040 // This information is currently needed by the timing calculation class.
41 // TODO(philipel): Remove this function when a new timing class has
42 // been implemented.
43 virtual bool delayed_by_retransmission() const { return 0; }
44
nisse37abf532016-10-28 00:37:29 -070045 size_t size() { return _length; }
philipelf4139332016-04-20 10:26:34 +020046
philipela1059872016-05-09 11:41:48 +020047 // The tuple (|picture_id|, |spatial_layer|) uniquely identifies a frame
48 // object. For codec types that don't necessarily have picture ids they
49 // have to be constructed from the header data relevant to that codec.
philipelf4139332016-04-20 10:26:34 +020050 uint16_t picture_id;
philipela1059872016-05-09 11:41:48 +020051 uint8_t spatial_layer;
philipelbe7a9e52016-05-19 12:19:35 +020052 uint32_t timestamp;
philipela1059872016-05-09 11:41:48 +020053
philipelf4139332016-04-20 10:26:34 +020054 size_t num_references;
philipelf4139332016-04-20 10:26:34 +020055 uint16_t references[kMaxFrameReferences];
philipela1059872016-05-09 11:41:48 +020056 bool inter_layer_predicted;
philipelc707ab72016-04-01 02:01:54 -070057};
58
59class PacketBuffer;
60
61class RtpFrameObject : public FrameObject {
62 public:
63 RtpFrameObject(PacketBuffer* packet_buffer,
philipel02447bc2016-05-13 06:01:03 -070064 uint16_t first_seq_num,
philipel5ceaaae2016-05-24 10:20:47 +020065 uint16_t last_seq_num,
66 size_t frame_size,
philipelb4d31082016-07-11 08:46:29 -070067 int times_nacked,
68 int64_t received_time);
philipelf4139332016-04-20 10:26:34 +020069
philipelc707ab72016-04-01 02:01:54 -070070 ~RtpFrameObject();
philipelf4139332016-04-20 10:26:34 +020071 uint16_t first_seq_num() const;
72 uint16_t last_seq_num() const;
philipel5ceaaae2016-05-24 10:20:47 +020073 int times_nacked() const;
philipel552866c2016-07-04 16:18:55 +020074 enum FrameType frame_type() const;
philipel02447bc2016-05-13 06:01:03 -070075 VideoCodecType codec_type() const;
philipelc707ab72016-04-01 02:01:54 -070076 bool GetBitstream(uint8_t* destination) const override;
philipelb4d31082016-07-11 08:46:29 -070077 uint32_t Timestamp() const override;
78 int64_t ReceivedTime() const override;
79 int64_t RenderTime() const override;
philipele0754302017-01-25 08:56:23 -080080 bool delayed_by_retransmission() const override;
philipel88488282016-11-03 08:56:54 -070081 rtc::Optional<RTPVideoTypeHeader> GetCodecHeader() const;
philipelc707ab72016-04-01 02:01:54 -070082
83 private:
philipel17deeb42016-08-11 15:09:26 +020084 rtc::scoped_refptr<PacketBuffer> packet_buffer_;
philipel552866c2016-07-04 16:18:55 +020085 enum FrameType frame_type_;
philipel02447bc2016-05-13 06:01:03 -070086 VideoCodecType codec_type_;
87 uint16_t first_seq_num_;
88 uint16_t last_seq_num_;
philipelb4d31082016-07-11 08:46:29 -070089 uint32_t timestamp_;
90 int64_t received_time_;
philipel5ceaaae2016-05-24 10:20:47 +020091
92 // Equal to times nacked of the packet with the highet times nacked
93 // belonging to this frame.
94 int times_nacked_;
philipelc707ab72016-04-01 02:01:54 -070095};
96
97} // namespace video_coding
98} // namespace webrtc
99
100#endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_