[svn r78] -fixed memory leak; trunk
authorrenatofilho
Fri Nov 10 19:21:45 2006 +0000 (2006-11-10)
branchtrunk
changeset 77bca1fb717911
parent 76 1c1958d4bab7
child 78 ac7e49c234d8
[svn r78] -fixed memory leak;
gst-plugins-nuvdemux/INSTALL
gst-plugins-nuvdemux/debian/files
gst-plugins-nuvdemux/debian/maemo-nuvdemux.postinst
gst-plugins-nuvdemux/debian/rules
gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c
gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h
gst-plugins-nuvdemux/typefind/Makefile.am
     1.1 --- a/gst-plugins-nuvdemux/INSTALL	Thu Nov 09 20:22:45 2006 +0000
     1.2 +++ b/gst-plugins-nuvdemux/INSTALL	Fri Nov 10 19:21:45 2006 +0000
     1.3 @@ -1,16 +1,13 @@
     1.4 -Installation Instructions
     1.5 -*************************
     1.6 +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
     1.7 +Foundation, Inc.
     1.8  
     1.9 -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
    1.10 -Software Foundation, Inc.
    1.11 -
    1.12 -This file is free documentation; the Free Software Foundation gives
    1.13 +   This file is free documentation; the Free Software Foundation gives
    1.14  unlimited permission to copy, distribute and modify it.
    1.15  
    1.16  Basic Installation
    1.17  ==================
    1.18  
    1.19 -These are generic installation instructions.
    1.20 +   These are generic installation instructions.
    1.21  
    1.22     The `configure' shell script attempts to guess correct values for
    1.23  various system-dependent variables used during compilation.  It uses
    1.24 @@ -70,9 +67,9 @@
    1.25  Compilers and Options
    1.26  =====================
    1.27  
    1.28 -Some systems require unusual options for compilation or linking that the
    1.29 -`configure' script does not know about.  Run `./configure --help' for
    1.30 -details on some of the pertinent environment variables.
    1.31 +   Some systems require unusual options for compilation or linking that
    1.32 +the `configure' script does not know about.  Run `./configure --help'
    1.33 +for details on some of the pertinent environment variables.
    1.34  
    1.35     You can give `configure' initial values for configuration parameters
    1.36  by setting variables in the command line or in the environment.  Here
    1.37 @@ -85,7 +82,7 @@
    1.38  Compiling For Multiple Architectures
    1.39  ====================================
    1.40  
    1.41 -You can compile the package for more than one kind of computer at the
    1.42 +   You can compile the package for more than one kind of computer at the
    1.43  same time, by placing the object files for each architecture in their
    1.44  own directory.  To do this, you must use a version of `make' that
    1.45  supports the `VPATH' variable, such as GNU `make'.  `cd' to the
    1.46 @@ -102,19 +99,19 @@
    1.47  Installation Names
    1.48  ==================
    1.49  
    1.50 -By default, `make install' installs the package's commands under
    1.51 -`/usr/local/bin', include files under `/usr/local/include', etc.  You
    1.52 -can specify an installation prefix other than `/usr/local' by giving
    1.53 -`configure' the option `--prefix=PREFIX'.
    1.54 +   By default, `make install' will install the package's files in
    1.55 +`/usr/local/bin', `/usr/local/man', etc.  You can specify an
    1.56 +installation prefix other than `/usr/local' by giving `configure' the
    1.57 +option `--prefix=PATH'.
    1.58  
    1.59     You can specify separate installation prefixes for
    1.60  architecture-specific files and architecture-independent files.  If you
    1.61 -pass the option `--exec-prefix=PREFIX' to `configure', the package uses
    1.62 -PREFIX as the prefix for installing programs and libraries.
    1.63 -Documentation and other data files still use the regular prefix.
    1.64 +give `configure' the option `--exec-prefix=PATH', the package will use
    1.65 +PATH as the prefix for installing programs and libraries.
    1.66 +Documentation and other data files will still use the regular prefix.
    1.67  
    1.68     In addition, if you use an unusual directory layout you can give
    1.69 -options like `--bindir=DIR' to specify different values for particular
    1.70 +options like `--bindir=PATH' to specify different values for particular
    1.71  kinds of files.  Run `configure --help' for a list of the directories
    1.72  you can set and what kinds of files go in them.
    1.73  
    1.74 @@ -125,7 +122,7 @@
    1.75  Optional Features
    1.76  =================
    1.77  
    1.78 -Some packages pay attention to `--enable-FEATURE' options to
    1.79 +   Some packages pay attention to `--enable-FEATURE' options to
    1.80  `configure', where FEATURE indicates an optional part of the package.
    1.81  They may also pay attention to `--with-PACKAGE' options, where PACKAGE
    1.82  is something like `gnu-as' or `x' (for the X Window System).  The
    1.83 @@ -140,11 +137,11 @@
    1.84  Specifying the System Type
    1.85  ==========================
    1.86  
    1.87 -There may be some features `configure' cannot figure out automatically,
    1.88 -but needs to determine by the type of machine the package will run on.
    1.89 -Usually, assuming the package is built to be run on the _same_
    1.90 -architectures, `configure' can figure that out, but if it prints a
    1.91 -message saying it cannot guess the machine type, give it the
    1.92 +   There may be some features `configure' cannot figure out
    1.93 +automatically, but needs to determine by the type of machine the package
    1.94 +will run on.  Usually, assuming the package is built to be run on the
    1.95 +_same_ architectures, `configure' can figure that out, but if it prints
    1.96 +a message saying it cannot guess the machine type, give it the
    1.97  `--build=TYPE' option.  TYPE can either be a short name for the system
    1.98  type, such as `sun4', or a canonical name which has the form:
    1.99  
   1.100 @@ -159,7 +156,7 @@
   1.101  need to know the machine type.
   1.102  
   1.103     If you are _building_ compiler tools for cross-compiling, you should
   1.104 -use the option `--target=TYPE' to select the type of system they will
   1.105 +use the `--target=TYPE' option to select the type of system they will
   1.106  produce code for.
   1.107  
   1.108     If you want to _use_ a cross compiler, that generates code for a
   1.109 @@ -170,9 +167,9 @@
   1.110  Sharing Defaults
   1.111  ================
   1.112  
   1.113 -If you want to set default values for `configure' scripts to share, you
   1.114 -can create a site shell script called `config.site' that gives default
   1.115 -values for variables like `CC', `cache_file', and `prefix'.
   1.116 +   If you want to set default values for `configure' scripts to share,
   1.117 +you can create a site shell script called `config.site' that gives
   1.118 +default values for variables like `CC', `cache_file', and `prefix'.
   1.119  `configure' looks for `PREFIX/share/config.site' if it exists, then
   1.120  `PREFIX/etc/config.site' if it exists.  Or, you can set the
   1.121  `CONFIG_SITE' environment variable to the location of the site script.
   1.122 @@ -181,7 +178,7 @@
   1.123  Defining Variables
   1.124  ==================
   1.125  
   1.126 -Variables not defined in a site shell script can be set in the
   1.127 +   Variables not defined in a site shell script can be set in the
   1.128  environment passed to `configure'.  However, some packages may run
   1.129  configure again during the build, and the customized values of these
   1.130  variables may be lost.  In order to avoid this problem, you should set
   1.131 @@ -189,18 +186,14 @@
   1.132  
   1.133       ./configure CC=/usr/local2/bin/gcc
   1.134  
   1.135 -causes the specified `gcc' to be used as the C compiler (unless it is
   1.136 -overridden in the site shell script).  Here is a another example:
   1.137 -
   1.138 -     /bin/bash ./configure CONFIG_SHELL=/bin/bash
   1.139 -
   1.140 -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
   1.141 -configuration-related scripts to be executed by `/bin/bash'.
   1.142 +will cause the specified gcc to be used as the C compiler (unless it is
   1.143 +overridden in the site shell script).
   1.144  
   1.145  `configure' Invocation
   1.146  ======================
   1.147  
   1.148 -`configure' recognizes the following options to control how it operates.
   1.149 +   `configure' recognizes the following options to control how it
   1.150 +operates.
   1.151  
   1.152  `--help'
   1.153  `-h'
     2.1 --- a/gst-plugins-nuvdemux/debian/files	Thu Nov 09 20:22:45 2006 +0000
     2.2 +++ b/gst-plugins-nuvdemux/debian/files	Fri Nov 10 19:21:45 2006 +0000
     2.3 @@ -1,2 +1,2 @@
     2.4  maemo-nuvdemux_0.10.2.debian-1_all.deb libs optional
     2.5 -gstreamer0.10-indt-nuvdemux_0.10.2.debian-1_i386.deb libs optional
     2.6 +gstreamer0.10-indt-nuvdemux_0.10.2.debian-1_armel.deb libs optional
     3.1 --- a/gst-plugins-nuvdemux/debian/maemo-nuvdemux.postinst	Thu Nov 09 20:22:45 2006 +0000
     3.2 +++ b/gst-plugins-nuvdemux/debian/maemo-nuvdemux.postinst	Fri Nov 10 19:21:45 2006 +0000
     3.3 @@ -10,7 +10,7 @@
     3.4  
     3.5  # Register a new type on Osso Media Server
     3.6  if [ -x /usr/bin/gconftool-2 ] ; then
     3.7 -    /urc/bin/gconftool-2 --makefile-install-rule /etc/gconf/schemas/osso_media_server_nuv.schemas
     3.8 +    /usr/bin/gconftool-2 --makefile-install-rule /etc/gconf/schemas/osso_media_server_nuv.schemas
     3.9  fi
    3.10  
    3.11  exit 0
     4.1 --- a/gst-plugins-nuvdemux/debian/rules	Thu Nov 09 20:22:45 2006 +0000
     4.2 +++ b/gst-plugins-nuvdemux/debian/rules	Fri Nov 10 19:21:45 2006 +0000
     4.3 @@ -5,8 +5,15 @@
     4.4  include /usr/share/cdbs/1/class/gnome.mk
     4.5  include /usr/share/cdbs/1/rules/utils.mk
     4.6  
     4.7 +# debian package version
     4.8 +version=$(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)
     4.9 +
    4.10 +maint: debian/control
    4.11 +
    4.12  binary-install/gstreamer0.10-indt-nuvdemux::
    4.13  	rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgstnuvdemux.la
    4.14  	rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgstnuvdemux.a
    4.15 -	rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgsttypefindfunctions.la
    4.16 -	rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgsttypefindfunctions.a
    4.17 +	rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgsttypefindfunctions_indt.la
    4.18 +	rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgsttypefindfunctions_indt.a
    4.19 +
    4.20 +.PHONY: maint
     5.1 --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Thu Nov 09 20:22:45 2006 +0000
     5.2 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Fri Nov 10 19:21:45 2006 +0000
     5.3 @@ -87,15 +87,6 @@
     5.4      GST_PAD_SOMETIMES,
     5.5      GST_STATIC_CAPS_ANY);
     5.6  
     5.7 -/* NUV Demux indexes init/dispose callers */
     5.8 -static void gst_nuv_demux_index_init( nuv_demux_index **p_idx );
     5.9 -static void gst_nuv_demux_index_clean( nuv_demux_index **p_idx );
    5.10 -
    5.11 -/* NUV Demux indexes manipulation functions */
    5.12 -//static gint64 gst_nuv_demux_index_find_offset( GstNuvDemux *nuv, gint64 i_offset );
    5.13 -static void gst_nuv_demux_index_append( GstNuvDemux *nuv, gint64 i_time, gint64 i_offset );
    5.14 -static gint64 gst_nuv_demux_index_convert_time( GstNuvDemux *nuv, gint64 i_time );
    5.15 -
    5.16  /* NUV Demux plug-in time-line functions */
    5.17  static void gst_nuv_demux_finalize (GObject * object);
    5.18  static GstStateChangeReturn gst_nuv_demux_change_state (GstElement * element,
    5.19 @@ -105,16 +96,12 @@
    5.20  static GstFlowReturn gst_nuv_demux_play (GstPad * pad);
    5.21  static gboolean gst_nuv_demux_sink_activate_pull (GstPad * sinkpad,
    5.22      gboolean active);
    5.23 +static gboolean gst_nuv_demux_sink_activate_push (GstPad * pad, 
    5.24 +    gboolean active);
    5.25  static gboolean gst_nuv_demux_sink_activate (GstPad * sinkpad);
    5.26  static GstFlowReturn gst_nuv_demux_read_bytes (GstNuvDemux * nuv, guint64 size,
    5.27      gboolean move, GstBuffer ** buffer);
    5.28  static void gst_nuv_demux_reset (GstNuvDemux * nuv);
    5.29 -static gboolean gst_nuv_demux_handle_sink_event (GstPad * sinkpad,
    5.30 -    GstEvent * event);
    5.31 -static gboolean gst_nuv_demux_handle_audio_src_event (GstPad * sinkpad,
    5.32 -    GstEvent * event);
    5.33 -static gboolean gst_nuv_demux_handle_video_src_event (GstPad * sinkpad,
    5.34 -    GstEvent * event);
    5.35  static void gst_nuv_demux_destoy_src_pad (GstNuvDemux * nuv);
    5.36  static void gst_nuv_demux_send_eos (GstNuvDemux * nuv);
    5.37  
    5.38 @@ -182,11 +169,12 @@
    5.39    gst_pad_set_activatepull_function (nuv->sinkpad,
    5.40        gst_nuv_demux_sink_activate_pull);
    5.41  
    5.42 +  gst_pad_set_activatepush_function (nuv->sinkpad, 
    5.43 +      gst_nuv_demux_sink_activate_push);
    5.44 +
    5.45    gst_pad_set_chain_function (nuv->sinkpad,
    5.46        GST_DEBUG_FUNCPTR (gst_nuv_demux_chain));
    5.47  
    5.48 -  gst_pad_set_event_function (nuv->sinkpad, gst_nuv_demux_handle_sink_event);
    5.49 -
    5.50    gst_element_add_pad (GST_ELEMENT (nuv), nuv->sinkpad);
    5.51    
    5.52    gst_nuv_demux_index_init( &nuv->index_entries );
    5.53 @@ -222,149 +210,6 @@
    5.54  }
    5.55  
    5.56  
    5.57 -/*****************************************************************************
    5.58 - * Indexes (timecode offset conversion) functions
    5.59 - *****************************************************************************/
    5.60 -
    5.61 -static void 
    5.62 -gst_nuv_demux_index_init( nuv_demux_index **p_idx )
    5.63 -{
    5.64 -	*p_idx = g_new0( nuv_demux_index, 1 );
    5.65 -	(*p_idx)->i_idx = 0;
    5.66 -	(*p_idx)->i_idx_max = 0;
    5.67 -}
    5.68 -
    5.69 -static void 
    5.70 -gst_nuv_demux_index_clean( nuv_demux_index **p_idx )
    5.71 -{
    5.72 -	if ( *p_idx != NULL ) {
    5.73 -		g_free( *p_idx );
    5.74 -		*p_idx = NULL;
    5.75 -	}
    5.76 -
    5.77 -}
    5.78 -
    5.79 -static void 
    5.80 -gst_nuv_demux_index_append( GstNuvDemux *nuv, gint64 i_time, gint64 i_offset )
    5.81 -{
    5.82 -	nuv_demux_index *p_idx = nuv->index_entries;
    5.83 -
    5.84 -	//if ( p_idx == NULL )
    5.85 -	//	return;
    5.86 -
    5.87 -	/* Be sure to append new entry (we don't insert point) */
    5.88 -	if( p_idx != NULL && p_idx->i_idx > 0 && p_idx->idx[p_idx->i_idx-1].i_time >= i_time )
    5.89 -		return;
    5.90 -
    5.91 -	/* */
    5.92 -	if( p_idx->i_idx >= p_idx->i_idx_max )
    5.93 -	{
    5.94 -		if( p_idx->i_idx >= DEMUX_INDEX_SIZE_MAX )
    5.95 -		{
    5.96 -			/* Avoid too big index */
    5.97 -			const gint64 i_length = p_idx->idx[p_idx->i_idx-1].i_time -
    5.98 -				p_idx->idx[0].i_time;
    5.99 -			const gint i_count = DEMUX_INDEX_SIZE_MAX/2;
   5.100 -			gint i, j;
   5.101 -
   5.102 -			/* We try to reduce the resolution of the index by a factor 2 */
   5.103 -			for( i = 1, j = 1; i < p_idx->i_idx; i++ )
   5.104 -			{
   5.105 -				if( p_idx->idx[i].i_time < j * i_length / i_count )
   5.106 -					continue;
   5.107 -
   5.108 -				p_idx->idx[j++] = p_idx->idx[i];
   5.109 -			}
   5.110 -			p_idx->i_idx = j;
   5.111 -
   5.112 -			if( p_idx->i_idx > 3 * DEMUX_INDEX_SIZE_MAX / 4 )
   5.113 -			{
   5.114 -				/* We haven't created enough space
   5.115 -				 * (This method won't create a good index but work for sure) */
   5.116 -				for( i = 0; i < p_idx->i_idx/2; i++ )
   5.117 -					p_idx->idx[i] = p_idx->idx[2*i];
   5.118 -				p_idx->i_idx /= 2;
   5.119 -			}
   5.120 -		}
   5.121 -		else
   5.122 -		{
   5.123 -			p_idx->i_idx_max += 1000;
   5.124 -		}
   5.125 -	}
   5.126 -
   5.127 -	/* */
   5.128 -	p_idx->idx[p_idx->i_idx].i_time = i_time;
   5.129 -	p_idx->idx[p_idx->i_idx].i_offset = i_offset;
   5.130 -
   5.131 -	p_idx->i_idx++;
   5.132 -}
   5.133 -
   5.134 -static gint64 
   5.135 -gst_nuv_demux_index_convert_time( GstNuvDemux *nuv, gint64 i_time )
   5.136 -{
   5.137 -	nuv_demux_index *p_idx = nuv->index_entries;
   5.138 -
   5.139 -	g_return_val_if_fail( p_idx != NULL , i_time );
   5.140 -
   5.141 -	gint i_min = 0;
   5.142 -	gint i_max = p_idx->i_idx-1;
   5.143 -
   5.144 -	/* Empty index */
   5.145 -	if( p_idx->i_idx <= 0 )
   5.146 -		return -1;
   5.147 -
   5.148 -	/* Special border case */
   5.149 -	if( i_time <= p_idx->idx[0].i_time )
   5.150 -		return p_idx->idx[0].i_offset;
   5.151 -	if( i_time >= p_idx->idx[i_max].i_time )
   5.152 -		return p_idx->idx[i_max].i_offset;
   5.153 -
   5.154 -	/* Dicho */
   5.155 -	for( ;; )
   5.156 -	{
   5.157 -		gint i_med;
   5.158 -
   5.159 -		if( i_max - i_min <= 1 )
   5.160 -			break;
   5.161 -
   5.162 -		i_med = (i_min+i_max)/2;
   5.163 -		if( p_idx->idx[i_med].i_time < i_time )
   5.164 -			i_min = i_med;
   5.165 -		else if( p_idx->idx[i_med].i_time > i_time )
   5.166 -			i_max = i_med;
   5.167 -		else
   5.168 -			return p_idx->idx[i_med].i_offset;
   5.169 -	}
   5.170 -
   5.171 -	/* return nearest in time */
   5.172 -	if( i_time - p_idx->idx[i_min].i_time < p_idx->idx[i_max].i_time - i_time )
   5.173 -		return p_idx->idx[i_min].i_offset;
   5.174 -	else
   5.175 -		return p_idx->idx[i_max].i_offset;
   5.176 -}
   5.177 -
   5.178 -/*****************************************************************************
   5.179 - * Utils functions
   5.180 - *****************************************************************************/
   5.181 -
   5.182 -static gboolean
   5.183 -gst_nuv_demux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
   5.184 -{
   5.185 -  gboolean res = FALSE;
   5.186 -
   5.187 -  switch (GST_EVENT_TYPE (event)) {
   5.188 -    case GST_EVENT_NEWSEGMENT:
   5.189 -      res = TRUE;
   5.190 -      break;
   5.191 -    default:
   5.192 -      return gst_pad_event_default (sinkpad, event);
   5.193 -      break;
   5.194 -  }
   5.195 -
   5.196 -  gst_event_unref (event);
   5.197 -  return res;
   5.198 -}
   5.199 -
   5.200  /* HeaderLoad:
   5.201   */
   5.202  static GstFlowReturn
   5.203 @@ -384,7 +229,7 @@
   5.204    h->i_height = GST_READ_UINT32_LE (&buffer->data[24]);
   5.205    h->i_width_desired = GST_READ_UINT32_LE (&buffer->data[28]);
   5.206    h->i_height_desired = GST_READ_UINT32_LE (&buffer->data[32]);
   5.207 -  h->i_mode = buffer->data[36];
   5.208 +  h->i_mode = GPOINTER_TO_INT (buffer->data[36]);
   5.209    h->d_aspect = READ_DOUBLE_FROM_LE (&buffer->data[40]);
   5.210    h->d_fps = READ_DOUBLE_FROM_LE (&buffer->data[48]);
   5.211    h->i_video_blocks = GST_READ_UINT32_LE (&buffer->data[56]);
   5.212 @@ -462,15 +307,13 @@
   5.213    h = g_new0 (nuv_frame_header, 1);
   5.214    data = buf->data;
   5.215  
   5.216 -  h->i_type = data[0];
   5.217 -  h->i_compression = data[1];
   5.218 -  h->i_keyframe = data[2];
   5.219 -  h->i_filters = data[3];
   5.220 -
   5.221 +  h->i_type = GPOINTER_TO_INT (data[0]);
   5.222 +  h->i_compression = GPOINTER_TO_INT (data[1]);
   5.223 +  h->i_keyframe = GPOINTER_TO_INT (data[2]);
   5.224 +  h->i_filters = GPOINTER_TO_INT (data[3]);
   5.225    h->i_timecode = GST_READ_UINT32_LE (&data[4]);
   5.226 -
   5.227 -
   5.228    h->i_length = GST_READ_UINT32_LE (&data[8]);
   5.229 +  
   5.230    GST_DEBUG_OBJECT (nuv, "frame hdr: t=%c c=%c k=%d f=0x%x timecode=%d l=%d",
   5.231        h->i_type,
   5.232        h->i_compression ? h->i_compression : ' ',
   5.233 @@ -535,20 +378,6 @@
   5.234    return res;
   5.235  }
   5.236  
   5.237 -static gboolean
   5.238 -gst_nuv_demux_handle_audio_src_event (GstPad * pad, GstEvent * event)
   5.239 -{
   5.240 -  gst_event_unref (event);
   5.241 -  return FALSE;
   5.242 -}
   5.243 -
   5.244 -static gboolean
   5.245 -gst_nuv_demux_handle_video_src_event (GstPad * pad, GstEvent * event)
   5.246 -{
   5.247 -  gst_event_unref (event);
   5.248 -  return FALSE;
   5.249 -}
   5.250 -
   5.251  static void
   5.252  gst_nuv_demux_create_pads (GstNuvDemux * nuv)
   5.253  {
   5.254 @@ -563,14 +392,12 @@
   5.255          "width", G_TYPE_INT, nuv->h->i_width,
   5.256          "height", G_TYPE_INT, nuv->h->i_height,
   5.257          "framerate", GST_TYPE_FRACTION, (gint) (nuv->h->d_fps * 1000.0f), 1000,
   5.258 +        "format", GST_TYPE_FOURCC, nuv->eh->i_video_fcc,
   5.259          "pixel-aspect-ratio", GST_TYPE_FRACTION,
   5.260          (gint) (nuv->h->d_aspect * 1000.0f), 1000, NULL);
   5.261  
   5.262      gst_pad_use_fixed_caps (nuv->src_video_pad);
   5.263      gst_pad_set_caps (nuv->src_video_pad, video_caps);
   5.264 -
   5.265 -    gst_pad_set_event_function (nuv->src_video_pad,
   5.266 -	    	gst_nuv_demux_handle_video_src_event);
   5.267      gst_pad_set_active (nuv->src_video_pad, TRUE);
   5.268      gst_element_add_pad (GST_ELEMENT (nuv), nuv->src_video_pad);
   5.269  
   5.270 @@ -591,12 +418,8 @@
   5.271  
   5.272      gst_pad_use_fixed_caps (nuv->src_audio_pad);
   5.273      gst_pad_set_caps (nuv->src_audio_pad, audio_caps);
   5.274 -    
   5.275 -    gst_pad_set_event_function (nuv->src_audio_pad,
   5.276 -  		  gst_nuv_demux_handle_audio_src_event);
   5.277      gst_pad_set_active (nuv->src_audio_pad, TRUE);
   5.278      gst_element_add_pad (GST_ELEMENT (nuv), nuv->src_audio_pad);
   5.279 -
   5.280      gst_caps_unref (audio_caps);
   5.281    }
   5.282  
   5.283 @@ -608,6 +431,12 @@
   5.284  {
   5.285    GstFlowReturn ret = GST_FLOW_OK;
   5.286  
   5.287 +  if (nuv->fh != NULL) 
   5.288 +  {
   5.289 +    g_free (nuv->fh);
   5.290 +    nuv->fh = NULL;
   5.291 +  }
   5.292 +  
   5.293    ret = gst_nuv_demux_frame_header_load (nuv, &nuv->fh);
   5.294    if (ret != GST_FLOW_OK)
   5.295      return ret;
   5.296 @@ -622,38 +451,35 @@
   5.297    GstFlowReturn ret = GST_FLOW_OK;
   5.298    GstBuffer *buf = NULL;
   5.299    nuv_frame_header *h = nuv->fh;
   5.300 -  
   5.301 -  gint64 table_timecode = 0;
   5.302  
   5.303    if (h->i_type == 'R')
   5.304      goto done;
   5.305      
   5.306 -  table_timecode = h->i_timecode;
   5.307 -
   5.308 -  /* append the frame's header timecode field, and the actual offset */
   5.309 -  if ( h->i_type == 'V' ) 
   5.310 -  	gst_nuv_demux_index_append( nuv, h->i_timecode, nuv->video_offset );
   5.311 -  else if ( h->i_type == 'A' ) 
   5.312 -  	gst_nuv_demux_index_append( nuv, h->i_timecode, nuv->audio_offset );  	
   5.313 - 
   5.314    if (h->i_length > 0) {
   5.315  	  ret = gst_nuv_demux_read_bytes (nuv, h->i_length, TRUE, &buf);
   5.316  	  if (ret != GST_FLOW_OK)
   5.317  		  return ret;
   5.318  
   5.319 -	  /* search for a valid timecode in the indexes list (find the nearest valid timecode) */
   5.320 -	  if ( h->i_timecode < 0 ) {
   5.321 -		  /* convert this actual timecode to a valid index in the timecode's table */
   5.322 -		  gint64 pos = gst_nuv_demux_index_convert_time( nuv, h->i_timecode );
   5.323 +      if ((h->i_type == 'V') || (h->i_type == 'A')) {
   5.324 +        if (h->i_timecode < 0) {
   5.325 +            nuv->last_time = 1;
   5.326 +            h->i_timecode = 0;
   5.327 +        }
   5.328 +        else if (nuv->last_time == 1)
   5.329 +        {
   5.330 +          nuv->last_time = 0;
   5.331 +          gst_pad_push_event (nuv->src_video_pad,
   5.332 +              gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, 
   5.333 +              		GST_CLOCK_TIME_NONE, 0));
   5.334  
   5.335 -		  /* just get the timecode from the timecode's table */		  
   5.336 -		  table_timecode = nuv->index_entries->idx[pos].i_time * GST_MSECOND;
   5.337 -	  } else {  
   5.338 -			table_timecode = h->i_timecode * GST_MSECOND;
   5.339 -	  }
   5.340 -	  
   5.341 -	  GST_BUFFER_TIMESTAMP (buf) = table_timecode;
   5.342 -  }  
   5.343 +          gst_pad_push_event (nuv->src_audio_pad,
   5.344 +              gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, 
   5.345 +              		GST_CLOCK_TIME_NONE, 0));
   5.346 +        }
   5.347 +
   5.348 +        GST_BUFFER_TIMESTAMP (buf) = h->i_timecode * GST_MSECOND;
   5.349 +      }    
   5.350 +  }
   5.351  
   5.352    switch (h->i_type) {
   5.353      case 'V':
   5.354 @@ -664,14 +490,13 @@
   5.355        if ( !gst_pad_is_linked( nuv->src_video_pad ) )
   5.356        	break;
   5.357        
   5.358 -      //GST_PAD_STREAM_LOCK(nuv->src_video_pad);
   5.359 -      
   5.360        GST_BUFFER_SIZE (buf) = h->i_length;
   5.361        gst_buffer_set_caps (buf, GST_PAD_CAPS (nuv->src_video_pad));
   5.362        ret = gst_pad_push (nuv->src_video_pad, buf);
   5.363 -      nuv->video_offset += h->i_length;
   5.364 -      
   5.365 -      //GST_PAD_STREAM_UNLOCK(nuv->src_video_pad);
   5.366 +      if (ret != GST_FLOW_OK) {
   5.367 +        GST_WARNING_OBJECT (nuv, "error pushing on srcpad %s, is linked? = %d",
   5.368 +            gst_pad_get_name (nuv->src_video_pad), gst_pad_is_linked (nuv->src_video_pad));
   5.369 +      }
   5.370        break;
   5.371      }
   5.372      case 'A':
   5.373 @@ -682,42 +507,41 @@
   5.374        if ( !gst_pad_is_linked( nuv->src_audio_pad ) )
   5.375        	break;
   5.376          
   5.377 -      //GST_PAD_STREAM_LOCK(nuv->src_audio_pad);
   5.378 -      
   5.379        GST_BUFFER_SIZE (buf) = h->i_length;
   5.380        gst_buffer_set_caps (buf, GST_PAD_CAPS (nuv->src_audio_pad));
   5.381        ret = gst_pad_push (nuv->src_audio_pad, buf);
   5.382 -      nuv->audio_offset += h->i_length;
   5.383 -      
   5.384 -      //GST_PAD_STREAM_UNLOCK(nuv->src_audio_pad);
   5.385 +      if (ret != GST_FLOW_OK) {
   5.386 +        GST_WARNING_OBJECT (nuv, "Error pushing on srcpad %s, is linked? = %d",
   5.387 +            gst_pad_get_name (nuv->src_audio_pad), gst_pad_is_linked (nuv->src_audio_pad));
   5.388 +      }
   5.389        break;
   5.390      }
   5.391      case 'S':
   5.392      {
   5.393        switch (h->i_compression) {
   5.394          case 'V':
   5.395 -		      if ( !gst_pad_is_linked( nuv->src_video_pad ) )
   5.396 -		      	break;
   5.397 +		  if ( !gst_pad_is_linked( nuv->src_video_pad ) )
   5.398 +		    break;
   5.399  
   5.400 -        	//GST_PAD_STREAM_LOCK(nuv->src_video_pad);
   5.401 +          GST_DEBUG_OBJECT (nuv, "sending new video segment: %d", h->i_timecode);
   5.402            gst_pad_push_event (nuv->src_video_pad,
   5.403 -              gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, table_timecode, 
   5.404 +              gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, h->i_timecode * GST_MSECOND, 
   5.405                		GST_CLOCK_TIME_NONE, 0));
   5.406 -          //GST_PAD_STREAM_UNLOCK(nuv->src_video_pad);
   5.407            break;
   5.408          case 'A':        
   5.409  		      if ( !gst_pad_is_linked( nuv->src_audio_pad ) )
   5.410  		      	break;
   5.411  
   5.412 -        	//GST_PAD_STREAM_LOCK(nuv->src_audio_pad);
   5.413 +          GST_DEBUG_OBJECT (nuv, "sending new audio segment: %d", h->i_timecode);
   5.414            gst_pad_push_event (nuv->src_audio_pad,
   5.415 -              gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, table_timecode, 
   5.416 +              gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, 
   5.417                		GST_CLOCK_TIME_NONE, 0));
   5.418 -          //GST_PAD_STREAM_UNLOCK(nuv->src_audio_pad);
   5.419            break;
   5.420          default:
   5.421            break;
   5.422        }
   5.423 +      if (buf != NULL)
   5.424 +        gst_buffer_unref (buf);
   5.425      }
   5.426      default:
   5.427        if (buf != NULL)
   5.428 @@ -743,7 +567,7 @@
   5.429        gst_nuv_demux_read_bytes (nuv, nuv->mpeg_data_size, TRUE,
   5.430        &nuv->mpeg_buffer);
   5.431    if (ret != GST_FLOW_OK) {
   5.432 -    return ret; //GST_FLOW_ERROR;
   5.433 +    return ret; 
   5.434    }
   5.435    GST_BUFFER_SIZE (nuv->mpeg_buffer) = nuv->mpeg_data_size;
   5.436    nuv->state = GST_NUV_DEMUX_EXTEND_HEADER;
   5.437 @@ -904,7 +728,7 @@
   5.438  
   5.439      case GST_NUV_DEMUX_MOVI:
   5.440        res = gst_nuv_demux_stream_data (nuv);
   5.441 -      if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA) && (res != GST_FLOW_CUSTOM_ERROR)) {
   5.442 +      if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
   5.443          goto pause;
   5.444        }
   5.445        break;
   5.446 @@ -959,11 +783,14 @@
   5.447    if (nuv->mode == 0) {
   5.448      ret = gst_pad_pull_range (nuv->sinkpad, nuv->offset, size, buffer);
   5.449      if (ret == GST_FLOW_OK) {
   5.450 -    		if (move) {
   5.451 -					nuv->offset += size;
   5.452 -				}    	
   5.453 +        if (move) {
   5.454 +		    nuv->offset += size;
   5.455 +		}
   5.456        /* got eos */
   5.457      } else if (ret == GST_FLOW_UNEXPECTED) {
   5.458 +      if (buffer != NULL)
   5.459 +          gst_buffer_unref (buffer);
   5.460 +      
   5.461        gst_nuv_demux_send_eos (nuv);
   5.462        return GST_FLOW_WRONG_STATE;
   5.463      }
   5.464 @@ -972,17 +799,17 @@
   5.465        return GST_FLOW_ERROR_NO_DATA;
   5.466  
   5.467      if (move) {
   5.468 -      *buffer = gst_adapter_take_buffer (nuv->adapter, size);
   5.469 +      guint8 *data = NULL;
   5.470 +      data = (guint8 *) gst_adapter_take (nuv->adapter, size);
   5.471 +      *buffer = gst_buffer_new ();
   5.472 +      gst_buffer_set_data (*buffer, data, size);
   5.473      } else {
   5.474        guint8 *data = NULL;
   5.475 -
   5.476        data = (guint8 *) gst_adapter_peek (nuv->adapter, size);
   5.477        *buffer = gst_buffer_new ();
   5.478        gst_buffer_set_data (*buffer, data, size);
   5.479      }
   5.480    }
   5.481 -  
   5.482 -	
   5.483    return ret;
   5.484  }
   5.485  
   5.486 @@ -1009,7 +836,6 @@
   5.487      }
   5.488      res = gst_pad_activate_push (sinkpad, TRUE);
   5.489    }
   5.490 -
   5.491    g_object_unref (nuv);
   5.492    return res;
   5.493  }
   5.494 @@ -1029,6 +855,22 @@
   5.495    return TRUE;
   5.496  }
   5.497  
   5.498 +static gboolean
   5.499 +gst_nuv_demux_sink_activate_push (GstPad * pad, gboolean active)
   5.500 +{
   5.501 +  GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
   5.502 +
   5.503 +  if (active) {
   5.504 +    GST_DEBUG_OBJECT (nuv, "activating push/chain function");
   5.505 +  } else {
   5.506 +    GST_DEBUG_OBJECT (nuv, "deactivating push/chain function");
   5.507 +  }
   5.508 +
   5.509 +  gst_object_unref (nuv);
   5.510 +
   5.511 +  return TRUE;
   5.512 +}
   5.513 +
   5.514  static GstFlowReturn
   5.515  gst_nuv_demux_chain (GstPad * pad, GstBuffer * buf)
   5.516  {
   5.517 @@ -1036,6 +878,8 @@
   5.518  
   5.519    gst_adapter_push (nuv->adapter, buf);
   5.520  
   5.521 +  gst_object_unref (nuv);
   5.522 +
   5.523    return gst_nuv_demux_play (pad);
   5.524  }
   5.525  
   5.526 @@ -1051,8 +895,7 @@
   5.527    nuv->state = GST_NUV_DEMUX_START;
   5.528    nuv->mode = 0;
   5.529    nuv->offset = 0;
   5.530 -  nuv->video_offset = 0;
   5.531 -  nuv->audio_offset = 0;
   5.532 +  nuv->last_time = 0;
   5.533  
   5.534    if (nuv->adapter != NULL)
   5.535      gst_adapter_clear (nuv->adapter);
     6.1 --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h	Thu Nov 09 20:22:45 2006 +0000
     6.2 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h	Fri Nov 10 19:21:45 2006 +0000
     6.3 @@ -156,20 +156,17 @@
     6.4  
     6.5    guint         mode;
     6.6    GstAdapter    *adapter; 
     6.7 -  guint64       video_offset;
     6.8 -  guint64       audio_offset;
     6.9  
    6.10    /* pads */
    6.11 -  
    6.12    GstPad        *sinkpad;
    6.13    GstPad        *src_video_pad;  
    6.14    GstPad        *src_audio_pad;
    6.15 -  gboolean      first_video;
    6.16 -  gboolean      first_audio;
    6.17  
    6.18    /* NUV decoding state */
    6.19    GstNuvDemuxState state;
    6.20    guint64        offset;
    6.21 +  guint          last_time;
    6.22 +
    6.23  
    6.24    /* Mpeg ExtraData */
    6.25    guint64       mpeg_data_size;
     7.1 --- a/gst-plugins-nuvdemux/typefind/Makefile.am	Thu Nov 09 20:22:45 2006 +0000
     7.2 +++ b/gst-plugins-nuvdemux/typefind/Makefile.am	Fri Nov 10 19:21:45 2006 +0000
     7.3 @@ -1,14 +1,14 @@
     7.4 -plugin_LTLIBRARIES = libgsttypefindfunctions.la
     7.5 +plugin_LTLIBRARIES = libgsttypefindfunctions_indt.la
     7.6  
     7.7 -libgsttypefindfunctions_la_SOURCES = \
     7.8 +libgsttypefindfunctions_indt_la_SOURCES = \
     7.9  	gsttypefindfunctions.c
    7.10  
    7.11 -libgsttypefindfunctions_la_CFLAGS = \
    7.12 +libgsttypefindfunctions_indt_la_CFLAGS = \
    7.13  	$(GST_CFLAGS)
    7.14  
    7.15 -libgsttypefindfunctions_la_LDFLAGS = \
    7.16 +libgsttypefindfunctions_indt_la_LDFLAGS = \
    7.17  	$(GST_PLUGIN_LDFLAGS) \
    7.18  	$(GST_BASE_LIBS)
    7.19  
    7.20 -libgsttypefindfunctions_la_LIBADD = \
    7.21 +libgsttypefindfunctions_indt_la_LIBADD = \
    7.22  	$(GST_LIBS)