From e8b398ca34242b14600e929b8aaeffdf780bd64a Mon Sep 17 00:00:00 2001 From: Alex Studer Date: Wed, 3 Jul 2024 15:55:30 -0400 Subject: [PATCH] LibMedia: Add a stub implementation of FFmpegVideoDecoder for Android We don't have ffmpeg available on Android, so provide a dummy FFmpegVideoDecoder and disable linking against ffmpeg for Android. --- Userland/Libraries/LibMedia/CMakeLists.txt | 17 +++++-- .../FFmpeg/FFmpegVideoDecoderStub.cpp | 49 +++++++++++++++++++ 2 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 Userland/Libraries/LibMedia/FFmpeg/FFmpegVideoDecoderStub.cpp diff --git a/Userland/Libraries/LibMedia/CMakeLists.txt b/Userland/Libraries/LibMedia/CMakeLists.txt index 350c2c58463..26d8f4263a0 100644 --- a/Userland/Libraries/LibMedia/CMakeLists.txt +++ b/Userland/Libraries/LibMedia/CMakeLists.txt @@ -4,15 +4,22 @@ set(SOURCES Color/TransferCharacteristics.cpp Containers/Matroska/MatroskaDemuxer.cpp Containers/Matroska/Reader.cpp - FFmpeg/FFmpegVideoDecoder.cpp PlaybackManager.cpp VideoFrame.cpp ) +if (NOT ANDROID) + list(APPEND SOURCES FFmpeg/FFmpegVideoDecoder.cpp) +else() + list(APPEND SOURCES FFmpeg/FFmpegVideoDecoderStub.cpp) +endif() + serenity_lib(LibMedia media) target_link_libraries(LibMedia PRIVATE LibCore LibIPC LibGfx LibThreading) -# Third-party -find_package(PkgConfig REQUIRED) -pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec) -target_link_libraries(LibMedia PRIVATE PkgConfig::AVCODEC) +if (NOT ANDROID) + # Third-party + find_package(PkgConfig REQUIRED) + pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec) + target_link_libraries(LibMedia PRIVATE PkgConfig::AVCODEC) +endif() diff --git a/Userland/Libraries/LibMedia/FFmpeg/FFmpegVideoDecoderStub.cpp b/Userland/Libraries/LibMedia/FFmpeg/FFmpegVideoDecoderStub.cpp new file mode 100644 index 00000000000..2331f3f5b14 --- /dev/null +++ b/Userland/Libraries/LibMedia/FFmpeg/FFmpegVideoDecoderStub.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024, Alex Studer + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include + +#include "FFmpegForward.h" +#include "FFmpegVideoDecoder.h" + +namespace Media::FFmpeg { + +DecoderErrorOr> FFmpegVideoDecoder::try_create(CodecID codec_id, ReadonlyBytes codec_initialization_data) +{ + (void)codec_id; + (void)codec_initialization_data; + return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform"); +} + +FFmpegVideoDecoder::FFmpegVideoDecoder(AVCodecContext* codec_context, AVPacket* packet, AVFrame* frame) + : m_codec_context(codec_context) + , m_packet(packet) + , m_frame(frame) +{ +} + +FFmpegVideoDecoder::~FFmpegVideoDecoder() +{ +} + +DecoderErrorOr FFmpegVideoDecoder::receive_sample(Duration timestamp, ReadonlyBytes sample) +{ + (void)timestamp; + (void)sample; + return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform"); +} + +DecoderErrorOr> FFmpegVideoDecoder::get_decoded_frame() +{ + return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform"); +} + +void FFmpegVideoDecoder::flush() +{ +} + +}