1 /*
2  *  Copyright (c) 2012 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_INCLUDE_VIDEO_CODEC_INTERFACE_H_
12 #define WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_
13 
14 #include <vector>
15 
16 #include "webrtc/api/video/video_frame.h"
17 #include "webrtc/common_types.h"
18 #include "webrtc/modules/include/module_common_types.h"
19 #include "webrtc/modules/video_coding/include/video_error_codes.h"
20 #include "webrtc/typedefs.h"
21 #include "webrtc/video_decoder.h"
22 #include "webrtc/video_encoder.h"
23 
24 namespace webrtc {
25 
26 class RTPFragmentationHeader;  // forward declaration
27 
28 // Note: if any pointers are added to this struct, it must be fitted
29 // with a copy-constructor. See below.
30 struct CodecSpecificInfoVP8 {
31   bool hasReceivedSLI;
32   uint8_t pictureIdSLI;
33   bool hasReceivedRPSI;
34   uint64_t pictureIdRPSI;
35   int16_t pictureId;  // Negative value to skip pictureId.
36   bool nonReference;
37   uint8_t simulcastIdx;
38   uint8_t temporalIdx;
39   bool layerSync;
40   int tl0PicIdx;  // Negative value to skip tl0PicIdx.
41   int8_t keyIdx;  // Negative value to skip keyIdx.
42 };
43 
44 struct CodecSpecificInfoVP9 {
45   bool has_received_sli;
46   uint8_t picture_id_sli;
47   bool has_received_rpsi;
48   uint64_t picture_id_rpsi;
49   int16_t picture_id;  // Negative value to skip pictureId.
50 
51   bool inter_pic_predicted;  // This layer frame is dependent on previously
52                              // coded frame(s).
53   bool flexible_mode;
54   bool ss_data_available;
55 
56   int tl0_pic_idx;  // Negative value to skip tl0PicIdx.
57   uint8_t temporal_idx;
58   uint8_t spatial_idx;
59   bool temporal_up_switch;
60   bool inter_layer_predicted;  // Frame is dependent on directly lower spatial
61                                // layer frame.
62   uint8_t gof_idx;
63 
64   // SS data.
65   size_t num_spatial_layers;  // Always populated.
66   bool spatial_layer_resolution_present;
67   uint16_t width[kMaxVp9NumberOfSpatialLayers];
68   uint16_t height[kMaxVp9NumberOfSpatialLayers];
69   GofInfoVP9 gof;
70 
71   // Frame reference data.
72   uint8_t num_ref_pics;
73   uint8_t p_diff[kMaxVp9RefPics];
74 };
75 
76 struct CodecSpecificInfoGeneric {
77   uint8_t simulcast_idx;
78 };
79 
80 struct CodecSpecificInfoH264 {
81   H264PacketizationMode packetization_mode;
82 };
83 
84 union CodecSpecificInfoUnion {
85   CodecSpecificInfoGeneric generic;
86   CodecSpecificInfoVP8 VP8;
87   CodecSpecificInfoVP9 VP9;
88   CodecSpecificInfoH264 H264;
89 };
90 
91 // Note: if any pointers are added to this struct or its sub-structs, it
92 // must be fitted with a copy-constructor. This is because it is copied
93 // in the copy-constructor of VCMEncodedFrame.
94 struct CodecSpecificInfo {
CodecSpecificInfoCodecSpecificInfo95   CodecSpecificInfo() : codecType(kVideoCodecUnknown), codec_name(nullptr) {}
96   VideoCodecType codecType;
97   const char* codec_name;
98   CodecSpecificInfoUnion codecSpecific;
99 };
100 
101 }  // namespace webrtc
102 
103 #endif  // WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_
104