My Project
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ParaEngine::CMoviePlatform Class Reference

For managing and rendering the movie. More...

#include <MoviePlatform.h>

Inheritance diagram for ParaEngine::CMoviePlatform:
ParaEngine::IAttributeFields ParaEngine::IObject ParaEngine::CRefCounted

Public Types

typedef std::function< void(bool, std::vector< BYTE > &base64)> screenshot_callback
 
- Public Types inherited from ParaEngine::IAttributeFields
typedef ParaEngine::weak_ptr< IObject, IAttributeFieldsWeakPtr_type
 
- Public Types inherited from ParaEngine::IObject
typedef ParaEngine::weak_ptr< IObjectWeakPtr_type
 

Public Member Functions

void Cleanup ()
 
IMovieCodecGetMovieCodec (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)
 
- Public Member Functions inherited from ParaEngine::IAttributeFields
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 IAttributeFieldsGetChildAttributeObject (int nRowIndex, int nColumnIndex=0)
 
virtual IAttributeFieldsGetChildAttributeObject (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 CDynamicAttributeFieldGetDynamicField (const std::string &sName)
 Get a dynamic field with a given name. More...
 
virtual CDynamicAttributeFieldGetDynamicField (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...
 
CAttributeClassGetAttributeClass ()
 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...
 
- Public Member Functions inherited from ParaEngine::IObject
virtual void Clone (IObject *obj) const
 Clone the object's contains to a pointer. More...
 
virtual IObjectClone () 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 ITypeGetType () const
 
virtual std::string ToString () const
 
WeakPtr_typeGetWeakReference ()
 get weak reference object. More...
 
virtual int ProcessObjectEvent (const ObjectEvent &event)
 this function is only used to backward compatibility of ParaObject:AddEvent() function. More...
 
- Public Member Functions inherited from ParaEngine::CRefCounted
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 ()
 
CRefCountedAddToAutoReleasePool ()
 addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More...
 

Static Public Member Functions

static CMoviePlatformGetSingleton ()
 
- Static Public Member Functions inherited from ParaEngine::IAttributeFields
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

- Protected Member Functions inherited from ParaEngine::IAttributeFields
virtual CAttributeClassCreateAttributeClass ()
 initialize fields
 
virtual CDynamicAttributesSetGetDynamicAttributes (bool bCreateIfNotExist=false)
 
- Protected Attributes inherited from ParaEngine::IObject
WeakPtr_type m_weak_reference
 
- Protected Attributes inherited from ParaEngine::CRefCounted
int m_refcount
 

Detailed Description

For managing and rendering the movie.

A movie may be comprised of series of clips

Member Function Documentation

§ BeginCapture()

bool CMoviePlatform::BeginCapture ( const string &  sFileName)

starting capturing a screen movie

Parameters
sFileNamethe movie file name, which can be "". If it is "", a default name is used.

§ CaptureBitmapBuffer()

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.

Parameters
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;Truecapture 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.

§ CaptureGUI()

bool ParaEngine::CMoviePlatform::CaptureGUI ( )
inline

return true if GUI is also captured.

§ EndCapture()

bool CMoviePlatform::EndCapture ( )

end capturing a screen movie and save movie to file.

§ FrameCaptureFFMPEG()

void CMoviePlatform::FrameCaptureFFMPEG ( )

force capture the current frame using just the movie codec plugin.

§ GetAttributeClassID()

virtual int ParaEngine::CMoviePlatform::GetAttributeClassID ( )
inlinevirtual

attribute class ID should be identical, unless one knows how overriding rules work.

Reimplemented from ParaEngine::IAttributeFields.

§ GetCurrentFrameNumber()

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.

§ GetImageInfo()

bool CMoviePlatform::GetImageInfo ( const string &  filename,
int *  width,
int *  height,
int *  nFileSize 
)

get the given image info: i.e.

size

Parameters
width;out in pixel
height;out in pixel
nFileSizeout in size in bytes

§ GetMovieCodec()

IMovieCodec * CMoviePlatform::GetMovieCodec ( bool  bCreateIfNotExist = true)

try get the movie codec.

this function may return NULL if dll does not exist.

§ GetRecordingFPS()

int CMoviePlatform::GetRecordingFPS ( )

Get the recording FPS, the default is 20 FPS.

Some may prefer 30FPS.

§ GetStereoCaptureMode()

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.

  • 0 for disable stereo capture(default);
  • 1 for line interlaced stereo.
  • 2 for left right stereo;
  • 3 for above below stereo;
  • 4 for frame interlaved mode, where the odd frame is the left eye and even frame is the right image;

§ GetStereoEyeSeparation()

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.

§ HasMoviePlugin()

bool CMoviePlatform::HasMoviePlugin ( )

whether we have the moviecodec plugin which uses ffmpeg internally.

§ InstallFields()

int CMoviePlatform::InstallFields ( CAttributeClass pClass,
bool  bOverride 
)
virtual

this class should be implemented if one wants to add new attribute.

This function is always called internally.

Reimplemented from ParaEngine::IAttributeFields.

§ IsInCaptureSession()

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.

§ IsRecording()

bool CMoviePlatform::IsRecording ( )

whether it is recording.

§ PauseCapture()

void CMoviePlatform::PauseCapture ( )

pause the capturing.

§ ResizeImage()

bool CMoviePlatform::ResizeImage ( const string &  filename,
int  width,
int  height,
const string &  destFilename 
)

resize the given image

Parameters
width;in pixel
height;in pixel
destFilenamedestination file name

§ SaveCapturedFrame()

void CMoviePlatform::SaveCapturedFrame ( int  nMode = 0)

save the captured frame to file.

Parameters
nMode0 for normal capture; 2 for capture only even lines, 3 for capture only odd lines.

§ SetCaptureGUI()

void ParaEngine::CMoviePlatform::SetCaptureGUI ( bool  bGUI)
inline

set whether GUI is captured.

§ SetCaptureTarget()

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.

§ SetMovieScreenSize()

void CMoviePlatform::SetMovieScreenSize ( int  nWidth,
int  nHeight 
)

set the movie screen size in pixel.

Parameters
nWidthin pixels, must be multiple of 4.
nHeightin pixels, must be multiple of 4.

§ SetRecordingFPS()

void CMoviePlatform::SetRecordingFPS ( int  nFPS)

set the recording FPS, the default is 20 FPS.

Some may prefer 30FPS.

§ SetStereoCaptureMode()

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.

  • 0 for disable stereo capture(default);
  • 1 for line interlaced stereo.
  • 2 for left right stereo;
  • 3 for above below stereo;
  • 4 for frame interlaved mode, where the odd frame is the left eye and even frame is the right image;

§ SetStereoEyeSeparation()

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.

§ TakeScreenShot() [1/2]

bool CMoviePlatform::TakeScreenShot ( const string &  filename)

by default it save the screen shot as JPG file in the .

/screenshot directory.

Parameters
filenamethis is the file name without extension. It can be "".

§ TakeScreenShot() [2/2]

bool CMoviePlatform::TakeScreenShot ( const string &  filename,
int  width,
int  height 
)

by default it save the screen shot as JPG file in the .

/screenshot directory.

Parameters
filenamethis 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

§ TakeScreenShot_Async()

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.

Parameters
filename;Its included file path and file name.
bEncode;Iftrue 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.

§ TakeScreenShot_FromGDI()

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.

Parameters
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.

§ UnsetCaptureTarget()

bool CMoviePlatform::UnsetCaptureTarget ( )

restore the render target to what it is when SetCaptureTarget() is called.

This usually restore render target to the back buffer

§ video_encode_example()

void CMoviePlatform::video_encode_example ( const char *  filename,
int  codec_id = 0 
)

encode a random dummy video to the given filename with given codec.


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