]> git.sesse.net Git - mlt/commitdiff
Minor config fixes and gtk2 consumer added
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 24 Oct 2004 14:18:29 +0000 (14:18 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 24 Oct 2004 14:18:29 +0000 (14:18 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@488 d19143bc-622f-0410-bfdd-b5b2a6649095

13 files changed:
mlt-config-template
src/framework/configure
src/miracle/configure
src/modules/gtk2/Makefile
src/modules/gtk2/configure
src/modules/gtk2/consumer_gtk2.c [new file with mode: 0644]
src/modules/gtk2/consumer_gtk2.h [new file with mode: 0644]
src/modules/gtk2/factory.c
src/modules/sdl/consumer_sdl.c
src/modules/sdl/consumer_sdl_preview.c
src/modules/sdl/consumer_sdl_still.c
src/modules/westley/producer_westley.c
src/valerie/configure

index ec0db9f8265bc9afcfc897a9e8c58c3fc9c92618..5559bf73072a2890cdefdfdbdb69b44c9e0e748d 100644 (file)
@@ -6,6 +6,7 @@ do
        case $1 in
                --help )                field=0 ;;
                --version )             field=-1 ;;
+               --prefix )              field=-2 ;;
                --prefix=* )    prefix="${i#--prefix=}" ;;
                --cflags )              field=2 ;;
                --libs )                field=3 ;;
@@ -19,6 +20,11 @@ if [ "$field" = "0" ]
 then   echo "Usage: mlt-config [ --version ] | [ --prefix=dir ] [ [ package ] [ --cflags ] [ --libs ] ]"
 elif [ "$field" = "-1" ]
 then   echo $version
+elif [ "$field" = "-2" ]
+then   config=`which mlt-config`
+               dir=`dirname $config`
+               dir=`dirname $dir`
+               echo $dir
 elif [ -f "$prefix/share/mlt/packages.dat" ]
 then grep "^$package" $prefix/share/mlt/packages.dat | cut -f $field
 else echo mlt-config cannot find package $package.
index 3a765aadf3e4095f5c815455b7e6939a74f20fec..569f86bbf7c6f80a2309589e53d5efb41b382a1c 100755 (executable)
@@ -1,2 +1,2 @@
 #!/bin/sh
-echo "framework        -I$prefix/include/mlt -D_REENTRANT      -lmlt" >> ../../packages.dat
+echo "framework        -I$prefix/include/mlt -D_REENTRANT      -L$prefix/lib -lmlt" >> ../../packages.dat
index f845807ca44e343146e7bb076ba1714fb1ea7cc3..9c8f962f95e28d4a71d6a0ae28c78a361fe5d001 100755 (executable)
@@ -1,2 +1,2 @@
 #!/bin/sh
-echo "miracle  -I$prefix/include/mlt -D_REENTRANT      -lmiracle" >> ../../packages.dat
+echo "miracle  -I$prefix/include/mlt -D_REENTRANT      -L$prefix/lib -lmiracle" >> ../../packages.dat
index 32d3eda064cb2600b1f70d05d7fa1cb238ae8490..3edd938926c9d808cfdc60721e6790805aae9ba2 100644 (file)
@@ -3,6 +3,7 @@ include ../../../config.mak
 TARGET = ../libmltgtk2.so
 
 OBJS = factory.o \
+          consumer_gtk2.o \
           producer_pixbuf.o \
           producer_pango.o \
           pixops.o \
@@ -11,9 +12,9 @@ OBJS = factory.o \
 ASM_OBJS = have_mmx.o \
                   scale_line_22_yuv_mmx.o
 
-CFLAGS += `pkg-config gdk-pixbuf-2.0 --cflags` `pkg-config pangoft2 --cflags` -I../..
+CFLAGS += `pkg-config gtk+-2.0 --cflags` `pkg-config gdk-pixbuf-2.0 --cflags` `pkg-config pangoft2 --cflags` -I../..
 
-LDFLAGS += `pkg-config gdk-pixbuf-2.0 --libs` `pkg-config pangoft2 --libs`
+LDFLAGS += `pkg-config gtk+-2.0 --libs` `pkg-config gdk-pixbuf-2.0 --libs` `pkg-config pangoft2 --libs`
 
 LDFLAGS+=-L../../framework -lmlt
 
index 8979d129d8c4624d1a4cb6ded3e91cf26204472a..58000a965e84d637a683d2d43aa9cebbb01129a5 100755 (executable)
@@ -12,5 +12,9 @@ cat << EOF >> ../filters.dat
 gtkrescale             libmltgtk2.so
 EOF
 
+cat << EOF >> ../consumers.dat
+gtk2_preview   libmltgtk2.so
+EOF
+
 fi
 
diff --git a/src/modules/gtk2/consumer_gtk2.c b/src/modules/gtk2/consumer_gtk2.c
new file mode 100644 (file)
index 0000000..4da317c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * consumer_gtk2.c -- A consumer for GTK2 apps
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "consumer_gtk2.h"
+
+#include <stdlib.h>
+#include <framework/mlt_consumer.h>
+#include <framework/mlt_factory.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+mlt_consumer consumer_gtk2_preview_init( GtkWidget *widget )
+{
+       // Create an sdl preview consumer
+       mlt_consumer consumer = NULL;
+
+       // This is a nasty little hack which is required by SDL
+       if ( widget != NULL )
+       {
+        Window xwin = GDK_WINDOW_XWINDOW( widget->window );
+        char windowhack[ 32 ];
+        sprintf( windowhack, "%ld", xwin );
+        setenv( "SDL_WINDOWID", windowhack, 1 );
+       }
+
+       // Create an sdl preview consumer
+       consumer = mlt_factory_consumer( "sdl_preview", NULL );
+
+       // Now assign the lock/unlock callbacks
+       if ( consumer != NULL )
+       {
+               mlt_properties properties = mlt_consumer_properties( consumer );
+               mlt_properties_set_data( properties, "app_lock", gdk_threads_enter, 0, NULL, NULL );
+               mlt_properties_set_data( properties, "app_unlock", gdk_threads_leave, 0, NULL, NULL );
+       }
+
+       return consumer;
+}
diff --git a/src/modules/gtk2/consumer_gtk2.h b/src/modules/gtk2/consumer_gtk2.h
new file mode 100644 (file)
index 0000000..84b3e32
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * consumer_gtk2.h -- A consumer for GTK2 apps
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _CONSUMER_GTK2_PREVIEW_H
+#define _CONSUMER_GTK2_PREVIEW_H
+
+#include <framework/mlt_consumer.h>
+#include <gtk/gtk.h>
+
+extern mlt_consumer consumer_gtk2_preview_init( GtkWidget *widget );
+
+#endif
index 82ed3d4235e6866b8f996ff91a4bbe30ddecf667..b7cca9b35079624819f856e04ac805e651a98f81 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <string.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include "consumer_gtk2.h"
 #include "producer_pixbuf.h"
 #include "producer_pango.h"
 #include "filter_rescale.h"
@@ -49,6 +50,9 @@ void *mlt_create_transition( char *id, void *arg )
 
 void *mlt_create_consumer( char *id, void *arg )
 {
+       g_type_init( );
+       if ( !strcmp( id, "gtk2_preview" ) )
+               return consumer_gtk2_preview_init( arg );
        return NULL;
 }
 
index 6e8e12d8bd0bbbbb495948f941fed3dcb8624727..58741522bf25f0d7a43b98febeadb9836acc879e 100644 (file)
@@ -428,7 +428,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        changed = 1;
                }
 
-               if ( this->sdl_screen == NULL || changed )
+               if ( this->running && ( this->sdl_screen == NULL || changed ) )
                {
                        // Determine frame's display aspect ratio
                        float frame_aspect = mlt_frame_get_aspect_ratio( frame ) * this->width / this->height;
@@ -436,6 +436,19 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        // Determine window's new display aspect ratio
                        float this_aspect = ( float )this->window_width / this->window_height;
 
+                       // Force an overlay recreation
+                       if ( this->sdl_overlay != NULL )
+                               SDL_FreeYUVOverlay( this->sdl_overlay );
+
+                       // open SDL window with video overlay, if possible
+                       sdl_lock_display();
+                       this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
+                       sdl_unlock_display();
+                       if ( consumer_get_dimensions( &this->window_width, &this->window_height ) )
+                               this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
+                       SDL_Flip( this->sdl_screen );
+                       mlt_properties_set_int( properties, "changed", 0 );
+               
                        // If using hardware scaler
                        if ( mlt_properties_get( properties, "rescale" ) != NULL &&
                                !strcmp( mlt_properties_get( properties, "rescale" ), "none" ) )
@@ -487,19 +500,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        mlt_properties_set_int( this->properties, "rect_w", this->rect.w );
                        mlt_properties_set_int( this->properties, "rect_h", this->rect.h );
 
-                       // Force an overlay recreation
-                       if ( this->sdl_overlay != NULL )
-                               SDL_FreeYUVOverlay( this->sdl_overlay );
-
-                       // open SDL window with video overlay, if possible
-                       sdl_lock_display();
-                       this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
-                       sdl_unlock_display();
-                       if ( consumer_get_dimensions( &this->window_width, &this->window_height ) )
-                               this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
-                       SDL_Flip( this->sdl_screen );
-                       mlt_properties_set_int( properties, "changed", 0 );
-               
                        if ( this->sdl_screen != NULL )
                        {
                                SDL_SetClipRect( this->sdl_screen, &this->rect );
@@ -514,6 +514,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        sdl_lock_display();
                        this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
                        SDL_SetClipRect( this->sdl_screen, &this->rect );
+                       SDL_Flip( this->sdl_screen );
                        sdl_unlock_display();
                        mlt_properties_set_int( properties, "changed", 0 );
                }
@@ -655,7 +656,6 @@ static void *consumer_thread( void *arg )
        {
                if ( SDL_GetVideoSurface( ) != NULL )
                        consumer_get_dimensions( &this->window_width, &this->window_height );
-               mlt_properties_set_int( mlt_consumer_properties( consumer ), "changed", 1 );
        }
 
        SDL_InitSubSystem( SDL_INIT_AUDIO );
index 1bcd173f619a866aaf09195c4a35b015cb75c7a8..ddb3ddf726952743e9b81157ed0c96150180ec22 100644 (file)
@@ -71,6 +71,8 @@ mlt_consumer consumer_sdl_preview_init( char *arg )
                this->joined = 1;
                mlt_events_listen( mlt_consumer_properties( this->play ), this, "consumer-frame-show", ( mlt_listener )consumer_frame_show_cb );
                mlt_events_listen( mlt_consumer_properties( this->still ), this, "consumer-frame-show", ( mlt_listener )consumer_frame_show_cb );
+               mlt_events_listen( mlt_consumer_properties( this->play ), this, "consumer-sdl-event", ( mlt_listener )consumer_sdl_event_cb );
+               mlt_events_listen( mlt_consumer_properties( this->still ), this, "consumer-sdl-event", ( mlt_listener )consumer_sdl_event_cb );
                return parent;
        }
        free( this );
@@ -204,30 +206,39 @@ static void *consumer_thread( void *arg )
                        // Determine which speed to use
                        double use_speed = first ? speed : this->last_speed;
 
-                       // Get changed requests to the preview
+                       // Get changed requests to the preview (focus changes)
                        int changed = mlt_properties_get_int( properties, "changed" );
+
+                       // Get refresh request for the current frame (effect changes in still mode)
+                       int refresh = mlt_properties_get_int( properties, "refresh" );
+
+                       // Decrement refresh and clear changed
+                       mlt_properties_set_int( properties, "refresh", refresh > 0 ? refresh - 1 : 0 );
                        mlt_properties_set_int( properties, "changed", 0 );
 
+                       // Set the changed property on this frame for the benefit of still
+                       mlt_properties_set_int( mlt_frame_properties( frame ), "refresh", refresh );
+
                        // Make sure the recipient knows that this frame isn't really rendered
                        mlt_properties_set_int( mlt_frame_properties( frame ), "rendered", 0 );
 
+                       // If we're not the first frame and both consumers are stopped, then stop ourselves
                        if ( !first && mlt_consumer_is_stopped( this->play ) && mlt_consumer_is_stopped( this->still ) )
                        {
                                this->running = 0;
                                mlt_frame_close( frame );
                        }
+                       // Allow a little grace time before switching consumers on speed changes
                        else if ( this->ignore_change -- > 0 && this->active != NULL && !mlt_consumer_is_stopped( this->active ) )
                        {
                                mlt_consumer_put_frame( this->active, frame );
-                               if ( this->active == this->still )
-                                       mlt_properties_set_int( still, "changed", changed );
+                               mlt_properties_set_int( still, "changed", changed );
                        }
+                       // If we aren't playing normally, then use the still
                        else if ( use_speed != 1 )
                        {
                                if ( !mlt_consumer_is_stopped( this->play ) )
-                               {
                                        mlt_consumer_stop( this->play );
-                               }
                                if ( mlt_consumer_is_stopped( this->still ) )
                                {
                                        this->last_speed = use_speed;
@@ -238,12 +249,11 @@ static void *consumer_thread( void *arg )
                                mlt_properties_set_int( still, "changed", changed );
                                mlt_consumer_put_frame( this->still, frame );
                        }
+                       // Otherwise use the normal player
                        else
                        {
                                if ( !mlt_consumer_is_stopped( this->still ) )
-                               {
                                        mlt_consumer_stop( this->still );
-                               }
                                if ( mlt_consumer_is_stopped( this->play ) )
                                {
                                        this->last_speed = use_speed;
@@ -251,8 +261,21 @@ static void *consumer_thread( void *arg )
                                        this->ignore_change = 25;
                                        mlt_consumer_start( this->play );
                                }
+                               mlt_properties_set_int( still, "changed", changed );
                                mlt_consumer_put_frame( this->play, frame );
                        }
+
+                       // Copy the rectangle info from the active consumer
+                       if ( this->running )
+                       {
+                               mlt_properties active = mlt_consumer_properties( this->active );
+                               mlt_properties_set_int( properties, "rect_x", mlt_properties_get_int( active, "rect_x" ) );
+                               mlt_properties_set_int( properties, "rect_y", mlt_properties_get_int( active, "rect_y" ) );
+                               mlt_properties_set_int( properties, "rect_w", mlt_properties_get_int( active, "rect_w" ) );
+                               mlt_properties_set_int( properties, "rect_h", mlt_properties_get_int( active, "rect_h" ) );
+                       }
+
+                       // We are definitely not waiting on the first frame any more
                        first = 0;
                }
        }
index d37255abafe958662e9fcb628440c6ab81e0a053..dc0c79e6ebe1f4884ecedf34093354c790429f56 100644 (file)
@@ -291,7 +291,8 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
        {
                // open SDL window 
                this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 16, this->sdl_flags );
-               consumer_get_dimensions( &this->window_width, &this->window_height );
+               if ( consumer_get_dimensions( &this->window_width, &this->window_height ) )
+                       this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 16, this->sdl_flags );
                changed = 1;
                mlt_properties_set_int( properties, "changed", 0 );
 
@@ -354,7 +355,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
        }
        else
        {
-               changed = mlt_properties_get_int( properties, "changed" );
+               changed = mlt_properties_get_int( properties, "changed" ) | mlt_properties_get_int( mlt_frame_properties( frame ), "refresh" );
                mlt_properties_set_int( properties, "changed", 0 );
        }
                
index 1d427543622b06cc86d05035cfbacc527f604af8..eb022cdf8ffaab7f426906be6553d7a442af6e4b 100644 (file)
@@ -1269,7 +1269,7 @@ mlt_producer producer_westley_init( int info, char *data )
        struct _xmlParserCtxt *xmlcontext;
        int well_formed = 0;
        char *filename = NULL;
-       
+
        context->producer_map = mlt_properties_new();
        context->destructors = mlt_properties_new();
        context->params = mlt_properties_new();
index 87c33640f593cfb94a04f7a0bf3581fdbb411c57..a921d4f19690e0cfbc9d9b75af0af14cee58893b 100755 (executable)
@@ -1,2 +1,2 @@
 #!/bin/sh
-echo "valerie  -I$prefix/include/mlt -D_REENTRANT      -lvalerie" >> ../../packages.dat
+echo "valerie  -I$prefix/include/mlt -D_REENTRANT      -L$prefix/lib -lvalerie" >> ../../packages.dat