File tree Expand file tree Collapse file tree 4 files changed +67
-7
lines changed
Expand file tree Collapse file tree 4 files changed +67
-7
lines changed Original file line number Diff line number Diff line change 77#pragma once
88
99#include < AK/Format.h>
10+ #include < LibMedia/TrackType.h>
1011
1112namespace Media {
1213
@@ -33,6 +34,32 @@ enum class CodecID : u32 {
3334 FLAC,
3435};
3536
37+ inline TrackType track_type_from_codec_id (CodecID codec)
38+ {
39+ switch (codec) {
40+ case CodecID::VP8:
41+ case CodecID::VP9:
42+ case CodecID::H261:
43+ case CodecID::MPEG1:
44+ case CodecID::H262:
45+ case CodecID::H263:
46+ case CodecID::H264:
47+ case CodecID::H265:
48+ case CodecID::AV1:
49+ return TrackType::Video;
50+ case CodecID::MP3:
51+ case CodecID::AAC:
52+ case CodecID::Theora:
53+ case CodecID::Vorbis:
54+ case CodecID::Opus:
55+ case CodecID::FLAC:
56+ return TrackType::Audio;
57+ case CodecID::Unknown:
58+ break ;
59+ }
60+ return TrackType::Unknown;
61+ }
62+
3663}
3764
3865namespace AK {
Original file line number Diff line number Diff line change 1313#include < AK/Time.h>
1414#include < AK/Utf8View.h>
1515#include < LibCore/MappedFile.h>
16+ #include < LibMedia/CodecID.h>
1617#include < LibMedia/Containers/Matroska/Utilities.h>
1718
1819#include " Reader.h"
@@ -538,6 +539,24 @@ static DecoderErrorOr<NonnullRefPtr<TrackEntry>> parse_track_entry(Streamer& str
538539 return IterationDecision::Continue;
539540 }));
540541
542+ if (track_entry->track_type () == TrackEntry::TrackType::Complex) {
543+ // A mix of different other TrackType. The codec needs to define how the Matroska Player
544+ // should interpret such data.
545+ auto codec_track_type = track_type_from_codec_id (codec_id_from_matroska_id_string (track_entry->codec_id ()));
546+ switch (codec_track_type) {
547+ case TrackType::Video:
548+ track_entry->set_track_type (TrackEntry::TrackType::Video);
549+ break ;
550+ case TrackType::Audio:
551+ track_entry->set_track_type (TrackEntry::TrackType::Audio);
552+ break ;
553+ case TrackType::Subtitles:
554+ track_entry->set_track_type (TrackEntry::TrackType::Subtitle);
555+ break ;
556+ case TrackType::Unknown:
557+ break ;
558+ }
559+ }
541560 return track_entry;
542561}
543562
Original file line number Diff line number Diff line change 1313#include < AK/Utf16String.h>
1414#include < AK/Variant.h>
1515#include < LibMedia/Color/CodingIndependentCodePoints.h>
16+ #include < LibMedia/TrackType.h>
1617
1718namespace Media {
1819
19- enum class TrackType : u32 {
20- Video,
21- Audio,
22- Subtitles,
23- Unknown,
24- };
25-
2620class Track {
2721 struct VideoData {
2822 u64 pixel_width { 0 };
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2025, Gregory Bertilson <gregory@ladybird.org>
3+ *
4+ * SPDX-License-Identifier: BSD-2-Clause
5+ */
6+
7+ #pragma once
8+
9+ #include < AK/Types.h>
10+
11+ namespace Media {
12+
13+ enum class TrackType : u8 {
14+ Video,
15+ Audio,
16+ Subtitles,
17+ Unknown,
18+ };
19+
20+ }
You can’t perform that action at this time.
0 commit comments