• Home
  • Raw
  • Download

Lines Matching refs:demux

76 …util_uint64_scale (MAX(0,(gint64) (GSTTIME_TO_MPEGTIME(time))), demux->scr_rate_n, demux->scr_rate…
77 …ytes != -1) ? MPEGTIME_TO_GSTTIME(gst_util_uint64_scale (bytes, demux->scr_rate_d, demux->scr_rate…
79 #define ADAPTER_OFFSET_FLUSH(_bytes_) demux->adapter_offset += (_bytes_)
146 static void gst_ps_demux_init (GstPsDemux * demux);
147 static void gst_ps_demux_finalize (GstPsDemux * demux);
152 static void gst_ps_demux_reset (GstPsDemux * demux);
172 static inline gboolean gst_ps_demux_scan_forward_ts (GstPsDemux * demux,
174 static inline gboolean gst_ps_demux_scan_backward_ts (GstPsDemux * demux,
177 static inline void gst_ps_demux_send_gap_updates (GstPsDemux * demux,
179 static inline void gst_ps_demux_clear_times (GstPsDemux * demux);
181 static void gst_ps_demux_reset_psm (GstPsDemux * demux);
182 static void gst_ps_demux_flush (GstPsDemux * demux);
285 gst_ps_demux_init (GstPsDemux * demux) in gst_ps_demux_init() argument
287 GstPsDemuxClass *klass = GST_PS_DEMUX_GET_CLASS (demux); in gst_ps_demux_init()
289 demux->sinkpad = gst_pad_new_from_template (klass->sink_template, "sink"); in gst_ps_demux_init()
290 gst_pad_set_event_function (demux->sinkpad, in gst_ps_demux_init()
292 gst_pad_set_chain_function (demux->sinkpad, in gst_ps_demux_init()
294 gst_pad_set_activate_function (demux->sinkpad, in gst_ps_demux_init()
296 gst_pad_set_activatemode_function (demux->sinkpad, in gst_ps_demux_init()
299 gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad); in gst_ps_demux_init()
301 demux->streams = in gst_ps_demux_init()
303 demux->streams_found = in gst_ps_demux_init()
305 demux->found_count = 0; in gst_ps_demux_init()
307 demux->adapter = gst_adapter_new (); in gst_ps_demux_init()
308 demux->rev_adapter = gst_adapter_new (); in gst_ps_demux_init()
309 demux->flowcombiner = gst_flow_combiner_new (); in gst_ps_demux_init()
311 gst_ps_demux_reset (demux); in gst_ps_demux_init()
313 demux->ignore_scr = DEFAULT_IGNORE_SCR; in gst_ps_demux_init()
317 gst_ps_demux_finalize (GstPsDemux * demux) in gst_ps_demux_finalize() argument
319 gst_ps_demux_reset (demux); in gst_ps_demux_finalize()
320 g_free (demux->streams); in gst_ps_demux_finalize()
321 g_free (demux->streams_found); in gst_ps_demux_finalize()
323 gst_flow_combiner_free (demux->flowcombiner); in gst_ps_demux_finalize()
324 g_object_unref (demux->adapter); in gst_ps_demux_finalize()
325 g_object_unref (demux->rev_adapter); in gst_ps_demux_finalize()
327 G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT (demux)); in gst_ps_demux_finalize()
334 GstPsDemux *demux = GST_PS_DEMUX (object); in gst_ps_demux_set_property() local
338 demux->ignore_scr = g_value_get_boolean (value); in gst_ps_demux_set_property()
349 GstPsDemux *demux = GST_PS_DEMUX (object); in gst_ps_demux_get_property() local
353 g_value_set_boolean (value, demux->ignore_scr); in gst_ps_demux_get_property()
361 gst_ps_demux_reset (GstPsDemux * demux) in gst_ps_demux_reset() argument
367 GstPsStream *stream = demux->streams[i]; in gst_ps_demux_reset()
371 gst_flow_combiner_remove_pad (demux->flowcombiner, stream->pad); in gst_ps_demux_reset()
372 gst_element_remove_pad (GST_ELEMENT_CAST (demux), stream->pad); in gst_ps_demux_reset()
380 demux->streams[i] = NULL; in gst_ps_demux_reset()
383 memset (demux->streams_found, 0, in gst_ps_demux_reset()
385 demux->found_count = 0; in gst_ps_demux_reset()
387 gst_adapter_clear (demux->adapter); in gst_ps_demux_reset()
388 gst_adapter_clear (demux->rev_adapter); in gst_ps_demux_reset()
390 demux->adapter_offset = G_MAXUINT64; in gst_ps_demux_reset()
391 demux->first_scr = G_MAXUINT64; in gst_ps_demux_reset()
392 demux->last_scr = G_MAXUINT64; in gst_ps_demux_reset()
393 demux->current_scr = G_MAXUINT64; in gst_ps_demux_reset()
394 demux->base_time = G_MAXUINT64; in gst_ps_demux_reset()
395 demux->scr_rate_n = G_MAXUINT64; in gst_ps_demux_reset()
396 demux->scr_rate_d = G_MAXUINT64; in gst_ps_demux_reset()
397 demux->first_pts = G_MAXUINT64; in gst_ps_demux_reset()
398 demux->last_pts = G_MAXUINT64; in gst_ps_demux_reset()
399 demux->mux_rate = G_MAXUINT64; in gst_ps_demux_reset()
400 demux->next_pts = G_MAXUINT64; in gst_ps_demux_reset()
401 demux->next_dts = G_MAXUINT64; in gst_ps_demux_reset()
402 demux->need_no_more_pads = TRUE; in gst_ps_demux_reset()
403 gst_ps_demux_reset_psm (demux); in gst_ps_demux_reset()
404 gst_segment_init (&demux->sink_segment, GST_FORMAT_UNDEFINED); in gst_ps_demux_reset()
405 gst_segment_init (&demux->src_segment, GST_FORMAT_TIME); in gst_ps_demux_reset()
406 gst_ps_demux_flush (demux); in gst_ps_demux_reset()
407 demux->have_group_id = FALSE; in gst_ps_demux_reset()
408 demux->group_id = G_MAXUINT; in gst_ps_demux_reset()
412 gst_ps_demux_create_stream (GstPsDemux * demux, gint id, gint stream_type, in gst_ps_demux_create_stream() argument
418 GstPsDemuxClass *klass = GST_PS_DEMUX_GET_CLASS (demux); in gst_ps_demux_create_stream()
428 GST_DEBUG_OBJECT (demux, "create stream id 0x%02x, type 0x%02x", id, in gst_ps_demux_create_stream()
439 (stream_type == ST_GST_VIDEO_MPEG1_OR_2 && demux->is_mpeg2_pack)) { in gst_ps_demux_create_stream()
554 GST_WARNING_OBJECT (demux, "Failed to activate pad %" GST_PTR_FORMAT, in gst_ps_demux_create_stream()
559 gst_pad_create_stream_id_printf (stream->pad, GST_ELEMENT_CAST (demux), in gst_ps_demux_create_stream()
562 event = gst_pad_get_sticky_event (demux->sinkpad, GST_EVENT_STREAM_START, 0); in gst_ps_demux_create_stream()
564 if (gst_event_parse_group_id (event, &demux->group_id)) in gst_ps_demux_create_stream()
565 demux->have_group_id = TRUE; in gst_ps_demux_create_stream()
567 demux->have_group_id = FALSE; in gst_ps_demux_create_stream()
569 } else if (!demux->have_group_id) { in gst_ps_demux_create_stream()
570 demux->have_group_id = TRUE; in gst_ps_demux_create_stream()
571 demux->group_id = gst_util_group_id_next (); in gst_ps_demux_create_stream()
574 if (demux->have_group_id) in gst_ps_demux_create_stream()
575 gst_event_set_group_id (event, demux->group_id); in gst_ps_demux_create_stream()
587 GST_DEBUG_OBJECT (demux, "create pad %s, caps %" GST_PTR_FORMAT, name, caps); in gst_ps_demux_create_stream()
595 gst_ps_demux_get_stream (GstPsDemux * demux, gint id, gint type, gint layer) in gst_ps_demux_get_stream() argument
597 GstPsStream *stream = demux->streams[id]; in gst_ps_demux_get_stream()
600 if (!(stream = gst_ps_demux_create_stream (demux, id, type, layer))) in gst_ps_demux_get_stream()
603 GST_DEBUG_OBJECT (demux, "adding pad for stream id 0x%02x type 0x%02x", id, in gst_ps_demux_get_stream()
606 demux->streams[id] = stream; in gst_ps_demux_get_stream()
607 demux->streams_found[demux->found_count++] = stream; in gst_ps_demux_get_stream()
609 if (demux->need_no_more_pads) { in gst_ps_demux_get_stream()
610 gst_element_add_pad (GST_ELEMENT (demux), stream->pad); in gst_ps_demux_get_stream()
611 gst_flow_combiner_add_pad (demux->flowcombiner, stream->pad); in gst_ps_demux_get_stream()
616 GST_DEBUG_OBJECT (demux, in gst_ps_demux_get_stream()
626 GST_DEBUG_OBJECT (demux, "unknown stream id 0x%02x type 0x%02x", id, type); in gst_ps_demux_get_stream()
632 gst_ps_demux_get_stream_from_pad (GstPsDemux * demux, GstPad * srcpad) in gst_ps_demux_get_stream_from_pad() argument
636 count = demux->found_count; in gst_ps_demux_get_stream_from_pad()
638 GstPsStream *stream = demux->streams_found[i]; in gst_ps_demux_get_stream_from_pad()
649 gst_ps_demux_send_segment (GstPsDemux * demux, GstPsStream * stream, in gst_ps_demux_send_segment() argument
659 GST_TIME_ARGS (pts), GST_TIME_ARGS (demux->base_time), in gst_ps_demux_send_segment()
660 GST_TIME_ARGS (demux->src_segment.start), in gst_ps_demux_send_segment()
661 GST_TIME_ARGS (demux->src_segment.stop)); in gst_ps_demux_send_segment()
665 gst_segment_copy_into (&demux->src_segment, &segment); in gst_ps_demux_send_segment()
666 if (GST_CLOCK_TIME_IS_VALID (demux->base_time)) { in gst_ps_demux_send_segment()
668 segment.start += demux->base_time; in gst_ps_demux_send_segment()
670 segment.stop += demux->base_time; in gst_ps_demux_send_segment()
671 segment.time = segment.start - demux->base_time; in gst_ps_demux_send_segment()
675 if (demux->segment_seqnum) in gst_ps_demux_send_segment()
676 gst_event_set_seqnum (segment_event, demux->segment_seqnum); in gst_ps_demux_send_segment()
678 demux->segment_seqnum = gst_event_get_seqnum (segment_event); in gst_ps_demux_send_segment()
679 GST_INFO_OBJECT (demux, "sending segment event %" GST_SEGMENT_FORMAT in gst_ps_demux_send_segment()
688 GST_DEBUG_OBJECT (demux, "Sending pending_tags %p for pad %s:%s : %" in gst_ps_demux_send_segment()
697 gst_ps_demux_send_data (GstPsDemux * demux, GstPsStream * stream, in gst_ps_demux_send_data() argument
708 if (G_UNLIKELY (demux->next_pts != G_MAXUINT64)) in gst_ps_demux_send_data()
709 pts = MPEGTIME_TO_GSTTIME (demux->next_pts); in gst_ps_demux_send_data()
710 if (G_UNLIKELY (demux->next_dts != G_MAXUINT64)) in gst_ps_demux_send_data()
711 dts = MPEGTIME_TO_GSTTIME (demux->next_dts); in gst_ps_demux_send_data()
713 gst_ps_demux_send_segment (demux, stream, pts); in gst_ps_demux_send_data()
728 GST_LOG_OBJECT (demux, in gst_ps_demux_send_data()
732 GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (demux->current_scr))); in gst_ps_demux_send_data()
734 if (demux->src_segment.position == GST_CLOCK_TIME_NONE in gst_ps_demux_send_data()
735 || stream->last_ts > demux->src_segment.position) in gst_ps_demux_send_data()
736 gst_segment_set_position (&demux->src_segment, GST_FORMAT_TIME, in gst_ps_demux_send_data()
742 GST_DEBUG_OBJECT (demux, "discont buffer to pad %" GST_PTR_FORMAT in gst_ps_demux_send_data()
752 demux->next_pts = G_MAXUINT64; in gst_ps_demux_send_data()
753 demux->next_dts = G_MAXUINT64; in gst_ps_demux_send_data()
755 GST_LOG_OBJECT (demux, "pushing stream id 0x%02x type 0x%02x, pts time: %" in gst_ps_demux_send_data()
759 GST_LOG_OBJECT (demux, "result: %s", gst_flow_get_name (result)); in gst_ps_demux_send_data()
766 GST_DEBUG_OBJECT (demux, "no stream given"); in gst_ps_demux_send_data()
773 gst_ps_demux_mark_discont (GstPsDemux * demux, gboolean discont, in gst_ps_demux_mark_discont() argument
776 gint i, count = demux->found_count; in gst_ps_demux_mark_discont()
780 GstPsStream *stream = demux->streams_found[i]; in gst_ps_demux_mark_discont()
786 demux->segment_seqnum = 0; in gst_ps_demux_mark_discont()
787 GST_DEBUG_OBJECT (demux, "marked stream as discont %d, need_segment %d", in gst_ps_demux_mark_discont()
794 gst_ps_demux_send_event (GstPsDemux * demux, GstEvent * event) in gst_ps_demux_send_event() argument
796 gint i, count = demux->found_count; in gst_ps_demux_send_event()
800 GstPsStream *stream = demux->streams_found[i]; in gst_ps_demux_send_event()
820 gst_ps_demux_handle_dvd_event (GstPsDemux * demux, GstEvent * event) in gst_ps_demux_handle_dvd_event() argument
830 GST_DEBUG_OBJECT (demux, "Handling language codes event"); in gst_ps_demux_handle_dvd_event()
833 (void) gst_ps_demux_get_stream (demux, 0xe0, ST_VIDEO_MPEG2, 0); in gst_ps_demux_handle_dvd_event()
855 GST_DEBUG_OBJECT (demux, in gst_ps_demux_handle_dvd_event()
858 temp = gst_ps_demux_get_stream (demux, stream_id, ST_PS_AUDIO_AC3, 0); in gst_ps_demux_handle_dvd_event()
865 GST_DEBUG_OBJECT (demux, in gst_ps_demux_handle_dvd_event()
868 temp = gst_ps_demux_get_stream (demux, stream_id, ST_AUDIO_MPEG1, 0); in gst_ps_demux_handle_dvd_event()
873 GST_DEBUG_OBJECT (demux, in gst_ps_demux_handle_dvd_event()
877 gst_ps_demux_get_stream (demux, stream_id, ST_PS_AUDIO_LPCM, 0); in gst_ps_demux_handle_dvd_event()
882 GST_DEBUG_OBJECT (demux, in gst_ps_demux_handle_dvd_event()
885 temp = gst_ps_demux_get_stream (demux, stream_id, ST_PS_AUDIO_DTS, 0); in gst_ps_demux_handle_dvd_event()
890 GST_WARNING_OBJECT (demux, in gst_ps_demux_handle_dvd_event()
927 GST_DEBUG_OBJECT (demux, "Subpicture stream %d ID 0x%02x", i, in gst_ps_demux_handle_dvd_event()
931 temp = gst_ps_demux_get_stream (demux, 0x20 + stream_id, in gst_ps_demux_handle_dvd_event()
949 GST_DEBUG_OBJECT (demux, "Created all pads from Language Codes event, " in gst_ps_demux_handle_dvd_event()
952 gst_element_no_more_pads (GST_ELEMENT (demux)); in gst_ps_demux_handle_dvd_event()
953 demux->need_no_more_pads = FALSE; in gst_ps_demux_handle_dvd_event()
957 gst_ps_demux_send_event (demux, event); in gst_ps_demux_handle_dvd_event()
965 gst_ps_demux_flush (GstPsDemux * demux) in gst_ps_demux_flush() argument
967 GST_DEBUG_OBJECT (demux, "flushing demuxer"); in gst_ps_demux_flush()
968 gst_adapter_clear (demux->adapter); in gst_ps_demux_flush()
969 gst_adapter_clear (demux->rev_adapter); in gst_ps_demux_flush()
970 gst_pes_filter_drain (&demux->filter); in gst_ps_demux_flush()
971 gst_ps_demux_clear_times (demux); in gst_ps_demux_flush()
972 demux->adapter_offset = G_MAXUINT64; in gst_ps_demux_flush()
973 demux->current_scr = G_MAXUINT64; in gst_ps_demux_flush()
974 demux->bytes_since_scr = 0; in gst_ps_demux_flush()
978 gst_ps_demux_clear_times (GstPsDemux * demux) in gst_ps_demux_clear_times() argument
980 gint i, count = demux->found_count; in gst_ps_demux_clear_times()
982 gst_flow_combiner_reset (demux->flowcombiner); in gst_ps_demux_clear_times()
985 GstPsStream *stream = demux->streams_found[i]; in gst_ps_demux_clear_times()
994 gst_ps_demux_send_gap_updates (GstPsDemux * demux, GstClockTime new_start) in gst_ps_demux_send_gap_updates() argument
997 gint i, count = demux->found_count; in gst_ps_demux_send_gap_updates()
1004 if ((base_time = demux->base_time) == GST_CLOCK_TIME_NONE) in gst_ps_demux_send_gap_updates()
1007 stop = demux->src_segment.stop; in gst_ps_demux_send_gap_updates()
1016 GstPsStream *stream = demux->streams_found[i]; in gst_ps_demux_send_gap_updates()
1020 stream->last_ts < demux->src_segment.start + base_time) in gst_ps_demux_send_gap_updates()
1021 stream->last_ts = demux->src_segment.start + base_time; in gst_ps_demux_send_gap_updates()
1025 gst_ps_demux_send_segment (demux, stream, GST_CLOCK_TIME_NONE); in gst_ps_demux_send_gap_updates()
1027 GST_LOG_OBJECT (demux, in gst_ps_demux_send_gap_updates()
1041 have_open_streams (GstPsDemux * demux) in have_open_streams() argument
1043 return (demux->streams_found[0] != NULL); in have_open_streams()
1050 GstPsDemux *demux = GST_PS_DEMUX (parent); in gst_ps_demux_sink_event() local
1054 gst_ps_demux_send_event (demux, event); in gst_ps_demux_sink_event()
1057 gst_ps_demux_send_event (demux, event); in gst_ps_demux_sink_event()
1058 gst_segment_init (&demux->sink_segment, GST_FORMAT_UNDEFINED); in gst_ps_demux_sink_event()
1059 gst_ps_demux_flush (demux); in gst_ps_demux_sink_event()
1066 gst_segment_copy_into (segment, &demux->sink_segment); in gst_ps_demux_sink_event()
1068 GST_INFO_OBJECT (demux, "received segment %" GST_SEGMENT_FORMAT, segment); in gst_ps_demux_sink_event()
1071 gst_ps_demux_mark_discont (demux, TRUE, TRUE); in gst_ps_demux_sink_event()
1074 && demux->scr_rate_n != G_MAXUINT64 in gst_ps_demux_sink_event()
1075 && demux->scr_rate_d != G_MAXUINT64) { in gst_ps_demux_sink_event()
1076 demux->src_segment.rate = segment->rate; in gst_ps_demux_sink_event()
1077 demux->src_segment.applied_rate = segment->applied_rate; in gst_ps_demux_sink_event()
1078 demux->src_segment.format = GST_FORMAT_TIME; in gst_ps_demux_sink_event()
1079 demux->src_segment.start = BYTES_TO_GSTTIME (segment->start); in gst_ps_demux_sink_event()
1080 demux->src_segment.stop = BYTES_TO_GSTTIME (segment->stop); in gst_ps_demux_sink_event()
1081 demux->src_segment.time = BYTES_TO_GSTTIME (segment->time); in gst_ps_demux_sink_event()
1085 gst_segment_copy_into (segment, &demux->src_segment); in gst_ps_demux_sink_event()
1093 GST_INFO_OBJECT (demux, "Received EOS"); in gst_ps_demux_sink_event()
1094 if (!gst_ps_demux_send_event (demux, event) in gst_ps_demux_sink_event()
1095 && !have_open_streams (demux)) { in gst_ps_demux_sink_event()
1096 GST_WARNING_OBJECT (demux, "EOS and no streams open"); in gst_ps_demux_sink_event()
1097 GST_ELEMENT_ERROR (demux, STREAM, FAILED, in gst_ps_demux_sink_event()
1108 res = gst_ps_demux_handle_dvd_event (demux, event); in gst_ps_demux_sink_event()
1110 gst_ps_demux_send_event (demux, event); in gst_ps_demux_sink_event()
1118 gst_ps_demux_send_event (demux, event); in gst_ps_demux_sink_event()
1126 gst_ps_demux_handle_seek_push (GstPsDemux * demux, GstEvent * event) in gst_ps_demux_handle_seek_push() argument
1140 GST_DEBUG_OBJECT (demux, "seek event, rate: %f start: %" GST_TIME_FORMAT in gst_ps_demux_handle_seek_push()
1145 GST_DEBUG_OBJECT (demux, "seek not supported on format %d", format); in gst_ps_demux_handle_seek_push()
1149 GST_DEBUG_OBJECT (demux, "seek - trying directly upstream first"); in gst_ps_demux_handle_seek_push()
1153 if ((res = gst_pad_push_event (demux->sinkpad, event))) in gst_ps_demux_handle_seek_push()
1158 GST_DEBUG_OBJECT (demux, "seek not supported on format %d", format); in gst_ps_demux_handle_seek_push()
1163 if (demux->scr_rate_n == G_MAXUINT64 || demux->scr_rate_d == G_MAXUINT64) { in gst_ps_demux_handle_seek_push()
1164 GST_DEBUG_OBJECT (demux, "seek not possible, no scr_rate"); in gst_ps_demux_handle_seek_push()
1168 GST_DEBUG_OBJECT (demux, "try with scr_rate interpolation"); in gst_ps_demux_handle_seek_push()
1173 GST_DEBUG_OBJECT (demux, "in bytes bstart %" G_GINT64_FORMAT " bstop %" in gst_ps_demux_handle_seek_push()
1178 res = gst_pad_push_event (demux->sinkpad, bevent); in gst_ps_demux_handle_seek_push()
1196 find_offset (GstPsDemux * demux, guint64 scr, in find_offset() argument
1211 scr_rate_d), demux->sink_segment.stop); in find_offset()
1213 if (!gst_ps_demux_scan_forward_ts (demux, &offset, SCAN_SCR, &fscr, 0)) { in find_offset()
1214 gst_ps_demux_scan_backward_ts (demux, &offset, SCAN_SCR, &fscr, 0); in find_offset()
1222 return find_offset (demux, scr, fscr, offset, max_scr, max_scr_offset, in find_offset()
1225 return find_offset (demux, scr, min_scr, min_scr_offset, fscr, offset, in find_offset()
1231 gst_ps_demux_do_seek (GstPsDemux * demux, GstSegment * seeksegment) in gst_ps_demux_do_seek() argument
1235 guint64 scr = GSTTIME_TO_MPEGTIME (seeksegment->position + demux->base_time); in gst_ps_demux_do_seek()
1240 if (demux->last_scr > demux->last_pts) in gst_ps_demux_do_seek()
1241 scr = gst_util_uint64_scale (scr, demux->last_scr, demux->last_pts); in gst_ps_demux_do_seek()
1243 scr = MIN (demux->last_scr, scr); in gst_ps_demux_do_seek()
1244 scr = MAX (demux->first_scr, scr); in gst_ps_demux_do_seek()
1247 GST_INFO_OBJECT (demux, "sink segment configured %" GST_SEGMENT_FORMAT in gst_ps_demux_do_seek()
1248 ", trying to go at SCR: %" G_GUINT64_FORMAT, &demux->sink_segment, scr); in gst_ps_demux_do_seek()
1251 find_offset (demux, scr, demux->first_scr, demux->first_scr_offset, in gst_ps_demux_do_seek()
1252 demux->last_scr, demux->last_scr_offset, 0); in gst_ps_demux_do_seek()
1258 found = gst_ps_demux_scan_forward_ts (demux, &offset, SCAN_SCR, &fscr, 0); in gst_ps_demux_do_seek()
1260 found = gst_ps_demux_scan_backward_ts (demux, &offset, SCAN_SCR, &fscr, 0); in gst_ps_demux_do_seek()
1264 found = gst_ps_demux_scan_forward_ts (demux, &offset, SCAN_SCR, &fscr, 0); in gst_ps_demux_do_seek()
1269 found = gst_ps_demux_scan_backward_ts (demux, &offset, SCAN_SCR, &fscr, 0); in gst_ps_demux_do_seek()
1272 GST_INFO_OBJECT (demux, "doing seek at offset %" G_GUINT64_FORMAT in gst_ps_demux_do_seek()
1276 gst_segment_set_position (&demux->sink_segment, GST_FORMAT_BYTES, offset); in gst_ps_demux_do_seek()
1282 gst_ps_demux_handle_seek_pull (GstPsDemux * demux, GstEvent * event) in gst_ps_demux_handle_seek_pull() argument
1291 GstClockTime first_pts = MPEGTIME_TO_GSTTIME (demux->first_pts); in gst_ps_demux_handle_seek_pull()
1300 GST_DEBUG_OBJECT (demux, "Seek requested start %" GST_TIME_FORMAT " stop %" in gst_ps_demux_handle_seek_pull()
1304 if (demux->scr_rate_n == G_MAXUINT64 || demux->scr_rate_d == G_MAXUINT64) in gst_ps_demux_handle_seek_pull()
1317 demux->flushing = TRUE; in gst_ps_demux_handle_seek_pull()
1318 gst_ps_demux_send_event (demux, event); in gst_ps_demux_handle_seek_pull()
1319 gst_pad_push_event (demux->sinkpad, gst_event_new_flush_start ()); in gst_ps_demux_handle_seek_pull()
1322 gst_pad_pause_task (demux->sinkpad); in gst_ps_demux_handle_seek_pull()
1326 GST_PAD_STREAM_LOCK (demux->sinkpad); in gst_ps_demux_handle_seek_pull()
1330 demux->flushing = FALSE; in gst_ps_demux_handle_seek_pull()
1331 gst_pad_push_event (demux->sinkpad, gst_event_new_flush_stop (TRUE)); in gst_ps_demux_handle_seek_pull()
1335 memcpy (&seeksegment, &demux->src_segment, sizeof (GstSegment)); in gst_ps_demux_handle_seek_pull()
1337 GST_DEBUG_OBJECT (demux, "segment before configure %" GST_SEGMENT_FORMAT, in gst_ps_demux_handle_seek_pull()
1338 &demux->src_segment); in gst_ps_demux_handle_seek_pull()
1345 GST_DEBUG_OBJECT (demux, "seek segment configured %" GST_SEGMENT_FORMAT, in gst_ps_demux_handle_seek_pull()
1348 if (flush || seeksegment.position != demux->src_segment.position) { in gst_ps_demux_handle_seek_pull()
1350 if (!gst_ps_demux_do_seek (demux, &seeksegment)) { in gst_ps_demux_handle_seek_pull()
1357 && seeksegment.start < first_pts - demux->base_time) { in gst_ps_demux_handle_seek_pull()
1358 seeksegment.position = first_pts - demux->base_time; in gst_ps_demux_handle_seek_pull()
1364 demux->sink_segment.rate = rate; in gst_ps_demux_handle_seek_pull()
1366 GST_DEBUG_OBJECT (demux, "seek segment adjusted %" GST_SEGMENT_FORMAT, in gst_ps_demux_handle_seek_pull()
1373 gst_ps_demux_send_event (demux, event); in gst_ps_demux_handle_seek_pull()
1376 if (flush || seeksegment.position != demux->src_segment.position) { in gst_ps_demux_handle_seek_pull()
1377 gst_ps_demux_flush (demux); in gst_ps_demux_handle_seek_pull()
1381 memcpy (&demux->src_segment, &seeksegment, sizeof (GstSegment)); in gst_ps_demux_handle_seek_pull()
1384 if (demux->src_segment.flags & GST_SEEK_FLAG_SEGMENT) { in gst_ps_demux_handle_seek_pull()
1385 gst_element_post_message (GST_ELEMENT (demux), in gst_ps_demux_handle_seek_pull()
1386 gst_message_new_segment_start (GST_OBJECT (demux), in gst_ps_demux_handle_seek_pull()
1387 demux->src_segment.format, demux->src_segment.position)); in gst_ps_demux_handle_seek_pull()
1391 gst_ps_demux_mark_discont (demux, TRUE, TRUE); in gst_ps_demux_handle_seek_pull()
1394 demux->segment_seqnum = seek_seqnum; in gst_ps_demux_handle_seek_pull()
1396 gst_pad_start_task (demux->sinkpad, in gst_ps_demux_handle_seek_pull()
1397 (GstTaskFunction) gst_ps_demux_loop, demux->sinkpad, NULL); in gst_ps_demux_handle_seek_pull()
1399 GST_PAD_STREAM_UNLOCK (demux->sinkpad); in gst_ps_demux_handle_seek_pull()
1407 GST_WARNING_OBJECT (demux, "we only support seeking in TIME or BYTES " in gst_ps_demux_handle_seek_pull()
1414 GST_WARNING_OBJECT (demux, "seek not possible, no scr_rate"); in gst_ps_demux_handle_seek_pull()
1420 GST_WARNING_OBJECT (demux, "couldn't perform seek"); in gst_ps_demux_handle_seek_pull()
1430 GstPsDemux *demux = GST_PS_DEMUX (parent); in gst_ps_demux_src_event() local
1434 if (demux->random_access) { in gst_ps_demux_src_event()
1435 res = gst_ps_demux_handle_seek_pull (demux, event); in gst_ps_demux_src_event()
1437 res = gst_ps_demux_handle_seek_push (demux, event); in gst_ps_demux_src_event()
1443 stream = gst_ps_demux_get_stream_from_pad (demux, pad); in gst_ps_demux_src_event()
1452 res = gst_pad_push_event (demux->sinkpad, event); in gst_ps_demux_src_event()
1463 GstPsDemux *demux = GST_PS_DEMUX (parent); in gst_ps_demux_src_query() local
1465 GST_LOG_OBJECT (demux, "Have query of type %d on pad %" GST_PTR_FORMAT, in gst_ps_demux_src_query()
1475 res = gst_pad_peer_query (demux->sinkpad, query); in gst_ps_demux_src_query()
1482 GST_DEBUG_OBJECT (demux, "position not supported for format: %s", in gst_ps_demux_src_query()
1487 pos = demux->src_segment.position - demux->src_segment.start; in gst_ps_demux_src_query()
1488 GST_LOG_OBJECT (demux, "Position %" GST_TIME_FORMAT, GST_TIME_ARGS (pos)); in gst_ps_demux_src_query()
1503 GST_CLOCK_TIME_IS_VALID (demux->src_segment.duration))) { in gst_ps_demux_src_query()
1505 demux->src_segment.duration); in gst_ps_demux_src_query()
1512 GST_DEBUG_OBJECT (demux, "duration not supported for format: %s", in gst_ps_demux_src_query()
1517 if (gst_pad_peer_query (demux->sinkpad, query)) { in gst_ps_demux_src_query()
1525 GST_DEBUG_OBJECT (demux, "duration not supported for format: %s", in gst_ps_demux_src_query()
1530 if (demux->mux_rate == -1) { in gst_ps_demux_src_query()
1531 GST_DEBUG_OBJECT (demux, "duration not possible, no mux_rate"); in gst_ps_demux_src_query()
1537 if (!gst_pad_peer_query (demux->sinkpad, byte_query)) { in gst_ps_demux_src_query()
1538 GST_LOG_OBJECT (demux, "query on peer pad failed"); in gst_ps_demux_src_query()
1546 GST_LOG_OBJECT (demux, in gst_ps_demux_src_query()
1551 GST_LOG_OBJECT (demux, "converted to time %" GST_TIME_FORMAT, in gst_ps_demux_src_query()
1564 if (demux->random_access) { in gst_ps_demux_src_query()
1566 if (fmt != GST_FORMAT_TIME || demux->scr_rate_n == G_MAXUINT64 in gst_ps_demux_src_query()
1567 || demux->scr_rate_d == G_MAXUINT64) { in gst_ps_demux_src_query()
1571 if (GST_CLOCK_TIME_IS_VALID (demux->src_segment.duration)) in gst_ps_demux_src_query()
1572 dur = demux->src_segment.duration; in gst_ps_demux_src_query()
1584 res = gst_pad_peer_query (demux->sinkpad, query); in gst_ps_demux_src_query()
1598 res = gst_pad_peer_query (demux->sinkpad, peerquery); in gst_ps_demux_src_query()
1599 if (!res || demux->scr_rate_n == G_MAXUINT64 in gst_ps_demux_src_query()
1600 || demux->scr_rate_d == G_MAXUINT64) { in gst_ps_demux_src_query()
1620 format = demux->src_segment.format; in gst_ps_demux_src_query()
1623 gst_segment_to_stream_time (&demux->src_segment, format, in gst_ps_demux_src_query()
1624 demux->src_segment.start); in gst_ps_demux_src_query()
1625 if ((stop = demux->src_segment.stop) == -1) in gst_ps_demux_src_query()
1626 stop = demux->src_segment.duration; in gst_ps_demux_src_query()
1628 stop = gst_segment_to_stream_time (&demux->src_segment, format, stop); in gst_ps_demux_src_query()
1630 gst_query_set_segment (query, demux->src_segment.rate, format, start, in gst_ps_demux_src_query()
1647 gst_ps_demux_reset_psm (GstPsDemux * demux) in gst_ps_demux_reset_psm() argument
1653 demux->psm[i] = type; in gst_ps_demux_reset_psm()
1698 gst_ps_demux_parse_pack_start (GstPsDemux * demux) in gst_ps_demux_parse_pack_start() argument
1706 guint avail = gst_adapter_available (demux->adapter); in gst_ps_demux_parse_pack_start()
1713 data = gst_adapter_map (demux->adapter, PACK_START_SIZE); in gst_ps_demux_parse_pack_start()
1731 demux->is_mpeg2_pack = TRUE; in gst_ps_demux_parse_pack_start()
1753 demux->cur_scr_offset = demux->adapter_offset + 12; in gst_ps_demux_parse_pack_start()
1755 GST_LOG_OBJECT (demux, "SCR: 0x%08" G_GINT64_MODIFIER "x SCRE: 0x%08x", in gst_ps_demux_parse_pack_start()
1772 GST_LOG_OBJECT (demux, "stuffing bytes: %d", stuffing_bytes); in gst_ps_demux_parse_pack_start()
1782 demux->is_mpeg2_pack = FALSE; in gst_ps_demux_parse_pack_start()
1798 demux->cur_scr_offset = demux->adapter_offset + 8; in gst_ps_demux_parse_pack_start()
1806 if (demux->ignore_scr) { in gst_ps_demux_parse_pack_start()
1809 if (demux->first_scr == G_MAXUINT64) { in gst_ps_demux_parse_pack_start()
1810 demux->first_scr = scr; in gst_ps_demux_parse_pack_start()
1811 demux->first_scr_offset = demux->cur_scr_offset; in gst_ps_demux_parse_pack_start()
1814 demux->current_scr = scr; in gst_ps_demux_parse_pack_start()
1822 scr_adjusted = scr + demux->scr_adjust; in gst_ps_demux_parse_pack_start()
1824 GST_LOG_OBJECT (demux, in gst_ps_demux_parse_pack_start()
1831 if (G_UNLIKELY (demux->first_scr == G_MAXUINT64)) { in gst_ps_demux_parse_pack_start()
1834 demux->first_scr = scr; in gst_ps_demux_parse_pack_start()
1835 demux->first_scr_offset = demux->cur_scr_offset; in gst_ps_demux_parse_pack_start()
1836 demux->base_time = MPEGTIME_TO_GSTTIME (demux->first_scr); in gst_ps_demux_parse_pack_start()
1837 GST_DEBUG_OBJECT (demux, "determined base_time %" GST_TIME_FORMAT, in gst_ps_demux_parse_pack_start()
1838 GST_TIME_ARGS (demux->base_time)); in gst_ps_demux_parse_pack_start()
1843 if (demux->sink_segment.format == GST_FORMAT_TIME) { in gst_ps_demux_parse_pack_start()
1844 if (demux->sink_segment.start > demux->base_time) in gst_ps_demux_parse_pack_start()
1845 diff = -(demux->sink_segment.start - demux->base_time); in gst_ps_demux_parse_pack_start()
1847 diff = demux->base_time - demux->sink_segment.start; in gst_ps_demux_parse_pack_start()
1849 GST_DEBUG_OBJECT (demux, "diff of %" GST_TIME_FORMAT in gst_ps_demux_parse_pack_start()
1851 GST_TIME_ARGS (diff), GST_TIME_ARGS (demux->sink_segment.start)); in gst_ps_demux_parse_pack_start()
1852 demux->base_time += diff; in gst_ps_demux_parse_pack_start()
1855 } else if (G_LIKELY (demux->first_scr_offset != demux->cur_scr_offset)) { in gst_ps_demux_parse_pack_start()
1857 scr_rate_n = demux->cur_scr_offset - demux->first_scr_offset; in gst_ps_demux_parse_pack_start()
1858 scr_rate_d = scr_adjusted - demux->first_scr; in gst_ps_demux_parse_pack_start()
1860 scr_rate_n = demux->scr_rate_n; in gst_ps_demux_parse_pack_start()
1861 scr_rate_d = demux->scr_rate_d; in gst_ps_demux_parse_pack_start()
1864 GST_LOG_OBJECT (demux, "%s mode scr: %" G_GUINT64_FORMAT " at %" in gst_ps_demux_parse_pack_start()
1868 ((demux->sink_segment.rate >= 0.0) ? "forward" : "backward"), in gst_ps_demux_parse_pack_start()
1869 scr, demux->cur_scr_offset, in gst_ps_demux_parse_pack_start()
1870 demux->first_scr, demux->first_scr_offset, in gst_ps_demux_parse_pack_start()
1874 if (G_LIKELY (demux->current_scr != G_MAXUINT64)) { in gst_ps_demux_parse_pack_start()
1879 old_scr = demux->current_scr; in gst_ps_demux_parse_pack_start()
1880 old_mux_rate = demux->mux_rate; in gst_ps_demux_parse_pack_start()
1885 bss = MAX (0, (gint) (demux->bytes_since_scr - avail)); in gst_ps_demux_parse_pack_start()
1892 if (demux->sink_segment.rate >= 0.0) in gst_ps_demux_parse_pack_start()
1893 demux->next_scr = old_scr + adjust; in gst_ps_demux_parse_pack_start()
1895 demux->next_scr = old_scr - adjust; in gst_ps_demux_parse_pack_start()
1897 GST_LOG_OBJECT (demux, in gst_ps_demux_parse_pack_start()
1900 bss, demux->next_scr, old_scr, scr_adjusted); in gst_ps_demux_parse_pack_start()
1912 demux->scr_adjust = demux->next_scr - scr; in gst_ps_demux_parse_pack_start()
1913 GST_LOG_OBJECT (demux, "discont found, diff: %" G_GINT64_FORMAT in gst_ps_demux_parse_pack_start()
1914 ", adjust %" G_GINT64_FORMAT, diff, demux->scr_adjust); in gst_ps_demux_parse_pack_start()
1915 scr_adjusted = demux->next_scr; in gst_ps_demux_parse_pack_start()
1917 scr_rate_n = demux->scr_rate_n; in gst_ps_demux_parse_pack_start()
1918 scr_rate_d = demux->scr_rate_d; in gst_ps_demux_parse_pack_start()
1920 demux->next_scr = scr_adjusted; in gst_ps_demux_parse_pack_start()
1925 demux->mux_rate = new_rate; in gst_ps_demux_parse_pack_start()
1926 demux->current_scr = scr_adjusted; in gst_ps_demux_parse_pack_start()
1927 demux->scr_rate_n = scr_rate_n; in gst_ps_demux_parse_pack_start()
1928 demux->scr_rate_d = scr_rate_d; in gst_ps_demux_parse_pack_start()
1932 demux->bytes_since_scr = avail; in gst_ps_demux_parse_pack_start()
1936 gst_ps_demux_send_gap_updates (demux, in gst_ps_demux_parse_pack_start()
1937 MPEGTIME_TO_GSTTIME (demux->current_scr - demux->first_scr)); in gst_ps_demux_parse_pack_start()
1940 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_pack_start()
1941 gst_adapter_flush (demux->adapter, length); in gst_ps_demux_parse_pack_start()
1948 GST_DEBUG_OBJECT (demux, "lost sync"); in gst_ps_demux_parse_pack_start()
1949 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_pack_start()
1954 GST_DEBUG_OBJECT (demux, "need more data"); in gst_ps_demux_parse_pack_start()
1986 gst_ps_demux_parse_sys_head (GstPsDemux * demux) in gst_ps_demux_parse_sys_head() argument
1994 if (gst_adapter_available (demux->adapter) < 6) in gst_ps_demux_parse_sys_head()
1998 data = gst_adapter_map (demux->adapter, 6); in gst_ps_demux_parse_sys_head()
2004 GST_DEBUG_OBJECT (demux, "length %d", length); in gst_ps_demux_parse_sys_head()
2008 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_sys_head()
2009 if (gst_adapter_available (demux->adapter) < length) in gst_ps_demux_parse_sys_head()
2012 data = gst_adapter_map (demux->adapter, length); in gst_ps_demux_parse_sys_head()
2032 GST_DEBUG_OBJECT (demux, "rate bound %u", rate_bound); in gst_ps_demux_parse_sys_head()
2050 GST_DEBUG_OBJECT (demux, "audio_bound %d, fixed %d, constrained %d", in gst_ps_demux_parse_sys_head()
2074 GST_DEBUG_OBJECT (demux, "audio_lock %d, video_lock %d, video_bound %d", in gst_ps_demux_parse_sys_head()
2092 GST_DEBUG_OBJECT (demux, "packet_rate_restriction %d", in gst_ps_demux_parse_sys_head()
2103 GST_DEBUG_OBJECT (demux, "number of streams: %d ", stream_count); in gst_ps_demux_parse_sys_head()
2130 GST_DEBUG_OBJECT (demux, "STD_buffer_bound_scale %d", in gst_ps_demux_parse_sys_head()
2132 GST_DEBUG_OBJECT (demux, "STD_buffer_size_bound %d or %d bytes", in gst_ps_demux_parse_sys_head()
2138 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_sys_head()
2139 gst_adapter_flush (demux->adapter, length); in gst_ps_demux_parse_sys_head()
2146 GST_DEBUG_OBJECT (demux, "expecting marker"); in gst_ps_demux_parse_sys_head()
2147 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_sys_head()
2152 GST_DEBUG_OBJECT (demux, "expecting placeholder bit values" in gst_ps_demux_parse_sys_head()
2154 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_sys_head()
2159 GST_DEBUG_OBJECT (demux, "error in system header length"); in gst_ps_demux_parse_sys_head()
2160 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_sys_head()
2165 GST_DEBUG_OBJECT (demux, "need more data"); in gst_ps_demux_parse_sys_head()
2166 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_sys_head()
2172 gst_ps_demux_parse_psm (GstPsDemux * demux) in gst_ps_demux_parse_psm() argument
2182 if (gst_adapter_available (demux->adapter) < 6) in gst_ps_demux_parse_psm()
2189 data = gst_adapter_map (demux->adapter, 6); in gst_ps_demux_parse_psm()
2193 GST_DEBUG_OBJECT (demux, "PSM length %u", psm_length); in gst_ps_demux_parse_psm()
2199 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_psm()
2201 if (gst_adapter_available (demux->adapter) < psm_length) in gst_ps_demux_parse_psm()
2204 data = gst_adapter_map (demux->adapter, psm_length); in gst_ps_demux_parse_psm()
2220 GST_DEBUG_OBJECT (demux, "PSM version %u (applicable now %u)", psm_version, in gst_ps_demux_parse_psm()
2230 GST_DEBUG_OBJECT (demux, "PS info length %u bytes", info_length); in gst_ps_demux_parse_psm()
2238 GST_DEBUG_OBJECT (demux, "ES map length %u bytes", es_map_length); in gst_ps_demux_parse_psm()
2255 GST_DEBUG_OBJECT (demux, in gst_ps_demux_parse_psm()
2260 demux->psm[stream_id] = stream_type; in gst_ps_demux_parse_psm()
2266 GST_DEBUG_OBJECT (demux, "stream type for private_stream_1 ignored"); in gst_ps_demux_parse_psm()
2276 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_psm()
2277 gst_adapter_flush (demux->adapter, psm_length); in gst_ps_demux_parse_psm()
2282 GST_DEBUG_OBJECT (demux, "Failed to parse PSM. Skipping"); in gst_ps_demux_parse_psm()
2283 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_psm()
2284 gst_adapter_flush (demux->adapter, psm_length); in gst_ps_demux_parse_psm()
2289 GST_DEBUG_OBJECT (demux, "error in PSM length"); in gst_ps_demux_parse_psm()
2290 gst_adapter_unmap (demux->adapter); in gst_ps_demux_parse_psm()
2295 GST_DEBUG_OBJECT (demux, "need more data"); in gst_ps_demux_parse_psm()
2301 gst_ps_demux_resync_cb (GstPESFilter * filter, GstPsDemux * demux) in gst_ps_demux_resync_cb() argument
2307 GstBuffer * buffer, GstPsDemux * demux) in gst_ps_demux_data_cb() argument
2324 stream_type = demux->psm[id]; in gst_ps_demux_data_cb()
2334 stream_type = demux->psm[id] = ST_GST_AUDIO_RAWA52; in gst_ps_demux_data_cb()
2335 GST_DEBUG_OBJECT (demux, "Found VDR raw A52 stream"); in gst_ps_demux_data_cb()
2344 stream_type = demux->psm[id]; in gst_ps_demux_data_cb()
2353 GST_LOG_OBJECT (demux, "private type 0x%02x, %d frames", id, in gst_ps_demux_data_cb()
2359 GST_LOG_OBJECT (demux, "private type 0x%02x, stream type %d", in gst_ps_demux_data_cb()
2381 GST_WARNING_OBJECT (demux, "unknown mpeg audio layer"); in gst_ps_demux_data_cb()
2388 demux->next_pts = filter->pts + demux->scr_adjust; in gst_ps_demux_data_cb()
2389 GST_LOG_OBJECT (demux, "stream 0x%02x PTS = orig %" G_GUINT64_FORMAT in gst_ps_demux_data_cb()
2390 " (%" G_GUINT64_FORMAT ")", id, filter->pts, demux->next_pts); in gst_ps_demux_data_cb()
2392 demux->next_pts = G_MAXUINT64; in gst_ps_demux_data_cb()
2394 demux->next_dts = filter->dts + demux->scr_adjust; in gst_ps_demux_data_cb()
2395 GST_LOG_OBJECT (demux, "stream 0x%02x DTS = orig %" G_GUINT64_FORMAT in gst_ps_demux_data_cb()
2396 " (%" G_GUINT64_FORMAT ")", id, filter->dts, demux->next_dts); in gst_ps_demux_data_cb()
2398 demux->next_dts = demux->next_pts; in gst_ps_demux_data_cb()
2401 demux->current_stream = in gst_ps_demux_data_cb()
2402 gst_ps_demux_get_stream (demux, id, stream_type, layer); in gst_ps_demux_data_cb()
2405 if (G_UNLIKELY (demux->current_stream == NULL)) { in gst_ps_demux_data_cb()
2406 GST_DEBUG_OBJECT (demux, "Dropping buffer for unknown stream id 0x%02x", in gst_ps_demux_data_cb()
2412 if (demux->need_no_more_pads in gst_ps_demux_data_cb()
2413 && (demux->current_scr - demux->first_scr) > 2 * CLOCK_FREQ) { in gst_ps_demux_data_cb()
2414 GST_DEBUG_OBJECT (demux, "no more pads, notifying"); in gst_ps_demux_data_cb()
2415 gst_element_no_more_pads (GST_ELEMENT_CAST (demux)); in gst_ps_demux_data_cb()
2416 demux->need_no_more_pads = FALSE; in gst_ps_demux_data_cb()
2422 if (demux->current_stream->discont) { in gst_ps_demux_data_cb()
2423 GST_DEBUG_OBJECT (demux, "stream is discont"); in gst_ps_demux_data_cb()
2424 demux->current_stream->notlinked = FALSE; in gst_ps_demux_data_cb()
2427 if (demux->current_stream->notlinked == FALSE) { in gst_ps_demux_data_cb()
2430 ret = gst_ps_demux_send_data (demux, demux->current_stream, out_buf); in gst_ps_demux_data_cb()
2432 demux->current_stream->notlinked = TRUE; in gst_ps_demux_data_cb()
2443 GST_DEBUG_OBJECT (demux, "unknown stream type %02x", id); in gst_ps_demux_data_cb()
2450 gst_ps_demux_resync (GstPsDemux * demux, gboolean save) in gst_ps_demux_resync() argument
2457 avail = gst_adapter_available (demux->adapter); in gst_ps_demux_resync()
2461 data = gst_adapter_map (demux->adapter, 4); in gst_ps_demux_resync()
2466 GST_LOG_OBJECT (demux, "Found resync code %08x after 0 bytes", code); in gst_ps_demux_resync()
2467 demux->last_sync_code = code; in gst_ps_demux_resync()
2468 gst_adapter_unmap (demux->adapter); in gst_ps_demux_resync()
2477 data = gst_adapter_map (demux->adapter, avail); in gst_ps_demux_resync()
2482 gst_adapter_unmap (demux->adapter); in gst_ps_demux_resync()
2483 if (!save || demux->sink_segment.rate >= 0.0) { in gst_ps_demux_resync()
2484 GST_LOG_OBJECT (demux, "flushing %d bytes", offset - 4); in gst_ps_demux_resync()
2486 gst_adapter_flush (demux->adapter, offset - 4); in gst_ps_demux_resync()
2490 GST_LOG_OBJECT (demux, "reverse saving %d bytes", offset - 4); in gst_ps_demux_resync()
2494 gst_adapter_push (demux->rev_adapter, in gst_ps_demux_resync()
2495 gst_adapter_take_buffer (demux->adapter, offset - 4)); in gst_ps_demux_resync()
2497 GST_LOG_OBJECT (demux, "reverse saving %d bytes", avail); in gst_ps_demux_resync()
2499 gst_adapter_push (demux->rev_adapter, in gst_ps_demux_resync()
2500 gst_adapter_take_buffer (demux->adapter, avail)); in gst_ps_demux_resync()
2505 GST_LOG_OBJECT (demux, "Found resync code %08x after %d bytes", in gst_ps_demux_resync()
2507 demux->last_sync_code = code; in gst_ps_demux_resync()
2509 GST_LOG_OBJECT (demux, "No resync after skipping %d", offset); in gst_ps_demux_resync()
2515 GST_LOG_OBJECT (demux, "we need more data for resync %d", avail); in gst_ps_demux_resync()
2528 gst_ps_demux_scan_ts (GstPsDemux * demux, const guint8 * data, in gst_ps_demux_scan_ts() argument
2717 gst_ps_demux_scan_forward_ts (GstPsDemux * demux, guint64 * pos, in gst_ps_demux_scan_forward_ts() argument
2731 if (offset + scan_sz > demux->sink_segment.stop) in gst_ps_demux_scan_forward_ts()
2736 if (offset + to_read > demux->sink_segment.stop) in gst_ps_demux_scan_forward_ts()
2737 to_read = demux->sink_segment.stop - offset; in gst_ps_demux_scan_forward_ts()
2740 ret = gst_pad_pull_range (demux->sinkpad, offset, to_read, &buffer); in gst_ps_demux_scan_forward_ts()
2754 found = gst_ps_demux_scan_ts (demux, map.data + cursor, mode, &ts, in gst_ps_demux_scan_forward_ts()
2767 } while (!found && offset < demux->sink_segment.stop); in gst_ps_demux_scan_forward_ts()
2772 gst_ps_demux_scan_backward_ts (GstPsDemux * demux, guint64 * pos, in gst_ps_demux_scan_backward_ts() argument
2800 ret = gst_pad_pull_range (demux->sinkpad, offset, to_read, &buffer); in gst_ps_demux_scan_backward_ts()
2815 found = gst_ps_demux_scan_ts (demux, data--, mode, &ts, in gst_ps_demux_scan_backward_ts()
2832 gst_ps_sink_get_duration (GstPsDemux * demux) in gst_ps_sink_get_duration() argument
2842 gst_segment_init (&demux->sink_segment, format); in gst_ps_sink_get_duration()
2844 if ((peer = gst_pad_get_peer (demux->sinkpad)) == NULL) in gst_ps_sink_get_duration()
2850 GST_DEBUG_OBJECT (demux, "file length %" G_GINT64_FORMAT, length); in gst_ps_sink_get_duration()
2852 demux->sink_segment.stop = length; in gst_ps_sink_get_duration()
2853 gst_segment_set_duration (&demux->sink_segment, format, length); in gst_ps_sink_get_duration()
2854 gst_segment_set_position (&demux->sink_segment, format, 0); in gst_ps_sink_get_duration()
2857 offset = demux->sink_segment.start; in gst_ps_sink_get_duration()
2858 gst_ps_demux_scan_forward_ts (demux, &offset, SCAN_SCR, in gst_ps_sink_get_duration()
2859 &demux->first_scr, DURATION_SCAN_LIMIT); in gst_ps_sink_get_duration()
2860 GST_DEBUG_OBJECT (demux, in gst_ps_sink_get_duration()
2862 " in packet starting at %" G_GUINT64_FORMAT, demux->first_scr, in gst_ps_sink_get_duration()
2863 GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (demux->first_scr)), offset); in gst_ps_sink_get_duration()
2864 demux->first_scr_offset = offset; in gst_ps_sink_get_duration()
2866 offset = demux->sink_segment.stop; in gst_ps_sink_get_duration()
2867 gst_ps_demux_scan_backward_ts (demux, &offset, SCAN_SCR, in gst_ps_sink_get_duration()
2868 &demux->last_scr, DURATION_SCAN_LIMIT); in gst_ps_sink_get_duration()
2869 GST_DEBUG_OBJECT (demux, in gst_ps_sink_get_duration()
2871 " in packet starting at %" G_GUINT64_FORMAT, demux->last_scr, in gst_ps_sink_get_duration()
2872 GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (demux->last_scr)), offset); in gst_ps_sink_get_duration()
2873 demux->last_scr_offset = offset; in gst_ps_sink_get_duration()
2875 offset = demux->sink_segment.start; in gst_ps_sink_get_duration()
2876 gst_ps_demux_scan_forward_ts (demux, &offset, SCAN_PTS, in gst_ps_sink_get_duration()
2877 &demux->first_pts, DURATION_SCAN_LIMIT); in gst_ps_sink_get_duration()
2878 GST_DEBUG_OBJECT (demux, in gst_ps_sink_get_duration()
2880 " in packet starting at %" G_GUINT64_FORMAT, demux->first_pts, in gst_ps_sink_get_duration()
2881 GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (demux->first_pts)), offset); in gst_ps_sink_get_duration()
2882 if (demux->first_pts != G_MAXUINT64) { in gst_ps_sink_get_duration()
2884 offset = demux->sink_segment.stop; in gst_ps_sink_get_duration()
2885 gst_ps_demux_scan_backward_ts (demux, &offset, SCAN_PTS, in gst_ps_sink_get_duration()
2886 &demux->last_pts, DURATION_SCAN_LIMIT); in gst_ps_sink_get_duration()
2887 GST_DEBUG_OBJECT (demux, in gst_ps_sink_get_duration()
2889 " in packet starting at %" G_GUINT64_FORMAT, demux->last_pts, in gst_ps_sink_get_duration()
2890 GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (demux->last_pts)), offset); in gst_ps_sink_get_duration()
2893 if (demux->first_scr > demux->last_scr) { in gst_ps_sink_get_duration()
2894 GST_DEBUG_OBJECT (demux, "Wrong SCR values detected, searching for " in gst_ps_sink_get_duration()
2896 offset = demux->first_scr_offset; in gst_ps_sink_get_duration()
2899 gst_ps_demux_scan_forward_ts (demux, &offset, SCAN_SCR, &scr, 0); in gst_ps_sink_get_duration()
2900 if (scr < demux->last_scr) { in gst_ps_sink_get_duration()
2901 demux->first_scr = scr; in gst_ps_sink_get_duration()
2902 demux->first_scr_offset = offset; in gst_ps_sink_get_duration()
2904 demux->sink_segment.position = offset; in gst_ps_sink_get_duration()
2905 GST_DEBUG_OBJECT (demux, "Replaced First SCR: %" G_GINT64_FORMAT in gst_ps_sink_get_duration()
2907 G_GUINT64_FORMAT, demux->first_scr, in gst_ps_sink_get_duration()
2908 GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (demux->first_scr)), offset); in gst_ps_sink_get_duration()
2914 demux->base_time = MPEGTIME_TO_GSTTIME (demux->first_scr); in gst_ps_sink_get_duration()
2915 demux->scr_rate_n = demux->last_scr_offset - demux->first_scr_offset; in gst_ps_sink_get_duration()
2916 demux->scr_rate_d = demux->last_scr - demux->first_scr; in gst_ps_sink_get_duration()
2917 if (G_LIKELY (demux->first_pts != G_MAXUINT64 && in gst_ps_sink_get_duration()
2918 demux->last_pts != G_MAXUINT64)) { in gst_ps_sink_get_duration()
2920 demux->src_segment.format = GST_FORMAT_TIME; in gst_ps_sink_get_duration()
2921 demux->src_segment.start = in gst_ps_sink_get_duration()
2922 MPEGTIME_TO_GSTTIME (demux->first_pts) - demux->base_time; in gst_ps_sink_get_duration()
2923 demux->src_segment.stop = -1; in gst_ps_sink_get_duration()
2924 gst_segment_set_duration (&demux->src_segment, GST_FORMAT_TIME, in gst_ps_sink_get_duration()
2925 MPEGTIME_TO_GSTTIME (demux->last_pts - demux->first_pts)); in gst_ps_sink_get_duration()
2926 gst_segment_set_position (&demux->src_segment, GST_FORMAT_TIME, in gst_ps_sink_get_duration()
2927 demux->src_segment.start); in gst_ps_sink_get_duration()
2929 GST_INFO_OBJECT (demux, "sink segment configured %" GST_SEGMENT_FORMAT, in gst_ps_sink_get_duration()
2930 &demux->sink_segment); in gst_ps_sink_get_duration()
2931 GST_INFO_OBJECT (demux, "src segment configured %" GST_SEGMENT_FORMAT, in gst_ps_sink_get_duration()
2932 &demux->src_segment); in gst_ps_sink_get_duration()
2939 gst_ps_demux_pull_block (GstPad * pad, GstPsDemux * demux, in gst_ps_demux_pull_block() argument
2946 GST_DEBUG_OBJECT (demux, "pull range at %" G_GUINT64_FORMAT in gst_ps_demux_pull_block()
2950 GST_LOG_OBJECT (demux, "pull range at %" G_GUINT64_FORMAT in gst_ps_demux_pull_block()
2952 if (demux->sink_segment.rate < 0) { in gst_ps_demux_pull_block()
2953 GST_LOG_OBJECT (demux, "setting discont flag on backward rate"); in gst_ps_demux_pull_block()
2956 ret = gst_ps_demux_chain (pad, GST_OBJECT (demux), buffer); in gst_ps_demux_pull_block()
2964 GstPsDemux *demux; in gst_ps_demux_loop() local
2967 demux = GST_PS_DEMUX (gst_pad_get_parent (pad)); in gst_ps_demux_loop()
2968 if (G_UNLIKELY (demux->flushing)) { in gst_ps_demux_loop()
2973 if (G_UNLIKELY (demux->sink_segment.format == GST_FORMAT_UNDEFINED)) in gst_ps_demux_loop()
2974 gst_ps_sink_get_duration (demux); in gst_ps_demux_loop()
2975 offset = demux->sink_segment.position; in gst_ps_demux_loop()
2976 if (demux->sink_segment.rate >= 0) { in gst_ps_demux_loop()
2978 if (G_LIKELY (demux->sink_segment.stop != (guint64) - 1)) { in gst_ps_demux_loop()
2979 size = MIN (size, demux->sink_segment.stop - offset); in gst_ps_demux_loop()
2982 ret = gst_ps_demux_pull_block (pad, demux, offset, size); in gst_ps_demux_loop()
2988 gst_segment_set_position (&demux->sink_segment, GST_FORMAT_BYTES, offset); in gst_ps_demux_loop()
2991 if ((demux->sink_segment.position >= demux->sink_segment.stop) || in gst_ps_demux_loop()
2992 (demux->src_segment.stop != (guint64) - 1 && in gst_ps_demux_loop()
2993 demux->src_segment.position >= in gst_ps_demux_loop()
2994 demux->src_segment.stop + demux->base_time)) { in gst_ps_demux_loop()
2995 GST_DEBUG_OBJECT (demux, in gst_ps_demux_loop()
2999 GST_TIME_ARGS (demux->src_segment.position), in gst_ps_demux_loop()
3000 GST_TIME_ARGS (demux->src_segment.stop), in gst_ps_demux_loop()
3001 demux->sink_segment.position, demux->sink_segment.stop); in gst_ps_demux_loop()
3008 ret = gst_ps_demux_pull_block (pad, demux, offset - size, size); in gst_ps_demux_loop()
3014 gst_segment_set_position (&demux->sink_segment, GST_FORMAT_BYTES, offset); in gst_ps_demux_loop()
3016 if (demux->sink_segment.position <= demux->sink_segment.start || in gst_ps_demux_loop()
3017 demux->src_segment.position <= demux->src_segment.start) { in gst_ps_demux_loop()
3018 GST_DEBUG_OBJECT (demux, in gst_ps_demux_loop()
3022 GST_TIME_ARGS (demux->src_segment.position), in gst_ps_demux_loop()
3023 GST_TIME_ARGS (demux->src_segment.start), in gst_ps_demux_loop()
3024 demux->sink_segment.position, demux->sink_segment.start); in gst_ps_demux_loop()
3030 gst_object_unref (demux); in gst_ps_demux_loop()
3035 GST_LOG_OBJECT (demux, "pausing task, reason %s", reason); in gst_ps_demux_loop()
3039 gst_element_no_more_pads (GST_ELEMENT_CAST (demux)); in gst_ps_demux_loop()
3040 if (demux->src_segment.flags & GST_SEEK_FLAG_SEGMENT) { in gst_ps_demux_loop()
3044 if ((stop = demux->src_segment.stop) == -1) in gst_ps_demux_loop()
3045 stop = demux->src_segment.duration; in gst_ps_demux_loop()
3046 if (demux->sink_segment.rate >= 0) { in gst_ps_demux_loop()
3047 GST_LOG_OBJECT (demux, "Sending segment done, at end of segment"); in gst_ps_demux_loop()
3048 gst_element_post_message (GST_ELEMENT_CAST (demux), in gst_ps_demux_loop()
3049 gst_message_new_segment_done (GST_OBJECT_CAST (demux), in gst_ps_demux_loop()
3051 gst_ps_demux_send_event (demux, in gst_ps_demux_loop()
3054 GST_LOG_OBJECT (demux, in gst_ps_demux_loop()
3056 gst_element_post_message (GST_ELEMENT_CAST (demux), in gst_ps_demux_loop()
3057 gst_message_new_segment_done (GST_OBJECT_CAST (demux), in gst_ps_demux_loop()
3058 GST_FORMAT_TIME, demux->src_segment.start)); in gst_ps_demux_loop()
3059 gst_ps_demux_send_event (demux, in gst_ps_demux_loop()
3061 demux->src_segment.start)); in gst_ps_demux_loop()
3066 gst_element_no_more_pads (GST_ELEMENT (demux)); in gst_ps_demux_loop()
3067 GST_LOG_OBJECT (demux, "Sending EOS, at end of stream"); in gst_ps_demux_loop()
3069 if (demux->segment_seqnum) in gst_ps_demux_loop()
3070 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_ps_demux_loop()
3071 if (!gst_ps_demux_send_event (demux, event) in gst_ps_demux_loop()
3072 && !have_open_streams (demux)) { in gst_ps_demux_loop()
3073 GST_WARNING_OBJECT (demux, "EOS and no streams open"); in gst_ps_demux_loop()
3074 GST_ELEMENT_ERROR (demux, STREAM, FAILED, in gst_ps_demux_loop()
3080 GST_ELEMENT_FLOW_ERROR (demux, ret); in gst_ps_demux_loop()
3082 if (demux->segment_seqnum) in gst_ps_demux_loop()
3083 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_ps_demux_loop()
3084 gst_ps_demux_send_event (demux, event); in gst_ps_demux_loop()
3087 gst_object_unref (demux); in gst_ps_demux_loop()
3118 GstPsDemux *demux = GST_PS_DEMUX (parent); in gst_ps_demux_sink_activate_push() local
3119 demux->random_access = FALSE; in gst_ps_demux_sink_activate_push()
3130 GstPsDemux *demux = GST_PS_DEMUX (parent); in gst_ps_demux_sink_activate_pull() local
3133 demux->random_access = TRUE; in gst_ps_demux_sink_activate_pull()
3137 demux->random_access = FALSE; in gst_ps_demux_sink_activate_pull()
3160 gst_ps_demux_combine_flows (GstPsDemux * demux, GstFlowReturn ret) in gst_ps_demux_combine_flows() argument
3162 GST_LOG_OBJECT (demux, "flow return: %s", gst_flow_get_name (ret)); in gst_ps_demux_combine_flows()
3163 ret = gst_flow_combiner_update_flow (demux->flowcombiner, ret); in gst_ps_demux_combine_flows()
3164 if (G_UNLIKELY (demux->need_no_more_pads && ret == GST_FLOW_NOT_LINKED)) in gst_ps_demux_combine_flows()
3166 GST_LOG_OBJECT (demux, "combined flow return: %s", gst_flow_get_name (ret)); in gst_ps_demux_combine_flows()
3173 GstPsDemux *demux = GST_PS_DEMUX (parent); in gst_ps_demux_chain() local
3179 GST_LOG_OBJECT (demux, in gst_ps_demux_chain()
3182 gst_pes_filter_drain (&demux->filter); in gst_ps_demux_chain()
3183 gst_ps_demux_mark_discont (demux, TRUE, FALSE); in gst_ps_demux_chain()
3185 if (demux->sink_segment.rate >= 0.0) { in gst_ps_demux_chain()
3186 demux->current_scr = G_MAXUINT64; in gst_ps_demux_chain()
3187 demux->bytes_since_scr = 0; in gst_ps_demux_chain()
3190 GST_LOG_OBJECT (demux, in gst_ps_demux_chain()
3196 demux->adapter_offset = GST_BUFFER_OFFSET (buffer); in gst_ps_demux_chain()
3197 gst_adapter_push (demux->adapter, buffer); in gst_ps_demux_chain()
3198 demux->bytes_since_scr += gst_buffer_get_size (buffer); in gst_ps_demux_chain()
3199 avail = gst_adapter_available (demux->rev_adapter); in gst_ps_demux_chain()
3201 GST_LOG_OBJECT (demux, "appending %u saved bytes", avail); in gst_ps_demux_chain()
3205 gst_adapter_push (demux->adapter, in gst_ps_demux_chain()
3206 gst_adapter_take_buffer (demux->rev_adapter, avail)); in gst_ps_demux_chain()
3209 avail = gst_adapter_available (demux->adapter); in gst_ps_demux_chain()
3210 GST_LOG_OBJECT (demux, "avail now: %d, state %d", avail, demux->filter.state); in gst_ps_demux_chain()
3211 switch (demux->filter.state) { in gst_ps_demux_chain()
3214 ret = gst_pes_filter_process (&demux->filter); in gst_ps_demux_chain()
3241 while (gst_ps_demux_resync (demux, save)) { in gst_ps_demux_chain()
3243 if (G_UNLIKELY (demux->flushing)) { in gst_ps_demux_chain()
3249 switch (demux->last_sync_code) { in gst_ps_demux_chain()
3251 ret = gst_ps_demux_parse_pack_start (demux); in gst_ps_demux_chain()
3254 ret = gst_ps_demux_parse_sys_head (demux); in gst_ps_demux_chain()
3258 gst_adapter_flush (demux->adapter, 4); in gst_ps_demux_chain()
3263 ret = gst_ps_demux_parse_psm (demux); in gst_ps_demux_chain()
3266 if (gst_ps_demux_is_pes_sync (demux->last_sync_code)) { in gst_ps_demux_chain()
3267 ret = gst_pes_filter_process (&demux->filter); in gst_ps_demux_chain()
3269 GST_DEBUG_OBJECT (demux, "sync_code=%08x, non PES sync found" in gst_ps_demux_chain()
3270 ", continuing", demux->last_sync_code); in gst_ps_demux_chain()
3282 GST_DEBUG_OBJECT (demux, "need more data"); in gst_ps_demux_chain()
3286 if (!save || demux->sink_segment.rate >= 0.0) { in gst_ps_demux_chain()
3287 GST_DEBUG_OBJECT (demux, "flushing 3 bytes"); in gst_ps_demux_chain()
3288 gst_adapter_flush (demux->adapter, 3); in gst_ps_demux_chain()
3291 GST_DEBUG_OBJECT (demux, "saving 3 bytes"); in gst_ps_demux_chain()
3292 gst_adapter_push (demux->rev_adapter, in gst_ps_demux_chain()
3293 gst_adapter_take_buffer (demux->adapter, 3)); in gst_ps_demux_chain()
3298 ret = gst_ps_demux_combine_flows (demux, ret); in gst_ps_demux_chain()
3311 GstPsDemux *demux = GST_PS_DEMUX (element); in gst_ps_demux_change_state() local
3315 gst_pes_filter_init (&demux->filter, demux->adapter, in gst_ps_demux_change_state()
3316 &demux->adapter_offset); in gst_ps_demux_change_state()
3317 gst_pes_filter_set_callbacks (&demux->filter, in gst_ps_demux_change_state()
3319 (GstPESFilterResync) gst_ps_demux_resync_cb, demux); in gst_ps_demux_change_state()
3320 demux->filter.gather_pes = TRUE; in gst_ps_demux_change_state()
3331 gst_ps_demux_reset (demux); in gst_ps_demux_change_state()
3334 gst_pes_filter_uninit (&demux->filter); in gst_ps_demux_change_state()