*/
#include "avformat.h"
+#include "rtpdec.h"
#include "rtpdec_formats.h"
#include "libavutil/intreadwrite.h"
#include "libavcodec/mjpeg.h"
static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
- const uint8_t *buf, int len, int flags)
+ const uint8_t *buf, int len, uint16_t seq,
+ int flags)
{
uint8_t type, q, width, height;
const uint8_t *qtables = NULL;
"Unimplemented RTP/JPEG restart marker header.\n");
return AVERROR_PATCHWELCOME;
}
+ if (type > 1) {
+ av_log(ctx, AV_LOG_ERROR, "Unimplemented RTP/JPEG type %d\n", type);
+ return AVERROR_PATCHWELCOME;
+ }
/* Parse the quantization table header. */
if (off == 0) {
avio_write(jpeg->frame, buf, sizeof(buf));
/* Prepare the JPEG packet. */
- av_init_packet(pkt);
- pkt->size = avio_close_dyn_buf(jpeg->frame, &pkt->data);
- if (pkt->size < 0) {
+ if ((ret = ff_rtp_finalize_packet(pkt, &jpeg->frame, st->index)) < 0) {
av_log(ctx, AV_LOG_ERROR,
- "Error occured when getting frame buffer.\n");
- jpeg->frame = NULL;
- return pkt->size;
+ "Error occurred when getting frame buffer.\n");
+ return ret;
}
- pkt->stream_index = st->index;
- pkt->destruct = av_destruct_packet;
-
- /* Re-init the frame buffer. */
- jpeg->frame = NULL;
return 0;
}