]> git.sesse.net Git - vlc/blobdiff - projects/mozilla/vlcplugin.h
Contribs: update libdvbpsi to 0.1.7
[vlc] / projects / mozilla / vlcplugin.h
index 4ace15b084326569683d5e4f18ed78463ccf33d0..5e6332d65f8e460560c29ee422b0e0ac7c63bc00 100644 (file)
 #define __VLCPLUGIN_H__
 
 #include <vlc/vlc.h>
-#include <pthread.h>
-#include <npapi.h>
-#include <vector>
 
-#include "control/nporuntime.h"
+// Setup XP_MACOSX, XP_UNIX, XP_WIN
+#if defined(_WIN32)
+#define XP_WIN 1
+#elif defined(__APPLE__)
+#define XP_MACOSX 1
+#else
+#define XP_UNIX 1
+#define MOZ_X11 1
+#endif
 
 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
 #define XP_UNIX 1
@@ -44,6 +49,8 @@
 
 #ifdef XP_WIN
     /* Windows stuff */
+#   include <windows.h>
+#   include <winbase.h>
 #endif
 
 #ifdef XP_MACOSX
@@ -52,6 +59,7 @@
 #endif
 
 #ifdef XP_UNIX
+#   include <pthread.h>
     /* X11 stuff */
 #   include <X11/Xlib.h>
 #   include <X11/Intrinsic.h>
 #   define __MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
 #endif
 
+#include <npapi.h>
+#include <vector>
+
+#include "control/nporuntime.h"
+
+
+typedef struct {
+#if defined(XP_UNIX)
+    pthread_mutex_t mutex;
+#elif defined(XP_WIN)
+    CRITICAL_SECTION cs;
+#else
+#warning "locking not implemented in this platform"
+#endif
+} plugin_lock_t;
+
+
 typedef enum vlc_toolbar_clicked_e {
     clicked_Unknown = 0,
     clicked_Play,
@@ -107,7 +132,7 @@ public:
     }
 };
 
-typedef bitmap<libvlc_num_event_types> eventtypes_bitmap_t;
+typedef bitmap<libvlc_VlmMediaInstanceStatusError+1> eventtypes_bitmap_t;
 
 
 class EventObj: private eventtypes_bitmap_t
@@ -135,8 +160,8 @@ private:
     void *_ud;
 public:
     EventObj(): _em(NULL)  { /* deferred to init() */ }
-    bool init() { return pthread_mutex_init(&mutex, NULL) == 0; }
-    ~EventObj() { pthread_mutex_destroy(&mutex); }
+    bool init();
+    ~EventObj();
 
     void deliver(NPP browser);
     void callback(const libvlc_event_t*);
@@ -151,7 +176,7 @@ private:
     lr_l _llist;
     ev_l _elist;
 
-    pthread_mutex_t mutex;
+    plugin_lock_t lock;
 
     bool ask_for_event(event_t e);
     void unask_for_event(event_t e);
@@ -161,17 +186,20 @@ private:
 class VlcPlugin
 {
 public:
+#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
              VlcPlugin( NPP, uint16 );
+#else
+             VlcPlugin( NPP, uint16_t );
+#endif
     virtual ~VlcPlugin();
 
     NPError             init(int argc, char* const argn[], char* const argv[]);
     libvlc_instance_t*  getVLC()
                             { return libvlc_instance; };
-    libvlc_media_player_t* getMD(libvlc_exception_t *ex)
+    libvlc_media_player_t* getMD()
     {
         if( !libvlc_media_player )
         {
-             libvlc_exception_raise(ex);
              libvlc_printerr("no mediaplayer");
         }
         return libvlc_media_player;
@@ -215,7 +243,11 @@ public:
     vlc_toolbar_clicked_t getToolbarButtonClicked( int i_xpos, int i_ypos );
 #endif
 
+#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
     uint16    i_npmode; /* either NP_EMBED or NP_FULL */
+#else
+    uint16_t  i_npmode; /* either NP_EMBED or NP_FULL */
+#endif
 
     /* plugin properties */
     int      b_stream;
@@ -224,14 +256,16 @@ public:
     char *   psz_text;
     char *   psz_target;
 
-    void playlist_play(libvlc_exception_t *ex)
+    void playlist_play()
     {
-        if( libvlc_media_player||playlist_select(0,ex) )
+        if( playlist_isplaying() )
+            playlist_stop();
+        if( libvlc_media_player||playlist_select(0) )
             libvlc_media_player_play(libvlc_media_player);
     }
-    void playlist_play_item(int idx,libvlc_exception_t *ex)
+    void playlist_play_item(int idx)
     {
-        if( playlist_select(idx,ex) )
+        if( playlist_select(idx) )
             libvlc_media_player_play(libvlc_media_player);
     }
     void playlist_stop()
@@ -239,14 +273,14 @@ public:
         if( libvlc_media_player )
             libvlc_media_player_stop(libvlc_media_player);
     }
-    void playlist_next(libvlc_exception_t *ex)
+    void playlist_next()
     {
-        if( playlist_select(playlist_index+1,ex) )
+        if( playlist_select(playlist_index+1) )
             libvlc_media_player_play(libvlc_media_player);
     }
-    void playlist_prev(libvlc_exception_t *ex)
+    void playlist_prev()
     {
-        if( playlist_select(playlist_index-1,ex) )
+        if( playlist_select(playlist_index-1) )
             libvlc_media_player_play(libvlc_media_player);
     }
     void playlist_pause()
@@ -263,9 +297,9 @@ public:
         return is_playing;
     }
 
-    int playlist_add( const char *, libvlc_exception_t * );
+    int playlist_add( const char * );
     int playlist_add_extended_untrusted( const char *, const char *, int,
-                                const char **, libvlc_exception_t * );
+                                const char ** );
     int playlist_delete_item( int );
     void playlist_clear();
     int  playlist_count();
@@ -281,7 +315,7 @@ public:
 
     EventObj events;
 private:
-    bool playlist_select(int,libvlc_exception_t *);
+    bool playlist_select(int);
     void set_player_window();
 
     /* VLC reference */
@@ -324,9 +358,9 @@ private:
 /*******************************************************************************
  * Plugin properties.
  ******************************************************************************/
-#define PLUGIN_NAME         "VLC Multimedia Plug-in"
+#define PLUGIN_NAME         "VLC Web Plugin"
 #define PLUGIN_DESCRIPTION \
-    "Version %s, copyright 1996-2007 The VideoLAN Team" \
+    "Version %s, copyright 1996-2010 VideoLAN and Authors" \
     "<br><a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
 
 #define PLUGIN_MIMETYPES \
@@ -381,6 +415,12 @@ private:
     "video/x-matroska:mkv:Matroska video;" \
     "audio/x-matroska:mka:Matroska audio;" \
     /* XSPF */ \
-    "application/xspf+xml:xspf:Playlist xspf;"
+    "application/xspf+xml:xspf:Playlist xspf;" \
+    /* Webm */ \
+    "video/webm:webm:WebM video;" \
+    "audio/webm:webm:WebM audio;" \
+    /* Real Media */ \
+    "application/vnd.rn-realmedia:rm:Real Media File;" \
+    "audio/x-realaudio:ra:Real Media Audio;"
 
 #endif