Commit cfdadfcd authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

parser: Handle subtitle tracks

Fix #39
parent e71165c3
......@@ -57,10 +57,13 @@ public:
struct Track
{
Track() = default;
enum class Type : uint8_t
{
Video,
Audio,
Subtitle,
};
std::string codec;
......@@ -86,6 +89,10 @@ public:
uint32_t fpsNum;
uint32_t fpsDen;
} v;
struct
{
char encoding[sizeof(v)];
} s;
};
};
......
......@@ -477,13 +477,18 @@ void MetadataAnalyzer::createTracks( Media& m, const std::vector<IItem::Track>&
track.v.sarNum, track.v.sarDen,
track.language, track.description );
}
else
else if ( track.type == IItem::Track::Type::Audio )
{
assert( track.type == IItem::Track::Type::Audio );
m.addAudioTrack( track.codec, track.bitrate,
track.a.rate, track.a.nbChannels,
track.language, track.description );
}
else
{
assert( track.type == IItem::Track::Type::Subtitle );
m.addSubtitleTrack( track.codec, track.language, track.description,
track.s.encoding );
}
}
}
......
......@@ -170,6 +170,15 @@ void VLCMetadataService::mediaToItem( VLC::Media& media, IItem& item )
t.v.sarNum = track.sarNum();
t.v.sarDen = track.sarDen();
}
else if ( track.type() == VLC::MediaTrack::Type::Subtitle )
{
t.type = IItem::Track::Type::Subtitle;
t.codec = track.codec();
t.language = track.language();
t.description = track.description();
const auto& enc = track.encoding();
strncpy( t.s.encoding, enc.c_str(), sizeof(t.s.encoding) - 1 );
}
else
continue;
auto codec = track.codec();
......
......@@ -6,7 +6,7 @@
"nbVideos": 1,
"nbAudios": 0,
"media": [{
"title": "mrmssmith.mp4",
"title": "mrmssmith.mkv",
"nbVideoTracks": 1,
"nbAudioTracks": 1,
"snapshotExpected": true,
......@@ -20,6 +20,10 @@
"codec": "mp4a",
"sampleRate": 44100,
"nbChannels": 2
}],
"subtitleTracks": [{
"codec": "text",
"encoding": "UTF-8"
}]
}]
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment