13 #include <cvd/config.h> 15 #include <cvd/colourspacebuffer.h> 16 #include <cvd/colourspaces.h> 17 #include <cvd/deinterlacebuffer.h> 18 #include <cvd/video/skipbuffer.h> 19 #include <cvd/videobufferwithdata.h> 21 #include <cvd/diskbuffer2.h> 22 #include <cvd/serverpushjpegbuffer.h> 45 std::string identifier;
46 typedef std::vector<std::pair<std::string, std::string>> option_list;
50 std::ostream& operator<<(std::ostream& out,
const VideoSource& vs);
61 template <class T, bool Implemented = Pixel::DefaultConvertible<T>::is>
67 using std::make_unique;
68 using std::unique_ptr;
70 unique_ptr<std::ifstream> stream = std::make_unique<ifstream>(filename);
71 unique_ptr<VideoBuffer<T>> buf = make_unique<ServerPushJpegBuffer<T>>(*stream);
86 void get_jpegstream_options(
const VideoSource& vs,
int& fps);
99 static const bool can = std::numeric_limits<T>::is_specialized;
109 template <class T, bool B = Internal::CanDeinterlace<T>::can>
114 auto source = std::unique_ptr<VideoBuffer<T>>(open_video_source<T>(url));
115 std::unique_ptr<VideoBuffer<T>> buf = std::make_unique<DeinterlaceBuffer<T>>(*source, f, linedouble);
134 void get_skip_options(
const VideoSource& vs,
bool& do_seek,
double& seek,
int& drop);
138 static VideoBuffer<T>* make(
bool do_seek,
double seek,
int drop,
const std::string& url)
140 auto source = std::unique_ptr<VideoBuffer<T>>(open_video_source<T>(url));
141 std::unique_ptr<VideoBuffer<T>> buf = std::make_unique<SkipBuffer<T>>(*source, do_seek, seek, drop);
142 return new VideoBufferWithData<T, VideoBuffer<T>>(buf, source);
151 void get_colourspace_options(
const VideoSource& vs, std::string& from);
153 template <
class Out,
class In,
bool can_convert>
158 std::unique_ptr<VideoBuffer<In>> buf { open_video_source<In>(r) };
160 std::unique_ptr<VideoBuffer<Out>> cvt = std::make_unique<ColourspaceBuffer<Out, In>>(*buf);
165 template <
class Out,
class In>
179 return open_video_source<T>(r);
183 template <
class Out,
class In>
190 VideoBuffer<T>* makeColourspaceBuffer(
const std::string& c,
const std::string& r)
193 if(c ==
"byte" || c ==
"mono" || c ==
"gray" || c ==
"grey")
194 return makeConvertBufferBit<T, byte>(r);
195 else if(c ==
"rgb<byte>" || c ==
"rgb")
196 return makeConvertBufferBit<T, Rgb<byte>>(r);
199 else if(c ==
"yuv422")
200 return makeConvertBufferBit<T, yuv422>(r);
201 else if(c ==
"yuv420p")
202 return makeConvertBufferBit<T, yuv420p>(r);
203 else if(c ==
"vuy422")
204 return makeConvertBufferBit<T, vuy422>(r);
205 else if(c ==
"bayer_bggr")
206 return makeConvertBufferBit<T, bayer_bggr>(r);
207 else if(c ==
"bayer_gbrg")
208 return makeConvertBufferBit<T, bayer_gbrg>(r);
209 else if(c ==
"bayer_grbg")
210 return makeConvertBufferBit<T, bayer_grbg>(r);
211 else if(c ==
"bayer_rggb")
212 return makeConvertBufferBit<T, bayer_rggb>(r);
213 else if(c ==
"bayer_bggr16be")
214 return makeConvertBufferBit<T, bayer_bggr16be>(r);
215 else if(c ==
"bayer_gbrg16be")
216 return makeConvertBufferBit<T, bayer_gbrg16be>(r);
217 else if(c ==
"bayer_grbg16be")
218 return makeConvertBufferBit<T, bayer_grbg16be>(r);
219 else if(c ==
"bayer_rggb16be")
220 return makeConvertBufferBit<T, bayer_rggb16be>(r);
233 template <class T, bool Implemented = Pixel::DefaultConvertible<T>::is>
252 template <
class T,
bool Implemented = 0>
272 throw VideoSourceException(
"V4LBuffer cannot handle types other than byte, bayer, yuv422, vuy422, Rgb<byte>");
276 VideoBuffer<byte>* makeV4LBuffer(
const std::string& dev,
const ImageRef& size,
int input,
bool interlaced,
bool verbose);
288 VideoBuffer<Rgb8>* makeV4LBuffer(
const std::string& dev,
const ImageRef& size,
int input,
bool interlaced,
bool verbose);
290 void get_v4l2_options(
const VideoSource& vs,
ImageRef& size,
int& input,
bool& interlaced,
bool& verbose);
308 void get_uvc_options(
const VideoSource& vs,
ImageRef& size,
double& fps,
bool& mjpeg,
bool& verbose);
364 void get_dc1394_options(
const VideoSource& vs,
ImageRef& size,
float& fps,
ImageRef& offset,
bool& verbose,
bool& bus_reset,
int& format7_mode);
374 if(vs.protocol ==
"jpegstream")
378 else if(vs.protocol ==
"deinterlace")
381 bool linedouble =
false;
383 get_deinterlace_options(vs, f, linedouble);
387 else if(vs.protocol ==
"skip")
393 get_skip_options(vs, do_seek, seek, drop);
397 else if(vs.protocol ==
"colourspace" || vs.protocol ==
"colorspace")
399 std::string from =
"byte";
400 get_colourspace_options(vs, from);
402 return makeColourspaceBuffer<T>(from, vs.identifier);
404 else if(vs.protocol ==
"files")
408 get_files_options(vs, fps, eob);
411 else if(vs.protocol ==
"v4l2")
415 bool interlaced, verbose;
416 get_v4l2_options(vs, size, input, interlaced, verbose);
417 return makeV4LBuffer<T>(vs.identifier, size, input, interlaced, verbose);
419 else if(vs.protocol ==
"uvc")
424 get_uvc_options(vs, size, fps, mjpeg, verbose);
425 return makeUVCBuffer<T>(vs.identifier, size, fps, mjpeg, verbose);
427 else if(vs.protocol ==
"dc1394")
429 int cam_no = atoi(vs.identifier.c_str());
435 get_dc1394_options(vs, size, fps, offset, verbose, bus_reset, format7_mode);
436 return makeDVBuffer2<T>(cam_no, size, fps, offset, verbose, bus_reset, format7_mode);
438 else if(vs.protocol ==
"file" || vs.protocol ==
"ffmpeg")
442 std::string formatname =
"";
443 std::map<std::string, std::string> opts;
444 get_file_options(vs, eob, verbose, formatname, opts);
445 return makeVideoFileBuffer<T>(vs.identifier, eob, verbose, formatname, opts);
448 throw VideoSourceException(
"undefined video source protocol: '" + vs.protocol +
"'\n\t valid protocols: " 449 "colourspace, jpegstream, " 468 return open_video_source<T>(vs);
614 std::istringstream in(src);
615 return open_video_source<T>(in);
OnEndOfBuffer
If it is a finite buffer (a video file, for example), what should happen when the end of the buffer i...
Definition: videobufferflags.h:14
A colour consisting of red, green and blue components.
Definition: rgb.h:25
All classes and functions are within the CVD namespace.
Definition: argb.h:6
Definition: videosource.h:136
Definition: videosource.h:34
Base class for objects which provide a typed video stream.
Definition: videobuffer.h:88
Definition: videosource.h:26
VideoBuffer< T > * open_video_source(const std::string &src)
opens a video device described by a video source url.
Definition: videosource.h:612
Definition: videosource.h:97
Definition: videosource.h:154
std::vector< std::string > globlist(const std::string &gl)
Make a list of strings from a UNIX-style pattern pathname expansion.
Definition: win32.cpp:41
Play a series of image files as a video stream.
Definition: diskbuffer2.h:86
Base class for all CVD exceptions.
Definition: exceptions.h:15
Definition: videosource.h:253
Definition: image_ref.h:29
Definition: videosource.h:110
Both fields, presenting the odd lines from each frame first.
Definition: deinterlacebuffer.h:70
Definition: videosource.h:42
Definition: name_builtin_types.h:11
Definition: videosource.h:62
Fields
Definition: deinterlacebuffer.h:66
Certain video buffers, especially the decorator classes, and buffers such as ServerPushJpegBuffer hav...
Definition: videobufferwithdata.h:17