frontend: Split UI utility implementation into single files per class
This commit is contained in:
parent
a0668682b7
commit
a1ba3247c6
15 changed files with 64 additions and 1033 deletions
|
|
@ -15,15 +15,12 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include "ffmpeg-utils.hpp"
|
||||
#include "FFmpegCodec.hpp"
|
||||
#include "FFmpegFormat.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
vector<FFmpegCodec> GetFormatCodecs(const FFmpegFormat &format, bool ignore_compatibility)
|
||||
|
|
@ -47,51 +44,6 @@ vector<FFmpegCodec> GetFormatCodecs(const FFmpegFormat &format, bool ignore_comp
|
|||
return codecs;
|
||||
}
|
||||
|
||||
static bool is_output_device(const AVClass *avclass)
|
||||
{
|
||||
if (!avclass)
|
||||
return false;
|
||||
|
||||
switch (avclass->category) {
|
||||
case AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT:
|
||||
case AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT:
|
||||
case AV_CLASS_CATEGORY_DEVICE_OUTPUT:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
vector<FFmpegFormat> GetSupportedFormats()
|
||||
{
|
||||
vector<FFmpegFormat> formats;
|
||||
const AVOutputFormat *output_format;
|
||||
|
||||
void *i = 0;
|
||||
while ((output_format = av_muxer_iterate(&i)) != nullptr) {
|
||||
if (is_output_device(output_format->priv_class))
|
||||
continue;
|
||||
|
||||
formats.emplace_back(output_format);
|
||||
}
|
||||
|
||||
return formats;
|
||||
}
|
||||
|
||||
FFmpegCodec FFmpegFormat::GetDefaultEncoder(FFmpegCodecType codec_type) const
|
||||
{
|
||||
const AVCodecID codec_id = codec_type == VIDEO ? video_codec : audio_codec;
|
||||
if (codec_type == UNKNOWN || codec_id == AV_CODEC_ID_NONE)
|
||||
return {};
|
||||
|
||||
if (auto codec = avcodec_find_encoder(codec_id))
|
||||
return {codec};
|
||||
|
||||
/* Fall back to using the format name as the encoder,
|
||||
* this works for some formats such as FLV. */
|
||||
return FFmpegCodec{name, codec_id, codec_type};
|
||||
}
|
||||
|
||||
bool FFCodecAndFormatCompatible(const char *codec, const char *format)
|
||||
{
|
||||
if (!codec || !format)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue