Remove VIDEOCODEC_* from engine_configurations.h.

Removes index-based codec fetching from the VCM and overall cleans up
the code.

BUG=webrtc:1695
R=mflodman@webrtc.org

Review URL: https://codereview.webrtc.org/1425613004 .

Cr-Commit-Position: refs/heads/master@{#10770}
This commit is contained in:
Peter Boström
2015-11-24 13:55:55 +01:00
parent 4f2152e328
commit 92f8dbde77
8 changed files with 19 additions and 158 deletions

View File

@ -15,18 +15,10 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/engine_configurations.h"
#ifdef VIDEOCODEC_H264
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
#endif
#ifdef VIDEOCODEC_I420
#include "webrtc/modules/video_coding/codecs/i420/include/i420.h"
#endif
#ifdef VIDEOCODEC_VP8
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
#endif
#ifdef VIDEOCODEC_VP9
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
#endif
#include "webrtc/modules/video_coding/internal_defines.h"
namespace {
@ -123,22 +115,10 @@ VCMCodecDataBase::~VCMCodecDataBase() {
ResetReceiver();
}
int VCMCodecDataBase::NumberOfCodecs() {
return VCM_NUM_VIDEO_CODECS_AVAILABLE;
}
bool VCMCodecDataBase::Codec(int list_id,
VideoCodec* settings) {
if (!settings) {
return false;
}
if (list_id >= VCM_NUM_VIDEO_CODECS_AVAILABLE) {
return false;
}
void VCMCodecDataBase::Codec(VideoCodecType codec_type, VideoCodec* settings) {
memset(settings, 0, sizeof(VideoCodec));
switch (list_id) {
#ifdef VIDEOCODEC_VP8
case VCM_VP8_IDX: {
switch (codec_type) {
case kVideoCodecVP8:
strncpy(settings->plName, "VP8", 4);
settings->codecType = kVideoCodecVP8;
// 96 to 127 dynamic payload types for video codecs.
@ -152,11 +132,8 @@ bool VCMCodecDataBase::Codec(int list_id,
settings->numberOfSimulcastStreams = 0;
settings->qpMax = 56;
settings->codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings();
return true;
}
#endif
#ifdef VIDEOCODEC_VP9
case VCM_VP9_IDX: {
return;
case kVideoCodecVP9:
strncpy(settings->plName, "VP9", 4);
settings->codecType = kVideoCodecVP9;
// 96 to 127 dynamic payload types for video codecs.
@ -170,11 +147,8 @@ bool VCMCodecDataBase::Codec(int list_id,
settings->numberOfSimulcastStreams = 0;
settings->qpMax = 56;
settings->codecSpecific.VP9 = VideoEncoder::GetDefaultVp9Settings();
return true;
}
#endif
#ifdef VIDEOCODEC_H264
case VCM_H264_IDX: {
return;
case kVideoCodecH264:
strncpy(settings->plName, "H264", 5);
settings->codecType = kVideoCodecH264;
// 96 to 127 dynamic payload types for video codecs.
@ -188,11 +162,8 @@ bool VCMCodecDataBase::Codec(int list_id,
settings->numberOfSimulcastStreams = 0;
settings->qpMax = 56;
settings->codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings();
return true;
}
#endif
#ifdef VIDEOCODEC_I420
case VCM_I420_IDX: {
return;
case kVideoCodecI420:
strncpy(settings->plName, "I420", 5);
settings->codecType = kVideoCodecI420;
// 96 to 127 dynamic payload types for video codecs.
@ -207,29 +178,16 @@ bool VCMCodecDataBase::Codec(int list_id,
settings->height = VCM_DEFAULT_CODEC_HEIGHT;
settings->minBitrate = VCM_MIN_BITRATE;
settings->numberOfSimulcastStreams = 0;
return true;
}
#endif
default: {
return false;
}
return;
case kVideoCodecRED:
case kVideoCodecULPFEC:
case kVideoCodecGeneric:
case kVideoCodecUnknown:
RTC_NOTREACHED();
return;
}
}
bool VCMCodecDataBase::Codec(VideoCodecType codec_type,
VideoCodec* settings) {
for (int i = 0; i < VCMCodecDataBase::NumberOfCodecs(); i++) {
const bool ret = VCMCodecDataBase::Codec(i, settings);
if (!ret) {
return false;
}
if (codec_type == settings->codecType) {
return true;
}
}
return false;
}
void VCMCodecDataBase::ResetSender() {
DeleteEncoder();
periodic_key_frames_ = false;
@ -641,25 +599,17 @@ void VCMCodecDataBase::DeleteEncoder() {
VCMGenericDecoder* VCMCodecDataBase::CreateDecoder(VideoCodecType type) const {
switch (type) {
#ifdef VIDEOCODEC_VP8
case kVideoCodecVP8:
return new VCMGenericDecoder(*(VP8Decoder::Create()));
#endif
#ifdef VIDEOCODEC_VP9
case kVideoCodecVP9:
return new VCMGenericDecoder(*(VP9Decoder::Create()));
#endif
#ifdef VIDEOCODEC_I420
case kVideoCodecI420:
return new VCMGenericDecoder(*(new I420Decoder));
#endif
#ifdef VIDEOCODEC_H264
case kVideoCodecH264:
if (H264Decoder::IsSupported()) {
return new VCMGenericDecoder(*(H264Decoder::Create()));
}
break;
#endif
default:
break;
}

View File

@ -51,14 +51,8 @@ class VCMCodecDataBase {
~VCMCodecDataBase();
// Sender Side
// Returns the number of supported codecs (or -1 in case of error).
static int NumberOfCodecs();
// Returns the default settings for the codec with id |list_id|.
static bool Codec(int list_id, VideoCodec* settings);
// Returns the default settings for the codec with type |codec_type|.
static bool Codec(VideoCodecType codec_type, VideoCodec* settings);
static void Codec(VideoCodecType codec_type, VideoCodec* settings);
void ResetSender();

View File

@ -32,30 +32,6 @@ inline uint32_t MaskWord64ToUWord32(int64_t w64)
#define VCM_MIN_BITRATE 30
#define VCM_FLUSH_INDICATOR 4
// Helper macros for creating the static codec list
#define VCM_NO_CODEC_IDX -1
#ifdef VIDEOCODEC_VP8
#define VCM_VP8_IDX (VCM_NO_CODEC_IDX + 1)
#else
#define VCM_VP8_IDX VCM_NO_CODEC_IDX
#endif
#ifdef VIDEOCODEC_VP9
#define VCM_VP9_IDX (VCM_VP8_IDX + 1)
#else
#define VCM_VP9_IDX VCM_VP8_IDX
#endif
#ifdef VIDEOCODEC_H264
#define VCM_H264_IDX (VCM_VP9_IDX + 1)
#else
#define VCM_H264_IDX VCM_VP9_IDX
#endif
#ifdef VIDEOCODEC_I420
#define VCM_I420_IDX (VCM_H264_IDX + 1)
#else
#define VCM_I420_IDX VCM_H264_IDX
#endif
#define VCM_NUM_VIDEO_CODECS_AVAILABLE (VCM_I420_IDX + 1)
#define VCM_NO_RECEIVER_ID 0
inline int32_t VCMId(const int32_t vcmId, const int32_t receiverId = 0)

View File

@ -92,21 +92,6 @@ public:
static void Destroy(VideoCodingModule* module);
// Get number of supported codecs
//
// Return value : Number of supported codecs
static uint8_t NumberOfCodecs();
// Get supported codec settings with using id
//
// Input:
// - listId : Id or index of the codec to look up
// - codec : Memory where the codec settings will be stored
//
// Return value : VCM_OK, on success
// VCM_PARAMETER_ERROR if codec not supported or id too high
static int32_t Codec(const uint8_t listId, VideoCodec* codec);
// Get supported codec settings using codec type
//
// Input:

View File

@ -309,22 +309,9 @@ class VideoCodingModuleImpl : public VideoCodingModule {
};
} // namespace
uint8_t VideoCodingModule::NumberOfCodecs() {
return VCMCodecDataBase::NumberOfCodecs();
}
int32_t VideoCodingModule::Codec(uint8_t listId, VideoCodec* codec) {
if (codec == NULL) {
return VCM_PARAMETER_ERROR;
}
return VCMCodecDataBase::Codec(listId, codec) ? 0 : -1;
}
int32_t VideoCodingModule::Codec(VideoCodecType codecType, VideoCodec* codec) {
if (codec == NULL) {
return VCM_PARAMETER_ERROR;
}
return VCMCodecDataBase::Codec(codecType, codec) ? 0 : -1;
VCMCodecDataBase::Codec(codecType, codec);
return 0;
}
VideoCodingModule* VideoCodingModule::Create(