gmerlin
streaminfo.h
1 /*****************************************************************
2  * gmerlin - a general purpose multimedia framework and applications
3  *
4  * Copyright (c) 2001 - 2011 Members of the Gmerlin project
5  * gmerlin-general@lists.sourceforge.net
6  * http://gmerlin.sourceforge.net
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  * *****************************************************************/
21 
22 #ifndef __BG_STREAMINFO_H_
23 #define __BG_STREAMINFO_H_
24 
25 #include <gavl/gavl.h>
26 #include <gavl/metadata.h>
27 
28 #include <libxml/tree.h>
29 #include <libxml/parser.h>
30 
40 /************************************************
41  * Types for describing media streams
42  ************************************************/
43 
44 /* Languages are ISO 639-2 (3 character code) */
45 
52 typedef struct
53  {
55 
56  gavl_metadata_t m;
57 
58  int64_t duration;
59  int64_t pts_offset;
61 
67 typedef struct
68  {
70  gavl_metadata_t m;
71 
72  int64_t duration;
73  int64_t pts_offset;
75 
81 typedef struct
82  {
83  gavl_metadata_t m;
84  int is_text;
86  int64_t duration;
88 
110 char * bg_create_track_name(const gavl_metadata_t * m, const char * format);
111 
118 char * bg_metadata_to_string(const gavl_metadata_t * m, int use_tabs);
119 
128 int bg_metadata_get_year(const gavl_metadata_t * m);
129 
130 
131 /* XML Interface */
132 
141 void bg_xml_2_metadata(xmlDocPtr xml_doc, xmlNodePtr xml_metadata,
142  gavl_metadata_t * ret);
143 
151 void bg_metadata_2_xml(xmlNodePtr xml_metadata,
152  gavl_metadata_t * ret);
153 
166 bg_parameter_info_t * bg_metadata_get_parameters(gavl_metadata_t * m);
167 
183 
184 
191 void bg_metadata_set_parameter(void * data, const char * name,
192  const bg_parameter_value_t * v);
193 
200 //int bg_metadata_equal(const bg_metadata_t * m1,
201 // const bg_metadata_t * m2);
202 
203 
211 typedef struct
212  {
214  int timescale;
215  struct
216  {
217  int64_t time;
218  char * name;
219  } * chapters;
221 
227 bg_chapter_list_t * bg_chapter_list_create(int num_chapters);
228 
234 
235 
248 void bg_chapter_list_insert(bg_chapter_list_t * list, int index,
249  int64_t time, const char * name);
250 
256 void bg_chapter_list_delete(bg_chapter_list_t * list, int index);
257 
266 
277  gavl_time_t time);
278 
290  gavl_time_t time, int * current_chapter);
291 
292 
300 void bg_chapter_list_2_xml(bg_chapter_list_t * list, xmlNodePtr xml_list);
301 
311 bg_xml_2_chapter_list(xmlDocPtr xml_doc, xmlNodePtr xml_list);
312 
318 void bg_chapter_list_save(bg_chapter_list_t * list, const char * filename);
319 
325 bg_chapter_list_t * bg_chapter_list_load(const char * filename);
326 
327 #define BG_TRACK_SEEKABLE (1<<0)
328 #define BG_TRACK_PAUSABLE (1<<1)
329 
330 
333 typedef struct
334  {
335  int flags;
336  char * name;
337  int64_t duration;
338 
342 
346 
347  gavl_metadata_t metadata;
348 
349  /* The following are only meaningful for redirectors */
350 
351  char * url;
352 
354 
355  } bg_track_info_t;
356 
367 
379  const char * location);
380 
391 char * bg_get_track_name_default(const char * location, int track, int num_tracks);
392 
398 #endif // /__BG_STREAMINFO_H_
gavl_audio_format_t format
Format (invalid until after the start function was called)
Definition: streaminfo.h:54
int num_video_streams
Number of video streams.
Definition: streaminfo.h:340
int bg_metadata_get_year(const gavl_metadata_t *m)
Try to get the year from the metadata.
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.
bg_chapter_list_t * bg_chapter_list_create(int num_chapters)
Create chapter list.
gavl_metadata_t m
Metadata.
Definition: streaminfo.h:70
char * bg_metadata_to_string(const gavl_metadata_t *m, int use_tabs)
Convert metadata to a humanized string.
int64_t duration
Duration.
Definition: streaminfo.h:337
Check if 2 metadata structures are equal.
Definition: streaminfo.h:211
int timescale
Scale of the timestamps.
Definition: streaminfo.h:214
bg_chapter_list_t * bg_chapter_list_copy(const bg_chapter_list_t *list)
Copy chapter list.
bg_chapter_list_t * chapter_list
Chapter list (or NULL)
Definition: streaminfo.h:353
int is_text
1 if subtitles are in text format (0 for overlay subtitles)
Definition: streaminfo.h:84
gavl_video_format_t format
Format of overlay subtitles.
Definition: streaminfo.h:85
void bg_chapter_list_destroy(bg_chapter_list_t *list)
Destroy chapter list.
void bg_set_track_name_default(bg_track_info_t *info, const char *location)
Set the track name from the filename/URL.
Description of a video stream.
Definition: streaminfo.h:67
bg_subtitle_info_t * subtitle_streams
Subtitle streams.
Definition: streaminfo.h:345
void bg_track_info_free(bg_track_info_t *info)
Free all allocated memory in a track info.
gavl_metadata_t m
Metadata.
Definition: streaminfo.h:83
void bg_chapter_list_save(bg_chapter_list_t *list, const char *filename)
Save a chapter list to a file.
int num_chapters
Number of chapters.
Definition: streaminfo.h:213
int num_subtitle_streams
Number of subtitle streams.
Definition: streaminfo.h:341
Description of a subtitle stream.
Definition: streaminfo.h:81
gavl_video_format_t format
Format (invalid before the start function was called)
Definition: streaminfo.h:69
void bg_chapter_list_set_default_names(bg_chapter_list_t *list)
Set default chapter names.
int num_audio_streams
Number of audio streams.
Definition: streaminfo.h:339
int64_t duration
Duration in timescale tics.
Definition: streaminfo.h:86
void bg_chapter_list_delete(bg_chapter_list_t *list, int index)
Delete a chapter from a chapter list.
Parmeter description.
Definition: parameter.h:134
bg_video_info_t * video_streams
Video streams.
Definition: streaminfo.h:344
void bg_metadata_set_parameter(void *data, const char *name, const bg_parameter_value_t *v)
Change metadata by setting parameters.
void bg_xml_2_metadata(xmlDocPtr xml_doc, xmlNodePtr xml_metadata, gavl_metadata_t *ret)
Convert a libxml2 node into a metadata struct.
char * name
Name for this chapter (or NULL if unavailable)
Definition: streaminfo.h:218
int64_t pts_offset
First timestamp.
Definition: streaminfo.h:59
char * bg_get_track_name_default(const char *location, int track, int num_tracks)
Get a track name from the filename/URL.
gavl_metadata_t metadata
Metadata (optional)
Definition: streaminfo.h:347
int64_t duration
Duration in timescale tics.
Definition: streaminfo.h:72
Description of an audio stream.
Definition: streaminfo.h:52
int64_t time
Start time (seekpoint) of this chapter.
Definition: streaminfo.h:217
bg_chapter_list_t * bg_xml_2_chapter_list(xmlDocPtr xml_doc, xmlNodePtr xml_list)
Convert libxml2 node into a chapter list.
char * name
Name of the track (can be NULL)
Definition: streaminfo.h:336
char * bg_create_track_name(const gavl_metadata_t *m, const char *format)
Create trackname from metadata.
int flags
1 if track is seekable (duration must be > 0 then)
Definition: streaminfo.h:335
int64_t gavl_time_t
char * url
URL (needed if is_redirector field is nonzero)
Definition: streaminfo.h:351
bg_audio_info_t * audio_streams
Audio streams.
Definition: streaminfo.h:343
int64_t duration
Duration in timescale tics.
Definition: streaminfo.h:58
Container for a parameter value.
Definition: parameter.h:82
int bg_chapter_list_get_current(bg_chapter_list_t *list, gavl_time_t time)
Get current chapter.
Track info.
Definition: streaminfo.h:333
void bg_chapter_list_2_xml(bg_chapter_list_t *list, xmlNodePtr xml_list)
Convert a chapter list into a libxml2 node.
int64_t pts_offset
First timestamp.
Definition: streaminfo.h:73
void bg_metadata_2_xml(xmlNodePtr xml_metadata, gavl_metadata_t *ret)
Convert a metadata struct into a libxml2 node.
bg_parameter_info_t * bg_metadata_get_parameters(gavl_metadata_t *m)
Get parameters for editing metadata.
bg_parameter_info_t * bg_metadata_get_parameters_common(gavl_metadata_t *m)
Get parameters for editing metadata.
bg_chapter_list_t * bg_chapter_list_load(const char *filename)
Load a chapter list from a file.
int bg_chapter_list_changed(bg_chapter_list_t *list, gavl_time_t time, int *current_chapter)
Get current chapter.
gavl_metadata_t m
Metadata.
Definition: streaminfo.h:56