X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=projects%2Fmozilla%2Fvlcplugin.h;h=5e6332d65f8e460560c29ee422b0e0ac7c63bc00;hb=0b47b18cb742ffe0affa2baea50fcd52f36eb8e7;hp=645dfe82875cd9c67fbf52c47ead59a230cf4848;hpb=35979e860abf629200c6946d0d24b58a33b435f5;p=vlc diff --git a/projects/mozilla/vlcplugin.h b/projects/mozilla/vlcplugin.h index 645dfe8287..5e6332d65f 100644 --- a/projects/mozilla/vlcplugin.h +++ b/projects/mozilla/vlcplugin.h @@ -1,11 +1,12 @@ /***************************************************************************** * vlcplugin.h: a VLC plugin for Mozilla ***************************************************************************** - * Copyright (C) 2002-2006 the VideoLAN team + * Copyright (C) 2002-2009 the VideoLAN team * $Id$ * * Authors: Samuel Hocevar - Damien Fouilleul + * Damien Fouilleul + * Jean-Paul Saman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,9 +29,17 @@ #ifndef __VLCPLUGIN_H__ #define __VLCPLUGIN_H__ -#include -#include -#include "control/nporuntime.h" +#include + +// 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 @@ -40,6 +49,8 @@ #ifdef XP_WIN /* Windows stuff */ +# include +# include #endif #ifdef XP_MACOSX @@ -48,6 +59,7 @@ #endif #ifdef XP_UNIX +# include /* X11 stuff */ # include # include @@ -66,15 +78,132 @@ # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) #endif +#include +#include + +#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, + clicked_Pause, + clicked_Stop, + clicked_timeline, + clicked_Time, + clicked_Fullscreen, + clicked_Mute, + clicked_Unmute +} vlc_toolbar_clicked_t; + + +// Note that the accessor functions are unsafe, but this is handled in +// the next layer up. 64bit uints can be substituted to taste (shift=6). +template class bitmap +{ +private: + typedef uint32_t bitu_t; enum { shift=5 }; + enum { bmax=M, bpu=1<>shift]&(1<<(idx&mask)); } + void set(size_t idx) { bits[idx>>shift]|= 1<<(idx&mask); } + void reset(size_t idx) { bits[idx>>shift]&=~(1<<(idx&mask)); } + void toggle(size_t idx) { bits[idx>>shift]^= 1<<(idx&mask); } + size_t maxbit() const { return bmax; } + void clear() { memset(bits,0,sizeof(bits)); } + bitmap() { clear(); } + ~bitmap() { } + bool empty() const { // naive invert() will break this + for(size_t i=0;i eventtypes_bitmap_t; + + +class EventObj: private eventtypes_bitmap_t +{ +private: + typedef libvlc_event_type_t event_t; + bool have_event(event_t e) const { return e lr_l; + typedef std::vector ev_l; + lr_l _llist; + ev_l _elist; + + plugin_lock_t lock; + + bool ask_for_event(event_t e); + void unask_for_event(event_t e); +}; + + 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() + { + if( !libvlc_media_player ) + { + libvlc_printerr("no mediaplayer"); + } + return libvlc_media_player; + } NPP getBrowser() { return p_browser; }; char* getAbsoluteURL(const char *url); @@ -86,18 +215,14 @@ public: NPClass* getScriptClass() { return p_scriptClass; }; - void setLog(libvlc_log_t *log) - { libvlc_log = log; }; - libvlc_log_t* getLog() - { return libvlc_log; }; -#if XP_WIN +#if defined(XP_WIN) WNDPROC getWindowProc() { return pf_wndproc; }; void setWindowProc(WNDPROC wndproc) { pf_wndproc = wndproc; }; #endif -#if XP_UNIX +#if defined(XP_UNIX) int setSize(unsigned width, unsigned height); Window getVideoWindow() { return npvideo; }; @@ -111,23 +236,93 @@ public: void showToolbar(); void hideToolbar(); void redrawToolbar(); + void getToolbarSize(unsigned int *width, unsigned int *height) + { *width = i_tb_width; *height = i_tb_height; }; + int setToolbarSize(unsigned int width, unsigned int height) + { i_tb_width = width; i_tb_height = height; return 1; }; + 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; int b_autoplay; + int b_toolbar; + char * psz_text; char * psz_target; -#if XP_UNIX - /* toolbar */ - int i_control_height; -#endif + void playlist_play() + { + 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) + { + if( playlist_select(idx) ) + libvlc_media_player_play(libvlc_media_player); + } + void playlist_stop() + { + if( libvlc_media_player ) + libvlc_media_player_stop(libvlc_media_player); + } + void playlist_next() + { + if( playlist_select(playlist_index+1) ) + libvlc_media_player_play(libvlc_media_player); + } + void playlist_prev() + { + if( playlist_select(playlist_index-1) ) + libvlc_media_player_play(libvlc_media_player); + } + void playlist_pause() + { + if( libvlc_media_player ) + libvlc_media_player_pause(libvlc_media_player); + } + int playlist_isplaying() + { + int is_playing = 0; + if( libvlc_media_player ) + is_playing = libvlc_media_player_is_playing( + libvlc_media_player ); + return is_playing; + } + + int playlist_add( const char * ); + int playlist_add_extended_untrusted( const char *, const char *, int, + const char ** ); + int playlist_delete_item( int ); + void playlist_clear(); + int playlist_count(); + + void toggle_fullscreen(); + void set_fullscreen( int ); + int get_fullscreen(); + + bool player_has_vout(); + + + static bool canUseEventListener(); + + EventObj events; private: + bool playlist_select(int); + void set_player_window(); + /* VLC reference */ + int playlist_index; libvlc_instance_t *libvlc_instance; - libvlc_log_t *libvlc_log; + libvlc_media_list_t *libvlc_media_list; + libvlc_media_player_t *libvlc_media_player; NPClass *p_scriptClass; /* browser reference */ @@ -136,11 +331,12 @@ private: /* display settings */ NPWindow npwindow; -#if XP_WIN +#if defined(XP_WIN) WNDPROC pf_wndproc; #endif -#if XP_UNIX +#if defined(XP_UNIX) unsigned int i_width, i_height; + unsigned int i_tb_width, i_tb_height; Window npvideo, npcontrol; XImage *p_btnPlay; @@ -154,14 +350,17 @@ private: int i_last_position; #endif + + static void eventAsync(void *); + static void event_callback(const libvlc_event_t *, void *); }; /******************************************************************************* * 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" \ "
http://www.videolan.org/" #define PLUGIN_MIMETYPES \ @@ -172,9 +371,12 @@ private: "video/x-mpeg:mpg,mpeg,mpe:MPEG video;" \ "video/mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \ "video/x-mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \ + /* M3U */ \ + "audio/x-mpegurl:m3u:MPEG audio;" \ /* MPEG-4 */ \ - "video/mpeg4:mp4,mpg4:MPEG-4 video;" \ - "audio/mpeg4:mp4,mpg4:MPEG-4 audio;" \ + "video/mp4:mp4,mpg4:MPEG-4 video;" \ + "audio/mp4:mp4,mpg4:MPEG-4 audio;" \ + "audio/x-m4a:m4a:MPEG-4 audio;" \ "application/mpeg4-iod:mp4,mpg4:MPEG-4 video;" \ "application/mpeg4-muxcodetable:mp4,mpg4:MPEG-4 video;" \ /* AVI */ \ @@ -192,6 +394,7 @@ private: "application/x-mplayer2::Windows Media;" \ "video/x-ms-wmv:wmv:Windows Media;" \ "video/x-ms-wvx:wvx:Windows Media Video;" \ + "audio/x-ms-wma:wma:Windows Media Audio;" \ /* Google VLC */ \ "application/x-google-vlc-plugin::Google VLC plug-in;" \ /* WAV audio */ \ @@ -204,6 +407,20 @@ private: "audio/3gpp2:3g2,3gpp2:3GPP2 audio;" \ "video/3gpp2:3g2,3gpp2:3GPP2 video;" \ /* DIVX */ \ - "video/divx:divx:DivX video;" + "video/divx:divx:DivX video;" \ + /* FLV */ \ + "video/flv:flv:FLV video;" \ + "video/x-flv:flv:FLV video;" \ + /* Matroska */ \ + "video/x-matroska:mkv:Matroska video;" \ + "audio/x-matroska:mka:Matroska audio;" \ + /* 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