xref: /aosp_15_r20/external/webrtc/modules/video_coding/include/video_coding_defines.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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 MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
12  #define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
13  
14  #include <stddef.h>
15  #include <stdint.h>
16  
17  #include "absl/types/optional.h"
18  #include "api/video/video_content_type.h"
19  #include "api/video/video_frame.h"
20  #include "api/video/video_timing.h"
21  #include "api/video_codecs/video_decoder.h"
22  
23  namespace webrtc {
24  
25  // Error codes
26  #define VCM_FRAME_NOT_READY 3
27  #define VCM_MISSING_CALLBACK 1
28  #define VCM_OK 0
29  #define VCM_GENERAL_ERROR -1
30  #define VCM_PARAMETER_ERROR -4
31  #define VCM_NO_CODEC_REGISTERED -8
32  #define VCM_JITTER_BUFFER_ERROR -9
33  
34  enum {
35    // Timing frames settings. Timing frames are sent every
36    // `kDefaultTimingFramesDelayMs`, or if the frame is at least
37    // `kDefaultOutliserFrameSizePercent` in size of average frame.
38    kDefaultTimingFramesDelayMs = 200,
39    kDefaultOutlierFrameSizePercent = 500,
40    // Maximum number of frames for what we store encode start timing information.
41    kMaxEncodeStartTimeListSize = 150,
42  };
43  
44  enum VCMVideoProtection {
45    kProtectionNack,
46    kProtectionNackFEC,
47  };
48  
49  // Callback class used for passing decoded frames which are ready to be
50  // rendered.
51  class VCMReceiveCallback {
52   public:
53    virtual int32_t FrameToRender(VideoFrame& videoFrame,  // NOLINT
54                                  absl::optional<uint8_t> qp,
55                                  TimeDelta decode_time,
56                                  VideoContentType content_type) = 0;
57  
58    virtual void OnDroppedFrames(uint32_t frames_dropped);
59  
60    // Called when the current receive codec changes.
61    virtual void OnIncomingPayloadType(int payload_type);
62    virtual void OnDecoderInfoChanged(
63        const VideoDecoder::DecoderInfo& decoder_info);
64  
65   protected:
~VCMReceiveCallback()66    virtual ~VCMReceiveCallback() {}
67  };
68  
69  // Callback class used for informing the user of the incoming bit rate and frame
70  // rate.
71  class VCMReceiveStatisticsCallback {
72   public:
73    virtual void OnCompleteFrame(bool is_keyframe,
74                                 size_t size_bytes,
75                                 VideoContentType content_type) = 0;
76  
77    virtual void OnDroppedFrames(uint32_t frames_dropped) = 0;
78  
79    virtual void OnFrameBufferTimingsUpdated(int max_decode_ms,
80                                             int current_delay_ms,
81                                             int target_delay_ms,
82                                             int jitter_buffer_ms,
83                                             int min_playout_delay_ms,
84                                             int render_delay_ms) = 0;
85  
86    virtual void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) = 0;
87  
88   protected:
~VCMReceiveStatisticsCallback()89    virtual ~VCMReceiveStatisticsCallback() {}
90  };
91  
92  // Callback class used for telling the user about what frame type needed to
93  // continue decoding.
94  // Typically a key frame when the stream has been corrupted in some way.
95  class VCMFrameTypeCallback {
96   public:
97    virtual int32_t RequestKeyFrame() = 0;
98  
99   protected:
~VCMFrameTypeCallback()100    virtual ~VCMFrameTypeCallback() {}
101  };
102  
103  // Callback class used for telling the user about which packet sequence numbers
104  // are currently
105  // missing and need to be resent.
106  // TODO(philipel): Deprecate VCMPacketRequestCallback
107  //                 and use NackSender instead.
108  class VCMPacketRequestCallback {
109   public:
110    virtual int32_t ResendPackets(const uint16_t* sequenceNumbers,
111                                  uint16_t length) = 0;
112  
113   protected:
~VCMPacketRequestCallback()114    virtual ~VCMPacketRequestCallback() {}
115  };
116  
117  }  // namespace webrtc
118  
119  #endif  // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
120