mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +00:00
LibVideo: Read Matroska lazily so that large files can start quickly
The Demuxer class was changed to return errors for more functions so that all of the underlying reading can be done lazily. Other than that, the demuxer interface is unchanged, and only the underlying reader was modified. The MatroskaDocument class is no more, and MatroskaReader's getter functions replace it. Every MatroskaReader getter beyond the Segment element's position is parsed lazily from the file as needed. This means that all getter functions can return DecoderErrors which must be handled by callers.
This commit is contained in:
parent
f4c476b26f
commit
393cfdd5c5
11 changed files with 576 additions and 310 deletions
|
@ -16,7 +16,7 @@ namespace Video {
|
|||
DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::from_file(Core::Object& event_handler, StringView filename)
|
||||
{
|
||||
NonnullOwnPtr<Demuxer> demuxer = TRY(Matroska::MatroskaDemuxer::from_file(filename));
|
||||
auto video_tracks = demuxer->get_tracks_for_type(TrackType::Video);
|
||||
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);
|
||||
auto track = video_tracks[0];
|
||||
|
@ -101,7 +101,10 @@ Time PlaybackManager::current_playback_time()
|
|||
|
||||
Time PlaybackManager::duration()
|
||||
{
|
||||
return m_demuxer->duration();
|
||||
auto duration_result = m_demuxer->duration();
|
||||
if (duration_result.is_error())
|
||||
on_decoder_error(duration_result.release_error());
|
||||
return duration_result.release_value();
|
||||
}
|
||||
|
||||
void PlaybackManager::on_decoder_error(DecoderError error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue