/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef DOM_MEDIA_PLATFORMS_FFMPEG_FFMPEGVIDEOENCODER_H_ #define DOM_MEDIA_PLATFORMS_FFMPEG_FFMPEGVIDEOENCODER_H_ #include "FFmpegDataEncoder.h" #include "FFmpegLibWrapper.h" #include "PlatformEncoderModule.h" #include "SimpleMap.h" // This must be the last header included #include "FFmpegLibs.h" namespace mozilla { template class FFmpegVideoEncoder : public MediaDataEncoder {}; template <> class FFmpegVideoEncoder : public FFmpegDataEncoder { using DurationMap = SimpleMap; public: FFmpegVideoEncoder(const FFmpegLibWrapper* aLib, AVCodecID aCodecID, const RefPtr& aTaskQueue, const EncoderConfig& aConfig); nsCString GetDescriptionName() const override; protected: // Methods only called on mTaskQueue. virtual nsresult InitSpecific() override; #if LIBAVCODEC_VERSION_MAJOR >= 58 Result EncodeInputWithModernAPIs( RefPtr aSample) override; #endif bool ScaleInputFrame(); virtual RefPtr ToMediaRawData(AVPacket* aPacket) override; Result, nsresult> GetExtraData( AVPacket* aPacket) override; void ForceEnablingFFmpegDebugLogs(); struct SVCSettings { nsTArray mTemporalLayerIds; // A key-value pair for av_opt_set. std::pair mSettingKeyValue; }; Maybe GetSVCSettings(); struct H264Settings { int mProfile; int mLevel; // A list of key-value pairs for av_opt_set. nsTArray> mSettingKeyValuePairs; }; H264Settings GetH264Settings(const H264Specific& aH264Specific); struct SVCInfo { explicit SVCInfo(nsTArray&& aTemporalLayerIds) : mTemporalLayerIds(std::move(aTemporalLayerIds)), mNextIndex(0) {} const nsTArray mTemporalLayerIds; size_t mNextIndex; // Return the current temporal layer id and update the next. uint8_t UpdateTemporalLayerId(); }; Maybe mSVCInfo{}; }; } // namespace mozilla #endif // DOM_MEDIA_PLATFORMS_FFMPEG_FFMPEGVIDEOENCODER_H_