2003-02-02 21:18:09 +02:00
|
|
|
/*
|
|
|
|
* Multipart JPEG format
|
2009-01-19 17:46:40 +02:00
|
|
|
* Copyright (c) 2000, 2001, 2002, 2003 Fabrice Bellard
|
2003-02-02 21:18:09 +02:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* This file is part of Libav.
|
2006-10-07 18:30:46 +03:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2003-02-02 21:18:09 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 18:30:46 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-02-02 21:18:09 +02:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2003-02-02 21:18:09 +02:00
|
|
|
* 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
|
2011-03-18 19:35:10 +02:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2006-01-13 00:43:26 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-02-02 21:18:09 +02:00
|
|
|
*/
|
|
|
|
#include "avformat.h"
|
|
|
|
|
|
|
|
/* Multipart JPEG */
|
|
|
|
|
2011-07-26 22:56:56 +03:00
|
|
|
#define BOUNDARY_TAG "avserver"
|
2003-02-02 21:18:09 +02:00
|
|
|
|
|
|
|
static int mpjpeg_write_header(AVFormatContext *s)
|
|
|
|
{
|
2015-07-04 00:46:44 +02:00
|
|
|
avio_printf(s->pb, "--%s\n", BOUNDARY_TAG);
|
2011-03-14 21:39:06 +02:00
|
|
|
avio_flush(s->pb);
|
2003-02-02 21:18:09 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-05-29 05:06:32 +03:00
|
|
|
static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
|
2003-02-02 21:18:09 +02:00
|
|
|
{
|
2015-07-04 00:48:47 +02:00
|
|
|
avio_printf(s->pb,
|
|
|
|
"Content-length: %i\n"
|
|
|
|
"Content-type: image/jpeg\n\n",
|
|
|
|
pkt->size);
|
2011-02-21 20:28:17 +02:00
|
|
|
avio_write(s->pb, pkt->data, pkt->size);
|
2003-02-02 21:18:09 +02:00
|
|
|
|
2015-07-04 00:46:44 +02:00
|
|
|
avio_printf(s->pb, "\n--%s\n", BOUNDARY_TAG);
|
2003-02-02 21:18:09 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mpjpeg_write_trailer(AVFormatContext *s)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-26 00:03:28 +02:00
|
|
|
AVOutputFormat ff_mpjpeg_muxer = {
|
2011-07-16 23:18:12 +03:00
|
|
|
.name = "mpjpeg",
|
2012-07-25 00:51:41 +03:00
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("MIME multipart JPEG"),
|
2011-07-16 23:18:12 +03:00
|
|
|
.mime_type = "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG,
|
|
|
|
.extensions = "mjpg",
|
2012-08-05 12:11:04 +03:00
|
|
|
.audio_codec = AV_CODEC_ID_NONE,
|
|
|
|
.video_codec = AV_CODEC_ID_MJPEG,
|
2011-07-16 23:18:12 +03:00
|
|
|
.write_header = mpjpeg_write_header,
|
|
|
|
.write_packet = mpjpeg_write_packet,
|
|
|
|
.write_trailer = mpjpeg_write_trailer,
|
2014-05-29 08:06:52 +03:00
|
|
|
.flags = AVFMT_NOTIMESTAMPS,
|
2003-02-02 21:18:09 +02:00
|
|
|
};
|