Removing VCMCodecDataBase::Codec and VideoCodingModule::Codec.
This CL brings us one step closer to removing CodecDatabase and GenericEncoder, by removing the static VCM::Codec(). Codec specific methods are moved to video_encoder.cc (they already belonged to this class) and getting default generic codec settings has been moved to a test specific file. This CL also makes video_encoder.h pass style guide and lint checks, since these checks are triggered with the new video_encoder.cc file. BUG=webrtc:8064 Review-Url: https://codereview.webrtc.org/2993923002 Cr-Commit-Position: refs/heads/master@{#19303}
This commit is contained in:
@ -17,7 +17,6 @@ import sys
|
||||
CPPLINT_BLACKLIST = [
|
||||
'tools_webrtc',
|
||||
'webrtc/api/video_codecs/video_decoder.h',
|
||||
'webrtc/api/video_codecs/video_encoder.h',
|
||||
'webrtc/examples/objc',
|
||||
'webrtc/media',
|
||||
'webrtc/modules/audio_coding',
|
||||
|
@ -15,6 +15,7 @@ if (is_android) {
|
||||
rtc_source_set("video_codecs_api") {
|
||||
sources = [
|
||||
"video_decoder.h",
|
||||
"video_encoder.cc",
|
||||
"video_encoder.h",
|
||||
]
|
||||
|
||||
|
98
webrtc/api/video_codecs/video_encoder.cc
Normal file
98
webrtc/api/video_codecs/video_encoder.cc
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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 "webrtc/api/video_codecs/video_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// TODO(mflodman): Add default complexity for VP9 and VP9.
|
||||
VideoCodecVP8 VideoEncoder::GetDefaultVp8Settings() {
|
||||
VideoCodecVP8 vp8_settings;
|
||||
memset(&vp8_settings, 0, sizeof(vp8_settings));
|
||||
|
||||
vp8_settings.resilience = kResilientStream;
|
||||
vp8_settings.numberOfTemporalLayers = 1;
|
||||
vp8_settings.denoisingOn = true;
|
||||
vp8_settings.errorConcealmentOn = false;
|
||||
vp8_settings.automaticResizeOn = false;
|
||||
vp8_settings.frameDroppingOn = true;
|
||||
vp8_settings.keyFrameInterval = 3000;
|
||||
|
||||
return vp8_settings;
|
||||
}
|
||||
|
||||
VideoCodecVP9 VideoEncoder::GetDefaultVp9Settings() {
|
||||
VideoCodecVP9 vp9_settings;
|
||||
memset(&vp9_settings, 0, sizeof(vp9_settings));
|
||||
|
||||
vp9_settings.resilienceOn = true;
|
||||
vp9_settings.numberOfTemporalLayers = 1;
|
||||
vp9_settings.denoisingOn = true;
|
||||
vp9_settings.frameDroppingOn = true;
|
||||
vp9_settings.keyFrameInterval = 3000;
|
||||
vp9_settings.adaptiveQpMode = true;
|
||||
vp9_settings.automaticResizeOn = true;
|
||||
vp9_settings.numberOfSpatialLayers = 1;
|
||||
vp9_settings.flexibleMode = false;
|
||||
|
||||
return vp9_settings;
|
||||
}
|
||||
|
||||
VideoCodecH264 VideoEncoder::GetDefaultH264Settings() {
|
||||
VideoCodecH264 h264_settings;
|
||||
memset(&h264_settings, 0, sizeof(h264_settings));
|
||||
|
||||
h264_settings.frameDroppingOn = true;
|
||||
h264_settings.keyFrameInterval = 3000;
|
||||
h264_settings.spsData = nullptr;
|
||||
h264_settings.spsLen = 0;
|
||||
h264_settings.ppsData = nullptr;
|
||||
h264_settings.ppsLen = 0;
|
||||
h264_settings.profile = H264::kProfileConstrainedBaseline;
|
||||
|
||||
return h264_settings;
|
||||
}
|
||||
|
||||
VideoEncoder::ScalingSettings::ScalingSettings(bool on, int low, int high)
|
||||
: enabled(on),
|
||||
thresholds(rtc::Optional<QpThresholds>(QpThresholds(low, high))) {}
|
||||
|
||||
VideoEncoder::ScalingSettings::ScalingSettings(bool on) : enabled(on) {}
|
||||
|
||||
VideoEncoder::ScalingSettings::~ScalingSettings() {}
|
||||
|
||||
|
||||
int32_t VideoEncoder::SetRates(uint32_t bitrate, uint32_t framerate) {
|
||||
RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t VideoEncoder::SetRateAllocation(
|
||||
const BitrateAllocation& allocation,
|
||||
uint32_t framerate) {
|
||||
return SetRates(allocation.get_sum_kbps(), framerate);
|
||||
}
|
||||
|
||||
VideoEncoder::ScalingSettings VideoEncoder::GetScalingSettings() const {
|
||||
return ScalingSettings(false);
|
||||
}
|
||||
|
||||
int32_t VideoEncoder::SetPeriodicKeyFrames(bool enable) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool VideoEncoder::SupportsNativeHandle() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* VideoEncoder::ImplementationName() const {
|
||||
return "unknown";
|
||||
}
|
||||
} // namespace webrtc
|
@ -41,7 +41,7 @@ class EncodedImageCallback {
|
||||
ERROR_SEND_FAILED,
|
||||
};
|
||||
|
||||
Result(Error error) : error(error) {}
|
||||
explicit Result(Error error) : error(error) {}
|
||||
Result(Error error, uint32_t frame_id) : error(error), frame_id(frame_id) {}
|
||||
|
||||
Error error;
|
||||
@ -74,10 +74,11 @@ class VideoEncoder {
|
||||
int high;
|
||||
};
|
||||
struct ScalingSettings {
|
||||
ScalingSettings(bool on, int low, int high)
|
||||
: enabled(on),
|
||||
thresholds(rtc::Optional<QpThresholds>(QpThresholds(low, high))) {}
|
||||
explicit ScalingSettings(bool on) : enabled(on) {}
|
||||
ScalingSettings(bool on, int low, int high);
|
||||
explicit ScalingSettings(bool on);
|
||||
ScalingSettings(const ScalingSettings&);
|
||||
~ScalingSettings();
|
||||
|
||||
const bool enabled;
|
||||
const rtc::Optional<QpThresholds> thresholds;
|
||||
};
|
||||
@ -155,28 +156,20 @@ class VideoEncoder {
|
||||
// - framerate : The target frame rate
|
||||
//
|
||||
// Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
|
||||
virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) {
|
||||
RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated.";
|
||||
return -1;
|
||||
}
|
||||
virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate);
|
||||
|
||||
// Default fallback: Just use the sum of bitrates as the single target rate.
|
||||
// TODO(sprang): Remove this default implementation when we remove SetRates().
|
||||
virtual int32_t SetRateAllocation(const BitrateAllocation& allocation,
|
||||
uint32_t framerate) {
|
||||
return SetRates(allocation.get_sum_kbps(), framerate);
|
||||
}
|
||||
uint32_t framerate);
|
||||
|
||||
// Any encoder implementation wishing to use the WebRTC provided
|
||||
// quality scaler must implement this method.
|
||||
virtual ScalingSettings GetScalingSettings() const {
|
||||
return ScalingSettings(false);
|
||||
}
|
||||
virtual ScalingSettings GetScalingSettings() const;
|
||||
|
||||
virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; }
|
||||
virtual bool SupportsNativeHandle() const { return false; }
|
||||
virtual const char* ImplementationName() const { return "unknown"; }
|
||||
virtual int32_t SetPeriodicKeyFrames(bool enable);
|
||||
virtual bool SupportsNativeHandle() const;
|
||||
virtual const char* ImplementationName() const;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_API_VIDEO_CODECS_VIDEO_ENCODER_H_
|
||||
|
@ -30,16 +30,10 @@ class EncodedImage {
|
||||
// number of additional bytes (due to over-reading byte readers).
|
||||
static size_t GetBufferPaddingBytes(VideoCodecType codec_type);
|
||||
|
||||
EncodedImage() : EncodedImage(nullptr, 0, 0) {}
|
||||
EncodedImage();
|
||||
EncodedImage(uint8_t* buffer, size_t length, size_t size);
|
||||
|
||||
EncodedImage(uint8_t* buffer, size_t length, size_t size)
|
||||
: _buffer(buffer), _length(length), _size(size) {}
|
||||
|
||||
void SetEncodeTime(int64_t encode_start_ms, int64_t encode_finish_ms) const {
|
||||
timing_.is_timing_frame = true;
|
||||
timing_.encode_start_ms = encode_start_ms;
|
||||
timing_.encode_finish_ms = encode_finish_ms;
|
||||
}
|
||||
void SetEncodeTime(int64_t encode_start_ms, int64_t encode_finish_ms) const;
|
||||
|
||||
// TODO(kthelgason): get rid of this struct as it only has a single member
|
||||
// remaining.
|
||||
|
@ -42,4 +42,15 @@ size_t EncodedImage::GetBufferPaddingBytes(VideoCodecType codec_type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
EncodedImage::EncodedImage() : EncodedImage(nullptr, 0, 0) {}
|
||||
|
||||
EncodedImage::EncodedImage(uint8_t* buffer, size_t length, size_t size)
|
||||
: _buffer(buffer), _length(length), _size(size) {}
|
||||
|
||||
void EncodedImage::SetEncodeTime(int64_t encode_start_ms,
|
||||
int64_t encode_finish_ms) const {
|
||||
timing_.is_timing_frame = true;
|
||||
timing_.encode_start_ms = encode_start_ms;
|
||||
timing_.encode_finish_ms = encode_finish_ms;
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
@ -407,6 +407,7 @@ if (rtc_include_tests) {
|
||||
"../../media:rtc_media",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../test:test_support",
|
||||
"../../test:video_test_common",
|
||||
"../../test:video_test_support",
|
||||
]
|
||||
|
||||
|
@ -20,57 +20,10 @@
|
||||
|
||||
namespace {
|
||||
const size_t kDefaultPayloadSize = 1440;
|
||||
const uint8_t kDefaultPayloadType = 100;
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VideoCodecVP8 VideoEncoder::GetDefaultVp8Settings() {
|
||||
VideoCodecVP8 vp8_settings;
|
||||
memset(&vp8_settings, 0, sizeof(vp8_settings));
|
||||
|
||||
vp8_settings.resilience = kResilientStream;
|
||||
vp8_settings.numberOfTemporalLayers = 1;
|
||||
vp8_settings.denoisingOn = true;
|
||||
vp8_settings.errorConcealmentOn = false;
|
||||
vp8_settings.automaticResizeOn = false;
|
||||
vp8_settings.frameDroppingOn = true;
|
||||
vp8_settings.keyFrameInterval = 3000;
|
||||
|
||||
return vp8_settings;
|
||||
}
|
||||
|
||||
VideoCodecVP9 VideoEncoder::GetDefaultVp9Settings() {
|
||||
VideoCodecVP9 vp9_settings;
|
||||
memset(&vp9_settings, 0, sizeof(vp9_settings));
|
||||
|
||||
vp9_settings.resilienceOn = true;
|
||||
vp9_settings.numberOfTemporalLayers = 1;
|
||||
vp9_settings.denoisingOn = true;
|
||||
vp9_settings.frameDroppingOn = true;
|
||||
vp9_settings.keyFrameInterval = 3000;
|
||||
vp9_settings.adaptiveQpMode = true;
|
||||
vp9_settings.automaticResizeOn = true;
|
||||
vp9_settings.numberOfSpatialLayers = 1;
|
||||
vp9_settings.flexibleMode = false;
|
||||
return vp9_settings;
|
||||
}
|
||||
|
||||
VideoCodecH264 VideoEncoder::GetDefaultH264Settings() {
|
||||
VideoCodecH264 h264_settings;
|
||||
memset(&h264_settings, 0, sizeof(h264_settings));
|
||||
|
||||
h264_settings.frameDroppingOn = true;
|
||||
h264_settings.keyFrameInterval = 3000;
|
||||
h264_settings.spsData = nullptr;
|
||||
h264_settings.spsLen = 0;
|
||||
h264_settings.ppsData = nullptr;
|
||||
h264_settings.ppsLen = 0;
|
||||
h264_settings.profile = H264::kProfileConstrainedBaseline;
|
||||
|
||||
return h264_settings;
|
||||
}
|
||||
|
||||
// Create an internal Decoder given a codec type
|
||||
static std::unique_ptr<VCMGenericDecoder> CreateDecoder(VideoCodecType type) {
|
||||
switch (type) {
|
||||
@ -135,89 +88,6 @@ VCMCodecDataBase::~VCMCodecDataBase() {
|
||||
delete kv.second;
|
||||
}
|
||||
|
||||
void VCMCodecDataBase::Codec(VideoCodecType codec_type, VideoCodec* settings) {
|
||||
memset(settings, 0, sizeof(VideoCodec));
|
||||
switch (codec_type) {
|
||||
case kVideoCodecVP8:
|
||||
strncpy(settings->plName, "VP8", 4);
|
||||
settings->codecType = kVideoCodecVP8;
|
||||
// 96 to 127 dynamic payload types for video codecs.
|
||||
settings->plType = kDefaultPayloadType;
|
||||
settings->startBitrate = kDefaultStartBitrateKbps;
|
||||
settings->minBitrate = VCM_MIN_BITRATE;
|
||||
settings->maxBitrate = 0;
|
||||
settings->maxFramerate = VCM_DEFAULT_FRAME_RATE;
|
||||
settings->width = VCM_DEFAULT_CODEC_WIDTH;
|
||||
settings->height = VCM_DEFAULT_CODEC_HEIGHT;
|
||||
settings->numberOfSimulcastStreams = 0;
|
||||
settings->qpMax = 56;
|
||||
settings->timing_frame_thresholds = {
|
||||
kDefaultTimingFramesDelayMs, kDefaultOutlierFrameSizePercent,
|
||||
};
|
||||
*(settings->VP8()) = VideoEncoder::GetDefaultVp8Settings();
|
||||
return;
|
||||
case kVideoCodecVP9:
|
||||
strncpy(settings->plName, "VP9", 4);
|
||||
settings->codecType = kVideoCodecVP9;
|
||||
// 96 to 127 dynamic payload types for video codecs.
|
||||
settings->plType = kDefaultPayloadType;
|
||||
settings->startBitrate = 100;
|
||||
settings->minBitrate = VCM_MIN_BITRATE;
|
||||
settings->maxBitrate = 0;
|
||||
settings->maxFramerate = VCM_DEFAULT_FRAME_RATE;
|
||||
settings->width = VCM_DEFAULT_CODEC_WIDTH;
|
||||
settings->height = VCM_DEFAULT_CODEC_HEIGHT;
|
||||
settings->numberOfSimulcastStreams = 0;
|
||||
settings->qpMax = 56;
|
||||
settings->timing_frame_thresholds = {
|
||||
kDefaultTimingFramesDelayMs, kDefaultOutlierFrameSizePercent,
|
||||
};
|
||||
*(settings->VP9()) = VideoEncoder::GetDefaultVp9Settings();
|
||||
return;
|
||||
case kVideoCodecH264:
|
||||
strncpy(settings->plName, "H264", 5);
|
||||
settings->codecType = kVideoCodecH264;
|
||||
// 96 to 127 dynamic payload types for video codecs.
|
||||
settings->plType = kDefaultPayloadType;
|
||||
settings->startBitrate = kDefaultStartBitrateKbps;
|
||||
settings->minBitrate = VCM_MIN_BITRATE;
|
||||
settings->maxBitrate = 0;
|
||||
settings->maxFramerate = VCM_DEFAULT_FRAME_RATE;
|
||||
settings->width = VCM_DEFAULT_CODEC_WIDTH;
|
||||
settings->height = VCM_DEFAULT_CODEC_HEIGHT;
|
||||
settings->numberOfSimulcastStreams = 0;
|
||||
settings->qpMax = 56;
|
||||
settings->timing_frame_thresholds = {
|
||||
kDefaultTimingFramesDelayMs, kDefaultOutlierFrameSizePercent,
|
||||
};
|
||||
*(settings->H264()) = VideoEncoder::GetDefaultH264Settings();
|
||||
return;
|
||||
case kVideoCodecI420:
|
||||
strncpy(settings->plName, "I420", 5);
|
||||
settings->codecType = kVideoCodecI420;
|
||||
// 96 to 127 dynamic payload types for video codecs.
|
||||
settings->plType = kDefaultPayloadType;
|
||||
// Bitrate needed for this size and framerate.
|
||||
settings->startBitrate = 3 * VCM_DEFAULT_CODEC_WIDTH *
|
||||
VCM_DEFAULT_CODEC_HEIGHT * 8 *
|
||||
VCM_DEFAULT_FRAME_RATE / 1000 / 2;
|
||||
settings->maxBitrate = settings->startBitrate;
|
||||
settings->maxFramerate = VCM_DEFAULT_FRAME_RATE;
|
||||
settings->width = VCM_DEFAULT_CODEC_WIDTH;
|
||||
settings->height = VCM_DEFAULT_CODEC_HEIGHT;
|
||||
settings->minBitrate = VCM_MIN_BITRATE;
|
||||
settings->numberOfSimulcastStreams = 0;
|
||||
return;
|
||||
case kVideoCodecRED:
|
||||
case kVideoCodecULPFEC:
|
||||
case kVideoCodecFlexfec:
|
||||
case kVideoCodecGeneric:
|
||||
case kVideoCodecUnknown:
|
||||
RTC_NOTREACHED();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Assuming only one registered encoder - since only one used, no need for more.
|
||||
bool VCMCodecDataBase::SetSendCodec(const VideoCodec* send_codec,
|
||||
int number_of_cores,
|
||||
|
@ -47,10 +47,6 @@ class VCMCodecDataBase {
|
||||
explicit VCMCodecDataBase(VCMEncodedFrameCallback* encoded_frame_callback);
|
||||
~VCMCodecDataBase();
|
||||
|
||||
// Sender Side
|
||||
// Returns the default settings for the codec with type |codec_type|.
|
||||
static void Codec(VideoCodecType codec_type, VideoCodec* settings);
|
||||
|
||||
// Sets the sender side codec and initiates the desired codec given the
|
||||
// VideoCodec struct.
|
||||
// Returns true if the codec was successfully registered, false otherwise.
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "webrtc/test/testsupport/frame_writer.h"
|
||||
#include "webrtc/test/testsupport/metrics/video_metrics.h"
|
||||
#include "webrtc/test/testsupport/packet_reader.h"
|
||||
#include "webrtc/test/video_codec_settings.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -634,7 +635,7 @@ class VideoProcessorIntegrationTest : public testing::Test {
|
||||
bool resilience_on,
|
||||
int width,
|
||||
int height) {
|
||||
VideoCodingModule::Codec(codec_type, &config->codec_settings);
|
||||
webrtc::test::CodecSettings(codec_type, &config->codec_settings);
|
||||
config->codec_settings.width = width;
|
||||
config->codec_settings.height = height;
|
||||
switch (config->codec_settings.codecType) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "webrtc/test/testsupport/mock/mock_frame_writer.h"
|
||||
#include "webrtc/test/testsupport/packet_reader.h"
|
||||
#include "webrtc/test/testsupport/unittest_utils.h"
|
||||
#include "webrtc/test/video_codec_settings.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
using ::testing::_;
|
||||
@ -45,7 +46,7 @@ class VideoProcessorTest : public testing::Test {
|
||||
protected:
|
||||
VideoProcessorTest() {
|
||||
// Get a codec configuration struct and configure it.
|
||||
VideoCodingModule::Codec(kVideoCodecVP8, &config_.codec_settings);
|
||||
webrtc::test::CodecSettings(kVideoCodecVP8, &config_.codec_settings);
|
||||
config_.codec_settings.width = kWidth;
|
||||
config_.codec_settings.height = kHeight;
|
||||
config_.codec_settings.maxFramerate = kFramerate;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "webrtc/test/testsupport/frame_writer.h"
|
||||
#include "webrtc/test/testsupport/metrics/video_metrics.h"
|
||||
#include "webrtc/test/testsupport/packet_reader.h"
|
||||
#include "webrtc/test/video_codec_settings.h"
|
||||
|
||||
DEFINE_string(test_name, "Quality test", "The name of the test to run. ");
|
||||
DEFINE_string(test_description,
|
||||
@ -204,8 +205,7 @@ int HandleCommandLineFlags(webrtc::test::TestConfig* config) {
|
||||
config->use_single_core = FLAGS_use_single_core;
|
||||
|
||||
// Get codec specific configuration.
|
||||
webrtc::VideoCodingModule::Codec(webrtc::kVideoCodecVP8,
|
||||
&config->codec_settings);
|
||||
webrtc::test::CodecSettings(webrtc::kVideoCodecVP8, &config->codec_settings);
|
||||
|
||||
// Check the temporal layers.
|
||||
if (FLAGS_temporal_layers < 0 ||
|
||||
|
@ -32,7 +32,7 @@ class FakeEncodedImageCallback : public EncodedImageCallback {
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
const RTPFragmentationHeader* fragmentation) override {
|
||||
last_frame_was_timing_ = encoded_image.timing_.is_timing_frame;
|
||||
return Result::OK;
|
||||
return Result(Result::OK);
|
||||
};
|
||||
|
||||
bool WasTimingFrame() { return last_frame_was_timing_; }
|
||||
|
@ -74,16 +74,6 @@ class VideoCodingModule : public Module {
|
||||
// DEPRECATED.
|
||||
static VideoCodingModule* Create(Clock* clock, EventFactory* event_factory);
|
||||
|
||||
// Get supported codec settings using codec type
|
||||
//
|
||||
// Input:
|
||||
// - codecType : The codec type to get settings for
|
||||
// - codec : Memory where the codec settings will be stored
|
||||
//
|
||||
// Return value : VCM_OK, on success
|
||||
// VCM_PARAMETER_ERROR if codec not supported
|
||||
static void Codec(VideoCodecType codecType, VideoCodec* codec);
|
||||
|
||||
/*
|
||||
* Sender
|
||||
*/
|
||||
|
@ -40,7 +40,6 @@ namespace webrtc {
|
||||
#define VCM_NOT_IMPLEMENTED -20
|
||||
|
||||
enum {
|
||||
kDefaultStartBitrateKbps = 300,
|
||||
// Timing frames settings. Timing frames are sent every
|
||||
// |kDefaultTimingFramesDelayMs|, or if the frame is at least
|
||||
// |kDefaultOutliserFrameSizePercent| in size of average frame.
|
||||
|
@ -270,10 +270,6 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void VideoCodingModule::Codec(VideoCodecType codecType, VideoCodec* codec) {
|
||||
VCMCodecDataBase::Codec(codecType, codec);
|
||||
}
|
||||
|
||||
// DEPRECATED. Create method for current interface, will be removed when the
|
||||
// new jitter buffer is in place.
|
||||
VideoCodingModule* VideoCodingModule::Create(Clock* clock,
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "webrtc/modules/video_coding/video_coding_impl.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/test/video_codec_settings.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::AnyNumber;
|
||||
@ -43,7 +44,7 @@ class TestVideoReceiver : public ::testing::Test {
|
||||
const int kMaxPacketAgeToNack = 450;
|
||||
receiver_->SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, 0);
|
||||
|
||||
VideoCodingModule::Codec(kVideoCodecVP8, &settings_);
|
||||
webrtc::test::CodecSettings(kVideoCodecVP8, &settings_);
|
||||
settings_.plType = kUnusedPayloadType; // Use the mocked encoder.
|
||||
EXPECT_EQ(0, receiver_->RegisterReceiveCodec(&settings_, 1, true));
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "webrtc/test/frame_generator.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/test/video_codec_settings.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::AllOf;
|
||||
@ -206,7 +207,7 @@ class TestVideoSenderWithMockEncoder : public TestVideoSender {
|
||||
void SetUp() override {
|
||||
TestVideoSender::SetUp();
|
||||
sender_->RegisterExternalEncoder(&encoder_, kUnusedPayloadType, false);
|
||||
VideoCodingModule::Codec(kVideoCodecVP8, &settings_);
|
||||
webrtc::test::CodecSettings(kVideoCodecVP8, &settings_);
|
||||
settings_.numberOfSimulcastStreams = kNumberOfStreams;
|
||||
ConfigureStream(kDefaultWidth / 4, kDefaultHeight / 4, 100,
|
||||
&settings_.simulcastStream[0]);
|
||||
@ -426,7 +427,7 @@ class TestVideoSenderWithVp8 : public TestVideoSender {
|
||||
int height,
|
||||
int temporal_layers) {
|
||||
VideoCodec codec;
|
||||
VideoCodingModule::Codec(kVideoCodecVP8, &codec);
|
||||
webrtc::test::CodecSettings(kVideoCodecVP8, &codec);
|
||||
codec.width = width;
|
||||
codec.height = height;
|
||||
codec.VP8()->numberOfTemporalLayers = temporal_layers;
|
||||
|
@ -50,6 +50,7 @@ rtc_source_set("video_test_common") {
|
||||
"vcm_capturer.h",
|
||||
"video_capturer.cc",
|
||||
"video_capturer.h",
|
||||
"video_codec_settings.h",
|
||||
]
|
||||
|
||||
if (!build_with_chromium && is_clang) {
|
||||
@ -60,6 +61,7 @@ rtc_source_set("video_test_common") {
|
||||
deps = [
|
||||
"..:video_stream_api",
|
||||
"..:webrtc_common",
|
||||
"../api/video_codecs:video_codecs_api",
|
||||
"../common_video",
|
||||
"../media:rtc_media_base",
|
||||
"../modules/video_capture:video_capture_module",
|
||||
|
111
webrtc/test/video_codec_settings.h
Normal file
111
webrtc/test/video_codec_settings.h
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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 WEBRTC_TEST_VIDEO_CODEC_SETTINGS_H_
|
||||
#define WEBRTC_TEST_VIDEO_CODEC_SETTINGS_H_
|
||||
|
||||
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
const uint16_t kTestWidth = 352;
|
||||
const uint16_t kTestHeight = 288;
|
||||
const uint32_t kTestFrameRate = 30;
|
||||
const unsigned int kTestMinBitrateKbps = 30;
|
||||
const unsigned int kTestStartBitrateKbps = 300;
|
||||
const uint8_t kTestPayloadType = 100;
|
||||
const int64_t kTestTimingFramesDelayMs = 200;
|
||||
const uint16_t kTestOutlierFrameSizePercent = 250;
|
||||
|
||||
static void CodecSettings(VideoCodecType codec_type, VideoCodec* settings) {
|
||||
memset(settings, 0, sizeof(VideoCodec));
|
||||
switch (codec_type) {
|
||||
case kVideoCodecVP8:
|
||||
strncpy(settings->plName, "VP8", 4);
|
||||
settings->codecType = kVideoCodecVP8;
|
||||
// 96 to 127 dynamic payload types for video codecs.
|
||||
settings->plType = kTestPayloadType;
|
||||
settings->startBitrate = kTestStartBitrateKbps;
|
||||
settings->minBitrate = kTestMinBitrateKbps;
|
||||
settings->maxBitrate = 0;
|
||||
settings->maxFramerate = kTestFrameRate;
|
||||
settings->width = kTestWidth;
|
||||
settings->height = kTestHeight;
|
||||
settings->numberOfSimulcastStreams = 0;
|
||||
settings->qpMax = 56;
|
||||
settings->timing_frame_thresholds = {
|
||||
kTestTimingFramesDelayMs, kTestOutlierFrameSizePercent,
|
||||
};
|
||||
*(settings->VP8()) = VideoEncoder::GetDefaultVp8Settings();
|
||||
return;
|
||||
case kVideoCodecVP9:
|
||||
strncpy(settings->plName, "VP9", 4);
|
||||
settings->codecType = kVideoCodecVP9;
|
||||
// 96 to 127 dynamic payload types for video codecs.
|
||||
settings->plType = kTestPayloadType;
|
||||
settings->startBitrate = 100;
|
||||
settings->minBitrate = kTestMinBitrateKbps;
|
||||
settings->maxBitrate = 0;
|
||||
settings->maxFramerate = kTestFrameRate;
|
||||
settings->width = kTestWidth;
|
||||
settings->height = kTestHeight;
|
||||
settings->numberOfSimulcastStreams = 0;
|
||||
settings->qpMax = 56;
|
||||
settings->timing_frame_thresholds = {
|
||||
kTestTimingFramesDelayMs, kTestOutlierFrameSizePercent,
|
||||
};
|
||||
*(settings->VP9()) = VideoEncoder::GetDefaultVp9Settings();
|
||||
return;
|
||||
case kVideoCodecH264:
|
||||
strncpy(settings->plName, "H264", 5);
|
||||
settings->codecType = kVideoCodecH264;
|
||||
// 96 to 127 dynamic payload types for video codecs.
|
||||
settings->plType = kTestPayloadType;
|
||||
settings->startBitrate = kTestStartBitrateKbps;
|
||||
settings->minBitrate = kTestMinBitrateKbps;
|
||||
settings->maxBitrate = 0;
|
||||
settings->maxFramerate = kTestFrameRate;
|
||||
settings->width = kTestWidth;
|
||||
settings->height = kTestHeight;
|
||||
settings->numberOfSimulcastStreams = 0;
|
||||
settings->qpMax = 56;
|
||||
settings->timing_frame_thresholds = {
|
||||
kTestTimingFramesDelayMs, kTestOutlierFrameSizePercent,
|
||||
};
|
||||
*(settings->H264()) = VideoEncoder::GetDefaultH264Settings();
|
||||
return;
|
||||
case kVideoCodecI420:
|
||||
strncpy(settings->plName, "I420", 5);
|
||||
settings->codecType = kVideoCodecI420;
|
||||
// 96 to 127 dynamic payload types for video codecs.
|
||||
settings->plType = kTestPayloadType;
|
||||
// Bitrate needed for this size and framerate.
|
||||
settings->startBitrate =
|
||||
3 * kTestWidth * kTestHeight * 8 * kTestFrameRate / 1000 / 2;
|
||||
settings->maxBitrate = settings->startBitrate;
|
||||
settings->maxFramerate = kTestFrameRate;
|
||||
settings->width = kTestWidth;
|
||||
settings->height = kTestHeight;
|
||||
settings->minBitrate = kTestMinBitrateKbps;
|
||||
settings->numberOfSimulcastStreams = 0;
|
||||
return;
|
||||
case kVideoCodecRED:
|
||||
case kVideoCodecULPFEC:
|
||||
case kVideoCodecFlexfec:
|
||||
case kVideoCodecGeneric:
|
||||
case kVideoCodecUnknown:
|
||||
RTC_NOTREACHED();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_TEST_VIDEO_CODEC_SETTINGS_H_
|
Reference in New Issue
Block a user