]> git.sesse.net Git - vlc/blobdiff - projects/mozilla/vlcshell.cpp
activex plugin: move deinterlace to own video subobject.
[vlc] / projects / mozilla / vlcshell.cpp
index d582cf6332e89a56ee38f2db66b6ede952fa6360..5681fbdec3a59486b3683d1586a2990cd43c7960 100644 (file)
 /* Enable/disable debugging printf's for X11 resizing */
 #undef X11_RESIZE_DEBUG
 
-#define WINDOW_TEXT "Waiting for video"
-
 /*****************************************************************************
  * Unix-only declarations
 ******************************************************************************/
-#ifdef XP_UNIX
+#if defined(XP_UNIX)
 
 static void Redraw( Widget w, XtPointer closure, XEvent *event );
 static void ControlHandler( Widget w, XtPointer closure, XEvent *event );
@@ -167,8 +165,7 @@ int16 NPP_HandleEvent( NPP instance, void * event )
         return false;
     }
 
-    VlcPlugin *p_plugin = (VlcPlugin*)instance->pdata;
-
+    VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
     if( p_plugin == NULL )
     {
         return false;
@@ -202,19 +199,23 @@ int16 NPP_HandleEvent( NPP instance, void * event )
             const NPWindow& npwindow = p_plugin->getWindow();
             if( npwindow.window )
             {
-                int hasVout = FALSE;
+                bool hasVout = false;
 
-                if( p_plugin->playlist_isplaying(&ex) )
+                if( p_plugin->playlist_isplaying() )
                 {
                     hasVout = p_plugin->player_has_vout(NULL);
                     if( hasVout )
                     {
+#ifdef NOT_WORKING
                         libvlc_rectangle_t area;
                         area.left = 0;
                         area.top = 0;
                         area.right = npwindow.width;
                         area.bottom = npwindow.height;
                         libvlc_video_redraw_rectangle(p_plugin->getMD(&ex), &area, NULL);
+#else
+#warning disabled code
+#endif
                     }
                 }
                 libvlc_exception_clear(&ex);
@@ -240,7 +241,8 @@ int16 NPP_HandleEvent( NPP instance, void * event )
 
                     ForeColor(whiteColor);
                     MoveTo( (npwindow.width-80)/ 2  , npwindow.height / 2 );
-                    DrawText( WINDOW_TEXT , 0 , strlen(WINDOW_TEXT) );
+                    if( p_plugin->psz_text )
+                        DrawText( p_plugin->psz_text, 0, strlen(p_plugin->psz_text) );
                 }
             }
             return true;
@@ -328,7 +330,7 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
 
     instance->pdata = NULL;
 
-#if XP_WIN
+#if defined(XP_WIN)
     HWND win = (HWND)p_plugin->getWindow().window;
     WNDPROC winproc = p_plugin->getWindowProc();
     if( winproc )
@@ -338,6 +340,9 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
     }
 #endif
 
+    if( p_plugin->playlist_isplaying() )
+        p_plugin->playlist_stop();
+
     delete p_plugin;
 
     return NPERR_NO_ERROR;
@@ -345,7 +350,7 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
 
 NPError NPP_SetWindow( NPP instance, NPWindow* window )
 {
-#if defined(XP_UNIX) && !defined(__APPLE__)
+#if defined(XP_UNIX)
     Window control;
     unsigned int i_control_height = 0, i_control_width = 0;
 #endif
@@ -363,7 +368,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
         return NPERR_NO_ERROR;
     }
 
-#if defined(XP_UNIX) && !defined(__APPLE__)
+#if defined(XP_UNIX)
     control = p_plugin->getControlWindow();
 #endif
 
@@ -388,14 +393,6 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
     {
         /* check if plugin has a new parent window */
         CGrafPtr drawable = (((NP_Port*) (window->window))->port);
-        if( !curwin.window || drawable != (((NP_Port*) (curwin.window))->port) )
-        {
-            /* set/change parent window */
-            libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, &ex);
-            if( libvlc_exception_raised(&ex) )
-                fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
-            libvlc_exception_clear(&ex);
-        }
 
         /* as MacOS X video output is windowless, set viewport */
         libvlc_rectangle_t view, clip;
@@ -415,24 +412,18 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
         clip.left    = window->clipRect.left;
         clip.bottom  = window->clipRect.bottom;
         clip.right   = window->clipRect.right;
-
+#ifdef NOT_WORKING
         libvlc_video_set_viewport(p_vlc, p_plugin->getMD(&ex), &view, &clip, &ex);
-        if( libvlc_exception_raised(&ex) )
-            fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
         libvlc_exception_clear(&ex);
-
+#else
+#warning disabled code
+#endif        
         /* remember new window */
         p_plugin->setWindow(*window);
     }
     else if( curwin.window )
     {
         /* change/set parent */
-        libvlc_video_set_parent(p_vlc, 0, &ex);
-
-        if( libvlc_exception_raised(&ex) )
-            fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
-        libvlc_exception_clear(&ex);
-
         curwin.window = NULL;
     }
 #endif /* XP_MACOSX */
@@ -465,12 +456,6 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
             style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
             SetWindowLong((HWND)drawable, GWL_STYLE, style);
 
-            /* change/set parent */
-            libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, &ex);
-            if( libvlc_exception_raised(&ex) )
-                fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
-            libvlc_exception_clear(&ex);
-
             /* remember new window */
             p_plugin->setWindow(*window);
 
@@ -486,17 +471,11 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
         SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) );
         p_plugin->setWindowProc(NULL);
 
-        /* change/set parent */
-        libvlc_video_set_parent(p_vlc, 0, &ex);
-        if( libvlc_exception_raised(&ex) )
-            fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
-        libvlc_exception_clear(&ex);
-
         curwin.window = NULL;
     }
 #endif /* XP_WIN */
 
-#ifdef XP_UNIX
+#if defined(XP_UNIX)
     /* default to hidden toolbar, shown at the end of this method if asked *
      * developers note : getToolbarSize need to wait the end of this method
      */
@@ -541,22 +520,6 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
             XtAddEventHandler( w, ButtonReleaseMask, FALSE,
                                (XtEventHandler)ControlHandler, p_plugin );
 
-            /* callback */
-/*
-            libvlc_media_player_t *p_md;
-
-            p_md = p_plugin->getMD( &ex );
-            libvlc_exception_clear( &ex );
-            libvlc_event_attach( libvlc_media_player_event_manager( p_md, &ex ),
-                                 libvlc_MediaPlayerPositionChanged, Redraw, NULL, &ex );
-*/
-
-            /* set/change parent window */
-            libvlc_video_set_parent( p_vlc, (libvlc_drawable_t) video, &ex );
-            if( libvlc_exception_raised(&ex) )
-                fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
-            libvlc_exception_clear(&ex);
-
             /* remember window */
             p_plugin->setWindow( *window );
             p_plugin->setVideoWindow( video );
@@ -577,11 +540,6 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
     }
     else if( curwin.window )
     {
-        /* change/set parent */
-        libvlc_video_set_parent(p_vlc, 0, &ex);
-        if( libvlc_exception_raised(&ex) )
-            fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
-        libvlc_exception_clear(&ex);
         curwin.window = NULL;
     }
 #endif /* XP_UNIX */
@@ -594,7 +552,8 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
             {
                 if( p_plugin->b_autoplay )
                 {
-                    p_plugin->playlist_play(NULL);
+                    p_plugin->playlist_play(&ex);
+                    libvlc_exception_clear(&ex);
                 }
             }
             p_plugin->b_stream = true;
@@ -757,7 +716,7 @@ void NPP_Print( NPP instance, NPPrint* printInfo )
 /******************************************************************************
  * Windows-only methods
  *****************************************************************************/
-#if XP_WIN
+#if defined(XP_WIN)
 static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
 {
     VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(GetWindowLongPtr(p_hwnd, GWLP_USERDATA));
@@ -780,8 +739,9 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
             FillRect( hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) );
             SetTextColor(hdc, RGB(255, 255, 255));
             SetBkColor(hdc, RGB(0, 0, 0));
-            DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect,
-                      DT_CENTER|DT_VCENTER|DT_SINGLELINE);
+            if( p_plugin->psz_text )
+                DrawText( hdc, p_plugin->psz_text, strlen(p_plugin->psz_text), &rect,
+                          DT_CENTER|DT_VCENTER|DT_SINGLELINE);
 
             EndPaint( p_hwnd, &paintstruct );
             return 0L;
@@ -797,7 +757,7 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
 /******************************************************************************
  * UNIX-only methods
  *****************************************************************************/
-#ifdef XP_UNIX
+#if defined(XP_UNIX)
 static void Redraw( Widget w, XtPointer closure, XEvent *event )
 {
     VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
@@ -824,9 +784,10 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event )
     gcv.foreground = WhitePixel( p_display, 0 );
     XChangeGC( p_display, gc, GCForeground, &gcv );
 
-    XDrawString( p_display, video, gc,
-                 window.width / 2 - 40, (window.height - i_control_height) / 2,
-                 WINDOW_TEXT, strlen(WINDOW_TEXT) );
+    if( p_plugin->psz_text )
+        XDrawString( p_display, video, gc,
+                     window.width / 2 - 40, (window.height - i_control_height) / 2,
+                     p_plugin->psz_text, strlen(p_plugin->psz_text) );
     XFreeGC( p_display, gc );
 
     p_plugin->redrawToolbar();
@@ -849,14 +810,9 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
 
         libvlc_exception_init( &ex );
         libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        if( libvlc_exception_raised(&ex) )
-            fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
         libvlc_exception_clear( &ex );
 
-        i_playing = p_plugin->playlist_isplaying( &ex );
-        if( libvlc_exception_raised(&ex) )
-            fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
-        libvlc_exception_clear( &ex );
+        i_playing = p_plugin->playlist_isplaying();
 
         vlc_toolbar_clicked_t clicked;
         clicked = p_plugin->getToolbarButtonClicked( i_xPos, i_yPos );
@@ -870,26 +826,19 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
                 else
                     p_plugin->playlist_play( &ex );
 
-                if( libvlc_exception_raised(&ex) )
-                    fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
                 libvlc_exception_clear( &ex );
             }
             break;
 
             case clicked_Stop:
             {
-                p_plugin->playlist_stop(&ex);
-                if( libvlc_exception_raised(&ex) )
-                    fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
-                libvlc_exception_clear( &ex );
+                p_plugin->playlist_stop();
             }
             break;
 
             case clicked_Fullscreen:
             {
                 p_plugin->set_fullscreen( 1, &ex );
-                if( libvlc_exception_raised(&ex) )
-                    fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
                 libvlc_exception_clear( &ex );
             }
             break;
@@ -897,10 +846,7 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
             case clicked_Mute:
             case clicked_Unmute:
             {
-                libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex );
-                if( libvlc_exception_raised(&ex) )
-                    fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
-                libvlc_exception_clear( &ex );
+                libvlc_audio_toggle_mute( p_plugin->getVLC() );
             }
             break;
 
@@ -917,8 +863,6 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
                             ( ((float)i_xPos-4.0 ) / ( ((float)i_width-8.0)/100) );
 
                     libvlc_media_player_set_time( p_md, f_length, &ex );
-                    if( libvlc_exception_raised(&ex) )
-                        fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
                     libvlc_exception_clear( &ex );
                 }
             }