Skip to content

Commit

Permalink
New buffer (skip buffer) and integration into videosource
Browse files Browse the repository at this point in the history
* use like:
  skip:[seek=10,drop=5]://files:///......
  to seek 10 seconds and drop 5 frames for every one displayed
  • Loading branch information
Edward Rosten committed Jul 1, 2015
1 parent 9121677 commit 03e3f19
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
36 changes: 35 additions & 1 deletion cvd/videosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <cvd/colourspaces.h>
#include <cvd/videobufferwithdata.h>
#include <cvd/readaheadvideobuffer.h>
#include <cvd/video/skipbuffer.h>

#include <cvd/diskbuffer2.h>
#include <cvd/serverpushjpegbuffer.h>
Expand Down Expand Up @@ -111,6 +112,25 @@ namespace CVD {
throw VideoSourceException("DeinterlaceBuffer cannot handle input type");
}
};


////////////////////////////////////////////////////////////////////////////////
//
// Colourspace conversion buffer
//

void get_skip_options(const VideoSource& vs, bool& do_seek, double& seek, int& drop);
template<class T> struct makeSkipBuffer
{
static VideoBuffer<T>* make(bool do_seek, double seek, int drop, const std::string& url)
{
auto source = std::unique_ptr<VideoBuffer<T>>(open_video_source<T>(url));
std::unique_ptr<VideoBuffer<T>> buf = std::make_unique<SkipBuffer<T>>(*source, do_seek, seek, drop);
return new VideoBufferWithData<T, VideoBuffer<T> >(buf, source);
}
};


////////////////////////////////////////////////////////////////////////////////
//
// Colourspace conversion buffer
Expand Down Expand Up @@ -328,6 +348,16 @@ namespace CVD {

return makeDeinterlaceBuffer<T>::make(f, linedouble, vs.identifier);
}
else if(vs.protocol == "skip")
{
double seek=0;
bool do_seek=0;
int drop=0;

get_skip_options(vs, do_seek, seek, drop);

return makeSkipBuffer<T>::make(do_seek, seek, drop, vs.identifier);
}
else if(vs.protocol == "colourspace")
{
std::string from = "byte";
Expand Down Expand Up @@ -484,7 +514,7 @@ redirection can be used:
@endverbatim
Fields are:
bool = true | yes | 1 ! false | no | 0
bool = true | yes | 1 | false | no | 0
offset = <width>x<height>
size = <offset> | qvga | vga | pal | ntsc | xga
Expand Down Expand Up @@ -532,6 +562,10 @@ Options supported by the various protocols are:
from = byte | mono | gray | grey | yuv411 | yuv422 | rgb<byte>
| rgb | bayer_bggr | bayer_gbrg | bayer_grbg | bayer_rggb (default mono)
'skip' protocol: identifier is a video URL
seek = <double>
drip = <int>
@endverbatim
@ingroup gVideo
Expand Down
20 changes: 20 additions & 0 deletions cvd_src/videosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,26 @@ namespace CVD {
}
}

void get_skip_options(const VideoSource& vs, bool& do_seek, double& seek, int& drop)
{

for (VideoSource::option_list::const_iterator it=vs.options.begin(); it != vs.options.end(); ++it)
{
if(it->first == "seek")
{
do_seek=true;
seek = atof(it->second.c_str());
}
else if(it->first == "drop")
{
drop = atoi(it->second.c_str());
}
else
throw VideoSourceException("invalid option for files protocol: "+it->first +
"\n\t valid options: seek=<time>, drop=<n>");
}
}

void get_colourspace_options(const VideoSource& vs, string& colourspace)
{
colourspace = "mono";
Expand Down

0 comments on commit 03e3f19

Please sign in to comment.