gmerlin-avdecoder
avdec.h
Go to the documentation of this file.
1 /*****************************************************************
2  * gmerlin-avdecoder - a general purpose multimedia decoding library
3  *
4  * Copyright (c) 2001 - 2012 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 /* Public entry points */
23 
29 #include <gavl/gavl.h>
30 #include <gavl/compression.h>
31 #include <gavl/metadata.h>
32 #include <gavl/chapterlist.h>
33 #include <gavl/connectors.h>
34 #include <gavl/edl.h>
35 
36 #include "bgavdefs.h" // This is ugly, but works
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
75 typedef struct bgav_s bgav_t;
76 
82 BGAV_PUBLIC
84 
115 typedef gavl_metadata_t bgav_metadata_t;
116 
123 BGAV_PUBLIC
124 const char * bgav_metadata_get_author(const bgav_metadata_t*metadata);
125 
132 BGAV_PUBLIC
133 const char * bgav_metadata_get_title(const bgav_metadata_t * metadata);
134 
141 BGAV_PUBLIC
142 const char * bgav_metadata_get_comment(const bgav_metadata_t * metadata);
143 
150 BGAV_PUBLIC
151 const char * bgav_metadata_get_copyright(const bgav_metadata_t * metadata);
152 
159 BGAV_PUBLIC
160 const char * bgav_metadata_get_album(const bgav_metadata_t * metadata);
161 
168 BGAV_PUBLIC
169 const char * bgav_metadata_get_artist(const bgav_metadata_t * metadata);
170 
177 BGAV_PUBLIC
178 const char * bgav_metadata_get_albumartist(const bgav_metadata_t * metadata);
179 
186 BGAV_PUBLIC
187 const char * bgav_metadata_get_genre(const bgav_metadata_t * metadata);
188 
195 BGAV_PUBLIC
196 const char * bgav_metadata_get_date(const bgav_metadata_t * metadata);
197 
204 BGAV_PUBLIC
205 int bgav_metadata_get_track(const bgav_metadata_t * metadata);
206 
207 /***************************************************
208  * Housekeeping Functions
209  ***************************************************/
210 
211 /***************************************************
212  * Set parameters
213  ***************************************************/
214 
215 
220 typedef struct bgav_options_s bgav_options_t;
221 
231 BGAV_PUBLIC
233 
248 BGAV_PUBLIC
250 
260 BGAV_PUBLIC
262 
269 BGAV_PUBLIC
270 void bgav_options_copy(bgav_options_t * dst, const bgav_options_t * src);
271 
281 BGAV_PUBLIC
282 void bgav_options_set_connect_timeout(bgav_options_t * opt, int timeout);
283 
293 BGAV_PUBLIC
294 void bgav_options_set_read_timeout(bgav_options_t * opt, int timeout);
295 
310 BGAV_PUBLIC
312 
322 BGAV_PUBLIC
323 void bgav_options_set_rtp_try_tcp(bgav_options_t * opt, int enable);
324 
334 BGAV_PUBLIC
335 void bgav_options_set_network_bandwidth(bgav_options_t * opt, int bandwidth);
336 
346 BGAV_PUBLIC
348 
349 /* HTTP Options */
350 
361 BGAV_PUBLIC
362 void bgav_options_set_http_use_proxy(bgav_options_t* opt, int enable);
363 
373 BGAV_PUBLIC
374 void bgav_options_set_http_proxy_host(bgav_options_t* opt, const char * host);
375 
385 BGAV_PUBLIC
387 
398 BGAV_PUBLIC
399 void bgav_options_set_http_proxy_auth(bgav_options_t* opt, int enable);
400 
409 BGAV_PUBLIC
410 void bgav_options_set_http_proxy_user(bgav_options_t* opt, const char * user);
411 
420 BGAV_PUBLIC
421 void bgav_options_set_http_proxy_pass(bgav_options_t* opt, const char * pass);
422 
431 BGAV_PUBLIC
433 
434 /* Set FTP options */
435 
442 BGAV_PUBLIC
443 void bgav_options_set_ftp_anonymous(bgav_options_t* opt, int enable);
444 
453 BGAV_PUBLIC
454 void bgav_options_set_ftp_anonymous_password(bgav_options_t* opt, const char* pass);
455 
467 BGAV_PUBLIC
469  const char* encoding);
470 
481 BGAV_PUBLIC
483  int audio_dynrange);
484 
485 
499 BGAV_PUBLIC
501 
513 BGAV_PUBLIC
515 
525 BGAV_PUBLIC
527 
543 BGAV_PUBLIC
545  int seek_subtitles);
546 
556 BGAV_PUBLIC
558  int pp_level);
559 
568 BGAV_PUBLIC
570  float pp_level);
571 
580 BGAV_PUBLIC
581 void bgav_options_set_threads(bgav_options_t * opt, int threads);
582 
583 
595 BGAV_PUBLIC
597  const char * file);
598 
610 BGAV_PUBLIC
612  int prefer);
613 
620 BGAV_PUBLIC
622  int datetime);
623 
633 BGAV_PUBLIC
635  int factor);
636 
645 BGAV_PUBLIC
647  int vdpau);
648 
657 BGAV_PUBLIC
659  int enable);
660 
669 BGAV_PUBLIC
671  int enable);
672 
673 
682 BGAV_PUBLIC
684  int enable);
685 
686 
693 typedef enum
694  {
695  BGAV_LOG_DEBUG = (1<<0),
696  BGAV_LOG_WARNING = (1<<1),
697  BGAV_LOG_ERROR = (1<<2),
698  BGAV_LOG_INFO = (1<<3)
700 
709 typedef void (*bgav_log_callback)(void*data, bgav_log_level_t level,
710  const char * log_domain,
711  const char * message);
712 
720 BGAV_PUBLIC void
722  bgav_log_callback callback,
723  void * data);
724 
733 BGAV_PUBLIC void
735  int level);
736 
737 
738 
739 /* Set callbacks */
740 
751 typedef void (*bgav_metadata_change_callback)(void*data, const bgav_metadata_t * metadata);
752 
760 BGAV_PUBLIC void
763  void * data);
764 
774 typedef void (*bgav_buffer_callback)(void*data, float percentage);
775 
783 BGAV_PUBLIC void
785  bgav_buffer_callback callback,
786  void * data);
787 
799 typedef int (*bgav_user_pass_callback)(void*data, const char * resource,
800  char ** username, char ** password);
801 
813 BGAV_PUBLIC void
815  bgav_user_pass_callback callback,
816  void * data);
817 
828 typedef void (*bgav_aspect_callback)(void*data, int stream,
829  int pixel_width, int pixel_height);
830 
831 
839 BGAV_PUBLIC void
841  bgav_aspect_callback callback,
842  void * data);
843 
851 typedef void (*bgav_index_callback)(void*data, float percentage);
852 
860 BGAV_PUBLIC void
862  bgav_index_callback callback,
863  void * data);
864 
865 
866 /* Device description */
867 
885 typedef struct
886  {
887  char * device;
888  char * name;
890 
891 /* Scan for devices */
892 
900 BGAV_PUBLIC
902 
910 BGAV_PUBLIC
911 int bgav_check_device_vcd(const char * device, char ** name);
912 
920 BGAV_PUBLIC
922 
930 BGAV_PUBLIC
931 int bgav_check_device_dvd(const char * device, char ** name);
932 
940 BGAV_PUBLIC
942 
950 BGAV_PUBLIC
951 int bgav_check_device_dvb(const char * device, char ** name);
952 
959 BGAV_PUBLIC
961 
968 BGAV_PUBLIC
969 int bgav_eject_disc(const char * device);
970 
977 BGAV_PUBLIC
978 const char * bgav_get_disc_name(bgav_t * bgav);
979 
980 /******************************************************
981  * Open
982  ******************************************************/
983 
984 /* Open a file or URL, return 1 on success */
985 
993 BGAV_PUBLIC
994 int bgav_open(bgav_t * bgav, const char * location);
995 
1003 BGAV_PUBLIC
1004 int bgav_open_vcd(bgav_t * bgav, const char * location);
1005 
1013 BGAV_PUBLIC
1014 int bgav_open_dvd(bgav_t * bgav, const char * location);
1015 
1027 BGAV_PUBLIC
1028 int bgav_open_dvb(bgav_t * bgav, const char * location);
1029 
1030 
1040 BGAV_PUBLIC
1041 int bgav_open_fd(bgav_t * bgav, int fd,
1042  int64_t total_size,
1043  const char * mimetype);
1044 
1057 BGAV_PUBLIC
1058 int bgav_open_callbacks(bgav_t * bgav,
1059  int (*read_callback)(void * priv, uint8_t * data, int len),
1060  int64_t (*seek_callback)(void * priv, int64_t pos, int whence),
1061  void * priv,
1062  const char * filename, const char * mimetype, int64_t total_bytes);
1063 
1064 
1065 /* Close and destroy everything */
1066 
1072 BGAV_PUBLIC
1073 void bgav_close(bgav_t * bgav);
1074 
1081 BGAV_PUBLIC
1082 gavl_edl_t * bgav_get_edl(bgav_t * bgav);
1083 
1084 /***************************************************
1085  * Check for redirecting: You MUST check if you opened
1086  * a redirector, because reading data from redirectors
1087  * crashes
1088  * After you read the URLs, close the bgav_t object
1089  * and open a new one with one of the URLs.
1090  ***************************************************/
1091 
1114 BGAV_PUBLIC
1115 int bgav_is_redirector(bgav_t * bgav);
1116 
1123 BGAV_PUBLIC
1125 
1133 BGAV_PUBLIC
1134 const char * bgav_redirector_get_url(bgav_t * bgav, int index);
1135 
1143 BGAV_PUBLIC
1144 const char * bgav_redirector_get_name(bgav_t * bgav, int index);
1145 
1153 BGAV_PUBLIC
1154 const gavl_metadata_t * bgav_redirector_get_metadata(bgav_t * b, int index);
1155 
1156 /***************************************************
1157  * Get information about the file
1158  ***************************************************/
1159 
1173 BGAV_PUBLIC
1174 int bgav_num_tracks(bgav_t * bgav);
1175 
1182 BGAV_PUBLIC
1183 const char * bgav_get_description(bgav_t * bgav);
1184 
1192 BGAV_PUBLIC
1193 gavl_time_t bgav_get_duration(bgav_t * bgav, int track);
1194 
1195 /* Query stream numbers */
1196 
1204 BGAV_PUBLIC
1205 int bgav_num_audio_streams(bgav_t * bgav, int track);
1206 
1214 BGAV_PUBLIC
1215 int bgav_num_video_streams(bgav_t * bgav, int track);
1216 
1229 BGAV_PUBLIC
1230 int bgav_num_subtitle_streams(bgav_t * bgav, int track);
1231 
1239 BGAV_PUBLIC
1240 int bgav_num_text_streams(bgav_t * bgav, int track);
1241 
1249 BGAV_PUBLIC
1250 int bgav_num_overlay_streams(bgav_t * bgav, int track);
1251 
1252 
1253 
1261 BGAV_PUBLIC
1262 const char * bgav_get_track_name(bgav_t * bgav, int track);
1263 
1271 BGAV_PUBLIC
1272 const bgav_metadata_t * bgav_get_metadata(bgav_t * bgav,int track);
1273 
1285 BGAV_PUBLIC
1286 int bgav_select_track(bgav_t * bgav, int track);
1287 
1300 BGAV_PUBLIC
1301 int bgav_get_num_chapters(bgav_t * bgav, int track, int * timescale);
1302 
1311 BGAV_PUBLIC const char *
1312 bgav_get_chapter_name(bgav_t * bgav, int track, int chapter);
1313 
1322 BGAV_PUBLIC
1323 int64_t bgav_get_chapter_time(bgav_t * bgav, int track, int chapter);
1324 
1335 BGAV_PUBLIC
1336 const gavl_chapter_list_t * bgav_get_chapter_list(bgav_t * bgav, int track);
1337 
1338 
1354 BGAV_PUBLIC
1355 const char * bgav_get_audio_language(bgav_t * bgav, int stream);
1356 
1364 BGAV_PUBLIC
1365 int bgav_get_audio_bitrate(bgav_t * bgav, int stream);
1366 
1374 BGAV_PUBLIC
1375 const bgav_metadata_t *
1376 bgav_get_audio_metadata(bgav_t * bgav, int stream);
1377 
1385 BGAV_PUBLIC
1386 const char * bgav_get_subtitle_language(bgav_t * bgav, int stream);
1387 
1395 BGAV_PUBLIC
1396 const bgav_metadata_t *
1397 bgav_get_subtitle_metadata(bgav_t * bgav, int stream);
1398 
1406 BGAV_PUBLIC
1407 const bgav_metadata_t *
1408 bgav_get_text_metadata(bgav_t * b, int stream);
1409 
1417 BGAV_PUBLIC
1418 const bgav_metadata_t *
1419 bgav_get_overlay_metadata(bgav_t * b, int stream);
1420 
1421 
1429 BGAV_PUBLIC
1430 const bgav_metadata_t *
1431 bgav_get_video_metadata(bgav_t * bgav, int stream);
1432 
1433 
1441 typedef enum
1442  {
1447  }
1449 
1480 BGAV_PUBLIC
1481 int bgav_get_audio_compression_info(bgav_t * bgav, int stream,
1482  gavl_compression_info_t * info);
1483 
1496 BGAV_PUBLIC
1497 int bgav_get_video_compression_info(bgav_t * bgav, int stream,
1498  gavl_compression_info_t * info);
1499 
1512 BGAV_PUBLIC
1513 int bgav_get_overlay_compression_info(bgav_t * bgav, int stream,
1514  gavl_compression_info_t * info);
1515 
1516 
1528 BGAV_PUBLIC
1529 int bgav_read_audio_packet(bgav_t * bgav, int stream, gavl_packet_t * p);
1530 
1540 BGAV_PUBLIC
1541 gavl_packet_source_t *
1542 bgav_get_audio_packet_source(bgav_t * bgav, int stream);
1543 
1544 
1556 BGAV_PUBLIC
1557 int bgav_read_video_packet(bgav_t * bgav, int stream, gavl_packet_t * p);
1558 
1568 BGAV_PUBLIC
1569 gavl_packet_source_t *
1570 bgav_get_video_packet_source(bgav_t * bgav, int stream);
1571 
1581 BGAV_PUBLIC
1582 gavl_packet_source_t *
1583 bgav_get_text_packet_source(bgav_t * bgav, int stream);
1584 
1592 BGAV_PUBLIC
1593 gavl_packet_source_t *
1594 bgav_get_overlay_packet_source(bgav_t * bgav, int stream);
1595 
1596 
1607 BGAV_PUBLIC
1608 int bgav_set_audio_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
1609 
1620 BGAV_PUBLIC
1621 int bgav_set_video_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
1622 
1633 BGAV_PUBLIC
1634 int bgav_set_subtitle_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
1635 
1646 BGAV_PUBLIC
1647 int bgav_set_text_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
1648 
1659 BGAV_PUBLIC
1660 int bgav_set_overlay_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
1661 
1662 /***************************************************
1663  * Stream handling functions
1664  ***************************************************/
1665 
1666 /*
1667  * You MUST these, if you want to decode anything.
1668  * After bgav_open(), all streams are switched off by
1669  * default
1670  */
1671 
1672 
1686 BGAV_PUBLIC
1687 int bgav_start(bgav_t * bgav);
1688 
1704 BGAV_PUBLIC
1705 const gavl_audio_format_t * bgav_get_audio_format(bgav_t * bgav, int stream);
1706 
1723 BGAV_PUBLIC
1724 const gavl_video_format_t * bgav_get_video_format(bgav_t * bgav, int stream);
1725 
1738 BGAV_PUBLIC
1739 const gavl_video_format_t * bgav_get_overlay_format(bgav_t * bgav, int stream);
1740 
1752 BGAV_PUBLIC
1753 int bgav_get_text_timescale(bgav_t * bgav, int stream);
1754 
1755 
1775 BGAV_PUBLIC
1776 gavl_frame_table_t * bgav_get_frame_table(bgav_t * bgav, int stream);
1777 
1778 
1796 BGAV_PUBLIC const gavl_video_format_t *
1797 bgav_get_subtitle_format(bgav_t * bgav, int stream);
1798 
1809 BGAV_PUBLIC
1810 int bgav_subtitle_is_text(bgav_t * bgav, int stream);
1811 
1823 BGAV_PUBLIC
1824 const char * bgav_get_audio_description(bgav_t * bgav, int stream);
1825 
1840 BGAV_PUBLIC
1841 const char * bgav_get_audio_info(bgav_t * bgav, int stream);
1842 
1843 
1855 BGAV_PUBLIC
1856 const char * bgav_get_video_description(bgav_t * bgav, int stream);
1857 
1869 BGAV_PUBLIC
1870 const char * bgav_get_subtitle_description(bgav_t * bgav, int stream);
1871 
1872 
1887 BGAV_PUBLIC
1888 const char * bgav_get_subtitle_info(bgav_t * bgav, int stream);
1889 
1899 BGAV_PUBLIC
1900 int bgav_can_pause(bgav_t * bgav);
1901 
1902 /***************************************************
1903  * Decoding functions
1904  ***************************************************/
1905 
1927 BGAV_PUBLIC
1928 int bgav_video_has_still(bgav_t * bgav, int stream);
1929 
1938 BGAV_PUBLIC
1939 int bgav_read_video(bgav_t * bgav, gavl_video_frame_t * frame, int stream);
1940 
1954 BGAV_PUBLIC
1955 void bgav_skip_video(bgav_t * bgav, int stream,
1956  int64_t * time, int scale,
1957  int exact);
1958 
1972 BGAV_PUBLIC
1973 gavl_video_source_t * bgav_get_video_source(bgav_t * bgav, int stream);
1974 
1983 BGAV_PUBLIC
1984 gavl_video_source_t * bgav_get_overlay_source(bgav_t * bgav, int stream);
1985 
1986 
1996 BGAV_PUBLIC
1997 int bgav_read_audio(bgav_t * bgav, gavl_audio_frame_t * frame, int stream,
1998  int num_samples);
1999 
2012 BGAV_PUBLIC
2013 gavl_audio_source_t * bgav_get_audio_source(bgav_t * bgav, int stream);
2014 
2015 
2016 
2028 BGAV_PUBLIC
2029 int bgav_has_subtitle(bgav_t * bgav, int stream);
2030 
2046 BGAV_PUBLIC
2047 int bgav_read_subtitle_overlay(bgav_t * bgav, gavl_overlay_t * ovl, int stream);
2048 
2068 BGAV_PUBLIC
2069 int bgav_read_subtitle_text(bgav_t * bgav, char ** ret, int *ret_alloc,
2070  int64_t * start_time, int64_t * duration,
2071  int stream);
2072 
2073 /***************************************************
2074  * Seek to a timestamp. This also resyncs all streams
2075  ***************************************************/
2076 
2113 BGAV_PUBLIC
2114 int bgav_can_seek(bgav_t * bgav);
2115 
2124 BGAV_PUBLIC
2125 void bgav_seek(bgav_t * bgav, gavl_time_t * time);
2126 
2127 
2151 BGAV_PUBLIC
2152 void bgav_seek_scaled(bgav_t * bgav, int64_t * time, int scale);
2153 
2158 #define BGAV_TIMESTAMP_UNDEFINED GAVL_TIME_UNDEFINED // Don't change this
2159 
2175 BGAV_PUBLIC
2176 int bgav_can_seek_sample(bgav_t * bgav);
2177 
2178 
2191 BGAV_PUBLIC
2192 int64_t bgav_audio_duration(bgav_t * bgav, int stream);
2193 
2205 BGAV_PUBLIC
2206 int64_t bgav_audio_start_time(bgav_t * bgav, int stream);
2207 
2220 BGAV_PUBLIC
2221 int64_t bgav_video_duration(bgav_t * bgav, int stream);
2222 
2234 BGAV_PUBLIC
2235 int64_t bgav_video_start_time(bgav_t * bgav, int stream);
2236 
2237 
2247 BGAV_PUBLIC
2248 int64_t bgav_subtitle_duration(bgav_t * bgav, int stream);
2249 
2259 BGAV_PUBLIC
2260 int64_t bgav_text_duration(bgav_t * bgav, int stream);
2261 
2271 BGAV_PUBLIC
2272 int64_t bgav_overlay_duration(bgav_t * bgav, int stream);
2273 
2274 
2275 
2289 BGAV_PUBLIC
2290 void bgav_seek_audio(bgav_t * bgav, int stream, int64_t sample);
2291 
2305 BGAV_PUBLIC
2306 void bgav_seek_video(bgav_t * bgav, int stream, int64_t time);
2307 
2323 BGAV_PUBLIC
2324 int64_t bgav_video_keyframe_before(bgav_t * bgav, int stream, int64_t time);
2325 
2341 BGAV_PUBLIC
2342 int64_t bgav_video_keyframe_after(bgav_t * bgav, int stream, int64_t time);
2343 
2344 
2355 BGAV_PUBLIC
2356 void bgav_seek_subtitle(bgav_t * bgav, int stream, int64_t time);
2357 
2368 BGAV_PUBLIC
2369 void bgav_seek_text(bgav_t * bgav, int stream, int64_t time);
2370 
2381 BGAV_PUBLIC
2382 void bgav_seek_overlay(bgav_t * bgav, int stream, int64_t time);
2383 
2384 
2402 typedef struct bgav_stream_decoder_s bgav_stream_decoder_t;
2403 
2408 BGAV_PUBLIC
2410 
2416 BGAV_PUBLIC bgav_options_t *
2418 
2435 BGAV_PUBLIC gavl_audio_source_t *
2437  gavl_packet_source_t * src,
2438  const gavl_compression_info_t * ci,
2439  const gavl_audio_format_t * fmt,
2440  gavl_metadata_t * m);
2441 
2458 BGAV_PUBLIC gavl_video_source_t *
2460  gavl_packet_source_t * src,
2461  const gavl_compression_info_t * ci,
2462  const gavl_video_format_t * fmt,
2463  gavl_metadata_t * m);
2464 
2481 BGAV_PUBLIC gavl_video_source_t *
2483  gavl_packet_source_t * src,
2484  const gavl_compression_info_t * ci,
2485  const gavl_video_format_t * fmt,
2486  gavl_metadata_t * m);
2487 
2498 BGAV_PUBLIC int64_t
2500 
2507 BGAV_PUBLIC void
2509 
2514 BGAV_PUBLIC void
2516 
2526 BGAV_PUBLIC gavl_codec_id_t *
2528 
2537 BGAV_PUBLIC
2539 
2540 
2546 /***************************************************
2547  * Debugging functions
2548  ***************************************************/
2549 
2558 BGAV_PUBLIC
2559 void bgav_dump(bgav_t * bgav);
2560 
2561 /* Dump infos about the installed codecs */
2562 
2570 BGAV_PUBLIC
2571 void bgav_codecs_dump();
2572 
2573 /* Dump known media formats */
2574 
2582 BGAV_PUBLIC
2583 void bgav_formats_dump();
2584 
2592 BGAV_PUBLIC
2593 void bgav_inputs_dump();
2594 
2602 BGAV_PUBLIC
2603 void bgav_redirectors_dump();
2604 
2612 BGAV_PUBLIC
2613 void bgav_subreaders_dump();
2614 
2615 
2616 #ifdef __cplusplus
2617 }
2618 #endif
2619