diff options
Diffstat (limited to 'libavformat/mpjpeg.c')
-rw-r--r-- | libavformat/mpjpeg.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/libavformat/mpjpeg.c b/libavformat/mpjpeg.c index 1a78c32274..3904ccb2b4 100644 --- a/libavformat/mpjpeg.c +++ b/libavformat/mpjpeg.c @@ -2,44 +2,51 @@ * Multipart JPEG format * Copyright (c) 2000, 2001, 2002, 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/opt.h" #include "avformat.h" /* Multipart JPEG */ -#define BOUNDARY_TAG "avserver" +#define BOUNDARY_TAG "ffserver" + +typedef struct MPJPEGContext { + AVClass *class; + char *boundary_tag; +} MPJPEGContext; static int mpjpeg_write_header(AVFormatContext *s) { - avio_printf(s->pb, "--%s\n", BOUNDARY_TAG); + MPJPEGContext *mpj = s->priv_data; + avio_printf(s->pb, "--%s\r\n", mpj->boundary_tag); avio_flush(s->pb); return 0; } static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt) { - avio_printf(s->pb, - "Content-length: %i\n" - "Content-type: image/jpeg\n\n", + MPJPEGContext *mpj = s->priv_data; + avio_printf(s->pb, "Content-type: image/jpeg\r\n"); + avio_printf(s->pb, "Content-length: %d\r\n\r\n", pkt->size); avio_write(s->pb, pkt->data, pkt->size); - avio_printf(s->pb, "\n--%s\n", BOUNDARY_TAG); + avio_printf(s->pb, "\r\n--%s\r\n", mpj->boundary_tag); return 0; } @@ -48,15 +55,29 @@ static int mpjpeg_write_trailer(AVFormatContext *s) return 0; } +static const AVOption options[] = { + { "boundary_tag", "Boundary tag", offsetof(MPJPEGContext, boundary_tag), AV_OPT_TYPE_STRING, {.str = BOUNDARY_TAG}, .flags = AV_OPT_FLAG_ENCODING_PARAM }, + { NULL }, +}; + +static const AVClass mpjpeg_muxer_class = { + .class_name = "mpjpeg_muxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVOutputFormat ff_mpjpeg_muxer = { .name = "mpjpeg", .long_name = NULL_IF_CONFIG_SMALL("MIME multipart JPEG"), .mime_type = "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG, .extensions = "mjpg", + .priv_data_size = sizeof(MPJPEGContext), .audio_codec = AV_CODEC_ID_NONE, .video_codec = AV_CODEC_ID_MJPEG, .write_header = mpjpeg_write_header, .write_packet = mpjpeg_write_packet, .write_trailer = mpjpeg_write_trailer, .flags = AVFMT_NOTIMESTAMPS, + .priv_class = &mpjpeg_muxer_class, }; |