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 .name = "mpjpeg",
00058 .long_name = NULL_IF_CONFIG_SMALL("MIME multipart JPEG format"),
00059 .mime_type = "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG,
00060 .extensions = "mjpg",
00061 .audio_codec = CODEC_ID_NONE,
00062 .video_codec = CODEC_ID_MJPEG,
00063 .write_header = mpjpeg_write_header,
00064 .write_packet = mpjpeg_write_packet,
00065 .write_trailer = mpjpeg_write_trailer,
00066 };