00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "avformat.h"
00022
00023
00024
00025 #define BOUNDARY_TAG "ffserver"
00026
00027 static int mpjpeg_write_header(AVFormatContext *s)
00028 {
00029 uint8_t buf1[256];
00030
00031 snprintf(buf1, sizeof(buf1), "--%s\n", BOUNDARY_TAG);
00032 avio_write(s->pb, buf1, strlen(buf1));
00033 avio_flush(s->pb);
00034 return 0;
00035 }
00036
00037 static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
00038 {
00039 uint8_t buf1[256];
00040
00041 snprintf(buf1, sizeof(buf1), "Content-type: image/jpeg\n\n");
00042 avio_write(s->pb, buf1, strlen(buf1));
00043 avio_write(s->pb, pkt->data, pkt->size);
00044
00045 snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG);
00046 avio_write(s->pb, buf1, strlen(buf1));
00047 avio_flush(s->pb);
00048 return 0;
00049 }
00050
00051 static int mpjpeg_write_trailer(AVFormatContext *s)
00052 {
00053 return 0;
00054 }
00055
00056 AVOutputFormat ff_mpjpeg_muxer = {
00057 "mpjpeg",
00058 NULL_IF_CONFIG_SMALL("MIME multipart JPEG format"),
00059 "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG,
00060 "mjpg",
00061 0,
00062 CODEC_ID_NONE,
00063 CODEC_ID_MJPEG,
00064 mpjpeg_write_header,
00065 mpjpeg_write_packet,
00066 mpjpeg_write_trailer,
00067 };