VLC 4.0.0-dev
No Matches
subtitles.c File Reference

This file contains functions to detect subtitle files. More...

Include dependency graph for subtitles.c:


static void filename_strip_ext_inplace (char *str)
 Remove file extension in-place.
static char * filename_trim_inplace (char *str)
 Trim special characters from a filename.
static int whiteonly (const char *s)
static int slave_strcmp (const void *a, const void *b)
int subtitles_Filter (const char *psz_dir_content)
static char ** paths_to_list (const char *psz_dir, char *psz_path)
 Convert a list of paths separated by ',' to a char**.
int subtitles_Detect (input_thread_t *p_this, char *psz_path, const char *psz_name_org, input_item_slave_t ***ppp_slaves, int *p_slaves)
 Detect subtitle files.


static const char *const sub_exts [] = { "aqt", "ass", "cdg", "dks", "idx", "jss", "mpl2", "mpsub", "pjs", "psb", "rt", "sami", "sbv", "scc", "smi", "srt", "ssa", "stl", "sub", "tt", "ttml", "usf", "vtt", "webvtt" , "" }
 The possible extensions for subtitle files we support.

Detailed Description

This file contains functions to detect subtitle files.

Function Documentation

◆ filename_strip_ext_inplace()

static void filename_strip_ext_inplace ( char *  str)

Remove file extension in-place.

Referenced by subtitles_Detect().

◆ filename_trim_inplace()

static char * filename_trim_inplace ( char *  str)

Trim special characters from a filename.

Trims whitespaces and other non-alphanumeric characters from filenames.

This function operates on the passed string without copying. It might return a pointer different to the passed one, in case it trims characters at the beginning. Therefore it is essential that the return value is used where the trimmed version of the string is needed and the returned pointer must not be free()d but rather the original pointer!

Referenced by subtitles_Detect().

◆ paths_to_list()

static char ** paths_to_list ( const char *  psz_dir,
char *  psz_path 

Convert a list of paths separated by ',' to a char**.

References asprintf().

Referenced by subtitles_Detect().

◆ slave_strcmp()

static int slave_strcmp ( const void *  a,
const void *  b 

References input_item_slave::psz_uri, and strcoll.

Referenced by subtitles_Detect().

◆ subtitles_Detect()

int subtitles_Detect ( input_thread_t p_this,
char *  psz_path,
const char *  psz_name_org,
input_item_slave_t ***  ppp_slaves,
int *  p_slaves 

Detect subtitle files.

When called this function will split up the psz_name string into a directory, filename and extension. It then opens the directory in which the file resides and tries to find possible matches of subtitles files.

p_thisthe calling input_thread_t
psz_patha list of subdirectories (separated by a ',') to look in.
psz_name_orgthe complete filename to base the search on.
ppp_slavesan initialized input item slave list to append detected subtitles to
p_slavespointer to the size of the slave list

References asprintf(), input_item_slave::b_forced, DIR_SEP, DIR_SEP_CHAR, filename_strip_ext_inplace(), filename_trim_inplace(), input_item_slave::i_priority, input_item_slave_Delete, input_item_slave_New(), msg_Dbg, paths_to_list(), psz_ext, psz_name, input_item_slave::psz_uri, SLAVE_PRIORITY_MATCH_ALL, SLAVE_PRIORITY_MATCH_LEFT, SLAVE_PRIORITY_MATCH_NONE, SLAVE_PRIORITY_MATCH_RIGHT, slave_strcmp(), SLAVE_TYPE_SPU, strcasecmp(), strdup(), subtitles_Filter(), TAB_APPEND, var_GetInteger(), vlc_closedir(), VLC_EGENERIC, VLC_ENOMEM, vlc_opendir(), vlc_path2uri(), vlc_readdir(), vlc_stat(), VLC_SUCCESS, vlc_uri2path(), and whiteonly().

Referenced by LoadSlaves().

◆ subtitles_Filter()

int subtitles_Filter ( const char *  psz_dir_content)

◆ whiteonly()

static int whiteonly ( const char *  s)

Referenced by subtitles_Detect().

Variable Documentation

◆ sub_exts

const char* const sub_exts[] = { "aqt", "ass", "cdg", "dks", "idx", "jss", "mpl2", "mpsub", "pjs", "psb", "rt", "sami", "sbv", "scc", "smi", "srt", "ssa", "stl", "sub", "tt", "ttml", "usf", "vtt", "webvtt" , "" }

The possible extensions for subtitle files we support.

Referenced by subtitles_Filter().