From Brad Christiansen, "Attached are some small changes to the ImageStream interface and the DirectShow and FFMPEG plugins to provide the current time being displayed in the image stream.

I don’t have access to an OSX or Linux dev machine to make the changes required to the quick time plugin. This plugin will just default to returning 0."
This commit is contained in:
Robert Osfield 2011-12-23 16:27:25 +00:00
parent f6ace4a7d0
commit 4e834dfc73
5 changed files with 31 additions and 0 deletions

View File

@ -79,6 +79,7 @@ class OSG_EXPORT ImageStream : public Image
virtual double getCreationTime() const { return HUGE_VAL; }
virtual double getLength() const { return 0.0; }
virtual double getFrameRate() const { return 0.0; }
virtual double getCurrentTime() const { return 0.0; }
virtual void setReferenceTime(double) {}
virtual double getReferenceTime() const { return 0.0; }

View File

@ -58,6 +58,7 @@ public:
void rewind();
osg::ImageStream::StreamStatus getStatus();
void seek(double time);
double getCurrentTime() const;
double getLength() const;
double getFrameRate() const;
void setTimeMultiplier(double rate);

View File

@ -1809,6 +1809,29 @@ void DirectShowImageStream::seek(double time)
}
}
double DirectShowImageStream::getCurrentTime() const
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
double currentTime = -1;
if (_renderer.valid() && _renderer->_mediaSeeking)
{
LONGLONG curTimeLL = 0;
HRESULT hr = _renderer->_mediaSeeking->GetCurrentPosition(&curTimeLL);
if (FAILED(hr))
{
OSG_NOTICE << this << " " << getErrorMessage(hr) << std::endl;
}
else
{
currentTime = static_cast<double>(curTimeLL);
currentTime = currentTime * (100.0 * 1e-9); // default unit in directshow IMediaSeeking
}
}
return currentTime;
}
void DirectShowImageStream::setOptions(const Options& map)
{
for (Options::const_iterator it = map.begin(); it != map.end(); it++)

View File

@ -179,6 +179,11 @@ double FFmpegImageStream::getReferenceTime () const
return m_decoder->reference();
}
double FFmpegImageStream::getCurrentTime() const
{
return m_decoder->reference();
}
double FFmpegImageStream::getFrameRate() const

View File

@ -41,6 +41,7 @@ namespace osgFFmpeg
virtual double getCreationTime() const;
virtual double getLength() const;
virtual double getReferenceTime () const;
virtual double getCurrentTime() const;
virtual double getFrameRate() const;
virtual bool isImageTranslucent() const;