/* * Copyright (c) 2023 Fancy Code. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "FfmpegBase.h" #include "ILog.h" #include "MediaBase.h" #ifdef __cplusplus extern "C" { #endif #include #ifdef __cplusplus } #endif FfmpegBase::FfmpegBase() : mType(MEDIA_HANDLE_TYPE_END), mTaskRuning(false) { } FfmpegBase::FfmpegBase(const MediaHandleType &type) : mType(type), mTaskRuning(false) { } void FfmpegBase::InitFfmpeg(void) { } void FfmpegBase::UnInitFfmpeg(void) { } const char *FfmpegBase::InputFormat(const MediaHandleType &type) { switch (type) { case MEDIA_HANDLE_TYPE_READ_H264: LogInfo("InputFormat: h264.\n"); return "h264"; case MEDIA_HANDLE_TYPE_READ_G711A: LogInfo("InputFormat: alaw.\n"); return "alaw"; default: LogError("Unknown media type.\n"); return nullptr; } } AVMediaType FfmpegBase::MediaTypeConvert(const MediaHandleType &type) { switch (type) { case MediaHandleType::MEDIA_HANDLE_TYPE_READ_H264: return AVMEDIA_TYPE_VIDEO; case MediaHandleType::MEDIA_HANDLE_TYPE_READ_G711A: return AVMEDIA_TYPE_AUDIO; default: LogWarning("Unknown media type.\n"); return AVMEDIA_TYPE_UNKNOWN; } }