OpenWalnut  1.5.0dev
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
WGEScreenCapture Class Reference

This class is a screen recorder. More...

#include <WGEScreenCapture.h>

+ Inheritance diagram for WGEScreenCapture:
+ Collaboration diagram for WGEScreenCapture:

Classes

struct  RecordingInformation
 Keeps track of several frame-counts. More...
 

Public Types

typedef WSharedObject< RecordingInformationSharedRecordingInformation
 The shared access type to the FrameCounting struct. More...
 
typedef osg::ref_ptr< WGEScreenCaptureRefPtr
 Convenience typedef. More...
 
typedef osg::ref_ptr< const WGEScreenCaptureConstRefPtr
 Convenience typedef. More...
 
typedef boost::function< void(size_t, size_t, osg::ref_ptr< osg::Image >) > HandleImageCallbackType
 This callback signature is needed to subscribe to the handleImage signal. More...
 

Public Member Functions

 WGEScreenCapture ()
 Creates a screen capture callback. More...
 
virtual ~WGEScreenCapture ()
 Destructor. More...
 
void recordStart ()
 Starts recording. More...
 
void recordStop ()
 Stops recording. More...
 
bool isRecording ()
 Checks if there are frames left for recording. More...
 
void screenshot ()
 Makes a screenshot with the next frame. More...
 
void resetFrameCounter ()
 Resets the frame-counter to 0. More...
 
virtual void operator() (osg::RenderInfo &renderInfo) const
 The draw callback operator. More...
 
WCondition::ConstSPtr getRecordCondition () const
 The condition returned here is actually the change condition of the frame counter. More...
 
SharedRecordingInformation::ReadTicket getRecordingInformation () const
 Returns the current recording information. More...
 
WGEAnimationFrameTimer::ConstSPtr getFrameTimer () const
 Returns a timer getting ticked on each recorded frame. More...
 
boost::signals2::connection subscribeSignal (HandleImageCallbackType callback)
 Subscribes a specified function to the new-image-signal. More...
 

Protected Member Functions

virtual void handleImage (size_t framesLeft, size_t totalFrames, osg::ref_ptr< osg::Image > image) const
 The function handles new images. More...
 
void record (size_t frames=std::numeric_limits< size_t >::max())
 Starts recording. More...
 

Private Types

typedef boost::signals2::signal< void(size_t, size_t, osg::ref_ptr< osg::Image >) > HandleImageSignalType
 The type of the signal for handleSignal. More...
 

Private Attributes

SharedRecordingInformation m_recordingInformation
 Counts the frames to take. More...
 
WGEAnimationFrameTimer::SPtr m_timer
 The frame timer. More...
 
HandleImageSignalType m_signalHandleImage
 The signal emitted on every new grabbed image. More...
 

Detailed Description

This class is a screen recorder.

It records the frame buffer to files on a per-frame-basis. This class is NOT thread-safe due to performance reasons. You should not distribute the instance among multiple threads. It can be applied to ONE camera only by setting it as finalDrawCallback (WGECamera::setFinalDrawCallback). Each camera can only use ONE final draw callback.

This class is abstract. Derive your own class and handle image writing.

Note
This class does NOT write the images to disk. Set a callback for this.

Definition at line 57 of file WGEScreenCapture.h.

Member Typedef Documentation

◆ ConstRefPtr

typedef osg::ref_ptr< const WGEScreenCapture > WGEScreenCapture::ConstRefPtr

Convenience typedef.

Definition at line 83 of file WGEScreenCapture.h.

◆ HandleImageCallbackType

typedef boost::function< void( size_t, size_t, osg::ref_ptr< osg::Image > ) > WGEScreenCapture::HandleImageCallbackType

This callback signature is needed to subscribe to the handleImage signal.

Definition at line 88 of file WGEScreenCapture.h.

◆ HandleImageSignalType

typedef boost::signals2::signal< void( size_t, size_t, osg::ref_ptr< osg::Image > ) > WGEScreenCapture::HandleImageSignalType
private

The type of the signal for handleSignal.

Definition at line 196 of file WGEScreenCapture.h.

◆ RefPtr

typedef osg::ref_ptr< WGEScreenCapture > WGEScreenCapture::RefPtr

Convenience typedef.

Definition at line 78 of file WGEScreenCapture.h.

◆ SharedRecordingInformation

The shared access type to the FrameCounting struct.

Definition at line 73 of file WGEScreenCapture.h.

Constructor & Destructor Documentation

◆ WGEScreenCapture()

WGEScreenCapture::WGEScreenCapture ( )

Creates a screen capture callback.

Definition at line 31 of file WGEScreenCapture.cpp.

References WSharedObject< T >::getWriteTicket(), and m_recordingInformation.

+ Here is the call graph for this function:

◆ ~WGEScreenCapture()

WGEScreenCapture::~WGEScreenCapture ( )
virtual

Destructor.

Cleans up.

Definition at line 40 of file WGEScreenCapture.cpp.

Member Function Documentation

◆ getFrameTimer()

WGEAnimationFrameTimer::ConstSPtr WGEScreenCapture::getFrameTimer ( ) const

Returns a timer getting ticked on each recorded frame.

This can then be used for animations for example.

Returns
the timer.

Definition at line 45 of file WGEScreenCapture.cpp.

References m_timer.

◆ getRecordCondition()

WCondition::ConstSPtr WGEScreenCapture::getRecordCondition ( ) const

The condition returned here is actually the change condition of the frame counter.

This can be used to update GUI or something as it contains frame-counts, recording information and so on (updated per frame).

Returns
the condition

Definition at line 152 of file WGEScreenCapture.cpp.

References WSharedObject< T >::getChangeCondition(), and m_recordingInformation.

+ Here is the call graph for this function:

◆ getRecordingInformation()

WGEScreenCapture::SharedRecordingInformation::ReadTicket WGEScreenCapture::getRecordingInformation ( ) const

Returns the current recording information.

Release the lock after you grabbed the info you need.

Returns
the info struct - read ticket

Definition at line 157 of file WGEScreenCapture.cpp.

References WSharedObject< T >::getReadTicket(), and m_recordingInformation.

+ Here is the call graph for this function:

◆ handleImage()

void WGEScreenCapture::handleImage ( size_t  framesLeft,
size_t  totalFrames,
osg::ref_ptr< osg::Image >  image 
) const
protectedvirtual

The function handles new images.

Implement it.

Parameters
framesLefthow much frames to come
totalFramesthe total number of frames until now
imagethe image

Definition at line 169 of file WGEScreenCapture.cpp.

References m_signalHandleImage.

◆ isRecording()

bool WGEScreenCapture::isRecording ( )

Checks if there are frames left for recording.

Returns
true if yes.

Definition at line 71 of file WGEScreenCapture.cpp.

References WSharedObject< T >::getReadTicket(), and m_recordingInformation.

+ Here is the call graph for this function:

◆ operator()()

void WGEScreenCapture::operator() ( osg::RenderInfo &  renderInfo) const
virtual

The draw callback operator.

Gets called by OSG in draw traversal.

Parameters
renderInfothe OSG renderinfo

Definition at line 77 of file WGEScreenCapture.cpp.

References WGEScreenCapture::RecordingInformation::m_frames, and WGEScreenCapture::RecordingInformation::m_framesLeft.

◆ record()

void WGEScreenCapture::record ( size_t  frames = std::numeric_limits< size_t >::max())
protected

Starts recording.

If already recording, it continues recording.

Parameters
framesthe number of frames to record. 0 means stop, 1 is a single screenshot.

Definition at line 65 of file WGEScreenCapture.cpp.

References WSharedObject< T >::getWriteTicket(), and m_recordingInformation.

Referenced by recordStart(), recordStop(), and screenshot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recordStart()

void WGEScreenCapture::recordStart ( )

Starts recording.

If it already is running, nothing happens.

Definition at line 50 of file WGEScreenCapture.cpp.

References record().

+ Here is the call graph for this function:

◆ recordStop()

void WGEScreenCapture::recordStop ( )

Stops recording.

If not recording, nothing happens.

Definition at line 55 of file WGEScreenCapture.cpp.

References record().

+ Here is the call graph for this function:

◆ resetFrameCounter()

void WGEScreenCapture::resetFrameCounter ( )

Resets the frame-counter to 0.

Definition at line 162 of file WGEScreenCapture.cpp.

References WSharedObject< T >::getWriteTicket(), m_recordingInformation, and m_timer.

+ Here is the call graph for this function:

◆ screenshot()

void WGEScreenCapture::screenshot ( )

Makes a screenshot with the next frame.

This is a shortcut for record( 1 ).

Definition at line 60 of file WGEScreenCapture.cpp.

References record().

+ Here is the call graph for this function:

◆ subscribeSignal()

boost::signals2::connection WGEScreenCapture::subscribeSignal ( HandleImageCallbackType  callback)

Subscribes a specified function to the new-image-signal.

This gets emitted every time a new image was grabbed.

Parameters
callbackthe callback
Returns
the connection.

Definition at line 174 of file WGEScreenCapture.cpp.

References m_signalHandleImage.

Member Data Documentation

◆ m_recordingInformation

SharedRecordingInformation WGEScreenCapture::m_recordingInformation
private

Counts the frames to take.

Definition at line 186 of file WGEScreenCapture.h.

Referenced by getRecordCondition(), getRecordingInformation(), isRecording(), record(), resetFrameCounter(), and WGEScreenCapture().

◆ m_signalHandleImage

HandleImageSignalType WGEScreenCapture::m_signalHandleImage
private

The signal emitted on every new grabbed image.

Definition at line 201 of file WGEScreenCapture.h.

Referenced by handleImage(), and subscribeSignal().

◆ m_timer

WGEAnimationFrameTimer::SPtr WGEScreenCapture::m_timer
private

The frame timer.

Ticket on each recorded frame.

Definition at line 191 of file WGEScreenCapture.h.

Referenced by getFrameTimer(), and resetFrameCounter().


The documentation for this class was generated from the following files: