Changeset a593fa18ef93069b6152cc571561c5ccc053e67b
- Timestamp:
- 27/08/06 18:18:59 (2 years ago)
- git-parent:
- Files:
-
- include/video_output.h (modified) (1 diff)
- include/vlc/libvlc.h (modified) (3 diffs)
- modules/gui/macosx/voutgl.m (modified) (8 diffs)
- mozilla/Makefile.am (modified) (4 diffs)
- mozilla/control/npolibvlc.cpp (added)
- mozilla/control/npolibvlc.h (added)
- mozilla/control/nporuntime.cpp (added)
- mozilla/control/nporuntime.h (added)
- mozilla/control/npovlc.cpp (added)
- mozilla/control/npovlc.h (added)
- mozilla/vlcintf.idl (deleted)
- mozilla/vlcpeer.cpp (deleted)
- mozilla/vlcpeer.h (deleted)
- mozilla/vlcplugin.cpp (modified) (1 diff)
- mozilla/vlcplugin.h (modified) (5 diffs)
- mozilla/vlcruntime.cpp (deleted)
- mozilla/vlcruntime.h (deleted)
- mozilla/vlcshell.cpp (modified) (23 diffs)
- src/control/video.c (modified) (1 diff)
- src/libvlc.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/video_output.h
r6b7fbfe ra593fa1 276 276 VOUT_SNAPSHOT, 277 277 VOUT_CLOSE, 278 VOUT_SET_FOCUS /* arg1= vlc_bool_t res= */ 278 VOUT_SET_FOCUS, /* arg1= vlc_bool_t res= */ 279 VOUT_SET_VIEWPORT /* arg1= view rect, arg2=clip rect, res= */ 279 280 }; 280 281 include/vlc/libvlc.h
r44de024 ra593fa1 357 357 358 358 /** 359 * Get current mute status359 * change the video output parent 360 360 * \param p_instance libvlc instance 361 361 * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32) … … 365 365 int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception_t * ); 366 366 367 /** 368 * Set the video output parent 369 * \param p_instance libvlc instance 370 * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32) 371 * \param p_exception an initialized exception 372 */ 373 void libvlc_video_set_parent( libvlc_instance_t *, libvlc_drawable_t, libvlc_exception_t * ); 374 375 /** 376 * Set the video output size 377 * \param p_instance libvlc instance 378 * \param width new width for video drawable 379 * \param height new height for video drawable 380 * \param p_exception an initialized exception 381 */ 382 void libvlc_video_set_size( libvlc_instance_t *, int, int, libvlc_exception_t * ); 383 384 /** 385 * Downcast to this general type as placeholder for a platform specific one, such as: 386 * Drawable on X11, 387 * CGrafPort on MacOSX, 388 * HWND on win32 389 */ 390 typedef struct 391 { 392 int top, left; 393 int bottom, right; 394 } 395 libvlc_rectangle_t; 396 397 /** 398 * Set the video output viewport for a windowless video ouput (MacOS X only) 399 * \param p_instance libvlc instance 400 * \param view coordinates within video drawable 401 * \param clip coordinates within video drawable 402 * \param p_exception an initialized exception 403 */ 404 void libvlc_video_set_viewport( libvlc_instance_t *, const libvlc_rectangle_t *, const libvlc_rectangle_t *, libvlc_exception_t * ); 405 367 406 368 407 /** @} */ … … 380 419 * @{ 381 420 */ 421 422 /** 423 * Toggle mute status 424 * \param p_instance libvlc instance 425 * \param p_exception an initialized exception 426 * \return void 427 */ 428 void libvlc_audio_toggle_mute( libvlc_instance_t *, libvlc_exception_t * ); 382 429 383 430 /** modules/gui/macosx/voutgl.m
r7a6b8a5 ra593fa1 87 87 static void aglEnd ( vout_thread_t * p_vout ); 88 88 static int aglManage ( vout_thread_t * p_vout ); 89 static int aglControl( vout_thread_t *, int, va_list ); 89 90 static void aglSwap ( vout_thread_t * p_vout ); 90 91 static int DrawableRedraw( vlc_object_t *p_this, const char *psz_name,92 vlc_value_t oval, vlc_value_t nval, void *param);93 91 94 92 int E_(OpenVideoGL) ( vlc_object_t * p_this ) … … 132 130 AGL_NONE }; 133 131 134 AGLDevice screen;135 132 AGLPixelFormat pixFormat; 136 133 137 134 p_vout->p_sys->b_embedded = VLC_TRUE; 138 135 139 screen = GetGWorldDevice((CGrafPtr)value_drawable.i_int); 140 if( NULL == screen ) 141 { 142 msg_Err( p_vout, "can't find screen device for drawable" ); 143 return VLC_EGENERIC; 144 } 145 146 pixFormat = aglChoosePixelFormat(&screen, 1, ATTRIBUTES); 136 pixFormat = aglChoosePixelFormat(NULL, 0, ATTRIBUTES); 147 137 if( NULL == pixFormat ) 148 138 { … … 159 149 } 160 150 else { 161 // tell opengl to sync buffer swap with vertical retrace162 GLint param = 1;151 // tell opengl not to sync buffer swap with vertical retrace 152 GLint param = 0; 163 153 aglSetInteger(p_vout->p_sys->agl_ctx, AGL_SWAP_INTERVAL, ¶m); 164 154 aglEnable(p_vout->p_sys->agl_ctx, AGL_SWAP_INTERVAL); … … 168 158 p_vout->pf_end = aglEnd; 169 159 p_vout->pf_manage = aglManage; 170 p_vout->pf_control = NULL;160 p_vout->pf_control = aglControl; 171 161 p_vout->pf_swap = aglSwap; 172 162 p_vout->pf_lock = Lock; … … 208 198 if( p_vout->p_sys->b_embedded ) 209 199 { 210 var_DelCallback(p_vout->p_vlc, "drawableredraw", DrawableRedraw, p_vout);211 200 aglDestroyContext(p_vout->p_sys->agl_ctx); 212 201 } … … 457 446 *****************************************************************************/ 458 447 459 static void UpdateEmbeddedGeometry( vout_thread_t *p_vout);448 static void aglSetViewport( vout_thread_t *p_vout, Rect viewBounds, Rect clipBounds ); 460 449 static void aglReshape( vout_thread_t * p_vout ); 461 450 462 451 static int aglInit( vout_thread_t * p_vout ) 463 452 { 464 UpdateEmbeddedGeometry(p_vout); 465 var_AddCallback(p_vout->p_vlc, "drawableredraw", DrawableRedraw, p_vout); 453 vlc_value_t val; 454 455 Rect viewBounds; 456 Rect clipBounds; 457 458 var_Get( p_vout->p_vlc, "drawable", &val ); 459 p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int; 460 aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable); 461 462 var_Get( p_vout->p_vlc, "drawable-view-top", &val ); 463 viewBounds.top = val.i_int; 464 var_Get( p_vout->p_vlc, "drawable-view-left", &val ); 465 viewBounds.left = val.i_int; 466 var_Get( p_vout->p_vlc, "drawable-view-bottom", &val ); 467 viewBounds.bottom = val.i_int; 468 var_Get( p_vout->p_vlc, "drawable-view-right", &val ); 469 viewBounds.right = val.i_int; 470 var_Get( p_vout->p_vlc, "drawable-clip-top", &val ); 471 clipBounds.top = val.i_int; 472 var_Get( p_vout->p_vlc, "drawable-clip-left", &val ); 473 clipBounds.left = val.i_int; 474 var_Get( p_vout->p_vlc, "drawable-clip-bottom", &val ); 475 clipBounds.bottom = val.i_int; 476 var_Get( p_vout->p_vlc, "drawable-clip-right", &val ); 477 clipBounds.right = val.i_int; 478 479 aglSetViewport(p_vout, viewBounds, clipBounds); 466 480 467 481 aglSetCurrentContext(p_vout->p_sys->agl_ctx); … … 548 562 } 549 563 564 static int aglControl( vout_thread_t *p_vout, int i_query, va_list args ) 565 { 566 switch( i_query ) 567 { 568 case VOUT_SET_VIEWPORT: 569 { 570 Rect viewBounds, clipBounds; 571 viewBounds.top = va_arg( args, int); 572 viewBounds.left = va_arg( args, int); 573 viewBounds.bottom = va_arg( args, int); 574 viewBounds.right = va_arg( args, int); 575 clipBounds.top = va_arg( args, int); 576 clipBounds.left = va_arg( args, int); 577 clipBounds.bottom = va_arg( args, int); 578 clipBounds.right = va_arg( args, int); 579 aglSetViewport(p_vout, viewBounds, clipBounds); 580 return VLC_SUCCESS; 581 } 582 583 case VOUT_REPARENT: 584 { 585 AGLDrawable drawable = (AGLDrawable)va_arg( args, int); 586 if( drawable != p_vout->p_sys->agl_drawable ) 587 { 588 p_vout->p_sys->agl_drawable = drawable; 589 aglSetDrawable(p_vout->p_sys->agl_ctx, drawable); 590 } 591 return VLC_SUCCESS; 592 } 593 594 default: 595 return vout_vaControlDefault( p_vout, i_query, args ); 596 } 597 } 598 550 599 static void aglSwap( vout_thread_t * p_vout ) 551 600 { … … 554 603 } 555 604 556 static void UpdateEmbeddedGeometry( vout_thread_t *p_vout ) 557 { 558 vlc_value_t val; 559 vlc_value_t valt, vall, valb, valr, valx, valy, valw, valh, 560 valportx, valporty; 561 562 Rect winBounds; 563 Rect clientBounds; 564 565 GLint rect[4]; 566 567 var_Get( p_vout->p_vlc, "drawable", &val ); 568 var_Get( p_vout->p_vlc, "drawablet", &valt ); 569 var_Get( p_vout->p_vlc, "drawablel", &vall ); 570 var_Get( p_vout->p_vlc, "drawableb", &valb ); 571 var_Get( p_vout->p_vlc, "drawabler", &valr ); 572 var_Get( p_vout->p_vlc, "drawablex", &valx ); 573 var_Get( p_vout->p_vlc, "drawabley", &valy ); 574 var_Get( p_vout->p_vlc, "drawablew", &valw ); 575 var_Get( p_vout->p_vlc, "drawableh", &valh ); 576 var_Get( p_vout->p_vlc, "drawableportx", &valportx ); 577 var_Get( p_vout->p_vlc, "drawableporty", &valporty ); 578 605 static void aglSetViewport( vout_thread_t *p_vout, Rect viewBounds, Rect clipBounds ) 606 { 579 607 // mozilla plugin provides coordinates based on port bounds 580 608 // however AGL coordinates are based on window structure region 581 609 // and are vertically flipped 582 583 GetWindowBounds(GetWindowFromPort((CGrafPtr)val.i_int), 610 GLint rect[4]; 611 CGrafPtr port = (CGrafPtr)p_vout->p_sys->agl_drawable; 612 Rect winBounds, clientBounds; 613 614 GetWindowBounds(GetWindowFromPort(port), 584 615 kWindowStructureRgn, &winBounds); 585 GetWindowBounds(GetWindowFromPort( (CGrafPtr)val.i_int),616 GetWindowBounds(GetWindowFromPort(port), 586 617 kWindowContentRgn, &clientBounds); 587 618 588 619 /* update video clipping bounds in drawable */ 589 620 rect[0] = (clientBounds.left-winBounds.left) 590 + vall.i_int;// from window left edge621 + clipBounds.left; // from window left edge 591 622 rect[1] = (winBounds.bottom-winBounds.top) 592 623 - (clientBounds.top-winBounds.top) 593 - valb.i_int;// from window bottom edge594 rect[2] = valr.i_int-vall.i_int;// width595 rect[3] = valb.i_int-valt.i_int;// height624 - clipBounds.bottom; // from window bottom edge 625 rect[2] = clipBounds.right-clipBounds.left; // width 626 rect[3] = clipBounds.bottom-clipBounds.top; // height 596 627 aglSetInteger(p_vout->p_sys->agl_ctx, AGL_BUFFER_RECT, rect); 597 628 aglEnable(p_vout->p_sys->agl_ctx, AGL_BUFFER_RECT); 598 629 599 630 /* update video internal bounds in drawable */ 600 p_vout->p_sys->i_offx = -vall.i_int - valportx.i_int; 601 p_vout->p_sys->i_offy = valb.i_int + valporty.i_int - valh.i_int; 602 p_vout->p_sys->i_width = valw.i_int; 603 p_vout->p_sys->i_height = valh.i_int; 604 605 if( p_vout->p_sys->agl_drawable == (AGLDrawable)val.i_int ) 606 { 607 aglUpdateContext(p_vout->p_sys->agl_ctx); 608 } 609 else 610 { 611 p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int; 612 aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable); 613 } 631 p_vout->p_sys->i_width = viewBounds.right-viewBounds.left; 632 p_vout->p_sys->i_height = viewBounds.bottom-viewBounds.top; 633 p_vout->p_sys->i_offx = -clipBounds.left - viewBounds.left; 634 p_vout->p_sys->i_offy = clipBounds.bottom + viewBounds.top 635 - p_vout->p_sys->i_height; 636 637 aglUpdateContext(p_vout->p_sys->agl_ctx); 614 638 aglReshape( p_vout ); 615 639 } 616 640 617 /* If we're embedded, the application is expected to indicate a618 * window change (move/resize/etc) via the "drawableredraw" value.619 */620 621 static int DrawableRedraw( vlc_object_t *p_this, const char *psz_name,622 vlc_value_t oval, vlc_value_t nval, void *param)623 {624 vout_thread_t *p_vout = (vout_thread_t *)param;625 626 UpdateEmbeddedGeometry( p_vout );627 628 return VLC_SUCCESS;629 }630 mozilla/Makefile.am
r5b36930 ra593fa1 5 5 noinst_LIBRARIES = $(noinst_LIBRARIES_mozilla) 6 6 7 MOSTLYCLEANFILES = $(npvlc_DATA) $(vlcintf_xpt_DATA)7 MOSTLYCLEANFILES = $(npvlc_DATA) 8 8 CLEANFILES = stamp-pic $(BUILT_SOURCES) 9 EXTRA_DIST = $(DIST_sources) vlcintf.idlnpvlc_rc.rc vlc.r9 EXTRA_DIST = $(DIST_sources) npvlc_rc.rc vlc.r 10 10 11 11 SOURCES_mozilla_common = \ … … 13 13 vlcplugin.cpp \ 14 14 vlcplugin.h \ 15 vlcpeer.cpp \ 16 vlcpeer.h \ 17 vlcruntime.cpp \ 18 vlcruntime.h \ 15 control/npolibvlc.cpp \ 16 control/npolibvlc.h \ 17 control/npovlc.cpp \ 18 control/npovlc.h \ 19 control/nporuntime.cpp \ 20 control/nporuntime.h \ 19 21 support/classinfo.h 20 22 … … 142 144 noinst_LIBRARIES_mozilla = libnpvlc.a 143 145 144 $(SOURCES_mozilla): vlcintf.h145 146 BUILT_SOURCES = vlcintf.h147 vlcintf_xpt_DATA = vlcintf.xpt148 149 146 if USE_LIBTOOL 150 147 # FIXME: name is incorrect on Win32 & Darwin … … 176 173 @if test -f "$@.exe"; then mv -f "$@.exe" "$@"; fi 177 174 178 vlcintf_xptdir = $(libdir)/mozilla/components179 vlcintf.xpt: vlcintf.idl180 $(XPIDL) $(XPIDL_INCL) \181 -m typelib -o vlcintf $(srcdir)/vlcintf.idl182 183 vlcintf.h: vlcintf.idl184 $(XPIDL) $(XPIDL_INCL) \185 -m header -o vlcintf $(srcdir)/vlcintf.idl186 187 175 ############################################################################### 188 176 # Stamp rules mozilla/vlcplugin.cpp
r20defc2 ra593fa1 27 27 #include "config.h" 28 28 29 #include <vlc/vlc.h>30 31 29 #ifdef HAVE_MOZILLA_CONFIG_H 32 30 # include <mozilla-config.h> 33 31 #endif 34 #include <nsISupports.h>35 #include <nsMemory.h>36 #include <npapi.h>37 38 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)39 #define XP_UNIX 140 #elif defined(XP_MACOSX)41 #undef XP_UNIX42 #endif43 32 44 33 #include "vlcplugin.h" 34 #include "control/npovlc.h" 35 #include "control/npolibvlc.h" 45 36 46 37 /***************************************************************************** 47 38 * VlcPlugin constructor and destructor 48 39 *****************************************************************************/ 49 VlcPlugin::VlcPlugin( NPP instance ) 50 { 51 p_instance = instance; 52 p_peer = NULL; 53 } 54 40 VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) : 41 i_npmode(mode), 42 b_stream(0), 43 b_autoplay(0), 44 psz_target(NULL), 45 libvlc_instance(NULL), 46 scriptClass(NULL), 47 p_browser(instance), 48 psz_baseURL(NULL) 49 #if XP_WIN 50 ,pf_wndproc(NULL) 51 #endif 52 #if XP_UNIX 53 ,i_width((unsigned)-1) 54 ,i_height((unsigned)-1) 55 #endif 56 { 57 memset(&npwindow, 0, sizeof(NPWindow)); 58 } 59 60 static int boolValue(const char *value) { 61 return ( !strcmp(value, "1") || 62 !strcasecmp(value, "true") || 63 !strcasecmp(value, "yes") ); 64 } 65 66 NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[]) 67 { 68 /* prepare VLC command line */ 69 char *ppsz_argv[32] = 70 { 71 "vlc", 72 "-vv", 73 "--no-stats", 74 "--intf", "dummy", 75 }; 76 int ppsz_argc = 5; 77 78 /* locate VLC module path */ 79 #ifdef XP_MACOSX 80 ppsz_argv[ppsz_argc++] = "--plugin-path"; 81 ppsz_argv[ppsz_argc++] = "/Library/Internet Plug-Ins/VLC Plugin.plugin/" 82 "Contents/MacOS/modules"; 83 #elif defined(XP_WIN) 84 HKEY h_key; 85 DWORD i_type, i_data = MAX_PATH + 1; 86 char p_data[MAX_PATH + 1]; 87 if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC", 88 0, KEY_READ, &h_key ) == ERROR_SUCCESS ) 89 { 90 if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type, 91 (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS ) 92 { 93 if( i_type == REG_SZ ) 94 { 95 strcat( p_data, "\\vlc" ); 96 ppsz_argv[0] = p_data; 97 } 98 } 99 RegCloseKey( h_key ); 100 } 101 ppsz_argv[ppsz_argc++] = "--no-one-instance"; 102 #if 1 103 ppsz_argv[0] = "F:\\Cygwin\\home\\Damien\\dev\\videolan\\vlc-trunk\\vlc"; 104 #endif 105 106 #endif /* XP_MACOSX */ 107 108 const char *version = NULL; 109 110 /* parse plugin arguments */ 111 for( int i = 0; i < argc ; i++ ) 112 { 113 fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]); 114 115 if( !strcmp( argn[i], "target" ) 116 || !strcmp( argn[i], "mrl") 117 || !strcmp( argn[i], "filename") 118 || !strcmp( argn[i], "src") ) 119 { 120 psz_target = argv[i]; 121 } 122 else if( !strcmp( argn[i], "autoplay") 123 || !strcmp( argn[i], "autostart") ) 124 { 125 b_autoplay = boolValue(argv[i]); 126 } 127 else if( !strcmp( argn[i], "fullscreen" ) ) 128 { 129 if( boolValue(argv[i]) ) 130 { 131 ppsz_argv[ppsz_argc++] = "--fullscreen"; 132 } 133 else 134 { 135 ppsz_argv[ppsz_argc++] = "--no-fullscreen"; 136 } 137 } 138 else if( !strcmp( argn[i], "mute" ) ) 139 { 140 if( boolValue(argv[i]) ) 141 { 142 ppsz_argv[ppsz_argc++] = "--volume"; 143 ppsz_argv[ppsz_argc++] = "0"; 144 } 145 } 146 else if( !strcmp( argn[i], "loop") 147 || !strcmp( argn[i], "autoloop") ) 148 { 149 if( boolValue(argv[i]) ) 150 { 151 ppsz_argv[ppsz_argc++] = "--loop"; 152 } 153 else { 154 ppsz_argv[ppsz_argc++] = "--no-loop"; 155 } 156 } 157 else if( !strcmp( argn[i], "version") ) 158 { 159 version = argv[i]; 160 } 161 } 162 163 libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, NULL); 164 if( ! libvlc_instance ) 165 { 166 return NPERR_GENERIC_ERROR; 167 } 168 169 /* 170 ** fetch plugin base URL, which is the URL of the page containing the plugin 171 ** this URL is used for making absolute URL from relative URL that may be 172 ** passed as an MRL argument 173 */ 174 NPObject *plugin; 175 176 if( NPERR_NO_ERROR == NPN_GetValue(p_browser, NPNVWindowNPObject, &plugin) ) 177 { 178 /* 179 ** is there a better way to get that info ? 180 */ 181 static const char docLocHref[] = "document.location.href"; 182 NPString script; 183 NPVariant result; 184 185 script.utf8characters = docLocHref; 186 script.utf8length = sizeof(docLocHref)-1; 187 188 if( NPN_Evaluate(p_browser, plugin, &script, &result) ) 189 { 190 if( NPVARIANT_IS_STRING(result) ) 191 { 192 NPString &location = NPVARIANT_TO_STRING(result); 193 194 psz_baseURL = new char[location.utf8length+1]; 195 if( psz_baseURL ) 196 { 197 strncpy(psz_baseURL, location.utf8characters, location.utf8length); 198 psz_baseURL[location.utf8length] = '\0'; 199 } 200 } 201 NPN_ReleaseVariantValue(&result); 202 } 203 NPN_ReleaseObject(plugin); 204 } 205 206 if( psz_target ) 207 { 208 // get absolute URL from src 209 psz_target = getAbsoluteURL(psz_target); 210 } 211 212 /* assign plugin script root class */ 213 if( (NULL != version) && (!strcmp(version, "VideoLAN.VLCPlugin.2")) ) 214 { 215 /* new APIs */ 216 scriptClass = new RuntimeNPClass<LibvlcRootNPObject>(); 217 } 218 else 219 { 220 /* legacy APIs */ 221 scriptClass = new RuntimeNPClass<VlcNPObject>(); 222 } 223 224 return NPERR_NO_ERROR; 225 } 226 227 #if 0 228 #ifdef XP_WIN 229 /* This is really ugly but there is a deadlock when stopping a stream 230 * (in VLC_CleanUp()) because the video output is a child of the drawable but 231 * is in a different thread. */ 232 static void HackStopVout( VlcPlugin* p_plugin ) 233 { 234 MSG msg; 235 HWND hwnd; 236 vlc_value_t value; 237 238 int i_vlc = libvlc_get_vlc_id(p_plugin->libvlc_instance); 239 VLC_VariableGet( i_vlc, "drawable", &value ); 240 241 hwnd = FindWindowEx( (HWND)value.i_int, 0, 0, 0 ); 242 if( !hwnd ) return; 243 244 PostMessage( hwnd, WM_CLOSE, 0, 0 ); 245 246 do 247 { 248 while( PeekMessage( &msg, (HWND)value.i_int, 0, 0, PM_REMOVE ) ) 249 { 250 TranslateMessage(&msg); 251 DispatchMessage(&msg); 252 } 253 if( FindWindowEx( (HWND)value.i_int, 0, 0, 0 ) ) Sleep( 10 ); 254 } 255 while( (hwnd = FindWindowEx( (HWND)value.i_int, 0, 0, 0 )) ); 256 } 257 #endif /* XP_WIN */ 258 #endif 55 259 56 260 VlcPlugin::~VlcPlugin() 57 261 { 58 if( p_peer ) 59 { 60 p_peer->Disable(); 61 p_peer->Release(); 62 } 63 } 64 262 delete psz_baseURL; 263 delete psz_target; 264 if( libvlc_instance ) 265 libvlc_destroy(libvlc_instance); 266 } 65 267 66 268 /***************************************************************************** 67 269 * VlcPlugin methods 68 270 *****************************************************************************/ 69 void VlcPlugin::SetInstance( NPP instance ) 70 { 71 p_instance = instance; 72 } 73 74 75 NPP VlcPlugin::GetInstance() 76 { 77 return p_instance; 78 } 79 80 81 VlcIntf* VlcPlugin::GetPeer() 82 { 83 if( !p_peer ) 84 { 85 p_peer = new VlcPeer( this ); 86 if( p_peer == NULL ) 87 { 88 return NULL; 89 } 90 91 NS_ADDREF( p_peer ); 92 } 93 94 NS_ADDREF( p_peer ); 95 return p_peer; 96 } 97 271 272 char *VlcPlugin::getAbsoluteURL(const char *url) 273 { 274 if( NULL != url ) 275 { 276 // check whether URL is already absolute 277 const char *end=strchr(url, ':'); 278 if( (NULL != end) && (end != url) ) 279 { 280 // validate protocol header 281 const char *start = url; 282 while( start != end ) { 283 char c = *start | 0x20; 284 if( (c < 'a') || (c > 'z') ) 285 // not valid protocol header, assume relative URL 286 break; 287 ++start; 288 } 289 /* we have a protocol header, therefore URL is absolute */ 290 return strdup(url); 291 } 292 293 if( psz_baseURL ) 294 { 295 size_t baseLen = strlen(psz_baseURL); 296 char *href = new char[baseLen+strlen(url)]; 297 if( href ) 298 { 299 /* prepend base URL */ 300 strcpy(href, psz_baseURL); 301 302 /* 303 ** relative url could be empty, 304 ** in which case return base URL 305 */ 306 if( '\0' == *url ) 307 return href; 308 309 /* 310 ** locate pathname part of base URL 311 */ 312 313 /* skip over protocol part */ 314 char *pathstart = strchr(href, ':'); 315 char *pathend; 316 if( '/' == *(++pathstart) ) 317 { 318 if( '/' == *(++pathstart) ) 319 { 320 ++pathstart; 321 } 322 } 323 /* skip over host part */ 324 pathstart = strchr(pathstart, '/'); 325 pathend = href+baseLen; 326 if( ! pathstart ) 327 { 328 // no path, add a / past end of url (over '\0') 329 pathstart = pathend; 330 *pathstart = '/'; 331 } 332 333 /* relative URL made of an absolute path ? */ 334 if( '/' == *url ) 335 { 336 /* replace path completely */ 337 strcpy(pathstart, url); 338 return href; 339 } 340 341 /* find last path component and replace it */ 342 while( '/' != *pathend) --pathend; 343 344 /* 345 ** if relative url path starts with one or more '../', 346 ** factor them out of href so that we return a 347 ** normalized URL 348 */ 349 while( pathend != pathstart ) 350 { 351 const char *p = url; 352 if( '.' != *p ) 353 break; 354 ++p; 355 if( '.' != *p ) 356 break; 357 ++p; 358 if( '/' != *p ) 359 break; 360 ++p; 361 url = p; 362 while( '/' != *pathend ) --pathend; 363 } 364 /* concatenate remaining base URL and relative URL */ 365 strcpy(pathend+1, url); 366 } 367 return href; 368 } 369 } 370 return NULL; 371 } 372 373 #if XP_UNIX 374 int VlcPlugin::setSize(unsigned width, unsigned height) 375 { 376 int diff = (width != i_width) || (height != i_height); 377 378 i_width = width; 379 i_height = height; 380 381 /* return size */ 382 return diff; 383 } 384 #endif 385 mozilla/vlcplugin.h
r20defc2 ra593fa1 2 2 * vlcplugin.h: a VLC plugin for Mozilla 3 3 ***************************************************************************** 4 * Copyright (C) 2002-200 5the VideoLAN team4 * Copyright (C) 2002-2006 the VideoLAN team 5 5 * $Id$ 6 6 * 7 7 * Authors: Samuel Hocevar <sam@zoy.org> 8 Damien Fouilleul <damienf@videolan.org> 8 9 * 9 10 * This program is free software; you can redistribute it and/or modify … … 28 29 #define __VLCPLUGIN_H__ 29 30 30 #include "vlcpeer.h" 31 #include <vlc/libvlc.h> 32 #include <npapi.h> 33 #include "control/nporuntime.h" 31 34 32 35 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN) … … 36 39 #endif 37 40 41 #if 0 38 42 #ifdef XP_WIN 39 43 /* Windows stuff */ … … 51 55 # include <X11/StringDefs.h> 52 56 #endif 57 #endif 53 58 54 59 class VlcPlugin 55 60 { 56 61 public: 57 VlcPlugin( NPP );62 VlcPlugin( NPP, uint16 ); 58 63 virtual ~VlcPlugin(); 59 64 60 void SetInstance( NPP ); 61 NPP GetInstance(); 62 VlcIntf* GetPeer(); 65 NPError init(int argc, char* const argn[], char* const argv[]); 66 libvlc_instance_t* getVLC() 67 { return libvlc_instance; }; 68 NPP getBrowser() 69 { return p_browser; }; 70 char* getAbsoluteURL(const char *url); 71 const NPWindow* getWindow() 72 { return &npwindow; }; 73 void setWindow(const NPWindow *window) 74 { npwindow = *window; }; 63 75 64 /* Window settings */ 65 NPWindow* p_npwin; 66 uint16 i_npmode; 67 uint32 i_width, i_height; 76 NPClass* getScriptClass() 77 { return scriptClass; }; 68 78 69 #ifdef XP_WIN 70 /* Windows data members */ 71 HWND p_hwnd; 72 WNDPROC pf_wndproc; 79 #if XP_WIN 80 WNDPROC getWindowProc() 81 { return pf_wndproc; }; 82 void setWindowProc(WNDPROC wndproc) 83 { pf_wndproc = wndproc; }; 73 84 #endif 74 85 75 #ifdef XP_UNIX 76 /* UNIX data members */ 77 Window window; 78 Display *p_display; 86 #if XP_UNIX 87 int setSize(unsigned width, unsigned height); 79 88 #endif 80 89 81 #ifdef XP_MACOSX 82 /* MACOS data members */ 83 NPWindow *window; 84 #endif 90 uint16 i_npmode; /* either NP_EMBED or NP_FULL */ 85 91 86 87 /* vlc data members */ 88 int i_vlc; 92 /* plugin properties */ 89 93 int b_stream; 90 94 int b_autoplay; … … 92 96 93 97 private: 94 NPP p_instance; 95 VlcPeer* p_peer; 98 /* VLC reference */ 99 libvlc_instance_t *libvlc_instance; 100 NPClass *scriptClass; 101 102 /* browser reference */ 103 NPP p_browser; 104 char* psz_baseURL; 105 106 /* display settings */ 107 NPWindow npwindow; 108 #if XP_WIN 109 WNDPROC pf_wndproc; 110 #endif 111 #if XP_UNIX 112 unsigned int i_width, i_height; 113 #endif 96 114 }; 97 115 mozilla/vlcshell.cpp
r31eaf45 ra593fa1 22 22 *****************************************************************************/ 23 23 24 /* XXX: disable VLC here */25 #define USE_LIBVLC 126 27 24 /***************************************************************************** 28 25 * Preamble … … 34 31 #include <stdlib.h> 35 32 36 /* vlc stuff */37 #ifdef USE_LIBVLC38 # include <vlc/vlc.h>39 #endif40 41 33 /* Mozilla stuff */ 42 34 #ifdef HAVE_MOZILLA_CONFIG_H 43 35 # include <mozilla-config.h> 44 36 #endif 45 #include <nsISupports.h>46 #include <nsMemory.h>47 #include <npapi.h>48 #include <npruntime.h>49 37 50 38 /* This is from mozilla java, do we really need it? */ … … 54 42 55 43 #include "vlcplugin.h" 56 #include "vlcruntime.h"57 58 #if USE_LIBVLC59 # define WINDOW_TEXT "(no picture)"60 #else61 # define WINDOW_TEXT "(no libvlc)"62 #endif63 44 64 45 /* Enable/disable debugging printf's for X11 resizing */ 65 46 #undef X11_RESIZE_DEBUG 47 48 #define WINDOW_TEXT "(no video)" 66 49 67 50 /***************************************************************************** … … 72 55 # define AOUT_PLUGINS "esd,arts,alsa,oss,dummy" 73 56 74 static unsigned int i_previous_height = 100000;75 static unsigned int i_previous_width = 100000;76 77 57 static void Redraw( Widget w, XtPointer closure, XEvent *event ); 78 58 static void Resize( Widget w, XtPointer closure, XEvent *event ); 59 79 60 #endif 80 61 … … 85 66 # define VOUT_PLUGINS "opengl,macosx,dummy" 86 67 # define AOUT_PLUGINS "auhal,macosx,dummy" 87 88 68 #endif 89 69 … … 95 75 # define AOUT_PLUGINS "directx,waveout,dummy" 96 76 97 #if defined(XP_WIN) && !USE_LIBVLC 98 LRESULT CALLBACK Manage( HWND, UINT, WPARAM, LPARAM ); 99 #endif 77 static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar ); 78 100 79 #endif 101 80 … … 111 90 { 112 91 113 static nsIID nsid = VLCINTF_IID;114 92 static char psz_desc[1000]; 115 93 94 /* plugin class variables */ 116 95 switch( variable ) 117 96 { … … 121 100 122 101 case NPPVpluginDescriptionString: 123 #if USE_LIBVLC 124 snprintf( psz_desc, 1000-1, PLUGIN_DESCRIPTION, VLC_Version() ); 125 #else /* USE_LIBVLC */ 126 snprintf( psz_desc, 1000-1, PLUGIN_DESCRIPTION, "(disabled)" ); 127 #endif /* USE_LIBVLC */ 128 psz_desc[1000-1] = 0; 102 snprintf( psz_desc, sizeof(psz_desc)-1, PLUGIN_DESCRIPTION, VLC_Version() ); 103 psz_desc[sizeof(psz_desc)-1] = 0; 129 104 *((char **)value) = psz_desc; 130 105 return NPERR_NO_ERROR; 131 106 132 107 default: 133 /* go on... */108 /* move on to instance variables ... */ 134 109 break; 135 110 } … … 140 115 } 141 116 142 VlcPlugin* p_plugin = (VlcPlugin*) instance->pdata; 117 /* plugin instance variables */ 118 119 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata); 120 if( NULL == p_plugin ) 121 { 122 // plugin has not been initialized yet ! 123 return NPERR_INVALID_INSTANCE_ERROR; 124 } 143 125 144 126 switch( variable ) 145 127 { 146 case NPPVpluginScriptableInstance: 147 *(nsISupports**)value = p_plugin->GetPeer(); 148 if( *(nsISupports**)value == NULL ) 128 case NPPVp
