00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef MEDIA_HTTPOUTPUTSTREAM_C_DEFINED
00039 #define MEDIA_HTTPOUTPUTSTREAM_C_DEFINED
00040
00041 #include "Media/HttpOutputStream.H"
00042
00043
00044 #include "Component/ModelOptionDef.H"
00045 #include "Image/Image.H"
00046 #include "Image/Pixels.H"
00047 #include "Media/HttpEncoder.H"
00048 #include "Raster/GenericFrame.H"
00049 #include "Transport/TransportOpts.H"
00050 #include "Util/Assert.H"
00051 #include "Util/log.H"
00052 #include "rutz/shared_ptr.h"
00053 #include "rutz/trace.h"
00054
00055 #include <map>
00056 #include <string>
00057
00058 #ifdef INVT_HAVE_AVCODEC
00059
00060
00061
00062 const ModelOptionDef OPT_OutputHttpStreamFrameRate =
00063 { MODOPT_ARG(int), "OutputHttpStreamFrameRate", &MOC_OUTPUT, OPTEXP_CORE,
00064 "The frame rate, in frames-per-second, for output mpeg streams",
00065 "output-http-framerate", '\0', "<frames-per-second>", "25" };
00066
00067
00068 const ModelOptionDef OPT_OutputHttpStreamBitRate =
00069 { MODOPT_ARG(int), "OutputHttpStreamBitRate", &MOC_OUTPUT, OPTEXP_CORE,
00070 "The bit rate for output mpeg streams",
00071
00072
00073 "output-http-bitrate", '\0', "<bits-per-?>", "750000" };
00074
00075
00076 const ModelOptionDef OPT_OutputHttpStreamBufSize =
00077 { MODOPT_ARG(ByteCount), "OutputHttpStreamBufSize", &MOC_OUTPUT, OPTEXP_CORE,
00078 "The size, in bytes, of the per-frame output buffer for output "
00079 "mpeg streams (you can try increasing the buffer size if you "
00080 "are seeing warnings like 'encoded frame too large')",
00081 "output-http-bufsize", '\0', "<bytes>", "2MiB" };
00082
00083
00084 static const ModelOptionDef OPT_OutputHttpStreamCodec =
00085 { MODOPT_ARG_STRING, "OutputHttpStreamCodec", &MOC_OUTPUT, OPTEXP_CORE,
00086 "Type of video output codec to use (use value 'List' to see list of "
00087 "available codecs on your system)",
00088 "output-http-codec", '\0', "<List|name>", "mpeg1video" };
00089
00090
00091 OutputHttpStream::OutputHttpStream(OptionManager& mgr,
00092 const std::string& descrName,
00093 const std::string& tagName)
00094 :
00095 LowLevelEncoderMap(mgr, descrName, tagName),
00096 itsHttpServer(new HttpServer(mgr)),
00097 itsFrameRate(&OPT_OutputHttpStreamFrameRate, this),
00098 itsFrameRateBase(tagName+"FrameRateBase", this, 1),
00099 itsBitRate(&OPT_OutputHttpStreamBitRate, this),
00100 itsBufSize(&OPT_OutputHttpStreamBufSize, this),
00101 itsCodecName(&OPT_OutputHttpStreamCodec, this),
00102 itsStem()
00103 {
00104 addSubComponent(itsHttpServer);
00105 }
00106
00107
00108 void OutputHttpStream::setConfigInfo(const std::string& filestem)
00109 {
00110
00111
00112
00113
00114 this->setFileStem(filestem);
00115 }
00116
00117
00118 void OutputHttpStream::setFileStem(const std::string& s)
00119 {
00120 GVX_TRACE(__PRETTY_FUNCTION__);
00121 itsStem = s;
00122 }
00123
00124
00125 #include "Media/MediaOpts.H"
00126 #include "Media/FrameRange.H"
00127 #include "Component/ModelManager.H"
00128
00129
00130 rutz::shared_ptr<LowLevelEncoder>
00131 OutputHttpStream::makeEncoder(const GenericFrameSpec& spec,
00132 const std::string& shortname,
00133 const FrameInfo& auxinfo)
00134 {
00135
00136
00137
00138 return rutz::shared_ptr<HttpEncoder>
00139 (new HttpEncoder(itsHttpServer,
00140 itsStem+shortname,
00141 itsCodecName.getVal(),
00142 itsBitRate.getVal(),
00143 itsFrameRate.getVal(),
00144 itsFrameRateBase.getVal(),
00145 spec.dims,
00146 itsBufSize.getVal().bytes()));
00147 }
00148
00149 #endif // HAVE_FFMPEG_AVCODEC_H
00150
00151
00152
00153
00154
00155
00156
00157
00158 #endif // MEDIA_HTTPOUTPUTSTREAM_C_DEFINED