From 5aed8f928a100bc008851f0f6d97f8202b9ed8cb Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 10 Jan 2020 20:52:16 -0800 Subject: [PATCH] Add V4L2M2M support using SDL renderer Note: This requires FFmpeg master to work, since it depends on: https://github.com/FFmpeg/FFmpeg/commit/d61cf1b1ebc2477749d7d7825a072400ed24af9 --- app/streaming/video/ffmpeg.cpp | 45 +++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index 53daac75..e64ba2be 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -543,20 +543,41 @@ bool FFmpegVideoDecoder::initialize(PDECODER_PARAMETERS params) #endif #ifdef HAVE_DRM - // RKMPP is a hardware accelerated decoder that outputs DRI PRIME buffers - AVCodec* rkmppDecoder; + { + // RKMPP is a hardware accelerated decoder that outputs DRI PRIME buffers + AVCodec* rkmppDecoder; - if (params->videoFormat & VIDEO_FORMAT_MASK_H264) { - rkmppDecoder = avcodec_find_decoder_by_name("h264_rkmpp"); - } - else { - rkmppDecoder = avcodec_find_decoder_by_name("hevc_rkmpp"); - } + if (params->videoFormat & VIDEO_FORMAT_MASK_H264) { + rkmppDecoder = avcodec_find_decoder_by_name("h264_rkmpp"); + } + else { + rkmppDecoder = avcodec_find_decoder_by_name("hevc_rkmpp"); + } - if (rkmppDecoder != nullptr && - tryInitializeRenderer(rkmppDecoder, params, nullptr, - []() -> IFFmpegRenderer* { return new DrmRenderer(); })) { - return true; + if (rkmppDecoder != nullptr && + tryInitializeRenderer(rkmppDecoder, params, nullptr, + []() -> IFFmpegRenderer* { return new DrmRenderer(); })) { + return true; + } + } +#endif + +#ifdef Q_OS_LINUX + { + AVCodec* v4l2Decoder; + + if (params->videoFormat & VIDEO_FORMAT_MASK_H264) { + v4l2Decoder = avcodec_find_decoder_by_name("h264_v4l2m2m"); + } + else { + v4l2Decoder = avcodec_find_decoder_by_name("hevc_v4l2m2m"); + } + + if (v4l2Decoder != nullptr && + tryInitializeRenderer(v4l2Decoder, params, nullptr, + []() -> IFFmpegRenderer* { return new SdlRenderer(); })) { + return true; + } } #endif