diff --git a/Libraries/LibMedia/CMakeLists.txt b/Libraries/LibMedia/CMakeLists.txt index 00d4e12a1b8..28fb66a5814 100644 --- a/Libraries/LibMedia/CMakeLists.txt +++ b/Libraries/LibMedia/CMakeLists.txt @@ -1,8 +1,6 @@ include(audio) -if (NOT ANDROID) - include(ffmpeg) -endif() +include(ffmpeg) set(SOURCES Audio/Loader.cpp @@ -19,20 +17,19 @@ set(SOURCES ladybird_lib(LibMedia media) target_link_libraries(LibMedia PRIVATE LibCore LibCrypto LibIPC LibGfx LibThreading LibUnicode) +target_sources(LibMedia PRIVATE + Audio/FFmpegLoader.cpp + FFmpeg/FFmpegDemuxer.cpp + FFmpeg/FFmpegIOContext.cpp + FFmpeg/FFmpegVideoDecoder.cpp +) + if (NOT ANDROID) - target_sources(LibMedia PRIVATE - Audio/FFmpegLoader.cpp - FFmpeg/FFmpegDemuxer.cpp - FFmpeg/FFmpegIOContext.cpp - FFmpeg/FFmpegVideoDecoder.cpp - ) target_link_libraries(LibMedia PRIVATE PkgConfig::AVCODEC PkgConfig::AVFORMAT PkgConfig::AVUTIL) else() - # FIXME: Need to figure out how to build or replace ffmpeg libs on Android and Windows - target_sources(LibMedia PRIVATE - FFmpeg/FFmpegDemuxerStub.cpp - FFmpeg/FFmpegVideoDecoderStub.cpp - ) + target_include_directories(LibMedia PRIVATE ${FFMPEG_INCLUDE_DIRS}) + target_link_directories(LibMedia PRIVATE ${FFMPEG_LIBRARY_DIRS}) + target_link_libraries(LibMedia PRIVATE ${FFMPEG_LIBRARIES}) endif() if (LADYBIRD_AUDIO_BACKEND STREQUAL "PULSE") diff --git a/Libraries/LibMedia/FFmpeg/FFmpegDemuxerStub.cpp b/Libraries/LibMedia/FFmpeg/FFmpegDemuxerStub.cpp deleted file mode 100644 index a13f264cde2..00000000000 --- a/Libraries/LibMedia/FFmpeg/FFmpegDemuxerStub.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2025, Luke Wilde - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include - -namespace Media::FFmpeg { - -DecoderErrorOr> FFmpegDemuxer::get_tracks_for_type(TrackType type) -{ - (void)type; - return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform"); -} - -DecoderErrorOr> FFmpegDemuxer::seek_to_most_recent_keyframe(Track track, AK::Duration timestamp, Optional earliest_available_sample = OptionalNone()) -{ - (void)track; - (void)timestamp; - (void)earliest_available_sample; - return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform"); -} - -DecoderErrorOr FFmpegDemuxer::duration() -{ - return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform"); -} - -DecoderErrorOr FFmpegDemuxer::get_codec_id_for_track(Track track) -{ - (void)track; - return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform"); -} - -DecoderErrorOr FFmpegDemuxer::get_codec_initialization_data_for_track(Track track) -{ - (void)track; - return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform"); -} - -DecoderErrorOr FFmpegDemuxer::get_next_sample_for_track(Track track) -{ - (void)track; - return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform"); -} - -} diff --git a/Libraries/LibMedia/FFmpeg/FFmpegVideoDecoderStub.cpp b/Libraries/LibMedia/FFmpeg/FFmpegVideoDecoderStub.cpp deleted file mode 100644 index e3308783934..00000000000 --- a/Libraries/LibMedia/FFmpeg/FFmpegVideoDecoderStub.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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(AK::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() -{ -} - -} diff --git a/Meta/CMake/ffmpeg.cmake b/Meta/CMake/ffmpeg.cmake index c31aaf7bb71..1d537f17545 100644 --- a/Meta/CMake/ffmpeg.cmake +++ b/Meta/CMake/ffmpeg.cmake @@ -1,6 +1,10 @@ include_guard() +if (NOT ANDROID) find_package(PkgConfig REQUIRED) pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec) pkg_check_modules(AVFORMAT REQUIRED IMPORTED_TARGET libavformat) pkg_check_modules(AVUTIL REQUIRED IMPORTED_TARGET libavutil) +else() + find_package(FFMPEG REQUIRED) +endif() diff --git a/vcpkg.json b/vcpkg.json index e13ad9a7ed5..48f8e058c66 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -31,7 +31,6 @@ "fast-float", { "name": "ffmpeg", - "platform": "!android", "features": [ "avcodec", "avformat",