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 22 namespace webrtc { 23 24 // Error codes 25 #define VCM_FRAME_NOT_READY 3 26 #define VCM_MISSING_CALLBACK 1 27 #define VCM_OK 0 28 #define VCM_GENERAL_ERROR -1 29 #define VCM_PARAMETER_ERROR -4 30 #define VCM_NO_CODEC_REGISTERED -8 31 #define VCM_JITTER_BUFFER_ERROR -9 32 33 enum { 34 // Timing frames settings. Timing frames are sent every 35 // |kDefaultTimingFramesDelayMs|, or if the frame is at least 36 // |kDefaultOutliserFrameSizePercent| in size of average frame. 37 kDefaultTimingFramesDelayMs = 200, 38 kDefaultOutlierFrameSizePercent = 500, 39 // Maximum number of frames for what we store encode start timing information. 40 kMaxEncodeStartTimeListSize = 150, 41 }; 42 43 enum VCMVideoProtection { 44 kProtectionNone, 45 kProtectionNack, 46 kProtectionFEC, 47 kProtectionNackFEC, 48 }; 49 50 // Callback class used for passing decoded frames which are ready to be 51 // rendered. 52 class VCMReceiveCallback { 53 public: 54 virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT 55 absl::optional<uint8_t> qp, 56 int32_t decode_time_ms, 57 VideoContentType content_type) = 0; 58 59 virtual void OnDroppedFrames(uint32_t frames_dropped); 60 61 // Called when the current receive codec changes. 62 virtual void OnIncomingPayloadType(int payload_type); 63 virtual void OnDecoderImplementationName(const char* implementation_name); 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