vlcplugin.h
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:10k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * vlcplugin.h: a VLC plugin for Mozilla
  3.  *****************************************************************************
  4.  * Copyright (C) 2002-2009 the VideoLAN team
  5.  * $Id: 99058f42815eab792931ef32e63cfa227f836ac0 $
  6.  *
  7.  * Authors: Samuel Hocevar <sam@zoy.org>
  8.  *          Damien Fouilleul <damienf@videolan.org>
  9.  *          Jean-Paul Saman <jpsaman@videolan.org>
  10.  *
  11.  * This program is free software; you can redistribute it and/or modify
  12.  * it under the terms of the GNU General Public License as published by
  13.  * the Free Software Foundation; either version 2 of the License, or
  14.  * (at your option) any later version.
  15.  *
  16.  * This program is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  * GNU General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU General Public License
  22.  * along with this program; if not, write to the Free Software
  23.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  24.  *****************************************************************************/
  25. /*******************************************************************************
  26.  * Instance state information about the plugin.
  27.  ******************************************************************************/
  28. #ifndef __VLCPLUGIN_H__
  29. #define __VLCPLUGIN_H__
  30. #include <vlc/vlc.h>
  31. #include <npapi.h>
  32. #include "control/nporuntime.h"
  33. #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
  34. #define XP_UNIX 1
  35. #elif defined(XP_MACOSX)
  36. #undef XP_UNIX
  37. #endif
  38. #ifdef XP_WIN
  39.     /* Windows stuff */
  40. #endif
  41. #ifdef XP_MACOSX
  42.     /* Mac OS X stuff */
  43. #   include <Quickdraw.h>
  44. #endif
  45. #ifdef XP_UNIX
  46.     /* X11 stuff */
  47. #   include <X11/Xlib.h>
  48. #   include <X11/Intrinsic.h>
  49. #   include <X11/StringDefs.h>
  50. #   include <X11/X.h>
  51. #   ifndef __APPLE__
  52. #       include <X11/xpm.h>
  53. #   endif
  54. #endif
  55. #ifndef __MAX
  56. #   define __MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
  57. #endif
  58. #ifndef __MIN
  59. #   define __MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
  60. #endif
  61. typedef enum vlc_toolbar_clicked_e {
  62.     clicked_Unknown = 0,
  63.     clicked_Play,
  64.     clicked_Pause,
  65.     clicked_Stop,
  66.     clicked_timeline,
  67.     clicked_Time,
  68.     clicked_Fullscreen,
  69.     clicked_Mute,
  70.     clicked_Unmute
  71. } vlc_toolbar_clicked_t;
  72. class VlcPlugin
  73. {
  74. public:
  75.              VlcPlugin( NPP, uint16 );
  76.     virtual ~VlcPlugin();
  77.     NPError             init(int argc, char* const argn[], char* const argv[]);
  78.     libvlc_instance_t*  getVLC()
  79.                             { return libvlc_instance; };
  80.     libvlc_media_player_t* getMD(libvlc_exception_t *ex)
  81.     {
  82.         if( !libvlc_media_player )
  83.         {
  84.              libvlc_exception_raise(ex,"no mediaplayer");
  85.         }
  86.         return libvlc_media_player;
  87.     }
  88.     NPP                 getBrowser()
  89.                             { return p_browser; };
  90.     char*               getAbsoluteURL(const char *url);
  91.     NPWindow&           getWindow()
  92.                             { return npwindow; };
  93.     void                setWindow(const NPWindow &window)
  94.                             { npwindow = window; };
  95.     NPClass*            getScriptClass()
  96.                             { return p_scriptClass; };
  97. #if XP_WIN
  98.     WNDPROC             getWindowProc()
  99.                             { return pf_wndproc; };
  100.     void                setWindowProc(WNDPROC wndproc)
  101.                             { pf_wndproc = wndproc; };
  102. #endif
  103. #if XP_UNIX
  104.     int                 setSize(unsigned width, unsigned height);
  105.     Window              getVideoWindow()
  106.                             { return npvideo; };
  107.     void                setVideoWindow(Window window)
  108.                             { npvideo = window; };
  109.     Window              getControlWindow()
  110.                             { return npcontrol; };
  111.     void                setControlWindow(Window window)
  112.                             { npcontrol = window; };
  113.     void                showToolbar();
  114.     void                hideToolbar();
  115.     void                redrawToolbar();
  116.     void                getToolbarSize(unsigned int *width, unsigned int *height)
  117.                             { *width = i_tb_width; *height = i_tb_height; };
  118.     int                 setToolbarSize(unsigned int width, unsigned int height)
  119.                             { i_tb_width = width; i_tb_height = height; return 1; };
  120.     vlc_toolbar_clicked_t getToolbarButtonClicked( int i_xpos, int i_ypos );
  121. #endif
  122.     uint16    i_npmode; /* either NP_EMBED or NP_FULL */
  123.     /* plugin properties */
  124.     int      b_stream;
  125.     int      b_autoplay;
  126.     int      b_toolbar;
  127.     char *   psz_target;
  128.     void playlist_play(libvlc_exception_t *ex)
  129.     {
  130.         if( libvlc_media_player||playlist_select(0,ex) )
  131.             libvlc_media_player_play(libvlc_media_player,ex);
  132.     }
  133.     void playlist_play_item(int idx,libvlc_exception_t *ex)
  134.     {
  135.         if( playlist_select(idx,ex) )
  136.             libvlc_media_player_play(libvlc_media_player,ex);
  137.     }
  138.     void playlist_stop(libvlc_exception_t *ex)
  139.     {
  140.         if( libvlc_media_player )
  141.             libvlc_media_player_stop(libvlc_media_player,ex);
  142.     }
  143.     void playlist_next(libvlc_exception_t *ex)
  144.     {
  145.         if( playlist_select(playlist_index+1,ex) )
  146.             libvlc_media_player_play(libvlc_media_player,ex);
  147.     }
  148.     void playlist_prev(libvlc_exception_t *ex)
  149.     {
  150.         if( playlist_select(playlist_index-1,ex) )
  151.             libvlc_media_player_play(libvlc_media_player,ex);
  152.     }
  153.     void playlist_pause(libvlc_exception_t *ex)
  154.     {
  155.         if( libvlc_media_player )
  156.             libvlc_media_player_pause(libvlc_media_player,ex);
  157.     }
  158.     int playlist_isplaying(libvlc_exception_t *ex)
  159.     {
  160.         int is_playing = 0;
  161.         if( libvlc_media_player )
  162.             is_playing = libvlc_media_player_is_playing(
  163.                                 libvlc_media_player, ex );
  164.         return is_playing;
  165.     }
  166.     int playlist_add( const char *, libvlc_exception_t * );
  167.     int playlist_add_extended_untrusted( const char *, const char *, int,
  168.                                 const char **, libvlc_exception_t * );
  169.     void playlist_delete_item( int, libvlc_exception_t * );
  170.     void playlist_clear( libvlc_exception_t * );
  171.     int  playlist_count( libvlc_exception_t * );
  172.     void toggle_fullscreen( libvlc_exception_t * );
  173.     void set_fullscreen( int, libvlc_exception_t * );
  174.     int  get_fullscreen( libvlc_exception_t * );
  175.     bool  player_has_vout( libvlc_exception_t * );
  176. private:
  177.     bool playlist_select(int,libvlc_exception_t *);
  178.     void set_player_window( libvlc_exception_t * );
  179.     /* VLC reference */
  180.     int                 playlist_index;
  181.     libvlc_instance_t   *libvlc_instance;
  182.     libvlc_media_list_t *libvlc_media_list;
  183.     libvlc_media_player_t *libvlc_media_player;
  184.     NPClass             *p_scriptClass;
  185.     /* browser reference */
  186.     NPP     p_browser;
  187.     char*   psz_baseURL;
  188.     /* display settings */
  189.     NPWindow  npwindow;
  190. #if XP_WIN
  191.     WNDPROC   pf_wndproc;
  192. #endif
  193. #if XP_UNIX
  194.     unsigned int     i_width, i_height;
  195.     unsigned int     i_tb_width, i_tb_height;
  196.     Window           npvideo, npcontrol;
  197.     XImage *p_btnPlay;
  198.     XImage *p_btnPause;
  199.     XImage *p_btnStop;
  200.     XImage *p_timeline;
  201.     XImage *p_btnTime;
  202.     XImage *p_btnFullscreen;
  203.     XImage *p_btnMute;
  204.     XImage *p_btnUnmute;
  205.     int i_last_position;
  206. #endif
  207. };
  208. /*******************************************************************************
  209.  * Plugin properties.
  210.  ******************************************************************************/
  211. #define PLUGIN_NAME         "VLC Multimedia Plug-in"
  212. #define PLUGIN_DESCRIPTION 
  213.     "Version %s, copyright 1996-2007 The VideoLAN Team" 
  214.     "<br><a href="http://www.videolan.org/">http://www.videolan.org/</a>"
  215. #define PLUGIN_MIMETYPES 
  216.     /* MPEG-1 and MPEG-2 */ 
  217.     "audio/mpeg:mp2,mp3,mpga,mpega:MPEG audio;" 
  218.     "audio/x-mpeg:mp2,mp3,mpga,mpega:MPEG audio;" 
  219.     "video/mpeg:mpg,mpeg,mpe:MPEG video;" 
  220.     "video/x-mpeg:mpg,mpeg,mpe:MPEG video;" 
  221.     "video/mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" 
  222.     "video/x-mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" 
  223.     /* M3U */ 
  224.     "audio/x-mpegurl:m3u:MPEG audio;" 
  225.     /* MPEG-4 */ 
  226.     "video/mp4:mp4,mpg4:MPEG-4 video;" 
  227.     "audio/mp4:mp4,mpg4:MPEG-4 audio;" 
  228.     "audio/x-m4a:m4a:MPEG-4 audio;" 
  229.     "application/mpeg4-iod:mp4,mpg4:MPEG-4 video;" 
  230.     "application/mpeg4-muxcodetable:mp4,mpg4:MPEG-4 video;" 
  231.     /* AVI */ 
  232.     "video/x-msvideo:avi:AVI video;" 
  233.     /* QuickTime */ 
  234.     "video/quicktime:mov,qt:QuickTime video;" 
  235.     /* OGG */ 
  236.     "application/x-ogg:ogg:Ogg stream;" 
  237.     "application/ogg:ogg:Ogg stream;" 
  238.     /* VLC */ 
  239.     "application/x-vlc-plugin:vlc:VLC plug-in;" 
  240.     /* Windows Media */ 
  241.     "video/x-ms-asf-plugin:asf,asx:Windows Media Video;" 
  242.     "video/x-ms-asf:asf,asx:Windows Media Video;" 
  243.     "application/x-mplayer2::Windows Media;" 
  244.     "video/x-ms-wmv:wmv:Windows Media;" 
  245.     "video/x-ms-wvx:wvx:Windows Media Video;" 
  246.     "audio/x-ms-wma:wma:Windows Media Audio;" 
  247.     /* Google VLC */ 
  248.     "application/x-google-vlc-plugin::Google VLC plug-in;" 
  249.     /* WAV audio */ 
  250.     "audio/wav:wav:WAV audio;" 
  251.     "audio/x-wav:wav:WAV audio;" 
  252.     /* 3GPP */ 
  253.     "audio/3gpp:3gp,3gpp:3GPP audio;" 
  254.     "video/3gpp:3gp,3gpp:3GPP video;" 
  255.     /* 3GPP2 */ 
  256.     "audio/3gpp2:3g2,3gpp2:3GPP2 audio;" 
  257.     "video/3gpp2:3g2,3gpp2:3GPP2 video;" 
  258.     /* DIVX */ 
  259.     "video/divx:divx:DivX video;" 
  260.     /* FLV */ 
  261.     "video/flv:flv:FLV video;" 
  262.     "video/x-flv:flv:FLV video;" 
  263.     /* Matroska */ 
  264.     "video/x-matroska:mkv:Matroska video;" 
  265.     "audio/x-matroska:mka:Matroska audio;" 
  266.     /* XSPF */ 
  267.     "application/xspf+xml:xspf:Playlist xspf;"
  268. #endif