2 * Multipart JPEG format
3 * Copyright (c) 2000, 2001, 2002, 2003 Fabrice Bellard.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define BOUNDARY_TAG "ffserver"
25 #ifdef CONFIG_ENCODERS
26 static int mpjpeg_write_header(AVFormatContext *s)
30 snprintf(buf1, sizeof(buf1), "--%s\n", BOUNDARY_TAG);
31 put_buffer(&s->pb, buf1, strlen(buf1));
32 put_flush_packet(&s->pb);
36 static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
40 snprintf(buf1, sizeof(buf1), "Content-type: image/jpeg\n\n");
41 put_buffer(&s->pb, buf1, strlen(buf1));
42 put_buffer(&s->pb, pkt->data, pkt->size);
44 snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG);
45 put_buffer(&s->pb, buf1, strlen(buf1));
46 put_flush_packet(&s->pb);
50 static int mpjpeg_write_trailer(AVFormatContext *s)
55 static AVOutputFormat mpjpeg_format = {
57 "Mime multipart JPEG format",
58 "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG,
69 /*************************************/
70 /* single frame JPEG */
72 static int single_jpeg_write_header(AVFormatContext *s)
77 static int single_jpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
79 put_buffer(&s->pb, pkt->data, pkt->size);
80 put_flush_packet(&s->pb);
81 return 1; /* no more data can be sent */
84 static int single_jpeg_write_trailer(AVFormatContext *s)
89 static AVOutputFormat single_jpeg_format = {
93 NULL, /* note: no extension to favorize jpeg multiple images match */
97 single_jpeg_write_header,
98 single_jpeg_write_packet,
99 single_jpeg_write_trailer,
104 av_register_output_format(&mpjpeg_format);
105 av_register_output_format(&single_jpeg_format);
108 #endif //CONFIG_ENCODERS