UcbMpegOutputStream.C
Go to the documentation of this file.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_UCBMPEGOUTPUTSTREAM_C_DEFINED
00039 #define MEDIA_UCBMPEGOUTPUTSTREAM_C_DEFINED
00040
00041 #include "Media/UcbMpegOutputStream.H"
00042
00043 #include "Component/ModelOptionDef.H"
00044 #include "Media/UcbMpegEncoder.H"
00045 #include "Raster/GenericFrame.H"
00046 #include "Transport/TransportOpts.H"
00047 #include "Util/Assert.H"
00048 #include "Util/FileUtil.H"
00049 #include "Util/log.H"
00050 #include "rutz/shared_ptr.h"
00051 #include "rutz/trace.h"
00052
00053 #include <map>
00054 #include <string>
00055
00056
00057 const ModelOptionDef OPT_UcbMpegFrameRate =
00058 { MODOPT_ARG(SimTime), "UcbMpegFrameRate", &MOC_OUTPUT, OPTEXP_CORE,
00059 "The frame rate, in frames-per-second, for ucb mpeg streams",
00060 "ucbmpeg-framerate", '\0',
00061 "<23.976, 24, 25, 29.97, 30, 50, 59.94, 60>Hz", "29.97Hz" };
00062
00063
00064 const ModelOptionDef OPT_UcbMpegQuality =
00065 { MODOPT_ARG_STRING, "UcbMpegQuality", &MOC_OUTPUT, OPTEXP_CORE,
00066 "The baseline quality settings for ucb mpeg streams (these "
00067 "settings may be further refined by additional command-line "
00068 "options)",
00069 "ucbmpeg-quality", '\0',
00070 "<basic|hq|superhq>", "basic" };
00071
00072
00073 UcbMpegOutputStream::UcbMpegOutputStream(OptionManager& mgr,
00074 const std::string& descrName,
00075 const std::string& tagName)
00076 :
00077 LowLevelEncoderMap(mgr, descrName, tagName),
00078 itsFrameRate(&OPT_UcbMpegFrameRate, this),
00079 itsBaselineQuality(&OPT_UcbMpegQuality, this),
00080 itsStem()
00081 {}
00082
00083
00084 void UcbMpegOutputStream::setConfigInfo(const std::string& filestem)
00085 {
00086
00087
00088
00089
00090 this->setFileStem(filestem);
00091 }
00092
00093
00094 void UcbMpegOutputStream::setFileStem(const std::string& s)
00095 {
00096 GVX_TRACE(__PRETTY_FUNCTION__);
00097 itsStem = s;
00098 }
00099
00100
00101 rutz::shared_ptr<LowLevelEncoder>
00102 UcbMpegOutputStream::makeEncoder(const GenericFrameSpec& spec,
00103 const std::string& shortname,
00104 const FrameInfo& auxinfo)
00105 {
00106 UcbMpegParams params;
00107
00108 if (itsBaselineQuality.getVal().compare("basic") == 0)
00109 params = UcbMpegParams::basic();
00110 else if (itsBaselineQuality.getVal().compare("hq") == 0)
00111 params = UcbMpegParams::hq();
00112 else if (itsBaselineQuality.getVal().compare("superhq") == 0)
00113 params = UcbMpegParams::superhq();
00114 else
00115 LFATAL("invalid setting for --ucbmpeg-quality: %s",
00116 itsBaselineQuality.getVal().c_str());
00117
00118 std::string fname = itsStem + shortname;
00119
00120 if (!hasExtension(fname, ".mpg") &&
00121 !hasExtension(fname, ".mpeg"))
00122 fname += ".mpg";
00123
00124 #ifndef MPEGENCODE_PROG
00125 LFATAL("MPEGENCODE_PROG is undefined (the configure script "
00126 "did not find an mpeg_encode or ppmtompeg program)");
00127 return rutz::shared_ptr<LowLevelEncoder>();
00128 #else
00129
00130
00131
00132
00133 return rutz::shared_ptr<LowLevelEncoder>
00134 (new UcbMpegEncoder(MPEGENCODE_PROG, fname, params,
00135 itsFrameRate.getVal().hertz()));
00136 #endif
00137 }
00138
00139
00140
00141
00142
00143
00144
00145
00146 #endif // MEDIA_UCBMPEGOUTPUTSTREAM_C_DEFINED