gmerlin
Data Structures | Macros | Functions
Track information

Data Structures

struct  bg_audio_info_t
 Description of an audio stream. More...
 
struct  bg_video_info_t
 Description of a video stream. More...
 
struct  bg_subtitle_info_t
 Description of a subtitle stream. More...
 
struct  bg_chapter_list_t
 Check if 2 metadata structures are equal. More...
 
struct  bg_track_info_t
 Track info. More...
 

Macros

#define BG_TRACK_SEEKABLE   (1<<0)
 Track is seekable. More...
 
#define BG_TRACK_PAUSABLE   (1<<1)
 Track is pausable. More...
 

Functions

char * bg_create_track_name (const gavl_metadata_t *m, const char *format)
 Create trackname from metadata. More...
 
char * bg_metadata_to_string (const gavl_metadata_t *m, int use_tabs)
 Convert metadata to a humanized string. More...
 
int bg_metadata_get_year (const gavl_metadata_t *m)
 Try to get the year from the metadata. More...
 
void bg_xml_2_metadata (xmlDocPtr xml_doc, xmlNodePtr xml_metadata, gavl_metadata_t *ret)
 Convert a libxml2 node into a metadata struct. More...
 
void bg_metadata_2_xml (xmlNodePtr xml_metadata, gavl_metadata_t *ret)
 Convert a metadata struct into a libxml2 node. More...
 
bg_parameter_info_tbg_metadata_get_parameters (gavl_metadata_t *m)
 Get parameters for editing metadata. More...
 
bg_parameter_info_tbg_metadata_get_parameters_common (gavl_metadata_t *m)
 Get parameters for editing metadata. More...
 
void bg_metadata_set_parameter (void *data, const char *name, const bg_parameter_value_t *v)
 Change metadata by setting parameters. More...
 
bg_chapter_list_tbg_chapter_list_create (int num_chapters)
 Create chapter list. More...
 
bg_chapter_list_tbg_chapter_list_copy (const bg_chapter_list_t *list)
 Copy chapter list. More...
 
void bg_chapter_list_destroy (bg_chapter_list_t *list)
 Destroy chapter list. More...
 
void bg_chapter_list_insert (bg_chapter_list_t *list, int index, int64_t time, const char *name)
 Insert a chapter into a chapter list. More...
 
void bg_chapter_list_delete (bg_chapter_list_t *list, int index)
 Delete a chapter from a chapter list. More...
 
void bg_chapter_list_set_default_names (bg_chapter_list_t *list)
 Set default chapter names. More...
 
int bg_chapter_list_get_current (bg_chapter_list_t *list, gavl_time_t time)
 Get current chapter. More...
 
int bg_chapter_list_changed (bg_chapter_list_t *list, gavl_time_t time, int *current_chapter)
 Get current chapter. More...
 
void bg_chapter_list_2_xml (bg_chapter_list_t *list, xmlNodePtr xml_list)
 Convert a chapter list into a libxml2 node. More...
 
bg_chapter_list_tbg_xml_2_chapter_list (xmlDocPtr xml_doc, xmlNodePtr xml_list)
 Convert libxml2 node into a chapter list. More...
 
void bg_chapter_list_save (bg_chapter_list_t *list, const char *filename)
 Save a chapter list to a file. More...
 
bg_chapter_list_tbg_chapter_list_load (const char *filename)
 Load a chapter list from a file. More...
 
void bg_track_info_free (bg_track_info_t *info)
 Free all allocated memory in a track info. More...
 
void bg_set_track_name_default (bg_track_info_t *info, const char *location)
 Set the track name from the filename/URL. More...
 
char * bg_get_track_name_default (const char *location, int track, int num_tracks)
 Get a track name from the filename/URL. More...
 

Detailed Description

These structures describe media tracks with their streams. They are returned by the input plugin.

Macro Definition Documentation

#define BG_TRACK_SEEKABLE   (1<<0)

Track is seekable.

#define BG_TRACK_PAUSABLE   (1<<1)

Track is pausable.

Function Documentation

char* bg_create_track_name ( const gavl_metadata_t *  m,
const char *  format 
)

Create trackname from metadata.

Parameters
mMetadata
formatFormat string
Returns
A newly allocated track name or NULL

The format string can contain arbitrary characters and the following placeholders

  • p: Artist
  • a: Album
  • g: Genre
  • t: Track name
  • c: Comment
  • y: Year
  • %<d>n: Track number with <d> digits

If the string corresponding to a placeholder is NULL, the whole function is aborted and NULL is returned.

char* bg_metadata_to_string ( const gavl_metadata_t *  m,
int  use_tabs 
)

Convert metadata to a humanized string.

Parameters
mMetadata
use_tabsIndicate, that tabs (\t) should be used in the output
Returns
A newly allocated string
int bg_metadata_get_year ( const gavl_metadata_t *  m)

Try to get the year from the metadata.

Parameters
mMetadata
Returns
The year as int

The date string can be in multiple formats. This function tries to extract the year and return it as int.

void bg_xml_2_metadata ( xmlDocPtr  xml_doc,
xmlNodePtr  xml_metadata,
gavl_metadata_t *  ret 
)

Convert a libxml2 node into a metadata struct.

Parameters
xml_docPointer to the xml document
xml_metadataPointer to the xml node containing the metadata
retMetadata container, where the info will be stored

See the libxml2 documentation for more infos

void bg_metadata_2_xml ( xmlNodePtr  xml_metadata,
gavl_metadata_t *  ret 
)

Convert a metadata struct into a libxml2 node.

Parameters
retMetadata
xml_metadataPointer to the xml node for the metadata

See the libxml2 documentation for more infos

bg_parameter_info_t* bg_metadata_get_parameters ( gavl_metadata_t *  m)

Get parameters for editing metadata.

Parameters
mMetadata
Returns
A NULL-terminated array of parameter descriptions

Using this function and bg_metadata_set_parameter lets you set metadata with the usual configuration methods. The default values of the returned descriptions are set from the Metadata.

Call bg_parameter_info_destroy_array to free the returned array

bg_parameter_info_t* bg_metadata_get_parameters_common ( gavl_metadata_t *  m)

Get parameters for editing metadata.

Parameters
mMetadata
Returns
A NULL-terminated array of parameter descriptions

This function works exactly like bg_metadata_get_parameters but it returns only the parameters suitable for mass tagging. Using this function and bg_metadata_set_parameter lets you set metadata with the usual configuration methods. The default values of the returned descriptions are set from the Metadata.

Call bg_parameter_info_destroy_array to free the returned array

void bg_metadata_set_parameter ( void *  data,
const char *  name,
const bg_parameter_value_t v 
)

Change metadata by setting parameters.

Parameters
dataMetadata casted to void
nameName of the parameter
vValue
bg_chapter_list_t* bg_chapter_list_create ( int  num_chapters)

Create chapter list.

Parameters
num_chaptersInitial number of chapters
bg_chapter_list_t* bg_chapter_list_copy ( const bg_chapter_list_t list)

Copy chapter list.

Parameters
listChapter list
void bg_chapter_list_destroy ( bg_chapter_list_t list)

Destroy chapter list.

Parameters
listA chapter list
void bg_chapter_list_insert ( bg_chapter_list_t list,
int  index,
int64_t  time,
const char *  name 
)

Insert a chapter into a chapter list.

Parameters
listA chapter list
indexPosition (starting with 0) where the new chapter will be placed
timeStart time of the chapter
nameChapter name (or NULL)
void bg_chapter_list_delete ( bg_chapter_list_t list,
int  index 
)

Delete a chapter from a chapter list.

Parameters
listA chapter list
indexPosition (starting with 0) of the chapter to delete
void bg_chapter_list_set_default_names ( bg_chapter_list_t list)

Set default chapter names.

Parameters
listA chapter list

If no names for the chapters are avaiable, this function will set them to "Chapter 1", "Chapter 2" etc.

int bg_chapter_list_get_current ( bg_chapter_list_t list,
gavl_time_t  time 
)

Get current chapter.

Parameters
listA chapter list
timePlayback time
Returns
The current chapter index

Use this function after seeking to signal a chapter change

int bg_chapter_list_changed ( bg_chapter_list_t list,
gavl_time_t  time,
int *  current_chapter 
)

Get current chapter.

Parameters
listA chapter list
timePlayback time
current_chapterReturns the current chapter
Returns
1 if the chapter changed, 0 else

Use this function during linear playback to signal a chapter change

void bg_chapter_list_2_xml ( bg_chapter_list_t list,
xmlNodePtr  xml_list 
)

Convert a chapter list into a libxml2 node.

Parameters
listChapter list
xml_listPointer to the xml node for the chapter list

See the libxml2 documentation for more infos

bg_chapter_list_t* bg_xml_2_chapter_list ( xmlDocPtr  xml_doc,
xmlNodePtr  xml_list 
)

Convert libxml2 node into a chapter list.

Parameters
xml_docPointer to the xml document
xml_listPointer to the xml node for chapter list
Returns
The chapter list from the xml node

See the libxml2 documentation for more infos

void bg_chapter_list_save ( bg_chapter_list_t list,
const char *  filename 
)

Save a chapter list to a file.

Parameters
listA chapter list
filenameWhere to save the list
bg_chapter_list_t* bg_chapter_list_load ( const char *  filename)

Load a chapter list from a file.

Parameters
filenameFrom where to load the list
Returns
A newly created chapter list or NULL
void bg_track_info_free ( bg_track_info_t info)

Free all allocated memory in a track info.

Parameters
infoTrack info

This one can be called by plugins to free all allocated memory contained in a track info. Note, that you have to free() the structure itself after.

void bg_set_track_name_default ( bg_track_info_t info,
const char *  location 
)

Set the track name from the filename/URL.

Parameters
infoTrack info
locationfilename or URL

This is used for cases, where the input plugin didn't set a track name, and the name cannot (or shouldn't) be set from the metadata. If location is an URL, the whole URL will be copied into the name field. If location is a local filename, the path and extension will be removed.

char* bg_get_track_name_default ( const char *  location,
int  track,
int  num_tracks 
)

Get a track name from the filename/URL.

Parameters
locationfilename or URL
Returns
A newly allocated track name which must be freed by the caller
Parameters
trackTrack index
num_tracksTotal number of tracks of the location

If location is an URL, the whole URL will be copied into the name field. If location is a local filename, the path and extension will be removed.