Line data Source code
1 : /*
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 :
14 : #include "webrtc/base/optional.h"
15 : #include "webrtc/common_types.h"
16 : #include "webrtc/modules/include/module_common_types.h"
17 : #include "webrtc/modules/video_coding/encoded_frame.h"
18 :
19 : namespace webrtc {
20 : namespace video_coding {
21 :
22 : class FrameObject : public webrtc::VCMEncodedFrame {
23 : public:
24 : static const uint8_t kMaxFrameReferences = 5;
25 :
26 : FrameObject();
27 0 : virtual ~FrameObject() {}
28 :
29 : virtual bool GetBitstream(uint8_t* destination) const = 0;
30 :
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 :
40 0 : size_t size() { return _length; }
41 :
42 : // The tuple (|picture_id|, |spatial_layer|) uniquely identifies a frame
43 : // object. For codec types that don't necessarily have picture ids they
44 : // have to be constructed from the header data relevant to that codec.
45 : uint16_t picture_id;
46 : uint8_t spatial_layer;
47 : uint32_t timestamp;
48 :
49 : size_t num_references;
50 : uint16_t references[kMaxFrameReferences];
51 : bool inter_layer_predicted;
52 : };
53 :
54 : class PacketBuffer;
55 :
56 : class RtpFrameObject : public FrameObject {
57 : public:
58 : RtpFrameObject(PacketBuffer* packet_buffer,
59 : uint16_t first_seq_num,
60 : uint16_t last_seq_num,
61 : size_t frame_size,
62 : int times_nacked,
63 : int64_t received_time);
64 :
65 : ~RtpFrameObject();
66 : uint16_t first_seq_num() const;
67 : uint16_t last_seq_num() const;
68 : int times_nacked() const;
69 : enum FrameType frame_type() const;
70 : VideoCodecType codec_type() const;
71 : bool GetBitstream(uint8_t* destination) const override;
72 : uint32_t Timestamp() const override;
73 : int64_t ReceivedTime() const override;
74 : int64_t RenderTime() const override;
75 : rtc::Optional<RTPVideoTypeHeader> GetCodecHeader() const;
76 :
77 : private:
78 : rtc::scoped_refptr<PacketBuffer> packet_buffer_;
79 : enum FrameType frame_type_;
80 : VideoCodecType codec_type_;
81 : uint16_t first_seq_num_;
82 : uint16_t last_seq_num_;
83 : uint32_t timestamp_;
84 : int64_t received_time_;
85 :
86 : // Equal to times nacked of the packet with the highet times nacked
87 : // belonging to this frame.
88 : int times_nacked_;
89 : };
90 :
91 : } // namespace video_coding
92 : } // namespace webrtc
93 :
94 : #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_
|