#include "metadata.h"
#include "riff.h"
#include "asf.h"
+#include "avio_internal.h"
#undef NDEBUG
#include <assert.h>
asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
- init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1,
+ ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
NULL, NULL, NULL, NULL);
return 0;
asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
- init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1,
+ ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
NULL, NULL, NULL, NULL);
}
#if FF_API_OLD_AVIO
typedef attribute_deprecated AVIOContext ByteIOContext;
-#endif
-int init_put_byte(AVIOContext *s,
+attribute_deprecated int init_put_byte(AVIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence));
+#endif
AVIOContext *av_alloc_put_byte(
unsigned char *buffer,
int buffer_size,
--- /dev/null
+/*
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFORMAT_AVIO_INTERNAL_H
+#define AVFORMAT_AVIO_INTERNAL_H
+
+#include "avio.h"
+
+int ffio_init_context(AVIOContext *s,
+ unsigned char *buffer,
+ int buffer_size,
+ int write_flag,
+ void *opaque,
+ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int64_t (*seek)(void *opaque, int64_t offset, int whence));
+
+
+#endif // AVFORMAT_AVIO_INTERNAL_H
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avio.h"
+#include "avio_internal.h"
#include "internal.h"
#include <stdarg.h>
static int url_resetbuf(AVIOContext *s, int flags);
#endif
-int init_put_byte(AVIOContext *s,
+int ffio_init_context(AVIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
return 0;
}
+#if FF_API_OLD_AVIO
+int init_put_byte(AVIOContext *s,
+ unsigned char *buffer,
+ int buffer_size,
+ int write_flag,
+ void *opaque,
+ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int64_t (*seek)(void *opaque, int64_t offset, int whence))
+{
+ return ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
+ read_packet, write_packet, seek);
+}
+#endif
+
AVIOContext *av_alloc_put_byte(
unsigned char *buffer,
int buffer_size,
int64_t (*seek)(void *opaque, int64_t offset, int whence))
{
AVIOContext *s = av_mallocz(sizeof(AVIOContext));
- init_put_byte(s, buffer, buffer_size, write_flag, opaque,
+ ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
read_packet, write_packet, seek);
return s;
}
return AVERROR(ENOMEM);
}
- if (init_put_byte(*s, buffer, buffer_size,
+ if (ffio_init_context(*s, buffer, buffer_size,
(h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
url_read, url_write, url_seek) < 0) {
av_free(buffer);
*s = av_mallocz(sizeof(AVIOContext));
if(!*s)
return AVERROR(ENOMEM);
- ret = init_put_byte(*s, buf, buf_size,
+ ret = ffio_init_context(*s, buf, buf_size,
(flags & URL_WRONLY || flags & URL_RDWR),
NULL, NULL, NULL, NULL);
if(ret != 0)
return AVERROR(ENOMEM);
}
d->io_buffer_size = io_buffer_size;
- ret = init_put_byte(*s, d->io_buffer, io_buffer_size,
+ ret = ffio_init_context(*s, d->io_buffer, io_buffer_size,
1, d, NULL,
max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
max_packet_size ? NULL : dyn_buf_seek);
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "metadata.h"
+#include "avio_internal.h"
int ff_id3v2_match(const uint8_t *buf, const char * magic)
{
j--;
}
}
- init_put_byte(&pb, buffer, j, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, buffer, j, 0, NULL, NULL, NULL, NULL);
read_ttag(s, &pb, j, tag);
} else {
read_ttag(s, s->pb, tlen, tag);
#include <stdio.h>
#include "avformat.h"
#include "internal.h"
+#include "avio_internal.h"
/* For ff_codec_get_id(). */
#include "riff.h"
#include "isom.h"
uint8_t *data, uint32_t size, uint64_t *num)
{
AVIOContext pb;
- init_put_byte(&pb, data, size, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, data, size, 0, NULL, NULL, NULL, NULL);
return ebml_read_num(matroska, &pb, FFMIN(size, 8), num);
}
} else if (!strcmp(track->codec_id, "A_MS/ACM")
&& track->codec_priv.size >= 14
&& track->codec_priv.data != NULL) {
- init_put_byte(&b, track->codec_priv.data, track->codec_priv.size,
+ ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size,
URL_RDONLY, NULL, NULL, NULL, NULL);
ff_get_wav_header(&b, st->codec, track->codec_priv.size);
codec_id = st->codec->codec_id;
extradata = av_mallocz(extradata_size);
if (extradata == NULL)
return AVERROR(ENOMEM);
- init_put_byte(&b, extradata, extradata_size, 1,
+ ffio_init_context(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
put_buffer(&b, "TTA1", 4);
put_le16(&b, 1);
} else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3 || codec_id == CODEC_ID_SIPR) {
int flavor;
- init_put_byte(&b, track->codec_priv.data,track->codec_priv.size,
+ ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
url_fskip(&b, 22);
flavor = get_be16(&b);
#include "avformat.h"
#include "mms.h"
#include "internal.h"
+#include "avio_internal.h"
#include "libavutil/intreadwrite.h"
#include "libavcodec/bytestream.h"
#include "network.h"
AVIOContext bic;
int size = mms->write_out_ptr - mms->out_buffer;
int len;
- init_put_byte(&bic, mms->write_out_ptr,
+ ffio_init_context(&bic, mms->write_out_ptr,
sizeof(mms->out_buffer) - size, 1, NULL, NULL, NULL, NULL);
len = avio_put_str16le(&bic, src);
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include "avformat.h"
+#include "avio_internal.h"
#include "riff.h"
#include "isom.h"
#include "libavcodec/get_bits.h"
get_buffer(pb, cmov_data, cmov_len);
if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK)
goto free_and_return;
- if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
+ if(ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
goto free_and_return;
atom.type = MKTAG('m','o','o','v');
atom.size = moov_len;
#include "avformat.h"
#include "mpegts.h"
#include "internal.h"
+#include "avio_internal.h"
#include "seek.h"
#include "mpeg.h"
#include "isom.h"
int tag;
unsigned len;
- init_put_byte(&pb, buf, size, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, buf, size, 0, NULL, NULL, NULL, NULL);
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4IODescrTag) {
if (st->codec->codec_id == CODEC_ID_AAC_LATM &&
mp4_dec_config_descr_len && mp4_es_id == pid) {
AVIOContext pb;
- init_put_byte(&pb, mp4_dec_config_descr,
+ ffio_init_context(&pb, mp4_dec_config_descr,
mp4_dec_config_descr_len, 0, NULL, NULL, NULL, NULL);
ff_mp4_read_dec_config_descr(fc, st, &pb);
if (st->codec->codec_id == CODEC_ID_AAC &&
#include "libavutil/md5.h"
#include "rm.h"
#include "internal.h"
+#include "avio_internal.h"
#include "libavcodec/get_bits.h"
struct RDTDemuxContext {
*/
if (!rdt->mlti_data)
return -1;
- init_put_byte(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
+ ffio_init_context(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
NULL, NULL, NULL, NULL);
tag = get_le32(&pb);
if (tag == MKTAG('M', 'L', 'T', 'I')) {
if (rdt->audio_pkt_cnt == 0) {
int pos;
- init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
flags = (flags & RTP_FLAG_KEY) ? 2 : 0;
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt,
&seq, flags, *timestamp);
#include "rtpdec_formats.h"
#include "rtsp.h"
#include "asf.h"
+#include "avio_internal.h"
/**
* From MSDN 2.2.1.4, we learn that ASF data packets over RTP should not
static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len)
{
- init_put_byte(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);
+ ffio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);
/* this "fills" the buffer with its current content */
pb->pos = len;
av_freep(&asf->buf);
- init_put_byte(pb, buf, len, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(pb, buf, len, 0, NULL, NULL, NULL, NULL);
while (url_ftell(pb) + 4 < len) {
int start_off = url_ftell(pb);
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "rtp.h"
#include "rtpdec.h"
#include "isom.h"
* http://developer.apple.com/quicktime/icefloe/dispatch026.html
*/
init_get_bits(&gb, buf, len << 3);
- init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
if (len < 4)
return AVERROR_INVALIDDATA;
#include "libavutil/parseutils.h"
#include "libavutil/random_seed.h"
#include "avformat.h"
+#include "avio_internal.h"
#include <sys/time.h>
#if HAVE_POLL_H
port, payload_type);
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
- init_put_byte(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
s->pb = &pb;
/* sdp_read_header initializes this again */
#include "network.h"
#include "os_support.h"
#include "internal.h"
+#include "avio_internal.h"
#if HAVE_POLL_H
#include <poll.h>
#endif
}
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sap->sdp);
- init_put_byte(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL,
+ ffio_init_context(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL,
NULL, NULL);
infmt = av_find_input_format("sdp");