VideoVis  0.9
Generates a volume visualisation of a video
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
CVideoFrameLoader Class Reference

This class loads video files. More...

#include <VideoFrameLoader.h>

Inheritance diagram for CVideoFrameLoader:
CVideoFrameToTextureLoader

Public Member Functions

 CVideoFrameLoader (void)
 This is the default constructor. More...
 
 CVideoFrameLoader (PWSTR filePath)
 Constructor to load a file. More...
 
 ~CVideoFrameLoader (void)
 Destructor. More...
 
VFLResult setVideoPath (PWSTR filePath)
 Opens a new videofile. More...
 
VFLResult setVideoURL (PWSTR fileURL)
 Opens a new videofile. More...
 
VFLResult loadAllFramesIntoBuffer ()
 Loads all video frames of the opend video file. More...
 
VFLResult loadAllFramesIntoBuffer (int offset, int distanceBetween)
 Loads all video frames with offset and distance between. More...
 
VFLResult loadAllFramesIntoBuffer (int offset, int distanceBetween, int lastFrame)
 Loads all video frames with offset, distance between and sets a last frame. More...
 
VFLResult addNextFrameToBuffer ()
 Adds the next frame at the current video file position. More...
 
VFLResult addNextFrameToBuffer (int distanceFromLast)
 Adds the next frame at an offset from the current video file position. More...
 
VFLResult getVideoResolution (int *width, int *height)
 Returns the resolution of the current loaded video file. More...
 
VFLResult getVideoBuffer (PBYTE *videoArray)
 Returns the BYTE-Array in which the video data is stored. More...
 
VFLResult getBufferFrameCount (int *frameCount)
 Returns the number of fames that have been saved to the byte array. More...
 
void reset ()
 Resets the "play head" to the starting position. More...
 
HRESULT setPosition (const LONGLONG &hnsPosition)
 Sets the position of the "play head" to a new time code. More...
 

Protected Member Functions

virtual VFLResult resetProperties ()
 Completly resets the object. More...
 
void copyVideoListToVideoArray ()
 Copies the video data from the internal storage into the video array. More...
 

Protected Attributes

PBYTE p_videoArray
 

Detailed Description

This class loads video files.

This class can load video files into a BYTE-Array. It uses the windows media foundation framework and should work under Windows 7, 8 and later. It can load all frames of a video file, all frames after an offset or single frames with a given distance to the last loaded frame.

Definition at line 40 of file VideoFrameLoader.h.

Constructor & Destructor Documentation

CVideoFrameLoader::CVideoFrameLoader ( void  )

This is the default constructor.

It simple initialises the object. To open a video file you can use the other constructor, the setVideoPath(PWSTR filePath) method or the setVideoURL(PWSTR fileURL) method.

See Also
CVideoFrameLoader(PWSTR filePath), setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL)

Definition at line 9 of file VideoFrameLoader.cpp.

CVideoFrameLoader::CVideoFrameLoader ( PWSTR  filePath)

Constructor to load a file.

Initialises the object and loads the specified file.

Parameters
filePatha pointer to a WSTR which contains the path to the video file in windows syntax
See Also
CVideoFrameLoader(), setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL)

Definition at line 14 of file VideoFrameLoader.cpp.

CVideoFrameLoader::~CVideoFrameLoader ( void  )

Destructor.

Cleans up all reserved memory.

Definition at line 44 of file VideoFrameLoader.cpp.

Member Function Documentation

VFLResult CVideoFrameLoader::addNextFrameToBuffer ( )

Adds the next frame at the current video file position.

After that, the "play head" moves to the next frame.

Returns
returns VFL_OK if the operation succeded or VFL_NO_MORE_FRAMES if the "play head" is at the end of the file
See Also
addNextFrameToBuffer(int distanceFromLast)
loadAllFramesIntoBuffer(), loadAllFramesIntoBuffer(int offset, int distanceBetween), loadAllFramesIntoBuffer(int offset, int distanceBetween, int lastFrame)
setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL), CVideoFrameLoader(PWSTR filePath)

Definition at line 196 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::addNextFrameToBuffer ( int  distanceFromLast)

Adds the next frame at an offset from the current video file position.

The function skipps the specified number of frames in the video file and reads the frame at that position

Parameters
distanceFromLastinteger value that specifies the distance from the last read frame; if 0 the next consecutive frame is read
Returns
returns VFL_OK if the operation succeded or VFL_NO_MORE_FRAMES if the "play head" comes to the end of the file without reading a frame
See Also
addNextFrameToBuffer()
loadAllFramesIntoBuffer(), loadAllFramesIntoBuffer(int offset, int distanceBetween), loadAllFramesIntoBuffer(int offset, int distanceBetween, int lastFrame)
setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL), CVideoFrameLoader(PWSTR filePath)

Definition at line 201 of file VideoFrameLoader.cpp.

void CVideoFrameLoader::copyVideoListToVideoArray ( )
protected

Copies the video data from the internal storage into the video array.

Call this method in your derived class if you want to access the data in a consecutive memory block. After the call the p_videoArray pointer points to a byte array with the video data. If only this method is invoked, the byte array will be destroyed bevor a new video is loaded or the object is deleted.

See Also
getVideoBuffer(PBYTE *videoArray)
addNextFrameToBuffer(), addNextFrameToBuffer(int distanceFromLast)
loadAllFramesIntoBuffer(), loadAllFramesIntoBuffer(int offset, int distanceBetween), loadAllFramesIntoBuffer(int offset, int distanceBetween, int lastFrame)

Definition at line 353 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::getBufferFrameCount ( int *  frameCount)

Returns the number of fames that have been saved to the byte array.

Parameters
frameCounta pointer to an integer where the number of captured frames will be saved
Returns
returns VFL_OK if the operation was successful
See Also
getVideoBuffer(PBYTE *videoArray), getVideoResolution(int *width, int *height)
addNextFrameToBuffer(), addNextFrameToBuffer(int distanceFromLast)
loadAllFramesIntoBuffer(), loadAllFramesIntoBuffer(int offset, int distanceBetween), loadAllFramesIntoBuffer(int offset, int distanceBetween, int lastFrame)

Definition at line 266 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::getVideoBuffer ( PBYTE *  videoArray)

Returns the BYTE-Array in which the video data is stored.

The caller receives a pointer to the byte array in which the video data resides in BGRA-format. The size of the array is the number of frames times the width and the height of the video times 4. These values can be obtained by calling the apropriate methods. After this method has been called, the array will never be delete. It falls to the caller to delete the array after usage.

Parameters
videoArraya pointer to a pointer to a BYTE
Returns
VFL_OK if the call was successful
See Also
getVideoResolution(int *width, int *height), getBufferFrameCount(int *frameCount)
addNextFrameToBuffer(), addNextFrameToBuffer(int distanceFromLast)
loadAllFramesIntoBuffer(), loadAllFramesIntoBuffer(int offset, int distanceBetween), loadAllFramesIntoBuffer(int offset, int distanceBetween, int lastFrame)
setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL), CVideoFrameLoader(PWSTR filePath)

Definition at line 252 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::getVideoResolution ( int *  width,
int *  height 
)

Returns the resolution of the current loaded video file.

This method returns good data, only after the video file has been succesfully loaded.

Parameters
widthpointer to an integer, where the video width will be saved
heightpointer to an integer, where the video height will be saved
Returns
return VFL_OK if the video resulution could be obtained
See Also
setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL), CVideoFrameLoader(PWSTR filePath)

Definition at line 241 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::loadAllFramesIntoBuffer ( )

Loads all video frames of the opend video file.

The frames will be saved into a BYTE buffer. The buffer can then be retrieved by calling getVideoBuffer(PBYTE *videoArray).

Returns
returns VFL_NO_MORE_FRAMES if the operation succeded and the video has ended.
See Also
loadAllFramesIntoBuffer(int offset, int distanceBetween), loadAllFramesIntoBuffer(int offset, int distanceBetween, int lastFrame)
addNextFrameToBuffer(), addNextFrameToBuffer(int distanceFromLast)
setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL), CVideoFrameLoader(PWSTR filePath)

Definition at line 164 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::loadAllFramesIntoBuffer ( int  offset,
int  distanceBetween 
)

Loads all video frames with offset and distance between.

The frames will be saved into a BYTE buffer. The buffer can then be retrieved by calling getVideoBuffer(PBYTE *videoArray).

Parameters
offsetan integer value starting by 0 that specifies the offset of frames from the start of the video
distanceBetweenan integer value the specifies the number of frames between to frames, that are left out
Returns
returns VFL_NO_MORE_FRAMES if the operation succeded and the video has ended.
See Also
loadAllFramesIntoBuffer(), loadAllFramesIntoBuffer(int offset, int distanceBetween, int lastFrame)
addNextFrameToBuffer(), addNextFrameToBuffer(int distanceFromLast)
setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL), CVideoFrameLoader(PWSTR filePath)

Definition at line 169 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::loadAllFramesIntoBuffer ( int  offset,
int  distanceBetween,
int  lastFrame 
)

Loads all video frames with offset, distance between and sets a last frame.

The frames will be saved into a BYTE buffer. The buffer can then be retrieved by calling getVideoBuffer(PBYTE *videoArray).

Parameters
offsetan integer value starting by 0 that specifies the offset of frames from the start of the video
distanceBetweenan integer value the specifies the number of frames between to frames, that are left out
lastFramean inteber value specifying the last frame that should be read; if 0 the method reads till the last frame of the video file
Returns
returns VFL_OK if the operation succeded or VFL_NO_MORE_FRAMES if the operation succeded and the video has ended
See Also
loadAllFramesIntoBuffer(), loadAllFramesIntoBuffer(int offset, int distanceBetween)
addNextFrameToBuffer(), addNextFrameToBuffer(int distanceFromLast)
setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL), CVideoFrameLoader(PWSTR filePath)

Definition at line 174 of file VideoFrameLoader.cpp.

void CVideoFrameLoader::reset ( )

Resets the "play head" to the starting position.

The byte array will remain filled. To completly reset the object you have to reopen the video file.

See Also
setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL), CVideoFrameLoader(PWSTR filePath)

Definition at line 276 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::resetProperties ( )
protectedvirtual

Completly resets the object.

This virtual method is called to reset the reset all neccessary member properties bevor a new video file is loaded. Overwrite this method to reset your own properties before a new video file is loaded, if you derive from this class.

Returns
returns VFL_OK;
See Also
reset()
setVideoPath(PWSTR filePath), setVideoURL(PWSTR fileURL), CVideoFrameLoader(PWSTR filePath)

Reimplemented in CVideoFrameToTextureLoader.

Definition at line 74 of file VideoFrameLoader.cpp.

HRESULT CVideoFrameLoader::setPosition ( const LONGLONG &  hnsPosition)

Sets the position of the "play head" to a new time code.

The byte array will remain filled. To completly reset the object you have to reopen the video file.

Parameters
hnsPositiona LONGLONG value of the new "play head" position in 100 ms increments.
Returns
returns VFL_OK if the operation was successful
See Also
addNextFrameToBuffer(), addNextFrameToBuffer(int distanceFromLast)
loadAllFramesIntoBuffer(), loadAllFramesIntoBuffer(int offset, int distanceBetween), loadAllFramesIntoBuffer(int offset, int distanceBetween, int lastFrame)

Definition at line 340 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::setVideoPath ( PWSTR  filePath)

Opens a new videofile.

If there is another video file loaded, the file will be closed and all references will be deleted.

Parameters
filePatha pointer to a WSTR which contains the path to the video file in windows syntax
Returns
returns VFL_OK if the operation succeeded.
See Also
CVideoFrameLoader(PWSTR filePath), setVideoURL(PWSTR fileURL)

Definition at line 90 of file VideoFrameLoader.cpp.

VFLResult CVideoFrameLoader::setVideoURL ( PWSTR  fileURL)

Opens a new videofile.

If there is another video file loaded, the file will be closed and all references will be deleted.

Parameters
fileURLa pointer to a WSTR which contains the URL to the video file
Returns
returns VFL_OK if the operation succeeded
See Also
CVideoFrameLoader(PWSTR filePath), setVideoPath(PWSTR filePath)

Definition at line 110 of file VideoFrameLoader.cpp.

Member Data Documentation

PBYTE CVideoFrameLoader::p_videoArray
protected

Pointer to the video array. It's only filled when the getVideoBuffer(PBYTE *videoArray) or the getVideoBuffer(PBYTE *videoArray) method is called.

Definition at line 196 of file VideoFrameLoader.h.


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