philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 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 | |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 14 | #include "webrtc/common_types.h" |
| 15 | #include "webrtc/modules/include/module_common_types.h" |
philipel | 552866c | 2016-07-04 16:18:55 +0200 | [diff] [blame] | 16 | #include "webrtc/modules/video_coding/encoded_frame.h" |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | namespace video_coding { |
| 20 | |
philipel | 552866c | 2016-07-04 16:18:55 +0200 | [diff] [blame] | 21 | class FrameObject : public webrtc::VCMEncodedFrame { |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 22 | public: |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 23 | static const uint8_t kMaxFrameReferences = 5; |
| 24 | |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 25 | FrameObject(); |
| 26 | |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 27 | virtual bool GetBitstream(uint8_t* destination) const = 0; |
| 28 | virtual ~FrameObject() {} |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 29 | |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 30 | // 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. |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 33 | uint16_t picture_id; |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 34 | uint8_t spatial_layer; |
philipel | be7a9e5 | 2016-05-19 12:19:35 +0200 | [diff] [blame] | 35 | uint32_t timestamp; |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 36 | |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 37 | size_t num_references; |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 38 | uint16_t references[kMaxFrameReferences]; |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 39 | bool inter_layer_predicted; |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame] | 40 | |
| 41 | size_t size; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | class PacketBuffer; |
| 45 | |
| 46 | class RtpFrameObject : public FrameObject { |
| 47 | public: |
| 48 | RtpFrameObject(PacketBuffer* packet_buffer, |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 49 | uint16_t first_seq_num, |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame] | 50 | uint16_t last_seq_num, |
| 51 | size_t frame_size, |
| 52 | int times_nacked); |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 53 | |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 54 | ~RtpFrameObject(); |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 55 | uint16_t first_seq_num() const; |
| 56 | uint16_t last_seq_num() const; |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame] | 57 | int times_nacked() const; |
philipel | 552866c | 2016-07-04 16:18:55 +0200 | [diff] [blame] | 58 | enum FrameType frame_type() const; |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 59 | VideoCodecType codec_type() const; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 60 | bool GetBitstream(uint8_t* destination) const override; |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 61 | RTPVideoTypeHeader* GetCodecHeader() const; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 62 | |
| 63 | private: |
| 64 | PacketBuffer* packet_buffer_; |
philipel | 552866c | 2016-07-04 16:18:55 +0200 | [diff] [blame] | 65 | enum FrameType frame_type_; |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 66 | VideoCodecType codec_type_; |
| 67 | uint16_t first_seq_num_; |
| 68 | uint16_t last_seq_num_; |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame] | 69 | |
| 70 | // Equal to times nacked of the packet with the highet times nacked |
| 71 | // belonging to this frame. |
| 72 | int times_nacked_; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } // namespace video_coding |
| 76 | } // namespace webrtc |
| 77 | |
| 78 | #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_ |