*/
#include "avformat.h"
+#include "avio_internal.h"
#include "rtpdec_formats.h"
#define RTP_AC3_PAYLOAD_HEADER_SIZE 2
AVIOContext *fragment;
};
-static void free_fragment(PayloadContext *data)
-{
- if (data->fragment) {
- uint8_t *p;
- avio_close_dyn_buf(data->fragment, &p);
- av_free(p);
- data->fragment = NULL;
- }
-}
-
static void ac3_free_context(PayloadContext *data)
{
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
}
static int ac3_handle_packet(AVFormatContext *ctx, PayloadContext *data,
case 1:
case 2: /* First fragment */
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
data->last_frame = 1;
data->nr_frames = nr_frames;
}
if (nr_frames != data->nr_frames ||
data->timestamp != *timestamp) {
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
av_log(ctx, AV_LOG_ERROR, "Invalid packet received\n");
return AVERROR_INVALIDDATA;
}
return AVERROR(EAGAIN);
if (data->last_frame != data->nr_frames) {
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
av_log(ctx, AV_LOG_ERROR, "Missed %d packets\n",
data->nr_frames - data->last_frame);
return AVERROR_INVALIDDATA;
* multiple RTP packets.
*/
if (asf->pktbuf && len_off != avio_tell(asf->pktbuf)) {
- uint8_t *p;
- avio_close_dyn_buf(asf->pktbuf, &p);
- asf->pktbuf = NULL;
- av_free(p);
+ ffio_free_dyn_buf(&asf->pktbuf);
}
if (!len_off && !asf->pktbuf &&
(res = avio_open_dyn_buf(&asf->pktbuf)) < 0)
static void asfrtp_free_context(PayloadContext *asf)
{
- if (asf->pktbuf) {
- uint8_t *p = NULL;
- avio_close_dyn_buf(asf->pktbuf, &p);
- asf->pktbuf = NULL;
- av_free(p);
- }
+ ffio_free_dyn_buf(&asf->pktbuf);
av_freep(&asf->buf);
av_free(asf);
}
#include "libavcodec/bytestream.h"
+#include "avio_internal.h"
#include "rtpdec_formats.h"
struct PayloadContext {
int bundled_audio;
};
-static void dv_free_dyn_buffer(AVIOContext **dyn_buf)
-{
- uint8_t *ptr_dyn_buffer;
- avio_close_dyn_buf(*dyn_buf, &ptr_dyn_buffer);
- av_free(ptr_dyn_buffer);
- *dyn_buf = NULL;
-}
-
static av_cold void dv_free_context(PayloadContext *data)
{
- dv_free_dyn_buffer(&data->buf);
+ ffio_free_dyn_buf(&data->buf);
}
static av_cold int dv_sdp_parse_fmtp_config(AVFormatContext *s,
/* drop data of previous packets in case of non-continuous (lossy) packet stream */
if (rtp_dv_ctx->buf && rtp_dv_ctx->timestamp != *timestamp) {
- dv_free_dyn_buffer(&rtp_dv_ctx->buf);
+ ffio_free_dyn_buf(&rtp_dv_ctx->buf);
}
/* sanity check for size of input packet: 1 byte payload at least */
#include "libavcodec/get_bits.h"
#include "avformat.h"
+#include "avio_internal.h"
#include "rtpdec_formats.h"
#define RTP_H261_PAYLOAD_HEADER_SIZE 4
uint32_t timestamp;
};
-static void h261_free_dyn_buffer(AVIOContext **dyn_buf)
-{
- uint8_t *ptr_dyn_buffer;
- avio_close_dyn_buf(*dyn_buf, &ptr_dyn_buffer);
- av_free(ptr_dyn_buffer);
- *dyn_buf = NULL;
-}
-
static av_cold void h261_free_context(PayloadContext *pl_ctx)
{
/* return if context is invalid */
return;
/* free buffer if it is valid */
- if (pl_ctx->buf) {
- h261_free_dyn_buffer(&pl_ctx->buf);
- }
+ ffio_free_dyn_buf(&pl_ctx->buf);
}
static int h261_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_h261_ctx,
/* drop data of previous packets in case of non-continuous (lossy) packet stream */
if (rtp_h261_ctx->buf && rtp_h261_ctx->timestamp != *timestamp) {
- h261_free_dyn_buffer(&rtp_h261_ctx->buf);
+ ffio_free_dyn_buf(&rtp_h261_ctx->buf);
rtp_h261_ctx->endbyte_bits = 0;
}
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "rtpdec_formats.h"
#include "libavutil/attributes.h"
#include "libavutil/intreadwrite.h"
static void h263_free_context(PayloadContext *data)
{
- if (data->buf) {
- uint8_t *p;
- avio_close_dyn_buf(data->buf, &p);
- av_free(p);
- }
+ ffio_free_dyn_buf(&data->buf);
}
static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
if (data->buf && data->timestamp != *timestamp) {
/* Dropping old buffered, unfinished data */
- uint8_t *p;
- avio_close_dyn_buf(data->buf, &p);
- av_free(p);
- data->buf = NULL;
+ ffio_free_dyn_buf(&data->buf);
data->endbyte_bits = 0;
}
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "rtpdec.h"
#include "rtpdec_formats.h"
#include "libavutil/intreadwrite.h"
99, 99, 99, 99, 99, 99, 99, 99
};
-static void free_frame(PayloadContext *jpeg)
-{
- if (jpeg->frame) {
- uint8_t *p;
- avio_close_dyn_buf(jpeg->frame, &p);
- av_free(p);
- jpeg->frame = NULL;
- }
-}
-
static void jpeg_free_context(PayloadContext *jpeg)
{
- free_frame(jpeg);
+ ffio_free_dyn_buf(&jpeg->frame);
}
static int jpeg_create_huffman_table(PutByteContext *p, int table_class,
/* Skip the current frame in case of the end packet
* has been lost somewhere. */
- free_frame(jpeg);
+ ffio_free_dyn_buf(&jpeg->frame);
if ((ret = avio_open_dyn_buf(&jpeg->frame)) < 0)
return ret;
if (jpeg->timestamp != *timestamp) {
/* Skip the current frame if timestamp is incorrect.
* A start packet has been lost somewhere. */
- free_frame(jpeg);
+ ffio_free_dyn_buf(&jpeg->frame);
av_log(ctx, AV_LOG_ERROR, "RTP timestamps don't match.\n");
return AVERROR_INVALIDDATA;
}
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "avio_internal.h"
#include "rtpdec_formats.h"
#include "internal.h"
#include "libavutil/avstring.h"
static void latm_free_context(PayloadContext *data)
{
- if (data->dyn_buf) {
- uint8_t *p;
- avio_close_dyn_buf(data->dyn_buf, &p);
- av_free(p);
- }
+ ffio_free_dyn_buf(&data->dyn_buf);
av_free(data->buf);
}
if (buf) {
if (!data->dyn_buf || data->timestamp != *timestamp) {
av_freep(&data->buf);
- if (data->dyn_buf)
- avio_close_dyn_buf(data->dyn_buf, &data->buf);
- data->dyn_buf = NULL;
- av_freep(&data->buf);
+ ffio_free_dyn_buf(&data->dyn_buf);
data->timestamp = *timestamp;
if ((ret = avio_open_dyn_buf(&data->dyn_buf)) < 0)
#include "libavutil/attributes.h"
#include "libavutil/intreadwrite.h"
+#include "avio_internal.h"
#include "rtpdec_formats.h"
struct PayloadContext {
AVIOContext *fragment;
};
-static void free_fragment(PayloadContext *data)
-{
- if (data->fragment) {
- uint8_t *p;
- avio_close_dyn_buf(data->fragment, &p);
- av_free(p);
- data->fragment = NULL;
- }
-}
-
static void mpa_robust_free_context(PayloadContext *data)
{
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
av_free(data->split_buf);
}
return 0;
} else if (!continuation) { /* && adu_size > len */
/* First fragment */
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
data->adu_size = adu_size;
data->cur_size = len;
}
if (adu_size = data->adu_size ||
data->timestamp != *timestamp) {
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
av_log(ctx, AV_LOG_ERROR, "Invalid packet received\n");
return AVERROR_INVALIDDATA;
}
#include <string.h>
#include "libavutil/intreadwrite.h"
+#include "avio_internal.h"
#include "rtp.h"
#include "rtpdec.h"
#include "rtpdec_formats.h"
if (start_packet) {
int res;
- if (sv->pktbuf) {
- uint8_t *tmp;
- avio_close_dyn_buf(sv->pktbuf, &tmp);
- av_free(tmp);
- }
+ ffio_free_dyn_buf(&sv->pktbuf);
if ((res = avio_open_dyn_buf(&sv->pktbuf)) < 0)
return res;
sv->timestamp = *timestamp;
static void svq3_extradata_free(PayloadContext *sv)
{
- if (sv->pktbuf) {
- uint8_t *buf;
- avio_close_dyn_buf(sv->pktbuf, &buf);
- av_free(buf);
- }
+ ffio_free_dyn_buf(&sv->pktbuf);
}
RTPDynamicProtocolHandler ff_svq3_dynamic_handler = {
#include "libavcodec/bytestream.h"
+#include "avio_internal.h"
#include "rtpdec_formats.h"
struct PayloadContext {
int got_keyframe;
};
-static void vp8_free_buffer(PayloadContext *vp8)
-{
- uint8_t *tmp;
- if (!vp8->data)
- return;
- avio_close_dyn_buf(vp8->data, &tmp);
- av_free(tmp);
- vp8->data = NULL;
-}
-
static int vp8_broken_sequence(AVFormatContext *ctx, PayloadContext *vp8,
const char *msg)
{
vp8->sequence_ok = 0;
av_log(ctx, AV_LOG_WARNING, "%s", msg);
- vp8_free_buffer(vp8);
+ ffio_free_dyn_buf(&vp8->data);
return AVERROR(EAGAIN);
}
int res;
int non_key = buf[0] & 0x01;
if (!non_key) {
- vp8_free_buffer(vp8);
+ ffio_free_dyn_buf(&vp8->data);
// Keyframe, decoding ok again
vp8->sequence_ok = 1;
vp8->sequence_dirty = 0;
old_timestamp = vp8->timestamp;
} else {
// Shouldn't happen
- vp8_free_buffer(vp8);
+ ffio_free_dyn_buf(&vp8->data);
}
}
}
static void vp8_free_context(PayloadContext *vp8)
{
- vp8_free_buffer(vp8);
+ ffio_free_dyn_buf(&vp8->data);
}
static int vp8_need_keyframe(PayloadContext *vp8)
#include <assert.h>
+#include "avio_internal.h"
#include "rtpdec.h"
#include "rtpdec_formats.h"
int split_pkts;
};
-static void free_fragment(PayloadContext * data)
-{
- if (data->fragment) {
- uint8_t* p;
- avio_close_dyn_buf(data->fragment, &p);
- av_free(p);
- data->fragment = NULL;
- }
-}
-
static void xiph_free_context(PayloadContext * data)
{
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
av_free(data->split_buf);
}
int res;
// end packet has been lost somewhere, so drop buffered data
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
if((res = avio_open_dyn_buf(&data->fragment)) < 0)
return res;
if (data->timestamp != *timestamp) {
// skip if fragmented timestamp is incorrect;
// a start packet has been lost somewhere
- free_fragment(data);
+ ffio_free_dyn_buf(&data->fragment);
av_log(ctx, AV_LOG_ERROR, "RTP timestamps don't match!\n");
return AVERROR_INVALIDDATA;
}