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 - 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 /* Public entry points */
23 
29 #include <gavl/gavl.h>
30 #include <gavl/compression.h>
31 #include <gavl/metadata.h>
32 
33 #include "bgavdefs.h" // This is ugly, but works
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
43 typedef struct bgav_edl_s bgav_edl_t;
44 
78 typedef struct bgav_s bgav_t;
79 
85 BGAV_PUBLIC
87 
118 typedef gavl_metadata_t bgav_metadata_t;
119 
126 BGAV_PUBLIC
127 const char * bgav_metadata_get_author(const bgav_metadata_t*metadata);
128 
135 BGAV_PUBLIC
136 const char * bgav_metadata_get_title(const bgav_metadata_t * metadata);
137 
144 BGAV_PUBLIC
145 const char * bgav_metadata_get_comment(const bgav_metadata_t * metadata);
146 
153 BGAV_PUBLIC
154 const char * bgav_metadata_get_copyright(const bgav_metadata_t * metadata);
155 
162 BGAV_PUBLIC
163 const char * bgav_metadata_get_album(const bgav_metadata_t * metadata);
164 
171 BGAV_PUBLIC
172 const char * bgav_metadata_get_artist(const bgav_metadata_t * metadata);
173 
180 BGAV_PUBLIC
181 const char * bgav_metadata_get_albumartist(const bgav_metadata_t * metadata);
182 
189 BGAV_PUBLIC
190 const char * bgav_metadata_get_genre(const bgav_metadata_t * metadata);
191 
198 BGAV_PUBLIC
199 const char * bgav_metadata_get_date(const bgav_metadata_t * metadata);
200 
207 BGAV_PUBLIC
208 int bgav_metadata_get_track(const bgav_metadata_t * metadata);
209 
210 /***************************************************
211  * Housekeeping Functions
212  ***************************************************/
213 
214 /***************************************************
215  * Set parameters
216  ***************************************************/
217 
218 
223 typedef struct bgav_options_s bgav_options_t;
224 
234 BGAV_PUBLIC
236 
251 BGAV_PUBLIC
253 
263 BGAV_PUBLIC
265 
272 BGAV_PUBLIC
273 void bgav_options_copy(bgav_options_t * dst, const bgav_options_t * src);
274 
284 BGAV_PUBLIC
285 void bgav_options_set_connect_timeout(bgav_options_t * opt, int timeout);
286 
296 BGAV_PUBLIC
297 void bgav_options_set_read_timeout(bgav_options_t * opt, int timeout);
298 
313 BGAV_PUBLIC
315 
325 BGAV_PUBLIC
326 void bgav_options_set_rtp_try_tcp(bgav_options_t * opt, int enable);
327 
337 BGAV_PUBLIC
338 void bgav_options_set_network_bandwidth(bgav_options_t * opt, int bandwidth);
339 
349 BGAV_PUBLIC
351 
352 /* HTTP Options */
353 
364 BGAV_PUBLIC
365 void bgav_options_set_http_use_proxy(bgav_options_t* opt, int enable);
366 
376 BGAV_PUBLIC
377 void bgav_options_set_http_proxy_host(bgav_options_t* opt, const char * host);
378 
388 BGAV_PUBLIC
390 
401 BGAV_PUBLIC
402 void bgav_options_set_http_proxy_auth(bgav_options_t* opt, int enable);
403 
412 BGAV_PUBLIC
413 void bgav_options_set_http_proxy_user(bgav_options_t* opt, const char * user);
414 
423 BGAV_PUBLIC
424 void bgav_options_set_http_proxy_pass(bgav_options_t* opt, const char * pass);
425 
434 BGAV_PUBLIC
436 
437 /* Set FTP options */
438 
445 BGAV_PUBLIC
446 void bgav_options_set_ftp_anonymous(bgav_options_t* opt, int enable);
447 
456 BGAV_PUBLIC
457 void bgav_options_set_ftp_anonymous_password(bgav_options_t* opt, const char* pass);
458 
470 BGAV_PUBLIC
472  const char* encoding);
473 
484 BGAV_PUBLIC
486  int audio_dynrange);
487 
488 
502 BGAV_PUBLIC
504 
516 BGAV_PUBLIC
518 
528 BGAV_PUBLIC
530 
546 BGAV_PUBLIC
548  int seek_subtitles);
549 
559 BGAV_PUBLIC
561  int pp_level);
562 
571 BGAV_PUBLIC
573  float pp_level);
574 
583 BGAV_PUBLIC
584 void bgav_options_set_threads(bgav_options_t * opt, int threads);
585 
586 
598 BGAV_PUBLIC
600  const char * file);
601 
613 BGAV_PUBLIC
615  int prefer);
616 
623 BGAV_PUBLIC
625  int datetime);
626 
636 BGAV_PUBLIC
638  int factor);
639 
648 BGAV_PUBLIC
650  int vdpau);
651 
660 BGAV_PUBLIC
662  int enable);
663 
672 BGAV_PUBLIC
674  int enable);
675 
676 
677 
684 typedef enum
685  {
686  BGAV_LOG_DEBUG = (1<<0),
687  BGAV_LOG_WARNING = (1<<1),
688  BGAV_LOG_ERROR = (1<<2),
689  BGAV_LOG_INFO = (1<<3)
691 
700 typedef void (*bgav_log_callback)(void*data, bgav_log_level_t level,
701  const char * log_domain,
702  const char * message);
703 
711 BGAV_PUBLIC void
713  bgav_log_callback callback,
714  void * data);
715 
724 BGAV_PUBLIC void
726  int level);
727 
728 
729 
730 /* Set callbacks */
731 
741 typedef void (*bgav_name_change_callback)(void*data, const char * name);
742 
750 BGAV_PUBLIC void
752  bgav_name_change_callback callback,
753  void * data);
754 
765 typedef void (*bgav_metadata_change_callback)(void*data, const bgav_metadata_t * metadata);
766 
774 BGAV_PUBLIC void
777  void * data);
778 
788 typedef void (*bgav_buffer_callback)(void*data, float percentage);
789 
797 BGAV_PUBLIC void
799  bgav_buffer_callback callback,
800  void * data);
801 
813 typedef int (*bgav_user_pass_callback)(void*data, const char * resource,
814  char ** username, char ** password);
815 
827 BGAV_PUBLIC void
829  bgav_user_pass_callback callback,
830  void * data);
831 
842 typedef void (*bgav_aspect_callback)(void*data, int stream,
843  int pixel_width, int pixel_height);
844 
845 
853 BGAV_PUBLIC void
855  bgav_aspect_callback callback,
856  void * data);
857 
865 typedef void (*bgav_index_callback)(void*data, float percentage);
866 
874 BGAV_PUBLIC void
876  bgav_index_callback callback,
877  void * data);
878 
879 
880 /* Device description */
881 
899 typedef struct
900  {
901  char * device;
902  char * name;
904 
905 /* Scan for devices */
906 
914 BGAV_PUBLIC
916 
924 BGAV_PUBLIC
925 int bgav_check_device_vcd(const char * device, char ** name);
926 
934 BGAV_PUBLIC
936 
944 BGAV_PUBLIC
945 int bgav_check_device_dvd(const char * device, char ** name);
946 
954 BGAV_PUBLIC
956 
964 BGAV_PUBLIC
965 int bgav_check_device_dvb(const char * device, char ** name);
966 
973 BGAV_PUBLIC
975 
982 BGAV_PUBLIC
983 int bgav_eject_disc(const char * device);
984 
991 BGAV_PUBLIC
992 const char * bgav_get_disc_name(bgav_t * bgav);
993 
994 /******************************************************
995  * Open
996  ******************************************************/
997 
998 /* Open a file or URL, return 1 on success */
999 
1007 BGAV_PUBLIC
1008 int bgav_open(bgav_t * bgav, const char * location);
1009 
1017 BGAV_PUBLIC
1018 int bgav_open_vcd(bgav_t * bgav, const char * location);
1019 
1027 BGAV_PUBLIC
1028 int bgav_open_dvd(bgav_t * bgav, const char * location);
1029 
1041 BGAV_PUBLIC
1042 int bgav_open_dvb(bgav_t * bgav, const char * location);
1043 
1044 
1054 BGAV_PUBLIC
1055 int bgav_open_fd(bgav_t * bgav, int fd,
1056  int64_t total_size,
1057  const char * mimetype);
1058 
1071 BGAV_PUBLIC
1072 int bgav_open_callbacks(bgav_t * bgav,
1073  int (*read_callback)(void * priv, uint8_t * data, int len),
1074  int64_t (*seek_callback)(void * priv, uint64_t pos, int whence),
1075  void * priv,
1076  const char * filename, const char * mimetype, int64_t total_bytes);
1077 
1078 
1079 /* Close and destroy everything */
1080 
1086 BGAV_PUBLIC
1087 void bgav_close(bgav_t * bgav);
1088 
1113 typedef struct
1114  {
1115  char * url;
1116 
1117  int track;
1118  int stream;
1120 
1121  int64_t src_time;
1122 
1123  /* Time and duration within the destination in destination
1124  timescale */
1125  int64_t dst_time;
1126  int64_t dst_duration;
1127 
1128  /* */
1129  int32_t speed_num;
1130  int32_t speed_den;
1131 
1133 
1137 typedef struct
1138  {
1143 
1147 typedef struct
1148  {
1149  char * name;
1150  bgav_metadata_t * metadata;
1151 
1154 
1157 
1160 
1163 
1164  } bgav_edl_track_t;
1165 
1170  {
1173  char * url;
1174  };
1175 
1182 BGAV_PUBLIC
1183 bgav_edl_t * bgav_get_edl(bgav_t * bgav);
1184 
1189 BGAV_PUBLIC
1190 void bgav_edl_dump(const bgav_edl_t * e);
1191 
1196 /***************************************************
1197  * Check for redirecting: You MUST check if you opened
1198  * a redirector, because reading data from redirectors
1199  * crashes
1200  * After you read the URLs, close the bgav_t object
1201  * and open a new one with one of the URLs.
1202  ***************************************************/
1203 
1226 BGAV_PUBLIC
1227 int bgav_is_redirector(bgav_t * bgav);
1228 
1235 BGAV_PUBLIC
1237 
1245 BGAV_PUBLIC
1246 const char * bgav_redirector_get_url(bgav_t * bgav, int index);
1247 
1255 BGAV_PUBLIC
1256 const char * bgav_redirector_get_name(bgav_t * bgav, int index);
1257 
1258 /***************************************************
1259  * Get information about the file
1260  ***************************************************/
1261 
1275 BGAV_PUBLIC
1276 int bgav_num_tracks(bgav_t * bgav);
1277 
1284 BGAV_PUBLIC
1285 const char * bgav_get_description(bgav_t * bgav);
1286 
1294 BGAV_PUBLIC
1295 gavl_time_t bgav_get_duration(bgav_t * bgav, int track);
1296 
1297 /* Query stream numbers */
1298 
1306 BGAV_PUBLIC
1307 int bgav_num_audio_streams(bgav_t * bgav, int track);
1308 
1316 BGAV_PUBLIC
1317 int bgav_num_video_streams(bgav_t * bgav, int track);
1318 
1326 BGAV_PUBLIC
1327 int bgav_num_subtitle_streams(bgav_t * bgav, int track);
1328 
1329 
1337 BGAV_PUBLIC
1338 const char * bgav_get_track_name(bgav_t * bgav, int track);
1339 
1347 BGAV_PUBLIC
1348 const bgav_metadata_t * bgav_get_metadata(bgav_t * bgav,int track);
1349 
1361 BGAV_PUBLIC
1362 int bgav_select_track(bgav_t * bgav, int track);
1363 
1376 BGAV_PUBLIC
1377 int bgav_get_num_chapters(bgav_t * bgav, int track, int * timescale);
1378 
1387 BGAV_PUBLIC const char *
1388 bgav_get_chapter_name(bgav_t * bgav, int track, int chapter);
1389 
1398 BGAV_PUBLIC
1399 int64_t bgav_get_chapter_time(bgav_t * bgav, int track, int chapter);
1400 
1416 BGAV_PUBLIC
1417 const char * bgav_get_audio_language(bgav_t * bgav, int stream);
1418 
1426 BGAV_PUBLIC
1427 int bgav_get_audio_bitrate(bgav_t * bgav, int stream);
1428 
1436 BGAV_PUBLIC
1437 const bgav_metadata_t *
1438 bgav_get_audio_metadata(bgav_t * bgav, int stream);
1439 
1447 BGAV_PUBLIC
1448 const char * bgav_get_subtitle_language(bgav_t * bgav, int stream);
1449 
1457 BGAV_PUBLIC
1458 const bgav_metadata_t *
1459 bgav_get_subtitle_metadata(bgav_t * bgav, int stream);
1460 
1468 BGAV_PUBLIC
1469 const bgav_metadata_t *
1470 bgav_get_video_metadata(bgav_t * bgav, int stream);
1471 
1472 
1480 typedef enum
1481  {
1486  }
1488 
1519 BGAV_PUBLIC
1520 int bgav_get_audio_compression_info(bgav_t * bgav, int stream,
1521  gavl_compression_info_t * info);
1522 
1535 BGAV_PUBLIC
1536 int bgav_get_video_compression_info(bgav_t * bgav, int stream,
1537  gavl_compression_info_t * info);
1538 
1550 BGAV_PUBLIC
1551 int bgav_read_audio_packet(bgav_t * bgav, int stream, gavl_packet_t * p);
1552 
1564 BGAV_PUBLIC
1565 int bgav_read_video_packet(bgav_t * bgav, int stream, gavl_packet_t * p);
1566 
1567 
1568 
1579 BGAV_PUBLIC
1580 int bgav_set_audio_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
1581 
1592 BGAV_PUBLIC
1593 int bgav_set_video_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
1594 
1605 BGAV_PUBLIC
1606 int bgav_set_subtitle_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
1607 
1608 /***************************************************
1609  * Stream handling functions
1610  ***************************************************/
1611 
1612 /*
1613  * You MUST these, if you want to decode anything.
1614  * After bgav_open(), all streams are switched off by
1615  * default
1616  */
1617 
1618 
1632 BGAV_PUBLIC
1633 int bgav_start(bgav_t * bgav);
1634 
1650 BGAV_PUBLIC
1651 const gavl_audio_format_t * bgav_get_audio_format(bgav_t * bgav, int stream);
1652 
1669 BGAV_PUBLIC
1670 const gavl_video_format_t * bgav_get_video_format(bgav_t * bgav, int stream);
1671 
1691 BGAV_PUBLIC
1692 gavl_frame_table_t * bgav_get_frame_table(bgav_t * bgav, int stream);
1693 
1694 
1712 BGAV_PUBLIC const gavl_video_format_t *
1713 bgav_get_subtitle_format(bgav_t * bgav, int stream);
1714 
1725 BGAV_PUBLIC
1726 int bgav_subtitle_is_text(bgav_t * bgav, int stream);
1727 
1739 BGAV_PUBLIC
1740 const char * bgav_get_audio_description(bgav_t * bgav, int stream);
1741 
1756 BGAV_PUBLIC
1757 const char * bgav_get_audio_info(bgav_t * bgav, int stream);
1758 
1759 
1771 BGAV_PUBLIC
1772 const char * bgav_get_video_description(bgav_t * bgav, int stream);
1773 
1785 BGAV_PUBLIC
1786 const char * bgav_get_subtitle_description(bgav_t * bgav, int stream);
1787 
1788 
1803 BGAV_PUBLIC
1804 const char * bgav_get_subtitle_info(bgav_t * bgav, int stream);
1805 
1815 BGAV_PUBLIC
1816 int bgav_can_pause(bgav_t * bgav);
1817 
1818 /***************************************************
1819  * Decoding functions
1820  ***************************************************/
1821 
1843 BGAV_PUBLIC
1844 int bgav_video_has_still(bgav_t * bgav, int stream);
1845 
1854 BGAV_PUBLIC
1855 int bgav_read_video(bgav_t * bgav, gavl_video_frame_t * frame, int stream);
1856 
1870 BGAV_PUBLIC
1871 void bgav_skip_video(bgav_t * bgav, int stream,
1872  int64_t * time, int scale,
1873  int exact);
1874 
1875 
1885 BGAV_PUBLIC
1886 int bgav_read_audio(bgav_t * bgav, gavl_audio_frame_t * frame, int stream,
1887  int num_samples);
1888 
1900 BGAV_PUBLIC
1901 int bgav_has_subtitle(bgav_t * bgav, int stream);
1902 
1918 BGAV_PUBLIC
1919 int bgav_read_subtitle_overlay(bgav_t * bgav, gavl_overlay_t * ovl, int stream);
1920 
1940 BGAV_PUBLIC
1941 int bgav_read_subtitle_text(bgav_t * bgav, char ** ret, int *ret_alloc,
1942  int64_t * start_time, int64_t * duration,
1943  int stream);
1944 
1945 /***************************************************
1946  * Seek to a timestamp. This also resyncs all streams
1947  ***************************************************/
1948 
1985 BGAV_PUBLIC
1986 int bgav_can_seek(bgav_t * bgav);
1987 
1996 BGAV_PUBLIC
1997 void bgav_seek(bgav_t * bgav, gavl_time_t * time);
1998 
1999 
2023 BGAV_PUBLIC
2024 void bgav_seek_scaled(bgav_t * bgav, int64_t * time, int scale);
2025 
2030 #define BGAV_TIMESTAMP_UNDEFINED GAVL_TIME_UNDEFINED // Don't change this
2031 
2047 BGAV_PUBLIC
2048 int bgav_can_seek_sample(bgav_t * bgav);
2049 
2050 
2063 BGAV_PUBLIC
2064 int64_t bgav_audio_duration(bgav_t * bgav, int stream);
2065 
2077 BGAV_PUBLIC
2078 int64_t bgav_audio_start_time(bgav_t * bgav, int stream);
2079 
2092 BGAV_PUBLIC
2093 int64_t bgav_video_duration(bgav_t * bgav, int stream);
2094 
2106 BGAV_PUBLIC
2107 int64_t bgav_video_start_time(bgav_t * bgav, int stream);
2108 
2109 
2119 BGAV_PUBLIC
2120 int64_t bgav_subtitle_duration(bgav_t * bgav, int stream);
2121 
2135 BGAV_PUBLIC
2136 void bgav_seek_audio(bgav_t * bgav, int stream, int64_t sample);
2137 
2151 BGAV_PUBLIC
2152 void bgav_seek_video(bgav_t * bgav, int stream, int64_t time);
2153 
2169 BGAV_PUBLIC
2170 int64_t bgav_video_keyframe_before(bgav_t * bgav, int stream, int64_t time);
2171 
2187 BGAV_PUBLIC
2188 int64_t bgav_video_keyframe_after(bgav_t * bgav, int stream, int64_t time);
2189 
2190 
2201 BGAV_PUBLIC
2202 void bgav_seek_subtitle(bgav_t * bgav, int stream, int64_t time);
2203 
2204 
2205 /***************************************************
2206  * Debugging functions
2207  ***************************************************/
2208 
2217 BGAV_PUBLIC
2218 void bgav_dump(bgav_t * bgav);
2219 
2220 /* Dump infos about the installed codecs */
2221 
2229 BGAV_PUBLIC
2230 void bgav_codecs_dump();
2231 
2232 /* Dump known media formats */
2233 
2241 BGAV_PUBLIC
2242 void bgav_formats_dump();
2243 
2251 BGAV_PUBLIC
2252 void bgav_inputs_dump();
2253 
2261 BGAV_PUBLIC
2262 void bgav_redirectors_dump();
2263 
2271 BGAV_PUBLIC
2272 void bgav_subreaders_dump();
2273 
2274 
2275 #ifdef __cplusplus
2276 }
2277 #endif
2278