My Project
|
For managing and rendering the movie. More...
#include <MoviePlatform.h>
Public Types | |
typedef std::function< void(bool, std::vector< BYTE > &base64)> | screenshot_callback |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_type |
Public Member Functions | |
void | Cleanup () |
IMovieCodec * | GetMovieCodec (bool bCreateIfNotExist=true) |
try get the movie codec. More... | |
virtual int | GetAttributeClassID () |
attribute class ID should be identical, unless one knows how overriding rules work. More... | |
virtual const char * | GetAttributeClassName () |
a static string, describing the attribute class object's name | |
virtual const char * | GetAttributeClassDescription () |
a static string, describing the attribute class object | |
virtual int | InstallFields (CAttributeClass *pClass, bool bOverride) |
this class should be implemented if one wants to add new attribute. More... | |
ATTRIBUTE_METHOD1 (CMoviePlatform, video_encode_example_s, const char *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, GetCodec_s, int *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetCodec_s, int) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, GetMarginLeft_s, int *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetMarginLeft_s, int) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, GetMarginTop_s, int *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetMarginTop_s, int) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, GetMarginRight_s, int *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetMarginRight_s, int) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, GetMarginBottom_s, int *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetMarginBottom_s, int) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, HasMoviePlugin_s, bool *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, GetRecordingFPS_s, int *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetRecordingFPS_s, int) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, GetVideoBitRate_s, int *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetVideoBitRate_s, int) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, IsCaptureMic_s, bool *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetCaptureMic_s, bool) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, IsCaptureAudio_s, bool *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetCaptureAudio_s, bool) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, GetStereoCaptureMode_s, int *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetStereoCaptureMode_s, int) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, GetStereoEyeSeparation_s, float *) | |
ATTRIBUTE_METHOD1 (CMoviePlatform, SetStereoEyeSeparation_s, float) | |
void | video_encode_example (const char *filename, int codec_id=0) |
encode a random dummy video to the given filename with given codec. More... | |
virtual void | SetCodec (int nCodec) |
set preferred codec | |
virtual int | GetCodec () |
get preferred codec | |
void | CleanUp () |
clear all clips | |
void | SetCaptureGUI (bool bGUI) |
set whether GUI is captured. More... | |
bool | CaptureGUI () |
return true if GUI is also captured. More... | |
void | SetMovieName (string name) |
set the movie name | |
string | GetMovieName () |
Get the movie name. | |
int | GetScreenWidth () |
get the movie screen width and height | |
int | GetScreenHeight () |
clip height in pixel | |
void | SetVideoBitRate (int nRate) |
int | GetVideoBitRate () |
void | SetMovieScreenSize (int nWidth, int nHeight) |
set the movie screen size in pixel. More... | |
void | GetMovieScreenSize (int *nWidth, int *nHeight) |
get movie screen size | |
string | GetMovieFileName () |
get the movie file name | |
void | BeginCaptureFrame () |
call this function just outside BeginScene and EndScene | |
void | EndCaptureFrame () |
bool | BeginCapture (const string &sFileName) |
starting capturing a screen movie More... | |
bool | EndCapture () |
end capturing a screen movie and save movie to file. More... | |
void | PauseCapture () |
pause the capturing. More... | |
void | ResumeCapture () |
resume capturing | |
bool | IsInCaptureSession () |
whether we are doing screen capture. More... | |
bool | IsRecording () |
whether it is recording. More... | |
bool | SetCaptureTarget () |
set the current render target, so that everything that is rendered subsequently will be recorded One must call UnsetCaptureTarget(), in a render frame. More... | |
bool | UnsetCaptureTarget () |
restore the render target to what it is when SetCaptureTarget() is called. More... | |
void | RenderCaptured () |
render (usually stretch) the capture target to the current render target at the specified location it will by default render to fill the entire render target. | |
void | SaveCapturedFrame (int nMode=0) |
save the captured frame to file. More... | |
bool | TakeScreenShot (const string &filename) |
by default it save the screen shot as JPG file in the . More... | |
void | TakeScreenShot_Async (const string &filename, bool bEncode=false, int width=-1, int height=-1, screenshot_callback callback=nullptr) |
Use a new thread to take a screenshot. More... | |
bool | TakeScreenShot_FromGDI (const string &filename, std::vector< BYTE > &outBase64Buffers, bool bEncode=false, int width=-1, int height=-1) |
Captures a bitmap buffer and uses FreeImage library to change it into a Image. More... | |
int | CaptureBitmapBuffer (HWND nHwnd, int &outFileHeaderSize, int &outInfoHeaderSize, std::vector< BYTE > &outBuffers, bool bCaptureMouse=false, int nLeft=0, int nTop=0, int width=0, int height=0) |
Captures a bitmap buffer through Windows GDI. More... | |
bool | TakeScreenShot (const string &filename, int width, int height) |
by default it save the screen shot as JPG file in the . More... | |
bool | ResizeImage (const string &filename, int width, int height, const string &destFilename) |
resize the given image More... | |
bool | GetImageInfo (const string &filename, int *width, int *height, int *nFileSize) |
get the given image info: i.e. More... | |
HRESULT | InvalidateDeviceObjects () |
HRESULT | RestoreDeviceObjects () |
void | EnableCodecSelection (bool bEnable) |
if true, a dialog will be displayed for the user to select the code and settings to use; otherwise the default codec will be used | |
bool | IsCodecSelectionEnabled () |
void | SetRecordingFPS (int nFPS) |
set the recording FPS, the default is 20 FPS. More... | |
int | GetRecordingFPS () |
Get the recording FPS, the default is 20 FPS. More... | |
void | SetStereoCaptureMode (MOVIE_CAPTURE_MODE nMode=MOVIE_CAPTURE_MODE_NORMAL) |
set the stereo capture mode. More... | |
MOVIE_CAPTURE_MODE | GetStereoCaptureMode () |
Get the stereo capture mode. More... | |
void | SetStereoEyeSeparation (float fDist) |
the distance in meters between the left and right eye when generating the stereo image. More... | |
float | GetStereoEyeSeparation () |
the distance in meters between the left and right eye when generating the stereo image. More... | |
int | GetCurrentFrameNumber () |
get the current frame number to be recorded. More... | |
void | FrameCaptureFFMPEG () |
force capture the current frame using just the movie codec plugin. More... | |
void | FrameCaptureDX (IMovieCodec *pMovieCodec) |
bool | HasMoviePlugin () |
whether we have the moviecodec plugin which uses ffmpeg internally. More... | |
void | SetCaptureAudio (bool bEnable) |
bool | IsCaptureAudio () |
void | SetCaptureMic (bool bEnable) |
bool | IsCaptureMic () |
bool | IsUseGDI () const |
void | SetUseGDI (bool val) |
![]() | |
virtual int | GetChildAttributeColumnCount () |
we support multi-dimensional child object. More... | |
virtual int | GetChildAttributeObjectCount (int nColumnIndex=0) |
get the number of child objects (row count) in the given column. More... | |
virtual IAttributeFields * | GetChildAttributeObject (int nRowIndex, int nColumnIndex=0) |
virtual IAttributeFields * | GetChildAttributeObject (const std::string &sName) |
get attribute by child object. More... | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetName_s, const char **) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetName_s, const char *) | |
ATTRIBUTE_METHOD (IAttributeFields, PrintObject_s) | |
ATTRIBUTE_METHOD (IAttributeFields, AddRef_s) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetRefCount_s, int *) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetTime_s, int) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetTime_s, int *) | |
ATTRIBUTE_METHOD (IAttributeFields, Release_s) | |
virtual const std::string & | GetIdentifier () |
virtual void | SetIdentifier (const std::string &sID) |
virtual bool | IsModified () |
whether some of the fields are modified.It is up to the implementation class to provide this functionality if necessary. More... | |
virtual void | SetModified (bool bModified) |
set whether any field has been modified. More... | |
virtual bool | ValidateFields () |
validate all fields and return true if validation passed. More... | |
virtual string | GetValidationMessage () |
get the recent validation message due to the most recent call to ValidateFields() | |
virtual bool | ResetField (int nFieldID) |
Reset the field to its initial or default value. More... | |
virtual bool | InvokeEditor (int nFieldID, const std::string &sParameters) |
Invoke an (external) editor for a given field. More... | |
virtual bool | AddChildAttributeObject (IAttributeFields *pChild, int nRowIndex=-1, int nColumnIndex=0) |
add child object. More... | |
virtual void * | QueryObjectByName (const std::string &sObjectType) |
convert to object of a given type. More... | |
virtual void * | QueryObject (int nObjectType) |
convert to object of a given type. More... | |
virtual int | GetTime () |
get the current local time in case it is animated in milli seconds frames. More... | |
virtual void | SetTime (int nTime) |
virtual CDynamicAttributeField * | GetDynamicField (const std::string &sName) |
Get a dynamic field with a given name. More... | |
virtual CDynamicAttributeField * | GetDynamicField (int nIndex) |
Get a dynamic field with a given index. More... | |
virtual const char * | GetDynamicFieldNameByIndex (int nIndex) |
get field name by index | |
virtual int | GetDynamicFieldCount () |
how many dynamic field this object currently have. More... | |
virtual int | SetDynamicField (const std::string &sName, const CVariable &value) |
set a dynamic field with a given name. More... | |
virtual int | AddDynamicField (const std::string &sName, ATTRIBUTE_FIELDTYPE dwType) |
add dynamic field and return field index | |
virtual void | RemoveAllDynamicFields () |
remove all dynamic fields | |
virtual int | SaveDynamicFieldsToString (std::string &output) |
save only text dynamic fields to fieldname = value text strings. More... | |
virtual int | LoadDynamicFieldsFromString (const std::string &input) |
load only text dynamic fields from string More... | |
CAttributeClass * | GetAttributeClass () |
get the main attribute class object. More... | |
void | PrintObject () |
print the content of this object to a text file at temp/doc/[ClassName].txt. More... | |
![]() | |
virtual void | Clone (IObject *obj) const |
Clone the object's contains to a pointer. More... | |
virtual IObject * | Clone () const |
Clone the object's contains and return a pointer to the newly created object. More... | |
virtual bool | Equals (const IObject *obj) const |
Compare the object with another object. More... | |
virtual const IType * | GetType () const |
virtual std::string | ToString () const |
WeakPtr_type & | GetWeakReference () |
get weak reference object. More... | |
virtual int | ProcessObjectEvent (const ObjectEvent &event) |
this function is only used to backward compatibility of ParaObject:AddEvent() function. More... | |
![]() | |
void | addref () const |
add reference count of the object. More... | |
bool | delref () const |
decrease reference count of the object. More... | |
int | GetRefCount () const |
get the reference count | |
virtual int | Release () |
CRefCounted * | AddToAutoReleasePool () |
addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More... | |
Static Public Member Functions | |
static CMoviePlatform & | GetSingleton () |
![]() | |
static HRESULT | GetAttributeClassID_s (IAttributeFields *cls, int *p1) |
static HRESULT | GetAttributeClassName_s (IAttributeFields *cls, const char **p1) |
static bool | OpenWithDefaultEditor (const char *sFilename, bool bWaitOnReturn=false) |
Open a given file with the default registered editor in the game engine. More... | |
Additional Inherited Members | |
![]() | |
virtual CAttributeClass * | CreateAttributeClass () |
initialize fields | |
virtual CDynamicAttributesSet * | GetDynamicAttributes (bool bCreateIfNotExist=false) |
![]() | |
WeakPtr_type | m_weak_reference |
![]() | |
int | m_refcount |
For managing and rendering the movie.
A movie may be comprised of series of clips
bool CMoviePlatform::BeginCapture | ( | const string & | sFileName | ) |
starting capturing a screen movie
sFileName | the movie file name, which can be "". If it is "", a default name is used. |
int CMoviePlatform::CaptureBitmapBuffer | ( | HWND | nHwnd, |
int & | outFileHeaderSize, | ||
int & | outInfoHeaderSize, | ||
std::vector< BYTE > & | outBuffers, | ||
bool | bCaptureMouse = false , |
||
int | nLeft = 0 , |
||
int | nTop = 0 , |
||
int | width = 0 , |
||
int | height = 0 |
||
) |
Captures a bitmap buffer through Windows GDI.
nHwnd; | A windows handle. |
outFileHeaderSize; | Out the size of BITMAPFILEHEADER. |
outInfoHeaderSize; | Out the size of BITMAPINFOHEADER |
outBuffers; | Out the completely buffer of a Bitmap includes BITMAPFILEHEADER and BITMAPINFOHEADER. |
bCaptureMouse;True | capture the mouse,False otherwise. |
nLeft; | The margin left of screen start to be captured. |
nTop; | The margin top of screen start to be captured. |
width; | The width of screen to be captured. |
height; | The height of screen to be captured. |
|
inline |
return true if GUI is also captured.
bool CMoviePlatform::EndCapture | ( | ) |
end capturing a screen movie and save movie to file.
void CMoviePlatform::FrameCaptureFFMPEG | ( | ) |
force capture the current frame using just the movie codec plugin.
|
inlinevirtual |
attribute class ID should be identical, unless one knows how overriding rules work.
Reimplemented from ParaEngine::IAttributeFields.
int CMoviePlatform::GetCurrentFrameNumber | ( | ) |
get the current frame number to be recorded.
This is usually used for stereo vision capture mode, when the even frame number is left eye, and odd is for right eye. if capture has not begun, it is always 0.
bool CMoviePlatform::GetImageInfo | ( | const string & | filename, |
int * | width, | ||
int * | height, | ||
int * | nFileSize | ||
) |
get the given image info: i.e.
size
width; | out in pixel |
height; | out in pixel |
nFileSize | out in size in bytes |
IMovieCodec * CMoviePlatform::GetMovieCodec | ( | bool | bCreateIfNotExist = true | ) |
try get the movie codec.
this function may return NULL if dll does not exist.
int CMoviePlatform::GetRecordingFPS | ( | ) |
Get the recording FPS, the default is 20 FPS.
Some may prefer 30FPS.
MOVIE_CAPTURE_MODE CMoviePlatform::GetStereoCaptureMode | ( | ) |
Get the stereo capture mode.
This is used to generate video files that can be viewed by 3d eye glasses and stereo video player.
float CMoviePlatform::GetStereoEyeSeparation | ( | ) |
the distance in meters between the left and right eye when generating the stereo image.
some common values are in range [0.03, 0.1]. This is also related to the rendering unit that we used in games. since ParaEngine games usually use meter as its rendering unit, the value is such near the real eye separation distance.
bool CMoviePlatform::HasMoviePlugin | ( | ) |
whether we have the moviecodec plugin which uses ffmpeg internally.
|
virtual |
this class should be implemented if one wants to add new attribute.
This function is always called internally.
Reimplemented from ParaEngine::IAttributeFields.
bool CMoviePlatform::IsInCaptureSession | ( | ) |
whether we are doing screen capture.
I.e. true between BeginCapture() and EndCapture() However, it may be in the recording or paused state.
bool CMoviePlatform::IsRecording | ( | ) |
whether it is recording.
void CMoviePlatform::PauseCapture | ( | ) |
pause the capturing.
bool CMoviePlatform::ResizeImage | ( | const string & | filename, |
int | width, | ||
int | height, | ||
const string & | destFilename | ||
) |
resize the given image
width; | in pixel |
height; | in pixel |
destFilename | destination file name |
void CMoviePlatform::SaveCapturedFrame | ( | int | nMode = 0 | ) |
save the captured frame to file.
nMode | 0 for normal capture; 2 for capture only even lines, 3 for capture only odd lines. |
|
inline |
set whether GUI is captured.
bool CMoviePlatform::SetCaptureTarget | ( | ) |
set the current render target, so that everything that is rendered subsequently will be recorded One must call UnsetCaptureTarget(), in a render frame.
void CMoviePlatform::SetMovieScreenSize | ( | int | nWidth, |
int | nHeight | ||
) |
set the movie screen size in pixel.
nWidth | in pixels, must be multiple of 4. |
nHeight | in pixels, must be multiple of 4. |
void CMoviePlatform::SetRecordingFPS | ( | int | nFPS | ) |
set the recording FPS, the default is 20 FPS.
Some may prefer 30FPS.
void CMoviePlatform::SetStereoCaptureMode | ( | MOVIE_CAPTURE_MODE | nMode = MOVIE_CAPTURE_MODE_NORMAL | ) |
set the stereo capture mode.
This is used to generate video files that can be viewed by 3d eye glasses and stereo video player.
void CMoviePlatform::SetStereoEyeSeparation | ( | float | fDist | ) |
the distance in meters between the left and right eye when generating the stereo image.
some common values are in range [0.03, 0.1]. This is also related to the rendering unit that we used in games. since ParaEngine games usually use meter as its rendering unit, the value is such near the real eye separation distance.
bool CMoviePlatform::TakeScreenShot | ( | const string & | filename | ) |
by default it save the screen shot as JPG file in the .
/screenshot directory.
filename | this is the file name without extension. It can be "". |
bool CMoviePlatform::TakeScreenShot | ( | const string & | filename, |
int | width, | ||
int | height | ||
) |
by default it save the screen shot as JPG file in the .
/screenshot directory.
filename | this is the file name without extension. It can be "". |
width; | in pixel, if 0 it will be the screen size |
height; | in pixel, if 0 it will be the screen size |
void CMoviePlatform::TakeScreenShot_Async | ( | const string & | filename, |
bool | bEncode = false , |
||
int | width = -1 , |
||
int | height = -1 , |
||
screenshot_callback | callback = nullptr |
||
) |
Use a new thread to take a screenshot.
filename; | Its included file path and file name. |
bEncode;If | true Enable Base64Encode. |
width; | The out value of Image's width, if width = -1 or height = -1, the out value same as the width of Windows. |
height; | The out value of Image's height, if width = -1 or height = -1, the out value same as the height of Windows. |
screenshot_callback; | It will be actived after take a screenshot. |
bool CMoviePlatform::TakeScreenShot_FromGDI | ( | const string & | filename, |
std::vector< BYTE > & | outBase64Buffers, | ||
bool | bEncode = false , |
||
int | width = -1 , |
||
int | height = -1 |
||
) |
Captures a bitmap buffer and uses FreeImage library to change it into a Image.
the format of Image defined by the extension of filename. default format is PNG,also supported DDS JPG BMP TGA.
filename; | Its included file path and file name. |
outBase64Buffers; | The result of Base64Encode. |
bEncode; | If true Enable Base64Encode. |
width; | The out value of Image's width, if width = -1 or height = -1, the out value same as the width of Windows. |
height; | The out value of Image's height, if width = -1 or height = -1, the out value same as the height of Windows. |
bool CMoviePlatform::UnsetCaptureTarget | ( | ) |
restore the render target to what it is when SetCaptureTarget() is called.
This usually restore render target to the back buffer
void CMoviePlatform::video_encode_example | ( | const char * | filename, |
int | codec_id = 0 |
||
) |
encode a random dummy video to the given filename with given codec.