• Home
  • Raw
  • Download

Lines Matching refs:demux

108 static gboolean flv_demux_handle_seek_push (GstFlvDemux * demux,
110 static gboolean gst_flv_demux_handle_seek_pull (GstFlvDemux * demux,
122 static void gst_flv_demux_push_tags (GstFlvDemux * demux);
125 gst_flv_demux_parse_and_add_index_entry (GstFlvDemux * demux, GstClockTime ts, in gst_flv_demux_parse_and_add_index_entry() argument
132 GST_LOG_OBJECT (demux, in gst_flv_demux_parse_and_add_index_entry()
137 if (!demux->upstream_seekable) in gst_flv_demux_parse_and_add_index_entry()
140 index = gst_flv_demux_get_index (GST_ELEMENT (demux)); in gst_flv_demux_parse_and_add_index_entry()
146 entry = gst_index_get_assoc_entry (index, demux->index_id, in gst_flv_demux_parse_and_add_index_entry()
156 GST_LOG_OBJECT (demux, "position already mapped to time %" GST_TIME_FORMAT in gst_flv_demux_parse_and_add_index_entry()
160 GST_DEBUG_OBJECT (demux, "metadata mismatch"); in gst_flv_demux_parse_and_add_index_entry()
171 gst_index_add_associationv (index, demux->index_id, in gst_flv_demux_parse_and_add_index_entry()
176 if (pos > demux->index_max_pos) in gst_flv_demux_parse_and_add_index_entry()
177 demux->index_max_pos = pos; in gst_flv_demux_parse_and_add_index_entry()
178 if (ts > demux->index_max_time) in gst_flv_demux_parse_and_add_index_entry()
179 demux->index_max_time = ts; in gst_flv_demux_parse_and_add_index_entry()
220 gst_flv_demux_check_seekability (GstFlvDemux * demux) in gst_flv_demux_check_seekability() argument
225 demux->upstream_seekable = FALSE; in gst_flv_demux_check_seekability()
228 if (!gst_pad_peer_query (demux->sinkpad, query)) { in gst_flv_demux_check_seekability()
229 GST_DEBUG_OBJECT (demux, "seeking query failed"); in gst_flv_demux_check_seekability()
234 gst_query_parse_seeking (query, NULL, &demux->upstream_seekable, in gst_flv_demux_check_seekability()
240 if (demux->upstream_seekable && stop == -1) { in gst_flv_demux_check_seekability()
241 GST_DEBUG_OBJECT (demux, "doing duration query to fix up unset stop"); in gst_flv_demux_check_seekability()
242 gst_pad_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &stop); in gst_flv_demux_check_seekability()
247 if (demux->upstream_seekable && (start != 0 || stop <= start)) { in gst_flv_demux_check_seekability()
248 GST_DEBUG_OBJECT (demux, "seekable but unknown start/stop -> disable"); in gst_flv_demux_check_seekability()
249 demux->upstream_seekable = FALSE; in gst_flv_demux_check_seekability()
252 GST_DEBUG_OBJECT (demux, "upstream seekable: %d", demux->upstream_seekable); in gst_flv_demux_check_seekability()
330 gst_flv_demux_parse_metadata_item (GstFlvDemux * demux, GstByteReader * reader, in gst_flv_demux_parse_metadata_item() argument
342 GST_WARNING_OBJECT (demux, "failed reading tag name"); in gst_flv_demux_parse_metadata_item()
350 GST_DEBUG_OBJECT (demux, "tag name %s, tag type %d", tag_name, tag_type); in gst_flv_demux_parse_metadata_item()
360 GST_DEBUG_OBJECT (demux, "%s => (double) %f", tag_name, d); in gst_flv_demux_parse_metadata_item()
363 demux->duration = d * GST_SECOND; in gst_flv_demux_parse_metadata_item()
365 gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE, in gst_flv_demux_parse_metadata_item()
366 GST_TAG_DURATION, demux->duration, NULL); in gst_flv_demux_parse_metadata_item()
368 demux->par_x = d; in gst_flv_demux_parse_metadata_item()
369 demux->got_par = TRUE; in gst_flv_demux_parse_metadata_item()
371 demux->par_y = d; in gst_flv_demux_parse_metadata_item()
372 demux->got_par = TRUE; in gst_flv_demux_parse_metadata_item()
374 demux->w = d; in gst_flv_demux_parse_metadata_item()
376 demux->h = d; in gst_flv_demux_parse_metadata_item()
378 demux->framerate = d; in gst_flv_demux_parse_metadata_item()
380 demux->audio_bitrate = (guint) (d * 1024); in gst_flv_demux_parse_metadata_item()
381 gst_tag_list_add (demux->audio_tags, GST_TAG_MERGE_REPLACE, in gst_flv_demux_parse_metadata_item()
382 GST_TAG_NOMINAL_BITRATE, demux->audio_bitrate, NULL); in gst_flv_demux_parse_metadata_item()
384 demux->video_bitrate = (guint) (d * 1024); in gst_flv_demux_parse_metadata_item()
385 gst_tag_list_add (demux->video_tags, GST_TAG_MERGE_REPLACE, in gst_flv_demux_parse_metadata_item()
386 GST_TAG_NOMINAL_BITRATE, demux->video_bitrate, NULL); in gst_flv_demux_parse_metadata_item()
388 GST_INFO_OBJECT (demux, "Tag \'%s\' not handled", tag_name); in gst_flv_demux_parse_metadata_item()
400 GST_DEBUG_OBJECT (demux, "%s => (boolean) %d", tag_name, b); in gst_flv_demux_parse_metadata_item()
402 GST_INFO_OBJECT (demux, "Tag \'%s\' not handled", tag_name); in gst_flv_demux_parse_metadata_item()
419 GST_DEBUG_OBJECT (demux, "%s => (string) %s", tag_name, s); in gst_flv_demux_parse_metadata_item()
426 GST_DEBUG_OBJECT (demux, "Failed to parse '%s' into datetime", s); in gst_flv_demux_parse_metadata_item()
428 gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE, in gst_flv_demux_parse_metadata_item()
433 gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE, in gst_flv_demux_parse_metadata_item()
436 gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE, in gst_flv_demux_parse_metadata_item()
440 gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE, in gst_flv_demux_parse_metadata_item()
443 GST_INFO_OBJECT (demux, "Tag \'%s\' not handled", tag_name); in gst_flv_demux_parse_metadata_item()
455 gboolean ok = gst_flv_demux_parse_metadata_item (demux, reader, in gst_flv_demux_parse_metadata_item()
459 GST_WARNING_OBJECT (demux, "failed reading a tag, skipping"); in gst_flv_demux_parse_metadata_item()
474 GST_DEBUG_OBJECT (demux, "there are approx. %d elements in the array", in gst_flv_demux_parse_metadata_item()
478 gboolean ok = gst_flv_demux_parse_metadata_item (demux, reader, in gst_flv_demux_parse_metadata_item()
482 GST_WARNING_OBJECT (demux, "failed reading a tag, skipping"); in gst_flv_demux_parse_metadata_item()
491 GST_DEBUG_OBJECT (demux, "end marker ?"); in gst_flv_demux_parse_metadata_item()
494 GST_DEBUG_OBJECT (demux, "end marker detected"); in gst_flv_demux_parse_metadata_item()
508 GST_DEBUG_OBJECT (demux, "array has %d elements", nb_elems); in gst_flv_demux_parse_metadata_item()
511 if (demux->times) { in gst_flv_demux_parse_metadata_item()
512 g_array_free (demux->times, TRUE); in gst_flv_demux_parse_metadata_item()
514 demux->times = g_array_new (FALSE, TRUE, sizeof (gdouble)); in gst_flv_demux_parse_metadata_item()
516 if (demux->filepositions) { in gst_flv_demux_parse_metadata_item()
517 g_array_free (demux->filepositions, TRUE); in gst_flv_demux_parse_metadata_item()
519 demux->filepositions = g_array_new (FALSE, TRUE, sizeof (gdouble)); in gst_flv_demux_parse_metadata_item()
536 GST_DEBUG_OBJECT (demux, "element is a double %f", d); in gst_flv_demux_parse_metadata_item()
538 if (!strcmp (tag_name, "times") && demux->times) { in gst_flv_demux_parse_metadata_item()
539 g_array_append_val (demux->times, d); in gst_flv_demux_parse_metadata_item()
541 demux->filepositions) { in gst_flv_demux_parse_metadata_item()
542 g_array_append_val (demux->filepositions, d); in gst_flv_demux_parse_metadata_item()
547 GST_WARNING_OBJECT (demux, "unsupported array element type %d", in gst_flv_demux_parse_metadata_item()
565 GST_DEBUG_OBJECT (demux, in gst_flv_demux_parse_metadata_item()
568 GST_INFO_OBJECT (demux, "Tag \'%s\' not handled", tag_name); in gst_flv_demux_parse_metadata_item()
573 GST_WARNING_OBJECT (demux, "unsupported tag type %d", tag_type); in gst_flv_demux_parse_metadata_item()
587 gst_flv_demux_clear_tags (GstFlvDemux * demux) in gst_flv_demux_clear_tags() argument
589 GST_DEBUG_OBJECT (demux, "clearing taglist"); in gst_flv_demux_clear_tags()
591 if (demux->taglist) { in gst_flv_demux_clear_tags()
592 gst_tag_list_unref (demux->taglist); in gst_flv_demux_clear_tags()
594 demux->taglist = gst_tag_list_new_empty (); in gst_flv_demux_clear_tags()
595 gst_tag_list_set_scope (demux->taglist, GST_TAG_SCOPE_GLOBAL); in gst_flv_demux_clear_tags()
597 if (demux->audio_tags) { in gst_flv_demux_clear_tags()
598 gst_tag_list_unref (demux->audio_tags); in gst_flv_demux_clear_tags()
600 demux->audio_tags = gst_tag_list_new_empty (); in gst_flv_demux_clear_tags()
602 if (demux->video_tags) { in gst_flv_demux_clear_tags()
603 gst_tag_list_unref (demux->video_tags); in gst_flv_demux_clear_tags()
605 demux->video_tags = gst_tag_list_new_empty (); in gst_flv_demux_clear_tags()
609 gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer) in gst_flv_demux_parse_tag_script() argument
623 GST_LOG_OBJECT (demux, "parsing a script tag"); in gst_flv_demux_parse_tag_script()
635 GST_LOG_OBJECT (demux, "function name is %s", GST_STR_NULL (function_name)); in gst_flv_demux_parse_tag_script()
639 GST_DEBUG_OBJECT (demux, "we have a metadata script object"); in gst_flv_demux_parse_tag_script()
641 gst_flv_demux_clear_tags (demux); in gst_flv_demux_parse_tag_script()
661 GST_DEBUG_OBJECT (demux, "there are approx. %d elements in the array", in gst_flv_demux_parse_tag_script()
670 gst_flv_demux_parse_metadata_item (demux, &reader, &end_marker); in gst_flv_demux_parse_tag_script()
673 GST_WARNING_OBJECT (demux, "failed reading a tag, skipping"); in gst_flv_demux_parse_tag_script()
680 GST_DEBUG_OBJECT (demux, "Unhandled script data type : %d", type); in gst_flv_demux_parse_tag_script()
685 gst_flv_demux_push_tags (demux); in gst_flv_demux_parse_tag_script()
690 if (demux->times && demux->filepositions) { in gst_flv_demux_parse_tag_script()
694 num = MIN (demux->times->len, demux->filepositions->len); in gst_flv_demux_parse_tag_script()
698 time = g_array_index (demux->times, gdouble, i) * GST_SECOND; in gst_flv_demux_parse_tag_script()
699 fileposition = g_array_index (demux->filepositions, gdouble, i); in gst_flv_demux_parse_tag_script()
700 gst_flv_demux_parse_and_add_index_entry (demux, time, fileposition, in gst_flv_demux_parse_tag_script()
703 demux->indexed = TRUE; in gst_flv_demux_parse_tag_script()
714 have_group_id (GstFlvDemux * demux) in have_group_id() argument
718 event = gst_pad_get_sticky_event (demux->sinkpad, GST_EVENT_STREAM_START, 0); in have_group_id()
720 if (gst_event_parse_group_id (event, &demux->group_id)) in have_group_id()
721 demux->have_group_id = TRUE; in have_group_id()
723 demux->have_group_id = FALSE; in have_group_id()
725 } else if (!demux->have_group_id) { in have_group_id()
726 demux->have_group_id = TRUE; in have_group_id()
727 demux->group_id = gst_util_group_id_next (); in have_group_id()
730 return demux->have_group_id; in have_group_id()
734 gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag, in gst_flv_demux_audio_negotiate() argument
779 if (!demux->audio_codec_data) { in gst_flv_demux_audio_negotiate()
780 GST_DEBUG_OBJECT (demux, "don't have AAC codec data yet"); in gst_flv_demux_audio_negotiate()
785 gst_buffer_map (demux->audio_codec_data, &map, GST_MAP_READ); in gst_flv_demux_audio_negotiate()
797 GST_LOG_OBJECT (demux, "Ajusting AAC sample rate %d -> %d", rate, in gst_flv_demux_audio_negotiate()
807 GST_LOG_OBJECT (demux, "Ajusting AAC channels %d -> %d", channels, in gst_flv_demux_audio_negotiate()
813 gst_buffer_unmap (demux->audio_codec_data, &map); in gst_flv_demux_audio_negotiate()
838 GST_DEBUG_OBJECT (demux, "generating speex header"); in gst_flv_demux_audio_negotiate()
884 GST_WARNING_OBJECT (demux, "unsupported audio codec tag %u", codec_tag); in gst_flv_demux_audio_negotiate()
889 GST_WARNING_OBJECT (demux, "failed creating caps for audio pad"); in gst_flv_demux_audio_negotiate()
896 if (demux->audio_codec_data) { in gst_flv_demux_audio_negotiate()
898 demux->audio_codec_data, NULL); in gst_flv_demux_audio_negotiate()
901 old_caps = gst_pad_get_current_caps (demux->audio_pad); in gst_flv_demux_audio_negotiate()
904 gst_pad_create_stream_id (demux->audio_pad, GST_ELEMENT_CAST (demux), in gst_flv_demux_audio_negotiate()
908 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_audio_negotiate()
909 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_flv_demux_audio_negotiate()
910 if (have_group_id (demux)) in gst_flv_demux_audio_negotiate()
911 gst_event_set_group_id (event, demux->group_id); in gst_flv_demux_audio_negotiate()
912 gst_pad_push_event (demux->audio_pad, event); in gst_flv_demux_audio_negotiate()
916 ret = gst_pad_set_caps (demux->audio_pad, caps); in gst_flv_demux_audio_negotiate()
926 demux->audio_codec_tag = codec_tag; in gst_flv_demux_audio_negotiate()
927 demux->rate = rate; in gst_flv_demux_audio_negotiate()
928 demux->channels = channels; in gst_flv_demux_audio_negotiate()
929 demux->width = width; in gst_flv_demux_audio_negotiate()
932 GST_DEBUG_OBJECT (demux->audio_pad, "successfully negotiated caps %" in gst_flv_demux_audio_negotiate()
935 gst_flv_demux_push_tags (demux); in gst_flv_demux_audio_negotiate()
937 GST_DEBUG_OBJECT (demux->audio_pad, "delayed setting caps"); in gst_flv_demux_audio_negotiate()
940 GST_WARNING_OBJECT (demux->audio_pad, "failed negotiating caps %" in gst_flv_demux_audio_negotiate()
952 gst_flv_demux_push_src_event (GstFlvDemux * demux, GstEvent * event) in gst_flv_demux_push_src_event() argument
956 if (demux->audio_pad) in gst_flv_demux_push_src_event()
957 ret |= gst_pad_push_event (demux->audio_pad, gst_event_ref (event)); in gst_flv_demux_push_src_event()
959 if (demux->video_pad) in gst_flv_demux_push_src_event()
960 ret |= gst_pad_push_event (demux->video_pad, gst_event_ref (event)); in gst_flv_demux_push_src_event()
968 gst_flv_demux_add_codec_tag (GstFlvDemux * demux, const gchar * tag, in gst_flv_demux_add_codec_tag() argument
978 gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE, in gst_flv_demux_add_codec_tag()
989 gst_flv_demux_push_tags (GstFlvDemux * demux) in gst_flv_demux_push_tags() argument
993 gst_flv_demux_add_codec_tag (demux, GST_TAG_AUDIO_CODEC, demux->audio_pad); in gst_flv_demux_push_tags()
994 gst_flv_demux_add_codec_tag (demux, GST_TAG_VIDEO_CODEC, demux->video_pad); in gst_flv_demux_push_tags()
996 GST_DEBUG_OBJECT (demux, "pushing %" GST_PTR_FORMAT, demux->taglist); in gst_flv_demux_push_tags()
998 tag_event = gst_event_new_tag (gst_tag_list_copy (demux->taglist)); in gst_flv_demux_push_tags()
999 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_push_tags()
1000 gst_event_set_seqnum (tag_event, demux->segment_seqnum); in gst_flv_demux_push_tags()
1001 gst_flv_demux_push_src_event (demux, tag_event); in gst_flv_demux_push_tags()
1003 if (demux->audio_pad) { in gst_flv_demux_push_tags()
1004 GST_DEBUG_OBJECT (demux->audio_pad, "pushing audio %" GST_PTR_FORMAT, in gst_flv_demux_push_tags()
1005 demux->audio_tags); in gst_flv_demux_push_tags()
1006 tag_event = gst_event_new_tag (gst_tag_list_copy (demux->audio_tags)); in gst_flv_demux_push_tags()
1007 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_push_tags()
1008 gst_event_set_seqnum (tag_event, demux->segment_seqnum); in gst_flv_demux_push_tags()
1009 gst_pad_push_event (demux->audio_pad, tag_event); in gst_flv_demux_push_tags()
1012 if (demux->video_pad) { in gst_flv_demux_push_tags()
1013 GST_DEBUG_OBJECT (demux->video_pad, "pushing video %" GST_PTR_FORMAT, in gst_flv_demux_push_tags()
1014 demux->video_tags); in gst_flv_demux_push_tags()
1015 tag_event = gst_event_new_tag (gst_tag_list_copy (demux->video_tags)); in gst_flv_demux_push_tags()
1016 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_push_tags()
1017 gst_event_set_seqnum (tag_event, demux->segment_seqnum); in gst_flv_demux_push_tags()
1018 gst_pad_push_event (demux->video_pad, tag_event); in gst_flv_demux_push_tags()
1023 gst_flv_demux_update_resync (GstFlvDemux * demux, guint32 dts, gboolean discont, in gst_flv_demux_update_resync() argument
1033 GST_WARNING_OBJECT (demux, in gst_flv_demux_update_resync()
1045 gst_flv_demux_sync_streams (GstFlvDemux * demux) in gst_flv_demux_sync_streams() argument
1050 if (demux->audio_pad && GST_CLOCK_TIME_IS_VALID (demux->segment.position) && in gst_flv_demux_sync_streams()
1051 demux->last_audio_pts * GST_MSECOND + demux->audio_time_offset + in gst_flv_demux_sync_streams()
1052 3 * GST_SECOND < demux->segment.position) { in gst_flv_demux_sync_streams()
1055 demux->last_audio_pts * GST_MSECOND + demux->audio_time_offset; in gst_flv_demux_sync_streams()
1056 guint64 stop = demux->segment.position - 3 * GST_SECOND; in gst_flv_demux_sync_streams()
1058 GST_DEBUG_OBJECT (demux, in gst_flv_demux_sync_streams()
1063 demux->last_audio_pts = (stop - demux->audio_time_offset) / GST_MSECOND; in gst_flv_demux_sync_streams()
1066 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_sync_streams()
1067 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_flv_demux_sync_streams()
1068 gst_pad_push_event (demux->audio_pad, event); in gst_flv_demux_sync_streams()
1071 if (demux->video_pad && GST_CLOCK_TIME_IS_VALID (demux->segment.position) && in gst_flv_demux_sync_streams()
1072 demux->last_video_dts * GST_MSECOND + demux->video_time_offset + in gst_flv_demux_sync_streams()
1073 3 * GST_SECOND < demux->segment.position) { in gst_flv_demux_sync_streams()
1076 demux->last_video_dts * GST_MSECOND + demux->video_time_offset; in gst_flv_demux_sync_streams()
1077 guint64 stop = demux->segment.position - 3 * GST_SECOND; in gst_flv_demux_sync_streams()
1079 GST_DEBUG_OBJECT (demux, in gst_flv_demux_sync_streams()
1084 demux->last_video_dts = (stop - demux->video_time_offset) / GST_MSECOND; in gst_flv_demux_sync_streams()
1087 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_sync_streams()
1088 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_flv_demux_sync_streams()
1089 gst_pad_push_event (demux->video_pad, event); in gst_flv_demux_sync_streams()
1094 gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer) in gst_flv_demux_parse_tag_audio() argument
1104 GST_LOG_OBJECT (demux, "parsing an audio tag"); in gst_flv_demux_parse_tag_audio()
1106 if (G_UNLIKELY (!demux->audio_pad && demux->no_more_pads)) { in gst_flv_demux_parse_tag_audio()
1108 if (G_UNLIKELY (!demux->no_audio_warned)) { in gst_flv_demux_parse_tag_audio()
1109 GST_WARNING_OBJECT (demux, in gst_flv_demux_parse_tag_audio()
1111 demux->no_audio_warned = TRUE; in gst_flv_demux_parse_tag_audio()
1117 g_return_val_if_fail (gst_buffer_get_size (buffer) == demux->tag_size, in gst_flv_demux_parse_tag_audio()
1122 GST_ERROR_OBJECT (demux, "Too small tag size (%" G_GSIZE_FORMAT ")", in gst_flv_demux_parse_tag_audio()
1137 GST_LOG_OBJECT (demux, "pts bytes %02X %02X %02X %02X (%d)", data[0], data[1], in gst_flv_demux_parse_tag_audio()
1177 GST_LOG_OBJECT (demux, "audio tag with %d channels, %dHz sampling rate, " in gst_flv_demux_parse_tag_audio()
1188 GST_LOG_OBJECT (demux, "got an AAC codec data packet"); in gst_flv_demux_parse_tag_audio()
1189 if (demux->audio_codec_data) { in gst_flv_demux_parse_tag_audio()
1190 gst_buffer_unref (demux->audio_codec_data); in gst_flv_demux_parse_tag_audio()
1192 demux->audio_codec_data = in gst_flv_demux_parse_tag_audio()
1194 7 + codec_data, demux->tag_data_size - codec_data); in gst_flv_demux_parse_tag_audio()
1197 if (demux->audio_pad) in gst_flv_demux_parse_tag_audio()
1198 gst_flv_demux_audio_negotiate (demux, codec_tag, rate, channels, in gst_flv_demux_parse_tag_audio()
1203 if (!demux->audio_codec_data) { in gst_flv_demux_parse_tag_audio()
1204 GST_ERROR_OBJECT (demux, "got AAC audio packet before codec data"); in gst_flv_demux_parse_tag_audio()
1209 GST_LOG_OBJECT (demux, "got a raw AAC audio packet"); in gst_flv_demux_parse_tag_audio()
1212 GST_WARNING_OBJECT (demux, "invalid AAC packet type %u", in gst_flv_demux_parse_tag_audio()
1218 if (G_UNLIKELY (!demux->audio_pad)) { in gst_flv_demux_parse_tag_audio()
1219 demux->audio_pad = in gst_flv_demux_parse_tag_audio()
1221 (GST_ELEMENT_GET_CLASS (demux), "audio"), "audio"); in gst_flv_demux_parse_tag_audio()
1222 if (G_UNLIKELY (!demux->audio_pad)) { in gst_flv_demux_parse_tag_audio()
1223 GST_WARNING_OBJECT (demux, "failed creating audio pad"); in gst_flv_demux_parse_tag_audio()
1229 gst_pad_set_query_function (demux->audio_pad, in gst_flv_demux_parse_tag_audio()
1231 gst_pad_set_event_function (demux->audio_pad, in gst_flv_demux_parse_tag_audio()
1234 gst_pad_use_fixed_caps (demux->audio_pad); in gst_flv_demux_parse_tag_audio()
1237 gst_pad_set_active (demux->audio_pad, TRUE); in gst_flv_demux_parse_tag_audio()
1240 if (!gst_flv_demux_audio_negotiate (demux, codec_tag, rate, channels, in gst_flv_demux_parse_tag_audio()
1242 gst_object_unref (demux->audio_pad); in gst_flv_demux_parse_tag_audio()
1243 demux->audio_pad = NULL; in gst_flv_demux_parse_tag_audio()
1251 caps = gst_pad_get_current_caps (demux->audio_pad); in gst_flv_demux_parse_tag_audio()
1252 GST_DEBUG_OBJECT (demux, "created audio pad with caps %" GST_PTR_FORMAT, in gst_flv_demux_parse_tag_audio()
1260 gst_element_add_pad (GST_ELEMENT (demux), in gst_flv_demux_parse_tag_audio()
1261 gst_object_ref (demux->audio_pad)); in gst_flv_demux_parse_tag_audio()
1262 gst_flow_combiner_add_pad (demux->flowcombiner, demux->audio_pad); in gst_flv_demux_parse_tag_audio()
1267 if (demux->audio_pad && demux->video_pad) { in gst_flv_demux_parse_tag_audio()
1268 GST_DEBUG_OBJECT (demux, "emitting no more pads"); in gst_flv_demux_parse_tag_audio()
1269 gst_element_no_more_pads (GST_ELEMENT (demux)); in gst_flv_demux_parse_tag_audio()
1270 demux->no_more_pads = TRUE; in gst_flv_demux_parse_tag_audio()
1275 if (G_UNLIKELY (rate != demux->rate || channels != demux->channels || in gst_flv_demux_parse_tag_audio()
1276 codec_tag != demux->audio_codec_tag || width != demux->width)) { in gst_flv_demux_parse_tag_audio()
1277 GST_DEBUG_OBJECT (demux, "audio settings have changed, changing caps"); in gst_flv_demux_parse_tag_audio()
1279 gst_buffer_replace (&demux->audio_codec_data, NULL); in gst_flv_demux_parse_tag_audio()
1282 if (!gst_flv_demux_audio_negotiate (demux, codec_tag, rate, channels, in gst_flv_demux_parse_tag_audio()
1290 if (demux->tag_data_size <= codec_data) { in gst_flv_demux_parse_tag_audio()
1291 GST_LOG_OBJECT (demux, "Nothing left in this tag, returning"); in gst_flv_demux_parse_tag_audio()
1297 7 + codec_data, demux->tag_data_size - codec_data); in gst_flv_demux_parse_tag_audio()
1300 if (gst_flv_demux_update_resync (demux, pts, demux->audio_need_discont, in gst_flv_demux_parse_tag_audio()
1301 &demux->last_audio_pts, &demux->audio_time_offset)) { in gst_flv_demux_parse_tag_audio()
1306 GST_BUFFER_PTS (outbuf) = pts * GST_MSECOND + demux->audio_time_offset; in gst_flv_demux_parse_tag_audio()
1309 GST_BUFFER_OFFSET (outbuf) = demux->audio_offset++; in gst_flv_demux_parse_tag_audio()
1310 GST_BUFFER_OFFSET_END (outbuf) = demux->audio_offset; in gst_flv_demux_parse_tag_audio()
1312 if (demux->duration == GST_CLOCK_TIME_NONE || in gst_flv_demux_parse_tag_audio()
1313 demux->duration < GST_BUFFER_TIMESTAMP (outbuf)) in gst_flv_demux_parse_tag_audio()
1314 demux->duration = GST_BUFFER_TIMESTAMP (outbuf); in gst_flv_demux_parse_tag_audio()
1318 if (!demux->has_video && !demux->indexed) { in gst_flv_demux_parse_tag_audio()
1319 gst_flv_demux_parse_and_add_index_entry (demux, in gst_flv_demux_parse_tag_audio()
1320 GST_BUFFER_TIMESTAMP (outbuf), demux->cur_tag_offset, TRUE); in gst_flv_demux_parse_tag_audio()
1323 if (G_UNLIKELY (demux->audio_need_discont)) { in gst_flv_demux_parse_tag_audio()
1325 demux->audio_need_discont = FALSE; in gst_flv_demux_parse_tag_audio()
1328 demux->segment.position = GST_BUFFER_TIMESTAMP (outbuf); in gst_flv_demux_parse_tag_audio()
1331 if (G_UNLIKELY (demux->audio_need_segment)) { in gst_flv_demux_parse_tag_audio()
1332 if (!demux->new_seg_event) { in gst_flv_demux_parse_tag_audio()
1333 GST_DEBUG_OBJECT (demux, "pushing newsegment from %" in gst_flv_demux_parse_tag_audio()
1335 GST_TIME_ARGS (demux->segment.position), in gst_flv_demux_parse_tag_audio()
1336 GST_TIME_ARGS (demux->segment.stop)); in gst_flv_demux_parse_tag_audio()
1337 demux->segment.start = demux->segment.time = demux->segment.position; in gst_flv_demux_parse_tag_audio()
1338 demux->new_seg_event = gst_event_new_segment (&demux->segment); in gst_flv_demux_parse_tag_audio()
1339 gst_event_set_seqnum (demux->new_seg_event, demux->segment_seqnum); in gst_flv_demux_parse_tag_audio()
1341 GST_DEBUG_OBJECT (demux, "pushing pre-generated newsegment event"); in gst_flv_demux_parse_tag_audio()
1344 gst_pad_push_event (demux->audio_pad, gst_event_ref (demux->new_seg_event)); in gst_flv_demux_parse_tag_audio()
1346 demux->audio_need_segment = FALSE; in gst_flv_demux_parse_tag_audio()
1349 GST_LOG_OBJECT (demux, in gst_flv_demux_parse_tag_audio()
1356 if (!GST_CLOCK_TIME_IS_VALID (demux->audio_start)) { in gst_flv_demux_parse_tag_audio()
1357 demux->audio_start = GST_BUFFER_TIMESTAMP (outbuf); in gst_flv_demux_parse_tag_audio()
1359 if (!GST_CLOCK_TIME_IS_VALID (demux->audio_first_ts)) { in gst_flv_demux_parse_tag_audio()
1360 demux->audio_first_ts = GST_BUFFER_TIMESTAMP (outbuf); in gst_flv_demux_parse_tag_audio()
1363 if (G_UNLIKELY (!demux->no_more_pads in gst_flv_demux_parse_tag_audio()
1364 && (GST_CLOCK_DIFF (demux->audio_start, in gst_flv_demux_parse_tag_audio()
1366 GST_DEBUG_OBJECT (demux, in gst_flv_demux_parse_tag_audio()
1369 gst_element_no_more_pads (GST_ELEMENT_CAST (demux)); in gst_flv_demux_parse_tag_audio()
1370 demux->no_more_pads = TRUE; in gst_flv_demux_parse_tag_audio()
1374 ret = gst_pad_push (demux->audio_pad, outbuf); in gst_flv_demux_parse_tag_audio()
1377 demux->segment.rate < 0.0 && ret == GST_FLOW_EOS && in gst_flv_demux_parse_tag_audio()
1378 demux->segment.position > demux->segment.stop) { in gst_flv_demux_parse_tag_audio()
1382 GST_DEBUG_OBJECT (demux, "downstream has reached end of segment"); in gst_flv_demux_parse_tag_audio()
1383 demux->audio_done = TRUE; in gst_flv_demux_parse_tag_audio()
1388 ret = gst_flow_combiner_update_pad_flow (demux->flowcombiner, in gst_flv_demux_parse_tag_audio()
1389 demux->audio_pad, ret); in gst_flv_demux_parse_tag_audio()
1392 gst_flv_demux_sync_streams (demux); in gst_flv_demux_parse_tag_audio()
1402 gst_flv_demux_video_negotiate (GstFlvDemux * demux, guint32 codec_tag) in gst_flv_demux_video_negotiate() argument
1426 if (!demux->video_codec_data) { in gst_flv_demux_video_negotiate()
1427 GST_DEBUG_OBJECT (demux, "don't have h264 codec data yet"); in gst_flv_demux_video_negotiate()
1448 GST_WARNING_OBJECT (demux, "unsupported video codec tag %u", codec_tag); in gst_flv_demux_video_negotiate()
1452 GST_WARNING_OBJECT (demux, "failed creating caps for video pad"); in gst_flv_demux_video_negotiate()
1456 if (demux->got_par) { in gst_flv_demux_video_negotiate()
1458 demux->par_x, demux->par_y, NULL); in gst_flv_demux_video_negotiate()
1461 if (G_LIKELY (demux->w)) { in gst_flv_demux_video_negotiate()
1462 gst_caps_set_simple (caps, "width", G_TYPE_INT, demux->w, NULL); in gst_flv_demux_video_negotiate()
1465 if (G_LIKELY (demux->h)) { in gst_flv_demux_video_negotiate()
1466 gst_caps_set_simple (caps, "height", G_TYPE_INT, demux->h, NULL); in gst_flv_demux_video_negotiate()
1469 if (G_LIKELY (demux->framerate)) { in gst_flv_demux_video_negotiate()
1472 gst_video_guess_framerate (GST_SECOND / demux->framerate, &num, &den); in gst_flv_demux_video_negotiate()
1473 GST_DEBUG_OBJECT (demux->video_pad, in gst_flv_demux_video_negotiate()
1474 "fps to be used on caps %f (as a fraction = %d/%d)", demux->framerate, in gst_flv_demux_video_negotiate()
1480 if (demux->video_codec_data) { in gst_flv_demux_video_negotiate()
1482 demux->video_codec_data, NULL); in gst_flv_demux_video_negotiate()
1485 old_caps = gst_pad_get_current_caps (demux->video_pad); in gst_flv_demux_video_negotiate()
1488 gst_pad_create_stream_id (demux->video_pad, GST_ELEMENT_CAST (demux), in gst_flv_demux_video_negotiate()
1491 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_video_negotiate()
1492 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_flv_demux_video_negotiate()
1495 if (have_group_id (demux)) in gst_flv_demux_video_negotiate()
1496 gst_event_set_group_id (event, demux->group_id); in gst_flv_demux_video_negotiate()
1497 gst_pad_push_event (demux->video_pad, event); in gst_flv_demux_video_negotiate()
1501 ret = gst_pad_set_caps (demux->video_pad, caps); in gst_flv_demux_video_negotiate()
1511 demux->video_codec_tag = codec_tag; in gst_flv_demux_video_negotiate()
1514 GST_DEBUG_OBJECT (demux->video_pad, "successfully negotiated caps %" in gst_flv_demux_video_negotiate()
1517 gst_flv_demux_push_tags (demux); in gst_flv_demux_video_negotiate()
1519 GST_DEBUG_OBJECT (demux->video_pad, "delayed setting caps"); in gst_flv_demux_video_negotiate()
1522 GST_WARNING_OBJECT (demux->video_pad, "failed negotiating caps %" in gst_flv_demux_video_negotiate()
1534 gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer) in gst_flv_demux_parse_tag_video() argument
1545 g_return_val_if_fail (gst_buffer_get_size (buffer) == demux->tag_size, in gst_flv_demux_parse_tag_video()
1548 GST_LOG_OBJECT (demux, "parsing a video tag"); in gst_flv_demux_parse_tag_video()
1551 (!demux->video_pad && demux->no_more_pads) { in gst_flv_demux_parse_tag_video()
1554 (!demux->no_video_warned) { in gst_flv_demux_parse_tag_video()
1555 GST_WARNING_OBJECT (demux, in gst_flv_demux_parse_tag_video()
1557 demux->no_video_warned = TRUE; in gst_flv_demux_parse_tag_video()
1564 GST_ERROR_OBJECT (demux, "Too small tag size"); in gst_flv_demux_parse_tag_video()
1578 GST_LOG_OBJECT (demux, "dts bytes %02X %02X %02X %02X (%d)", data[0], data[1], in gst_flv_demux_parse_tag_video()
1599 GST_ERROR_OBJECT (demux, "Detected a negative composition time offset " in gst_flv_demux_parse_tag_video()
1604 GST_LOG_OBJECT (demux, "got cts %d", cts); in gst_flv_demux_parse_tag_video()
1607 GST_LOG_OBJECT (demux, "video tag with codec tag %u, keyframe (%d) " in gst_flv_demux_parse_tag_video()
1616 if (demux->tag_data_size < codec_data) { in gst_flv_demux_parse_tag_video()
1617 GST_ERROR_OBJECT (demux, "Got invalid H.264 codec, ignoring."); in gst_flv_demux_parse_tag_video()
1622 GST_LOG_OBJECT (demux, "got an H.264 codec data packet"); in gst_flv_demux_parse_tag_video()
1623 if (demux->video_codec_data) { in gst_flv_demux_parse_tag_video()
1624 gst_buffer_unref (demux->video_codec_data); in gst_flv_demux_parse_tag_video()
1626 demux->video_codec_data = gst_buffer_copy_region (buffer, in gst_flv_demux_parse_tag_video()
1628 demux->tag_data_size - codec_data);; in gst_flv_demux_parse_tag_video()
1630 if (demux->video_pad) in gst_flv_demux_parse_tag_video()
1631 gst_flv_demux_video_negotiate (demux, codec_tag); in gst_flv_demux_parse_tag_video()
1636 if (!demux->video_codec_data) { in gst_flv_demux_parse_tag_video()
1637 GST_ERROR_OBJECT (demux, "got H.264 video packet before codec data"); in gst_flv_demux_parse_tag_video()
1641 GST_LOG_OBJECT (demux, "got a H.264 NALU video packet"); in gst_flv_demux_parse_tag_video()
1644 GST_WARNING_OBJECT (demux, "invalid video packet type %u", in gst_flv_demux_parse_tag_video()
1650 if (G_UNLIKELY (!demux->video_pad)) { in gst_flv_demux_parse_tag_video()
1651 demux->video_pad = in gst_flv_demux_parse_tag_video()
1653 (GST_ELEMENT_GET_CLASS (demux), "video"), "video"); in gst_flv_demux_parse_tag_video()
1654 if (G_UNLIKELY (!demux->video_pad)) { in gst_flv_demux_parse_tag_video()
1655 GST_WARNING_OBJECT (demux, "failed creating video pad"); in gst_flv_demux_parse_tag_video()
1661 gst_pad_set_query_function (demux->video_pad, in gst_flv_demux_parse_tag_video()
1663 gst_pad_set_event_function (demux->video_pad, in gst_flv_demux_parse_tag_video()
1666 gst_pad_use_fixed_caps (demux->video_pad); in gst_flv_demux_parse_tag_video()
1669 gst_pad_set_active (demux->video_pad, TRUE); in gst_flv_demux_parse_tag_video()
1672 if (!gst_flv_demux_video_negotiate (demux, codec_tag)) { in gst_flv_demux_parse_tag_video()
1673 gst_object_unref (demux->video_pad); in gst_flv_demux_parse_tag_video()
1674 demux->video_pad = NULL; in gst_flv_demux_parse_tag_video()
1681 demux->got_par = FALSE; in gst_flv_demux_parse_tag_video()
1687 caps = gst_pad_get_current_caps (demux->video_pad); in gst_flv_demux_parse_tag_video()
1688 GST_DEBUG_OBJECT (demux, "created video pad with caps %" GST_PTR_FORMAT, in gst_flv_demux_parse_tag_video()
1696 gst_element_add_pad (GST_ELEMENT (demux), in gst_flv_demux_parse_tag_video()
1697 gst_object_ref (demux->video_pad)); in gst_flv_demux_parse_tag_video()
1698 gst_flow_combiner_add_pad (demux->flowcombiner, demux->video_pad); in gst_flv_demux_parse_tag_video()
1703 if (demux->audio_pad && demux->video_pad) { in gst_flv_demux_parse_tag_video()
1704 GST_DEBUG_OBJECT (demux, "emitting no more pads"); in gst_flv_demux_parse_tag_video()
1705 gst_element_no_more_pads (GST_ELEMENT (demux)); in gst_flv_demux_parse_tag_video()
1706 demux->no_more_pads = TRUE; in gst_flv_demux_parse_tag_video()
1711 if (G_UNLIKELY (codec_tag != demux->video_codec_tag || demux->got_par)) { in gst_flv_demux_parse_tag_video()
1712 GST_DEBUG_OBJECT (demux, "video settings have changed, changing caps"); in gst_flv_demux_parse_tag_video()
1713 if (codec_tag != demux->video_codec_tag) in gst_flv_demux_parse_tag_video()
1714 gst_buffer_replace (&demux->video_codec_data, NULL); in gst_flv_demux_parse_tag_video()
1716 if (!gst_flv_demux_video_negotiate (demux, codec_tag)) { in gst_flv_demux_parse_tag_video()
1723 demux->got_par = FALSE; in gst_flv_demux_parse_tag_video()
1727 if (demux->tag_data_size <= codec_data) { in gst_flv_demux_parse_tag_video()
1728 GST_LOG_OBJECT (demux, "Nothing left in this tag, returning"); in gst_flv_demux_parse_tag_video()
1734 7 + codec_data, demux->tag_data_size - codec_data); in gst_flv_demux_parse_tag_video()
1737 if (gst_flv_demux_update_resync (demux, dts, demux->video_need_discont, in gst_flv_demux_parse_tag_video()
1738 &demux->last_video_dts, &demux->video_time_offset)) { in gst_flv_demux_parse_tag_video()
1743 GST_LOG_OBJECT (demux, "dts %u pts %u cts %d", dts, dts + cts, cts); in gst_flv_demux_parse_tag_video()
1746 (dts + cts) * GST_MSECOND + demux->video_time_offset; in gst_flv_demux_parse_tag_video()
1747 GST_BUFFER_DTS (outbuf) = dts * GST_MSECOND + demux->video_time_offset; in gst_flv_demux_parse_tag_video()
1749 GST_BUFFER_OFFSET (outbuf) = demux->video_offset++; in gst_flv_demux_parse_tag_video()
1750 GST_BUFFER_OFFSET_END (outbuf) = demux->video_offset; in gst_flv_demux_parse_tag_video()
1752 if (demux->duration == GST_CLOCK_TIME_NONE || in gst_flv_demux_parse_tag_video()
1753 demux->duration < GST_BUFFER_TIMESTAMP (outbuf)) in gst_flv_demux_parse_tag_video()
1754 demux->duration = GST_BUFFER_TIMESTAMP (outbuf); in gst_flv_demux_parse_tag_video()
1759 if (!demux->indexed) { in gst_flv_demux_parse_tag_video()
1760 gst_flv_demux_parse_and_add_index_entry (demux, in gst_flv_demux_parse_tag_video()
1761 GST_BUFFER_TIMESTAMP (outbuf), demux->cur_tag_offset, keyframe); in gst_flv_demux_parse_tag_video()
1764 if (G_UNLIKELY (demux->video_need_discont)) { in gst_flv_demux_parse_tag_video()
1766 demux->video_need_discont = FALSE; in gst_flv_demux_parse_tag_video()
1769 demux->segment.position = GST_BUFFER_TIMESTAMP (outbuf); in gst_flv_demux_parse_tag_video()
1772 if (G_UNLIKELY (demux->video_need_segment)) { in gst_flv_demux_parse_tag_video()
1773 if (!demux->new_seg_event) { in gst_flv_demux_parse_tag_video()
1774 GST_DEBUG_OBJECT (demux, "pushing newsegment from %" in gst_flv_demux_parse_tag_video()
1776 GST_TIME_ARGS (demux->segment.position), in gst_flv_demux_parse_tag_video()
1777 GST_TIME_ARGS (demux->segment.stop)); in gst_flv_demux_parse_tag_video()
1778 demux->segment.start = demux->segment.time = demux->segment.position; in gst_flv_demux_parse_tag_video()
1779 demux->new_seg_event = gst_event_new_segment (&demux->segment); in gst_flv_demux_parse_tag_video()
1780 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_parse_tag_video()
1781 gst_event_set_seqnum (demux->new_seg_event, demux->segment_seqnum); in gst_flv_demux_parse_tag_video()
1783 GST_DEBUG_OBJECT (demux, "pushing pre-generated newsegment event"); in gst_flv_demux_parse_tag_video()
1786 gst_pad_push_event (demux->video_pad, gst_event_ref (demux->new_seg_event)); in gst_flv_demux_parse_tag_video()
1788 demux->video_need_segment = FALSE; in gst_flv_demux_parse_tag_video()
1791 GST_LOG_OBJECT (demux, in gst_flv_demux_parse_tag_video()
1799 if (!GST_CLOCK_TIME_IS_VALID (demux->video_start)) { in gst_flv_demux_parse_tag_video()
1800 demux->video_start = GST_BUFFER_TIMESTAMP (outbuf); in gst_flv_demux_parse_tag_video()
1802 if (!GST_CLOCK_TIME_IS_VALID (demux->audio_first_ts)) { in gst_flv_demux_parse_tag_video()
1803 demux->video_first_ts = GST_BUFFER_TIMESTAMP (outbuf); in gst_flv_demux_parse_tag_video()
1806 if (G_UNLIKELY (!demux->no_more_pads in gst_flv_demux_parse_tag_video()
1807 && (GST_CLOCK_DIFF (demux->video_start, in gst_flv_demux_parse_tag_video()
1809 GST_DEBUG_OBJECT (demux, in gst_flv_demux_parse_tag_video()
1812 gst_element_no_more_pads (GST_ELEMENT_CAST (demux)); in gst_flv_demux_parse_tag_video()
1813 demux->no_more_pads = TRUE; in gst_flv_demux_parse_tag_video()
1817 ret = gst_pad_push (demux->video_pad, outbuf); in gst_flv_demux_parse_tag_video()
1820 demux->segment.rate < 0.0 && ret == GST_FLOW_EOS && in gst_flv_demux_parse_tag_video()
1821 demux->segment.position > demux->segment.stop) { in gst_flv_demux_parse_tag_video()
1825 GST_DEBUG_OBJECT (demux, "downstream has reached end of segment"); in gst_flv_demux_parse_tag_video()
1826 demux->video_done = TRUE; in gst_flv_demux_parse_tag_video()
1831 ret = gst_flow_combiner_update_pad_flow (demux->flowcombiner, in gst_flv_demux_parse_tag_video()
1832 demux->video_pad, ret); in gst_flv_demux_parse_tag_video()
1835 gst_flv_demux_sync_streams (demux); in gst_flv_demux_parse_tag_video()
1844 gst_flv_demux_parse_tag_timestamp (GstFlvDemux * demux, gboolean index, in gst_flv_demux_parse_tag_timestamp() argument
1866 GST_WARNING_OBJECT (demux, "Unsupported tag type %u", data[0]); in gst_flv_demux_parse_tag_timestamp()
1871 demux->has_video = TRUE; in gst_flv_demux_parse_tag_timestamp()
1873 demux->has_audio = TRUE; in gst_flv_demux_parse_tag_timestamp()
1879 GST_WARNING_OBJECT (demux, "Invalid tag size"); in gst_flv_demux_parse_tag_timestamp()
1889 GST_LOG_OBJECT (demux, "dts bytes %02X %02X %02X %02X", data[0], data[1], in gst_flv_demux_parse_tag_timestamp()
1906 GST_LOG_OBJECT (demux, "dts: %" GST_TIME_FORMAT, GST_TIME_ARGS (ret)); in gst_flv_demux_parse_tag_timestamp()
1908 if (index && !demux->indexed && (type == 9 || (type == 8 in gst_flv_demux_parse_tag_timestamp()
1909 && !demux->has_video))) { in gst_flv_demux_parse_tag_timestamp()
1910 gst_flv_demux_parse_and_add_index_entry (demux, ret, demux->offset, in gst_flv_demux_parse_tag_timestamp()
1914 if (demux->duration == GST_CLOCK_TIME_NONE || demux->duration < ret) in gst_flv_demux_parse_tag_timestamp()
1915 demux->duration = ret; in gst_flv_demux_parse_tag_timestamp()
1923 gst_flv_demux_parse_tag_type (GstFlvDemux * demux, GstBuffer * buffer) in gst_flv_demux_parse_tag_type() argument
1937 demux->tag_data_size = GST_READ_UINT24_BE (map.data + 1); in gst_flv_demux_parse_tag_type()
1938 demux->tag_size = demux->tag_data_size + 11; in gst_flv_demux_parse_tag_type()
1940 GST_LOG_OBJECT (demux, "tag data size is %" G_GUINT64_FORMAT, in gst_flv_demux_parse_tag_type()
1941 demux->tag_data_size); in gst_flv_demux_parse_tag_type()
1947 demux->state = FLV_STATE_TAG_VIDEO; in gst_flv_demux_parse_tag_type()
1948 demux->has_video = TRUE; in gst_flv_demux_parse_tag_type()
1951 demux->state = FLV_STATE_TAG_AUDIO; in gst_flv_demux_parse_tag_type()
1952 demux->has_audio = TRUE; in gst_flv_demux_parse_tag_type()
1955 demux->state = FLV_STATE_TAG_SCRIPT; in gst_flv_demux_parse_tag_type()
1958 GST_WARNING_OBJECT (demux, "unsupported tag type %u", tag_type); in gst_flv_demux_parse_tag_type()
1959 demux->state = FLV_STATE_SKIP; in gst_flv_demux_parse_tag_type()
1966 gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer) in gst_flv_demux_parse_header() argument
1977 GST_DEBUG_OBJECT (demux, "FLV header detected"); in gst_flv_demux_parse_header()
1979 if (G_UNLIKELY (demux->strict)) { in gst_flv_demux_parse_header()
1980 GST_WARNING_OBJECT (demux, "invalid header tag detected"); in gst_flv_demux_parse_header()
1987 GST_DEBUG_OBJECT (demux, "FLV version 1 detected"); in gst_flv_demux_parse_header()
1989 if (G_UNLIKELY (demux->strict)) { in gst_flv_demux_parse_header()
1990 GST_WARNING_OBJECT (demux, "invalid header version detected"); in gst_flv_demux_parse_header()
2001 demux->has_video = demux->has_audio = FALSE; in gst_flv_demux_parse_header()
2004 GST_DEBUG_OBJECT (demux, "there is a video stream"); in gst_flv_demux_parse_header()
2005 demux->has_video = TRUE; in gst_flv_demux_parse_header()
2008 GST_DEBUG_OBJECT (demux, "there is an audio stream"); in gst_flv_demux_parse_header()
2009 demux->has_audio = TRUE; in gst_flv_demux_parse_header()
2014 gst_flv_demux_check_seekability (demux); in gst_flv_demux_parse_header()
2017 demux->need_header = FALSE; in gst_flv_demux_parse_header()
2026 gst_flv_demux_flush (GstFlvDemux * demux, gboolean discont) in gst_flv_demux_flush() argument
2028 GST_DEBUG_OBJECT (demux, "flushing queued data in the FLV demuxer"); in gst_flv_demux_flush()
2030 gst_adapter_clear (demux->adapter); in gst_flv_demux_flush()
2032 demux->audio_need_discont = TRUE; in gst_flv_demux_flush()
2033 demux->video_need_discont = TRUE; in gst_flv_demux_flush()
2035 demux->flushing = FALSE; in gst_flv_demux_flush()
2038 if (!demux->random_access && demux->state != FLV_STATE_SEEK) { in gst_flv_demux_flush()
2040 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_flush()
2042 demux->offset = 0; in gst_flv_demux_flush()
2047 gst_flv_demux_cleanup (GstFlvDemux * demux) in gst_flv_demux_cleanup() argument
2049 GST_DEBUG_OBJECT (demux, "cleaning up FLV demuxer"); in gst_flv_demux_cleanup()
2051 demux->state = FLV_STATE_HEADER; in gst_flv_demux_cleanup()
2053 demux->have_group_id = FALSE; in gst_flv_demux_cleanup()
2054 demux->group_id = G_MAXUINT; in gst_flv_demux_cleanup()
2056 demux->flushing = FALSE; in gst_flv_demux_cleanup()
2057 demux->need_header = TRUE; in gst_flv_demux_cleanup()
2058 demux->audio_need_segment = TRUE; in gst_flv_demux_cleanup()
2059 demux->video_need_segment = TRUE; in gst_flv_demux_cleanup()
2060 demux->audio_need_discont = TRUE; in gst_flv_demux_cleanup()
2061 demux->video_need_discont = TRUE; in gst_flv_demux_cleanup()
2063 demux->has_audio = FALSE; in gst_flv_demux_cleanup()
2064 demux->has_video = FALSE; in gst_flv_demux_cleanup()
2065 demux->got_par = FALSE; in gst_flv_demux_cleanup()
2067 demux->indexed = FALSE; in gst_flv_demux_cleanup()
2068 demux->upstream_seekable = FALSE; in gst_flv_demux_cleanup()
2069 demux->file_size = 0; in gst_flv_demux_cleanup()
2070 demux->segment_seqnum = 0; in gst_flv_demux_cleanup()
2072 demux->index_max_pos = 0; in gst_flv_demux_cleanup()
2073 demux->index_max_time = 0; in gst_flv_demux_cleanup()
2075 demux->audio_start = demux->video_start = GST_CLOCK_TIME_NONE; in gst_flv_demux_cleanup()
2076 demux->last_audio_pts = demux->last_video_dts = 0; in gst_flv_demux_cleanup()
2077 demux->audio_time_offset = demux->video_time_offset = 0; in gst_flv_demux_cleanup()
2079 demux->no_more_pads = FALSE; in gst_flv_demux_cleanup()
2082 demux->no_audio_warned = FALSE; in gst_flv_demux_cleanup()
2083 demux->no_video_warned = FALSE; in gst_flv_demux_cleanup()
2086 gst_segment_init (&demux->segment, GST_FORMAT_TIME); in gst_flv_demux_cleanup()
2088 demux->w = demux->h = 0; in gst_flv_demux_cleanup()
2089 demux->framerate = 0.0; in gst_flv_demux_cleanup()
2090 demux->par_x = demux->par_y = 1; in gst_flv_demux_cleanup()
2091 demux->video_offset = 0; in gst_flv_demux_cleanup()
2092 demux->audio_offset = 0; in gst_flv_demux_cleanup()
2093 demux->offset = demux->cur_tag_offset = 0; in gst_flv_demux_cleanup()
2094 demux->tag_size = demux->tag_data_size = 0; in gst_flv_demux_cleanup()
2095 demux->duration = GST_CLOCK_TIME_NONE; in gst_flv_demux_cleanup()
2097 if (demux->new_seg_event) { in gst_flv_demux_cleanup()
2098 gst_event_unref (demux->new_seg_event); in gst_flv_demux_cleanup()
2099 demux->new_seg_event = NULL; in gst_flv_demux_cleanup()
2102 gst_adapter_clear (demux->adapter); in gst_flv_demux_cleanup()
2104 if (demux->audio_codec_data) { in gst_flv_demux_cleanup()
2105 gst_buffer_unref (demux->audio_codec_data); in gst_flv_demux_cleanup()
2106 demux->audio_codec_data = NULL; in gst_flv_demux_cleanup()
2109 if (demux->video_codec_data) { in gst_flv_demux_cleanup()
2110 gst_buffer_unref (demux->video_codec_data); in gst_flv_demux_cleanup()
2111 demux->video_codec_data = NULL; in gst_flv_demux_cleanup()
2114 if (demux->audio_pad) { in gst_flv_demux_cleanup()
2115 gst_flow_combiner_remove_pad (demux->flowcombiner, demux->audio_pad); in gst_flv_demux_cleanup()
2116 gst_element_remove_pad (GST_ELEMENT (demux), demux->audio_pad); in gst_flv_demux_cleanup()
2117 gst_object_unref (demux->audio_pad); in gst_flv_demux_cleanup()
2118 demux->audio_pad = NULL; in gst_flv_demux_cleanup()
2121 if (demux->video_pad) { in gst_flv_demux_cleanup()
2122 gst_flow_combiner_remove_pad (demux->flowcombiner, demux->video_pad); in gst_flv_demux_cleanup()
2123 gst_element_remove_pad (GST_ELEMENT (demux), demux->video_pad); in gst_flv_demux_cleanup()
2124 gst_object_unref (demux->video_pad); in gst_flv_demux_cleanup()
2125 demux->video_pad = NULL; in gst_flv_demux_cleanup()
2128 if (demux->times) { in gst_flv_demux_cleanup()
2129 g_array_free (demux->times, TRUE); in gst_flv_demux_cleanup()
2130 demux->times = NULL; in gst_flv_demux_cleanup()
2133 if (demux->filepositions) { in gst_flv_demux_cleanup()
2134 g_array_free (demux->filepositions, TRUE); in gst_flv_demux_cleanup()
2135 demux->filepositions = NULL; in gst_flv_demux_cleanup()
2138 demux->video_bitrate = 0; in gst_flv_demux_cleanup()
2139 demux->audio_bitrate = 0; in gst_flv_demux_cleanup()
2141 gst_flv_demux_clear_tags (demux); in gst_flv_demux_cleanup()
2148 flv_demux_seek_to_offset (GstFlvDemux * demux, guint64 offset) in flv_demux_seek_to_offset() argument
2153 GST_DEBUG_OBJECT (demux, "Seeking to %" G_GUINT64_FORMAT, offset); in flv_demux_seek_to_offset()
2159 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in flv_demux_seek_to_offset()
2160 gst_event_set_seqnum (event, demux->segment_seqnum); in flv_demux_seek_to_offset()
2162 res = gst_pad_push_event (demux->sinkpad, event); in flv_demux_seek_to_offset()
2165 demux->offset = offset; in flv_demux_seek_to_offset()
2173 GstFlvDemux *demux = NULL; in gst_flv_demux_chain() local
2175 demux = GST_FLV_DEMUX (parent); in gst_flv_demux_chain()
2177 GST_LOG_OBJECT (demux, in gst_flv_demux_chain()
2183 GST_DEBUG_OBJECT (demux, "beginning of file, expect header"); in gst_flv_demux_chain()
2184 demux->state = FLV_STATE_HEADER; in gst_flv_demux_chain()
2185 demux->offset = 0; in gst_flv_demux_chain()
2188 if (G_UNLIKELY (demux->offset == 0 && GST_BUFFER_OFFSET (buffer) != 0)) { in gst_flv_demux_chain()
2189 GST_DEBUG_OBJECT (demux, "offset was zero, synchronizing with buffer's"); in gst_flv_demux_chain()
2190 demux->offset = GST_BUFFER_OFFSET (buffer); in gst_flv_demux_chain()
2194 GST_DEBUG_OBJECT (demux, "Discontinuity"); in gst_flv_demux_chain()
2195 gst_adapter_clear (demux->adapter); in gst_flv_demux_chain()
2198 gst_adapter_push (demux->adapter, buffer); in gst_flv_demux_chain()
2200 if (demux->seeking) { in gst_flv_demux_chain()
2201 demux->state = FLV_STATE_SEEK; in gst_flv_demux_chain()
2202 GST_OBJECT_LOCK (demux); in gst_flv_demux_chain()
2203 demux->seeking = FALSE; in gst_flv_demux_chain()
2204 GST_OBJECT_UNLOCK (demux); in gst_flv_demux_chain()
2209 GST_DEBUG_OBJECT (demux, "got flow return %s", gst_flow_get_name (ret)); in gst_flv_demux_chain()
2213 if (G_UNLIKELY (demux->flushing)) { in gst_flv_demux_chain()
2214 GST_DEBUG_OBJECT (demux, "we are now flushing, exiting parser loop"); in gst_flv_demux_chain()
2219 switch (demux->state) { in gst_flv_demux_chain()
2222 if (gst_adapter_available (demux->adapter) >= FLV_HEADER_SIZE) { in gst_flv_demux_chain()
2225 buffer = gst_adapter_take_buffer (demux->adapter, FLV_HEADER_SIZE); in gst_flv_demux_chain()
2227 ret = gst_flv_demux_parse_header (demux, buffer); in gst_flv_demux_chain()
2230 demux->offset += FLV_HEADER_SIZE; in gst_flv_demux_chain()
2232 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_chain()
2240 if (gst_adapter_available (demux->adapter) >= FLV_TAG_TYPE_SIZE) { in gst_flv_demux_chain()
2244 demux->cur_tag_offset = demux->offset; in gst_flv_demux_chain()
2246 buffer = gst_adapter_take_buffer (demux->adapter, FLV_TAG_TYPE_SIZE); in gst_flv_demux_chain()
2248 ret = gst_flv_demux_parse_tag_type (demux, buffer); in gst_flv_demux_chain()
2251 demux->offset += FLV_TAG_TYPE_SIZE; in gst_flv_demux_chain()
2255 if (demux->seek_event && demux->state != FLV_STATE_TAG_SCRIPT) in gst_flv_demux_chain()
2265 if (gst_adapter_available (demux->adapter) >= demux->tag_size) { in gst_flv_demux_chain()
2268 buffer = gst_adapter_take_buffer (demux->adapter, demux->tag_size); in gst_flv_demux_chain()
2270 ret = gst_flv_demux_parse_tag_video (demux, buffer); in gst_flv_demux_chain()
2273 demux->offset += demux->tag_size; in gst_flv_demux_chain()
2275 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_chain()
2283 if (gst_adapter_available (demux->adapter) >= demux->tag_size) { in gst_flv_demux_chain()
2286 buffer = gst_adapter_take_buffer (demux->adapter, demux->tag_size); in gst_flv_demux_chain()
2288 ret = gst_flv_demux_parse_tag_audio (demux, buffer); in gst_flv_demux_chain()
2291 demux->offset += demux->tag_size; in gst_flv_demux_chain()
2293 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_chain()
2301 if (gst_adapter_available (demux->adapter) >= demux->tag_size) { in gst_flv_demux_chain()
2304 buffer = gst_adapter_take_buffer (demux->adapter, demux->tag_size); in gst_flv_demux_chain()
2306 ret = gst_flv_demux_parse_tag_script (demux, buffer); in gst_flv_demux_chain()
2309 demux->offset += demux->tag_size; in gst_flv_demux_chain()
2311 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_chain()
2315 if (demux->seek_event) { in gst_flv_demux_chain()
2316 if (demux->indexed) in gst_flv_demux_chain()
2317 demux->state = FLV_STATE_SEEK; in gst_flv_demux_chain()
2333 if (!demux->indexed) { in gst_flv_demux_chain()
2334 if (demux->offset == demux->file_size - sizeof (guint32)) { in gst_flv_demux_chain()
2338 data = gst_adapter_take (demux->adapter, 4); in gst_flv_demux_chain()
2342 seek_offset = demux->file_size - sizeof (guint32) - in gst_flv_demux_chain()
2346 GST_INFO_OBJECT (demux, in gst_flv_demux_chain()
2349 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_chain()
2350 flv_demux_seek_to_offset (demux, seek_offset); in gst_flv_demux_chain()
2356 GST_OBJECT_LOCK (demux); in gst_flv_demux_chain()
2357 event = demux->seek_event; in gst_flv_demux_chain()
2358 demux->seek_event = NULL; in gst_flv_demux_chain()
2359 GST_OBJECT_UNLOCK (demux); in gst_flv_demux_chain()
2362 if (!flv_demux_handle_seek_push (demux, event)) in gst_flv_demux_chain()
2366 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_chain()
2371 if (gst_adapter_available (demux->adapter) >= demux->tag_size) { in gst_flv_demux_chain()
2372 gst_adapter_flush (demux->adapter, demux->tag_size); in gst_flv_demux_chain()
2373 demux->offset += demux->tag_size; in gst_flv_demux_chain()
2374 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_chain()
2380 GST_DEBUG_OBJECT (demux, "unexpected demuxer state"); in gst_flv_demux_chain()
2389 GST_OBJECT_LOCK (demux); in gst_flv_demux_chain()
2390 demux->seeking = FALSE; in gst_flv_demux_chain()
2391 gst_event_unref (demux->seek_event); in gst_flv_demux_chain()
2392 demux->seek_event = NULL; in gst_flv_demux_chain()
2393 GST_OBJECT_UNLOCK (demux); in gst_flv_demux_chain()
2394 GST_WARNING_OBJECT (demux, in gst_flv_demux_chain()
2396 flv_demux_seek_to_offset (demux, 0); in gst_flv_demux_chain()
2401 GST_ELEMENT_ERROR (demux, STREAM, DEMUX, (NULL), ("seek failed")); in gst_flv_demux_chain()
2408 gst_flv_demux_pull_range (GstFlvDemux * demux, GstPad * pad, guint64 offset, in gst_flv_demux_pull_range() argument
2415 GST_WARNING_OBJECT (demux, in gst_flv_demux_pull_range()
2423 GST_WARNING_OBJECT (demux, in gst_flv_demux_pull_range()
2436 gst_flv_demux_pull_tag (GstPad * pad, GstFlvDemux * demux) in gst_flv_demux_pull_tag() argument
2442 demux->cur_tag_offset = demux->offset; in gst_flv_demux_pull_tag()
2445 if (G_UNLIKELY ((ret = gst_flv_demux_pull_range (demux, pad, demux->offset, in gst_flv_demux_pull_tag()
2450 ret = gst_flv_demux_parse_tag_type (demux, buffer); in gst_flv_demux_pull_tag()
2458 demux->offset += FLV_TAG_TYPE_SIZE; in gst_flv_demux_pull_tag()
2462 if (G_UNLIKELY ((ret = gst_flv_demux_pull_range (demux, pad, demux->offset, in gst_flv_demux_pull_tag()
2463 demux->tag_size, &buffer)) != GST_FLOW_OK)) in gst_flv_demux_pull_tag()
2466 switch (demux->state) { in gst_flv_demux_pull_tag()
2468 ret = gst_flv_demux_parse_tag_video (demux, buffer); in gst_flv_demux_pull_tag()
2471 ret = gst_flv_demux_parse_tag_audio (demux, buffer); in gst_flv_demux_pull_tag()
2474 ret = gst_flv_demux_parse_tag_script (demux, buffer); in gst_flv_demux_pull_tag()
2477 GST_WARNING_OBJECT (demux, "unexpected state %d", demux->state); in gst_flv_demux_pull_tag()
2483 demux->offset += demux->tag_size; in gst_flv_demux_pull_tag()
2486 demux->tag_size = 0; in gst_flv_demux_pull_tag()
2489 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_pull_tag()
2492 GST_WARNING_OBJECT (demux, "parsing this tag returned not-linked and " in gst_flv_demux_pull_tag()
2501 gst_flv_demux_pull_header (GstPad * pad, GstFlvDemux * demux) in gst_flv_demux_pull_header() argument
2507 if (G_UNLIKELY ((ret = gst_flv_demux_pull_range (demux, pad, demux->offset, in gst_flv_demux_pull_header()
2511 ret = gst_flv_demux_parse_header (demux, buffer); in gst_flv_demux_pull_header()
2516 demux->offset += FLV_HEADER_SIZE; in gst_flv_demux_pull_header()
2517 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_pull_header()
2524 gst_flv_demux_move_to_offset (GstFlvDemux * demux, gint64 offset, in gst_flv_demux_move_to_offset() argument
2527 demux->offset = offset; in gst_flv_demux_move_to_offset()
2530 demux->audio_need_discont = TRUE; in gst_flv_demux_move_to_offset()
2531 demux->video_need_discont = TRUE; in gst_flv_demux_move_to_offset()
2534 demux->from_offset = -1; in gst_flv_demux_move_to_offset()
2535 demux->audio_done = demux->video_done = FALSE; in gst_flv_demux_move_to_offset()
2536 demux->audio_first_ts = demux->video_first_ts = GST_CLOCK_TIME_NONE; in gst_flv_demux_move_to_offset()
2539 demux->from_offset = -1; in gst_flv_demux_move_to_offset()
2540 demux->to_offset = G_MAXINT64; in gst_flv_demux_move_to_offset()
2544 if (G_UNLIKELY (!demux->offset)) { in gst_flv_demux_move_to_offset()
2545 demux->state = FLV_STATE_HEADER; in gst_flv_demux_move_to_offset()
2547 demux->state = FLV_STATE_TAG_TYPE; in gst_flv_demux_move_to_offset()
2552 gst_flv_demux_seek_to_prev_keyframe (GstFlvDemux * demux) in gst_flv_demux_seek_to_prev_keyframe() argument
2558 GST_DEBUG_OBJECT (demux, in gst_flv_demux_seek_to_prev_keyframe()
2560 demux->from_offset); in gst_flv_demux_seek_to_prev_keyframe()
2563 if ((!GST_CLOCK_TIME_IS_VALID (demux->audio_first_ts) || in gst_flv_demux_seek_to_prev_keyframe()
2564 demux->audio_first_ts < demux->segment.start) && in gst_flv_demux_seek_to_prev_keyframe()
2565 (!GST_CLOCK_TIME_IS_VALID (demux->video_first_ts) || in gst_flv_demux_seek_to_prev_keyframe()
2566 demux->video_first_ts < demux->segment.start)) in gst_flv_demux_seek_to_prev_keyframe()
2569 if (demux->from_offset <= 0) in gst_flv_demux_seek_to_prev_keyframe()
2572 GST_DEBUG_OBJECT (demux, "locating previous position"); in gst_flv_demux_seek_to_prev_keyframe()
2574 index = gst_flv_demux_get_index (GST_ELEMENT (demux)); in gst_flv_demux_seek_to_prev_keyframe()
2578 entry = gst_index_get_assoc_entry (index, demux->index_id, in gst_flv_demux_seek_to_prev_keyframe()
2580 GST_FORMAT_BYTES, demux->from_offset - 1); in gst_flv_demux_seek_to_prev_keyframe()
2588 GST_DEBUG_OBJECT (demux, "found index entry for %" G_GINT64_FORMAT in gst_flv_demux_seek_to_prev_keyframe()
2590 demux->offset - 1, GST_TIME_ARGS (time), bytes); in gst_flv_demux_seek_to_prev_keyframe()
2593 demux->to_offset = demux->from_offset; in gst_flv_demux_seek_to_prev_keyframe()
2594 gst_flv_demux_move_to_offset (demux, bytes, FALSE); in gst_flv_demux_seek_to_prev_keyframe()
2606 gst_flv_demux_create_index (GstFlvDemux * demux, gint64 pos, GstClockTime ts) in gst_flv_demux_create_index() argument
2615 if (!gst_pad_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &size)) in gst_flv_demux_create_index()
2618 GST_DEBUG_OBJECT (demux, "building index at %" G_GINT64_FORMAT in gst_flv_demux_create_index()
2621 old_offset = demux->offset; in gst_flv_demux_create_index()
2622 demux->offset = pos; in gst_flv_demux_create_index()
2625 while ((ret = gst_flv_demux_pull_range (demux, demux->sinkpad, demux->offset, in gst_flv_demux_create_index()
2628 gst_flv_demux_parse_tag_timestamp (demux, TRUE, buffer, &tag_size); in gst_flv_demux_create_index()
2636 demux->offset += tag_size; in gst_flv_demux_create_index()
2641 demux->indexed = TRUE; in gst_flv_demux_create_index()
2646 demux->offset = old_offset; in gst_flv_demux_create_index()
2652 gst_flv_demux_get_metadata (GstFlvDemux * demux) in gst_flv_demux_get_metadata() argument
2659 if (!gst_pad_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &offset)) in gst_flv_demux_get_metadata()
2663 GST_DEBUG_OBJECT (demux, "upstream size: %" G_GINT64_FORMAT, offset); in gst_flv_demux_get_metadata()
2668 if (GST_FLOW_OK != gst_flv_demux_pull_range (demux, demux->sinkpad, offset, in gst_flv_demux_get_metadata()
2675 GST_DEBUG_OBJECT (demux, "last tag size: %" G_GSIZE_FORMAT, tag_size); in gst_flv_demux_get_metadata()
2683 if (GST_FLOW_OK != gst_flv_demux_pull_range (demux, demux->sinkpad, offset, in gst_flv_demux_get_metadata()
2692 GST_DEBUG_OBJECT (demux, in gst_flv_demux_get_metadata()
2699 gst_flv_demux_parse_tag_timestamp (demux, FALSE, buffer, &size); in gst_flv_demux_get_metadata()
2706 GST_DEBUG_OBJECT (demux, "script tag, pulling it to parse"); in gst_flv_demux_get_metadata()
2708 if (GST_FLOW_OK == gst_flv_demux_pull_range (demux, demux->sinkpad, offset, in gst_flv_demux_get_metadata()
2710 gst_flv_demux_parse_tag_script (demux, buffer); in gst_flv_demux_get_metadata()
2725 GstFlvDemux *demux = NULL; in gst_flv_demux_loop() local
2728 demux = GST_FLV_DEMUX (gst_pad_get_parent (pad)); in gst_flv_demux_loop()
2731 switch (demux->state) { in gst_flv_demux_loop()
2733 if (demux->from_offset == -1) in gst_flv_demux_loop()
2734 demux->from_offset = demux->offset; in gst_flv_demux_loop()
2735 ret = gst_flv_demux_pull_tag (pad, demux); in gst_flv_demux_loop()
2739 if (G_UNLIKELY (!demux->file_size && !demux->indexed && in gst_flv_demux_loop()
2740 (demux->has_video || demux->has_audio))) in gst_flv_demux_loop()
2741 demux->file_size = gst_flv_demux_get_metadata (demux); in gst_flv_demux_loop()
2751 ret = gst_flv_demux_create_index (demux, demux->index_max_pos, in gst_flv_demux_loop()
2752 demux->seek_time); in gst_flv_demux_loop()
2757 gst_flv_demux_handle_seek_pull (demux, demux->seek_event, FALSE); in gst_flv_demux_loop()
2758 demux->seek_event = NULL; in gst_flv_demux_loop()
2761 ret = gst_flv_demux_pull_header (pad, demux); in gst_flv_demux_loop()
2763 demux->index_max_pos = demux->offset; in gst_flv_demux_loop()
2767 if (demux->segment.rate < 0.0) { in gst_flv_demux_loop()
2769 if ((gint64) demux->offset >= demux->to_offset || in gst_flv_demux_loop()
2770 demux->segment.position >= demux->segment.stop + 2 * GST_SECOND || in gst_flv_demux_loop()
2771 (demux->audio_done && demux->video_done)) in gst_flv_demux_loop()
2772 ret = gst_flv_demux_seek_to_prev_keyframe (demux); in gst_flv_demux_loop()
2775 if ((demux->segment.stop != -1) && in gst_flv_demux_loop()
2776 (demux->segment.position >= demux->segment.stop)) { in gst_flv_demux_loop()
2783 && !demux->no_more_pads)) in gst_flv_demux_loop()
2786 gst_object_unref (demux); in gst_flv_demux_loop()
2796 GST_LOG_OBJECT (demux, "pausing task, reason %s", reason); in gst_flv_demux_loop()
2803 if (demux->segment.rate > 0.0 && in gst_flv_demux_loop()
2804 GST_CLOCK_TIME_IS_VALID (demux->segment.stop)) in gst_flv_demux_loop()
2805 demux->segment.position = demux->segment.stop; in gst_flv_demux_loop()
2806 else if (demux->segment.rate < 0.0) in gst_flv_demux_loop()
2807 demux->segment.position = demux->segment.start; in gst_flv_demux_loop()
2810 if (!demux->no_more_pads) { in gst_flv_demux_loop()
2811 gst_element_no_more_pads (GST_ELEMENT_CAST (demux)); in gst_flv_demux_loop()
2812 demux->no_more_pads = TRUE; in gst_flv_demux_loop()
2815 if (demux->segment.flags & GST_SEGMENT_FLAG_SEGMENT) { in gst_flv_demux_loop()
2820 if ((stop = demux->segment.stop) == -1) in gst_flv_demux_loop()
2821 stop = demux->segment.duration; in gst_flv_demux_loop()
2823 if (demux->segment.rate >= 0) { in gst_flv_demux_loop()
2824 GST_LOG_OBJECT (demux, "Sending segment done, at end of segment"); in gst_flv_demux_loop()
2825 message = gst_message_new_segment_done (GST_OBJECT_CAST (demux), in gst_flv_demux_loop()
2827 gst_message_set_seqnum (message, demux->segment_seqnum); in gst_flv_demux_loop()
2828 gst_element_post_message (GST_ELEMENT_CAST (demux), message); in gst_flv_demux_loop()
2830 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_flv_demux_loop()
2831 gst_flv_demux_push_src_event (demux, event); in gst_flv_demux_loop()
2833 GST_LOG_OBJECT (demux, "Sending segment done, at beginning of " in gst_flv_demux_loop()
2835 message = gst_message_new_segment_done (GST_OBJECT_CAST (demux), in gst_flv_demux_loop()
2836 GST_FORMAT_TIME, demux->segment.start); in gst_flv_demux_loop()
2837 gst_message_set_seqnum (message, demux->segment_seqnum); in gst_flv_demux_loop()
2838 gst_element_post_message (GST_ELEMENT_CAST (demux), message); in gst_flv_demux_loop()
2840 demux->segment.start); in gst_flv_demux_loop()
2841 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_flv_demux_loop()
2842 gst_flv_demux_push_src_event (demux, event); in gst_flv_demux_loop()
2846 if (!demux->no_more_pads) { in gst_flv_demux_loop()
2847 gst_element_no_more_pads (GST_ELEMENT (demux)); in gst_flv_demux_loop()
2848 demux->no_more_pads = TRUE; in gst_flv_demux_loop()
2851 GST_LOG_OBJECT (demux, "Sending EOS, at end of stream"); in gst_flv_demux_loop()
2852 if (!demux->audio_pad && !demux->video_pad) { in gst_flv_demux_loop()
2853 GST_ELEMENT_ERROR (demux, STREAM, FAILED, in gst_flv_demux_loop()
2857 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_loop()
2858 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_flv_demux_loop()
2859 if (!gst_flv_demux_push_src_event (demux, event)) in gst_flv_demux_loop()
2860 GST_WARNING_OBJECT (demux, "failed pushing EOS on streams"); in gst_flv_demux_loop()
2864 GST_ELEMENT_FLOW_ERROR (demux, ret); in gst_flv_demux_loop()
2866 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in gst_flv_demux_loop()
2867 gst_event_set_seqnum (event, demux->segment_seqnum); in gst_flv_demux_loop()
2868 gst_flv_demux_push_src_event (demux, event); in gst_flv_demux_loop()
2870 gst_object_unref (demux); in gst_flv_demux_loop()
2876 gst_flv_demux_find_offset (GstFlvDemux * demux, GstSegment * segment, in gst_flv_demux_find_offset() argument
2888 index = gst_flv_demux_get_index (GST_ELEMENT (demux)); in gst_flv_demux_find_offset()
2892 entry = gst_index_get_assoc_entry (index, demux->index_id, in gst_flv_demux_find_offset()
2901 GST_DEBUG_OBJECT (demux, "found index entry for %" GST_TIME_FORMAT in gst_flv_demux_find_offset()
2912 GST_DEBUG_OBJECT (demux, "no index entry found for %" GST_TIME_FORMAT, in gst_flv_demux_find_offset()
2923 flv_demux_handle_seek_push (GstFlvDemux * demux, GstEvent * event) in flv_demux_handle_seek_push() argument
2942 memcpy (&seeksegment, &demux->segment, sizeof (GstSegment)); in flv_demux_handle_seek_push()
2944 GST_DEBUG_OBJECT (demux, "segment before configure %" GST_SEGMENT_FORMAT, in flv_demux_handle_seek_push()
2945 &demux->segment); in flv_demux_handle_seek_push()
2951 GST_DEBUG_OBJECT (demux, "segment configured %" GST_SEGMENT_FORMAT, in flv_demux_handle_seek_push()
2954 if (flush || seeksegment.position != demux->segment.position) { in flv_demux_handle_seek_push()
2956 guint64 offset = gst_flv_demux_find_offset (demux, &seeksegment, flags); in flv_demux_handle_seek_push()
2958 GST_DEBUG_OBJECT (demux, "generating an upstream seek at position %" in flv_demux_handle_seek_push()
2964 ret = gst_pad_push_event (demux->sinkpad, event); in flv_demux_handle_seek_push()
2966 GST_WARNING_OBJECT (demux, "upstream seek failed"); in flv_demux_handle_seek_push()
2969 gst_flow_combiner_reset (demux->flowcombiner); in flv_demux_handle_seek_push()
2971 demux->audio_need_discont = TRUE; in flv_demux_handle_seek_push()
2972 demux->video_need_discont = TRUE; in flv_demux_handle_seek_push()
2979 memcpy (&demux->segment, &seeksegment, sizeof (GstSegment)); in flv_demux_handle_seek_push()
2982 demux->audio_need_segment = TRUE; in flv_demux_handle_seek_push()
2983 demux->video_need_segment = TRUE; in flv_demux_handle_seek_push()
2986 if (G_UNLIKELY (demux->new_seg_event)) { in flv_demux_handle_seek_push()
2987 gst_event_unref (demux->new_seg_event); in flv_demux_handle_seek_push()
2988 demux->new_seg_event = NULL; in flv_demux_handle_seek_push()
2990 GST_DEBUG_OBJECT (demux, "preparing newsegment from %" in flv_demux_handle_seek_push()
2992 GST_TIME_ARGS (demux->segment.start), in flv_demux_handle_seek_push()
2993 GST_TIME_ARGS (demux->segment.stop)); in flv_demux_handle_seek_push()
2994 demux->new_seg_event = gst_event_new_segment (&demux->segment); in flv_demux_handle_seek_push()
2995 if (demux->segment_seqnum != GST_SEQNUM_INVALID) in flv_demux_handle_seek_push()
2996 gst_event_set_seqnum (demux->new_seg_event, demux->segment_seqnum); in flv_demux_handle_seek_push()
2999 ret = gst_pad_push_event (demux->sinkpad, event); in flv_demux_handle_seek_push()
3007 GST_WARNING_OBJECT (demux, "we only support seeking in TIME format"); in flv_demux_handle_seek_push()
3014 gst_flv_demux_handle_seek_push (GstFlvDemux * demux, GstEvent * event) in gst_flv_demux_handle_seek_push() argument
3021 GST_WARNING_OBJECT (demux, "we only support seeking in TIME format"); in gst_flv_demux_handle_seek_push()
3027 if (gst_pad_push_event (demux->sinkpad, gst_event_ref (event))) { in gst_flv_demux_handle_seek_push()
3028 GST_DEBUG_OBJECT (demux, "Upstream successfully seeked"); in gst_flv_demux_handle_seek_push()
3033 if (!demux->indexed) { in gst_flv_demux_handle_seek_push()
3037 GST_OBJECT_LOCK (demux); in gst_flv_demux_handle_seek_push()
3039 demux->seeking = TRUE; in gst_flv_demux_handle_seek_push()
3040 demux->state = FLV_STATE_SEEK; in gst_flv_demux_handle_seek_push()
3043 gst_event_replace (&demux->seek_event, event); in gst_flv_demux_handle_seek_push()
3047 building_index = demux->building_index; in gst_flv_demux_handle_seek_push()
3049 demux->building_index = TRUE; in gst_flv_demux_handle_seek_push()
3050 if (!demux->file_size in gst_flv_demux_handle_seek_push()
3051 && !gst_pad_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, in gst_flv_demux_handle_seek_push()
3052 &demux->file_size)) { in gst_flv_demux_handle_seek_push()
3053 GST_WARNING_OBJECT (demux, "Failed to query upstream file size"); in gst_flv_demux_handle_seek_push()
3054 GST_OBJECT_UNLOCK (demux); in gst_flv_demux_handle_seek_push()
3061 seek_offset = demux->file_size - sizeof (guint32); in gst_flv_demux_handle_seek_push()
3062 GST_DEBUG_OBJECT (demux, in gst_flv_demux_handle_seek_push()
3065 GST_OBJECT_UNLOCK (demux); in gst_flv_demux_handle_seek_push()
3068 GST_INFO_OBJECT (demux, "Seeking to last 4 bytes at %" G_GUINT64_FORMAT, in gst_flv_demux_handle_seek_push()
3070 return flv_demux_seek_to_offset (demux, seek_offset); in gst_flv_demux_handle_seek_push()
3079 return flv_demux_handle_seek_push (demux, event); in gst_flv_demux_handle_seek_push()
3083 gst_flv_demux_handle_seek_pull (GstFlvDemux * demux, GstEvent * event, in gst_flv_demux_handle_seek_pull() argument
3105 GST_OBJECT_LOCK (demux); in gst_flv_demux_handle_seek_pull()
3107 demux->seeking = seeking; in gst_flv_demux_handle_seek_pull()
3108 GST_OBJECT_UNLOCK (demux); in gst_flv_demux_handle_seek_pull()
3117 gst_flv_demux_push_src_event (demux, flush_event); in gst_flv_demux_handle_seek_pull()
3121 gst_pad_push_event (demux->sinkpad, flush_event); in gst_flv_demux_handle_seek_pull()
3124 gst_pad_pause_task (demux->sinkpad); in gst_flv_demux_handle_seek_pull()
3128 GST_PAD_STREAM_LOCK (demux->sinkpad); in gst_flv_demux_handle_seek_pull()
3129 demux->segment_seqnum = seqnum; in gst_flv_demux_handle_seek_pull()
3135 gst_pad_push_event (demux->sinkpad, flush_event); in gst_flv_demux_handle_seek_pull()
3139 memcpy (&seeksegment, &demux->segment, sizeof (GstSegment)); in gst_flv_demux_handle_seek_pull()
3141 GST_DEBUG_OBJECT (demux, "segment before configure %" GST_SEGMENT_FORMAT, in gst_flv_demux_handle_seek_pull()
3142 &demux->segment); in gst_flv_demux_handle_seek_pull()
3148 GST_DEBUG_OBJECT (demux, "segment configured %" GST_SEGMENT_FORMAT, in gst_flv_demux_handle_seek_pull()
3151 if (flush || seeksegment.position != demux->segment.position) { in gst_flv_demux_handle_seek_pull()
3154 if (seeking && !demux->indexed && in gst_flv_demux_handle_seek_pull()
3155 seeksegment.position > demux->index_max_time + 10 * GST_SECOND) { in gst_flv_demux_handle_seek_pull()
3156 GST_DEBUG_OBJECT (demux, "delaying seek to post-scan; " in gst_flv_demux_handle_seek_pull()
3158 GST_TIME_ARGS (demux->index_max_time)); in gst_flv_demux_handle_seek_pull()
3163 gst_flv_demux_push_src_event (demux, flush_event); in gst_flv_demux_handle_seek_pull()
3167 if (demux->seek_event) in gst_flv_demux_handle_seek_pull()
3168 gst_event_unref (demux->seek_event); in gst_flv_demux_handle_seek_pull()
3169 demux->seek_event = gst_event_ref (event); in gst_flv_demux_handle_seek_pull()
3170 demux->seek_time = seeksegment.position; in gst_flv_demux_handle_seek_pull()
3171 demux->state = FLV_STATE_SEEK; in gst_flv_demux_handle_seek_pull()
3178 gst_flv_demux_move_to_offset (demux, in gst_flv_demux_handle_seek_pull()
3179 gst_flv_demux_find_offset (demux, &seeksegment, flags), TRUE); in gst_flv_demux_handle_seek_pull()
3189 gst_flv_demux_push_src_event (demux, flush_event); in gst_flv_demux_handle_seek_pull()
3194 memcpy (&demux->segment, &seeksegment, sizeof (GstSegment)); in gst_flv_demux_handle_seek_pull()
3197 if (demux->segment.flags & GST_SEGMENT_FLAG_SEGMENT) { in gst_flv_demux_handle_seek_pull()
3198 message = gst_message_new_segment_start (GST_OBJECT (demux), in gst_flv_demux_handle_seek_pull()
3199 demux->segment.format, demux->segment.position); in gst_flv_demux_handle_seek_pull()
3201 gst_element_post_message (GST_ELEMENT (demux), message); in gst_flv_demux_handle_seek_pull()
3204 gst_flow_combiner_reset (demux->flowcombiner); in gst_flv_demux_handle_seek_pull()
3206 demux->audio_need_segment = TRUE; in gst_flv_demux_handle_seek_pull()
3207 demux->video_need_segment = TRUE; in gst_flv_demux_handle_seek_pull()
3210 if (G_UNLIKELY (demux->new_seg_event)) { in gst_flv_demux_handle_seek_pull()
3211 gst_event_unref (demux->new_seg_event); in gst_flv_demux_handle_seek_pull()
3212 demux->new_seg_event = NULL; in gst_flv_demux_handle_seek_pull()
3214 GST_DEBUG_OBJECT (demux, "preparing newsegment from %" in gst_flv_demux_handle_seek_pull()
3216 GST_TIME_ARGS (demux->segment.start), in gst_flv_demux_handle_seek_pull()
3217 GST_TIME_ARGS (demux->segment.stop)); in gst_flv_demux_handle_seek_pull()
3218 demux->new_seg_event = gst_event_new_segment (&demux->segment); in gst_flv_demux_handle_seek_pull()
3219 gst_event_set_seqnum (demux->new_seg_event, seqnum); in gst_flv_demux_handle_seek_pull()
3223 GST_OBJECT_LOCK (demux); in gst_flv_demux_handle_seek_pull()
3224 seeking = demux->seeking && !seeking; in gst_flv_demux_handle_seek_pull()
3225 demux->seeking = FALSE; in gst_flv_demux_handle_seek_pull()
3226 GST_OBJECT_UNLOCK (demux); in gst_flv_demux_handle_seek_pull()
3232 gst_pad_pause_task (demux->sinkpad); in gst_flv_demux_handle_seek_pull()
3234 gst_pad_start_task (demux->sinkpad, in gst_flv_demux_handle_seek_pull()
3235 (GstTaskFunction) gst_flv_demux_loop, demux->sinkpad, NULL); in gst_flv_demux_handle_seek_pull()
3238 GST_PAD_STREAM_UNLOCK (demux->sinkpad); in gst_flv_demux_handle_seek_pull()
3246 GST_WARNING_OBJECT (demux, "we only support seeking in TIME format"); in gst_flv_demux_handle_seek_pull()
3288 GstFlvDemux *demux; in gst_flv_demux_sink_activate_mode() local
3290 demux = GST_FLV_DEMUX (parent); in gst_flv_demux_sink_activate_mode()
3294 demux->random_access = FALSE; in gst_flv_demux_sink_activate_mode()
3299 demux->random_access = TRUE; in gst_flv_demux_sink_activate_mode()
3300 demux->segment_seqnum = gst_util_seqnum_next (); in gst_flv_demux_sink_activate_mode()
3304 demux->random_access = FALSE; in gst_flv_demux_sink_activate_mode()
3318 GstFlvDemux *demux; in gst_flv_demux_sink_event() local
3321 demux = GST_FLV_DEMUX (parent); in gst_flv_demux_sink_event()
3323 GST_DEBUG_OBJECT (demux, "handling event %s", GST_EVENT_TYPE_NAME (event)); in gst_flv_demux_sink_event()
3327 GST_DEBUG_OBJECT (demux, "trying to force chain function to exit"); in gst_flv_demux_sink_event()
3328 demux->flushing = TRUE; in gst_flv_demux_sink_event()
3329 ret = gst_flv_demux_push_src_event (demux, event); in gst_flv_demux_sink_event()
3332 GST_DEBUG_OBJECT (demux, "flushing FLV demuxer"); in gst_flv_demux_sink_event()
3333 gst_flv_demux_flush (demux, TRUE); in gst_flv_demux_sink_event()
3334 ret = gst_flv_demux_push_src_event (demux, event); in gst_flv_demux_sink_event()
3340 GST_DEBUG_OBJECT (demux, "received EOS"); in gst_flv_demux_sink_event()
3342 index = gst_flv_demux_get_index (GST_ELEMENT (demux)); in gst_flv_demux_sink_event()
3345 GST_DEBUG_OBJECT (demux, "committing index"); in gst_flv_demux_sink_event()
3346 gst_index_commit (index, demux->index_id); in gst_flv_demux_sink_event()
3350 if (!demux->audio_pad && !demux->video_pad) { in gst_flv_demux_sink_event()
3351 GST_ELEMENT_ERROR (demux, STREAM, FAILED, in gst_flv_demux_sink_event()
3355 if (!demux->no_more_pads) { in gst_flv_demux_sink_event()
3356 gst_element_no_more_pads (GST_ELEMENT (demux)); in gst_flv_demux_sink_event()
3357 demux->no_more_pads = TRUE; in gst_flv_demux_sink_event()
3360 if (!gst_flv_demux_push_src_event (demux, event)) in gst_flv_demux_sink_event()
3361 GST_WARNING_OBJECT (demux, "failed pushing EOS on streams"); in gst_flv_demux_sink_event()
3370 GST_DEBUG_OBJECT (demux, "received new segment"); in gst_flv_demux_sink_event()
3373 demux->segment_seqnum = gst_event_get_seqnum (event); in gst_flv_demux_sink_event()
3377 memcpy (&demux->segment, &in_segment, sizeof (in_segment)); in gst_flv_demux_sink_event()
3379 GST_DEBUG_OBJECT (demux, "NEWSEGMENT: %" GST_SEGMENT_FORMAT, in gst_flv_demux_sink_event()
3380 &demux->segment); in gst_flv_demux_sink_event()
3383 ret = gst_flv_demux_push_src_event (demux, event); in gst_flv_demux_sink_event()
3386 demux->audio_need_segment = TRUE; in gst_flv_demux_sink_event()
3387 demux->video_need_segment = TRUE; in gst_flv_demux_sink_event()
3390 if (demux->new_seg_event) { in gst_flv_demux_sink_event()
3391 gst_event_unref (demux->new_seg_event); in gst_flv_demux_sink_event()
3392 demux->new_seg_event = NULL; in gst_flv_demux_sink_event()
3395 gst_flow_combiner_reset (demux->flowcombiner); in gst_flv_demux_sink_event()
3409 GstFlvDemux *demux; in gst_flv_demux_sink_query() local
3412 demux = GST_FLV_DEMUX (parent); in gst_flv_demux_sink_query()
3419 if (demux->audio_pad) { in gst_flv_demux_sink_query()
3420 if (!demux->audio_bitrate) { in gst_flv_demux_sink_query()
3421 GST_DEBUG_OBJECT (demux, in gst_flv_demux_sink_query()
3425 total_bitrate = demux->audio_bitrate; in gst_flv_demux_sink_query()
3427 if (demux->video_pad) { in gst_flv_demux_sink_query()
3428 if (!demux->video_bitrate) { in gst_flv_demux_sink_query()
3429 GST_DEBUG_OBJECT (demux, in gst_flv_demux_sink_query()
3433 total_bitrate += demux->video_bitrate; in gst_flv_demux_sink_query()
3436 GST_DEBUG_OBJECT (demux, in gst_flv_demux_sink_query()
3457 GstFlvDemux *demux; in gst_flv_demux_src_event() local
3460 demux = GST_FLV_DEMUX (parent); in gst_flv_demux_src_event()
3462 GST_DEBUG_OBJECT (demux, "handling event %s", GST_EVENT_TYPE_NAME (event)); in gst_flv_demux_src_event()
3468 ret = gst_pad_push_event (demux->sinkpad, event); in gst_flv_demux_src_event()
3473 if (demux->random_access) { in gst_flv_demux_src_event()
3474 ret = gst_flv_demux_handle_seek_pull (demux, event, TRUE); in gst_flv_demux_src_event()
3476 ret = gst_flv_demux_handle_seek_push (demux, event); in gst_flv_demux_src_event()
3480 ret = gst_pad_push_event (demux->sinkpad, event); in gst_flv_demux_src_event()
3491 GstFlvDemux *demux; in gst_flv_demux_query() local
3493 demux = GST_FLV_DEMUX (parent); in gst_flv_demux_query()
3504 GST_DEBUG_OBJECT (demux, "duration query only supported for time " in gst_flv_demux_query()
3511 res = gst_pad_peer_query (demux->sinkpad, query); in gst_flv_demux_query()
3516 GST_TIME_ARGS (demux->duration)); in gst_flv_demux_query()
3518 gst_query_set_duration (query, GST_FORMAT_TIME, demux->duration); in gst_flv_demux_query()
3530 GST_DEBUG_OBJECT (demux, "position query only supported for time " in gst_flv_demux_query()
3537 GST_TIME_ARGS (demux->segment.position)); in gst_flv_demux_query()
3539 gst_query_set_position (query, GST_FORMAT_TIME, demux->segment.position); in gst_flv_demux_query()
3550 if (fmt == GST_FORMAT_TIME && gst_pad_peer_query (demux->sinkpad, query)) { in gst_flv_demux_query()
3561 if (fmt != GST_FORMAT_TIME || !demux->index) { in gst_flv_demux_query()
3563 } else if (demux->random_access) { in gst_flv_demux_query()
3565 demux->duration); in gst_flv_demux_query()
3568 gboolean seekable = gst_pad_peer_query (demux->sinkpad, peerquery); in gst_flv_demux_query()
3576 demux->duration); in gst_flv_demux_query()
3587 format = demux->segment.format; in gst_flv_demux_query()
3590 gst_segment_to_stream_time (&demux->segment, format, in gst_flv_demux_query()
3591 demux->segment.start); in gst_flv_demux_query()
3592 if ((stop = demux->segment.stop) == -1) in gst_flv_demux_query()
3593 stop = demux->segment.duration; in gst_flv_demux_query()
3595 stop = gst_segment_to_stream_time (&demux->segment, format, stop); in gst_flv_demux_query()
3597 gst_query_set_segment (query, demux->segment.rate, format, start, stop); in gst_flv_demux_query()
3615 GstFlvDemux *demux; in gst_flv_demux_change_state() local
3618 demux = GST_FLV_DEMUX (element); in gst_flv_demux_change_state()
3624 if (demux->own_index) { in gst_flv_demux_change_state()
3625 gst_object_unref (demux->index); in gst_flv_demux_change_state()
3626 demux->index = NULL; in gst_flv_demux_change_state()
3627 demux->own_index = FALSE; in gst_flv_demux_change_state()
3631 if (G_UNLIKELY (!demux->index)) { in gst_flv_demux_change_state()
3632 GST_DEBUG_OBJECT (demux, "no index provided creating our own"); in gst_flv_demux_change_state()
3634 demux->index = g_object_new (gst_mem_index_get_type (), NULL); in gst_flv_demux_change_state()
3636 gst_index_get_writer_id (demux->index, GST_OBJECT (demux), in gst_flv_demux_change_state()
3637 &demux->index_id); in gst_flv_demux_change_state()
3638 demux->own_index = TRUE; in gst_flv_demux_change_state()
3640 gst_flv_demux_cleanup (demux); in gst_flv_demux_change_state()
3652 gst_flv_demux_cleanup (demux); in gst_flv_demux_change_state()
3665 GstFlvDemux *demux = GST_FLV_DEMUX (element);
3668 GST_OBJECT_LOCK (demux);
3670 old_index = demux->index;
3673 demux->index = gst_object_ref (index);
3674 demux->own_index = FALSE;
3676 demux->index = NULL;
3679 gst_object_unref (demux->index);
3683 GST_OBJECT_UNLOCK (demux);
3687 gst_index_get_writer_id (index, GST_OBJECT (element), &demux->index_id);
3689 GST_DEBUG_OBJECT (demux, "Set index %" GST_PTR_FORMAT, demux->index);
3700 GstFlvDemux *demux = GST_FLV_DEMUX (element); in gst_flv_demux_get_index() local
3702 GST_OBJECT_LOCK (demux); in gst_flv_demux_get_index()
3703 if (demux->index) in gst_flv_demux_get_index()
3704 result = gst_object_ref (demux->index); in gst_flv_demux_get_index()
3705 GST_OBJECT_UNLOCK (demux); in gst_flv_demux_get_index()
3713 GstFlvDemux *demux = GST_FLV_DEMUX (object); in gst_flv_demux_dispose() local
3715 GST_DEBUG_OBJECT (demux, "disposing FLV demuxer"); in gst_flv_demux_dispose()
3717 if (demux->adapter) { in gst_flv_demux_dispose()
3718 gst_adapter_clear (demux->adapter); in gst_flv_demux_dispose()
3719 g_object_unref (demux->adapter); in gst_flv_demux_dispose()
3720 demux->adapter = NULL; in gst_flv_demux_dispose()
3723 if (demux->taglist) { in gst_flv_demux_dispose()
3724 gst_tag_list_unref (demux->taglist); in gst_flv_demux_dispose()
3725 demux->taglist = NULL; in gst_flv_demux_dispose()
3728 if (demux->audio_tags) { in gst_flv_demux_dispose()
3729 gst_tag_list_unref (demux->audio_tags); in gst_flv_demux_dispose()
3730 demux->audio_tags = NULL; in gst_flv_demux_dispose()
3733 if (demux->video_tags) { in gst_flv_demux_dispose()
3734 gst_tag_list_unref (demux->video_tags); in gst_flv_demux_dispose()
3735 demux->video_tags = NULL; in gst_flv_demux_dispose()
3738 if (demux->flowcombiner) { in gst_flv_demux_dispose()
3739 gst_flow_combiner_free (demux->flowcombiner); in gst_flv_demux_dispose()
3740 demux->flowcombiner = NULL; in gst_flv_demux_dispose()
3743 if (demux->new_seg_event) { in gst_flv_demux_dispose()
3744 gst_event_unref (demux->new_seg_event); in gst_flv_demux_dispose()
3745 demux->new_seg_event = NULL; in gst_flv_demux_dispose()
3748 if (demux->audio_codec_data) { in gst_flv_demux_dispose()
3749 gst_buffer_unref (demux->audio_codec_data); in gst_flv_demux_dispose()
3750 demux->audio_codec_data = NULL; in gst_flv_demux_dispose()
3753 if (demux->video_codec_data) { in gst_flv_demux_dispose()
3754 gst_buffer_unref (demux->video_codec_data); in gst_flv_demux_dispose()
3755 demux->video_codec_data = NULL; in gst_flv_demux_dispose()
3758 if (demux->audio_pad) { in gst_flv_demux_dispose()
3759 gst_object_unref (demux->audio_pad); in gst_flv_demux_dispose()
3760 demux->audio_pad = NULL; in gst_flv_demux_dispose()
3763 if (demux->video_pad) { in gst_flv_demux_dispose()
3764 gst_object_unref (demux->video_pad); in gst_flv_demux_dispose()
3765 demux->video_pad = NULL; in gst_flv_demux_dispose()
3768 if (demux->index) { in gst_flv_demux_dispose()
3769 gst_object_unref (demux->index); in gst_flv_demux_dispose()
3770 demux->index = NULL; in gst_flv_demux_dispose()
3773 if (demux->times) { in gst_flv_demux_dispose()
3774 g_array_free (demux->times, TRUE); in gst_flv_demux_dispose()
3775 demux->times = NULL; in gst_flv_demux_dispose()
3778 if (demux->filepositions) { in gst_flv_demux_dispose()
3779 g_array_free (demux->filepositions, TRUE); in gst_flv_demux_dispose()
3780 demux->filepositions = NULL; in gst_flv_demux_dispose()
3814 gst_flv_demux_init (GstFlvDemux * demux) in gst_flv_demux_init() argument
3816 demux->sinkpad = in gst_flv_demux_init()
3818 GST_PAD_SET_ACCEPT_TEMPLATE (demux->sinkpad); in gst_flv_demux_init()
3819 gst_pad_set_event_function (demux->sinkpad, in gst_flv_demux_init()
3821 gst_pad_set_chain_function (demux->sinkpad, in gst_flv_demux_init()
3823 gst_pad_set_activate_function (demux->sinkpad, in gst_flv_demux_init()
3825 gst_pad_set_activatemode_function (demux->sinkpad, in gst_flv_demux_init()
3827 gst_pad_set_query_function (demux->sinkpad, in gst_flv_demux_init()
3830 gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad); in gst_flv_demux_init()
3832 demux->adapter = gst_adapter_new (); in gst_flv_demux_init()
3833 demux->flowcombiner = gst_flow_combiner_new (); in gst_flv_demux_init()
3835 demux->own_index = FALSE; in gst_flv_demux_init()
3837 GST_OBJECT_FLAG_SET (demux, GST_ELEMENT_FLAG_INDEXABLE); in gst_flv_demux_init()
3839 gst_flv_demux_cleanup (demux); in gst_flv_demux_init()