FFmpegUtils.cpp (1228B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "FFmpegUtils.h" 8 9 #include "FFmpegLibWrapper.h" 10 #include "mozilla/Assertions.h" 11 #include "nsString.h" 12 13 namespace mozilla { 14 15 nsCString MakeErrorString(const FFmpegLibWrapper* aLib, int aErrNum) { 16 MOZ_ASSERT(aLib); 17 18 char errStr[FFmpegErrorMaxStringSize]; 19 aLib->av_strerror(aErrNum, errStr, FFmpegErrorMaxStringSize); 20 return nsCString(errStr); 21 } 22 23 #define ENUM_TO_STR(enumVal) \ 24 if (aCodec == (enumVal)) { \ 25 return #enumVal; \ 26 } 27 28 const char* AVCodecToString(const AVCodecID& aCodec) { 29 ENUM_TO_STR(AV_CODEC_ID_AAC); 30 ENUM_TO_STR(AV_CODEC_ID_H264); 31 #if LIBAVCODEC_VERSION_MAJOR >= 54 32 ENUM_TO_STR(AV_CODEC_ID_VP8); 33 #endif 34 #if LIBAVCODEC_VERSION_MAJOR >= 55 35 ENUM_TO_STR(AV_CODEC_ID_VP9); 36 ENUM_TO_STR(AV_CODEC_ID_HEVC); 37 #endif 38 #if LIBAVCODEC_VERSION_MAJOR >= 59 39 ENUM_TO_STR(AV_CODEC_ID_AV1); 40 #endif 41 return "unknown"; 42 } 43 44 #undef ENUM_TO_STR 45 46 } // namespace mozilla