[svn r88] Fixes the autotools prefix directory, added do_seek callback to the source.
1.1 --- a/gst-plugins-mythtv/autogen.sh Wed Nov 15 14:37:59 2006 +0000
1.2 +++ b/gst-plugins-mythtv/autogen.sh Wed Nov 15 18:07:23 2006 +0000
1.3 @@ -24,6 +24,8 @@
1.4
1.5 CONFIGURE_DEF_OPT='--enable-maintainer-mode'
1.6
1.7 +CONFIGURE_EXT_OPT="$@"
1.8 +
1.9 autogen_options
1.10
1.11 echo -n "+ check for build tools"
2.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Nov 15 14:37:59 2006 +0000
2.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Nov 15 18:07:23 2006 +0000
2.3 @@ -90,7 +90,9 @@
2.4 static gboolean gst_mythtv_src_start (GstBaseSrc * bsrc);
2.5 static gboolean gst_mythtv_src_stop (GstBaseSrc * bsrc);
2.6 static gboolean gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size);
2.7 -//static gboolean gst_mythtv_src_is_seekable( GstBaseSrc *push_src );
2.8 +static gboolean gst_mythtv_src_is_seekable( GstBaseSrc *push_src );
2.9 +
2.10 +static gboolean gst_mythtv_src_do_seek( GstBaseSrc *base, GstSegment *segment );
2.11
2.12 static gboolean gst_mythtv_src_next_program_chain ( GstMythtvSrc *src );
2.13
2.14 @@ -104,6 +106,8 @@
2.15
2.16 static void gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data);
2.17
2.18 +static gboolean gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query);
2.19 +
2.20 //static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event);
2.21 //static gboolean gst_mythtv_src_query ( GstPad * pad, GstQuery * query );
2.22
2.23 @@ -131,7 +135,7 @@
2.24 GST_BOILERPLATE_FULL (GstMythtvSrc, gst_mythtv_src, GstPushSrc,
2.25 GST_TYPE_PUSH_SRC, _urihandler_init)
2.26
2.27 - static void
2.28 +static void
2.29 gst_mythtv_src_base_init (gpointer g_class)
2.30 {
2.31 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
2.32 @@ -222,9 +226,9 @@
2.33 gstbasesrc_class->start = gst_mythtv_src_start;
2.34 gstbasesrc_class->stop = gst_mythtv_src_stop;
2.35 gstbasesrc_class->get_size = gst_mythtv_src_get_size;
2.36 - //gstbasesrc_class->is_seekable = gst_mythtv_src_is_seekable;
2.37 + gstbasesrc_class->is_seekable = gst_mythtv_src_is_seekable;
2.38
2.39 - //gstbasesrc_class->create = gst_mythtv_src_create;
2.40 + gstbasesrc_class->do_seek = gst_mythtv_src_do_seek;
2.41 gstpushsrc_class->create = gst_mythtv_src_create;
2.42
2.43 GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0,
2.44 @@ -271,16 +275,16 @@
2.45 this->th_mutex = NULL;
2.46
2.47 this->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
2.48 - //gst_pad_set_chain_function ( GST_BASE_SRC_PAD( GST_BASE_SRC( this ) ),
2.49 - // GST_DEBUG_FUNCPTR ( gst_mythtv_src_chain ) );
2.50 gst_element_add_pad (GST_ELEMENT (this), this->srcpad);
2.51
2.52 - //gst_base_src_set_format( GST_BASE_SRC( this ), GST_FORMAT_BYTES );
2.53 + gst_base_src_set_format( GST_BASE_SRC( this ), GST_FORMAT_BYTES );
2.54
2.55 - gst_base_src_set_live ( GST_BASE_SRC( this ), TRUE );
2.56 + //gst_base_src_set_live ( GST_BASE_SRC( this ), TRUE );
2.57
2.58 // gst_pad_set_event_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
2.59 // gst_mythtv_src_handle_event );
2.60 + gst_pad_set_query_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
2.61 + gst_mythtv_src_handle_query );
2.62
2.63 }
2.64
2.65 @@ -338,7 +342,7 @@
2.66 gint len = 0;
2.67 gint8 *data_ptr = g_malloc0( size );
2.68
2.69 - //GST_OBJECT_LOCK(src);
2.70 + GST_OBJECT_LOCK(src);
2.71
2.72 while ( sizetoread > 0 ) {
2.73
2.74 @@ -422,7 +426,7 @@
2.75 src->eos = TRUE;
2.76
2.77 done:
2.78 - //GST_OBJECT_UNLOCK(src);
2.79 + GST_OBJECT_UNLOCK(src);
2.80
2.81 return read;
2.82 }
2.83 @@ -598,13 +602,10 @@
2.84 if ( G_UNLIKELY (src->update_prog_chain) )
2.85 goto change_progchain;
2.86
2.87 - //gint64 new_offset = -1;
2.88 - /* just get from the adapter, no network effort... */
2.89 - //do
2.90 - //{
2.91 - /* Create the buffer. */
2.92 + /* just get from the adapter, no network effort... */
2.93 + /* Create the buffer. */
2.94 ret = gst_pad_alloc_buffer ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
2.95 - GST_BUFFER_OFFSET_NONE, MAX_READ_SIZE,
2.96 + src->read_offset /*GST_BUFFER_OFFSET_NONE*/, MAX_READ_SIZE,
2.97 GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc))), outbuf );
2.98
2.99 if (G_UNLIKELY (ret != GST_FLOW_OK)) {
2.100 @@ -616,7 +617,7 @@
2.101
2.102 read = do_read_request_response ( src, src->read_offset, MAX_READ_SIZE, outbuf );
2.103
2.104 - if (G_UNLIKELY (src->update_prog_chain) )
2.105 + if ( G_UNLIKELY (src->update_prog_chain) )
2.106 goto change_progchain;
2.107
2.108 if (G_UNLIKELY (read <= 0) || *outbuf == NULL) {
2.109 @@ -625,8 +626,6 @@
2.110 else
2.111 goto read_error;
2.112 }
2.113 -
2.114 - //} while ( TRUE );
2.115
2.116 done:
2.117 {
2.118 @@ -695,6 +694,64 @@
2.119
2.120 }
2.121
2.122 +static gboolean
2.123 +gst_mythtv_src_do_seek( GstBaseSrc *base, GstSegment *segment )
2.124 +{
2.125 + GstMythtvSrc *src = GST_MYTHTV_SRC( base );
2.126 + gint64 new_offset = 0;
2.127 + gboolean ret = TRUE;
2.128 +
2.129 + g_print( "[%s]DO Seek called! (start = %lld, stop = %lld)\n", __FUNCTION__, segment->start, segment->stop );
2.130 +
2.131 + /* verify if it needs to seek */
2.132 + if ( src->read_offset != segment->start )
2.133 + {
2.134 +
2.135 + new_offset = gmyth_file_transfer_seek( src->file_transfer, segment->start, SEEK_SET );
2.136 +
2.137 + g_print( "[%s] Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.\n",
2.138 + __FUNCTION__, segment->start, src->read_offset, new_offset );
2.139 + if ( G_UNLIKELY (new_offset < 0 ) )
2.140 + {
2.141 + ret = FALSE;
2.142 + if ( src->live_tv )
2.143 + goto change_progchain;
2.144 + else
2.145 + goto eos;
2.146 + }
2.147 +
2.148 + src->read_offset = new_offset;
2.149 +
2.150 + }
2.151 +
2.152 + return ret;
2.153 +
2.154 +eos:
2.155 + {
2.156 +
2.157 + GST_DEBUG_OBJECT (src, "EOS found on seeking!!!");
2.158 + gst_object_unref( src );
2.159 + return FALSE;
2.160 + }
2.161 +change_progchain:
2.162 + {
2.163 + GST_ELEMENT_ERROR (src, RESOURCE, READ,
2.164 + (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
2.165 + src->uri_name));
2.166 +
2.167 + gst_pad_push_event ( GST_BASE_SRC_PAD (base),
2.168 + gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
2.169 + /* go to the next program chain */
2.170 + src->unique_setup = FALSE;
2.171 + src->update_prog_chain = TRUE;
2.172 +
2.173 + gst_mythtv_src_next_program_chain( src );
2.174 +
2.175 + return TRUE;
2.176 + }
2.177 +
2.178 +}
2.179 +
2.180 #if 0
2.181 static void
2.182 gst_mythtv_src_read_ahead ( void *data ) {
2.183 @@ -814,7 +871,9 @@
2.184 //src->adapter = gst_adapter_new();
2.185 //g_static_rec_mutex_init( src->th_mutex );
2.186 //src->th_read_ahead = gst_task_create( (GstTaskFunction)gst_mythtv_src_read_ahead, src );
2.187 - }
2.188 + }
2.189 + //gst_pad_push_event ( GST_BASE_SRC_PAD (bsrc),
2.190 + // gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, src->content_size, 0 ) );
2.191
2.192 //GST_OBJECT_UNLOCK(src);
2.193
2.194 @@ -946,8 +1005,11 @@
2.195 #endif
2.196
2.197 src->content_size = src->file_transfer->filesize;
2.198 - while ( src->content_size < GMYTHTV_TRANSFER_MAX_BUFFER*4 )
2.199 - src->content_size = gst_mythtv_src_get_position( src );
2.200 + if ( src->live_tv ) {
2.201 + wait_to_transfer = 0;
2.202 + while ( wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS && src->content_size < GMYTHTV_TRANSFER_MAX_BUFFER )
2.203 + src->content_size = gst_mythtv_src_get_position( src );
2.204 + }
2.205
2.206 src->read_offset = 0;
2.207
2.208 @@ -977,74 +1039,6 @@
2.209
2.210 }
2.211
2.212 -#if 0
2.213 -/* handles queries for location in the stream in the requested format */
2.214 -static gboolean
2.215 -gst_mythtv_src_query ( GstPad * pad, GstQuery * query )
2.216 -{
2.217 - gboolean res = TRUE;
2.218 - GstMythtvSrc *mythtv;
2.219 -
2.220 - guint64 size = 0;
2.221 -
2.222 - mythtv = GST_GMYTHTV_SRC( GST_PAD_PARENT (pad) );
2.223 -
2.224 - size = gst_mythtv_src_get_position (mythtv);
2.225 -
2.226 - switch (GST_QUERY_TYPE (query)) {
2.227 -
2.228 - case GST_QUERY_POSITION:
2.229 - {
2.230 -
2.231 - //GstFormat format;
2.232 - gint64 cur = 0;
2.233 -
2.234 - /* save requested format */
2.235 - gst_query_parse_position (query, NULL, &cur);
2.236 -
2.237 - /* query peer for current position in time */
2.238 - g_print( "[%s] Actual size is %s than current size from sink. [ %lld, %lld ]\n", __FUNCTION__,
2.239 - ( size > cur ) ? "greater" : "lower", size, cur );
2.240 - gst_query_set_position (query, GST_FORMAT_BYTES, size);
2.241 - if ( size < cur )
2.242 - goto error;
2.243 -
2.244 - break;
2.245 - }
2.246 - #if 0
2.247 - case GST_QUERY_DURATION:
2.248 - {
2.249 - //GstFormat format;
2.250 - gint64 cur = 0;
2.251 -
2.252 - /* save requested format */
2.253 - gst_query_parse_position (query, NULL, &cur);
2.254 -
2.255 - /* query peer for current position in time */
2.256 - g_print( "[%s] Actual size is %s than current size from sink. [ %lld, %lld ]\n", __FUNCTION__,
2.257 - ( size * GST_SECOND > cur * GST_SECOND ) ? "greater" : "lower", size * GST_SECOND,
2.258 - cur * GST_SECOND );
2.259 - gst_query_set_position (query, GST_FORMAT_TIME, size * GST_SECOND );
2.260 -
2.261 - if ( size * GST_SECOND < cur * GST_SECOND )
2.262 - goto error;
2.263 -
2.264 - break;
2.265 - }
2.266 - #endif
2.267 - default:
2.268 - res = FALSE;
2.269 - break;
2.270 - }
2.271 -
2.272 - return res;
2.273 -
2.274 -error:
2.275 -
2.276 - return FALSE;
2.277 -}
2.278 -#endif
2.279 -
2.280 static gboolean
2.281 gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size)
2.282 {
2.283 @@ -1053,8 +1047,8 @@
2.284 g_print( "[%s] Differs from previous content size: %d (max.: %d)\n", __FUNCTION__,
2.285 abs( src->content_size - src->prev_content_size ), GMYTHTV_TRANSFER_MAX_BUFFER );
2.286
2.287 - if (src->content_size <= 0) {
2.288 - ret= FALSE;
2.289 + if (src->content_size == -1) {
2.290 + //ret= FALSE;
2.291 } else if ( src->live_tv && ( abs( src->content_size - src->bytes_read ) <
2.292 GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
2.293 //g_static_mutex_lock( &update_size_mutex );
2.294 @@ -1090,7 +1084,7 @@
2.295
2.296 *size = src->content_size;
2.297 g_print( "[%s] Content size = %lld\n", __FUNCTION__, src->content_size );
2.298 -
2.299 +
2.300 return ret;
2.301
2.302 }
2.303 @@ -1210,155 +1204,62 @@
2.304 }
2.305 #endif
2.306
2.307 -#if 0
2.308 static gboolean
2.309 gst_mythtv_src_is_seekable( GstBaseSrc *push_src )
2.310 {
2.311 return TRUE;
2.312 }
2.313 +
2.314 +static gboolean
2.315 +gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query)
2.316 +{
2.317 + gboolean res = FALSE;
2.318 + GstMythtvSrc *myth = GST_MYTHTV_SRC (gst_pad_get_parent (pad));
2.319 +
2.320 + switch (GST_QUERY_TYPE (query)) {
2.321 + case GST_QUERY_POSITION:
2.322 + gst_query_set_position (query, GST_FORMAT_BYTES,
2.323 + myth->read_offset );
2.324 + res = TRUE;
2.325 + GST_DEBUG_OBJECT (myth, "POS %d", myth->read_offset);
2.326 + break;
2.327 + case GST_QUERY_DURATION:
2.328 +#if 0
2.329 + if (myth->duration != 0) {
2.330 + gint64 total;
2.331 + gint64 fps;
2.332 +
2.333 + fps = nuv->h->i_fpsn / nuv->h->i_fpsd;
2.334 + total = gst_util_uint64_scale_int (GST_SECOND, nuv->h->i_video_blocks, fps);
2.335 #endif
2.336 -
2.337 -#if 0
2.338 -static GstFlowReturn
2.339 -gst_mythtv_src_file_transfer( GstMythtvSrc *src )
2.340 -{
2.341 - GstFlowReturn ret = GST_FLOW_OK;
2.342 - GstBuffer *buf = NULL;
2.343 - gint read = -1;
2.344 -
2.345 - /* The caller should know the number of bytes and not read beyond EOS. */
2.346 - if ( G_UNLIKELY (src->eos) )
2.347 - goto eos;
2.348 - if ( G_UNLIKELY (src->update_prog_chain) )
2.349 - goto change_progchain;
2.350 -
2.351 - do {
2.352 -
2.353 - /* Create the buffer. */
2.354 - buf = gst_buffer_new_and_alloc (4096);
2.355 -
2.356 - ret = gst_mythtv_src_read_bytes( src, GST_BUFFER_SIZE(buf), TRUE, &buf );
2.357 - if ( ret != GST_FLOW_OK )
2.358 - return ret;
2.359 -
2.360 - read = do_read_request_response ( src, src->read_offset, GST_BUFFER_SIZE(buf), &buf );
2.361 -
2.362 - if (G_UNLIKELY (src->update_prog_chain) )
2.363 - goto change_progchain;
2.364 -
2.365 - if (G_UNLIKELY (read <= 0) || buf == NULL) {
2.366 - if ( src->live_tv )
2.367 - goto change_progchain;
2.368 - else
2.369 - goto read_error;
2.370 - }
2.371 -
2.372 - if ( GST_FLOW_OK != ( ret = gst_pad_push ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)), buf ) ) ) {
2.373 - goto done;
2.374 - }
2.375 -
2.376 - } while(TRUE);
2.377 -
2.378 -done:
2.379 - {
2.380 - const gchar *reason = gst_flow_get_name (ret);
2.381 -
2.382 - GST_DEBUG_OBJECT (src, "DONE task, reason %s", reason);
2.383 - return ret;
2.384 - }
2.385 -eos:
2.386 - {
2.387 - const gchar *reason = gst_flow_get_name (ret);
2.388 -
2.389 - GST_DEBUG_OBJECT (src, "pausing task, reason %s", reason);
2.390 - return GST_FLOW_UNEXPECTED;
2.391 - }
2.392 - /* ERRORS */
2.393 -read_error:
2.394 - {
2.395 - GST_ELEMENT_ERROR (src, RESOURCE, READ,
2.396 - (NULL), ("Could not read any bytes (%i, %s)", read,
2.397 - src->uri_name));
2.398 - return GST_FLOW_ERROR;
2.399 - }
2.400 -change_progchain:
2.401 - {
2.402 - GST_ELEMENT_ERROR (src, RESOURCE, READ,
2.403 - (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
2.404 - src->uri_name));
2.405 - // go to the next program chain
2.406 - src->unique_setup = FALSE;
2.407 - src->update_prog_chain = TRUE;
2.408 - src->mode = GST_MYTHTV_SRC_NEXT_PROGRAM_CHAIN;
2.409 -
2.410 - //GST_OBJECT_LOCK(src);
2.411 - //gst_mythtv_src_next_program_chain( src );
2.412 - //GST_OBJECT_UNLOCK(src);
2.413 - return GST_FLOW_OK;//GST_FLOW_ERROR_NO_DATA;
2.414 - }
2.415 -}
2.416 -
2.417 -static GstFlowReturn
2.418 -gst_mythtv_src_play (GstPad * pad)
2.419 -{
2.420 - GstFlowReturn res = GST_FLOW_OK;
2.421 - GstMythtvSrc *src = GST_MYTHTV_SRC (GST_PAD_PARENT (pad));
2.422 -
2.423 - switch ( src->state ) {
2.424 - case GST_MYTHTV_SRC_FILE_TRANSFER:
2.425 - res = gst_mythtv_src_file_transfer( src );
2.426 - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) {
2.427 - goto pause;
2.428 - }
2.429 - break;
2.430 - case GST_MYTHTV_SRC_NEXT_PROGRAM_CHAIN:
2.431 - src->read_offset = 0;
2.432 - src->bytes_read = 0;
2.433 - src->unique_setup = FALSE;
2.434 - if ( !gst_mythtv_src_next_program_chain( src ) ) {
2.435 - goto pause;
2.436 - }
2.437 - src->state = GST_MYTHTV_SRC_FILE_TRANSFER;
2.438 - break;
2.439 - case GST_MYTHTV_SRC_INVALID_DATA:
2.440 - goto pause;
2.441 + //gst_query_set_duration (query, GST_FORMAT_TIME, myth->content_size);
2.442 + GST_DEBUG_OBJECT (myth, "DURATION %d", myth->content_size);
2.443 + res = FALSE;
2.444 break;
2.445 default:
2.446 - g_assert_not_reached ();
2.447 + res = FALSE;
2.448 + break;
2.449 }
2.450
2.451 - GST_DEBUG_OBJECT (src, "state: %d res:%s", src->state,
2.452 - gst_flow_get_name (res));
2.453 + gst_object_unref (myth);
2.454
2.455 - return GST_FLOW_OK;
2.456 -
2.457 -pause:
2.458 - GST_LOG_OBJECT (src, "pausing task, reason %s", gst_flow_get_name (res));
2.459 - gst_pad_pause_task (src->srcpad);
2.460 - if (GST_FLOW_IS_FATAL (res)) {
2.461 - GST_ELEMENT_ERROR (src, STREAM, FAILED,
2.462 - ("Internal data stream error."),
2.463 - ("streaming stopped, reason %s", gst_flow_get_name (res)));
2.464 - gst_pad_send_event( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)), gst_event_new_eos() );
2.465 - }
2.466 return res;
2.467 }
2.468 -#endif
2.469
2.470 static GstStateChangeReturn
2.471 gst_mythtv_src_change_state (GstElement * element, GstStateChange transition)
2.472 {
2.473 - GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;//GST_STATE_CHANGE_NO_PREROLL;
2.474 + GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;//GST_STATE_CHANGE_NO_PREROLL;
2.475 GstMythtvSrc *src = GST_MYTHTV_SRC (element);
2.476
2.477 switch (transition) {
2.478 case GST_STATE_CHANGE_NULL_TO_READY:
2.479 - src->do_start = TRUE;
2.480 - src->unique_setup = FALSE;
2.481 + //src->do_start = TRUE;
2.482 + //src->unique_setup = FALSE;
2.483 break;
2.484 case GST_STATE_CHANGE_READY_TO_PAUSED:
2.485 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
2.486 - src->eos = FALSE;
2.487 + //src->eos = FALSE;
2.488 break;
2.489 default:
2.490 break;
2.491 @@ -1603,7 +1504,7 @@
2.492 return TRUE;
2.493 }
2.494
2.495 - static void
2.496 + static void
2.497 gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
2.498 {
2.499 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;