Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 14:04:28 +01:00
parent 81b91f4139
commit f8c34fa5ee
22732 changed files with 4815320 additions and 2 deletions

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_
#define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_
#include <memory>
#include <string>
#include <vector>
#include "video/config/video_encoder_config.h"
namespace webrtc {
class VideoCodec;
class VideoCodecInitializer {
public:
// Takes a VideoEncoderConfig and the VideoStream configuration and
// translates them into the old school VideoCodec type.
static bool SetupCodec(const VideoEncoderConfig& config,
const std::vector<VideoStream>& streams,
VideoCodec* codec);
private:
static VideoCodec VideoEncoderConfigToVideoCodec(
const VideoEncoderConfig& config,
const std::vector<VideoStream>& streams);
};
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/video_coding/include/video_codec_interface.h"
namespace webrtc {
CodecSpecificInfo::CodecSpecificInfo() : codecType(kVideoCodecGeneric) {
memset(&codecSpecific, 0, sizeof(codecSpecific));
}
CodecSpecificInfo::CodecSpecificInfo(const CodecSpecificInfo&) = default;
CodecSpecificInfo::~CodecSpecificInfo() = default;
} // namespace webrtc

View file

@ -0,0 +1,136 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_
#define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_
#include <vector>
#include "absl/types/optional.h"
#include "api/video/video_frame.h"
#include "api/video_codecs/scalability_mode.h"
#include "api/video_codecs/video_decoder.h"
#include "api/video_codecs/video_encoder.h"
#include "common_video/generic_frame_descriptor/generic_frame_info.h"
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
#include "modules/video_coding/codecs/h265/include/h265_globals.h"
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
#include "modules/video_coding/include/video_error_codes.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
// Note: If any pointers are added to this struct, it must be fitted
// with a copy-constructor. See below.
// Hack alert - the code assumes that thisstruct is memset when constructed.
struct CodecSpecificInfoVP8 {
bool nonReference;
uint8_t temporalIdx;
bool layerSync;
int8_t keyIdx; // Negative value to skip keyIdx.
// Used to generate the list of dependency frames.
// `referencedBuffers` and `updatedBuffers` contain buffer IDs.
// Note that the buffer IDs here have a one-to-one mapping with the actual
// codec buffers, but the exact mapping (i.e. whether 0 refers to Last,
// to Golden or to Arf) is not pre-determined.
// More references may be specified than are strictly necessary, but not less.
// TODO(bugs.webrtc.org/10242): Remove `useExplicitDependencies` once all
// encoder-wrappers are updated.
bool useExplicitDependencies;
static constexpr size_t kBuffersCount = 3;
size_t referencedBuffers[kBuffersCount];
size_t referencedBuffersCount;
size_t updatedBuffers[kBuffersCount];
size_t updatedBuffersCount;
};
static_assert(std::is_trivial_v<CodecSpecificInfoVP8> &&
std::is_standard_layout_v<CodecSpecificInfoVP8>,
"");
// Hack alert - the code assumes that thisstruct is memset when constructed.
struct CodecSpecificInfoVP9 {
bool first_frame_in_picture; // First frame, increment picture_id.
bool inter_pic_predicted; // This layer frame is dependent on previously
// coded frame(s).
bool flexible_mode;
bool ss_data_available;
bool non_ref_for_inter_layer_pred;
uint8_t temporal_idx;
bool temporal_up_switch;
bool inter_layer_predicted; // Frame is dependent on directly lower spatial
// layer frame.
uint8_t gof_idx;
// SS data.
size_t num_spatial_layers; // Always populated.
size_t first_active_layer;
bool spatial_layer_resolution_present;
uint16_t width[kMaxVp9NumberOfSpatialLayers];
uint16_t height[kMaxVp9NumberOfSpatialLayers];
GofInfoVP9 gof;
// Frame reference data.
uint8_t num_ref_pics;
uint8_t p_diff[kMaxVp9RefPics];
};
static_assert(std::is_trivial_v<CodecSpecificInfoVP9> &&
std::is_standard_layout_v<CodecSpecificInfoVP9>,
"");
// Hack alert - the code assumes that thisstruct is memset when constructed.
struct CodecSpecificInfoH264 {
H264PacketizationMode packetization_mode;
uint8_t temporal_idx;
bool base_layer_sync;
bool idr_frame;
};
static_assert(std::is_trivial_v<CodecSpecificInfoH264> &&
std::is_standard_layout_v<CodecSpecificInfoH264>,
"");
struct CodecSpecificInfoH265 {
H265PacketizationMode packetization_mode;
bool idr_frame;
};
static_assert(std::is_trivial_v<CodecSpecificInfoH265> &&
std::is_standard_layout_v<CodecSpecificInfoH265>,
"");
union CodecSpecificInfoUnion {
CodecSpecificInfoVP8 VP8;
CodecSpecificInfoVP9 VP9;
CodecSpecificInfoH264 H264;
CodecSpecificInfoH265 H265;
};
static_assert(std::is_trivial_v<CodecSpecificInfoUnion> &&
std::is_standard_layout_v<CodecSpecificInfoUnion>,
"");
// Note: if any pointers are added to this struct or its sub-structs, it
// must be fitted with a copy-constructor. This is because it is copied
// in the copy-constructor of VCMEncodedFrame.
struct RTC_EXPORT CodecSpecificInfo {
CodecSpecificInfo();
CodecSpecificInfo(const CodecSpecificInfo&);
~CodecSpecificInfo();
VideoCodecType codecType;
CodecSpecificInfoUnion codecSpecific;
bool end_of_picture = true;
absl::optional<GenericFrameInfo> generic_frame_info;
absl::optional<FrameDependencyStructure> template_structure;
absl::optional<ScalabilityMode> scalability_mode;
};
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_

View file

@ -0,0 +1,150 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_
#define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_
#include "api/field_trials_view.h"
#include "api/video/video_frame.h"
#include "api/video_codecs/video_decoder.h"
#include "modules/rtp_rtcp/source/rtp_video_header.h"
#include "modules/video_coding/include/video_coding_defines.h"
namespace webrtc {
class Clock;
class EncodedImageCallback;
class VideoDecoder;
class VideoEncoder;
struct CodecSpecificInfo;
class VideoCodingModule {
public:
// DEPRECATED.
static VideoCodingModule* Create(
Clock* clock,
const FieldTrialsView* field_trials = nullptr);
virtual ~VideoCodingModule() = default;
/*
* Receiver
*/
// Register possible receive codecs, can be called multiple times for
// different codecs.
// The module will automatically switch between registered codecs depending on
// the
// payload type of incoming frames. The actual decoder will be created when
// needed.
//
// Input:
// - payload_type : RTP payload type
// - settings : Settings for the decoder to be registered.
//
virtual void RegisterReceiveCodec(uint8_t payload_type,
const VideoDecoder::Settings& settings) = 0;
// Register an external decoder object.
//
// Input:
// - externalDecoder : Decoder object to be used for decoding frames.
// - payloadType : The payload type which this decoder is bound to.
virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder,
uint8_t payloadType) = 0;
// Register a receive callback. Will be called whenever there is a new frame
// ready
// for rendering.
//
// Input:
// - receiveCallback : The callback object to be used by the
// module when a
// frame is ready for rendering.
// De-register with a NULL pointer.
//
// Return value : VCM_OK, on success.
// < 0, on error.
virtual int32_t RegisterReceiveCallback(
VCMReceiveCallback* receiveCallback) = 0;
// Register a frame type request callback. This callback will be called when
// the
// module needs to request specific frame types from the send side.
//
// Input:
// - frameTypeCallback : The callback object to be used by the
// module when
// requesting a specific type of frame from
// the send side.
// De-register with a NULL pointer.
//
// Return value : VCM_OK, on success.
// < 0, on error.
virtual int32_t RegisterFrameTypeCallback(
VCMFrameTypeCallback* frameTypeCallback) = 0;
// Registers a callback which is called whenever the receive side of the VCM
// encounters holes in the packet sequence and needs packets to be
// retransmitted.
//
// Input:
// - callback : The callback to be registered in the VCM.
//
// Return value : VCM_OK, on success.
// <0, on error.
virtual int32_t RegisterPacketRequestCallback(
VCMPacketRequestCallback* callback) = 0;
// Waits for the next frame in the jitter buffer to become complete
// (waits no longer than maxWaitTimeMs), then passes it to the decoder for
// decoding.
// Should be called as often as possible to get the most out of the decoder.
//
// Return value : VCM_OK, on success.
// < 0, on error.
virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0;
// Insert a parsed packet into the receiver side of the module. Will be placed
// in the
// jitter buffer waiting for the frame to become complete. Returns as soon as
// the packet
// has been placed in the jitter buffer.
//
// Input:
// - incomingPayload : Payload of the packet.
// - payloadLength : Length of the payload.
// - rtp_header : The parsed RTP header.
// - video_header : The relevant extensions and payload header.
//
// Return value : VCM_OK, on success.
// < 0, on error.
virtual int32_t IncomingPacket(const uint8_t* incomingPayload,
size_t payloadLength,
const RTPHeader& rtp_header,
const RTPVideoHeader& video_header) = 0;
// Sets the maximum number of sequence numbers that we are allowed to NACK
// and the oldest sequence number that we will consider to NACK. If a
// sequence number older than `max_packet_age_to_nack` is missing
// a key frame will be requested. A key frame will also be requested if the
// time of incomplete or non-continuous frames in the jitter buffer is above
// `max_incomplete_time_ms`.
virtual void SetNackSettings(size_t max_nack_list_size,
int max_packet_age_to_nack,
int max_incomplete_time_ms) = 0;
// Runs delayed tasks. Expected to be called periodically.
virtual void Process() = 0;
};
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_

View file

@ -0,0 +1,97 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
#define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
#include <stddef.h>
#include <stdint.h>
#include "absl/types/optional.h"
#include "api/video/video_content_type.h"
#include "api/video/video_frame.h"
#include "api/video/video_timing.h"
#include "api/video_codecs/video_decoder.h"
namespace webrtc {
// Error codes
#define VCM_FRAME_NOT_READY 3
#define VCM_MISSING_CALLBACK 1
#define VCM_OK 0
#define VCM_GENERAL_ERROR -1
#define VCM_PARAMETER_ERROR -4
#define VCM_NO_CODEC_REGISTERED -8
#define VCM_JITTER_BUFFER_ERROR -9
enum {
// Timing frames settings. Timing frames are sent every
// `kDefaultTimingFramesDelayMs`, or if the frame is at least
// `kDefaultOutlierFrameSizePercent` in size of average frame.
kDefaultTimingFramesDelayMs = 200,
kDefaultOutlierFrameSizePercent = 500,
// Maximum number of frames for what we store encode start timing information.
kMaxEncodeStartTimeListSize = 150,
};
enum VCMVideoProtection {
kProtectionNack,
kProtectionNackFEC,
};
// Callback class used for passing decoded frames which are ready to be
// rendered.
class VCMReceiveCallback {
public:
virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT
absl::optional<uint8_t> qp,
TimeDelta decode_time,
VideoContentType content_type,
VideoFrameType frame_type) = 0;
virtual void OnDroppedFrames(uint32_t frames_dropped);
// Called when the current receive codec changes.
virtual void OnIncomingPayloadType(int payload_type);
virtual void OnDecoderInfoChanged(
const VideoDecoder::DecoderInfo& decoder_info);
protected:
virtual ~VCMReceiveCallback() {}
};
// Callback class used for telling the user about what frame type needed to
// continue decoding.
// Typically a key frame when the stream has been corrupted in some way.
class VCMFrameTypeCallback {
public:
virtual int32_t RequestKeyFrame() = 0;
protected:
virtual ~VCMFrameTypeCallback() {}
};
// Callback class used for telling the user about which packet sequence numbers
// are currently
// missing and need to be resent.
// TODO(philipel): Deprecate VCMPacketRequestCallback
// and use NackSender instead.
class VCMPacketRequestCallback {
public:
virtual int32_t ResendPackets(const uint16_t* sequenceNumbers,
uint16_t length) = 0;
protected:
virtual ~VCMPacketRequestCallback() {}
};
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_

View file

@ -0,0 +1,27 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_ERROR_CODES_H_
#define MODULES_VIDEO_CODING_INCLUDE_VIDEO_ERROR_CODES_H_
#define WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT 5
#define WEBRTC_VIDEO_CODEC_OK_REQUEST_KEYFRAME 4
#define WEBRTC_VIDEO_CODEC_NO_OUTPUT 1
#define WEBRTC_VIDEO_CODEC_OK 0
#define WEBRTC_VIDEO_CODEC_ERROR -1
#define WEBRTC_VIDEO_CODEC_MEMORY -3
#define WEBRTC_VIDEO_CODEC_ERR_PARAMETER -4
#define WEBRTC_VIDEO_CODEC_TIMEOUT -6
#define WEBRTC_VIDEO_CODEC_UNINITIALIZED -7
#define WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE -13
#define WEBRTC_VIDEO_CODEC_ERR_SIMULCAST_PARAMETERS_NOT_SUPPORTED -15
#define WEBRTC_VIDEO_CODEC_ENCODER_FAILURE -16
#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_ERROR_CODES_H_

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2024 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/video_coding/include/video_error_codes_utils.h"
#include "modules/video_coding/include/video_error_codes.h"
namespace webrtc {
const char* WebRtcVideoCodecErrorToString(int32_t error_code) {
switch (error_code) {
case WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT:
return "WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT";
case WEBRTC_VIDEO_CODEC_OK_REQUEST_KEYFRAME:
return "WEBRTC_VIDEO_CODEC_OK_REQUEST_KEYFRAME";
case WEBRTC_VIDEO_CODEC_NO_OUTPUT:
return "WEBRTC_VIDEO_CODEC_NO_OUTPUT";
case WEBRTC_VIDEO_CODEC_ERROR:
return "WEBRTC_VIDEO_CODEC_ERROR";
case WEBRTC_VIDEO_CODEC_MEMORY:
return "WEBRTC_VIDEO_CODEC_MEMORY";
case WEBRTC_VIDEO_CODEC_ERR_PARAMETER:
return "WEBRTC_VIDEO_CODEC_ERR_PARAMETER";
case WEBRTC_VIDEO_CODEC_TIMEOUT:
return "WEBRTC_VIDEO_CODEC_TIMEOUT";
case WEBRTC_VIDEO_CODEC_UNINITIALIZED:
return "WEBRTC_VIDEO_CODEC_UNINITIALIZED";
case WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE:
return "WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE";
case WEBRTC_VIDEO_CODEC_ERR_SIMULCAST_PARAMETERS_NOT_SUPPORTED:
return "WEBRTC_VIDEO_CODEC_ERR_SIMULCAST_PARAMETERS_NOT_SUPPORTED";
case WEBRTC_VIDEO_CODEC_ENCODER_FAILURE:
return "WEBRTC_VIDEO_CODEC_ENCODER_FAILURE";
default:
return "WEBRTC_VIDEO_CODEC_UNKNOWN";
}
}
} // namespace webrtc

View file

@ -0,0 +1,22 @@
/*
* Copyright (c) 2024 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_ERROR_CODES_UTILS_H_
#define MODULES_VIDEO_CODING_INCLUDE_VIDEO_ERROR_CODES_UTILS_H_
#include <stdint.h>
namespace webrtc {
const char* WebRtcVideoCodecErrorToString(int32_t error_code);
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_ERROR_CODES_UTILS_H_