Permalink
Browse files

Implemented more theoraplayer API.

git-svn-id: http://maxmods.googlecode.com/svn/trunk@1243 b77917fb-863c-0410-9a43-030a88dac9d3
  • Loading branch information...
1 parent 982612d commit e10abb0a4e5eab02c0a9479c266ff4774ae5db61 woollybah committed Nov 6, 2011
Showing with 84 additions and 13 deletions.
  1. +6 −1 theoraplayer.mod/common.bmx
  2. +27 −3 theoraplayer.mod/glue.cpp
  3. +51 −9 theoraplayer.mod/theoraplayer.bmx
@@ -33,14 +33,16 @@ Import "source.bmx"
Extern
- Function bmx_TheoraVideoManager_new:Byte Ptr()
+ Function bmx_TheoraVideoManager_new:Byte Ptr(numWorkerThreads:Int)
Function bmx_TheoraVideoManager_free(handle:Byte Ptr)
Function bmx_TheoraVideoManager_createVideoClip:Byte Ptr(handle:Byte Ptr, filename:String, outputMode:Int, numPrecachedOverride:Int, usePower2Stride:Int)
Function bmx_TheoraVideoManager_update(handle:Byte Ptr, timeIncrease:Float)
Function bmx_TheoraVideoManager_setAudioInterfaceFactory(handle:Byte Ptr, factory:Byte Ptr)
Function bmx_TheoraVideoManager_getVersion(handle:Byte Ptr, a:Int Ptr, b:Int Ptr, c:Int Ptr)
Function bmx_TheoraVideoManager_getVersionString:String(handle:Byte Ptr)
Function bmx_TheoraVideoManager_destroyVideoClip(handle:Byte Ptr, clip:Byte Ptr)
+ Function bmx_TheoraVideoManager_getNumWorkerThreads:Int(handle:Byte Ptr)
+ Function bmx_TheoraVideoManager_setNumWorkerThreads(handle:Byte Ptr, numWorkerThreads:Int)
Function bmx_TheoraVideoClip_getName:String(handle:Byte Ptr)
Function bmx_TheoraVideoClip_getWidth:Int(handle:Byte Ptr)
@@ -61,6 +63,9 @@ Extern
Function bmx_TheoraVideoClip_setPlaybackSpeed(handle:Byte Ptr, speed:Float)
Function bmx_TheoraVideoClip_getPlaybackSpeed:Float(handle:Byte Ptr)
Function bmx_TheoraVideoClip_seek(handle:Byte Ptr, time:Float)
+ Function bmx_TheoraVideoClip_updateToNextFrame:Float(handle:Byte Ptr)
+ Function bmx_TheoraVideoClip_setAutoRestart(handle:Byte Ptr, restart:Int)
+ Function bmx_TheoraVideoClip_getAutoRestart:Int(handle:Byte Ptr)
Function bmx_TheoraVideoFrame_getBuffer:Byte Ptr(handle:Byte Ptr)
View
@@ -34,14 +34,16 @@ extern "C" {
BBObject * _bah_theoraplayer_TTheoraGenericException__create(BBString * mErrText, BBString * mFile, BBString * mType);
- TheoraVideoManager * bmx_TheoraVideoManager_new();
+ TheoraVideoManager * bmx_TheoraVideoManager_new(int numWorkerThreads);
void bmx_TheoraVideoManager_free(TheoraVideoManager * manager);
TheoraVideoClip * bmx_TheoraVideoManager_createVideoClip(TheoraVideoManager * manager, BBString * filename, int outputMode, int numPrecachedOverride, int usePower2Stride);
void bmx_TheoraVideoManager_update(TheoraVideoManager * manager, float timeIncrease);
void bmx_TheoraVideoManager_setAudioInterfaceFactory(TheoraVideoManager * manager, TheoraAudioInterfaceFactory * factory);
void bmx_TheoraVideoManager_getVersion(TheoraVideoManager * manager, int * a, int * b, int * c);
BBString * bmx_TheoraVideoManager_getVersionString(TheoraVideoManager * manager);
void bmx_TheoraVideoManager_destroyVideoClip(TheoraVideoManager * manager, TheoraVideoClip * clip);
+ int bmx_TheoraVideoManager_getNumWorkerThreads(TheoraVideoManager * manager);
+ void bmx_TheoraVideoManager_setNumWorkerThreads(TheoraVideoManager * manager, int numWorkerThreads);
BBString * bmx_TheoraVideoClip_getName(TheoraVideoClip * clip);
int bmx_TheoraVideoClip_getWidth(TheoraVideoClip * clip);
@@ -62,6 +64,9 @@ extern "C" {
void bmx_TheoraVideoClip_setPlaybackSpeed(TheoraVideoClip * clip, float speed);
float bmx_TheoraVideoClip_getPlaybackSpeed(TheoraVideoClip * clip);
void bmx_TheoraVideoClip_seek(TheoraVideoClip * clip, float time);
+ float bmx_TheoraVideoClip_updateToNextFrame(TheoraVideoClip * clip);
+ void bmx_TheoraVideoClip_setAutoRestart(TheoraVideoClip * clip, int restart);
+ int bmx_TheoraVideoClip_getAutoRestart(TheoraVideoClip * clip);
void * bmx_TheoraVideoFrame_getBuffer(TheoraVideoFrame * frame);
@@ -78,8 +83,8 @@ void bmx_theoraplayer_throw_exception(_TheoraGenericException & e) {
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-TheoraVideoManager * bmx_TheoraVideoManager_new() {
- return new TheoraVideoManager();
+TheoraVideoManager * bmx_TheoraVideoManager_new(int numWorkerThreads) {
+ return new TheoraVideoManager(numWorkerThreads);
}
void bmx_TheoraVideoManager_free(TheoraVideoManager * manager) {
@@ -125,6 +130,14 @@ void bmx_TheoraVideoManager_destroyVideoClip(TheoraVideoManager * manager, Theor
manager->destroyVideoClip(clip);
}
+int bmx_TheoraVideoManager_getNumWorkerThreads(TheoraVideoManager * manager) {
+ return manager->getNumWorkerThreads();
+}
+
+void bmx_TheoraVideoManager_setNumWorkerThreads(TheoraVideoManager * manager, int numWorkerThreads) {
+ manager->setNumWorkerThreads(numWorkerThreads);
+}
+
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BBString * bmx_TheoraVideoClip_getName(TheoraVideoClip * clip) {
@@ -199,6 +212,17 @@ void bmx_TheoraVideoClip_seek(TheoraVideoClip * clip, float time) {
clip->seek(time);
}
+float bmx_TheoraVideoClip_updateToNextFrame(TheoraVideoClip * clip) {
+ return clip->updateToNextFrame();
+}
+
+void bmx_TheoraVideoClip_setAutoRestart(TheoraVideoClip * clip, int restart) {
+ clip->setAutoRestart(restart);
+}
+
+int bmx_TheoraVideoClip_getAutoRestart(TheoraVideoClip * clip) {
+ return clip->getAutoRestart();
+}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -57,22 +57,23 @@ Type TTheoraVideoManager
Field audioFactory:TTheoraAudioInterfaceFactory
Rem
- bbdoc:
+ bbdoc: Creates a Video Manager instance, with an optional worker thread count.
End Rem
- Method Create:TTheoraVideoManager()
- managerPtr = bmx_TheoraVideoManager_new()
+ Method Create:TTheoraVideoManager(numWorkerThreads:Int = 1)
+ managerPtr = bmx_TheoraVideoManager_new(numWorkerThreads)
Return Self
End Method
Rem
- bbdoc:
+ bbdoc: Creates a video clip with the specified parameters.
+ about: When you are finished with the clip, it should be freed using the #destroyVideoClip() method.
End Rem
Method createVideoClip:TTheoraVideoClip(filename:String, outputMode:Int = TH_RGB, numPrecachedOverride:Int = 0, usePower2Stride:Int = 0)
Return TTheoraVideoClip._create(bmx_TheoraVideoManager_createVideoClip(managerPtr, filename, outputMode, numPrecachedOverride, usePower2Stride))
End Method
Rem
- bbdoc:
+ bbdoc: Frees a previously created video clip.
End Rem
Method destroyVideoClip(clip:TTheoraVideoClip)
bmx_TheoraVideoManager_destroyVideoClip(managerPtr, clip.clipPtr)
@@ -101,13 +102,28 @@ Type TTheoraVideoManager
End Method
Rem
- bbdoc:
+ bbdoc: Sets the audio interface.
+ about: Call this with an appropriate audio factory to enable sound with the video.
End Rem
Method setAudioInterfaceFactory(factory:TTheoraAudioInterfaceFactory)
audioFactory = factory
bmx_TheoraVideoManager_setAudioInterfaceFactory(managerPtr, factory.factoryPtr)
End Method
+ Rem
+ bbdoc: Returns the number of worker threads.
+ End Rem
+ Method getNumWorkerThreads:Int()
+ Return bmx_TheoraVideoManager_getNumWorkerThreads(managerPtr)
+ End Method
+
+ Rem
+ bbdoc: Sets the number of worker threads.
+ End Rem
+ Method setNumWorkerThreads(numWorkerThreads:Int)
+ bmx_TheoraVideoManager_setNumWorkerThreads(managerPtr, numWorkerThreads)
+ End Method
+
Method Free()
If managerPtr Then
bmx_TheoraVideoManager_free(managerPtr)
@@ -145,7 +161,7 @@ Type TTheoraVideoClip
End Method
Rem
- bbdoc:
+ bbdoc: Returns the name of the video clip.
End Rem
Method getName:String()
Return bmx_TheoraVideoClip_getName(clipPtr)
@@ -272,11 +288,37 @@ Type TTheoraVideoClip
bmx_TheoraVideoClip_seek(clipPtr, time)
End Method
+ Rem
+ bbdoc: Updates timer to the display time of the next frame.
+ returns: Time advanced. 0 if no frames are ready.
+ about: Useful if you want to grab frames instead of regular display.
+ End Rem
+ Method updateToNextFrame:Float()
+ Return bmx_TheoraVideoClip_updateToNextFrame(clipPtr)
+ End Method
+
+ Rem
+ bbdoc: Sets the auto restart flag.
+ about: If you want the video to automatically and smoothly restart when the last frame is reached.
+ End Rem
+ Method setAutoRestart(restart:Int)
+ bmx_TheoraVideoClip_setAutoRestart(clipPtr, restart)
+ End Method
+
+ Rem
+ bbdoc: Returns the auto restart flag.
+ about: If you want the video to automatically and smoothly restart when the last frame is reached.
+ bbdoc:
+ End Rem
+ Method getAutoRestart:Int()
+ Return bmx_TheoraVideoClip_getAutoRestart(clipPtr)
+ End Method
+
End Type
Rem
-bbdoc:
+bbdoc: A video frame.
End Rem
Type TTheoraVideoFrame
@@ -291,7 +333,7 @@ Type TTheoraVideoFrame
End Function
Rem
- bbdoc:
+ bbdoc: Returns the pixel data buffer for this frame.
End Rem
Method getBuffer:Byte Ptr()
Return bmx_TheoraVideoFrame_getBuffer(framePtr)

0 comments on commit e10abb0

Please sign in to comment.