0250738f |
/*
* Multipart JPEG format |
406792e7 |
* Copyright (c) 2000, 2001, 2002, 2003 Fabrice Bellard |
0250738f |
* |
b78e7197 |
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or |
0250738f |
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either |
b78e7197 |
* version 2.1 of the License, or (at your option) any later version. |
0250738f |
* |
b78e7197 |
* FFmpeg is distributed in the hope that it will be useful, |
0250738f |
* 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 |
b78e7197 |
* License along with FFmpeg; if not, write to the Free Software |
5509bffa |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0250738f |
*/ |
a0528d9d |
#include "libavutil/opt.h" |
0250738f |
#include "avformat.h"
/* Multipart JPEG */
#define BOUNDARY_TAG "ffserver"
|
a0528d9d |
typedef struct MPJPEGContext {
AVClass *class;
char *boundary_tag;
} MPJPEGContext;
|
0250738f |
static int mpjpeg_write_header(AVFormatContext *s)
{ |
a0528d9d |
MPJPEGContext *mpj = s->priv_data; |
2a33dc2c |
avio_printf(s->pb, "--%s\r\n", mpj->boundary_tag); |
b7f2fdde |
avio_flush(s->pb); |
0250738f |
return 0;
}
|
e928649b |
static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt) |
0250738f |
{ |
a0528d9d |
MPJPEGContext *mpj = s->priv_data; |
2a33dc2c |
avio_printf(s->pb, "Content-type: image/jpeg\r\n"); |
17498b70 |
avio_printf(s->pb, "Content-length: %d\r\n\r\n", |
161a301d |
pkt->size); |
77eb5504 |
avio_write(s->pb, pkt->data, pkt->size); |
0250738f |
|
2a33dc2c |
avio_printf(s->pb, "\r\n--%s\r\n", mpj->boundary_tag); |
0250738f |
return 0;
}
static int mpjpeg_write_trailer(AVFormatContext *s)
{
return 0;
}
|
a0528d9d |
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,
};
|
c6610a21 |
AVOutputFormat ff_mpjpeg_muxer = { |
dfc2c4d9 |
.name = "mpjpeg", |
6774247a |
.long_name = NULL_IF_CONFIG_SMALL("MIME multipart JPEG"), |
dfc2c4d9 |
.mime_type = "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG,
.extensions = "mjpg", |
a0528d9d |
.priv_data_size = sizeof(MPJPEGContext), |
36ef5369 |
.audio_codec = AV_CODEC_ID_NONE,
.video_codec = AV_CODEC_ID_MJPEG, |
dfc2c4d9 |
.write_header = mpjpeg_write_header,
.write_packet = mpjpeg_write_packet,
.write_trailer = mpjpeg_write_trailer, |
f792d3cb |
.flags = AVFMT_NOTIMESTAMPS, |
a0528d9d |
.priv_class = &mpjpeg_muxer_class, |
0250738f |
}; |