mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
LibVideo: Extract video metadata for public-facing video track data
This copies the video data from the Matroska document into the Track structure that outside users have access to. Because Track can actually represent other media types, this is set up such that the Track can hold metadata for those other types when they are needed. This is needed for LibWeb's HTMLMediaElement implementation.
This commit is contained in:
parent
952808eaaa
commit
c978beb18b
2 changed files with 44 additions and 1 deletions
|
@ -38,9 +38,21 @@ DecoderErrorOr<Vector<Track>> MatroskaDemuxer::get_tracks_for_type(TrackType typ
|
|||
Vector<Track> tracks;
|
||||
TRY(m_reader.for_each_track_of_type(matroska_track_type, [&](TrackEntry const& track_entry) -> DecoderErrorOr<IterationDecision> {
|
||||
VERIFY(track_entry.track_type() == matroska_track_type);
|
||||
DECODER_TRY_ALLOC(tracks.try_append(Track(type, track_entry.track_number())));
|
||||
Track track(type, track_entry.track_number());
|
||||
|
||||
switch (type) {
|
||||
case TrackType::Video:
|
||||
if (auto video_track = track_entry.video_track(); video_track.has_value())
|
||||
track.set_video_data({ TRY(duration()), video_track->pixel_width, video_track->pixel_height });
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DECODER_TRY_ALLOC(tracks.try_append(track));
|
||||
return IterationDecision::Continue;
|
||||
}));
|
||||
|
||||
return tracks;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue