1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:47:35 +00:00

LibVideo: Add a factory to create a PlaybackManager from in-memory data

The demuxer already has such a factory, so this just exposes the same
factory in the PlaybackManager.
This commit is contained in:
Timothy Flynn 2023-04-08 21:22:15 -04:00 committed by Linus Groh
parent 3591a13e85
commit 519b79abde
2 changed files with 15 additions and 1 deletions

View file

@ -47,7 +47,18 @@ private:
DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::from_file(StringView filename, PlaybackTimerCreator playback_timer_creator)
{
NonnullOwnPtr<Demuxer> demuxer = TRY(Matroska::MatroskaDemuxer::from_file(filename));
auto demuxer = TRY(Matroska::MatroskaDemuxer::from_file(filename));
return create_with_demuxer(move(demuxer), move(playback_timer_creator));
}
DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::from_data(ReadonlyBytes data, PlaybackTimerCreator playback_timer_creator)
{
auto demuxer = TRY(Matroska::MatroskaDemuxer::from_data(data));
return create_with_demuxer(move(demuxer), move(playback_timer_creator));
}
DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::create_with_demuxer(NonnullOwnPtr<Demuxer> demuxer, PlaybackTimerCreator playback_timer_creator)
{
auto video_tracks = TRY(demuxer->get_tracks_for_type(TrackType::Video));
if (video_tracks.is_empty())
return DecoderError::with_description(DecoderErrorCategory::Invalid, "No video track is present"sv);