00001 /* 00002 * copyright (c) 2001 Fabrice Bellard 00003 * 00004 * This file is part of FFmpeg. 00005 * 00006 * FFmpeg is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * FFmpeg is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with FFmpeg; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #ifndef AVFORMAT_INTERNAL_H 00022 #define AVFORMAT_INTERNAL_H 00023 00024 #include <stdint.h> 00025 #include "avformat.h" 00026 00027 #define MAX_URL_SIZE 4096 00028 00029 #ifdef DEBUG 00030 # define hex_dump_debug(class, buf, size) av_hex_dump_log(class, AV_LOG_DEBUG, buf, size) 00031 #else 00032 # define hex_dump_debug(class, buf, size) 00033 #endif 00034 00035 typedef struct AVCodecTag { 00036 enum AVCodecID id; 00037 unsigned int tag; 00038 } AVCodecTag; 00039 00040 typedef struct CodecMime{ 00041 char str[32]; 00042 enum AVCodecID id; 00043 } CodecMime; 00044 00045 #ifdef __GNUC__ 00046 #define dynarray_add(tab, nb_ptr, elem)\ 00047 do {\ 00048 __typeof__(tab) _tab = (tab);\ 00049 __typeof__(elem) _elem = (elem);\ 00050 (void)sizeof(**_tab == _elem); /* check that types are compatible */\ 00051 av_dynarray_add(_tab, nb_ptr, _elem);\ 00052 } while(0) 00053 #else 00054 #define dynarray_add(tab, nb_ptr, elem)\ 00055 do {\ 00056 av_dynarray_add((tab), nb_ptr, (elem));\ 00057 } while(0) 00058 #endif 00059 00060 struct tm *ff_brktimegm(time_t secs, struct tm *tm); 00061 00062 char *ff_data_to_hex(char *buf, const uint8_t *src, int size, int lowercase); 00063 00072 int ff_hex_to_data(uint8_t *data, const char *p); 00073 00074 void ff_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx); 00075 00081 int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, 00082 int (*compare)(AVFormatContext *, AVPacket *, AVPacket *)); 00083 00084 void ff_read_frame_flush(AVFormatContext *s); 00085 00086 #define NTP_OFFSET 2208988800ULL 00087 #define NTP_OFFSET_US (NTP_OFFSET * 1000000ULL) 00088 00090 uint64_t ff_ntp_time(void); 00091 00113 int ff_url_join(char *str, int size, const char *proto, 00114 const char *authorization, const char *hostname, 00115 int port, const char *fmt, ...) av_printf_format(7, 8); 00116 00134 void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, 00135 const char *dest_addr, const char *dest_type, 00136 int port, int ttl, AVFormatContext *fmt); 00137 00149 int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt, 00150 AVFormatContext *src); 00151 00155 int ff_get_v_length(uint64_t val); 00156 00160 void ff_put_v(AVIOContext *bc, uint64_t val); 00161 00173 int ff_get_line(AVIOContext *s, char *buf, int maxlen); 00174 00175 #define SPACE_CHARS " \t\r\n" 00176 00187 typedef void (*ff_parse_key_val_cb)(void *context, const char *key, 00188 int key_len, char **dest, int *dest_len); 00198 void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf, 00199 void *context); 00200 00205 int ff_find_stream_index(AVFormatContext *s, int id); 00206 00210 int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries, 00211 int64_t wanted_timestamp, int flags); 00212 00216 int ff_add_index_entry(AVIndexEntry **index_entries, 00217 int *nb_index_entries, 00218 unsigned int *index_entries_allocated_size, 00219 int64_t pos, int64_t timestamp, int size, int distance, int flags); 00220 00232 AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, 00233 int64_t start, int64_t end, const char *title); 00234 00240 void ff_reduce_index(AVFormatContext *s, int stream_index); 00241 00242 /* 00243 * Convert a relative url into an absolute url, given a base url. 00244 * 00245 * @param buf the buffer where output absolute url is written 00246 * @param size the size of buf 00247 * @param base the base url, may be equal to buf. 00248 * @param rel the new url, which is interpreted relative to base 00249 */ 00250 void ff_make_absolute_url(char *buf, int size, const char *base, 00251 const char *rel); 00252 00253 enum AVCodecID ff_guess_image2_codec(const char *filename); 00254 00258 int64_t ff_iso8601_to_unix_time(const char *datestr); 00259 00267 int ff_seek_frame_binary(AVFormatContext *s, int stream_index, 00268 int64_t target_ts, int flags); 00269 00278 void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); 00279 00286 int64_t ff_gen_search(AVFormatContext *s, int stream_index, 00287 int64_t target_ts, int64_t pos_min, 00288 int64_t pos_max, int64_t pos_limit, 00289 int64_t ts_min, int64_t ts_max, 00290 int flags, int64_t *ts_ret, 00291 int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); 00292 00303 void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, 00304 unsigned int pts_num, unsigned int pts_den); 00305 00310 int ff_add_param_change(AVPacket *pkt, int32_t channels, 00311 uint64_t channel_layout, int32_t sample_rate, 00312 int32_t width, int32_t height); 00313 00318 int ff_framehash_write_header(AVFormatContext *s); 00319 00327 int ff_read_packet(AVFormatContext *s, AVPacket *pkt); 00328 00344 int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, 00345 AVPacket *pkt, int flush); 00346 00347 void ff_free_stream(AVFormatContext *s, AVStream *st); 00348 00349 #endif /* AVFORMAT_INTERNAL_H */