avdec.h

Go to the documentation of this file.
00001 /*****************************************************************
00002  * gmerlin-avdecoder - a general purpose multimedia decoding library
00003  *
00004  * Copyright (c) 2001 - 2008 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 
00035 typedef struct bgav_edl_s bgav_edl_t;
00036 
00070 typedef struct bgav_s bgav_t;
00071 
00077 bgav_t * bgav_create();
00078 
00109 typedef struct bgav_metadata_s bgav_metadata_t;
00110 
00117 const char * bgav_metadata_get_author(const bgav_metadata_t*metadata);
00118 
00125 const char * bgav_metadata_get_title(const bgav_metadata_t * metadata);
00126 
00133 const char * bgav_metadata_get_comment(const bgav_metadata_t * metadata);
00134 
00141 const char * bgav_metadata_get_copyright(const bgav_metadata_t * metadata);
00142 
00148 const char * bgav_metadata_get_album(const bgav_metadata_t * metadata);
00149 
00155 const char * bgav_metadata_get_artist(const bgav_metadata_t * metadata);
00156 
00163 const char * bgav_metadata_get_genre(const bgav_metadata_t * metadata);
00164 
00171 const char * bgav_metadata_get_date(const bgav_metadata_t * metadata);
00172 
00179 int bgav_metadata_get_track(const bgav_metadata_t * metadata);
00180 
00181 /***************************************************
00182  * Housekeeping Functions
00183  ***************************************************/
00184 
00185 /***************************************************
00186  * Set parameters
00187  ***************************************************/
00188 
00189 
00194 typedef struct bgav_options_s bgav_options_t;
00195 
00205 bgav_options_t * bgav_get_options(bgav_t * bgav);
00206 
00220 bgav_options_t * bgav_options_create();
00221 
00231 void bgav_options_destroy(bgav_options_t * opt);
00232 
00239 void bgav_options_copy(bgav_options_t * dst, const bgav_options_t * src);
00240 
00250 void bgav_options_set_connect_timeout(bgav_options_t * opt, int timeout);
00251 
00261 void bgav_options_set_read_timeout(bgav_options_t * opt, int timeout);
00262 
00272 void bgav_options_set_network_bandwidth(bgav_options_t * opt, int bandwidth);
00273 
00283 void bgav_options_set_network_buffer_size(bgav_options_t * opt, int size);
00284 
00285 /* HTTP Options */
00286 
00297 void bgav_options_set_http_use_proxy(bgav_options_t* opt, int enable);
00298 
00308 void bgav_options_set_http_proxy_host(bgav_options_t* opt, const char * host);
00309 
00319 void bgav_options_set_http_proxy_port(bgav_options_t* opt, int port);
00320 
00331 void bgav_options_set_http_proxy_auth(bgav_options_t* opt, int enable);
00332 
00341 void bgav_options_set_http_proxy_user(bgav_options_t* opt, const char * user);
00342 
00351 void bgav_options_set_http_proxy_pass(bgav_options_t* opt, const char * pass);
00352 
00361 void bgav_options_set_http_shoutcast_metadata(bgav_options_t* opt, int enable);
00362 
00363 /* Set FTP options */
00364 
00371 void bgav_options_set_ftp_anonymous(bgav_options_t* opt, int enable);
00372 
00381 void bgav_options_set_ftp_anonymous_password(bgav_options_t* opt, const char* pass);
00382 
00394 void bgav_options_set_default_subtitle_encoding(bgav_options_t* opt,
00395                                                 const char* encoding);
00396 
00407 void bgav_options_set_audio_dynrange(bgav_options_t* opt,
00408                                      int audio_dynrange);
00409 
00410 
00426 void bgav_options_set_seamless(bgav_options_t* opt,
00427                                int seamless);
00428 
00440 void bgav_options_set_sample_accurate(bgav_options_t*opt, int enable);
00441 
00453 void bgav_options_set_cache_time(bgav_options_t*opt, int t);
00454 
00464 void bgav_options_set_cache_size(bgav_options_t*opt, int s);
00465 
00481 void bgav_options_set_seek_subtitles(bgav_options_t* opt,
00482                                     int seek_subtitles);
00483 
00490 void bgav_options_set_pp_level(bgav_options_t* opt,
00491                                int pp_level);
00492 
00504 void bgav_options_set_dvb_channels_file(bgav_options_t* opt,
00505                                         const char * file);
00506 
00518 void bgav_options_set_prefer_ffmpeg_demuxers(bgav_options_t* opt,
00519                                              int prefer);
00520 
00521 
00528 typedef enum
00529   {
00530     BGAV_LOG_DEBUG,
00531     BGAV_LOG_WARNING,
00532     BGAV_LOG_ERROR,
00533     BGAV_LOG_INFO
00534   } bgav_log_level_t;
00535 
00544 typedef void (*bgav_log_callback)(void*data, bgav_log_level_t level,
00545                                   const char * log_domain,
00546                                   const char * message);
00547 
00555 void
00556 bgav_options_set_log_callback(bgav_options_t* opt,
00557                               bgav_log_callback callback,
00558                               void * data);
00559 
00560 
00561 /* Set callbacks */
00562 
00572 typedef void (*bgav_name_change_callback)(void*data, const char * name);
00573 
00581 void
00582 bgav_options_set_name_change_callback(bgav_options_t* opt,
00583                                       bgav_name_change_callback callback,
00584                                       void * data);
00585 
00596 typedef void (*bgav_metadata_change_callback)(void*data, const bgav_metadata_t * metadata);
00597 
00605 void
00606 bgav_options_set_metadata_change_callback(bgav_options_t* opt,
00607                                           bgav_metadata_change_callback callback,
00608                                           void * data);
00609 
00620 typedef void (*bgav_track_change_callback)(void*data, int track);
00621 
00629 void
00630 bgav_options_set_track_change_callback(bgav_options_t* opt,
00631                                        bgav_track_change_callback callback,
00632                                        void * data);
00633 
00643 typedef void (*bgav_buffer_callback)(void*data, float percentage);
00644 
00652 void
00653 bgav_options_set_buffer_callback(bgav_options_t* opt,
00654                                  bgav_buffer_callback callback,
00655                                  void * data);
00656 
00668 typedef int (*bgav_user_pass_callback)(void*data, const char * resource,
00669                                        char ** username, char ** password);
00670   
00682 void
00683 bgav_options_set_user_pass_callback(bgav_options_t* opt,
00684                                     bgav_user_pass_callback callback,
00685                                     void * data);
00686 
00697 typedef void (*bgav_aspect_callback)(void*data, int stream,
00698                                      int pixel_width, int pixel_height);
00699 
00700 
00708 void
00709 bgav_options_set_aspect_callback(bgav_options_t* opt,
00710                                  bgav_aspect_callback callback,
00711                                  void * data);
00712 
00720 typedef void (*bgav_index_callback)(void*data, float percentage);
00721 
00729 void
00730 bgav_options_set_index_callback(bgav_options_t* opt,
00731                                 bgav_index_callback callback,
00732                                 void * data);
00733 
00734 
00735 /* Device description */
00736 
00754 typedef struct
00755   {
00756   char * device; 
00757   char * name;   
00758   } bgav_device_info_t;
00759 
00760 /* Scan for devices */
00761 
00769 bgav_device_info_t * bgav_find_devices_vcd();
00770 
00778 int bgav_check_device_vcd(const char * device, char ** name);
00779 
00787 bgav_device_info_t * bgav_find_devices_dvd();
00788 
00796 int bgav_check_device_dvd(const char * device, char ** name);
00797 
00805 bgav_device_info_t * bgav_find_devices_dvb();
00806 
00814 int bgav_check_device_dvb(const char * device, char ** name);
00815 
00822 void bgav_device_info_destroy(bgav_device_info_t * arr);
00823 
00830 int bgav_eject_disc(const char * device);
00831 
00838 const char * bgav_get_disc_name(bgav_t * bgav);
00839 
00840 /******************************************************
00841  * Open
00842  ******************************************************/
00843 
00844 /* Open a file or URL, return 1 on success */
00845 
00853 int bgav_open(bgav_t * bgav, const char * location);
00854 
00862 int bgav_open_vcd(bgav_t * bgav, const char * location);
00863 
00871 int bgav_open_dvd(bgav_t * bgav, const char * location);
00872 
00884 int bgav_open_dvb(bgav_t * bgav, const char * location);
00885 
00886 
00896 int bgav_open_fd(bgav_t * bgav, int fd,
00897                  int64_t total_size,
00898                  const char * mimetype);
00899 
00911 int bgav_open_callbacks(bgav_t * bgav,
00912                         int (*read_callback)(void * priv, uint8_t * data, int len),
00913                         int64_t (*seek_callback)(void * priv, uint64_t pos, int whence),
00914                         void * priv,
00915                         const char * filename, const char * mimetype);
00916  
00917 
00918 /* Close and destroy everything */
00919 
00925 void bgav_close(bgav_t * bgav);
00926 
00951 typedef struct
00952   {
00953   char * url;   
00954 
00955   int track;        
00956   int stream;       
00957   int timescale;    
00958     
00959   int64_t src_time; 
00960   
00961   /* Time and duration within the destination in destination
00962      timescale */
00963   int64_t dst_time;  
00964   int64_t dst_duration; 
00965 
00966   /*  */
00967   int32_t speed_num; 
00968   int32_t speed_den; 
00969   
00970   } bgav_edl_segment_t;
00971 
00975 typedef struct
00976   {
00977   bgav_edl_segment_t * segments; 
00978   int num_segments;              
00979   int timescale;                 
00980   } bgav_edl_stream_t;
00981 
00985 typedef struct
00986   {
00987   int num_audio_streams;             
00988   bgav_edl_stream_t * audio_streams; 
00989 
00990   int num_video_streams;             
00991   bgav_edl_stream_t * video_streams; 
00992 
00993   int num_subtitle_text_streams;     
00994   bgav_edl_stream_t * subtitle_text_streams; 
00995 
00996   int num_subtitle_overlay_streams;  
00997   bgav_edl_stream_t * subtitle_overlay_streams; 
00998   
00999   } bgav_edl_track_t;
01000 
01004 struct bgav_edl_s
01005   {
01006   int num_tracks;             
01007   bgav_edl_track_t * tracks;  
01008   char * url;                 
01009   };
01010 
01017 bgav_edl_t * bgav_get_edl(bgav_t * bgav);
01018 
01023 void bgav_edl_dump(const bgav_edl_t * e);
01024 
01029 /***************************************************
01030  * Check for redirecting: You MUST check if you opened
01031  * a redirector, because reading data from redirectors
01032  * crashes
01033  * After you read the URLs, close the bgav_t object
01034  * and open a new one with one of the URLs.
01035  ***************************************************/
01036 
01059 int bgav_is_redirector(bgav_t * bgav);
01060 
01067 int bgav_redirector_get_num_urls(bgav_t * bgav);
01068 
01076 const char * bgav_redirector_get_url(bgav_t * bgav, int index);
01077 
01085 const char * bgav_redirector_get_name(bgav_t * bgav, int index);
01086 
01087 /***************************************************
01088  * Get information about the file
01089  ***************************************************/
01090 
01104 int bgav_num_tracks(bgav_t * bgav);
01105 
01112 const char * bgav_get_description(bgav_t * bgav);
01113 
01121 gavl_time_t bgav_get_duration(bgav_t * bgav, int track);
01122 
01123 /* Query stream numbers */
01124 
01132 int bgav_num_audio_streams(bgav_t * bgav, int track);
01133 
01141 int bgav_num_video_streams(bgav_t * bgav, int track);
01142 
01150 int bgav_num_subtitle_streams(bgav_t * bgav, int track);
01151 
01152 
01160 const char * bgav_get_track_name(bgav_t * bgav, int track);
01161 
01169 const bgav_metadata_t * bgav_get_metadata(bgav_t * bgav,int track);
01170 
01182 int bgav_select_track(bgav_t * bgav, int track);
01183 
01196 int bgav_get_num_chapters(bgav_t * bgav, int track, int * timescale);
01197 
01206 const char *
01207 bgav_get_chapter_name(bgav_t * bgav, int track, int chapter);
01208 
01217 int64_t bgav_get_chapter_time(bgav_t * bgav, int track, int chapter);
01218 
01234 const char * bgav_get_audio_language(bgav_t * bgav, int stream);
01235 
01243 const char * bgav_get_subtitle_language(bgav_t * bgav, int stream);
01244 
01252 typedef enum
01253   {
01254     BGAV_STREAM_MUTE = 0,  
01255     BGAV_STREAM_DECODE = 1, 
01256     BGAV_STREAM_PARSE  = 2 
01257   }
01258 bgav_stream_action_t;
01259 
01270 int bgav_set_audio_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
01271 
01282 int bgav_set_video_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
01283 
01294 int bgav_set_subtitle_stream(bgav_t * bgav, int stream, bgav_stream_action_t action);
01295 
01296 /***************************************************
01297  * Stream handling functions
01298  ***************************************************/
01299 
01300 /*
01301  *  You MUST these, if you want to decode anything.
01302  *  After bgav_open(), all streams are switched off by
01303  *  default
01304  */
01305 
01306 
01320 int bgav_start(bgav_t * bgav);
01321 
01337 const gavl_audio_format_t * bgav_get_audio_format(bgav_t * bgav, int stream);
01338 
01350 const gavl_video_format_t * bgav_get_video_format(bgav_t * bgav, int stream);
01351 
01367 const gavl_video_format_t *
01368 bgav_get_subtitle_format(bgav_t * bgav, int stream);
01369 
01380 int bgav_subtitle_is_text(bgav_t * bgav, int stream);
01381 
01393 const char * bgav_get_audio_description(bgav_t * bgav, int stream);
01394 
01409 const char * bgav_get_audio_info(bgav_t * bgav, int stream);
01410 
01411 
01423 const char * bgav_get_video_description(bgav_t * bgav, int stream);
01424 
01436 const char * bgav_get_subtitle_description(bgav_t * bgav, int stream);
01437 
01438 
01453 const char * bgav_get_subtitle_info(bgav_t * bgav, int stream);
01454 
01455 
01456 
01457 /***************************************************
01458  * Decoding functions
01459  ***************************************************/
01460 
01473 int bgav_read_video(bgav_t * bgav, gavl_video_frame_t * frame, int stream);
01474 
01484 int bgav_read_audio(bgav_t * bgav, gavl_audio_frame_t * frame, int stream,
01485                     int num_samples);
01486 
01498 int bgav_has_subtitle(bgav_t * bgav, int stream);
01499 
01515 int bgav_read_subtitle_overlay(bgav_t * bgav, gavl_overlay_t * ovl, int stream);
01516 
01536 int bgav_read_subtitle_text(bgav_t * bgav, char ** ret, int *ret_alloc,
01537                             int64_t * start_time, int64_t * duration,
01538                             int stream);
01539 
01540 /***************************************************
01541  * Seek to a timestamp. This also resyncs all streams
01542  ***************************************************/
01543 
01580 int bgav_can_seek(bgav_t * bgav);
01581 
01590 void bgav_seek(bgav_t * bgav, gavl_time_t * time);
01591 
01592 
01616 void bgav_seek_scaled(bgav_t * bgav, int64_t * time, int scale);
01617 
01622 #define BGAV_TIMESTAMP_UNDEFINED 0x8000000000000000LL
01623 
01638 int bgav_can_seek_sample(bgav_t * bgav);
01639 
01640 
01653 int64_t bgav_audio_duration(bgav_t * bgav, int stream);
01654 
01666 int64_t bgav_audio_start_time(bgav_t * bgav, int stream);
01667 
01680 int64_t bgav_video_duration(bgav_t * bgav, int stream);
01681 
01693 int64_t bgav_video_start_time(bgav_t * bgav, int stream);
01694 
01695 
01705 int64_t bgav_subtitle_duration(bgav_t * bgav, int stream);
01706 
01720 void bgav_seek_audio(bgav_t * bgav, int stream, int64_t sample);
01721 
01735 void bgav_seek_video(bgav_t * bgav, int stream, int64_t time);
01736 
01752 int64_t bgav_video_keyframe_before(bgav_t * bgav, int stream, int64_t time);
01753 
01769 int64_t bgav_video_keyframe_after(bgav_t * bgav, int stream, int64_t time);
01770 
01771 
01782 void bgav_seek_subtitle(bgav_t * bgav, int stream, int64_t time);
01783 
01784 
01785 /***************************************************
01786  * Debugging functions
01787  ***************************************************/
01788 
01797 void bgav_dump(bgav_t * bgav);
01798 
01799 /* Dump infos about the installed codecs */
01800 
01808 void bgav_codecs_dump();
01809 
01810 /* Dump known media formats */
01811 
01819 void bgav_formats_dump();
01820 
01828 void bgav_inputs_dump();
01829 
01837 void bgav_redirectors_dump();
01838 
01846 void bgav_subreaders_dump();

Generated on Sun Aug 3 15:34:52 2008 for gmerlin-avdecoder by  doxygen 1.5.6