mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01:00
LibMedia+LibWeb: Prefer MatroskaDemuxer for media playback
MatroskaDemuxer supports multiple streams already, and gives us a bit more control over seeking.
This commit is contained in:
parent
0ff330c906
commit
dfe59b8a4f
|
|
@ -4,6 +4,7 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibMedia/Containers/Matroska/MatroskaDemuxer.h>
|
||||||
#include <LibMedia/FFmpeg/FFmpegDemuxer.h>
|
#include <LibMedia/FFmpeg/FFmpegDemuxer.h>
|
||||||
#include <LibMedia/MutexedDemuxer.h>
|
#include <LibMedia/MutexedDemuxer.h>
|
||||||
#include <LibMedia/Providers/AudioDataProvider.h>
|
#include <LibMedia/Providers/AudioDataProvider.h>
|
||||||
|
|
@ -16,9 +17,14 @@
|
||||||
|
|
||||||
namespace Media {
|
namespace Media {
|
||||||
|
|
||||||
DecoderErrorOr<NonnullRefPtr<PlaybackManager>> PlaybackManager::try_create(NonnullOwnPtr<SeekableStream>&& stream)
|
DecoderErrorOr<NonnullRefPtr<PlaybackManager>> PlaybackManager::try_create(ReadonlyBytes data)
|
||||||
{
|
{
|
||||||
auto inner_demuxer = DECODER_TRY_ALLOC(FFmpeg::FFmpegDemuxer::create(move(stream)));
|
auto inner_demuxer = TRY([&] -> DecoderErrorOr<NonnullRefPtr<Demuxer>> {
|
||||||
|
auto matroska_result = Matroska::MatroskaDemuxer::from_data(data);
|
||||||
|
if (!matroska_result.is_error())
|
||||||
|
return matroska_result.release_value();
|
||||||
|
return DECODER_TRY_ALLOC(FFmpeg::FFmpegDemuxer::create(make<FixedMemoryStream>(data)));
|
||||||
|
}());
|
||||||
auto demuxer = DECODER_TRY_ALLOC(try_make_ref_counted<MutexedDemuxer>(inner_demuxer));
|
auto demuxer = DECODER_TRY_ALLOC(try_make_ref_counted<MutexedDemuxer>(inner_demuxer));
|
||||||
|
|
||||||
// Create the weak wrapper.
|
// Create the weak wrapper.
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
using AudioTracks = Vector<Track, EXPECTED_AUDIO_TRACK_COUNT>;
|
using AudioTracks = Vector<Track, EXPECTED_AUDIO_TRACK_COUNT>;
|
||||||
|
|
||||||
static DecoderErrorOr<NonnullRefPtr<PlaybackManager>> try_create(NonnullOwnPtr<SeekableStream>&& stream);
|
static DecoderErrorOr<NonnullRefPtr<PlaybackManager>> try_create(ReadonlyBytes data);
|
||||||
~PlaybackManager();
|
~PlaybackManager();
|
||||||
|
|
||||||
AK::Duration current_time() const;
|
AK::Duration current_time() const;
|
||||||
|
|
|
||||||
|
|
@ -1173,7 +1173,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
|
||||||
{
|
{
|
||||||
auto& realm = this->realm();
|
auto& realm = this->realm();
|
||||||
|
|
||||||
auto playback_manager_result = Media::PlaybackManager::try_create(make<FixedMemoryStream>(m_media_data.bytes()));
|
auto playback_manager_result = Media::PlaybackManager::try_create(m_media_data.bytes());
|
||||||
|
|
||||||
// -> If the media data cannot be fetched at all, due to network errors, causing the user agent to give up trying to fetch the resource
|
// -> If the media data cannot be fetched at all, due to network errors, causing the user agent to give up trying to fetch the resource
|
||||||
// -> If the media data can be fetched but is found by inspection to be in an unsupported format, or can otherwise not be rendered at all
|
// -> If the media data can be fetched but is found by inspection to be in an unsupported format, or can otherwise not be rendered at all
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user