Revision e731b8d8

View differences:

libavformat/asfenc.c
22 22
#include "metadata.h"
23 23
#include "riff.h"
24 24
#include "asf.h"
25
#include "avio_internal.h"
25 26

  
26 27
#undef NDEBUG
27 28
#include <assert.h>
......
578 579
    asf->packet_nb_payloads = 0;
579 580
    asf->packet_timestamp_start = -1;
580 581
    asf->packet_timestamp_end = -1;
581
    init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1,
582
    ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
582 583
                  NULL, NULL, NULL, NULL);
583 584

  
584 585
    return 0;
......
676 677
    asf->packet_nb_payloads = 0;
677 678
    asf->packet_timestamp_start = -1;
678 679
    asf->packet_timestamp_end = -1;
679
    init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1,
680
    ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
680 681
                  NULL, NULL, NULL, NULL);
681 682
}
682 683

  
libavformat/avio.h
361 361

  
362 362
#if FF_API_OLD_AVIO
363 363
typedef attribute_deprecated AVIOContext ByteIOContext;
364
#endif
365 364

  
366
int init_put_byte(AVIOContext *s,
365
attribute_deprecated int init_put_byte(AVIOContext *s,
367 366
                  unsigned char *buffer,
368 367
                  int buffer_size,
369 368
                  int write_flag,
......
371 370
                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
372 371
                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
373 372
                  int64_t (*seek)(void *opaque, int64_t offset, int whence));
373
#endif
374 374
AVIOContext *av_alloc_put_byte(
375 375
                  unsigned char *buffer,
376 376
                  int buffer_size,
libavformat/avio_internal.h
1
/*
2
 *
3
 * This file is part of FFmpeg.
4
 *
5
 * FFmpeg is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * FFmpeg is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with FFmpeg; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
 */
19

  
20
#ifndef AVFORMAT_AVIO_INTERNAL_H
21
#define AVFORMAT_AVIO_INTERNAL_H
22

  
23
#include "avio.h"
24

  
25
int ffio_init_context(AVIOContext *s,
26
                  unsigned char *buffer,
27
                  int buffer_size,
28
                  int write_flag,
29
                  void *opaque,
30
                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
31
                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
32
                  int64_t (*seek)(void *opaque, int64_t offset, int whence));
33

  
34

  
35
#endif // AVFORMAT_AVIO_INTERNAL_H
libavformat/aviobuf.c
23 23
#include "libavutil/intreadwrite.h"
24 24
#include "avformat.h"
25 25
#include "avio.h"
26
#include "avio_internal.h"
26 27
#include "internal.h"
27 28
#include <stdarg.h>
28 29

  
......
40 41
static int url_resetbuf(AVIOContext *s, int flags);
41 42
#endif
42 43

  
43
int init_put_byte(AVIOContext *s,
44
int ffio_init_context(AVIOContext *s,
44 45
                  unsigned char *buffer,
45 46
                  int buffer_size,
46 47
                  int write_flag,
......
73 74
    return 0;
74 75
}
75 76

  
77
#if FF_API_OLD_AVIO
78
int init_put_byte(AVIOContext *s,
79
                  unsigned char *buffer,
80
                  int buffer_size,
81
                  int write_flag,
82
                  void *opaque,
83
                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
84
                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
85
                  int64_t (*seek)(void *opaque, int64_t offset, int whence))
86
{
87
    return ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
88
                                read_packet, write_packet, seek);
89
}
90
#endif
91

  
76 92
AVIOContext *av_alloc_put_byte(
77 93
                  unsigned char *buffer,
78 94
                  int buffer_size,
......
83 99
                  int64_t (*seek)(void *opaque, int64_t offset, int whence))
84 100
{
85 101
    AVIOContext *s = av_mallocz(sizeof(AVIOContext));
86
    init_put_byte(s, buffer, buffer_size, write_flag, opaque,
102
    ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
87 103
                  read_packet, write_packet, seek);
88 104
    return s;
89 105
}
......
664 680
        return AVERROR(ENOMEM);
665 681
    }
666 682

  
667
    if (init_put_byte(*s, buffer, buffer_size,
683
    if (ffio_init_context(*s, buffer, buffer_size,
668 684
                      (h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
669 685
                      url_read, url_write, url_seek) < 0) {
670 686
        av_free(buffer);
......
865 881
    *s = av_mallocz(sizeof(AVIOContext));
866 882
    if(!*s)
867 883
        return AVERROR(ENOMEM);
868
    ret = init_put_byte(*s, buf, buf_size,
884
    ret = ffio_init_context(*s, buf, buf_size,
869 885
                        (flags & URL_WRONLY || flags & URL_RDWR),
870 886
                        NULL, NULL, NULL, NULL);
871 887
    if(ret != 0)
......
964 980
        return AVERROR(ENOMEM);
965 981
    }
966 982
    d->io_buffer_size = io_buffer_size;
967
    ret = init_put_byte(*s, d->io_buffer, io_buffer_size,
983
    ret = ffio_init_context(*s, d->io_buffer, io_buffer_size,
968 984
                        1, d, NULL,
969 985
                        max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
970 986
                        max_packet_size ? NULL : dyn_buf_seek);
libavformat/id3v2.c
24 24
#include "libavutil/avstring.h"
25 25
#include "libavutil/intreadwrite.h"
26 26
#include "metadata.h"
27
#include "avio_internal.h"
27 28

  
28 29
int ff_id3v2_match(const uint8_t *buf, const char * magic)
29 30
{
......
216 217
                        j--;
217 218
                    }
218 219
                }
219
                init_put_byte(&pb, buffer, j, 0, NULL, NULL, NULL, NULL);
220
                ffio_init_context(&pb, buffer, j, 0, NULL, NULL, NULL, NULL);
220 221
                read_ttag(s, &pb, j, tag);
221 222
            } else {
222 223
                read_ttag(s, s->pb, tlen, tag);
libavformat/matroskadec.c
31 31
#include <stdio.h>
32 32
#include "avformat.h"
33 33
#include "internal.h"
34
#include "avio_internal.h"
34 35
/* For ff_codec_get_id(). */
35 36
#include "riff.h"
36 37
#include "isom.h"
......
698 699
                                 uint8_t *data, uint32_t size, uint64_t *num)
699 700
{
700 701
    AVIOContext pb;
701
    init_put_byte(&pb, data, size, 0, NULL, NULL, NULL, NULL);
702
    ffio_init_context(&pb, data, size, 0, NULL, NULL, NULL, NULL);
702 703
    return ebml_read_num(matroska, &pb, FFMIN(size, 8), num);
703 704
}
704 705

  
......
1328 1329
        } else if (!strcmp(track->codec_id, "A_MS/ACM")
1329 1330
                   && track->codec_priv.size >= 14
1330 1331
                   && track->codec_priv.data != NULL) {
1331
            init_put_byte(&b, track->codec_priv.data, track->codec_priv.size,
1332
            ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size,
1332 1333
                          URL_RDONLY, NULL, NULL, NULL, NULL);
1333 1334
            ff_get_wav_header(&b, st->codec, track->codec_priv.size);
1334 1335
            codec_id = st->codec->codec_id;
......
1373 1374
            extradata = av_mallocz(extradata_size);
1374 1375
            if (extradata == NULL)
1375 1376
                return AVERROR(ENOMEM);
1376
            init_put_byte(&b, extradata, extradata_size, 1,
1377
            ffio_init_context(&b, extradata, extradata_size, 1,
1377 1378
                          NULL, NULL, NULL, NULL);
1378 1379
            put_buffer(&b, "TTA1", 4);
1379 1380
            put_le16(&b, 1);
......
1390 1391
        } else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK ||
1391 1392
                   codec_id == CODEC_ID_ATRAC3 || codec_id == CODEC_ID_SIPR) {
1392 1393
            int flavor;
1393
            init_put_byte(&b, track->codec_priv.data,track->codec_priv.size,
1394
            ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size,
1394 1395
                          0, NULL, NULL, NULL, NULL);
1395 1396
            url_fskip(&b, 22);
1396 1397
            flavor                       = get_be16(&b);
libavformat/mmst.c
31 31
#include "avformat.h"
32 32
#include "mms.h"
33 33
#include "internal.h"
34
#include "avio_internal.h"
34 35
#include "libavutil/intreadwrite.h"
35 36
#include "libavcodec/bytestream.h"
36 37
#include "network.h"
......
155 156
    AVIOContext bic;
156 157
    int size = mms->write_out_ptr - mms->out_buffer;
157 158
    int len;
158
    init_put_byte(&bic, mms->write_out_ptr,
159
    ffio_init_context(&bic, mms->write_out_ptr,
159 160
            sizeof(mms->out_buffer) - size, 1, NULL, NULL, NULL, NULL);
160 161

  
161 162
    len = avio_put_str16le(&bic, src);
libavformat/mov.c
29 29
#include "libavutil/intreadwrite.h"
30 30
#include "libavutil/avstring.h"
31 31
#include "avformat.h"
32
#include "avio_internal.h"
32 33
#include "riff.h"
33 34
#include "isom.h"
34 35
#include "libavcodec/get_bits.h"
......
2123 2124
    get_buffer(pb, cmov_data, cmov_len);
2124 2125
    if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK)
2125 2126
        goto free_and_return;
2126
    if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
2127
    if(ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
2127 2128
        goto free_and_return;
2128 2129
    atom.type = MKTAG('m','o','o','v');
2129 2130
    atom.size = moov_len;
libavformat/mpegts.c
29 29
#include "avformat.h"
30 30
#include "mpegts.h"
31 31
#include "internal.h"
32
#include "avio_internal.h"
32 33
#include "seek.h"
33 34
#include "mpeg.h"
34 35
#include "isom.h"
......
855 856
    int tag;
856 857
    unsigned len;
857 858

  
858
    init_put_byte(&pb, buf, size, 0, NULL, NULL, NULL, NULL);
859
    ffio_init_context(&pb, buf, size, 0, NULL, NULL, NULL, NULL);
859 860

  
860 861
    len = ff_mp4_read_descr(s, &pb, &tag);
861 862
    if (tag == MP4IODescrTag) {
......
914 915
        if (st->codec->codec_id == CODEC_ID_AAC_LATM &&
915 916
            mp4_dec_config_descr_len && mp4_es_id == pid) {
916 917
            AVIOContext pb;
917
            init_put_byte(&pb, mp4_dec_config_descr,
918
            ffio_init_context(&pb, mp4_dec_config_descr,
918 919
                          mp4_dec_config_descr_len, 0, NULL, NULL, NULL, NULL);
919 920
            ff_mp4_read_dec_config_descr(fc, st, &pb);
920 921
            if (st->codec->codec_id == CODEC_ID_AAC &&
libavformat/rdt.c
33 33
#include "libavutil/md5.h"
34 34
#include "rm.h"
35 35
#include "internal.h"
36
#include "avio_internal.h"
36 37
#include "libavcodec/get_bits.h"
37 38

  
38 39
struct RDTDemuxContext {
......
150 151
     */
151 152
    if (!rdt->mlti_data)
152 153
        return -1;
153
    init_put_byte(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
154
    ffio_init_context(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
154 155
                  NULL, NULL, NULL, NULL);
155 156
    tag = get_le32(&pb);
156 157
    if (tag == MKTAG('M', 'L', 'T', 'I')) {
......
300 301
    if (rdt->audio_pkt_cnt == 0) {
301 302
        int pos;
302 303

  
303
        init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
304
        ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
304 305
        flags = (flags & RTP_FLAG_KEY) ? 2 : 0;
305 306
        res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt,
306 307
                                  &seq, flags, *timestamp);
libavformat/rtpdec_asf.c
32 32
#include "rtpdec_formats.h"
33 33
#include "rtsp.h"
34 34
#include "asf.h"
35
#include "avio_internal.h"
35 36

  
36 37
/**
37 38
 * From MSDN 2.2.1.4, we learn that ASF data packets over RTP should not
......
84 85

  
85 86
static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len)
86 87
{
87
    init_put_byte(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);
88
    ffio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);
88 89

  
89 90
    /* this "fills" the buffer with its current content */
90 91
    pb->pos     = len;
......
176 177

  
177 178
        av_freep(&asf->buf);
178 179

  
179
        init_put_byte(pb, buf, len, 0, NULL, NULL, NULL, NULL);
180
        ffio_init_context(pb, buf, len, 0, NULL, NULL, NULL, NULL);
180 181

  
181 182
        while (url_ftell(pb) + 4 < len) {
182 183
            int start_off = url_ftell(pb);
libavformat/rtpdec_qt.c
26 26
 */
27 27

  
28 28
#include "avformat.h"
29
#include "avio_internal.h"
29 30
#include "rtp.h"
30 31
#include "rtpdec.h"
31 32
#include "isom.h"
......
69 70
     * http://developer.apple.com/quicktime/icefloe/dispatch026.html
70 71
     */
71 72
    init_get_bits(&gb, buf, len << 3);
72
    init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
73
    ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
73 74

  
74 75
    if (len < 4)
75 76
        return AVERROR_INVALIDDATA;
libavformat/rtsp.c
25 25
#include "libavutil/parseutils.h"
26 26
#include "libavutil/random_seed.h"
27 27
#include "avformat.h"
28
#include "avio_internal.h"
28 29

  
29 30
#include <sys/time.h>
30 31
#if HAVE_POLL_H
......
1913 1914
             port, payload_type);
1914 1915
    av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
1915 1916

  
1916
    init_put_byte(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
1917
    ffio_init_context(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
1917 1918
    s->pb = &pb;
1918 1919

  
1919 1920
    /* sdp_read_header initializes this again */
libavformat/sapdec.c
25 25
#include "network.h"
26 26
#include "os_support.h"
27 27
#include "internal.h"
28
#include "avio_internal.h"
28 29
#if HAVE_POLL_H
29 30
#include <poll.h>
30 31
#endif
......
142 143
    }
143 144

  
144 145
    av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sap->sdp);
145
    init_put_byte(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL,
146
    ffio_init_context(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL,
146 147
                  NULL, NULL);
147 148

  
148 149
    infmt = av_find_input_format("sdp");

Also available in: Unified diff