1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-28 02:23:06 +00:00

Demuxer-independent functions for selecting tracks based on language.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26118 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
eugeni 2008-02-29 17:25:43 +00:00
parent 579e353b0f
commit 2c8e65329f
2 changed files with 37 additions and 0 deletions

View File

@ -1405,3 +1405,35 @@ int demuxer_set_angle(demuxer_t *demuxer, int angle) {
return angle;
}
int demuxer_audio_track_by_lang(demuxer_t* d, char* lang)
{
int i, len;
lang += strspn(lang, ",");
while((len = strcspn(lang, ",")) > 0) {
for (i=0; i < MAX_A_STREAMS; ++i) {
sh_audio_t* sh = d->a_streams[i];
if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0)
return sh->aid;
}
lang += len;
lang += strspn(lang, ",");
}
return -1;
}
int demuxer_sub_track_by_lang(demuxer_t* d, char* lang)
{
int i, len;
lang += strspn(lang, ",");
while((len = strcspn(lang, ",")) > 0) {
for (i=0; i < MAX_S_STREAMS; ++i) {
sh_sub_t* sh = d->s_streams[i];
if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0)
return sh->sid;
}
lang += len;
lang += strspn(lang, ",");
}
return -1;
}

View File

@ -421,4 +421,9 @@ int demuxer_set_angle(demuxer_t *demuxer, int angle);
/// Get number of angles.
int demuxer_angles_count(demuxer_t *demuxer);
// get the index of a track
// lang is a comma-separated list
int demuxer_audio_track_by_lang(demuxer_t* demuxer, char* lang);
int demuxer_sub_track_by_lang(demuxer_t* demuxer, char* lang);
#endif /* MPLAYER_DEMUXER_H */