2003-02-02 20:18:09 +01:00
|
|
|
/*
|
|
|
|
* Multipart JPEG format
|
|
|
|
* Copyright (c) 2000, 2001, 2002, 2003 Fabrice Bellard.
|
|
|
|
*
|
2006-10-07 17:30:46 +02:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2003-02-02 20:18:09 +01:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 17:30:46 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-02-02 20:18:09 +01:00
|
|
|
*
|
2006-10-07 17:30:46 +02:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2003-02-02 20:18:09 +01: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
|
2006-10-07 17:30:46 +02:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2006-01-12 23:43:26 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-02-02 20:18:09 +01:00
|
|
|
*/
|
|
|
|
#include "avformat.h"
|
|
|
|
|
|
|
|
/* Multipart JPEG */
|
|
|
|
|
|
|
|
#define BOUNDARY_TAG "ffserver"
|
|
|
|
|
|
|
|
static int mpjpeg_write_header(AVFormatContext *s)
|
|
|
|
{
|
2003-02-11 17:35:48 +01:00
|
|
|
uint8_t buf1[256];
|
2003-02-02 20:18:09 +01:00
|
|
|
|
|
|
|
snprintf(buf1, sizeof(buf1), "--%s\n", BOUNDARY_TAG);
|
2007-11-21 08:41:00 +01:00
|
|
|
put_buffer(s->pb, buf1, strlen(buf1));
|
|
|
|
put_flush_packet(s->pb);
|
2003-02-02 20:18:09 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-05-29 04:06:32 +02:00
|
|
|
static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
|
2003-02-02 20:18:09 +01:00
|
|
|
{
|
2003-02-11 17:35:48 +01:00
|
|
|
uint8_t buf1[256];
|
2003-02-02 20:18:09 +01:00
|
|
|
|
|
|
|
snprintf(buf1, sizeof(buf1), "Content-type: image/jpeg\n\n");
|
2007-11-21 08:41:00 +01:00
|
|
|
put_buffer(s->pb, buf1, strlen(buf1));
|
|
|
|
put_buffer(s->pb, pkt->data, pkt->size);
|
2003-02-02 20:18:09 +01:00
|
|
|
|
|
|
|
snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG);
|
2007-11-21 08:41:00 +01:00
|
|
|
put_buffer(s->pb, buf1, strlen(buf1));
|
|
|
|
put_flush_packet(s->pb);
|
2003-02-02 20:18:09 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mpjpeg_write_trailer(AVFormatContext *s)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-07-10 23:14:37 +02:00
|
|
|
AVOutputFormat mpjpeg_muxer = {
|
2003-02-02 20:18:09 +01:00
|
|
|
"mpjpeg",
|
2008-06-03 18:20:54 +02:00
|
|
|
NULL_IF_CONFIG_SMALL("Mime multipart JPEG format"),
|
2003-02-02 20:18:09 +01:00
|
|
|
"multipart/x-mixed-replace;boundary=" BOUNDARY_TAG,
|
|
|
|
"mjpg",
|
|
|
|
0,
|
|
|
|
CODEC_ID_NONE,
|
|
|
|
CODEC_ID_MJPEG,
|
|
|
|
mpjpeg_write_header,
|
|
|
|
mpjpeg_write_packet,
|
|
|
|
mpjpeg_write_trailer,
|
|
|
|
};
|