[xiph-commits] r3130 - in liboggplay/trunk/plugin: . support test
shans at svn.annodex.net
shans at svn.annodex.net
Thu Jun 28 17:18:28 PDT 2007
Author: shans
Date: 2007-06-28 17:18:28 -0700 (Thu, 28 Jun 2007)
New Revision: 3130
Modified:
liboggplay/trunk/plugin/Makefile.am
liboggplay/trunk/plugin/nsILibOggPlugin.idl
liboggplay/trunk/plugin/plugin.cpp
liboggplay/trunk/plugin/plugin.h
liboggplay/trunk/plugin/plugin_c.h
liboggplay/trunk/plugin/plugin_gui_linux.c
liboggplay/trunk/plugin/support/nsScriptablePeer.cpp
liboggplay/trunk/plugin/test/test.html
Log:
Asynchronous CMML retrieval
Modified: liboggplay/trunk/plugin/Makefile.am
===================================================================
--- liboggplay/trunk/plugin/Makefile.am 2007-06-28 16:16:41 UTC (rev 3129)
+++ liboggplay/trunk/plugin/Makefile.am 2007-06-29 00:18:28 UTC (rev 3130)
@@ -34,7 +34,9 @@
include/npplat.h \
include/pluginbase.h \
support/nsScriptablePeer.h \
- audio/sydney_audio.h
+ audio/sydney_audio.h \
+ plugin_c.h \
+ plugin_cmml.h
# Libraries to build
lib_LTLIBRARIES = $(plugin_libs)
@@ -48,7 +50,8 @@
support/npp_gate.cpp \
support/np_entry.cpp \
support/npn_gate.cpp \
- audio/sydney_audio_oss.c
+ audio/sydney_audio_oss.c \
+ plugin_cmml.c
#support/npunix.c
libnpoggplugin_dynamic_la_SOURCES = \
plugin.cpp \
@@ -59,7 +62,8 @@
support/npp_gate.cpp \
support/np_entry.cpp \
support/npn_gate.cpp \
- audio/sydney_audio_oss.c
+ audio/sydney_audio_oss.c \
+ plugin_cmml.c
libnpoggplugin_la_LIBADD = -lX11 -lXt $(OGGPLAY_LIBS) $(PTHREAD_LIBS)
Modified: liboggplay/trunk/plugin/nsILibOggPlugin.idl
===================================================================
--- liboggplay/trunk/plugin/nsILibOggPlugin.idl 2007-06-28 16:16:41 UTC (rev 3129)
+++ liboggplay/trunk/plugin/nsILibOggPlugin.idl 2007-06-29 00:18:28 UTC (rev 3130)
@@ -73,7 +73,7 @@
long getWindowHeight();
long getBufferedTime();
long getMovieLength();
- string retrieveAnnotations();
+ void retrieveAnnotations(in nsILibOggCallbackString callback);
void registerCMMLCallback(in nsILibOggCallbackString callback);
void registerEndPlayCallback(in nsILibOggCallbackNoArg callback);
@@ -90,7 +90,8 @@
void appendMovie(in string url);
boolean insertMovieBefore(in long position, in string url);
boolean removeMovieAt(in long position);
- string retrieveAnnotationsAt(in long position);
+ void retrieveAnnotationsAt(in long position,
+ in nsILibOggCallbackString callback);
long getMovieLengthAt(in long position);
void registerPlaylistCallback(in nsILibOggCallbackNoArg callback);
};
Modified: liboggplay/trunk/plugin/plugin.cpp
===================================================================
--- liboggplay/trunk/plugin/plugin.cpp 2007-06-28 16:16:41 UTC (rev 3129)
+++ liboggplay/trunk/plugin/plugin.cpp 2007-06-29 00:18:28 UTC (rev 3130)
@@ -68,6 +68,7 @@
#include "plugin_gui.h"
#include "plugin_oggplay.h"
#include "plugin_tools.h"
+#include "plugin_cmml.h"
}
@@ -233,7 +234,9 @@
mProxyPort(80),
mPlaylistPos(0),
mReachedEndOfMovie(FALSE),
+ mAsyncCmmlString(NULL),
mCmmlCallback(NULL),
+ mAsyncCmmlCallback(NULL),
mEndPlayCallback(NULL),
mPlaylistCallback(NULL)
#if defined(XP_MACOSX)
@@ -639,9 +642,9 @@
return get_oggplay_duration(mOggHandle);
}
-char *
-nsPluginInstance::retrieveAnnotations() {
- return retrieveAnnotationsAt(mPlaylistPos);
+void
+nsPluginInstance::retrieveAnnotations(nsILibOggCallbackString * callback) {
+ retrieveAnnotationsAt(mPlaylistPos, callback);
}
////////////////////////////////////////
@@ -759,17 +762,20 @@
return TRUE;
}
-char *
-nsPluginInstance::retrieveAnnotationsAt(long position) {
+void
+nsPluginInstance::retrieveAnnotationsAt(long position,
+ nsILibOggCallbackString * callback) {
if (!playlistIndexOk(position)) {
- return NULL;
+ return;
}
- //!todo
- char *annotations = (char *)NPN_MemAlloc(100);
- if (annotations != NULL) {
- sprintf(annotations, "annotations for %ld ftw", position);
- }
- return annotations;
+
+ if (mAsyncCmmlCallback != NULL)
+ return;
+
+ mAsyncCmmlCallback = callback;
+ NS_ADDREF(callback);
+
+ start_cmml_thread(this, mPlaylist[position], mProxyHost, mProxyPort);
}
long
@@ -845,23 +851,33 @@
//
// Linux doesn't have a problem with cross-thread calls, so we can execute
// processCrossThreadCalls directly from the callback notification functions.
+//
+// This function gets called both by the display thread (for in-line CMML
+// annotations) and by a seperate CMML fetching thread (for asynchronous
+// CMML annotations).
// -- Callback notification functions --
// These are executed in the display thread.
void
-nsPluginInstance::onCMMLData(char **cmml_data, int cmml_size) {
+nsPluginInstance::onCMMLData(char **cmml_data, int cmml_size, int async) {
SEM_WAIT(mCrossThreadSem);
- if (mCmmlCallback != NULL) {
- for (int i = 0; i < cmml_size; i++) {
- // We need to make copies of the strings because the oggplay frame in
- // which they're stored can be freed before processCrossThreadCalls
- // passes them to the browser.
- mCmmlStrings.push_back(strdup(cmml_data[i]));
+ if (async) {
+ assert (cmml_size == 1);
+ mAsyncCmmlString = cmml_data[0];
+ } else {
+
+ if (mCmmlCallback != NULL) {
+ for (int i = 0; i < cmml_size; i++) {
+ // We need to make copies of the strings because the oggplay frame in
+ // which they're stored can be freed before processCrossThreadCalls
+ // passes them to the browser.
+ mCmmlStrings.push_back(strdup(cmml_data[i]));
+ }
}
+ }
#if defined(XP_UX)
- processCrossThreadCalls(FALSE);
+ processCrossThreadCalls(FALSE);
#endif
- }
SEM_SIGNAL(mCrossThreadSem);
}
@@ -878,14 +894,16 @@
// C hooks for the callback notification functions
extern "C" {
void
-onCMMLData(nsPluginInstance *i, char **cmml_data, int cmml_size) {
- i->onCMMLData(cmml_data, cmml_size);
+onCMMLData(nsPluginInstance *i, char **cmml_data, int cmml_size, int async) {
+ i->onCMMLData(cmml_data, cmml_size, async);
}
void
onEndOfMovie(nsPluginInstance *i) {
i->onEndOfMovie();
}
+
+
} // extern "C"
@@ -908,6 +926,17 @@
clearCmmlStrings();
}
+ if (mAsyncCmmlString != NULL && mAsyncCmmlCallback != NULL) {
+ mAsyncCmmlCallback->Call(mAsyncCmmlString);
+ free(mAsyncCmmlString);
+ NS_RELEASE(mAsyncCmmlCallback);
+ mAsyncCmmlString = NULL;
+ mAsyncCmmlCallback = NULL;
+ } else if (mAsyncCmmlString != NULL) {
+ free(mAsyncCmmlString);
+ mAsyncCmmlString = NULL;
+ }
+
// End-of-movie handling.
if (mReachedEndOfMovie) {
mReachedEndOfMovie = FALSE;
Modified: liboggplay/trunk/plugin/plugin.h
===================================================================
--- liboggplay/trunk/plugin/plugin.h 2007-06-28 16:16:41 UTC (rev 3129)
+++ liboggplay/trunk/plugin/plugin.h 2007-06-29 00:18:28 UTC (rev 3130)
@@ -98,7 +98,7 @@
long getWindowHeight();
long getBufferedTime();
long getMovieLength();
- char * retrieveAnnotations();
+ void retrieveAnnotations(nsILibOggCallbackString *cbObj);
void freezePlaylistProgression();
void unfreezePlaylistProgression();
@@ -112,13 +112,14 @@
void appendMovie(const char *url);
bool insertMovieBefore(long position, const char *url);
bool removeMovieAt(long position);
- char * retrieveAnnotationsAt(long position);
+ void retrieveAnnotationsAt(long position,
+ nsILibOggCallbackString *cbObj);
long getMovieLengthAt(long position);
void registerCMMLCallback(nsILibOggCallbackString *cbObj);
void registerEndPlayCallback(nsILibOggCallbackNoArg *cbObj);
void registerPlaylistCallback(nsILibOggCallbackNoArg *cbObj);
- void onCMMLData(char **cmml_data, int cmml_size);
+ void onCMMLData(char **cmml_data, int cmml_size, int async);
void onEndOfMovie();
// This is only public so the Windows "heartbeat" function can
@@ -144,7 +145,9 @@
int mPlaylistPos;
NPBool mReachedEndOfMovie;
std::vector<char*> mCmmlStrings;
+ char * mAsyncCmmlString;
nsILibOggCallbackString * mCmmlCallback;
+ nsILibOggCallbackString * mAsyncCmmlCallback;
nsILibOggCallbackNoArg * mEndPlayCallback;
nsILibOggCallbackNoArg * mPlaylistCallback;
semaphore mCrossThreadSem;
Modified: liboggplay/trunk/plugin/plugin_c.h
===================================================================
--- liboggplay/trunk/plugin/plugin_c.h 2007-06-28 16:16:41 UTC (rev 3129)
+++ liboggplay/trunk/plugin/plugin_c.h 2007-06-29 00:18:28 UTC (rev 3130)
@@ -2,7 +2,7 @@
typedef struct nsPluginInstance nsPluginInstance;
void
-onCMMLData(nsPluginInstance *i, char **cmml_data, int cmml_size);
+onCMMLData(nsPluginInstance *i, char **cmml_data, int cmml_size, int async);
void
onEndOfMovie(nsPluginInstance *i);
Modified: liboggplay/trunk/plugin/plugin_gui_linux.c
===================================================================
--- liboggplay/trunk/plugin/plugin_gui_linux.c 2007-06-28 16:16:41 UTC (rev 3129)
+++ liboggplay/trunk/plugin/plugin_gui_linux.c 2007-06-29 00:18:28 UTC (rev 3130)
@@ -201,7 +201,7 @@
if (frame_data.cmml_strings != NULL) {
onCMMLData(info->pluginInstance, frame_data.cmml_strings,
- frame_data.cmml_size);
+ frame_data.cmml_size, 0);
}
calc_offset:
Modified: liboggplay/trunk/plugin/support/nsScriptablePeer.cpp
===================================================================
--- liboggplay/trunk/plugin/support/nsScriptablePeer.cpp 2007-06-28 16:16:41 UTC (rev 3129)
+++ liboggplay/trunk/plugin/support/nsScriptablePeer.cpp 2007-06-29 00:18:28 UTC (rev 3130)
@@ -218,10 +218,11 @@
return NS_OK;
}
-NS_IMETHODIMP nsScriptablePeer::RetrieveAnnotations(char **xmlData) {
- *xmlData = NULL;
+NS_IMETHODIMP nsScriptablePeer::RetrieveAnnotations
+ (nsILibOggCallbackString *callback)
+{
if (mPlugin)
- *xmlData = mPlugin->retrieveAnnotations();
+ mPlugin->retrieveAnnotations(callback);
return NS_OK;
}
@@ -318,10 +319,10 @@
return NS_OK;
}
-NS_IMETHODIMP nsScriptablePeer::RetrieveAnnotationsAt(PRInt32 position, char **_retval) {
- *_retval = NULL;
+NS_IMETHODIMP nsScriptablePeer::RetrieveAnnotationsAt(PRInt32 position,
+ nsILibOggCallbackString * callback) {
if (mPlugin)
- *_retval = mPlugin->retrieveAnnotationsAt(position);
+ mPlugin->retrieveAnnotationsAt(position, callback);
return NS_OK;
}
Modified: liboggplay/trunk/plugin/test/test.html
===================================================================
--- liboggplay/trunk/plugin/test/test.html 2007-06-28 16:16:41 UTC (rev 3129)
+++ liboggplay/trunk/plugin/test/test.html 2007-06-29 00:18:28 UTC (rev 3130)
@@ -219,7 +219,10 @@
}
function RetrieveAnnotations() {
- setOutput("-- Annotations --\n" + plugin.retrieveAnnotations());
+ plugin.retrieveAnnotations(
+ {
+ call: function(s) { setOutput("-- Annotations -- \n" + s); }
+ });
}
function FreezePlaylistProgression() {
@@ -299,7 +302,11 @@
function RetrieveAnnotationsAt() {
i = getInput();
- setOutput("-- Annotations at " + i + " --\n" + plugin.retrieveAnnotationsAt(i));
+ plugin.retrieveAnnotationsAt(i,
+ {
+ call: function(s) {
+ setOutput("-- Annotations at -- \n" + s); }
+ });
}
function GetMovieLengthAt() {
More information about the commits
mailing list