gmyth-stream/gmemcoder/src/gmencoder.c
branchtrunk
changeset 748 bf9dac4bdc5d
parent 712 8d28bf09d12f
child 749 fb471f7af20b
     1.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.c	Fri May 25 14:14:18 2007 +0100
     1.2 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c	Tue Jun 12 22:13:46 2007 +0100
     1.3 @@ -27,7 +27,7 @@
     1.4      gdouble video_fps;
     1.5      gdouble video_rate;
     1.6      guint video_width;
     1.7 -    guint video_height;                        
     1.8 +    guint video_height;
     1.9      gchar* audio_encode;
    1.10      gchar** audio_encode_prop;
    1.11      guint audio_rate;
    1.12 @@ -35,80 +35,80 @@
    1.13  
    1.14  
    1.15  struct _GMencoderPrivate
    1.16 -{    
    1.17 -	GstElement *pipe;
    1.18 -	GstElement *abin;
    1.19 -	GstElement *vbin;
    1.20 -	GstElement *sink;
    1.21 -	GstElement *src;
    1.22 -	gboolean ready;
    1.23 +{
    1.24 +    GstElement *pipe;
    1.25 +    GstElement *abin;
    1.26 +    GstElement *vbin;
    1.27 +    GstElement *sink;
    1.28 +    GstElement *src;
    1.29 +    gboolean ready;
    1.30      SetupInfo *info;
    1.31      GstClockTime videot;
    1.32      GstClockTime audiot;
    1.33      gint fd;
    1.34 -	gint sources;
    1.35 -	gint tick_id;
    1.36 -	gint64 duration;
    1.37 +    gint sources;
    1.38 +    gint tick_id;
    1.39 +    gint64 duration;
    1.40  };
    1.41  
    1.42  enum {
    1.43 -  PAUSED,
    1.44 -  PLAYING,
    1.45 -  STOPED,
    1.46 -  EOS,
    1.47 -  ERROR,
    1.48 -  LAST_SIGNAL
    1.49 +    PAUSED,
    1.50 +    PLAYING,
    1.51 +    STOPED,
    1.52 +    EOS,
    1.53 +    ERROR,
    1.54 +    LAST_SIGNAL
    1.55  };
    1.56  
    1.57  static void g_mencoder_class_init       (GMencoderClass *klass);
    1.58  static void g_mencoder_init             (GMencoder *object);
    1.59 -static void g_mencoder_dispose  	    (GObject *object);
    1.60 -static void g_mencoder_finalize 	    (GObject *object);
    1.61 +static void g_mencoder_dispose  	(GObject *object);
    1.62 +static void g_mencoder_finalize 	(GObject *object);
    1.63  static GstElement*
    1.64 -            _create_audio_bin           (const gchar* encode,
    1.65 -                                         gchar** encode_prop,
    1.66 -                                         gint rate);
    1.67 +_create_audio_bin           (const gchar* encode,
    1.68 +                             gchar** encode_prop,
    1.69 +                             gint rate);
    1.70  static GstElement*
    1.71 -            _create_video_bin           (const gchar* encode,
    1.72 -                                        gchar** encode_prop,
    1.73 -                                        gdouble fps,
    1.74 -                                        gint rate,
    1.75 -                                        guint width, 
    1.76 -                                        guint height);
    1.77 +_create_video_bin           (const gchar* encode,
    1.78 +                             gchar** encode_prop,
    1.79 +                             gdouble fps,
    1.80 +                             gint rate,
    1.81 +                             guint width,
    1.82 +                             guint height);
    1.83  
    1.84 -static gboolean 
    1.85 -            _pipeline_bus_cb            (GstBus     *bus,
    1.86 -		                                 GstMessage *msg,
    1.87 -		                                 gpointer    user_data);
    1.88 -static void _decodebin_new_pad_cb 		(GstElement* object,
    1.89 -				                         GstPad* pad,
    1.90 -				                         gboolean flag,
    1.91 -				                         gpointer user_data);
    1.92 +static gboolean
    1.93 +_pipeline_bus_cb            (GstBus     *bus,
    1.94 +                             GstMessage *msg,
    1.95 +                             gpointer    user_data);
    1.96 +
    1.97 +static void _decodebin_new_pad_cb 	(GstElement* object,
    1.98 +                                         GstPad* pad,
    1.99 +                                         gboolean flag,
   1.100 +                                         gpointer user_data);
   1.101 +
   1.102  static void  _decodebin_unknown_type_cb (GstElement* object,
   1.103 -		                         	     GstPad* pad,
   1.104 +                                         GstPad* pad,
   1.105                                           GstCaps* caps,
   1.106                                           gpointer user_data);
   1.107 +
   1.108  static void _close_output              (GMencoder *self);
   1.109  static void _open_output               (GMencoder *self,
   1.110 -                                         const gchar* uri);
   1.111 +                                        const gchar* uri);
   1.112 +
   1.113  static GstElement* _create_source       (const gchar* uri);
   1.114  static GstElement*_create_pipeline      (GMencoder *self,
   1.115 -                                          const gchar* video_encode,
   1.116 -                                          const gchar* mux_name,
   1.117 -                                          gchar** video_encode_prop,
   1.118 -                                          gdouble video_fps,
   1.119 -                                          gdouble video_rate,
   1.120 -                                          guint video_width, 
   1.121 -                                          guint video_height,                         
   1.122 -                                          const gchar* audio_encode,
   1.123 -                                          gchar** audio_encode_prop,
   1.124 -                                          guint audio_rate);
   1.125 -static gboolean _tick_cb 				 (gpointer data);
   1.126 +                                         const gchar* video_encode,
   1.127 +                                         const gchar* mux_name,
   1.128 +                                         gchar** video_encode_prop,
   1.129 +                                         gdouble video_fps,
   1.130 +                                         gdouble video_rate,
   1.131 +                                         guint video_width,
   1.132 +                                         guint video_height,
   1.133 +                                         const gchar* audio_encode,
   1.134 +                                         gchar** audio_encode_prop,
   1.135 +                                         guint audio_rate);
   1.136  
   1.137 -
   1.138 -
   1.139 -
   1.140 -
   1.141 +static gboolean _tick_cb  (gpointer data);
   1.142  
   1.143  static guint g_mencoder_signals[LAST_SIGNAL] = { 0 };
   1.144  
   1.145 @@ -116,78 +116,75 @@
   1.146  
   1.147  static void
   1.148  g_mencoder_class_init (GMencoderClass *klass)
   1.149 -{   
   1.150 -	GObjectClass *object_class;
   1.151 +{
   1.152 +    GObjectClass *object_class;
   1.153 +    object_class = (GObjectClass *) klass;
   1.154 +    g_type_class_add_private (klass, sizeof (GMencoderPrivate));
   1.155  
   1.156 -	object_class = (GObjectClass *) klass;
   1.157 +    object_class->dispose  = g_mencoder_dispose;
   1.158 +    object_class->finalize = g_mencoder_finalize;
   1.159  
   1.160 -	g_type_class_add_private (klass, sizeof (GMencoderPrivate));
   1.161 -        
   1.162 -	object_class->dispose  = g_mencoder_dispose;
   1.163 -	object_class->finalize = g_mencoder_finalize;	
   1.164 -	
   1.165      g_mencoder_signals[PAUSED] =
   1.166          g_signal_new ("paused",
   1.167 -    		  G_OBJECT_CLASS_TYPE (object_class),
   1.168 -    		  G_SIGNAL_RUN_FIRST,
   1.169 -    		  0, NULL, NULL,
   1.170 -    		  g_cclosure_marshal_VOID__VOID,
   1.171 -    		  G_TYPE_NONE, 0);
   1.172 -    		  
   1.173 +                      G_OBJECT_CLASS_TYPE (object_class),
   1.174 +                      G_SIGNAL_RUN_FIRST,
   1.175 +                      0, NULL, NULL,
   1.176 +                      g_cclosure_marshal_VOID__VOID,
   1.177 +                      G_TYPE_NONE, 0);
   1.178 +
   1.179      g_mencoder_signals[PLAYING] =
   1.180          g_signal_new ("playing",
   1.181 -    		  G_OBJECT_CLASS_TYPE (object_class),
   1.182 -    		  G_SIGNAL_RUN_FIRST,
   1.183 -    		  0, NULL, NULL,
   1.184 -              g_cclosure_marshal_VOID__VOID,
   1.185 -    		  G_TYPE_NONE, 0);
   1.186 +                      G_OBJECT_CLASS_TYPE (object_class),
   1.187 +                      G_SIGNAL_RUN_FIRST,
   1.188 +                      0, NULL, NULL,
   1.189 +                      g_cclosure_marshal_VOID__VOID,
   1.190 +                      G_TYPE_NONE, 0);
   1.191  
   1.192      g_mencoder_signals[STOPED] =
   1.193          g_signal_new ("stoped",
   1.194 -    		  G_OBJECT_CLASS_TYPE (object_class),
   1.195 -    		  G_SIGNAL_RUN_FIRST,
   1.196 -    		  0, NULL, NULL,
   1.197 -    		  g_cclosure_marshal_VOID__VOID,
   1.198 -    		  G_TYPE_NONE, 0);
   1.199 +                      G_OBJECT_CLASS_TYPE (object_class),
   1.200 +                      G_SIGNAL_RUN_FIRST,
   1.201 +                      0, NULL, NULL,
   1.202 +                      g_cclosure_marshal_VOID__VOID,
   1.203 +                      G_TYPE_NONE, 0);
   1.204  
   1.205      g_mencoder_signals[EOS] =
   1.206          g_signal_new ("eos",
   1.207 -    		  G_OBJECT_CLASS_TYPE (object_class),
   1.208 -    		  G_SIGNAL_RUN_FIRST,
   1.209 -    		  0, NULL, NULL,
   1.210 -    		  g_cclosure_marshal_VOID__VOID,
   1.211 -    		  G_TYPE_NONE, 0);
   1.212 -    		  
   1.213 -    		  
   1.214 +                      G_OBJECT_CLASS_TYPE (object_class),
   1.215 +                      G_SIGNAL_RUN_FIRST,
   1.216 +                      0, NULL, NULL,
   1.217 +                      g_cclosure_marshal_VOID__VOID,
   1.218 +                      G_TYPE_NONE, 0);
   1.219 +
   1.220      g_mencoder_signals[ERROR] =
   1.221          g_signal_new ("error",
   1.222 -    		  G_OBJECT_CLASS_TYPE (object_class),
   1.223 -    		  G_SIGNAL_RUN_LAST,
   1.224 -    		  0, NULL, NULL,
   1.225 -    		  g_cclosure_marshal_VOID__STRING,
   1.226 -    		  G_TYPE_NONE, 1, G_TYPE_STRING);	
   1.227 +                      G_OBJECT_CLASS_TYPE (object_class),
   1.228 +                      G_SIGNAL_RUN_LAST,
   1.229 +                      0, NULL, NULL,
   1.230 +                      g_cclosure_marshal_VOID__STRING,
   1.231 +                      G_TYPE_NONE, 1, G_TYPE_STRING);
   1.232  }
   1.233  
   1.234  static void
   1.235  g_mencoder_init (GMencoder *self)
   1.236  {
   1.237 -	GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self);
   1.238 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self);
   1.239      priv->info = g_new0 (SetupInfo, 1);
   1.240  }
   1.241  
   1.242 -static void 
   1.243 +static void
   1.244  g_mencoder_dispose (GObject *object)
   1.245  {
   1.246  }
   1.247  
   1.248 -static void 
   1.249 +static void
   1.250  g_mencoder_finalize (GObject *object)
   1.251  {
   1.252      //TODO: clear vars
   1.253 -	g_mencoder_close_stream (G_MENCODER (object));
   1.254 +    g_mencoder_close_stream (G_MENCODER (object));
   1.255  }
   1.256  
   1.257 -GMencoder*  
   1.258 +GMencoder*
   1.259  g_mencoder_new (void)
   1.260  {
   1.261      return g_object_new (G_TYPE_MENCODER, NULL);
   1.262 @@ -195,9 +192,9 @@
   1.263  
   1.264  
   1.265  static void
   1.266 -_obj_set_prop (GObject *obj, 
   1.267 -                const gchar *prop_name,
   1.268 -                const gchar *prop_val)
   1.269 +_obj_set_prop (GObject *obj,
   1.270 +               const gchar *prop_name,
   1.271 +               const gchar *prop_val)
   1.272  {
   1.273      GValue p = {0};
   1.274      GValue v = {0};
   1.275 @@ -215,8 +212,8 @@
   1.276      }
   1.277  
   1.278      g_value_init (&p, s->value_type);
   1.279 -    switch (s->value_type) 
   1.280 -    {
   1.281 +    switch (s->value_type)
   1.282 +        {
   1.283          case G_TYPE_INT:
   1.284              g_value_set_int (&p, atoi (prop_val));
   1.285              break;
   1.286 @@ -225,8 +222,8 @@
   1.287              break;
   1.288          default:
   1.289              return;
   1.290 -    }
   1.291 -       
   1.292 +        }
   1.293 +
   1.294      g_object_set_property (obj, prop_name, &p);
   1.295      g_value_unset (&v);
   1.296      g_value_unset (&p);
   1.297 @@ -234,8 +231,8 @@
   1.298  
   1.299  static GstElement*
   1.300  _create_element_with_prop (const gchar* factory_name,
   1.301 -                            const gchar* element_name,
   1.302 -                            gchar** prop)
   1.303 +                           const gchar* element_name,
   1.304 +                           gchar** prop)
   1.305  {
   1.306      GstElement *ret;
   1.307      int i;
   1.308 @@ -246,13 +243,13 @@
   1.309  
   1.310      if (prop != NULL) {
   1.311          for (i=0; i < g_strv_length (prop); i++) {
   1.312 -			if (prop[i] != NULL) {
   1.313 +            if (prop[i] != NULL) {
   1.314              	char** v = g_strsplit(prop[i], "=", 2);
   1.315              	if (g_strv_length (v) == 2) {
   1.316 -                	_obj_set_prop (G_OBJECT (ret), v[0], v[1]);
   1.317 -            	}	
   1.318 +                    _obj_set_prop (G_OBJECT (ret), v[0], v[1]);
   1.319 +            	}
   1.320              	g_strfreev (v);
   1.321 -			}
   1.322 +            }
   1.323          }
   1.324      }
   1.325  
   1.326 @@ -272,58 +269,58 @@
   1.327      GstElement *aqueue_src = NULL;
   1.328      GstPad *apad = NULL;
   1.329  
   1.330 -    //audio/x-raw-int ! queue ! audioconvert ! faac ! rtpmp4gpay !  udpsink name=upd_audio host=224.0.0.1 port=5002	
   1.331 -	abin 	= gst_bin_new ("abin");
   1.332 -	aqueue	= gst_element_factory_make ("queue", "aqueue");
   1.333 -	aconvert= gst_element_factory_make ("audioconvert", "aconvert");
   1.334 -	aencode = _create_element_with_prop ((encode ? encode : "lame"), "aencode", encode_prop);
   1.335 -	aqueue_src= gst_element_factory_make ("queue", "aqueue_src");	
   1.336 +    //audio/x-raw-int ! queue ! audioconvert ! faac ! rtpmp4gpay !  udpsink name=upd_audio host=224.0.0.1 port=5002
   1.337 +    abin 	= gst_bin_new ("abin");
   1.338 +    aqueue	= gst_element_factory_make ("queue", "aqueue");
   1.339 +    aconvert= gst_element_factory_make ("audioconvert", "aconvert");
   1.340 +    aencode = _create_element_with_prop ((encode ? encode : "lame"), "aencode", encode_prop);
   1.341 +    aqueue_src= gst_element_factory_make ("queue", "aqueue_src");
   1.342  
   1.343 -	if ((abin == NULL) || (aqueue == NULL) || (aconvert == NULL) 
   1.344 -		|| (aencode == NULL) || (aqueue_src == NULL)) {
   1.345 -		g_warning ("Audio elements not found");
   1.346 -		goto error;
   1.347 -	}
   1.348 +    if ((abin == NULL) || (aqueue == NULL) || (aconvert == NULL)
   1.349 +        || (aencode == NULL) || (aqueue_src == NULL)) {
   1.350 +        g_warning ("Audio elements not found");
   1.351 +        goto error;
   1.352 +    }
   1.353  
   1.354      g_object_set (G_OBJECT (aencode), "bitrate", 32, NULL);
   1.355      /*
   1.356 -    if (rate > 0) {
   1.357 -        g_object_set (G_OBJECT (aencode), "bitrate", 32, NULL);
   1.358 -    }
   1.359 +      if (rate > 0) {
   1.360 +      g_object_set (G_OBJECT (aencode), "bitrate", 32, NULL);
   1.361 +      }
   1.362      */
   1.363  
   1.364 -	gst_bin_add_many (GST_BIN (abin), aqueue, aconvert, aencode, aqueue_src, NULL);
   1.365 -	if (gst_element_link_many (aqueue, aconvert, aencode, aqueue_src, NULL) == FALSE) {
   1.366 +    gst_bin_add_many (GST_BIN (abin), aqueue, aconvert, aencode, aqueue_src, NULL);
   1.367 +    if (gst_element_link_many (aqueue, aconvert, aencode, aqueue_src, NULL) == FALSE) {
   1.368          g_warning ("Not Link audio elements");
   1.369      }
   1.370  
   1.371 -    //TODO: apply audio rate 
   1.372 +    //TODO: apply audio rate
   1.373  
   1.374 -	// ghost pad the audio bin
   1.375 -   	apad = gst_element_get_pad (aqueue, "sink");
   1.376 -   	gst_element_add_pad (abin, gst_ghost_pad_new("sink", apad));
   1.377 -	gst_object_unref (apad);
   1.378 -	
   1.379 -   	apad = gst_element_get_pad (aqueue_src, "src");
   1.380 -   	gst_element_add_pad (abin, gst_ghost_pad_new("src", apad));
   1.381 +    // ghost pad the audio bin
   1.382 +    apad = gst_element_get_pad (aqueue, "sink");
   1.383 +    gst_element_add_pad (abin, gst_ghost_pad_new("sink", apad));
   1.384 +    gst_object_unref (apad);
   1.385 +
   1.386 +    apad = gst_element_get_pad (aqueue_src, "src");
   1.387 +    gst_element_add_pad (abin, gst_ghost_pad_new("src", apad));
   1.388      gst_object_unref (apad);
   1.389  
   1.390      return abin;
   1.391 -error:
   1.392 -   	if (abin != NULL)
   1.393 -		gst_object_unref (abin);
   1.394 +  error:
   1.395 +    if (abin != NULL)
   1.396 +        gst_object_unref (abin);
   1.397  
   1.398 -	if (aqueue != NULL)
   1.399 -		gst_object_unref (aqueue);
   1.400 +    if (aqueue != NULL)
   1.401 +        gst_object_unref (aqueue);
   1.402  
   1.403 -	if (aconvert != NULL)
   1.404 -		gst_object_unref (aconvert);
   1.405 +    if (aconvert != NULL)
   1.406 +        gst_object_unref (aconvert);
   1.407  
   1.408 -	if (aencode != NULL)
   1.409 -		gst_object_unref (aencode);
   1.410 +    if (aencode != NULL)
   1.411 +        gst_object_unref (aencode);
   1.412  
   1.413 -	if (aqueue_src != NULL)
   1.414 -		gst_object_unref (aqueue_src);
   1.415 +    if (aqueue_src != NULL)
   1.416 +        gst_object_unref (aqueue_src);
   1.417  
   1.418      if (apad != NULL)
   1.419          gst_object_unref (apad);
   1.420 @@ -337,11 +334,11 @@
   1.421  //queue ! videoscale ! video/x-raw-yuv,width=240,height=144 ! colorspace ! rate ! encode ! queue
   1.422  static GstElement*
   1.423  _create_video_bin (const gchar* encode,
   1.424 -                    gchar** encode_prop,
   1.425 -                    gdouble fps,
   1.426 -                    gint rate,
   1.427 -                    guint width, 
   1.428 -                    guint height)
   1.429 +                   gchar** encode_prop,
   1.430 +                   gdouble fps,
   1.431 +                   gint rate,
   1.432 +                   guint width,
   1.433 +                   guint height)
   1.434  {
   1.435      GstElement *vbin = NULL;
   1.436      GstElement *vqueue = NULL;
   1.437 @@ -351,38 +348,37 @@
   1.438      GstElement *vrate = NULL;
   1.439      GstPad *vpad = NULL;
   1.440  
   1.441 -	vbin    = gst_bin_new ("vbin");
   1.442 -	vqueue	= gst_element_factory_make ("queue", "vqueue");
   1.443 -	vcolorspace = gst_element_factory_make ("ffmpegcolorspace", "colorspace");
   1.444 +    vbin    = gst_bin_new ("vbin");
   1.445 +    vqueue	= gst_element_factory_make ("queue", "vqueue");
   1.446 +    vcolorspace = gst_element_factory_make ("ffmpegcolorspace", "colorspace");
   1.447  
   1.448 -	vencode = _create_element_with_prop (
   1.449 -            (encode != NULL ? encode : "ffenc_mpeg1video"), 
   1.450 -            "vencode", encode_prop);
   1.451 -	vqueue_src = gst_element_factory_make ("queue", "queue_src");
   1.452 +    vencode = _create_element_with_prop (
   1.453 +        (encode != NULL ? encode : "ffenc_mpeg1video"),
   1.454 +        "vencode", encode_prop);
   1.455 +    vqueue_src = gst_element_factory_make ("queue", "queue_src");
   1.456  
   1.457 -	if ((vbin == NULL) || (vqueue == NULL) || (vcolorspace == NULL) 
   1.458 -		|| (vencode == NULL) || (vqueue_src == NULL)) {
   1.459 -		g_warning ("Video elements not found");
   1.460 -		goto error;
   1.461 -	}
   1.462 -		
   1.463 -	gst_bin_add_many (GST_BIN (vbin), vqueue, vcolorspace, vencode, vqueue_src, NULL);
   1.464 +    if ((vbin == NULL) || (vqueue == NULL) || (vcolorspace == NULL)
   1.465 +        || (vencode == NULL) || (vqueue_src == NULL)) {
   1.466 +        g_warning ("Video elements not found");
   1.467 +        goto error;
   1.468 +    }
   1.469  
   1.470 -	
   1.471 -    if ((width > 0) && (height > 0)) {        
   1.472 +    gst_bin_add_many (GST_BIN (vbin), vqueue, vcolorspace, vencode, vqueue_src, NULL);
   1.473 +
   1.474 +    if ((width > 0) && (height > 0)) {
   1.475          //Scalling video
   1.476          GstCaps *vcaps;
   1.477 -	    GstElement *vscale  = gst_element_factory_make ("videoscale", "vscale");
   1.478 +        GstElement *vscale  = gst_element_factory_make ("videoscale", "vscale");
   1.479  
   1.480          gst_bin_add (GST_BIN (vbin), vscale);
   1.481  
   1.482          vcaps = gst_caps_new_simple ("video/x-raw-yuv",
   1.483 -                           "width", G_TYPE_INT, width,
   1.484 -                           "height", G_TYPE_INT, height,                           
   1.485 -                           NULL);
   1.486 +                                     "width", G_TYPE_INT, width,
   1.487 +                                     "height", G_TYPE_INT, height,
   1.488 +                                     NULL);
   1.489  
   1.490          gst_element_link (vqueue, vscale);
   1.491 -					   	
   1.492 +
   1.493          if (gst_element_link_filtered (vscale, vcolorspace, vcaps) == FALSE) {
   1.494              g_warning ("Fail to resize video");
   1.495              gst_object_unref (vcaps);
   1.496 @@ -393,7 +389,6 @@
   1.497      } else {
   1.498          gst_element_link (vqueue, vcolorspace);
   1.499      }
   1.500 -    
   1.501  
   1.502      if (fps > 0) {
   1.503          //Changing the video fps
   1.504 @@ -403,16 +398,16 @@
   1.505          gst_bin_add (GST_BIN (vbin), vrate);
   1.506  
   1.507      	if (gst_element_link (vcolorspace, vrate) == FALSE) {
   1.508 -	        g_warning ("Fail to link video elements");
   1.509 -	        goto error;
   1.510 +            g_warning ("Fail to link video elements");
   1.511 +            goto error;
   1.512      	}
   1.513  
   1.514      	vcaps = gst_caps_new_simple ("video/x-raw-yuv",
   1.515 -					   "framerate", GST_TYPE_FRACTION,  (int) (fps * 1000), 1000, NULL);
   1.516 +                                     "framerate", GST_TYPE_FRACTION,  (int) (fps * 1000), 1000, NULL);
   1.517  
   1.518 -        if (gst_element_link_filtered (vrate, vencode, vcaps) == FALSE) { 
   1.519 -           g_warning ("Fail to link vrate with vencode.");
   1.520 -           goto error;
   1.521 +        if (gst_element_link_filtered (vrate, vencode, vcaps) == FALSE) {
   1.522 +            g_warning ("Fail to link vrate with vencode.");
   1.523 +            goto error;
   1.524          }
   1.525          gst_caps_unref (vcaps);
   1.526      } else {
   1.527 @@ -421,35 +416,35 @@
   1.528              goto error;
   1.529          }
   1.530      }
   1.531 -    
   1.532 +
   1.533      gst_element_link (vencode, vqueue_src);
   1.534  
   1.535 -	// ghost pad the video  bin
   1.536 -   	vpad = gst_element_get_pad (vqueue, "sink");
   1.537 -   	gst_element_add_pad (vbin, gst_ghost_pad_new ("sink", vpad));	
   1.538 -	gst_object_unref (vpad);
   1.539 -	
   1.540 -   	vpad = gst_element_get_pad (vqueue_src, "src");
   1.541 -   	gst_element_add_pad (vbin, gst_ghost_pad_new ("src", vpad));	
   1.542 -	gst_object_unref (vpad);
   1.543 +    // ghost pad the video  bin
   1.544 +    vpad = gst_element_get_pad (vqueue, "sink");
   1.545 +    gst_element_add_pad (vbin, gst_ghost_pad_new ("sink", vpad));
   1.546 +    gst_object_unref (vpad);
   1.547 +
   1.548 +    vpad = gst_element_get_pad (vqueue_src, "src");
   1.549 +    gst_element_add_pad (vbin, gst_ghost_pad_new ("src", vpad));
   1.550 +    gst_object_unref (vpad);
   1.551  
   1.552      return vbin;
   1.553  
   1.554 -error:
   1.555 +  error:
   1.556      if (vpad != NULL)
   1.557          gst_object_unref (vpad);
   1.558  
   1.559 -	if (vbin != NULL)
   1.560 -		gst_object_unref (vbin);
   1.561 +    if (vbin != NULL)
   1.562 +        gst_object_unref (vbin);
   1.563  
   1.564 -	if (vqueue != NULL)
   1.565 -		gst_object_unref (vqueue);
   1.566 +    if (vqueue != NULL)
   1.567 +        gst_object_unref (vqueue);
   1.568  
   1.569 -	if (vencode != NULL)
   1.570 -		gst_object_unref (vencode);
   1.571 +    if (vencode != NULL)
   1.572 +        gst_object_unref (vencode);
   1.573  
   1.574 -	if (vqueue_src != NULL)
   1.575 -		gst_object_unref (vqueue_src);
   1.576 +    if (vqueue_src != NULL)
   1.577 +        gst_object_unref (vqueue_src);
   1.578  
   1.579      if (vcolorspace != NULL)
   1.580          gst_object_unref (vcolorspace);
   1.581 @@ -460,14 +455,14 @@
   1.582  
   1.583  
   1.584  void
   1.585 -g_mencoder_setup_stream (GMencoder *self, 
   1.586 +g_mencoder_setup_stream (GMencoder *self,
   1.587                           const gchar* mux_name,
   1.588                           const gchar* video_encode,
   1.589                           gchar** video_encode_prop,
   1.590                           gdouble video_fps,
   1.591                           gdouble video_rate,
   1.592 -                         guint video_width, 
   1.593 -                         guint video_height,                         
   1.594 +                         guint video_width,
   1.595 +                         guint video_height,
   1.596                           const gchar* audio_encode,
   1.597                           gchar** audio_encode_prop,
   1.598                           guint audio_rate,
   1.599 @@ -482,25 +477,25 @@
   1.600      _close_output (self);
   1.601      _open_output (self, out_uri);
   1.602  
   1.603 -	priv->sources = 0;
   1.604 +    priv->sources = 0;
   1.605      priv->pipe = _create_pipeline (self,
   1.606 -            video_encode,
   1.607 -            mux_name,
   1.608 -            video_encode_prop,
   1.609 -            video_fps,
   1.610 -            video_rate,
   1.611 -            video_width,
   1.612 -            video_height,
   1.613 -            audio_encode,
   1.614 -            audio_encode_prop,
   1.615 -            audio_rate);
   1.616 +                                   video_encode,
   1.617 +                                   mux_name,
   1.618 +                                   video_encode_prop,
   1.619 +                                   video_fps,
   1.620 +                                   video_rate,
   1.621 +                                   video_width,
   1.622 +                                   video_height,
   1.623 +                                   audio_encode,
   1.624 +                                   audio_encode_prop,
   1.625 +                                   audio_rate);
   1.626  
   1.627  }
   1.628  
   1.629  
   1.630  gboolean
   1.631  g_mencoder_append_uri (GMencoder *self,
   1.632 -                     const gchar* uri)
   1.633 +                       const gchar* uri)
   1.634  {
   1.635      GstPad *pad_src;
   1.636      GstPad *pad_sink;
   1.637 @@ -515,14 +510,14 @@
   1.638      g_return_val_if_fail (priv->ready == FALSE, FALSE);
   1.639  
   1.640  #ifndef SUPPORT_MULT_INPUT
   1.641 -	g_return_val_if_fail (priv->sources < 1, FALSE);
   1.642 +    g_return_val_if_fail (priv->sources < 1, FALSE);
   1.643  #endif
   1.644  
   1.645      src = _create_source (uri);
   1.646 -    if (src == NULL) 
   1.647 +    if (src == NULL)
   1.648          return FALSE;
   1.649  
   1.650 -	priv->src = gst_bin_get_by_name (GST_BIN (src), "src");
   1.651 +    priv->src = gst_bin_get_by_name (GST_BIN (src), "src");
   1.652  
   1.653      gst_bin_add (GST_BIN (priv->pipe), src);
   1.654  
   1.655 @@ -535,14 +530,14 @@
   1.656  #endif
   1.657  
   1.658      if ((vp == NULL)  || (ap == NULL)) {
   1.659 -		g_warning  ("Fail to get output bin");
   1.660 +        g_warning  ("Fail to get output bin");
   1.661          goto error;
   1.662 -	}
   1.663 +    }
   1.664  
   1.665      pad_src = gst_element_get_pad (src, "src_audio");
   1.666 -    pad_sink = gst_element_get_compatible_pad (ap, 
   1.667 -            pad_src, 
   1.668 -            gst_pad_get_caps (pad_src));
   1.669 +    pad_sink = gst_element_get_compatible_pad (ap,
   1.670 +                                               pad_src,
   1.671 +                                               gst_pad_get_caps (pad_src));
   1.672  
   1.673      if ((pad_sink == NULL) || (pad_src == NULL))
   1.674          goto error;
   1.675 @@ -555,9 +550,9 @@
   1.676      gst_object_unref (pad_sink);
   1.677  
   1.678      pad_src = gst_element_get_pad (src, "src_video");
   1.679 -    pad_sink = gst_element_get_compatible_pad (vp, 
   1.680 -            pad_src, 
   1.681 -            gst_pad_get_caps (pad_src));
   1.682 +    pad_sink = gst_element_get_compatible_pad (vp,
   1.683 +                                               pad_src,
   1.684 +                                               gst_pad_get_caps (pad_src));
   1.685  
   1.686      if ((pad_src == NULL) || (pad_sink == NULL))
   1.687          goto error;
   1.688 @@ -567,16 +562,16 @@
   1.689          goto error;
   1.690      }
   1.691  
   1.692 -	priv->sources++;
   1.693 +    priv->sources++;
   1.694      ret = TRUE;
   1.695 -error:
   1.696 +  error:
   1.697  
   1.698      if ((src != NULL) && (ret == FALSE)) {
   1.699          gst_bin_remove (GST_BIN (priv->pipe), src);
   1.700          gst_object_unref (src);
   1.701      }
   1.702  
   1.703 -    if (ap != NULL) 
   1.704 +    if (ap != NULL)
   1.705          gst_object_unref (ap);
   1.706  
   1.707      if (vp != NULL)
   1.708 @@ -593,9 +588,9 @@
   1.709  
   1.710  
   1.711  
   1.712 -void        
   1.713 +void
   1.714  g_mencoder_remove_uri (GMencoder *self,
   1.715 -                        const gchar* uri)
   1.716 +                       const gchar* uri)
   1.717  {
   1.718      // GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self);
   1.719      //TODO: remove src
   1.720 @@ -605,19 +600,16 @@
   1.721  g_mencoder_play_stream (GMencoder *self)
   1.722  {
   1.723      GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self);
   1.724 -
   1.725      g_return_if_fail (priv->ready == FALSE);
   1.726      priv->ready = TRUE;
   1.727      gst_element_set_state (priv->pipe, GST_STATE_PLAYING);
   1.728 -
   1.729 -	priv->tick_id = g_timeout_add (500, _tick_cb, self);
   1.730 +    priv->tick_id = g_timeout_add (500, _tick_cb, self);
   1.731  }
   1.732  
   1.733  void
   1.734  g_mencoder_pause_stream (GMencoder *self)
   1.735  {
   1.736      GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self);
   1.737 -
   1.738      g_return_if_fail (priv->ready == TRUE);
   1.739      gst_element_set_state (priv->pipe, GST_STATE_PAUSED);
   1.740  }
   1.741 @@ -627,20 +619,19 @@
   1.742  {
   1.743  
   1.744      GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self);
   1.745 +    if (priv->tick_id != 0) {
   1.746 +        g_source_remove (priv->tick_id);
   1.747 +        priv->tick_id = 0;
   1.748 +    }
   1.749  
   1.750 -	if (priv->tick_id != 0) {			
   1.751 -		g_source_remove (priv->tick_id);
   1.752 -		priv->tick_id = 0;
   1.753 -	}
   1.754 -
   1.755 -    if (priv->pipe != NULL) { 
   1.756 -		//TODO: fixe pipeline dispose
   1.757 -		g_debug ("SETING STATE TO NULL");
   1.758 +    if (priv->pipe != NULL) {
   1.759 +        //TODO: fixe pipeline dispose
   1.760 +        g_debug ("SETING STATE TO NULL");
   1.761          //gst_element_set_state (priv->pipe, GST_STATE_NULL);
   1.762 -		g_debug ("SETING STATE TO NULL: OK");
   1.763 +        g_debug ("SETING STATE TO NULL: OK");
   1.764          //gst_object_unref (priv->pipe);
   1.765          gst_object_unref (priv->src);
   1.766 -		priv->src = NULL;
   1.767 +        priv->src = NULL;
   1.768          priv->pipe = NULL;
   1.769          priv->abin = NULL;
   1.770          priv->vbin = NULL;
   1.771 @@ -656,8 +647,8 @@
   1.772                    gchar** video_encode_prop,
   1.773                    gdouble video_fps,
   1.774                    gdouble video_rate,
   1.775 -                  guint video_width, 
   1.776 -                  guint video_height,                         
   1.777 +                  guint video_width,
   1.778 +                  guint video_height,
   1.779                    const gchar* audio_encode,
   1.780                    gchar** audio_encode_prop,
   1.781                    guint audio_rate)
   1.782 @@ -667,22 +658,22 @@
   1.783      GstElement *sink = NULL;
   1.784      GstElement *mux = NULL;
   1.785      GstElement *abin = NULL;
   1.786 -    GstElement *vbin = NULL;    
   1.787 +    GstElement *vbin = NULL;
   1.788      GstElement *queue= NULL;
   1.789      GstPad *aux_pad = NULL;
   1.790      GstPad *mux_pad = NULL;
   1.791  #ifdef SUPPORT_MULT_INPUT
   1.792      GstElement *ap = NULL;
   1.793 -    GstElement *vp = NULL;    
   1.794 +    GstElement *vp = NULL;
   1.795  #endif
   1.796      GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self);
   1.797  
   1.798 -	pipe = gst_pipeline_new ("pipe");
   1.799 +    pipe = gst_pipeline_new ("pipe");
   1.800  
   1.801 -#ifdef SUPPORT_MULT_INPUT			
   1.802 -	ap = gst_element_factory_make ("concatmux", "ap");
   1.803 +#ifdef SUPPORT_MULT_INPUT
   1.804 +    ap = gst_element_factory_make ("concatmux", "ap");
   1.805      vp = gst_element_factory_make ("concatmux", "vp");
   1.806 -	gst_bin_add_many (GST_BIN (pipe), ap, vp, NULL);
   1.807 +    gst_bin_add_many (GST_BIN (pipe), ap, vp, NULL);
   1.808  #endif
   1.809  
   1.810      mux = gst_element_factory_make ((mux_name ? mux_name : "ffmux_mpeg"), "mux");
   1.811 @@ -696,10 +687,10 @@
   1.812      if (sink == NULL)
   1.813          goto error;
   1.814  
   1.815 -    g_object_set (G_OBJECT(sink), 
   1.816 -			"fd", priv->fd,
   1.817 -			"sync", FALSE,
   1.818 -            NULL);
   1.819 +    g_object_set (G_OBJECT(sink),
   1.820 +                  "fd", priv->fd,
   1.821 +                  "sync", FALSE,
   1.822 +                  NULL);
   1.823  
   1.824      abin = _create_audio_bin (audio_encode, audio_encode_prop, audio_rate);
   1.825      if (abin == NULL)
   1.826 @@ -709,20 +700,20 @@
   1.827      if (vbin == NULL)
   1.828          goto error;
   1.829  
   1.830 -	// Finish Pipe
   1.831 +    // Finish Pipe
   1.832      gst_bin_add_many (GST_BIN (pipe), abin, vbin, mux, queue, sink, NULL);
   1.833  
   1.834  
   1.835 -#ifdef SUPPORT_MULT_INPUT	
   1.836 -	if (gst_element_link (ap, abin) == FALSE) {
   1.837 -		g_warning ("Fail to link concat and abin");
   1.838 -		goto error;
   1.839 -	}
   1.840 +#ifdef SUPPORT_MULT_INPUT
   1.841 +    if (gst_element_link (ap, abin) == FALSE) {
   1.842 +        g_warning ("Fail to link concat and abin");
   1.843 +        goto error;
   1.844 +    }
   1.845  
   1.846 -	if (gst_element_link (vp, vbin) == FALSE) {
   1.847 -		g_warning ("Fail to link concat and vbin");
   1.848 -	}
   1.849 -#endif	
   1.850 +    if (gst_element_link (vp, vbin) == FALSE) {
   1.851 +        g_warning ("Fail to link concat and vbin");
   1.852 +    }
   1.853 +#endif
   1.854  
   1.855      //Link bins with mux
   1.856      aux_pad = gst_element_get_pad (abin, "src");
   1.857 @@ -735,9 +726,9 @@
   1.858      if (ret != GST_PAD_LINK_OK) {
   1.859          g_warning ("Fail link audio and mux: %d", ret);
   1.860          goto error;
   1.861 -   
   1.862 +
   1.863      }
   1.864 -	gst_object_unref (aux_pad);
   1.865 +    gst_object_unref (aux_pad);
   1.866      gst_object_unref (mux_pad);
   1.867  
   1.868      aux_pad = gst_element_get_pad (vbin, "src");
   1.869 @@ -759,16 +750,16 @@
   1.870      //Link mux with sink
   1.871      gst_element_link_many (mux, queue, sink, NULL);
   1.872  
   1.873 -	bus = gst_pipeline_get_bus (GST_PIPELINE (pipe));
   1.874 -	gst_bus_add_watch (bus, _pipeline_bus_cb, self);
   1.875 -	gst_object_unref (bus);
   1.876 +    bus = gst_pipeline_get_bus (GST_PIPELINE (pipe));
   1.877 +    gst_bus_add_watch (bus, _pipeline_bus_cb, self);
   1.878 +    gst_object_unref (bus);
   1.879      return pipe;
   1.880 -	
   1.881 -error:
   1.882 -	g_warning ("Invalid uri");
   1.883  
   1.884 -	if (pipe != NULL) {
   1.885 -		gst_object_unref (pipe);
   1.886 +  error:
   1.887 +    g_warning ("Invalid uri");
   1.888 +
   1.889 +    if (pipe != NULL) {
   1.890 +        gst_object_unref (pipe);
   1.891      }
   1.892  
   1.893  
   1.894 @@ -784,8 +775,8 @@
   1.895          gst_object_unref (mux_pad);
   1.896      }
   1.897  
   1.898 -	if (sink != NULL) {
   1.899 -		gst_object_unref (sink);
   1.900 +    if (sink != NULL) {
   1.901 +        gst_object_unref (sink);
   1.902      }
   1.903  
   1.904      if (abin != NULL) {
   1.905 @@ -796,14 +787,13 @@
   1.906          gst_object_unref (vbin);
   1.907      }
   1.908  
   1.909 -	return FALSE;
   1.910 +    return FALSE;
   1.911  }
   1.912  
   1.913  
   1.914  static void
   1.915  _close_output (GMencoder *self)
   1.916  {
   1.917 -    
   1.918  }
   1.919  
   1.920  static GstElement*
   1.921 @@ -821,15 +811,15 @@
   1.922  
   1.923      bsrc = gst_bin_new (NULL);
   1.924  
   1.925 -	//src = gst_element_factory_make ("gnomevfssrc", "src");
   1.926 +    //src = gst_element_factory_make ("gnomevfssrc", "src");
   1.927      //g_object_set (G_OBJECT (src), "location", uri, NULL);
   1.928 -	src = gst_element_make_from_uri (GST_URI_SRC, uri, "src");
   1.929 -	if (src == NULL) 
   1.930 -		goto error;
   1.931 +    src = gst_element_make_from_uri (GST_URI_SRC, uri, "src");
   1.932 +    if (src == NULL)
   1.933 +        goto error;
   1.934  
   1.935 -	decode = gst_element_factory_make ("decodebin", "decode");
   1.936 -	if (decode == NULL) 
   1.937 -		goto error;
   1.938 +    decode = gst_element_factory_make ("decodebin", "decode");
   1.939 +    if (decode == NULL)
   1.940 +        goto error;
   1.941  
   1.942      queue = gst_element_factory_make ("queue", "queue_src");
   1.943      aqueue = gst_element_factory_make ("queue", "aqueue");
   1.944 @@ -843,48 +833,48 @@
   1.945      gst_bin_add_many (GST_BIN (bsrc), src, queue, decode, aqueue, vqueue, NULL);
   1.946      gst_element_link_many (src, queue, decode, NULL);
   1.947  
   1.948 -	g_signal_connect (G_OBJECT (decode), 
   1.949 -				"new-decoded-pad",
   1.950 -				G_CALLBACK (_decodebin_new_pad_cb),
   1.951 -				bsrc);
   1.952 +    g_signal_connect (G_OBJECT (decode),
   1.953 +                      "new-decoded-pad",
   1.954 +                      G_CALLBACK (_decodebin_new_pad_cb),
   1.955 +                      bsrc);
   1.956  
   1.957 -	g_signal_connect (G_OBJECT (decode),
   1.958 -				"unknown-type",
   1.959 -				G_CALLBACK (_decodebin_unknown_type_cb),
   1.960 -				pipe);
   1.961 +    g_signal_connect (G_OBJECT (decode),
   1.962 +                      "unknown-type",
   1.963 +                      G_CALLBACK (_decodebin_unknown_type_cb),
   1.964 +                      pipe);
   1.965  
   1.966      src_pad = gst_element_get_pad (aqueue, "src");
   1.967 -   	gst_element_add_pad (bsrc, gst_ghost_pad_new("src_audio", src_pad));
   1.968 +    gst_element_add_pad (bsrc, gst_ghost_pad_new("src_audio", src_pad));
   1.969      gst_object_unref (src_pad);
   1.970  
   1.971      src_pad = gst_element_get_pad (vqueue, "src");
   1.972 -   	gst_element_add_pad (bsrc, gst_ghost_pad_new("src_video", src_pad));
   1.973 +    gst_element_add_pad (bsrc, gst_ghost_pad_new("src_video", src_pad));
   1.974      gst_object_unref (src_pad);
   1.975  
   1.976      return bsrc;
   1.977  
   1.978 -error:
   1.979 -	if (src != NULL) {
   1.980 -		gst_object_unref (src);
   1.981 +  error:
   1.982 +    if (src != NULL) {
   1.983 +        gst_object_unref (src);
   1.984      }
   1.985  
   1.986 -	if (decode != NULL) {
   1.987 -		gst_object_unref (decode);
   1.988 +    if (decode != NULL) {
   1.989 +        gst_object_unref (decode);
   1.990      }
   1.991  
   1.992 -	if (aqueue != NULL) {
   1.993 -		gst_object_unref (aqueue);
   1.994 +    if (aqueue != NULL) {
   1.995 +        gst_object_unref (aqueue);
   1.996      }
   1.997  
   1.998 -	if (vqueue != NULL) {
   1.999 -		gst_object_unref (vqueue);
  1.1000 +    if (vqueue != NULL) {
  1.1001 +        gst_object_unref (vqueue);
  1.1002      }
  1.1003  
  1.1004      return NULL;
  1.1005  }
  1.1006  
  1.1007  static void
  1.1008 -_open_output (GMencoder *self, 
  1.1009 +_open_output (GMencoder *self,
  1.1010                const gchar* uri)
  1.1011  {
  1.1012      gchar** i;
  1.1013 @@ -907,113 +897,116 @@
  1.1014  		  GstMessage *msg,
  1.1015  		  gpointer    user_data)
  1.1016  {
  1.1017 -	GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (user_data);
  1.1018 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (user_data);
  1.1019  
  1.1020 -	switch (GST_MESSAGE_TYPE (msg)) 
  1.1021 +    switch (GST_MESSAGE_TYPE (msg))
  1.1022  	{
  1.1023 -		case GST_MESSAGE_STATE_CHANGED:
  1.1024 -		{
  1.1025 -			GstState oldstate;
  1.1026 -			GstState newstate;
  1.1027 -			GstState pendingstate;
  1.1028  
  1.1029 +        case GST_MESSAGE_STATE_CHANGED:
  1.1030 +        {
  1.1031 +            GstState oldstate;
  1.1032 +            GstState newstate;
  1.1033 +            GstState pendingstate;
  1.1034  
  1.1035 -			gst_message_parse_state_changed (msg, &oldstate,
  1.1036 -				&newstate, &pendingstate);
  1.1037 +
  1.1038 +            gst_message_parse_state_changed (msg, &oldstate,
  1.1039 +                                             &newstate, &pendingstate);
  1.1040  
  1.1041              if (pendingstate != GST_STATE_VOID_PENDING)
  1.1042                  break;
  1.1043  
  1.1044 -            if ((oldstate == GST_STATE_READY) && 
  1.1045 +            if ((oldstate == GST_STATE_READY) &&
  1.1046                  (newstate == GST_STATE_PAUSED)) {
  1.1047 -                    if (priv->ready) 
  1.1048 -                        g_signal_emit (user_data, g_mencoder_signals[PAUSED], 0);
  1.1049 +                if (priv->ready)
  1.1050 +                    g_signal_emit (user_data, g_mencoder_signals[PAUSED], 0);
  1.1051              } else if ((oldstate == GST_STATE_PAUSED) &&
  1.1052                         (newstate == GST_STATE_PLAYING)) {
  1.1053 -                        g_signal_emit (user_data, g_mencoder_signals[PLAYING], 0);
  1.1054 +                g_signal_emit (user_data, g_mencoder_signals[PLAYING], 0);
  1.1055              } else if ((oldstate == GST_STATE_READY) &&
  1.1056                         (newstate == GST_STATE_NULL)) {
  1.1057 -                        g_signal_emit (user_data, g_mencoder_signals[STOPED], 0);
  1.1058 -            }			
  1.1059 +                g_signal_emit (user_data, g_mencoder_signals[STOPED], 0);
  1.1060 +            }
  1.1061              break;
  1.1062 -		}
  1.1063 -		case GST_MESSAGE_ERROR: 
  1.1064 -		{
  1.1065 -		    GError *error;
  1.1066 -		    gchar *debug;
  1.1067 -		    gchar *err_str;
  1.1068 +        }
  1.1069  
  1.1070 -			if (priv->tick_id != 0) {			
  1.1071 -				g_source_remove (priv->tick_id);
  1.1072 -				priv->tick_id = 0;
  1.1073 -			}
  1.1074 -		    
  1.1075 -		    gst_message_parse_error (msg, &error, &debug);
  1.1076 -		    err_str = g_strdup_printf ("Error [%d] %s (%s)", error->code,
  1.1077 -		        error->message,
  1.1078 -		        debug);
  1.1079 +        case GST_MESSAGE_ERROR:
  1.1080 +        {
  1.1081 +            GError *error;
  1.1082 +            gchar *debug;
  1.1083 +            gchar *err_str;
  1.1084 +
  1.1085 +            if (priv->tick_id != 0) {
  1.1086 +                g_source_remove (priv->tick_id);
  1.1087 +                priv->tick_id = 0;
  1.1088 +            }
  1.1089 +
  1.1090 +            gst_message_parse_error (msg, &error, &debug);
  1.1091 +            err_str = g_strdup_printf ("Error [%d] %s (%s)", error->code,
  1.1092 +                                       error->message,
  1.1093 +                                       debug);
  1.1094              priv->ready = FALSE;
  1.1095 -		    g_signal_emit (user_data, g_mencoder_signals[ERROR], 0, err_str);
  1.1096 -		    g_free (err_str);
  1.1097 -		    g_clear_error (&error);
  1.1098 -		    g_free (debug);
  1.1099 -		    break;
  1.1100 -		}
  1.1101 -		
  1.1102 -		case GST_MESSAGE_EOS:
  1.1103 +            g_signal_emit (user_data, g_mencoder_signals[ERROR], 0, err_str);
  1.1104 +            g_free (err_str);
  1.1105 +            g_clear_error (&error);
  1.1106 +            g_free (debug);
  1.1107 +            break;
  1.1108 +        }
  1.1109 +
  1.1110 +        case GST_MESSAGE_EOS:
  1.1111              priv->ready = FALSE;
  1.1112 -		    g_signal_emit (user_data, g_mencoder_signals[EOS], 0);
  1.1113 -		    break;		
  1.1114 -		case GST_MESSAGE_DURATION:
  1.1115 -		{
  1.1116 -			GstFormat format;
  1.1117 -			gint64 duration;
  1.1118 -			gst_message_parse_duration (msg, &format, &duration);
  1.1119 -			if (format == GST_FORMAT_BYTES)
  1.1120 -				priv->duration = duration;
  1.1121 -			break;
  1.1122 -		}
  1.1123 -		default:
  1.1124 -		{
  1.1125 -			break;
  1.1126 -		}
  1.1127 +            g_signal_emit (user_data, g_mencoder_signals[EOS], 0);
  1.1128 +            break;
  1.1129 +
  1.1130 +        case GST_MESSAGE_DURATION:
  1.1131 +        {
  1.1132 +            GstFormat format;
  1.1133 +            gint64 duration;
  1.1134 +            gst_message_parse_duration (msg, &format, &duration);
  1.1135 +            if (format == GST_FORMAT_BYTES)
  1.1136 +                priv->duration = duration;
  1.1137 +            break;
  1.1138 +        }
  1.1139 +        default:
  1.1140 +        {
  1.1141 +            break;
  1.1142 +        }
  1.1143  	}
  1.1144 -	return TRUE;
  1.1145 +    return TRUE;
  1.1146  }
  1.1147  
  1.1148  
  1.1149  
  1.1150 -static void 
  1.1151 +static void
  1.1152  _decodebin_new_pad_cb (GstElement* object,
  1.1153                         GstPad* pad,
  1.1154                         gboolean flag,
  1.1155                         gpointer user_data)
  1.1156  {
  1.1157 -	GstCaps *caps;
  1.1158 -	gchar *str_caps = NULL;
  1.1159 +    GstCaps *caps;
  1.1160 +    gchar *str_caps = NULL;
  1.1161      GstElement *sink_element;
  1.1162      GstPad *sink_pad;
  1.1163  
  1.1164 -	caps = gst_pad_get_caps (pad);
  1.1165 -	str_caps = gst_caps_to_string (caps);
  1.1166 -	if (strstr (str_caps, "audio") != NULL) {
  1.1167 +    caps = gst_pad_get_caps (pad);
  1.1168 +    str_caps = gst_caps_to_string (caps);
  1.1169 +    if (strstr (str_caps, "audio") != NULL) {
  1.1170          sink_element = gst_bin_get_by_name (GST_BIN (user_data), "aqueue");
  1.1171 -	} else if (strstr (str_caps, "video") != NULL) {
  1.1172 +    } else if (strstr (str_caps, "video") != NULL) {
  1.1173          sink_element = gst_bin_get_by_name (GST_BIN (user_data), "vqueue");
  1.1174 -	} else {
  1.1175 -		g_warning ("invalid caps %s", str_caps);
  1.1176 -	}
  1.1177 +    } else {
  1.1178 +        g_warning ("invalid caps %s", str_caps);
  1.1179 +    }
  1.1180  
  1.1181      sink_pad = gst_element_get_pad (sink_element, "sink");
  1.1182 -	gst_pad_link (pad, sink_pad);
  1.1183 +    gst_pad_link (pad, sink_pad);
  1.1184  
  1.1185      gst_object_unref (sink_element);
  1.1186 -	gst_object_unref (sink_pad);
  1.1187 -	g_free (str_caps);
  1.1188 -	gst_caps_unref (caps);
  1.1189 +    gst_object_unref (sink_pad);
  1.1190 +    g_free (str_caps);
  1.1191 +    gst_caps_unref (caps);
  1.1192  }
  1.1193  
  1.1194 -static void 
  1.1195 +static void
  1.1196  _decodebin_unknown_type_cb (GstElement* object,
  1.1197                              GstPad* pad,
  1.1198                              GstCaps* caps,
  1.1199 @@ -1026,21 +1019,21 @@
  1.1200  static gboolean
  1.1201  _tick_cb (gpointer user_data)
  1.1202  {
  1.1203 -	GstFormat format = GST_FORMAT_BYTES;
  1.1204 -	gint64 cur = 0;
  1.1205 +    GstFormat format = GST_FORMAT_BYTES;
  1.1206 +    gint64 cur = 0;
  1.1207  
  1.1208 -	GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (user_data);
  1.1209 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (user_data);
  1.1210  
  1.1211 -	if (priv->duration == 0) {
  1.1212 -		gint64 d = 0;
  1.1213 -		if (gst_element_query_duration (priv->src, &format, &d))
  1.1214 -			priv->duration = d;
  1.1215 -	}			
  1.1216 +    if (priv->duration == 0) {
  1.1217 +        gint64 d = 0;
  1.1218 +        if (gst_element_query_duration (priv->src, &format, &d))
  1.1219 +            priv->duration = d;
  1.1220 +    }
  1.1221  
  1.1222 -	if (priv->duration != 0) {
  1.1223 -		gst_element_query_position (priv->src, &format, &cur);
  1.1224 -		g_print ("PROGRESS:%lli\n", (99 * cur) / priv->duration); 
  1.1225 -	}
  1.1226 +    if (priv->duration != 0) {
  1.1227 +        gst_element_query_position (priv->src, &format, &cur);
  1.1228 +        g_print ("PROGRESS:%lli\n", (99 * cur) / priv->duration);
  1.1229 +    }
  1.1230  
  1.1231 -	return TRUE;
  1.1232 +    return TRUE;
  1.1233  }