[svn r137] trunk
authorrenatofilho
Wed Nov 29 16:52:27 2006 +0000 (2006-11-29)
branchtrunk
changeset 136a60f905e0412
parent 135 3c5189bfdca6
child 137 9e55f7e4ed6f
[svn r137]
gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c
     1.1 --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Wed Nov 29 13:02:32 2006 +0000
     1.2 +++ b/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c	Wed Nov 29 16:52:27 2006 +0000
     1.3 @@ -747,10 +747,11 @@
     1.4        pad = nuv->priv->src_video_pad;
     1.5  
     1.6        if (nuv->priv->new_video_segment) {
     1.7 +
     1.8          /* send new segment event*/
     1.9 -        gst_pad_push_event (nuv->priv->src_video_pad,
    1.10 -          gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0,
    1.11 -                                     GST_CLOCK_TIME_NONE, 0));
    1.12 +//        gst_pad_push_event (nuv->priv->src_video_pad,
    1.13 +//          gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0,
    1.14 +//                                     GST_CLOCK_TIME_NONE, 0));
    1.15  
    1.16          if (nuv->priv->time_start == GST_CLOCK_TIME_NONE) {
    1.17              nuv->priv->time_start = timestamp;
    1.18 @@ -766,9 +767,9 @@
    1.19  
    1.20        if (nuv->priv->new_audio_segment) {
    1.21          /* send new segment event*/
    1.22 -        gst_pad_push_event (nuv->priv->src_audio_pad,
    1.23 -          gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0,
    1.24 -                                     GST_CLOCK_TIME_NONE, 0));
    1.25 +//        gst_pad_push_event (nuv->priv->src_audio_pad,
    1.26 +//          gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0,
    1.27 +//                                     GST_CLOCK_TIME_NONE, 0));
    1.28  
    1.29          if (nuv->priv->time_start == GST_CLOCK_TIME_NONE) {
    1.30              nuv->priv->time_start = timestamp;
    1.31 @@ -819,6 +820,8 @@
    1.32        ret = gst_pad_push (pad, buf);
    1.33  
    1.34        if (ret != GST_FLOW_OK) {
    1.35 +        GST_WARNING_OBJECT (nuv, "error: %d pushing on srcpad %s", ret, gst_pad_get_name (pad));
    1.36 +
    1.37          if (pad == nuv->priv->src_video_pad) {
    1.38              nuv->priv->last_video_return = ret;
    1.39          }
    1.40 @@ -831,7 +834,7 @@
    1.41              ret = GST_FLOW_OK;
    1.42          }
    1.43  
    1.44 -        GST_WARNING_OBJECT (nuv, "error: %d pushing on srcpad %s", ret, gst_pad_get_name (pad));
    1.45 +        //GST_WARNING_OBJECT (nuv, "error: %d pushing on srcpad %s", ret, gst_pad_get_name (pad));
    1.46        }
    1.47    }
    1.48  
    1.49 @@ -960,58 +963,49 @@
    1.50        if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
    1.51          goto pause;
    1.52        }
    1.53 -      if (nuv->priv->state != GST_NUV_DEMUX_HEADER_DATA)
    1.54 -        break;
    1.55 +      break;
    1.56  
    1.57      case GST_NUV_DEMUX_HEADER_DATA:
    1.58        res = gst_nuv_demux_stream_header_data (nuv);
    1.59        if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
    1.60          goto pause;
    1.61        }
    1.62 -      if (nuv->priv->state != GST_NUV_DEMUX_EXTRA_DATA)
    1.63 -        break;
    1.64 +      break;
    1.65  
    1.66      case GST_NUV_DEMUX_EXTRA_DATA:
    1.67        res = gst_nuv_demux_stream_extra_data (nuv);
    1.68        if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
    1.69          goto pause;
    1.70        }
    1.71 -      if (nuv->priv->state != GST_NUV_DEMUX_MPEG_DATA)
    1.72 -        break;
    1.73 +      break;
    1.74  
    1.75      case GST_NUV_DEMUX_MPEG_DATA:
    1.76        res = gst_nuv_demux_stream_mpeg_data (nuv);
    1.77        if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
    1.78          goto pause;
    1.79        }
    1.80 -
    1.81 -      if (nuv->priv->state != GST_NUV_DEMUX_EXTEND_HEADER)
    1.82 -        break;
    1.83 +      break;
    1.84  
    1.85      case GST_NUV_DEMUX_EXTEND_HEADER:
    1.86        res = gst_nuv_demux_stream_extend_header (nuv);
    1.87        if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
    1.88          goto pause;
    1.89        }
    1.90 -      if (nuv->priv->state != GST_NUV_DEMUX_EXTEND_HEADER_DATA)
    1.91 -        break;
    1.92 +      break;
    1.93  
    1.94      case GST_NUV_DEMUX_EXTEND_HEADER_DATA:
    1.95        res = gst_nuv_demux_stream_extend_header_data (nuv);
    1.96        if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
    1.97          goto pause;
    1.98        }
    1.99 -
   1.100 -      if (nuv->priv->state != GST_NUV_DEMUX_FRAME_HEADER)
   1.101 -        break;
   1.102 +      break;
   1.103  
   1.104      case GST_NUV_DEMUX_FRAME_HEADER:
   1.105        res = gst_nuv_demux_read_head_frame (nuv);
   1.106        if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
   1.107          goto pause;
   1.108        }
   1.109 -      if (nuv->priv->state != GST_NUV_DEMUX_MOVI)
   1.110 -        break;
   1.111 +      break;
   1.112  
   1.113      case GST_NUV_DEMUX_MOVI:
   1.114        res = gst_nuv_demux_stream_data (nuv);
   1.115 @@ -1019,6 +1013,7 @@
   1.116          goto pause;
   1.117        }
   1.118        break;
   1.119 +
   1.120      case GST_NUV_DEMUX_INVALID_DATA:
   1.121        goto pause;
   1.122        break;
   1.123 @@ -1144,7 +1139,6 @@
   1.124  {
   1.125    GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
   1.126  
   1.127 -
   1.128    g_debug ("gst_nuv_demux_sink_activate_push: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx");
   1.129  
   1.130    if (active) {
   1.131 @@ -1234,6 +1228,7 @@
   1.132    GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad));
   1.133  
   1.134    GST_DEBUG_OBJECT (nuv, " gst_nuv_demux_chain function");
   1.135 +  g_debug (" gst_nuv_demux_chain function");
   1.136    gst_adapter_push (nuv->priv->adapter, buf);
   1.137  
   1.138    gst_object_unref (nuv);
   1.139 @@ -1298,8 +1293,9 @@
   1.140  {
   1.141    GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
   1.142  
   1.143 +  g_debug ("TRANSI %d", transition);
   1.144    switch (transition) {
   1.145 -    case GST_STATE_CHANGE_READY_TO_PAUSED:
   1.146 +    case GST_STATE_CHANGE_NULL_TO_READY:
   1.147        g_debug ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxx= RESET");        
   1.148        gst_nuv_demux_reset (GST_NUV_DEMUX (element));
   1.149        gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (element));
   1.150 @@ -1309,8 +1305,10 @@
   1.151    }
   1.152  
   1.153    ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
   1.154 -  if (ret == GST_STATE_CHANGE_FAILURE)
   1.155 +  if (ret == GST_STATE_CHANGE_FAILURE) {
   1.156 +      g_debug ("FFFFFFFFFFFFFFFFFFFFFAAAAAAAAAAAAAAAAAIIIIIIIIIIIIIIIIIILLLLLLLLLLLLLLLLLL");
   1.157      goto done;
   1.158 +  }
   1.159  
   1.160    switch (transition) {
   1.161      case GST_STATE_CHANGE_READY_TO_NULL:
   1.162 @@ -1343,13 +1341,19 @@
   1.163          if (duration_bytes == GST_CLOCK_TIME_NONE)
   1.164              return;
   1.165  
   1.166 -        interval = gst_util_uint64_scale (1, current_timestamp - nuv->priv->time_start, GST_SECOND);
   1.167 -        average = gst_util_uint64_scale (1 , nuv->priv->streamer_offset, interval);
   1.168 -        nuv->priv->duration_average = gst_util_uint64_scale (GST_SECOND, duration_bytes, average);
   1.169 -        nuv->priv->last_update = current_timestamp;
   1.170 -        msg = gst_message_new_duration (GST_OBJECT (nuv), GST_FORMAT_TIME, nuv->priv->duration_average);
   1.171 -        gst_element_post_message (GST_ELEMENT (nuv), msg);
   1.172 -        GST_DEBUG_OBJECT (nuv, "New Duration Average %"G_GUINT64_FORMAT, nuv->priv->duration_average);
   1.173 +        if (current_timestamp > 0) {
   1.174 +            interval = gst_util_uint64_scale (1, current_timestamp - nuv->priv->time_start, GST_SECOND);
   1.175 +            if (interval > 0) {
   1.176 +                average = gst_util_uint64_scale (1 , nuv->priv->streamer_offset, interval);
   1.177 +            }
   1.178 +            if (average > 0) {
   1.179 +                nuv->priv->duration_average = gst_util_uint64_scale (GST_SECOND, duration_bytes, average);
   1.180 +            }
   1.181 +            nuv->priv->last_update = current_timestamp;
   1.182 +            msg = gst_message_new_duration (GST_OBJECT (nuv), GST_FORMAT_TIME, nuv->priv->duration_average);
   1.183 +            gst_element_post_message (GST_ELEMENT (nuv), msg);
   1.184 +            GST_DEBUG_OBJECT (nuv, "New Duration Average %"G_GUINT64_FORMAT, nuv->priv->duration_average);
   1.185 +        }
   1.186      }
   1.187  }
   1.188