OpenWalnut  1.4.0
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes
WGEScreenCapture Class Reference

This class is a screen recorder. More...

#include <WGEScreenCapture.h>

+ Inheritance diagram for WGEScreenCapture:

List of all members.

Classes

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

Public Types

typedef WSharedObject
< RecordingInformation
SharedRecordingInformation
 The shared access type to the FrameCounting struct.
typedef osg::ref_ptr
< WGEScreenCapture
RefPtr
 Convenience typedef.
typedef osg::ref_ptr< const
WGEScreenCapture
ConstRefPtr
 Convenience typedef.
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.

Public Member Functions

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

Protected Member Functions

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

Private Types

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

Private Attributes

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

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.

Notes:
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

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

Convenience typedef.

Definition at line 83 of file WGEScreenCapture.h.

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.

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.

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

Convenience typedef.

Definition at line 78 of file WGEScreenCapture.h.

The shared access type to the FrameCounting struct.

Definition at line 73 of file WGEScreenCapture.h.


Constructor & Destructor Documentation

Creates a screen capture callback.

Definition at line 31 of file WGEScreenCapture.cpp.

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

Destructor.

Cleans up.

Definition at line 40 of file WGEScreenCapture.cpp.


Member Function Documentation

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.

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.

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.

void WGEScreenCapture::handleImage ( size_t  framesLeft,
size_t  totalFrames,
osg::ref_ptr< osg::Image >  image 
) const [protected, virtual]

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.

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.

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.

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().

Starts recording.

If it already is running, nothing happens.

Definition at line 50 of file WGEScreenCapture.cpp.

References record().

Stops recording.

If not recording, nothing happens.

Definition at line 55 of file WGEScreenCapture.cpp.

References record().

Resets the frame-counter to 0.

Definition at line 162 of file WGEScreenCapture.cpp.

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

Makes a screenshot with the next frame.

This is a shortcut for record( 1 ).

Definition at line 60 of file WGEScreenCapture.cpp.

References record().

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

Counts the frames to take.

Definition at line 186 of file WGEScreenCapture.h.

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

The signal emitted on every new grabbed image.

Definition at line 201 of file WGEScreenCapture.h.

Referenced by handleImage(), and subscribeSignal().

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: