Merge pull request #1833 from dwot/master
vlc-video: Enable subtitle track selection
This commit is contained in:
commit
4dc1c2a7f9
@ -13,3 +13,5 @@ Stop="Stop"
|
||||
PlaylistNext="Next"
|
||||
PlaylistPrev="Previous"
|
||||
AudioTrack="Audio Track"
|
||||
SubtitleTrack="Subtitle Track"
|
||||
SubtitleEnable="Subtitles Enabled"
|
||||
|
@ -19,6 +19,8 @@
|
||||
#define S_BEHAVIOR_ALWAYS_PLAY "always_play"
|
||||
#define S_NETWORK_CACHING "network_caching"
|
||||
#define S_TRACK "track"
|
||||
#define S_SUBTITLE_ENABLE "subtitle_enable"
|
||||
#define S_SUBTITLE_TRACK "subtitle"
|
||||
|
||||
#define T_(text) obs_module_text(text)
|
||||
#define T_PLAYLIST T_("Playlist")
|
||||
@ -30,6 +32,8 @@
|
||||
#define T_BEHAVIOR_ALWAYS_PLAY T_("PlaybackBehavior.AlwaysPlay")
|
||||
#define T_NETWORK_CACHING T_("NetworkCaching")
|
||||
#define T_TRACK T_("AudioTrack")
|
||||
#define T_SUBTITLE_ENABLE T_("SubtitleEnable")
|
||||
#define T_SUBTITLE_TRACK T_("SubtitleTrack")
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@ -405,7 +409,8 @@ static int vlcs_audio_setup(void **p_data, char *format, unsigned *rate,
|
||||
}
|
||||
|
||||
static void add_file(struct vlc_source *c, struct darray *array,
|
||||
const char *path, int network_caching, int track_index)
|
||||
const char *path, int network_caching, int track_index,
|
||||
int subtitle_index, bool subtitle_enable)
|
||||
{
|
||||
DARRAY(struct media_file_data) new_files;
|
||||
struct media_file_data data;
|
||||
@ -444,6 +449,14 @@ static void add_file(struct vlc_source *c, struct darray *array,
|
||||
libvlc_media_add_option_(new_media, track_option.array);
|
||||
dstr_free(&track_option);
|
||||
|
||||
struct dstr sub_option = {0};
|
||||
if (subtitle_enable) {
|
||||
dstr_catf(&sub_option,
|
||||
":sub-track=%d", subtitle_index - 1);
|
||||
}
|
||||
libvlc_media_add_option_(new_media, sub_option.array);
|
||||
dstr_free(&sub_option);
|
||||
|
||||
data.path = new_path.array;
|
||||
data.media = new_media;
|
||||
da_push_back(new_files, &data);
|
||||
@ -498,6 +511,8 @@ static void vlcs_update(void *data, obs_data_t *settings)
|
||||
size_t count;
|
||||
int network_caching;
|
||||
int track_index;
|
||||
int subtitle_index;
|
||||
bool subtitle_enable;
|
||||
|
||||
da_init(new_files);
|
||||
da_init(old_files);
|
||||
@ -513,6 +528,10 @@ static void vlcs_update(void *data, obs_data_t *settings)
|
||||
|
||||
track_index = (int)obs_data_get_int(settings, S_TRACK);
|
||||
|
||||
subtitle_index = (int)obs_data_get_int(settings, S_SUBTITLE_TRACK);
|
||||
|
||||
subtitle_enable = obs_data_get_bool(settings, S_SUBTITLE_ENABLE);
|
||||
|
||||
if (astrcmpi(behavior, S_BEHAVIOR_PAUSE_UNPAUSE) == 0) {
|
||||
c->behavior = BEHAVIOR_PAUSE_UNPAUSE;
|
||||
} else if (astrcmpi(behavior, S_BEHAVIOR_ALWAYS_PLAY) == 0) {
|
||||
@ -550,14 +569,17 @@ static void vlcs_update(void *data, obs_data_t *settings)
|
||||
dstr_cat_ch(&dir_path, '/');
|
||||
dstr_cat(&dir_path, ent->d_name);
|
||||
add_file(c, &new_files.da, dir_path.array,
|
||||
network_caching, track_index);
|
||||
network_caching, track_index,
|
||||
subtitle_index,
|
||||
subtitle_enable);
|
||||
}
|
||||
|
||||
dstr_free(&dir_path);
|
||||
os_closedir(dir);
|
||||
} else {
|
||||
add_file(c, &new_files.da, path, network_caching,
|
||||
track_index);
|
||||
track_index, subtitle_index,
|
||||
subtitle_enable);
|
||||
}
|
||||
|
||||
obs_data_release(item);
|
||||
@ -845,6 +867,8 @@ static void vlcs_defaults(obs_data_t *settings)
|
||||
S_BEHAVIOR_STOP_RESTART);
|
||||
obs_data_set_default_int(settings, S_NETWORK_CACHING, 400);
|
||||
obs_data_set_default_int(settings, S_TRACK, 1);
|
||||
obs_data_set_default_bool(settings, S_SUBTITLE_ENABLE, false);
|
||||
obs_data_set_default_int(settings, S_SUBTITLE_TRACK, 1);
|
||||
}
|
||||
|
||||
static obs_properties_t *vlcs_properties(void *data)
|
||||
@ -915,6 +939,9 @@ static obs_properties_t *vlcs_properties(void *data)
|
||||
obs_properties_add_int(ppts, S_NETWORK_CACHING, T_NETWORK_CACHING,
|
||||
100, 60000, 10);
|
||||
obs_properties_add_int(ppts, S_TRACK, T_TRACK, 1, 10, 1);
|
||||
obs_properties_add_bool(ppts, S_SUBTITLE_ENABLE, T_SUBTITLE_ENABLE);
|
||||
obs_properties_add_int(ppts, S_SUBTITLE_TRACK, T_SUBTITLE_TRACK,
|
||||
1, 10, 1);
|
||||
|
||||
return ppts;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user