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

input: Reintroduce subtitle extension check

Fix #18882
parent 649e477b
......@@ -460,7 +460,9 @@ enum input_query_e
INPUT_GET_ATTACHMENT, /* arg1=input_attachment_t**, arg2=char* res=can fail */
/* On the fly input slave */
INPUT_ADD_SLAVE, /* arg1= enum slave_type, arg2= const char *, arg3= bool, arg4= bool */
INPUT_ADD_SLAVE, /* arg1= enum slave_type, arg2= const char *,
* arg3= bool forced, arg4= bool notify,
* arg5= bool check_extension */
INPUT_ADD_SUBTITLE, /* arg1= const char *, arg2=bool b_check_extension */
/* On the fly record while playing */
......@@ -576,9 +578,11 @@ static inline vout_thread_t *input_GetVout( input_thread_t *p_input )
}
static inline int input_AddSlave( input_thread_t *p_input, enum slave_type type,
const char *psz_uri, bool b_forced, bool b_notify )
const char *psz_uri, bool b_forced,
bool b_notify, bool b_check_ext )
{
return input_Control( p_input, INPUT_ADD_SLAVE, type, psz_uri, b_forced, b_notify );
return input_Control( p_input, INPUT_ADD_SLAVE, type, psz_uri, b_forced,
b_notify, b_check_ext );
}
/**
......
......@@ -1936,7 +1936,7 @@ int libvlc_media_player_add_slave( libvlc_media_player_t *p_mi,
else
{
int i_ret = input_AddSlave( p_input_thread, (enum slave_type) i_type,
psz_uri, b_select, false );
psz_uri, b_select, false, false );
vlc_object_release( p_input_thread );
return i_ret == VLC_SUCCESS ? 0 : -1;
......
......@@ -407,7 +407,7 @@ int libvlc_video_set_subtitle_file( libvlc_media_player_t *p_mi,
if( psz_mrl )
{
if( !input_AddSlave( p_input_thread, SLAVE_TYPE_SPU, psz_mrl,
true, false ) )
true, false, false ) )
b_ret = true;
free( psz_mrl );
}
......
......@@ -613,7 +613,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
continue;
msg_Dbg(getIntf(), "loading subs from %s", mrl);
int i_result = input_AddSlave(p_input, SLAVE_TYPE_SPU, mrl, true, true);
int i_result = input_AddSlave(p_input, SLAVE_TYPE_SPU, mrl, true, true, true);
if (i_result != VLC_SUCCESS)
msg_Warn(getIntf(), "unable to load subtitles from '%s'", mrl);
free(mrl);
......
......@@ -608,7 +608,7 @@
if (isSubtitle && array.count == 1 && p_input) {
int i_result = input_AddSlave(p_input, SLAVE_TYPE_SPU,
[[[array firstObject] objectForKey:@"ITEM_URL"] UTF8String],
true, true);
true, true, true);
if (i_result == VLC_SUCCESS) {
vlc_object_release(p_input);
return;
......
......@@ -806,7 +806,7 @@ void DialogsProvider::loadSubtitlesFile()
free( path2 );
foreach( const QString &qsUrl, qsl )
{
if( input_AddSlave( p_input, SLAVE_TYPE_SPU, qtu( qsUrl ), true, true ) )
if( input_AddSlave( p_input, SLAVE_TYPE_SPU, qtu( qsUrl ), true, true, true ) )
msg_Warn( p_intf, "unable to load subtitles from '%s'",
qtu( qsUrl ) );
}
......
......@@ -1453,7 +1453,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playli
if( mimeData->urls().count() == 1 && THEMIM->getIM()->hasInput() )
{
if( !input_AddSlave( THEMIM->getInput(), SLAVE_TYPE_SPU,
qtu( mimeData->urls()[0].toString() ), true, true ) )
qtu( mimeData->urls()[0].toString() ), true, true, true ) )
{
event->accept();
return;
......
......@@ -265,7 +265,7 @@ void TopWindow::processEvent( EvtDragDrop &rEvtDragDrop )
{
std::list<std::string>::const_iterator it = files.begin();
is_subtitle = !input_AddSlave( pInput, SLAVE_TYPE_SPU,
it->c_str(), true, true );
it->c_str(), true, true, true );
}
if( !is_subtitle )
{
......
......@@ -239,13 +239,13 @@ static int vlclua_input_add_subtitle( lua_State *L, bool b_path )
b_autoselect = lua_toboolean( L, 2 );
const char *psz_sub = luaL_checkstring( L, 1 );
if( !b_path )
input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_sub, b_autoselect, true );
input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_sub, b_autoselect, true, false );
else
{
char* psz_mrl = vlc_path2uri( psz_sub, NULL );
if ( psz_mrl )
{
input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_mrl, b_autoselect, true );
input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_mrl, b_autoselect, true, false );
free( psz_mrl );
}
}
......
......@@ -412,9 +412,13 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
psz = va_arg( args, char * );
b_bool = va_arg( args, int );
bool b_notify = va_arg( args, int );
bool b_check_ext = va_arg( args, int );
if( !psz || ( type != SLAVE_TYPE_SPU && type != SLAVE_TYPE_AUDIO ) )
return VLC_EGENERIC;
if( b_check_ext && type == SLAVE_TYPE_SPU &&
!subtitles_Filter( psz ) )
return VLC_EGENERIC;
input_item_slave_t *p_slave =
input_item_slave_New( psz, type, SLAVE_PRIORITY_USER );
......
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