Added pause, rewind and play support into xine plugin.

This commit is contained in:
Robert Osfield 2005-02-24 17:07:37 +00:00
parent 5fbb1f11cd
commit 79833fa704
3 changed files with 54 additions and 15 deletions

View File

@ -40,6 +40,7 @@ class SG_EXPORT ImageStream : public Image
enum StreamStatus enum StreamStatus
{ {
INVALID,
PLAYING, PLAYING,
PAUSED, PAUSED,
REWINDING REWINDING

View File

@ -16,7 +16,7 @@
using namespace osg; using namespace osg;
ImageStream::ImageStream(): ImageStream::ImageStream():
_status(PAUSED), _status(INVALID),
_loopingMode(LOOPING) _loopingMode(LOOPING)
{ {
setDataVariance(DYNAMIC); setDataVariance(DYNAMIC);

View File

@ -75,24 +75,51 @@ class XineImageStream : public osg::ImageStream
virtual void play() virtual void play()
{ {
if (_status!=PLAYING) if (_status!=PLAYING && _stream)
{ {
osg::notify(osg::NOTICE)<<"XineImageStream::play()"<<std::endl; if (_status==PAUSED)
xine_play(_stream, 0, 0);
while (!_ready)
{ {
osg::notify(osg::NOTICE)<<"waiting..."<<std::endl; xine_set_param (_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL);
usleep(10000); }
else
{
osg::notify(osg::NOTICE)<<"XineImageStream::play()"<<std::endl;
xine_play(_stream, 0, 0);
while (!_ready)
{
osg::notify(osg::NOTICE)<<"waiting..."<<std::endl;
usleep(10000);
}
} }
} }
_status=PLAYING; _status=PLAYING;
} }
virtual void pause() { _status=PAUSED; } virtual void pause()
{
if (_status==PAUSED) return;
_status=PAUSED;
if (_stream)
{
xine_set_param (_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE);
}
}
virtual void rewind() { _status=REWINDING; } virtual void rewind()
{
_status=REWINDING;
if (_stream)
{
xine_trick_mode(_stream,XINE_TRICK_MODE_FAST_REWIND,0);
}
}
virtual void quit(bool /*waitForThreadToExit*/ = true) {} virtual void quit(bool /*waitForThreadToExit*/ = true)
{
close();
}
static void my_render_frame(uint32_t width, uint32_t height, void* data, void* userData) static void my_render_frame(uint32_t width, uint32_t height, void* data, void* userData)
{ {
@ -100,7 +127,7 @@ class XineImageStream : public osg::ImageStream
GLenum pixelFormat = GL_BGRA; GLenum pixelFormat = GL_BGRA;
#if 0 #if 0
if (!imageStream->_ready) if (!imageStream->_ready)
{ {
imageStream->allocateImage(width,height,1,pixelFormat,GL_UNSIGNED_BYTE,1); imageStream->allocateImage(width,height,1,pixelFormat,GL_UNSIGNED_BYTE,1);
@ -142,14 +169,22 @@ class XineImageStream : public osg::ImageStream
virtual ~XineImageStream() virtual ~XineImageStream()
{ {
osg::notify(osg::NOTICE)<<"Killing XineImageStream"<<std::endl;
close(); close();
osg::notify(osg::NOTICE)<<"Closed XineImageStream"<<std::endl;
} }
void close() void close()
{ {
if (_stream) if (_stream)
{ {
osg::notify(osg::NOTICE)<<"Closing stream"<<std::endl;
xine_close(_stream); xine_close(_stream);
osg::notify(osg::NOTICE)<<"Disposing stream"<<std::endl;
xine_dispose(_stream); xine_dispose(_stream);
_stream = 0; _stream = 0;
} }
@ -157,11 +192,15 @@ class XineImageStream : public osg::ImageStream
if (_ao) if (_ao)
{ {
osg::notify(osg::NOTICE)<<"Closing audio driver"<<std::endl;
xine_close_audio_driver(_xine, _ao); xine_close_audio_driver(_xine, _ao);
} }
if (_vo) if (_vo)
{ {
osg::notify(osg::NOTICE)<<"Closing video driver"<<std::endl;
xine_close_video_driver(_xine, _vo); xine_close_video_driver(_xine, _vo);
} }
@ -190,13 +229,12 @@ class ReaderWriterXine : public osgDB::ReaderWriter
xine_init(_xine); xine_init(_xine);
register_rgbout_plugin(_xine); register_rgbout_plugin(_xine);
// register_plugin(_xine, "/usr/local/lib/osgPlugins", "osgdb_xine.so");
} }
virtual ~ReaderWriterXine() virtual ~ReaderWriterXine()
{ {
osg::notify(osg::NOTICE)<<"Killing Xine"<<std::endl;
if (_xine) xine_exit(_xine); if (_xine) xine_exit(_xine);
_xine = NULL; _xine = NULL;
} }
@ -209,7 +247,7 @@ class ReaderWriterXine : public osgDB::ReaderWriter
osgDB::equalCaseInsensitive(extension,"mov"); osgDB::equalCaseInsensitive(extension,"mov");
} }
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*) const
{ {
//std::string ext = osgDB::getLowerCaseFileExtension(file); //std::string ext = osgDB::getLowerCaseFileExtension(file);
//if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; //if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;