From 4e834dfc73e145443c33388c7a7430c86362c452 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 23 Dec 2011 16:27:25 +0000 Subject: [PATCH] =?UTF-8?q?From=20Brad=20Christiansen,=20"Attached=20are?= =?UTF-8?q?=20some=20small=20changes=20to=20the=20ImageStream=20interface?= =?UTF-8?q?=20and=20the=20DirectShow=20and=20FFMPEG=20plugins=20to=20provi?= =?UTF-8?q?de=20the=20current=20time=20being=20displayed=20in=20the=20imag?= =?UTF-8?q?e=20stream.=20I=20don=E2=80=99t=20have=20access=20to=20an=20OSX?= =?UTF-8?q?=20or=20Linux=20dev=20machine=20to=20make=20the=20changes=20req?= =?UTF-8?q?uired=20to=20the=20quick=20time=20plugin.=20This=20plugin=20wil?= =?UTF-8?q?l=20just=20default=20to=20returning=200."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/osg/ImageStream | 1 + src/osgPlugins/directshow/DirectShowTexture | 1 + .../directshow/DirectShowTexture.cpp | 23 +++++++++++++++++++ src/osgPlugins/ffmpeg/FFmpegImageStream.cpp | 5 ++++ src/osgPlugins/ffmpeg/FFmpegImageStream.hpp | 1 + 5 files changed, 31 insertions(+) diff --git a/include/osg/ImageStream b/include/osg/ImageStream index 4b4a6d593..3f339cdf1 100644 --- a/include/osg/ImageStream +++ b/include/osg/ImageStream @@ -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; } diff --git a/src/osgPlugins/directshow/DirectShowTexture b/src/osgPlugins/directshow/DirectShowTexture index 9d57bd861..3fc5be65d 100644 --- a/src/osgPlugins/directshow/DirectShowTexture +++ b/src/osgPlugins/directshow/DirectShowTexture @@ -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); diff --git a/src/osgPlugins/directshow/DirectShowTexture.cpp b/src/osgPlugins/directshow/DirectShowTexture.cpp index 197c2732d..50b888b94 100644 --- a/src/osgPlugins/directshow/DirectShowTexture.cpp +++ b/src/osgPlugins/directshow/DirectShowTexture.cpp @@ -1809,6 +1809,29 @@ void DirectShowImageStream::seek(double time) } } + +double DirectShowImageStream::getCurrentTime() const +{ + OpenThreads::ScopedLock 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(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++) diff --git a/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp b/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp index 89984628c..915907b66 100644 --- a/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp +++ b/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp @@ -179,6 +179,11 @@ double FFmpegImageStream::getReferenceTime () const return m_decoder->reference(); } +double FFmpegImageStream::getCurrentTime() const +{ + return m_decoder->reference(); +} + double FFmpegImageStream::getFrameRate() const diff --git a/src/osgPlugins/ffmpeg/FFmpegImageStream.hpp b/src/osgPlugins/ffmpeg/FFmpegImageStream.hpp index 11cb332b7..9c0ace976 100644 --- a/src/osgPlugins/ffmpeg/FFmpegImageStream.hpp +++ b/src/osgPlugins/ffmpeg/FFmpegImageStream.hpp @@ -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;