OpenWalnut
1.5.0dev
|
This class is a screen recorder. More...
#include <WGEScreenCapture.h>
Classes | |
struct | RecordingInformation |
Keeps track of several frame-counts. More... | |
Public Types | |
typedef WSharedObject< RecordingInformation > | SharedRecordingInformation |
The shared access type to the FrameCounting struct. More... | |
typedef osg::ref_ptr< WGEScreenCapture > | RefPtr |
Convenience typedef. More... | |
typedef osg::ref_ptr< const WGEScreenCapture > | ConstRefPtr |
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... | |
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.
Definition at line 57 of file WGEScreenCapture.h.
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.
|
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.
WGEScreenCapture::WGEScreenCapture | ( | ) |
Creates a screen capture callback.
Definition at line 31 of file WGEScreenCapture.cpp.
References WSharedObject< T >::getWriteTicket(), and m_recordingInformation.
|
virtual |
WGEAnimationFrameTimer::ConstSPtr WGEScreenCapture::getFrameTimer | ( | ) | const |
Returns a timer getting ticked on each recorded frame.
This can then be used for animations for example.
Definition at line 45 of file WGEScreenCapture.cpp.
References m_timer.
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).
Definition at line 152 of file WGEScreenCapture.cpp.
References WSharedObject< T >::getChangeCondition(), and m_recordingInformation.
WGEScreenCapture::SharedRecordingInformation::ReadTicket WGEScreenCapture::getRecordingInformation | ( | ) | const |
Returns the current recording information.
Release the lock after you grabbed the info you need.
Definition at line 157 of file WGEScreenCapture.cpp.
References WSharedObject< T >::getReadTicket(), and m_recordingInformation.
|
protectedvirtual |
The function handles new images.
Implement it.
framesLeft | how much frames to come |
totalFrames | the total number of frames until now |
image | the image |
Definition at line 169 of file WGEScreenCapture.cpp.
References m_signalHandleImage.
bool WGEScreenCapture::isRecording | ( | ) |
Checks if there are frames left for recording.
Definition at line 71 of file WGEScreenCapture.cpp.
References WSharedObject< T >::getReadTicket(), and m_recordingInformation.
|
virtual |
The draw callback operator.
Gets called by OSG in draw traversal.
renderInfo | the OSG renderinfo |
Definition at line 77 of file WGEScreenCapture.cpp.
References WGEScreenCapture::RecordingInformation::m_frames, and WGEScreenCapture::RecordingInformation::m_framesLeft.
|
protected |
Starts recording.
If already recording, it continues recording.
frames | the 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().
void WGEScreenCapture::recordStart | ( | ) |
Starts recording.
If it already is running, nothing happens.
Definition at line 50 of file WGEScreenCapture.cpp.
References record().
void WGEScreenCapture::recordStop | ( | ) |
Stops recording.
If not recording, nothing happens.
Definition at line 55 of file WGEScreenCapture.cpp.
References record().
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.
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().
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.
callback | the callback |
Definition at line 174 of file WGEScreenCapture.cpp.
References m_signalHandleImage.
|
private |
Counts the frames to take.
Definition at line 186 of file WGEScreenCapture.h.
Referenced by getRecordCondition(), getRecordingInformation(), isRecording(), record(), resetFrameCounter(), and WGEScreenCapture().
|
private |
The signal emitted on every new grabbed image.
Definition at line 201 of file WGEScreenCapture.h.
Referenced by handleImage(), and subscribeSignal().
|
private |
The frame timer.
Ticket on each recorded frame.
Definition at line 191 of file WGEScreenCapture.h.
Referenced by getFrameTimer(), and resetFrameCounter().