Files
OpenSceneGraph/src/osgPlugins/QTKit/OSXQTKitVideo.h
Robert Osfield f9fd4342ba From Stephan Huber, "attached you'll find the latest versions of the QTKit + the AVFoundation-plugin, some changes to osgPresentation and a small enhancement für ImageIO.
I fixed some bugs and did some more tests with both of the video-plugins. I integrated CoreVideo with osgPresentation, ImageStream has a new virtual method called createSuitableTexture which returns NULL for default implementations. Specialized implementations like the QTKit-plugin return a CoreVideo-texture. I refactored the code in SlideShowConstructor::createTexturedQuad to use a texture returned from ImageStream::createSuitableTexture.

I did not use osgDB::readObjectFile to get the texture-object, as a lot of image-related code in SlideShowConstructor had to be refactored to use a texture.  My changes are minimal and should not break existing code.

There's one minor issue with CoreVideo in general: As the implementation is asynchronous, there might be no texture available, when first showing the video the first frame. I am a bit unsure how to tackle this problem, any input on this is appreciated.

Back to the AVFoundation-plugin: the current implementation does not support CoreVideo as the QTKit-plugin supports it. There's no way to get decoded frames from AVFoundation stored on the GPU, which is kind of sad. I added some support for CoreVideo to transfer decoded frames back to the GPU, but in my testings the performance was worse than using the normal approach using glTexSubImage. This is why I disabled CoreVideo for AVFoundation. You can still request a CoreVideoTexture via readObjectFile, though.
"
2012-10-24 10:43:01 +00:00

104 lines
2.7 KiB
C++

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#pragma once
#include <osg/ImageStream>
#include "VideoFrameDispatcher.h"
#ifdef __OBJC__
@class QTMovie;
#else
class QTMovie;
#endif
class QTVisualContext;
class OSXCoreVideoAdapter;
class OSXQTKitVideo : public osgVideo::VideoImageStream {
public:
OSXQTKitVideo();
~OSXQTKitVideo();
virtual void setTimeMultiplier(double r);
virtual double getTimeMultiplier() const;
virtual double getCurrentTime() const;
virtual bool isPlaying() const { return (getStatus() == PLAYING); }
virtual bool valid() const { return (getStatus() != INVALID); }
void open(const std::string& file_name);
virtual void setVolume (float);
virtual float getVolume () const;
virtual float getAudioBalance();
virtual void setAudioBalance(float b);
virtual double getLength() const { return _duration; }
virtual void seek (double t);
virtual void play ();
virtual void pause ();
void setCoreVideoAdapter(OSXCoreVideoAdapter* adapter);
OSXCoreVideoAdapter* getCoreVideoAdapter() const { return _coreVideoAdapter; }
void decodeFrame(bool force);
virtual void decodeFrame() { decodeFrame(_waitForFirstFrame); }
virtual bool requiresUpdateCall () const { return (!getCoreVideoAdapter() && !getVideoFrameDispatcher() ); }
virtual void update(osg::NodeVisitor *)
{
requestNewFrame(_waitForFirstFrame);
}
void requestNewFrame(bool force)
{
if (!setNeedsDispatching(RequestSingleUpdate))
decodeFrame(force);
else
_waitForFirstFrame = true;
}
virtual bool needsDispatching() const
{
return _waitForFirstFrame || getNeedsDispatching();
}
static void initializeQTKit();
virtual osg::Texture* createSuitableTexture();
protected:
virtual void applyLoopingMode();
struct Data;
private:
bool _isActive, _isValid;
double _duration;
QTMovie* _movie;
Data* _data;
mutable double _rate;
bool _waitForFirstFrame;
OSXCoreVideoAdapter* _coreVideoAdapter;
};