gmerlin-avdecoder
avdec.h
Go to the documentation of this file.
00001 /*****************************************************************
00002  * gmerlin-avdecoder - a general purpose multimedia decoding library
00003  *
00004  * Copyright (c) 2001 - 2011 Members of the Gmerlin project
00005  * gmerlin-general@lists.sourceforge.net
00006  * http://gmerlin.sourceforge.net
00007  *
00008  * This program is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  * *****************************************************************/
00021 
00022 /* Public entry points */
00023 
00029 #include <gavl/gavl.h>
00030 #include <gavl/compression.h>
00031 #include "bgavdefs.h" // This is ugly, but works
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00041 typedef struct bgav_edl_s bgav_edl_t;
00042 
00076 typedef struct bgav_s bgav_t;
00077 
00083 BGAV_PUBLIC
00084 bgav_t * bgav_create();
00085 
00116 typedef struct bgav_metadata_s bgav_metadata_t;
00117 
00124 BGAV_PUBLIC
00125 const char * bgav_metadata_get_author(const bgav_metadata_t*metadata);
00126 
00133 BGAV_PUBLIC
00134 const char * bgav_metadata_get_title(const bgav_metadata_t * metadata);
00135 
00142 BGAV_PUBLIC
00143 const char * bgav_metadata_get_comment(const bgav_metadata_t * metadata);
00144 
00151 BGAV_PUBLIC
00152 const char * bgav_metadata_get_copyright(const bgav_metadata_t * metadata);
00153 
00160 BGAV_PUBLIC
00161 const char * bgav_metadata_get_album(const bgav_metadata_t * metadata);
00162 
00169 BGAV_PUBLIC
00170 const char * bgav_metadata_get_artist(const bgav_metadata_t * metadata);
00171 
00178 BGAV_PUBLIC
00179 const char * bgav_metadata_get_genre(const bgav_metadata_t * metadata);
00180 
00187 BGAV_PUBLIC
00188 const char * bgav_metadata_get_date(const bgav_metadata_t * metadata);
00189 
00196 BGAV_PUBLIC
00197 int bgav_metadata_get_track(const bgav_metadata_t * metadata);
00198 
00199 /***************************************************
00200  * Housekeeping Functions
00201  ***************************************************/
00202 
00203 /***************************************************
00204  * Set parameters
00205  ***************************************************/
00206 
00207 
00212 typedef struct bgav_options_s bgav_options_t;
00213 
00223 BGAV_PUBLIC
00224 bgav_options_t * bgav_get_options(bgav_t * bgav);
00225 
00240 BGAV_PUBLIC
00241 bgav_options_t * bgav_options_create();
00242 
00252 BGAV_PUBLIC
00253 void bgav_options_destroy(bgav_options_t * opt);
00254 
00261 BGAV_PUBLIC
00262 void bgav_options_copy(bgav_options_t * dst, const bgav_options_t * src);
00263 
00273 BGAV_PUBLIC
00274 void bgav_options_set_connect_timeout(bgav_options_t * opt, int timeout);
00275 
00285 BGAV_PUBLIC
00286 void bgav_options_set_read_timeout(bgav_options_t * opt, int timeout);
00287 
00302 BGAV_PUBLIC
00303 void bgav_options_set_rtp_port_base(bgav_options_t*b, int p);
00304 
00314 BGAV_PUBLIC
00315 void bgav_options_set_rtp_try_tcp(bgav_options_t*b, int enable);
00316 
00326 BGAV_PUBLIC
00327 void bgav_options_set_network_bandwidth(bgav_options_t * opt, int bandwidth);
00328 
00338 BGAV_PUBLIC
00339 void bgav_options_set_network_buffer_size(bgav_options_t * opt, int size);
00340 
00341 /* HTTP Options */
00342 
00353 BGAV_PUBLIC
00354 void bgav_options_set_http_use_proxy(bgav_options_t* opt, int enable);
00355 
00365 BGAV_PUBLIC
00366 void bgav_options_set_http_proxy_host(bgav_options_t* opt, const char * host);
00367 
00377 BGAV_PUBLIC
00378 void bgav_options_set_http_proxy_port(bgav_options_t* opt, int port);
00379 
00390 BGAV_PUBLIC
00391 void bgav_options_set_http_proxy_auth(bgav_options_t* opt, int enable);
00392 
00401 BGAV_PUBLIC
00402 void bgav_options_set_http_proxy_user(bgav_options_t* opt, const char * user);
00403 
00412 BGAV_PUBLIC
00413 void bgav_options_set_http_proxy_pass(bgav_options_t* opt, const char * pass);
00414 
00423 BGAV_PUBLIC
00424 void bgav_options_set_http_shoutcast_metadata(bgav_options_t* opt, int enable);
00425 
00426 /* Set FTP options */
00427 
00434 BGAV_PUBLIC
00435 void bgav_options_set_ftp_anonymous(bgav_options_t* opt, int enable);
00436 
00445 BGAV_PUBLIC
00446 void bgav_options_set_ftp_anonymous_password(bgav_options_t* opt, const char* pass);
00447 
00459 BGAV_PUBLIC
00460 void bgav_options_set_default_subtitle_encoding(bgav_options_t* opt,
00461                                                 const char* encoding);
00462 
00473 BGAV_PUBLIC
00474 void bgav_options_set_audio_dynrange(bgav_options_t* opt,
00475                                      int audio_dynrange);
00476 
00477 
00491 BGAV_PUBLIC
00492 void bgav_options_set_sample_accurate(bgav_options_t*opt, int enable);
00493 
00505 BGAV_PUBLIC
00506 void bgav_options_set_cache_time(bgav_options_t*opt, int t);
00507 
00517 BGAV_PUBLIC
00518 void bgav_options_set_cache_size(bgav_options_t*opt, int s);
00519 
00535 BGAV_PUBLIC
00536 void bgav_options_set_seek_subtitles(bgav_options_t* opt,
00537                                     int seek_subtitles);
00538 
00548 BGAV_PUBLIC
00549 void bgav_options_set_pp_level(bgav_options_t* opt,
00550                                int pp_level);
00551 
00560 BGAV_PUBLIC
00561 void bgav_options_set_postprocessing_level(bgav_options_t* opt,
00562                                            float pp_level);
00563 
00572 BGAV_PUBLIC
00573 void bgav_options_set_threads(bgav_options_t * opt, int threads);
00574 
00575   
00587 BGAV_PUBLIC
00588 void bgav_options_set_dvb_channels_file(bgav_options_t* opt,
00589                                         const char * file);
00590 
00602 BGAV_PUBLIC
00603 void bgav_options_set_prefer_ffmpeg_demuxers(bgav_options_t* opt,
00604                                              int prefer);
00605 
00612 BGAV_PUBLIC
00613 void bgav_options_set_dv_datetime(bgav_options_t* opt,
00614                                   int datetime);
00615 
00625 BGAV_PUBLIC
00626 void bgav_options_set_shrink(bgav_options_t* opt,
00627                              int factor);
00628 
00637 BGAV_PUBLIC
00638 void bgav_options_set_vdpau(bgav_options_t* opt,
00639                             int vdpau);
00640 
00641   
00642 
00649 typedef enum
00650   {
00651     BGAV_LOG_DEBUG   = (1<<0),
00652     BGAV_LOG_WARNING = (1<<1),
00653     BGAV_LOG_ERROR   = (1<<2),
00654     BGAV_LOG_INFO    = (1<<3)
00655   } bgav_log_level_t;
00656 
00665 typedef void (*bgav_log_callback)(void*data, bgav_log_level_t level,
00666                                   const char * log_domain,
00667                                   const char * message);
00668 
00676 BGAV_PUBLIC void
00677 bgav_options_set_log_callback(bgav_options_t* opt,
00678                               bgav_log_callback callback,
00679                               void * data);
00680 
00689 BGAV_PUBLIC void
00690 bgav_options_set_log_level(bgav_options_t* opt,
00691                            int level);
00692   
00693   
00694 
00695 /* Set callbacks */
00696 
00706 typedef void (*bgav_name_change_callback)(void*data, const char * name);
00707 
00715 BGAV_PUBLIC void
00716 bgav_options_set_name_change_callback(bgav_options_t* opt,
00717                                       bgav_name_change_callback callback,
00718                                       void * data);
00719 
00730 typedef void (*bgav_metadata_change_callback)(void*data, const bgav_metadata_t * metadata);
00731 
00739 BGAV_PUBLIC void
00740 bgav_options_set_metadata_change_callback(bgav_options_t* opt,
00741                                           bgav_metadata_change_callback callback,
00742                                           void * data);
00743 
00753 typedef void (*bgav_buffer_callback)(void*data, float percentage);
00754 
00762 BGAV_PUBLIC void
00763 bgav_options_set_buffer_callback(bgav_options_t* opt,
00764                                  bgav_buffer_callback callback,
00765                                  void * data);
00766 
00778 typedef int (*bgav_user_pass_callback)(void*data, const char * resource,
00779                                        char ** username, char ** password);
00780   
00792 BGAV_PUBLIC void
00793 bgav_options_set_user_pass_callback(bgav_options_t* opt,
00794                                     bgav_user_pass_callback callback,
00795                                     void * data);
00796 
00807 typedef void (*bgav_aspect_callback)(void*data, int stream,
00808                                      int pixel_width, int pixel_height);
00809 
00810 
00818 BGAV_PUBLIC void
00819 bgav_options_set_aspect_callback(bgav_options_t* opt,
00820                                  bgav_aspect_callback callback,
00821                                  void * data);
00822 
00830 typedef void (*bgav_index_callback)(void*data, float percentage);
00831 
00839 BGAV_PUBLIC void
00840 bgav_options_set_index_callback(bgav_options_t* opt,
00841                                 bgav_index_callback callback,
00842                                 void * data);
00843 
00844 
00845 /* Device description */
00846 
00864 typedef struct
00865   {
00866   char * device; 
00867   char * name;   
00868   } bgav_device_info_t;
00869 
00870 /* Scan for devices */
00871 
00879 BGAV_PUBLIC
00880 bgav_device_info_t * bgav_find_devices_vcd();
00881 
00889 BGAV_PUBLIC
00890 int bgav_check_device_vcd(const char * device, char ** name);
00891 
00899 BGAV_PUBLIC
00900 bgav_device_info_t * bgav_find_devices_dvd();
00901 
00909 BGAV_PUBLIC
00910 int bgav_check_device_dvd(const char * device, char ** name);
00911 
00919 BGAV_PUBLIC
00920 bgav_device_info_t * bgav_find_devices_dvb();
00921 
00929 BGAV_PUBLIC
00930 int bgav_check_device_dvb(const char * device, char ** name);
00931 
00938 BGAV_PUBLIC
00939 void bgav_device_info_destroy(bgav_device_info_t * arr);
00940 
00947 BGAV_PUBLIC
00948 int bgav_eject_disc(const char * device);
00949 
00956 BGAV_PUBLIC
00957 const char * bgav_get_disc_name(bgav_t * bgav);
00958 
00959 /******************************************************
00960  * Open
00961  ******************************************************/
00962 
00963 /* Open a file or URL, return 1 on success */
00964 
00972 BGAV_PUBLIC
00973 int bgav_open(bgav_t * bgav, const char * location);
00974 
00982 BGAV_PUBLIC
00983 int bgav_open_vcd(bgav_t * bgav, const char * location);
00984 
00992 BGAV_PUBLIC
00993 int bgav_open_dvd(bgav_t * bgav, const char * location);
00994 
01006 BGAV_PUBLIC
01007 int bgav_open_dvb(bgav_t * bgav, const char * location);
01008 
01009 
01019 BGAV_PUBLIC
01020 int bgav_open_fd(bgav_t * bgav, int fd,
01021                  int64_t total_size,
01022                  const char * mimetype);
01023 
01035 BGAV_PUBLIC
01036 int bgav_open_callbacks(bgav_t * bgav,
01037                         int (*read_callback)(void * priv, uint8_t * data, int len),
01038                         int64_t (*seek_callback)(void * priv, uint64_t pos, int whence),
01039                         void * priv,
01040                         const char * filename, const char * mimetype, int64_t total_bytes);
01041  
01042 
01043 /* Close and destroy everything */
01044 
01050 BGAV_PUBLIC
01051 void bgav_close(bgav_t * bgav);
01052 
01077 typedef struct
01078   {
01079   char * url;   
01080 
01081   int track;        
01082   int stream;       
01083   int timescale;    
01084     
01085   int64_t src_time; 
01086   
01087   /* Time and duration within the destination in destination
01088      timescale */
01089   int64_t dst_time;  
01090   int64_t dst_duration; 
01091 
01092   /*  */
01093   int32_t speed_num; 
01094   int32_t speed_den; 
01095   
01096   } bgav_edl_segment_t;
01097 
01101 typedef struct
01102   {
01103   bgav_edl_segment_t * segments; 
01104   int num_segments;              
01105   int timescale;                 
01106   } bgav_edl_stream_t;
01107 
01111 typedef struct
01112   {
01113   int num_audio_streams;             
01114   bgav_edl_stream_t * audio_streams; 
01115 
01116   int num_video_streams;             
01117   bgav_edl_stream_t * video_streams; 
01118 
01119   int num_subtitle_text_streams;     
01120   bgav_edl_stream_t * subtitle_text_streams; 
01121 
01122   int num_subtitle_overlay_streams;  
01123   bgav_edl_stream_t * subtitle_overlay_streams; 
01124   
01125   } bgav_edl_track_t;
01126 
01130 struct bgav_edl_s
01131   {
01132   int num_tracks;             
01133   bgav_edl_track_t * tracks;  
01134   char * url;                 
01135   };
01136 
01143 BGAV_PUBLIC
01144 bgav_edl_t * bgav_get_edl(bgav_t * bgav);
01145 
01150 BGAV_PUBLIC
01151 void bgav_edl_dump(const bgav_edl_t * e);
01152 
01157 /***************************************************
01158  * Check for redirecting: You MUST check if you opened
01159  * a redirector, because reading data from redirectors
01160  * crashes
01161  * After you read the URLs, close the bgav_t object
01162  * and open a new one with one of the URLs.
01163  ***************************************************/
01164 
01187 BGAV_PUBLIC
01188 int bgav_is_redirector(bgav_t * bgav);
01189 
01196 BGAV_PUBLIC
01197 int bgav_redirector_get_num_urls(bgav_t * bgav);
01198 
01206 BGAV_PUBLIC
01207 const char * bgav_redirector_get_url(bgav_t * bgav, int index);
01208 
01216 BGAV_PUBLIC
01217 const char * bgav_redirector_get_name(bgav_t * bgav, int index);
01218 
01219 /***************************************************
01220  * Get information about the file
01221  ***************************************************/
01222 
01236 BGAV_PUBLIC
01237 int bgav_num_tracks(bgav_t * bgav);
01238 
01245 BGAV_PUBLIC
01246 const char * bgav_get_description(bgav_t * bgav);
01247 
01255 BGAV_PUBLIC
01256 gavl_time_t bgav_get_duration(bgav_t * bgav, int track);
01257 
01258 /* Query stream numbers */
01259 
01267 BGAV_PUBLIC
01268 int bgav_num_audio_streams(bgav_t * bgav, int track);
01269 
01277 BGAV_PUBLIC
01278 int bgav_num_video_streams(bgav_t * bgav, int track);
01279 
01287 BGAV_PUBLIC
01288 int bgav_num_subtitle_streams(bgav_t * bgav, int track);
01289 
01290 
01298 BGAV_PUBLIC
01299 const char * bgav_get_track_name(bgav_t * bgav, int track);
01300 
01308 BGAV_PUBLIC
01309 const bgav_metadata_t * bgav_get_metadata(bgav_t * bgav,int track);
01310 
01322 BGAV_PUBLIC
01323 int bgav_select_track(bgav_t * bgav, int track);
01324 
01337 BGAV_PUBLIC
01338 int bgav_get_num_chapters(bgav_t * bgav, int track, int * timescale);
01339 
01348 BGAV_PUBLIC const char *
01349 bgav_get_chapter_name(bgav_t * bgav, int track, int chapter);
01350 
01359 BGAV_PUBLIC
01360 int64_t bgav_get_chapter_time(bgav_t * bgav, int track, int chapter);
01361 
01377 BGAV_PUBLIC
01378 const char * bgav_get_audio_language(bgav_t * bgav, int stream);
01379 
01387 BGAV_PUBLIC
01388 const char * bgav_get_subtitle_language(bgav_t * bgav, int stream);
01389 
01397 typedef enum
01398   {
01399     BGAV_STREAM_MUTE    = 0,  
01400     BGAV_STREAM_DECODE  = 1, 
01401     BGAV_STREAM_PARSE   = 2, 
01402     BGAV_STREAM_READRAW = 3 
01403   }
01404 bgav_stream_action_t;
01405 
01436 BGAV_PUBLIC
01437 int bgav_get_audio_compression_info(bgav_t * bgav, int stream,
01438                                     gavl_compression_info_t * info);
01439 
01452 BGAV_PUBLIC
01453 int bgav_get_video_compression_info(bgav_t * bgav, int stream,
01454                                     gavl_compression_info_t * info);
01455 
01467 BGAV_PUBLIC
01468 int bgav_read_audio_packet(bgav_t * bgav, int stream, gavl_packet_t * p);
01469 
01481 BGAV_PUBLIC
01482 int bgav_read_video_packet(bgav_t * bgav, int stream, gavl_packet_t * p);
01483 
01484   
01485 
01496 BGAV_PUBLIC
01497 int bgav_set_audio_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
01498 
01509 BGAV_PUBLIC
01510 int bgav_set_video_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
01511 
01522 BGAV_PUBLIC
01523 int bgav_set_subtitle_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
01524 
01525 /***************************************************
01526  * Stream handling functions
01527  ***************************************************/
01528 
01529 /*
01530  *  You MUST these, if you want to decode anything.
01531  *  After bgav_open(), all streams are switched off by
01532  *  default
01533  */
01534 
01535 
01549 BGAV_PUBLIC
01550 int bgav_start(bgav_t * bgav);
01551 
01567 BGAV_PUBLIC
01568 const gavl_audio_format_t * bgav_get_audio_format(bgav_t * bgav, int stream);
01569 
01586 BGAV_PUBLIC
01587 const gavl_video_format_t * bgav_get_video_format(bgav_t * bgav, int stream);
01588 
01608 BGAV_PUBLIC
01609 gavl_frame_table_t * bgav_get_frame_table(bgav_t * bgav, int stream);
01610 
01611   
01629 BGAV_PUBLIC const gavl_video_format_t *
01630 bgav_get_subtitle_format(bgav_t * bgav, int stream);
01631 
01642 BGAV_PUBLIC
01643 int bgav_subtitle_is_text(bgav_t * bgav, int stream);
01644 
01656 BGAV_PUBLIC
01657 const char * bgav_get_audio_description(bgav_t * bgav, int stream);
01658 
01673 BGAV_PUBLIC
01674 const char * bgav_get_audio_info(bgav_t * bgav, int stream);
01675 
01676 
01688 BGAV_PUBLIC
01689 const char * bgav_get_video_description(bgav_t * bgav, int stream);
01690 
01702 BGAV_PUBLIC
01703 const char * bgav_get_subtitle_description(bgav_t * bgav, int stream);
01704 
01705 
01720 BGAV_PUBLIC
01721 const char * bgav_get_subtitle_info(bgav_t * bgav, int stream);
01722 
01732 BGAV_PUBLIC
01733 int bgav_can_pause(bgav_t * bgav);
01734 
01735 /***************************************************
01736  * Decoding functions
01737  ***************************************************/
01738 
01760 BGAV_PUBLIC
01761 int bgav_video_has_still(bgav_t * bgav, int stream);
01762   
01771 BGAV_PUBLIC
01772 int bgav_read_video(bgav_t * bgav, gavl_video_frame_t * frame, int stream);
01773 
01787 BGAV_PUBLIC
01788 void bgav_skip_video(bgav_t * bgav, int stream,
01789                      int64_t * time, int scale,
01790                      int exact);
01791 
01792   
01802 BGAV_PUBLIC
01803 int bgav_read_audio(bgav_t * bgav, gavl_audio_frame_t * frame, int stream,
01804                     int num_samples);
01805 
01817 BGAV_PUBLIC
01818 int bgav_has_subtitle(bgav_t * bgav, int stream);
01819 
01835 BGAV_PUBLIC
01836 int bgav_read_subtitle_overlay(bgav_t * bgav, gavl_overlay_t * ovl, int stream);
01837 
01857 BGAV_PUBLIC
01858 int bgav_read_subtitle_text(bgav_t * bgav, char ** ret, int *ret_alloc,
01859                             int64_t * start_time, int64_t * duration,
01860                             int stream);
01861 
01862 /***************************************************
01863  * Seek to a timestamp. This also resyncs all streams
01864  ***************************************************/
01865 
01902 BGAV_PUBLIC
01903 int bgav_can_seek(bgav_t * bgav);
01904 
01913 BGAV_PUBLIC
01914 void bgav_seek(bgav_t * bgav, gavl_time_t * time);
01915 
01916 
01940 BGAV_PUBLIC
01941 void bgav_seek_scaled(bgav_t * bgav, int64_t * time, int scale);
01942 
01947 #define BGAV_TIMESTAMP_UNDEFINED GAVL_TIME_UNDEFINED // Don't change this
01948 
01964 BGAV_PUBLIC
01965 int bgav_can_seek_sample(bgav_t * bgav);
01966 
01967 
01980 BGAV_PUBLIC
01981 int64_t bgav_audio_duration(bgav_t * bgav, int stream);
01982 
01994 BGAV_PUBLIC
01995 int64_t bgav_audio_start_time(bgav_t * bgav, int stream);
01996 
02009 BGAV_PUBLIC
02010 int64_t bgav_video_duration(bgav_t * bgav, int stream);
02011 
02023 BGAV_PUBLIC
02024 int64_t bgav_video_start_time(bgav_t * bgav, int stream);
02025 
02026 
02036 BGAV_PUBLIC
02037 int64_t bgav_subtitle_duration(bgav_t * bgav, int stream);
02038 
02052 BGAV_PUBLIC
02053 void bgav_seek_audio(bgav_t * bgav, int stream, int64_t sample);
02054 
02068 BGAV_PUBLIC
02069 void bgav_seek_video(bgav_t * bgav, int stream, int64_t time);
02070 
02086 BGAV_PUBLIC
02087 int64_t bgav_video_keyframe_before(bgav_t * bgav, int stream, int64_t time);
02088 
02104 BGAV_PUBLIC
02105 int64_t bgav_video_keyframe_after(bgav_t * bgav, int stream, int64_t time);
02106 
02107 
02118 BGAV_PUBLIC
02119 void bgav_seek_subtitle(bgav_t * bgav, int stream, int64_t time);
02120 
02121 
02122 /***************************************************
02123  * Debugging functions
02124  ***************************************************/
02125 
02134 BGAV_PUBLIC
02135 void bgav_dump(bgav_t * bgav);
02136 
02137 /* Dump infos about the installed codecs */
02138 
02146 BGAV_PUBLIC
02147 void bgav_codecs_dump();
02148 
02149 /* Dump known media formats */
02150 
02158 BGAV_PUBLIC
02159 void bgav_formats_dump();
02160 
02168 BGAV_PUBLIC
02169 void bgav_inputs_dump();
02170 
02178 BGAV_PUBLIC
02179 void bgav_redirectors_dump();
02180 
02188 BGAV_PUBLIC
02189 void bgav_subreaders_dump();
02190 
02191 
02192 #ifdef __cplusplus
02193 }
02194 #endif
02195