• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavformat/mpjpeg.c

Go to the documentation of this file.
00001 /*
00002  * Multipart JPEG format
00003  * Copyright (c) 2000, 2001, 2002, 2003 Fabrice Bellard
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 #include "avformat.h"
00022 
00023 /* Multipart JPEG */
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     put_buffer(s->pb, buf1, strlen(buf1));
00033     put_flush_packet(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     put_buffer(s->pb, buf1, strlen(buf1));
00043     put_buffer(s->pb, pkt->data, pkt->size);
00044 
00045     snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG);
00046     put_buffer(s->pb, buf1, strlen(buf1));
00047     put_flush_packet(s->pb);
00048     return 0;
00049 }
00050 
00051 static int mpjpeg_write_trailer(AVFormatContext *s)
00052 {
00053     return 0;
00054 }
00055 
00056 AVOutputFormat 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 };

Generated on Fri Sep 16 2011 17:17:49 for FFmpeg by  doxygen 1.7.1