[xiph-commits] r2872 - liboggplay/trunk/plugin
shans at svn.annodex.net
shans at svn.annodex.net
Thu Jun 7 21:54:03 PDT 2007
Author: shans
Date: 2007-06-07 21:54:01 -0700 (Thu, 07 Jun 2007)
New Revision: 2872
Modified:
liboggplay/trunk/plugin/plugin.cpp
liboggplay/trunk/plugin/plugin.h
liboggplay/trunk/plugin/plugin_gui.h
liboggplay/trunk/plugin/plugin_gui_linux.c
liboggplay/trunk/plugin/plugin_tools.c
liboggplay/trunk/plugin/plugin_tools.h
Log:
Moved cmml callback functions into plugin_tools.c
Modified: liboggplay/trunk/plugin/plugin.cpp
===================================================================
--- liboggplay/trunk/plugin/plugin.cpp 2007-06-08 04:20:54 UTC (rev 2871)
+++ liboggplay/trunk/plugin/plugin.cpp 2007-06-08 04:54:01 UTC (rev 2872)
@@ -64,6 +64,7 @@
extern "C" {
#include "plugin_gui.h"
#include "plugin_oggplay.h"
+#include "plugin_tools.h"
}
// service manager which will give the access to all public browser services
@@ -343,7 +344,7 @@
nsPluginInstance::setCMMLCallback(const char * callback) {
char * callback_target = strdup(callback);
#if !defined(XP_MACOSX)
- set_gui_cmml_callback(mGuiHandle, callback_target, mInstance);
+ set_cmml_callback(mToolsHandle, callback_target);
#endif
}
@@ -423,9 +424,11 @@
// when to shut down the old handle after a new media source has been
// provided.
mOggHandle = initialise_oggplay(mSource);
- mGuiHandle = initialise_gui(aWindow, mOggHandle);
+ mToolsHandle = initialise_tools(mInstance);
+ mGuiHandle = initialise_gui(aWindow, mOggHandle, mToolsHandle);
mWindow = aWindow;
mWindowInitialised = TRUE;
+
}
return NPERR_NO_ERROR;
Modified: liboggplay/trunk/plugin/plugin.h
===================================================================
--- liboggplay/trunk/plugin/plugin.h 2007-06-08 04:20:54 UTC (rev 2871)
+++ liboggplay/trunk/plugin/plugin.h 2007-06-08 04:54:01 UTC (rev 2872)
@@ -101,6 +101,7 @@
nsScriptablePeer * mScriptablePeer;
void * mOggHandle;
void * mGuiHandle;
+ void * mToolsHandle;
char * mSource;
#if defined(XP_WIN)
Modified: liboggplay/trunk/plugin/plugin_gui.h
===================================================================
--- liboggplay/trunk/plugin/plugin_gui.h 2007-06-08 04:20:54 UTC (rev 2871)
+++ liboggplay/trunk/plugin/plugin_gui.h 2007-06-08 04:54:01 UTC (rev 2872)
@@ -43,7 +43,7 @@
#endif
void *
-initialise_gui(NPWindow *np_window, void *oggplay_handle);
+initialise_gui(NPWindow *np_window, void *oggplay_handle, void *tools_handle);
void
update_gui_with_new_display_size(void *gui_handle, NPWindow *np_window);
Modified: liboggplay/trunk/plugin/plugin_gui_linux.c
===================================================================
--- liboggplay/trunk/plugin/plugin_gui_linux.c 2007-06-08 04:20:54 UTC (rev 2871)
+++ liboggplay/trunk/plugin/plugin_gui_linux.c 2007-06-08 04:54:01 UTC (rev 2872)
@@ -47,7 +47,7 @@
#include <sys/time.h>
#include <time.h>
-#include <npapi.h>
+#include "plugin_tools.h"
#ifdef USE_AUDIO
#include "sydney_audio.h"
@@ -78,15 +78,9 @@
gboolean audio_opened;
gboolean tried_audio;
int64_t playback_target;
- char * cmml_callback;
- NPP plugin_instance;
+ void * tools_handle;
} PluginWindowInfo;
-/*
- * decalarations of private functions
- */
-void on_cmml_data(PluginWindowInfo * info, unsigned char ** cmml_data, int cmml_size);
-
/** returns current time in ms */
int64_t get_curr_time() {
int64_t _time;
@@ -177,7 +171,8 @@
}
if (frame_data.cmml_strings != NULL) {
- on_cmml_data(info, frame_data.cmml_strings, frame_data.cmml_size);
+ on_cmml_data(info->tools_handle, frame_data.cmml_strings,
+ frame_data.cmml_size);
}
calc_offset:
@@ -308,7 +303,7 @@
}
void *
-initialise_gui(NPWindow * aWindow, void * ogg_handle)
+initialise_gui(NPWindow * aWindow, void * ogg_handle, void * tools_handle)
{
GtkWidget * plug;
@@ -321,6 +316,7 @@
info->width = aWindow->width;
info->height = aWindow->height;
info->ogg_handle = ogg_handle;
+ info->tools_handle = tools_handle;
info->shutdown_gui = 0;
info->window = (GtkWidget*)plug;
info->new_oggplay_handle = NULL;
@@ -406,23 +402,6 @@
return state;
}
-void set_gui_cmml_callback(void *handle, char * callback, NPP mInstance) {
- PluginWindowInfo * info = (PluginWindowInfo *)handle;
- info->cmml_callback = callback;
- info->plugin_instance = mInstance;
- NPN_GetURL(info->plugin_instance, "javascript:alert(\"CMML callback registered\");", NULL);
-}
-
-void on_cmml_data(PluginWindowInfo * info, unsigned char ** cmml_data, int cmml_size) {
- int i;
- if ((info->cmml_callback == NULL) || (info->plugin_instance == NULL)) {
- return;
- }
- for (i = 0; i < cmml_size; i++) {
- printf("CMML annotations: %s\n", cmml_data[i]);
- }
-}
-
void
shut_gui(void *handle) {
Modified: liboggplay/trunk/plugin/plugin_tools.c
===================================================================
--- liboggplay/trunk/plugin/plugin_tools.c 2007-06-08 04:20:54 UTC (rev 2871)
+++ liboggplay/trunk/plugin/plugin_tools.c 2007-06-08 04:54:01 UTC (rev 2872)
@@ -41,6 +41,21 @@
#include <stdlib.h>
#include <math.h>
+typedef struct {
+ char * cmml_callback;
+ NPP plugin_instance;
+} PluginToolsInfo;
+
+void *
+initialise_tools(NPP plugin_instance) {
+
+ PluginToolsInfo *info = malloc(sizeof (PluginToolsInfo));
+ info->plugin_instance = plugin_instance;
+ info->cmml_callback = NULL;
+
+ return info;
+}
+
void
buffer_audio_data(unsigned char ** buffer, int* buffer_length,
unsigned char * data, int samples, int sample_size, int channels) {
@@ -68,3 +83,28 @@
}
}
}
+
+void
+set_cmml_callback(void * handle, char * callback) {
+ PluginToolsInfo * info = (PluginToolsInfo *)handle;
+
+ info->cmml_callback = callback;
+
+ NPN_GetURL(info->plugin_instance,
+ "javascript:alert(\"CMML callback registered\");", NULL);
+}
+
+void
+on_cmml_data(void * handle, unsigned char ** cmml_data, int cmml_size) {
+ int i;
+
+ PluginToolsInfo * info = (PluginToolsInfo *)handle;
+
+ if ((info->cmml_callback == NULL) || (info->plugin_instance == NULL)) {
+ return;
+ }
+
+ for (i = 0; i < cmml_size; i++) {
+ printf("CMML annotations: %s\n", cmml_data[i]);
+ }
+}
Modified: liboggplay/trunk/plugin/plugin_tools.h
===================================================================
--- liboggplay/trunk/plugin/plugin_tools.h 2007-06-08 04:20:54 UTC (rev 2871)
+++ liboggplay/trunk/plugin/plugin_tools.h 2007-06-08 04:54:01 UTC (rev 2872)
@@ -35,11 +35,22 @@
#ifndef _PLUGIN_TOOLS_H
#define _PLUGIN_TOOLS_H
+#include <npapi.h>
+
+void *
+initialise_tools(NPP plugin_instance);
+
void
buffer_audio_data(unsigned char ** buffer, int* buffer_length,
unsigned char * data, int samples, int sample_size, int channels);
void
float_to_short_array(const float* in, short* out, int len);
-
+
+void
+set_cmml_callback(void * handle, char * callback);
+
+void
+on_cmml_data(void * handle, unsigned char ** cmml_data, int cmml_size);
+
#endif
More information about the commits
mailing list