mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
LibVideo: Propagate decoder errors in the Matroska Reader
Matroska::Reader functions now return DecoderErrorOr instead of values being declared Optional. Useful errors can be handled by the users of the parser, similarly to the VP9 decoder. A lot of the error checking in the reader is a lot cleaner thanks to this change, since all reads can be range checked in Streamer::read_octet() now. Most functions for the Streamer class are now also out-of-line in Reader.cpp now instead of residing in the header.
This commit is contained in:
parent
9cf7e8c5aa
commit
2dfd236dcd
6 changed files with 338 additions and 440 deletions
|
@ -10,22 +10,12 @@ namespace Video::Matroska {
|
|||
|
||||
DecoderErrorOr<NonnullOwnPtr<MatroskaDemuxer>> MatroskaDemuxer::from_file(StringView filename)
|
||||
{
|
||||
// FIXME: MatroskaReader should return errors.
|
||||
auto nullable_document = Reader::parse_matroska_from_file(filename);
|
||||
if (!nullable_document)
|
||||
return DecoderError::format(DecoderErrorCategory::IO, "Failed to open matroska from file '{}'", filename);
|
||||
auto document = nullable_document.release_nonnull();
|
||||
return make<MatroskaDemuxer>(document);
|
||||
return make<MatroskaDemuxer>(TRY(Reader::parse_matroska_from_file(filename)));
|
||||
}
|
||||
|
||||
DecoderErrorOr<NonnullOwnPtr<MatroskaDemuxer>> MatroskaDemuxer::from_data(ReadonlyBytes data)
|
||||
{
|
||||
// FIXME: MatroskaReader should return errors.
|
||||
auto nullable_document = Reader::parse_matroska_from_data(data.data(), data.size());
|
||||
if (!nullable_document)
|
||||
return DecoderError::format(DecoderErrorCategory::IO, "Failed to open matroska from data");
|
||||
auto document = nullable_document.release_nonnull();
|
||||
return make<MatroskaDemuxer>(document);
|
||||
return make<MatroskaDemuxer>(TRY(Reader::parse_matroska_from_data(data.data(), data.size())));
|
||||
}
|
||||
|
||||
Vector<Track> MatroskaDemuxer::get_tracks_for_type(TrackType type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue