blob: 5299ed8152a59827fadccfd3070178ec4c12ec10 [file] [log] [blame]
philipelc70e4ec2016-04-01 09:01:541/*
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
philipel871cc2c2016-05-13 13:01:0314#include "webrtc/common_types.h"
15#include "webrtc/modules/include/module_common_types.h"
philipelca7ea5f2016-07-04 14:18:5516#include "webrtc/modules/video_coding/encoded_frame.h"
Edward Lemur76de83e2017-07-06 17:44:3417#include "webrtc/rtc_base/optional.h"
philipelc70e4ec2016-04-01 09:01:5418
19namespace webrtc {
20namespace video_coding {
21
philipelca7ea5f2016-07-04 14:18:5522class FrameObject : public webrtc::VCMEncodedFrame {
philipelc70e4ec2016-04-01 09:01:5423 public:
philipel2d4f1082016-04-20 08:26:3424 static const uint8_t kMaxFrameReferences = 5;
25
philipel2e86f762016-05-09 09:41:4826 FrameObject();
philipeld053dee2016-07-11 15:46:2927 virtual ~FrameObject() {}
philipel2e86f762016-05-09 09:41:4828
philipelc70e4ec2016-04-01 09:01:5429 virtual bool GetBitstream(uint8_t* destination) const = 0;
philipeld053dee2016-07-11 15:46:2930
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
philipelfdbe39f2017-01-25 16:56:2340 // 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
philipel43eaad52017-08-04 13:39:3145 size_t size() const { return _length; }
philipel2d4f1082016-04-20 08:26:3446
philipel21950c62017-08-18 11:55:0247 bool is_keyframe() const { return num_references == 0; }
48
philipel2e86f762016-05-09 09:41:4849 // The tuple (|picture_id|, |spatial_layer|) uniquely identifies a frame
50 // object. For codec types that don't necessarily have picture ids they
51 // have to be constructed from the header data relevant to that codec.
philipel2d4f1082016-04-20 08:26:3452 uint16_t picture_id;
philipel2e86f762016-05-09 09:41:4853 uint8_t spatial_layer;
philipel1934b822016-05-19 10:19:3554 uint32_t timestamp;
philipel2e86f762016-05-09 09:41:4855
philipelc81ec9b2017-06-15 16:06:2156 // TODO(philipel): Add simple modify/access functions to prevent adding too
57 // many |references|.
philipel2d4f1082016-04-20 08:26:3458 size_t num_references;
philipel2d4f1082016-04-20 08:26:3459 uint16_t references[kMaxFrameReferences];
philipel2e86f762016-05-09 09:41:4860 bool inter_layer_predicted;
philipelc70e4ec2016-04-01 09:01:5461};
62
63class PacketBuffer;
64
65class RtpFrameObject : public FrameObject {
66 public:
67 RtpFrameObject(PacketBuffer* packet_buffer,
philipel871cc2c2016-05-13 13:01:0368 uint16_t first_seq_num,
philipel0aeed852016-05-24 08:20:4769 uint16_t last_seq_num,
70 size_t frame_size,
philipeld053dee2016-07-11 15:46:2971 int times_nacked,
72 int64_t received_time);
philipel2d4f1082016-04-20 08:26:3473
philipelc70e4ec2016-04-01 09:01:5474 ~RtpFrameObject();
philipel2d4f1082016-04-20 08:26:3475 uint16_t first_seq_num() const;
76 uint16_t last_seq_num() const;
philipel0aeed852016-05-24 08:20:4777 int times_nacked() const;
philipelca7ea5f2016-07-04 14:18:5578 enum FrameType frame_type() const;
philipel871cc2c2016-05-13 13:01:0379 VideoCodecType codec_type() const;
philipelc70e4ec2016-04-01 09:01:5480 bool GetBitstream(uint8_t* destination) const override;
philipeld053dee2016-07-11 15:46:2981 uint32_t Timestamp() const override;
82 int64_t ReceivedTime() const override;
83 int64_t RenderTime() const override;
philipelfdbe39f2017-01-25 16:56:2384 bool delayed_by_retransmission() const override;
philipel4bf739e2016-11-03 15:56:5485 rtc::Optional<RTPVideoTypeHeader> GetCodecHeader() const;
philipelc70e4ec2016-04-01 09:01:5486
87 private:
philipel50934662016-08-11 13:09:2688 rtc::scoped_refptr<PacketBuffer> packet_buffer_;
philipelca7ea5f2016-07-04 14:18:5589 enum FrameType frame_type_;
philipel871cc2c2016-05-13 13:01:0390 VideoCodecType codec_type_;
91 uint16_t first_seq_num_;
92 uint16_t last_seq_num_;
philipeld053dee2016-07-11 15:46:2993 uint32_t timestamp_;
94 int64_t received_time_;
philipel0aeed852016-05-24 08:20:4795
96 // Equal to times nacked of the packet with the highet times nacked
97 // belonging to this frame.
98 int times_nacked_;
philipelc70e4ec2016-04-01 09:01:5499};
100
101} // namespace video_coding
102} // namespace webrtc
103
104#endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_