Changeset 262
- Timestamp:
- 07/04/08 22:59:58 (4 years ago)
- Location:
- trunk/fm_server/src/fm_input_gst
- Files:
-
- 5 modified
-
fm_input_gst.c (modified) (7 diffs)
-
fm_input_gst.h (modified) (1 diff)
-
fm_input_gst_common.c (modified) (1 diff)
-
fm_input_gst_common.h (modified) (1 diff)
-
gstfmsink.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fm_server/src/fm_input_gst/fm_input_gst.c
r246 r262 522 522 track = input_gst->read_track; 523 523 common->new_track = NULL; 524 g_print ("NEW TRACK - skipped to track %d \n", track->id);524 g_print ("NEW TRACK - skipped to track %d, _search\n", track->id); 525 525 skip_to = _search_chunk (track, 0); 526 526 … … 538 538 guint64 seek_at_sample = ns_to_samples (common, input_gst->seek_at_ns); 539 539 540 if ((seek_at_sample > first_avail_sample) && (seek_at_sample < last_avail_sample)) {540 if ((seek_at_sample >= first_avail_sample) && (seek_at_sample < last_avail_sample)) { 541 541 /* LOCAL seek - we have the data already ready in the ringbuffer */ 542 542 g_print ("seek at %ld, first %ld last %ld, LOCAL\n", seek_at_sample, first_avail_sample, last_avail_sample); … … 554 554 FM_BUFFER_DISCONT (buffer) = TRUE; 555 555 } else { 556 g_print ("non-LOCAL seek, _search\n"); 556 557 skip_to = _search_chunk (track, input_gst->seek_at_ns); 557 558 if (skip_to) { 558 559 /* CHUNK seek - the destination is in another ready chunk */ 559 560 g_print ("seek at %ld, first %ld last %ld, CHUNK %u\n", seek_at_sample, first_avail_sample, last_avail_sample, skip_to->id); 561 562 /* If we're just requested a FAR seek for the same position and the new buffer has just arrived 563 don't wait for it any more. Prevents _search_chunk () loops */ 564 if (track->seek_waiting_for_ns == input_gst->seek_at_ns) 565 track->seek_waiting_for_ns = -1; 560 566 561 567 } else { … … 576 582 if ((!skip_to) && (track) && (track->seek_waiting_for_ns > -1)) { 577 583 // g_print ("Waiting...\n"); 584 g_print ("Pending FAR seek for %llu, _search\n", (long long unsigned int) track->seek_waiting_for_ns); 578 585 skip_to = _search_chunk (track, track->seek_waiting_for_ns); 579 586 if (skip_to) … … 588 595 g_warning ("Skipping to a chunk not marked usable!"); 589 596 597 // input_gst->seek_at_ns = -1; // prevent looping if we're both waiting for a local and a far seek 590 598 track->read_chunk = skip_to; 591 599 … … 798 806 seek_target = 0; 799 807 808 /* if ((seek_target == 0) && (input_gst->read_track->start_at > 0)) 809 seek_target =input_gst->read_track->start_at;*/ 810 800 811 input_gst->seek_at_ns = seek_target; 801 812 } … … 813 824 g_return_if_fail (track->read_chunk->duration_ns > 0); 814 825 815 input_gst->seek_at_ns = track->read_chunk->duration_ns * pos; 826 gint64 seek_target = track->read_chunk->duration_ns * pos; 827 828 /* if ((seek_target == 0) && (input_gst->read_track->start_at > 0)) 829 seek_target =input_gst->read_track->start_at;*/ 830 831 input_gst->seek_at_ns = seek_target; 816 832 } 817 833 -
trunk/fm_server/src/fm_input_gst/fm_input_gst.h
r242 r262 52 52 53 53 guint tick_ns_count; // for "tick" 54 55 // gboolean drop_chunks; // invalidate all the currently unused chunks56 54 57 55 guint rt_signal; -
trunk/fm_server/src/fm_input_gst/fm_input_gst_common.c
r242 r262 63 63 track->gst_seek_to_ns = -1; 64 64 track->seek_waiting_for_ns = -1; 65 track->start_at = -1; 65 66 return track; 66 67 } -
trunk/fm_server/src/fm_input_gst/fm_input_gst_common.h
r242 r262 81 81 gint64 gst_seek_to_ns; // only for a FAR seek, where GStreamer should seek 82 82 gint64 seek_waiting_for_ns; // only for a FAR seek, wait for a new chunk returned from GST which starts here 83 84 gint64 start_at; 83 85 }; 84 86 -
trunk/fm_server/src/fm_input_gst/gstfmsink.c
r242 r262 250 250 } 251 251 case GST_EVENT_NEWSEGMENT: { 252 //g_print("> new segment! creating a new chunk...\n");252 g_print("> new segment! creating a new chunk...\n"); 253 253 sink->create_new_chunk = TRUE; 254 254 } … … 317 317 318 318 gboolean ret; 319 ret = gst_element_seek (common->pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, 319 g_print ("> asking GStreamer to seek to %lld ns\n", (long long int) sink->seek_target_timestamp); 320 if (sink->seek_target_timestamp != 0) 321 ret = gst_element_seek (common->pipeline, 1.0, GST_FORMAT_TIME, 322 GST_SEEK_FLAG_ACCURATE, 320 323 GST_SEEK_TYPE_SET, sink->seek_target_timestamp, 321 324 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); 325 else { 326 /* What the... it looks like gstreamer-0.10.18 is not able to seek reliably to "0" with 327 a "normal" seek. But it used to work, I'm sure */ 328 ret = gst_element_seek (common->pipeline, 1.0, GST_FORMAT_TIME, 329 GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_FLUSH, 330 GST_SEEK_TYPE_SET, 0, 331 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); 332 } 333 322 334 323 335 if (ret) { 324 336 sink->seek_completed = TRUE; 325 g_print("> trying to seek to%lld ns...\n", (long long int) sink->seek_target_timestamp);337 g_print("> ok, now waiting for %lld ns...\n", (long long int) sink->seek_target_timestamp); 326 338 } else { 327 339 sink->seek_in_progress = FALSE; … … 334 346 335 347 336 337 348 static GstFlowReturn 338 349 gst_fm_sink_render (GstBaseSink * bsink, GstBuffer * buf) … … 342 353 FmInputGstTrack *track = sink->write_track; 343 354 355 //g_print ("> sink_render, new buffer TIMESTAMP %lld\n", (long long int) GST_BUFFER_TIMESTAMP (buf)); 356 344 357 if (common->stop_processing || (sink->seek_in_progress && !sink->seek_completed)) 345 358 return GST_FLOW_OK; … … 352 365 (sink->create_new_chunk && !sink->seek_in_progress) || 353 366 (sink->create_new_chunk && sink->seek_in_progress && sink->seek_completed)) { // ehm... 354 367 355 368 sink->create_new_chunk = FALSE; 356 369 … … 361 374 362 375 chk = fm_chunk_new (SAMPLES_TO_BYTES (CHUNK_SAMPLES), track->chunk_count++); 363 track->chunks = g_slist_append (track->chunks, chk);364 376 track->write_chunk = chk; 365 377 366 378 gint64 timestamp = GST_BUFFER_TIMESTAMP (buf); 367 379 g_print ("> new chunk %d, TIMESTAMP %lld\n", chk->id, (long long int) timestamp); … … 369 381 g_warning ("This file probably starts at timestamp %llu, taking care of it", (long long int) timestamp); 370 382 chk->start_of_file = TRUE; 383 track->start_at = timestamp; 371 384 } 372 385 if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf)) … … 466 479 // common->chunk_skip_to = chk; 467 480 g_print ("> preload complete... GO!\n"); 468 481 track->chunks = g_slist_append (track->chunks, chk); 482 469 483 // GStreamer has hopefully figured out the correct lenght 470 484 // of the stream now (useful with old MP3 VBR)
