avdec.h

Go to the documentation of this file.
00001 /*****************************************************************
00002  * gmerlin-avdecoder - a general purpose multimedia decoding library
00003  *
00004  * Copyright (c) 2001 - 2010 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 "bgavdefs.h" // This is ugly, but works
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00040 typedef struct bgav_edl_s bgav_edl_t;
00041 
00075 typedef struct bgav_s bgav_t;
00076 
00082 BGAV_PUBLIC
00083 bgav_t * bgav_create();
00084 
00115 typedef struct bgav_metadata_s bgav_metadata_t;
00116 
00123 BGAV_PUBLIC
00124 const char * bgav_metadata_get_author(const bgav_metadata_t*metadata);
00125 
00132 BGAV_PUBLIC
00133 const char * bgav_metadata_get_title(const bgav_metadata_t * metadata);
00134 
00141 BGAV_PUBLIC
00142 const char * bgav_metadata_get_comment(const bgav_metadata_t * metadata);
00143 
00150 BGAV_PUBLIC
00151 const char * bgav_metadata_get_copyright(const bgav_metadata_t * metadata);
00152 
00159 BGAV_PUBLIC
00160 const char * bgav_metadata_get_album(const bgav_metadata_t * metadata);
00161 
00168 BGAV_PUBLIC
00169 const char * bgav_metadata_get_artist(const bgav_metadata_t * metadata);
00170 
00177 BGAV_PUBLIC
00178 const char * bgav_metadata_get_genre(const bgav_metadata_t * metadata);
00179 
00186 BGAV_PUBLIC
00187 const char * bgav_metadata_get_date(const bgav_metadata_t * metadata);
00188 
00195 BGAV_PUBLIC
00196 int bgav_metadata_get_track(const bgav_metadata_t * metadata);
00197 
00198 /***************************************************
00199  * Housekeeping Functions
00200  ***************************************************/
00201 
00202 /***************************************************
00203  * Set parameters
00204  ***************************************************/
00205 
00206 
00211 typedef struct bgav_options_s bgav_options_t;
00212 
00222 BGAV_PUBLIC
00223 bgav_options_t * bgav_get_options(bgav_t * bgav);
00224 
00239 BGAV_PUBLIC
00240 bgav_options_t * bgav_options_create();
00241 
00251 BGAV_PUBLIC
00252 void bgav_options_destroy(bgav_options_t * opt);
00253 
00260 BGAV_PUBLIC
00261 void bgav_options_copy(bgav_options_t * dst, const bgav_options_t * src);
00262 
00272 BGAV_PUBLIC
00273 void bgav_options_set_connect_timeout(bgav_options_t * opt, int timeout);
00274 
00284 BGAV_PUBLIC
00285 void bgav_options_set_read_timeout(bgav_options_t * opt, int timeout);
00286 
00301 BGAV_PUBLIC
00302 void bgav_options_set_rtp_port_base(bgav_options_t*b, int p);
00303 
00313 BGAV_PUBLIC
00314 void bgav_options_set_rtp_try_tcp(bgav_options_t*b, int enable);
00315 
00325 BGAV_PUBLIC
00326 void bgav_options_set_network_bandwidth(bgav_options_t * opt, int bandwidth);
00327 
00337 BGAV_PUBLIC
00338 void bgav_options_set_network_buffer_size(bgav_options_t * opt, int size);
00339 
00340 /* HTTP Options */
00341 
00352 BGAV_PUBLIC
00353 void bgav_options_set_http_use_proxy(bgav_options_t* opt, int enable);
00354 
00364 BGAV_PUBLIC
00365 void bgav_options_set_http_proxy_host(bgav_options_t* opt, const char * host);
00366 
00376 BGAV_PUBLIC
00377 void bgav_options_set_http_proxy_port(bgav_options_t* opt, int port);
00378 
00389 BGAV_PUBLIC
00390 void bgav_options_set_http_proxy_auth(bgav_options_t* opt, int enable);
00391 
00400 BGAV_PUBLIC
00401 void bgav_options_set_http_proxy_user(bgav_options_t* opt, const char * user);
00402 
00411 BGAV_PUBLIC
00412 void bgav_options_set_http_proxy_pass(bgav_options_t* opt, const char * pass);
00413 
00422 BGAV_PUBLIC
00423 void bgav_options_set_http_shoutcast_metadata(bgav_options_t* opt, int enable);
00424 
00425 /* Set FTP options */
00426 
00433 BGAV_PUBLIC
00434 void bgav_options_set_ftp_anonymous(bgav_options_t* opt, int enable);
00435 
00444 BGAV_PUBLIC
00445 void bgav_options_set_ftp_anonymous_password(bgav_options_t* opt, const char* pass);
00446 
00458 BGAV_PUBLIC
00459 void bgav_options_set_default_subtitle_encoding(bgav_options_t* opt,
00460                                                 const char* encoding);
00461 
00472 BGAV_PUBLIC
00473 void bgav_options_set_audio_dynrange(bgav_options_t* opt,
00474                                      int audio_dynrange);
00475 
00476 
00490 BGAV_PUBLIC
00491 void bgav_options_set_sample_accurate(bgav_options_t*opt, int enable);
00492 
00504 BGAV_PUBLIC
00505 void bgav_options_set_cache_time(bgav_options_t*opt, int t);
00506 
00516 BGAV_PUBLIC
00517 void bgav_options_set_cache_size(bgav_options_t*opt, int s);
00518 
00534 BGAV_PUBLIC
00535 void bgav_options_set_seek_subtitles(bgav_options_t* opt,
00536                                     int seek_subtitles);
00537 
00547 BGAV_PUBLIC
00548 void bgav_options_set_pp_level(bgav_options_t* opt,
00549                                int pp_level);
00550 
00559 BGAV_PUBLIC
00560 void bgav_options_set_postprocessing_level(bgav_options_t* opt,
00561                                            float pp_level);
00562 
00563   
00575 BGAV_PUBLIC
00576 void bgav_options_set_dvb_channels_file(bgav_options_t* opt,
00577                                         const char * file);
00578 
00590 BGAV_PUBLIC
00591 void bgav_options_set_prefer_ffmpeg_demuxers(bgav_options_t* opt,
00592                                              int prefer);
00593 
00600 BGAV_PUBLIC
00601 void bgav_options_set_dv_datetime(bgav_options_t* opt,
00602                                   int datetime);
00603 
00613 BGAV_PUBLIC
00614 void bgav_options_set_shrink(bgav_options_t* opt,
00615                              int factor);
00616 
00625 BGAV_PUBLIC
00626 void bgav_options_set_vdpau(bgav_options_t* opt,
00627                             int vdpau);
00628 
00629   
00630 
00637 typedef enum
00638   {
00639     BGAV_LOG_DEBUG,
00640     BGAV_LOG_WARNING,
00641     BGAV_LOG_ERROR,
00642     BGAV_LOG_INFO
00643   } bgav_log_level_t;
00644 
00653 typedef void (*bgav_log_callback)(void*data, bgav_log_level_t level,
00654                                   const char * log_domain,
00655                                   const char * message);
00656 
00664 BGAV_PUBLIC void
00665 bgav_options_set_log_callback(bgav_options_t* opt,
00666                               bgav_log_callback callback,
00667                               void * data);
00668 
00669 
00670 /* Set callbacks */
00671 
00681 typedef void (*bgav_name_change_callback)(void*data, const char * name);
00682 
00690 BGAV_PUBLIC void
00691 bgav_options_set_name_change_callback(bgav_options_t* opt,
00692                                       bgav_name_change_callback callback,
00693                                       void * data);
00694 
00705 typedef void (*bgav_metadata_change_callback)(void*data, const bgav_metadata_t * metadata);
00706 
00714 BGAV_PUBLIC void
00715 bgav_options_set_metadata_change_callback(bgav_options_t* opt,
00716                                           bgav_metadata_change_callback callback,
00717                                           void * data);
00718 
00728 typedef void (*bgav_buffer_callback)(void*data, float percentage);
00729 
00737 BGAV_PUBLIC void
00738 bgav_options_set_buffer_callback(bgav_options_t* opt,
00739                                  bgav_buffer_callback callback,
00740                                  void * data);
00741 
00753 typedef int (*bgav_user_pass_callback)(void*data, const char * resource,
00754                                        char ** username, char ** password);
00755   
00767 BGAV_PUBLIC void
00768 bgav_options_set_user_pass_callback(bgav_options_t* opt,
00769                                     bgav_user_pass_callback callback,
00770                                     void * data);
00771 
00782 typedef void (*bgav_aspect_callback)(void*data, int stream,
00783                                      int pixel_width, int pixel_height);
00784 
00785 
00793 BGAV_PUBLIC void
00794 bgav_options_set_aspect_callback(bgav_options_t* opt,
00795                                  bgav_aspect_callback callback,
00796                                  void * data);
00797 
00805 typedef void (*bgav_index_callback)(void*data, float percentage);
00806 
00814 BGAV_PUBLIC void
00815 bgav_options_set_index_callback(bgav_options_t* opt,
00816                                 bgav_index_callback callback,
00817                                 void * data);
00818 
00819 
00820 /* Device description */
00821 
00839 typedef struct
00840   {
00841   char * device; 
00842   char * name;   
00843   } bgav_device_info_t;
00844 
00845 /* Scan for devices */
00846 
00854 BGAV_PUBLIC
00855 bgav_device_info_t * bgav_find_devices_vcd();
00856 
00864 BGAV_PUBLIC
00865 int bgav_check_device_vcd(const char * device, char ** name);
00866 
00874 BGAV_PUBLIC
00875 bgav_device_info_t * bgav_find_devices_dvd();
00876 
00884 BGAV_PUBLIC
00885 int bgav_check_device_dvd(const char * device, char ** name);
00886 
00894 BGAV_PUBLIC
00895 bgav_device_info_t * bgav_find_devices_dvb();
00896 
00904 BGAV_PUBLIC
00905 int bgav_check_device_dvb(const char * device, char ** name);
00906 
00913 BGAV_PUBLIC
00914 void bgav_device_info_destroy(bgav_device_info_t * arr);
00915 
00922 BGAV_PUBLIC
00923 int bgav_eject_disc(const char * device);
00924 
00931 BGAV_PUBLIC
00932 const char * bgav_get_disc_name(bgav_t * bgav);
00933 
00934 /******************************************************
00935  * Open
00936  ******************************************************/
00937 
00938 /* Open a file or URL, return 1 on success */
00939 
00947 BGAV_PUBLIC
00948 int bgav_open(bgav_t * bgav, const char * location);
00949 
00957 BGAV_PUBLIC
00958 int bgav_open_vcd(bgav_t * bgav, const char * location);
00959 
00967 BGAV_PUBLIC
00968 int bgav_open_dvd(bgav_t * bgav, const char * location);
00969 
00981 BGAV_PUBLIC
00982 int bgav_open_dvb(bgav_t * bgav, const char * location);
00983 
00984 
00994 BGAV_PUBLIC
00995 int bgav_open_fd(bgav_t * bgav, int fd,
00996                  int64_t total_size,
00997                  const char * mimetype);
00998 
01010 BGAV_PUBLIC
01011 int bgav_open_callbacks(bgav_t * bgav,
01012                         int (*read_callback)(void * priv, uint8_t * data, int len),
01013                         int64_t (*seek_callback)(void * priv, uint64_t pos, int whence),
01014                         void * priv,
01015                         const char * filename, const char * mimetype, int64_t total_bytes);
01016  
01017 
01018 /* Close and destroy everything */
01019 
01025 BGAV_PUBLIC
01026 void bgav_close(bgav_t * bgav);
01027 
01052 typedef struct
01053   {
01054   char * url;   
01055 
01056   int track;        
01057   int stream;       
01058   int timescale;    
01059     
01060   int64_t src_time; 
01061   
01062   /* Time and duration within the destination in destination
01063      timescale */
01064   int64_t dst_time;  
01065   int64_t dst_duration; 
01066 
01067   /*  */
01068   int32_t speed_num; 
01069   int32_t speed_den; 
01070   
01071   } bgav_edl_segment_t;
01072 
01076 typedef struct
01077   {
01078   bgav_edl_segment_t * segments; 
01079   int num_segments;              
01080   int timescale;                 
01081   } bgav_edl_stream_t;
01082 
01086 typedef struct
01087   {
01088   int num_audio_streams;             
01089   bgav_edl_stream_t * audio_streams; 
01090 
01091   int num_video_streams;             
01092   bgav_edl_stream_t * video_streams; 
01093 
01094   int num_subtitle_text_streams;     
01095   bgav_edl_stream_t * subtitle_text_streams; 
01096 
01097   int num_subtitle_overlay_streams;  
01098   bgav_edl_stream_t * subtitle_overlay_streams; 
01099   
01100   } bgav_edl_track_t;
01101 
01105 struct bgav_edl_s
01106   {
01107   int num_tracks;             
01108   bgav_edl_track_t * tracks;  
01109   char * url;                 
01110   };
01111 
01118 BGAV_PUBLIC
01119 bgav_edl_t * bgav_get_edl(bgav_t * bgav);
01120 
01125 BGAV_PUBLIC
01126 void bgav_edl_dump(const bgav_edl_t * e);
01127 
01132 /***************************************************
01133  * Check for redirecting: You MUST check if you opened
01134  * a redirector, because reading data from redirectors
01135  * crashes
01136  * After you read the URLs, close the bgav_t object
01137  * and open a new one with one of the URLs.
01138  ***************************************************/
01139 
01162 BGAV_PUBLIC
01163 int bgav_is_redirector(bgav_t * bgav);
01164 
01171 BGAV_PUBLIC
01172 int bgav_redirector_get_num_urls(bgav_t * bgav);
01173 
01181 BGAV_PUBLIC
01182 const char * bgav_redirector_get_url(bgav_t * bgav, int index);
01183 
01191 BGAV_PUBLIC
01192 const char * bgav_redirector_get_name(bgav_t * bgav, int index);
01193 
01194 /***************************************************
01195  * Get information about the file
01196  ***************************************************/
01197 
01211 BGAV_PUBLIC
01212 int bgav_num_tracks(bgav_t * bgav);
01213 
01220 BGAV_PUBLIC
01221 const char * bgav_get_description(bgav_t * bgav);
01222 
01230 BGAV_PUBLIC
01231 gavl_time_t bgav_get_duration(bgav_t * bgav, int track);
01232 
01233 /* Query stream numbers */
01234 
01242 BGAV_PUBLIC
01243 int bgav_num_audio_streams(bgav_t * bgav, int track);
01244 
01252 BGAV_PUBLIC
01253 int bgav_num_video_streams(bgav_t * bgav, int track);
01254 
01262 BGAV_PUBLIC
01263 int bgav_num_subtitle_streams(bgav_t * bgav, int track);
01264 
01265 
01273 BGAV_PUBLIC
01274 const char * bgav_get_track_name(bgav_t * bgav, int track);
01275 
01283 BGAV_PUBLIC
01284 const bgav_metadata_t * bgav_get_metadata(bgav_t * bgav,int track);
01285 
01297 BGAV_PUBLIC
01298 int bgav_select_track(bgav_t * bgav, int track);
01299 
01312 BGAV_PUBLIC
01313 int bgav_get_num_chapters(bgav_t * bgav, int track, int * timescale);
01314 
01323 BGAV_PUBLIC const char *
01324 bgav_get_chapter_name(bgav_t * bgav, int track, int chapter);
01325 
01334 BGAV_PUBLIC
01335 int64_t bgav_get_chapter_time(bgav_t * bgav, int track, int chapter);
01336 
01352 BGAV_PUBLIC
01353 const char * bgav_get_audio_language(bgav_t * bgav, int stream);
01354 
01362 BGAV_PUBLIC
01363 const char * bgav_get_subtitle_language(bgav_t * bgav, int stream);
01364 
01372 typedef enum
01373   {
01374     BGAV_STREAM_MUTE = 0,  
01375     BGAV_STREAM_DECODE = 1, 
01376     BGAV_STREAM_PARSE  = 2 
01377   }
01378 bgav_stream_action_t;
01379 
01390 BGAV_PUBLIC
01391 int bgav_set_audio_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
01392 
01403 BGAV_PUBLIC
01404 int bgav_set_video_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
01405 
01416 BGAV_PUBLIC
01417 int bgav_set_subtitle_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
01418 
01419 /***************************************************
01420  * Stream handling functions
01421  ***************************************************/
01422 
01423 /*
01424  *  You MUST these, if you want to decode anything.
01425  *  After bgav_open(), all streams are switched off by
01426  *  default
01427  */
01428 
01429 
01443 BGAV_PUBLIC
01444 int bgav_start(bgav_t * bgav);
01445 
01461 BGAV_PUBLIC
01462 const gavl_audio_format_t * bgav_get_audio_format(bgav_t * bgav, int stream);
01463 
01480 BGAV_PUBLIC
01481 const gavl_video_format_t * bgav_get_video_format(bgav_t * bgav, int stream);
01482 
01502 BGAV_PUBLIC
01503 gavl_frame_table_t * bgav_get_frame_table(bgav_t * bgav, int stream);
01504 
01505   
01523 BGAV_PUBLIC const gavl_video_format_t *
01524 bgav_get_subtitle_format(bgav_t * bgav, int stream);
01525 
01536 BGAV_PUBLIC
01537 int bgav_subtitle_is_text(bgav_t * bgav, int stream);
01538 
01550 BGAV_PUBLIC
01551 const char * bgav_get_audio_description(bgav_t * bgav, int stream);
01552 
01567 BGAV_PUBLIC
01568 const char * bgav_get_audio_info(bgav_t * bgav, int stream);
01569 
01570 
01582 BGAV_PUBLIC
01583 const char * bgav_get_video_description(bgav_t * bgav, int stream);
01584 
01596 BGAV_PUBLIC
01597 const char * bgav_get_subtitle_description(bgav_t * bgav, int stream);
01598 
01599 
01614 BGAV_PUBLIC
01615 const char * bgav_get_subtitle_info(bgav_t * bgav, int stream);
01616 
01626 BGAV_PUBLIC
01627 int bgav_can_pause(bgav_t * bgav);
01628 
01629 /***************************************************
01630  * Decoding functions
01631  ***************************************************/
01632 
01654 BGAV_PUBLIC
01655 int bgav_video_has_still(bgav_t * bgav, int stream);
01656   
01665 BGAV_PUBLIC
01666 int bgav_read_video(bgav_t * bgav, gavl_video_frame_t * frame, int stream);
01667 
01681 BGAV_PUBLIC
01682 void bgav_skip_video(bgav_t * bgav, int stream,
01683                      int64_t * time, int scale,
01684                      int exact);
01685 
01686   
01696 BGAV_PUBLIC
01697 int bgav_read_audio(bgav_t * bgav, gavl_audio_frame_t * frame, int stream,
01698                     int num_samples);
01699 
01711 BGAV_PUBLIC
01712 int bgav_has_subtitle(bgav_t * bgav, int stream);
01713 
01729 BGAV_PUBLIC
01730 int bgav_read_subtitle_overlay(bgav_t * bgav, gavl_overlay_t * ovl, int stream);
01731 
01751 BGAV_PUBLIC
01752 int bgav_read_subtitle_text(bgav_t * bgav, char ** ret, int *ret_alloc,
01753                             int64_t * start_time, int64_t * duration,
01754                             int stream);
01755 
01756 /***************************************************
01757  * Seek to a timestamp. This also resyncs all streams
01758  ***************************************************/
01759 
01796 BGAV_PUBLIC
01797 int bgav_can_seek(bgav_t * bgav);
01798 
01807 BGAV_PUBLIC
01808 void bgav_seek(bgav_t * bgav, gavl_time_t * time);
01809 
01810 
01834 BGAV_PUBLIC
01835 void bgav_seek_scaled(bgav_t * bgav, int64_t * time, int scale);
01836 
01841 #define BGAV_TIMESTAMP_UNDEFINED 0x8000000000000000LL
01842 
01859 BGAV_PUBLIC
01860 int bgav_can_seek_sample(bgav_t * bgav);
01861 
01862 
01875 BGAV_PUBLIC
01876 int64_t bgav_audio_duration(bgav_t * bgav, int stream);
01877 
01889 BGAV_PUBLIC
01890 int64_t bgav_audio_start_time(bgav_t * bgav, int stream);
01891 
01904 BGAV_PUBLIC
01905 int64_t bgav_video_duration(bgav_t * bgav, int stream);
01906 
01918 BGAV_PUBLIC
01919 int64_t bgav_video_start_time(bgav_t * bgav, int stream);
01920 
01921 
01931 BGAV_PUBLIC
01932 int64_t bgav_subtitle_duration(bgav_t * bgav, int stream);
01933 
01947 BGAV_PUBLIC
01948 void bgav_seek_audio(bgav_t * bgav, int stream, int64_t sample);
01949 
01963 BGAV_PUBLIC
01964 void bgav_seek_video(bgav_t * bgav, int stream, int64_t time);
01965 
01981 BGAV_PUBLIC
01982 int64_t bgav_video_keyframe_before(bgav_t * bgav, int stream, int64_t time);
01983 
01999 BGAV_PUBLIC
02000 int64_t bgav_video_keyframe_after(bgav_t * bgav, int stream, int64_t time);
02001 
02002 
02013 BGAV_PUBLIC
02014 void bgav_seek_subtitle(bgav_t * bgav, int stream, int64_t time);
02015 
02016 
02017 /***************************************************
02018  * Debugging functions
02019  ***************************************************/
02020 
02029 BGAV_PUBLIC
02030 void bgav_dump(bgav_t * bgav);
02031 
02032 /* Dump infos about the installed codecs */
02033 
02041 BGAV_PUBLIC
02042 void bgav_codecs_dump();
02043 
02044 /* Dump known media formats */
02045 
02053 BGAV_PUBLIC
02054 void bgav_formats_dump();
02055 
02063 BGAV_PUBLIC
02064 void bgav_inputs_dump();
02065 
02073 BGAV_PUBLIC
02074 void bgav_redirectors_dump();
02075 
02083 BGAV_PUBLIC
02084 void bgav_subreaders_dump();
02085 
02086 
02087 #ifdef __cplusplus
02088 }
02089 #endif
02090 

doxygen