Merge ../mlt
[melted] / src / modules / dv / consumer_libdv.c
index c8f58bd..2ee9b20 100644 (file)
@@ -3,26 +3,23 @@
  * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
  * Author: Charles Yates <charles.yates@pandora.be>
  *
- * 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 library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library 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.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser 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.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-// Local header files
-#include "consumer_libdv.h"
-#include "producer_libdv.h"
-
 // mlt Header files
+#include <framework/mlt_consumer.h>
 #include <framework/mlt_frame.h>
 
 // System header files
@@ -34,6 +31,9 @@
 // libdv header files
 #include <libdv/dv.h>
 
+#define FRAME_SIZE_525_60      10 * 150 * 80
+#define FRAME_SIZE_625_50      12 * 150 * 80
+
 // Forward references.
 static int consumer_start( mlt_consumer this );
 static int consumer_stop( mlt_consumer this );
@@ -47,13 +47,13 @@ static void consumer_close( mlt_consumer this );
 /** Initialise the dv consumer.
 */
 
-mlt_consumer consumer_libdv_init( char *arg )
+mlt_consumer consumer_libdv_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
 {
        // Allocate the consumer
        mlt_consumer this = calloc( 1, sizeof( struct mlt_consumer_s ) );
 
        // If memory allocated and initialises without error
-       if ( this != NULL && mlt_consumer_init( this, NULL ) == 0 )
+       if ( this != NULL && mlt_consumer_init( this, NULL, profile ) == 0 )
        {
                // Get properties from the consumer
                mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
@@ -70,6 +70,9 @@ mlt_consumer consumer_libdv_init( char *arg )
                mlt_properties_set_data( properties, "audio", consumer_encode_audio, 0, NULL, NULL );
                mlt_properties_set_data( properties, "output", consumer_output, 0, NULL, NULL );
 
+               // Terminate at end of the stream by default
+               mlt_properties_set_int( properties, "terminate_on_pause", 1 );
+
                // Set up start/stop/terminated callbacks
                this->start = consumer_start;
                this->stop = consumer_stop;
@@ -280,7 +283,7 @@ static void consumer_encode_audio( mlt_consumer this, uint8_t *dv_frame, mlt_fra
                time_t start = time( NULL );
                int height = mlt_properties_get_int( this_properties, "height" );
                int is_pal = height == 576;
-               int is_wide = mlt_properties_get_double( frame_properties, "fps" ) == ( ( double ) 16.0 / 9.0 );
+               int is_wide = mlt_properties_get_int( this_properties, "display_aspect_num" ) == 16;
 
                // Temporary - audio buffer allocation
                int16_t *audio_buffers[ 4 ];