Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members

mjpeg_pipe.cpp

00001 //           ///          //
00002 //          /////        ////
00003 //         /// XXX     XXX ///
00004 //        ///    XXX XXX    ///     $RCSfile: mjpeg_pipe.cpp,v $  
00005 //       ///       XXX       ///     $Revision: 1.1 $
00006 //      ///      XXX XXX      ///     $Date: 2005/08/09 13:57:26 $
00007 //     ////    XXX     XXX    ////     $Author: cvs-steve $
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems ///////////////////////////////////////////////
00011 
00012 // Copyright (c) 2005, MOBOTIX AG.
00013 // This software is made available under the BSD licence. Please refer 
00014 // to the file LICENCE.TXT contained in this distribution for details.
00015 
00016 
00017 #include <mxcpcFramewiseMxPEGDecoder.h>
00018 
00019 #ifdef USE_IPP
00020 #include <mxcpcFramewiseMxPEGScanToJPEGConverterIPP.h>
00021 #endif
00022 #include <mxcpcFramewiseMxPEGScanToJPEGConverterSoftwareOnly.h>
00023 
00024 #include <mxcpcMJPEGServerpushWriter.h>
00025 #include <mxcpcDefaultMxPEGDecoderBackEnd.h>
00026 #include <mxcpcStreamFile.h>
00027 #include <mxcpcStreamStandardIn.h>
00028 
00029 #include <cstdio>
00030 #include <cstdlib>
00031 
00032 #ifdef HAVE_LIBC
00033 #include <getopt.h>
00034 #else
00035 #include "simpleOptions.h"
00036 #endif
00037 
00038 
00039 int usage(const char* progname, FILE* stream) {
00040     fprintf (stream, "%s: Convert an MxPEG stream to MJPEG\n", progname);
00041     fprintf (stream, "\n");
00042     fprintf (stream, "Usage: %s [options]\n", progname);
00043     fprintf (stream, "\n");
00044     fprintf (stream, "Options:\n");
00045     fprintf (stream, "-b : Use built-in routines instead of acceleration (Note: acceleration \n");
00046     fprintf (stream, "     is only available if compiled in. Currently, Intel's \"Integrated \n");
00047     fprintf (stream, "     Performance Primitves\" library is supported on Windows and Linux.)\n");
00048     fprintf (stream, "-h : This message\n");
00049     fprintf (stream, "-s : Insert a MIME separator between JPEG frames (useful within CGI scripts)\n");
00050     fprintf (stream, "\n");
00051     fprintf (stream, "Examples:\n");
00052     fprintf (stream, "cat file1.mxg file2.mxg | %s > file.mjpg\n", progname);
00053     fprintf (stream, "curl 'http://<camera_ip>/control/faststream.jpg?stream=MxPEG' | %s -s\n", progname);
00054     fprintf (stream, "C:\\> type file1.mxg | %s > file.mjpg\n", progname);
00055     fprintf (stream, "\n", progname);
00056     return 0;
00057 }
00058 
00059 int main(int argc, char* argv[]) {
00060 
00061   mxcpcFramewiseMxPEGDecoder *decoder;
00062   int decoded;
00063   
00064   const char* sep = "";
00065   const char* allowed_opts = "bhs";
00066   bool ipp_active = false;
00067 #ifdef USE_IPP
00068   ipp_active = true;
00069 #endif
00070 
00071 #ifdef HAVE_LIBC
00072   int c;
00073   while ((c = getopt (argc, argv, allowed_opts)) != EOF) {
00074     switch (c) {
00075 #else
00076   CSimpleOptions cl( argc, argv, allowed_opts );
00077   while (cl.next()) {
00078     switch (cl.option()) {
00079 #endif
00080     case 'b': // built-in routines
00081       ipp_active = false;
00082     case 'h': // help
00083       usage ("mjpeg_pipe", stdout);
00084     case 's': // output separator
00085       sep = "MOBOTIX_Fast_Serverpush";
00086     }
00087   }
00088 
00089   mxcpcMJPEGServerpushWriter* writer = new mxcpcMJPEGServerpushWriter (stdout, sep );
00090 
00091   mxcpcFramewiseMxPEGScanDecoder* scandecoder;
00092 
00093 #ifdef USE_IPP
00094   if (ipp_active) {
00095     scandecoder = new mxcpcFramewiseMxPEGScanToJPEGConverterIPP (writer);
00096   } else {
00097 #endif
00098     scandecoder = new mxcpcFramewiseMxPEGScanToJPEGConverterSoftwareOnly (writer);
00099 #ifdef USE_IPP
00100   }
00101 #endif
00102 
00103   decoder = new mxcpcFramewiseMxPEGDecoder(
00104              new mxcpcStreamStandardIn(),
00105              new mxcpcDefaultMxPEGDecoderBackEnd(),
00106              scandecoder
00107              );
00108                    
00109   do {
00110     decoded = decoder->decode(2048);
00111   } while(decoded);
00112   
00113   delete decoder;
00114 }
00115 

Generated on Mon Aug 15 03:39:28 2005 for mxcpc by  doxygen 1.4.2-20050421