OpenWalnut
1.4.0
|
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. | |
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. |
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.
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.
Creates a screen capture callback.
Definition at line 31 of file WGEScreenCapture.cpp.
References WSharedObject< T >::getWriteTicket(), and m_recordingInformation.
WGEScreenCapture::~WGEScreenCapture | ( | ) | [virtual] |
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.
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.
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.
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.
void WGEScreenCapture::operator() | ( | osg::RenderInfo & | renderInfo | ) | const [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.
void WGEScreenCapture::record | ( | size_t | frames = std::numeric_limits< size_t >::max() | ) | [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.
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().