• Home
  • Raw
  • Download

Lines Matching refs:aiff

140 gst_aiff_parse_reset (GstAiffParse * aiff)  in gst_aiff_parse_reset()  argument
142 aiff->state = AIFF_PARSE_START; in gst_aiff_parse_reset()
145 aiff->rate = 0; in gst_aiff_parse_reset()
146 aiff->width = 0; in gst_aiff_parse_reset()
147 aiff->depth = 0; in gst_aiff_parse_reset()
148 aiff->channels = 0; in gst_aiff_parse_reset()
149 aiff->bps = 0; in gst_aiff_parse_reset()
150 aiff->offset = 0; in gst_aiff_parse_reset()
151 aiff->end_offset = 0; in gst_aiff_parse_reset()
152 aiff->dataleft = 0; in gst_aiff_parse_reset()
153 aiff->datasize = 0; in gst_aiff_parse_reset()
154 aiff->datastart = 0; in gst_aiff_parse_reset()
155 aiff->duration = 0; in gst_aiff_parse_reset()
156 aiff->got_comm = FALSE; in gst_aiff_parse_reset()
158 if (aiff->seek_event) in gst_aiff_parse_reset()
159 gst_event_unref (aiff->seek_event); in gst_aiff_parse_reset()
160 aiff->seek_event = NULL; in gst_aiff_parse_reset()
161 if (aiff->adapter) { in gst_aiff_parse_reset()
162 gst_adapter_clear (aiff->adapter); in gst_aiff_parse_reset()
163 aiff->adapter = NULL; in gst_aiff_parse_reset()
166 if (aiff->tags != NULL) { in gst_aiff_parse_reset()
167 gst_tag_list_unref (aiff->tags); in gst_aiff_parse_reset()
168 aiff->tags = NULL; in gst_aiff_parse_reset()
175 GstAiffParse *aiff = GST_AIFF_PARSE (object); in gst_aiff_parse_dispose() local
177 GST_DEBUG_OBJECT (aiff, "AIFF: Dispose"); in gst_aiff_parse_dispose()
178 gst_aiff_parse_reset (aiff); in gst_aiff_parse_dispose()
213 gst_aiff_parse_parse_file_header (GstAiffParse * aiff, GstBuffer * buf) in gst_aiff_parse_parse_file_header() argument
219 GST_WARNING_OBJECT (aiff, "Could not map buffer"); in gst_aiff_parse_parse_file_header()
224 GST_WARNING_OBJECT (aiff, "Buffer too short"); in gst_aiff_parse_parse_file_header()
237 aiff->is_aifc = FALSE; in gst_aiff_parse_parse_file_header()
239 aiff->is_aifc = TRUE; in gst_aiff_parse_parse_file_header()
249 GST_ELEMENT_ERROR (aiff, STREAM, WRONG_TYPE, (NULL), in gst_aiff_parse_parse_file_header()
257 gst_aiff_parse_stream_init (GstAiffParse * aiff) in gst_aiff_parse_stream_init() argument
262 if ((res = gst_pad_pull_range (aiff->sinkpad, in gst_aiff_parse_stream_init()
263 aiff->offset, 12, &buf)) != GST_FLOW_OK) in gst_aiff_parse_stream_init()
265 else if (!gst_aiff_parse_parse_file_header (aiff, buf)) in gst_aiff_parse_stream_init()
268 aiff->offset += 12; in gst_aiff_parse_stream_init()
274 gst_aiff_parse_time_to_bytepos (GstAiffParse * aiff, gint64 ts, in gst_aiff_parse_time_to_bytepos() argument
289 if (aiff->bps > 0) { in gst_aiff_parse_time_to_bytepos()
290 *bytepos = gst_util_uint64_scale_ceil (ts, (guint64) aiff->bps, GST_SECOND); in gst_aiff_parse_time_to_bytepos()
294 GST_WARNING_OBJECT (aiff, "No valid bps to convert position"); in gst_aiff_parse_time_to_bytepos()
308 gst_aiff_parse_perform_seek (GstAiffParse * aiff, GstEvent * event, in gst_aiff_parse_perform_seek() argument
323 GST_DEBUG_OBJECT (aiff, "doing seek with event"); in gst_aiff_parse_perform_seek()
332 if (format != aiff->segment.format) { in gst_aiff_parse_perform_seek()
333 GST_INFO_OBJECT (aiff, "converting seek-event from %s to %s", in gst_aiff_parse_perform_seek()
335 gst_format_get_name (aiff->segment.format)); in gst_aiff_parse_perform_seek()
339 gst_pad_query_convert (aiff->srcpad, format, start, in gst_aiff_parse_perform_seek()
340 aiff->segment.format, &start); in gst_aiff_parse_perform_seek()
343 gst_pad_query_convert (aiff->srcpad, format, stop, in gst_aiff_parse_perform_seek()
344 aiff->segment.format, &stop); in gst_aiff_parse_perform_seek()
348 format = aiff->segment.format; in gst_aiff_parse_perform_seek()
351 GST_DEBUG_OBJECT (aiff, "doing seek without event"); in gst_aiff_parse_perform_seek()
363 if (aiff->streaming && !starting) { in gst_aiff_parse_perform_seek()
371 if (aiff->bps > 0) in gst_aiff_parse_perform_seek()
373 gst_util_uint64_scale_ceil (start, (guint64) aiff->bps, GST_SECOND); in gst_aiff_parse_perform_seek()
374 start -= (start % aiff->bytes_per_sample); in gst_aiff_parse_perform_seek()
375 start += aiff->datastart; in gst_aiff_parse_perform_seek()
379 if (aiff->bps > 0) in gst_aiff_parse_perform_seek()
381 gst_util_uint64_scale_ceil (stop, (guint64) aiff->bps, GST_SECOND); in gst_aiff_parse_perform_seek()
382 stop -= (stop % aiff->bytes_per_sample); in gst_aiff_parse_perform_seek()
383 stop += aiff->datastart; in gst_aiff_parse_perform_seek()
388 if (gst_pad_peer_query_duration (aiff->sinkpad, GST_FORMAT_BYTES, in gst_aiff_parse_perform_seek()
398 res = gst_pad_push_event (aiff->sinkpad, new_event); in gst_aiff_parse_perform_seek()
407 GST_DEBUG_OBJECT (aiff, "sending flush start"); in gst_aiff_parse_perform_seek()
408 gst_pad_push_event (aiff->srcpad, gst_event_new_flush_start ()); in gst_aiff_parse_perform_seek()
410 gst_pad_pause_task (aiff->sinkpad); in gst_aiff_parse_perform_seek()
415 GST_PAD_STREAM_LOCK (aiff->sinkpad); in gst_aiff_parse_perform_seek()
418 position = aiff->segment.position; in gst_aiff_parse_perform_seek()
420 GST_DEBUG_OBJECT (aiff, "stopped streaming at %" G_GINT64_FORMAT, position); in gst_aiff_parse_perform_seek()
424 memcpy (&seeksegment, &aiff->segment, sizeof (GstSegment)); in gst_aiff_parse_perform_seek()
429 GST_DEBUG_OBJECT (aiff, "configuring seek"); in gst_aiff_parse_perform_seek()
439 GST_DEBUG_OBJECT (aiff, "start_type =%d", start_type); in gst_aiff_parse_perform_seek()
444 if (aiff->bps > 0) in gst_aiff_parse_perform_seek()
445 aiff->offset = in gst_aiff_parse_perform_seek()
447 (guint64) aiff->bps, GST_SECOND); in gst_aiff_parse_perform_seek()
449 aiff->offset = seeksegment.position; in gst_aiff_parse_perform_seek()
450 GST_LOG_OBJECT (aiff, "offset=%" G_GUINT64_FORMAT, aiff->offset); in gst_aiff_parse_perform_seek()
451 aiff->offset -= (aiff->offset % aiff->bytes_per_sample); in gst_aiff_parse_perform_seek()
452 GST_LOG_OBJECT (aiff, "offset=%" G_GUINT64_FORMAT, aiff->offset); in gst_aiff_parse_perform_seek()
453 aiff->offset += aiff->datastart; in gst_aiff_parse_perform_seek()
454 GST_LOG_OBJECT (aiff, "offset=%" G_GUINT64_FORMAT, aiff->offset); in gst_aiff_parse_perform_seek()
456 GST_LOG_OBJECT (aiff, "continue from offset=%" G_GUINT64_FORMAT, in gst_aiff_parse_perform_seek()
457 aiff->offset); in gst_aiff_parse_perform_seek()
461 if (aiff->bps > 0) in gst_aiff_parse_perform_seek()
462 aiff->end_offset = in gst_aiff_parse_perform_seek()
463 gst_util_uint64_scale_ceil (stop, (guint64) aiff->bps, GST_SECOND); in gst_aiff_parse_perform_seek()
465 aiff->end_offset = stop; in gst_aiff_parse_perform_seek()
466 GST_LOG_OBJECT (aiff, "end_offset=%" G_GUINT64_FORMAT, aiff->end_offset); in gst_aiff_parse_perform_seek()
467 aiff->end_offset -= (aiff->end_offset % aiff->bytes_per_sample); in gst_aiff_parse_perform_seek()
468 GST_LOG_OBJECT (aiff, "end_offset=%" G_GUINT64_FORMAT, aiff->end_offset); in gst_aiff_parse_perform_seek()
469 aiff->end_offset += aiff->datastart; in gst_aiff_parse_perform_seek()
470 GST_LOG_OBJECT (aiff, "end_offset=%" G_GUINT64_FORMAT, aiff->end_offset); in gst_aiff_parse_perform_seek()
472 GST_LOG_OBJECT (aiff, "continue to end_offset=%" G_GUINT64_FORMAT, in gst_aiff_parse_perform_seek()
473 aiff->end_offset); in gst_aiff_parse_perform_seek()
478 if (gst_pad_peer_query_duration (aiff->sinkpad, GST_FORMAT_BYTES, in gst_aiff_parse_perform_seek()
480 aiff->end_offset = MIN (aiff->end_offset, upstream_size); in gst_aiff_parse_perform_seek()
483 aiff->offset = MIN (aiff->offset, aiff->end_offset); in gst_aiff_parse_perform_seek()
484 aiff->dataleft = aiff->end_offset - aiff->offset; in gst_aiff_parse_perform_seek()
486 GST_DEBUG_OBJECT (aiff, in gst_aiff_parse_perform_seek()
489 aiff->offset, aiff->end_offset, GST_TIME_ARGS (seeksegment.start), in gst_aiff_parse_perform_seek()
495 GST_DEBUG_OBJECT (aiff, "sending flush stop"); in gst_aiff_parse_perform_seek()
496 gst_pad_push_event (aiff->srcpad, gst_event_new_flush_stop (TRUE)); in gst_aiff_parse_perform_seek()
500 memcpy (&aiff->segment, &seeksegment, sizeof (GstSegment)); in gst_aiff_parse_perform_seek()
503 if (aiff->segment.flags & GST_SEEK_FLAG_SEGMENT) { in gst_aiff_parse_perform_seek()
504 gst_element_post_message (GST_ELEMENT_CAST (aiff), in gst_aiff_parse_perform_seek()
505 gst_message_new_segment_start (GST_OBJECT_CAST (aiff), in gst_aiff_parse_perform_seek()
506 aiff->segment.format, aiff->segment.position)); in gst_aiff_parse_perform_seek()
510 GST_DEBUG_OBJECT (aiff, "Creating segment from %" G_GINT64_FORMAT in gst_aiff_parse_perform_seek()
511 " to %" G_GINT64_FORMAT, aiff->segment.position, stop); in gst_aiff_parse_perform_seek()
514 if (aiff->start_segment) in gst_aiff_parse_perform_seek()
515 gst_event_unref (aiff->start_segment); in gst_aiff_parse_perform_seek()
516 aiff->start_segment = gst_event_new_segment (&aiff->segment); in gst_aiff_parse_perform_seek()
519 if (position != aiff->segment.position) { in gst_aiff_parse_perform_seek()
520 GST_DEBUG_OBJECT (aiff, in gst_aiff_parse_perform_seek()
522 aiff->discont = TRUE; in gst_aiff_parse_perform_seek()
526 aiff->segment_running = TRUE; in gst_aiff_parse_perform_seek()
527 if (!aiff->streaming) { in gst_aiff_parse_perform_seek()
528 gst_pad_start_task (aiff->sinkpad, (GstTaskFunction) gst_aiff_parse_loop, in gst_aiff_parse_perform_seek()
529 aiff->sinkpad, NULL); in gst_aiff_parse_perform_seek()
532 GST_PAD_STREAM_UNLOCK (aiff->sinkpad); in gst_aiff_parse_perform_seek()
542 GST_DEBUG_OBJECT (aiff, "negative playback rates are not supported yet."); in gst_aiff_parse_perform_seek()
547 GST_DEBUG_OBJECT (aiff, "unsupported format given, seek aborted."); in gst_aiff_parse_perform_seek()
563 gst_aiff_parse_peek_chunk_info (GstAiffParse * aiff, guint32 * tag, in gst_aiff_parse_peek_chunk_info() argument
568 if (gst_adapter_available (aiff->adapter) < 8) in gst_aiff_parse_peek_chunk_info()
571 data = gst_adapter_map (aiff->adapter, 8); in gst_aiff_parse_peek_chunk_info()
574 gst_adapter_unmap (aiff->adapter); in gst_aiff_parse_peek_chunk_info()
576 GST_DEBUG_OBJECT (aiff, in gst_aiff_parse_peek_chunk_info()
594 gst_aiff_parse_peek_chunk (GstAiffParse * aiff, guint32 * tag, guint32 * size) in gst_aiff_parse_peek_chunk() argument
599 if (!gst_aiff_parse_peek_chunk_info (aiff, tag, size)) in gst_aiff_parse_peek_chunk()
602 GST_DEBUG_OBJECT (aiff, "Need to peek chunk of %d bytes", *size); in gst_aiff_parse_peek_chunk()
605 available = gst_adapter_available (aiff->adapter); in gst_aiff_parse_peek_chunk()
609 GST_LOG_OBJECT (aiff, "but only %u bytes available now", available); in gst_aiff_parse_peek_chunk()
615 gst_aiff_parse_peek_data (GstAiffParse * aiff, guint32 size, in gst_aiff_parse_peek_data() argument
618 if (gst_adapter_available (aiff->adapter) < size) in gst_aiff_parse_peek_data()
621 *data = gst_adapter_map (aiff->adapter, size); in gst_aiff_parse_peek_data()
634 gst_aiff_parse_calculate_duration (GstAiffParse * aiff) in gst_aiff_parse_calculate_duration() argument
636 if (aiff->duration > 0) in gst_aiff_parse_calculate_duration()
639 if (aiff->datasize > 0 && aiff->bps > 0) { in gst_aiff_parse_calculate_duration()
640 aiff->duration = in gst_aiff_parse_calculate_duration()
641 gst_util_uint64_scale_ceil (aiff->datasize, GST_SECOND, in gst_aiff_parse_calculate_duration()
642 (guint64) aiff->bps); in gst_aiff_parse_calculate_duration()
643 GST_INFO_OBJECT (aiff, "Got duration %" GST_TIME_FORMAT, in gst_aiff_parse_calculate_duration()
644 GST_TIME_ARGS (aiff->duration)); in gst_aiff_parse_calculate_duration()
651 gst_aiff_parse_ignore_chunk (GstAiffParse * aiff, guint32 tag, guint32 size) in gst_aiff_parse_ignore_chunk() argument
655 if (aiff->streaming) { in gst_aiff_parse_ignore_chunk()
656 if (!gst_aiff_parse_peek_chunk (aiff, &tag, &size)) { in gst_aiff_parse_ignore_chunk()
657 GST_LOG_OBJECT (aiff, "Not enough data to skip tag %" GST_FOURCC_FORMAT, in gst_aiff_parse_ignore_chunk()
662 GST_WARNING_OBJECT (aiff, "Ignoring tag %" GST_FOURCC_FORMAT, in gst_aiff_parse_ignore_chunk()
665 aiff->offset += flush; in gst_aiff_parse_ignore_chunk()
666 if (aiff->streaming) { in gst_aiff_parse_ignore_chunk()
667 gst_adapter_flush (aiff->adapter, flush); in gst_aiff_parse_ignore_chunk()
699 gst_aiff_parse_parse_comm (GstAiffParse * aiff, GstBuffer * buf) in gst_aiff_parse_parse_comm() argument
706 GST_WARNING_OBJECT (aiff, "Can't map buffer"); in gst_aiff_parse_parse_comm()
711 if (aiff->is_aifc) in gst_aiff_parse_parse_comm()
719 aiff->channels = GST_READ_UINT16_BE (info.data); in gst_aiff_parse_parse_comm()
720 aiff->total_frames = GST_READ_UINT32_BE (info.data + 2); in gst_aiff_parse_parse_comm()
721 aiff->depth = GST_READ_UINT16_BE (info.data + 6); in gst_aiff_parse_parse_comm()
722 aiff->width = GST_ROUND_UP_8 (aiff->depth); in gst_aiff_parse_parse_comm()
723 aiff->rate = (int) gst_aiff_parse_read_IEEE80 (info.data + 8); in gst_aiff_parse_parse_comm()
725 aiff->floating_point = FALSE; in gst_aiff_parse_parse_comm()
727 if (aiff->is_aifc) { in gst_aiff_parse_parse_comm()
734 aiff->endianness = G_BIG_ENDIAN; in gst_aiff_parse_parse_comm()
737 aiff->endianness = G_LITTLE_ENDIAN; in gst_aiff_parse_parse_comm()
741 aiff->floating_point = TRUE; in gst_aiff_parse_parse_comm()
742 aiff->width = aiff->depth = 32; in gst_aiff_parse_parse_comm()
743 aiff->endianness = G_BIG_ENDIAN; in gst_aiff_parse_parse_comm()
746 aiff->floating_point = TRUE; in gst_aiff_parse_parse_comm()
747 aiff->width = aiff->depth = 64; in gst_aiff_parse_parse_comm()
748 aiff->endianness = G_BIG_ENDIAN; in gst_aiff_parse_parse_comm()
754 aiff->endianness = G_BIG_ENDIAN; in gst_aiff_parse_parse_comm()
764 GST_WARNING_OBJECT (aiff, "COMM chunk too short, cannot parse header"); in gst_aiff_parse_parse_comm()
771 GST_WARNING_OBJECT (aiff, "Unsupported compression in AIFC " in gst_aiff_parse_parse_comm()
780 gst_aiff_parse_read_chunk (GstAiffParse * aiff, guint64 * offset, guint32 * tag, in gst_aiff_parse_read_chunk() argument
789 gst_pad_pull_range (aiff->sinkpad, *offset, 8, &buf)) != GST_FLOW_OK) in gst_aiff_parse_read_chunk()
800 gst_pad_pull_range (aiff->sinkpad, (*offset) + 8, size, in gst_aiff_parse_read_chunk()
815 GST_DEBUG_OBJECT (aiff, in gst_aiff_parse_read_chunk()
827 gst_aiff_parse_create_caps (GstAiffParse * aiff) in gst_aiff_parse_create_caps() argument
833 if (aiff->floating_point) { in gst_aiff_parse_create_caps()
834 if (aiff->endianness == G_BIG_ENDIAN) { in gst_aiff_parse_create_caps()
835 if (aiff->width == 32) in gst_aiff_parse_create_caps()
837 else if (aiff->width == 64) in gst_aiff_parse_create_caps()
841 if (aiff->endianness == G_BIG_ENDIAN) { in gst_aiff_parse_create_caps()
842 if (aiff->width == 8) in gst_aiff_parse_create_caps()
844 else if (aiff->width == 16) in gst_aiff_parse_create_caps()
846 else if (aiff->width == 24) in gst_aiff_parse_create_caps()
848 else if (aiff->width == 32) in gst_aiff_parse_create_caps()
851 if (aiff->width == 8) in gst_aiff_parse_create_caps()
853 else if (aiff->width == 16) in gst_aiff_parse_create_caps()
855 else if (aiff->width == 24) in gst_aiff_parse_create_caps()
857 else if (aiff->width == 32) in gst_aiff_parse_create_caps()
864 "channels", G_TYPE_INT, aiff->channels, in gst_aiff_parse_create_caps()
866 "rate", G_TYPE_INT, aiff->rate, NULL); in gst_aiff_parse_create_caps()
870 switch (aiff->channels) { in gst_aiff_parse_create_caps()
891 GST_FIXME_OBJECT (aiff, "using fallback channel layout for %d channels", in gst_aiff_parse_create_caps()
892 aiff->channels); in gst_aiff_parse_create_caps()
893 channel_mask = gst_audio_channel_get_fallback_mask (aiff->channels); in gst_aiff_parse_create_caps()
902 GST_DEBUG_OBJECT (aiff, "Created caps: %" GST_PTR_FORMAT, caps); in gst_aiff_parse_create_caps()
908 gst_aiff_parse_stream_headers (GstAiffParse * aiff) in gst_aiff_parse_stream_headers() argument
918 gst_pad_peer_query_duration (aiff->sinkpad, GST_FORMAT_BYTES, &upstream_size); in gst_aiff_parse_stream_headers()
919 GST_DEBUG_OBJECT (aiff, "upstream size %" G_GUINT64_FORMAT, upstream_size); in gst_aiff_parse_stream_headers()
923 if (aiff->streaming) { in gst_aiff_parse_stream_headers()
924 if (!gst_aiff_parse_peek_chunk_info (aiff, &tag, &size)) in gst_aiff_parse_stream_headers()
930 gst_pad_pull_range (aiff->sinkpad, aiff->offset, 8, in gst_aiff_parse_stream_headers()
942 GST_INFO_OBJECT (aiff, in gst_aiff_parse_stream_headers()
944 GST_FOURCC_ARGS (tag), aiff->offset); in gst_aiff_parse_stream_headers()
954 if (aiff->streaming) { in gst_aiff_parse_stream_headers()
955 if (!gst_aiff_parse_peek_chunk (aiff, &tag, &size)) in gst_aiff_parse_stream_headers()
958 gst_adapter_flush (aiff->adapter, 8); in gst_aiff_parse_stream_headers()
959 aiff->offset += 8; in gst_aiff_parse_stream_headers()
961 buf = gst_adapter_take_buffer (aiff->adapter, size); in gst_aiff_parse_stream_headers()
962 aiff->offset += size; in gst_aiff_parse_stream_headers()
964 if ((res = gst_aiff_parse_read_chunk (aiff, in gst_aiff_parse_stream_headers()
965 &aiff->offset, &tag, &buf)) != GST_FLOW_OK) in gst_aiff_parse_stream_headers()
969 if (!gst_aiff_parse_parse_comm (aiff, buf)) in gst_aiff_parse_stream_headers()
973 if (aiff->channels == 0) in gst_aiff_parse_stream_headers()
975 if (aiff->rate == 0) in gst_aiff_parse_stream_headers()
979 gst_pad_create_stream_id (aiff->srcpad, GST_ELEMENT_CAST (aiff), in gst_aiff_parse_stream_headers()
983 gst_pad_push_event (aiff->srcpad, event); in gst_aiff_parse_stream_headers()
986 GST_DEBUG_OBJECT (aiff, "creating the caps"); in gst_aiff_parse_stream_headers()
988 caps = gst_aiff_parse_create_caps (aiff); in gst_aiff_parse_stream_headers()
992 gst_pad_push_event (aiff->srcpad, gst_event_new_caps (caps)); in gst_aiff_parse_stream_headers()
995 aiff->bytes_per_sample = aiff->channels * aiff->width / 8; in gst_aiff_parse_stream_headers()
996 aiff->bps = aiff->bytes_per_sample * aiff->rate; in gst_aiff_parse_stream_headers()
998 if (!aiff->tags) in gst_aiff_parse_stream_headers()
999 aiff->tags = gst_tag_list_new_empty (); in gst_aiff_parse_stream_headers()
1002 GstCaps *templ_caps = gst_pad_get_pad_template_caps (aiff->sinkpad); in gst_aiff_parse_stream_headers()
1003 gst_pb_utils_add_codec_description_to_tag_list (aiff->tags, in gst_aiff_parse_stream_headers()
1008 if (aiff->bps) { in gst_aiff_parse_stream_headers()
1009 guint bitrate = aiff->bps * 8; in gst_aiff_parse_stream_headers()
1011 GST_DEBUG_OBJECT (aiff, "adding bitrate of %u bps to tag list", in gst_aiff_parse_stream_headers()
1018 gst_tag_list_add (aiff->tags, GST_TAG_MERGE_REPLACE, in gst_aiff_parse_stream_headers()
1024 if (aiff->bytes_per_sample <= 0) in gst_aiff_parse_stream_headers()
1027 aiff->got_comm = TRUE; in gst_aiff_parse_stream_headers()
1033 GST_DEBUG_OBJECT (aiff, "Got 'SSND' TAG, size : %d", size); in gst_aiff_parse_stream_headers()
1036 if (aiff->streaming) { in gst_aiff_parse_stream_headers()
1039 if (!gst_aiff_parse_peek_data (aiff, 16, &ssnddata)) in gst_aiff_parse_stream_headers()
1042 aiff->ssnd_offset = GST_READ_UINT32_BE (ssnddata + 8); in gst_aiff_parse_stream_headers()
1043 aiff->ssnd_blocksize = GST_READ_UINT32_BE (ssnddata + 12); in gst_aiff_parse_stream_headers()
1044 gst_adapter_unmap (aiff->adapter); in gst_aiff_parse_stream_headers()
1045 gst_adapter_flush (aiff->adapter, 16); in gst_aiff_parse_stream_headers()
1051 gst_pad_pull_range (aiff->sinkpad, aiff->offset, 16, in gst_aiff_parse_stream_headers()
1056 aiff->ssnd_offset = GST_READ_UINT32_BE (info.data + 8); in gst_aiff_parse_stream_headers()
1057 aiff->ssnd_blocksize = GST_READ_UINT32_BE (info.data + 12); in gst_aiff_parse_stream_headers()
1065 aiff->offset += 16; in gst_aiff_parse_stream_headers()
1068 aiff->datastart = aiff->offset + aiff->ssnd_offset; in gst_aiff_parse_stream_headers()
1071 size = MIN (datasize, (upstream_size - aiff->datastart)); in gst_aiff_parse_stream_headers()
1073 aiff->datasize = (guint64) datasize; in gst_aiff_parse_stream_headers()
1074 aiff->dataleft = (guint64) datasize; in gst_aiff_parse_stream_headers()
1075 aiff->end_offset = datasize + aiff->datastart; in gst_aiff_parse_stream_headers()
1076 if (!aiff->streaming) { in gst_aiff_parse_stream_headers()
1079 aiff->offset += datasize; in gst_aiff_parse_stream_headers()
1081 GST_DEBUG_OBJECT (aiff, "datasize = %d", datasize); in gst_aiff_parse_stream_headers()
1082 if (aiff->streaming) { in gst_aiff_parse_stream_headers()
1090 if (aiff->streaming) { in gst_aiff_parse_stream_headers()
1091 if (!gst_aiff_parse_peek_chunk (aiff, &tag, &size)) in gst_aiff_parse_stream_headers()
1094 gst_adapter_flush (aiff->adapter, 8); in gst_aiff_parse_stream_headers()
1095 aiff->offset += 8; in gst_aiff_parse_stream_headers()
1097 buf = gst_adapter_take_buffer (aiff->adapter, size); in gst_aiff_parse_stream_headers()
1099 if ((res = gst_aiff_parse_read_chunk (aiff, in gst_aiff_parse_stream_headers()
1100 &aiff->offset, &tag, &buf)) != GST_FLOW_OK) in gst_aiff_parse_stream_headers()
1104 GST_LOG_OBJECT (aiff, "ID3 chunk of size %" G_GSIZE_FORMAT, in gst_aiff_parse_stream_headers()
1110 GST_INFO_OBJECT (aiff, "ID3 tags: %" GST_PTR_FORMAT, tags); in gst_aiff_parse_stream_headers()
1112 if (aiff->tags == NULL) { in gst_aiff_parse_stream_headers()
1113 aiff->tags = tags; in gst_aiff_parse_stream_headers()
1115 gst_tag_list_insert (aiff->tags, tags, GST_TAG_MERGE_APPEND); in gst_aiff_parse_stream_headers()
1121 GST_FIXME_OBJECT (aiff, "Handle CHAN chunk with channel layouts"); in gst_aiff_parse_stream_headers()
1122 if (!gst_aiff_parse_ignore_chunk (aiff, tag, size)) { in gst_aiff_parse_stream_headers()
1128 if (!gst_aiff_parse_ignore_chunk (aiff, tag, size)) { in gst_aiff_parse_stream_headers()
1135 if (upstream_size && (aiff->offset >= upstream_size)) { in gst_aiff_parse_stream_headers()
1145 if (!aiff->got_comm) { in gst_aiff_parse_stream_headers()
1146 GST_WARNING_OBJECT (aiff, "Failed to find COMM chunk"); in gst_aiff_parse_stream_headers()
1150 GST_WARNING_OBJECT (aiff, "Failed to find SSND chunk"); in gst_aiff_parse_stream_headers()
1154 GST_DEBUG_OBJECT (aiff, "Finished parsing headers"); in gst_aiff_parse_stream_headers()
1156 if (gst_aiff_parse_calculate_duration (aiff)) { in gst_aiff_parse_stream_headers()
1157 gst_segment_init (&aiff->segment, GST_FORMAT_TIME); in gst_aiff_parse_stream_headers()
1158 aiff->segment.duration = aiff->duration; in gst_aiff_parse_stream_headers()
1161 gst_segment_init (&aiff->segment, GST_FORMAT_BYTES); in gst_aiff_parse_stream_headers()
1162 aiff->segment.duration = aiff->datasize; in gst_aiff_parse_stream_headers()
1168 gst_aiff_parse_perform_seek (aiff, aiff->seek_event, TRUE); in gst_aiff_parse_stream_headers()
1170 event_p = &aiff->seek_event; in gst_aiff_parse_stream_headers()
1174 aiff->discont = TRUE; in gst_aiff_parse_stream_headers()
1176 aiff->state = AIFF_PARSE_DATA; in gst_aiff_parse_stream_headers()
1183 gst_aiff_parse_time_to_bytepos (aiff, 40 * GST_MSECOND, &upstream_size); in gst_aiff_parse_stream_headers()
1184 aiff->max_buf_size = upstream_size; in gst_aiff_parse_stream_headers()
1185 aiff->max_buf_size = MAX (aiff->max_buf_size, MAX_BUFFER_SIZE); in gst_aiff_parse_stream_headers()
1186 if (aiff->bytes_per_sample > 0) in gst_aiff_parse_stream_headers()
1187 aiff->max_buf_size -= (aiff->max_buf_size % aiff->bytes_per_sample); in gst_aiff_parse_stream_headers()
1189 GST_DEBUG_OBJECT (aiff, "max buffer size %u", aiff->max_buf_size); in gst_aiff_parse_stream_headers()
1196 GST_ELEMENT_ERROR (aiff, STREAM, TYPE_NOT_FOUND, (NULL), in gst_aiff_parse_stream_headers()
1202 GST_ELEMENT_ERROR (aiff, STREAM, TYPE_NOT_FOUND, (NULL), in gst_aiff_parse_stream_headers()
1208 GST_ELEMENT_ERROR (aiff, STREAM, DEMUX, (NULL), in gst_aiff_parse_stream_headers()
1214 GST_ELEMENT_ERROR (aiff, STREAM, FAILED, (NULL), in gst_aiff_parse_stream_headers()
1220 GST_ELEMENT_ERROR (aiff, STREAM, FAILED, (NULL), in gst_aiff_parse_stream_headers()
1226 GST_ELEMENT_ERROR (aiff, STREAM, FAILED, (NULL), in gst_aiff_parse_stream_headers()
1232 GST_ELEMENT_ERROR (aiff, STREAM, TYPE_NOT_FOUND, (NULL), in gst_aiff_parse_stream_headers()
1234 aiff->format, aiff->channels, aiff->rate)); in gst_aiff_parse_stream_headers()
1239 GST_ELEMENT_ERROR (aiff, STREAM, DEMUX, (NULL), in gst_aiff_parse_stream_headers()
1249 gst_aiff_parse_parse_stream_init (GstAiffParse * aiff) in gst_aiff_parse_parse_stream_init() argument
1251 if (gst_adapter_available (aiff->adapter) >= 12) { in gst_aiff_parse_parse_stream_init()
1255 tmp = gst_adapter_take_buffer (aiff->adapter, 12); in gst_aiff_parse_parse_stream_init()
1257 GST_DEBUG_OBJECT (aiff, "Parsing aiff header"); in gst_aiff_parse_parse_stream_init()
1258 if (!gst_aiff_parse_parse_file_header (aiff, tmp)) in gst_aiff_parse_parse_stream_init()
1261 aiff->offset += 12; in gst_aiff_parse_parse_stream_init()
1263 aiff->state = AIFF_PARSE_HEADER; in gst_aiff_parse_parse_stream_init()
1284 GstAiffParse *aiff = GST_AIFF_PARSE (element); in gst_aiff_parse_send_event() local
1288 GST_DEBUG_OBJECT (aiff, "received event %s", GST_EVENT_TYPE_NAME (event)); in gst_aiff_parse_send_event()
1292 if (aiff->state == AIFF_PARSE_DATA) { in gst_aiff_parse_send_event()
1294 res = gst_aiff_parse_perform_seek (aiff, event, FALSE); in gst_aiff_parse_send_event()
1296 GST_DEBUG_OBJECT (aiff, "queuing seek for later"); in gst_aiff_parse_send_event()
1298 event_p = &aiff->seek_event; in gst_aiff_parse_send_event()
1313 gst_aiff_parse_stream_data (GstAiffParse * aiff) in gst_aiff_parse_stream_data() argument
1321 if (aiff->bytes_per_sample <= 0) { in gst_aiff_parse_stream_data()
1322 GST_ELEMENT_ERROR (aiff, STREAM, WRONG_TYPE, (NULL), in gst_aiff_parse_stream_data()
1328 GST_LOG_OBJECT (aiff, in gst_aiff_parse_stream_data()
1330 G_GINT64_FORMAT, aiff->offset, aiff->end_offset, aiff->dataleft); in gst_aiff_parse_stream_data()
1333 if (aiff->dataleft == 0 || aiff->dataleft < aiff->bytes_per_sample) in gst_aiff_parse_stream_data()
1339 MIN (gst_guint64_to_gdouble (aiff->dataleft), in gst_aiff_parse_stream_data()
1340 aiff->max_buf_size * ABS (aiff->segment.rate)); in gst_aiff_parse_stream_data()
1342 if (desired >= aiff->bytes_per_sample) in gst_aiff_parse_stream_data()
1343 desired -= (desired % aiff->bytes_per_sample); in gst_aiff_parse_stream_data()
1345 GST_LOG_OBJECT (aiff, "Fetching %" G_GINT64_FORMAT " bytes of data " in gst_aiff_parse_stream_data()
1348 if (aiff->streaming) { in gst_aiff_parse_stream_data()
1349 guint avail = gst_adapter_available (aiff->adapter); in gst_aiff_parse_stream_data()
1352 GST_LOG_OBJECT (aiff, "Got only %d bytes of data from the sinkpad", in gst_aiff_parse_stream_data()
1357 buf = gst_adapter_take_buffer (aiff->adapter, desired); in gst_aiff_parse_stream_data()
1359 if ((res = gst_pad_pull_range (aiff->sinkpad, aiff->offset, in gst_aiff_parse_stream_data()
1365 if (G_UNLIKELY (aiff->close_segment != NULL)) { in gst_aiff_parse_stream_data()
1366 gst_pad_push_event (aiff->srcpad, aiff->close_segment); in gst_aiff_parse_stream_data()
1367 aiff->close_segment = NULL; in gst_aiff_parse_stream_data()
1369 if (G_UNLIKELY (aiff->start_segment != NULL)) { in gst_aiff_parse_stream_data()
1370 gst_pad_push_event (aiff->srcpad, aiff->start_segment); in gst_aiff_parse_stream_data()
1371 aiff->start_segment = NULL; in gst_aiff_parse_stream_data()
1373 if (G_UNLIKELY (aiff->tags != NULL)) { in gst_aiff_parse_stream_data()
1374 gst_pad_push_event (aiff->srcpad, gst_event_new_tag (aiff->tags)); in gst_aiff_parse_stream_data()
1375 aiff->tags = NULL; in gst_aiff_parse_stream_data()
1381 pos = aiff->offset - aiff->datastart; in gst_aiff_parse_stream_data()
1385 GST_BUFFER_OFFSET (buf) = pos / aiff->bytes_per_sample; in gst_aiff_parse_stream_data()
1386 GST_BUFFER_OFFSET_END (buf) = nextpos / aiff->bytes_per_sample; in gst_aiff_parse_stream_data()
1388 if (aiff->bps > 0) { in gst_aiff_parse_stream_data()
1391 gst_util_uint64_scale_ceil (pos, GST_SECOND, (guint64) aiff->bps); in gst_aiff_parse_stream_data()
1393 gst_util_uint64_scale_ceil (nextpos, GST_SECOND, (guint64) aiff->bps); in gst_aiff_parse_stream_data()
1397 aiff->segment.position = next_timestamp; in gst_aiff_parse_stream_data()
1407 aiff->segment.position = nextpos; in gst_aiff_parse_stream_data()
1409 if (aiff->discont) { in gst_aiff_parse_stream_data()
1410 GST_DEBUG_OBJECT (aiff, "marking DISCONT"); in gst_aiff_parse_stream_data()
1412 aiff->discont = FALSE; in gst_aiff_parse_stream_data()
1418 GST_LOG_OBJECT (aiff, in gst_aiff_parse_stream_data()
1423 if ((res = gst_pad_push (aiff->srcpad, buf)) != GST_FLOW_OK) in gst_aiff_parse_stream_data()
1426 if (obtained < aiff->dataleft) { in gst_aiff_parse_stream_data()
1427 aiff->offset += obtained; in gst_aiff_parse_stream_data()
1428 aiff->dataleft -= obtained; in gst_aiff_parse_stream_data()
1430 aiff->offset += aiff->dataleft; in gst_aiff_parse_stream_data()
1431 aiff->dataleft = 0; in gst_aiff_parse_stream_data()
1435 if (aiff->streaming) { in gst_aiff_parse_stream_data()
1436 GST_LOG_OBJECT (aiff, in gst_aiff_parse_stream_data()
1437 "offset: %" G_GINT64_FORMAT " , end: %" G_GINT64_FORMAT, aiff->offset, in gst_aiff_parse_stream_data()
1438 aiff->end_offset); in gst_aiff_parse_stream_data()
1446 GST_DEBUG_OBJECT (aiff, "found EOS"); in gst_aiff_parse_stream_data()
1455 GST_WARNING_OBJECT (aiff, in gst_aiff_parse_stream_data()
1457 "sinkpad (dataleft = %" G_GINT64_FORMAT ")", desired, aiff->dataleft); in gst_aiff_parse_stream_data()
1462 GST_INFO_OBJECT (aiff, in gst_aiff_parse_stream_data()
1464 GST_DEBUG_PAD_NAME (aiff->srcpad), gst_flow_get_name (res), in gst_aiff_parse_stream_data()
1465 gst_pad_is_linked (aiff->srcpad)); in gst_aiff_parse_stream_data()
1474 GstAiffParse *aiff = GST_AIFF_PARSE (GST_PAD_PARENT (pad)); in gst_aiff_parse_loop() local
1476 GST_LOG_OBJECT (aiff, "process data"); in gst_aiff_parse_loop()
1478 switch (aiff->state) { in gst_aiff_parse_loop()
1480 GST_INFO_OBJECT (aiff, "AIFF_PARSE_START"); in gst_aiff_parse_loop()
1481 if ((ret = gst_aiff_parse_stream_init (aiff)) != GST_FLOW_OK) in gst_aiff_parse_loop()
1484 aiff->state = AIFF_PARSE_HEADER; in gst_aiff_parse_loop()
1488 GST_INFO_OBJECT (aiff, "AIFF_PARSE_HEADER"); in gst_aiff_parse_loop()
1489 if ((ret = gst_aiff_parse_stream_headers (aiff)) != GST_FLOW_OK) in gst_aiff_parse_loop()
1492 aiff->state = AIFF_PARSE_DATA; in gst_aiff_parse_loop()
1493 GST_INFO_OBJECT (aiff, "AIFF_PARSE_DATA"); in gst_aiff_parse_loop()
1497 if ((ret = gst_aiff_parse_stream_data (aiff)) != GST_FLOW_OK) in gst_aiff_parse_loop()
1510 GST_DEBUG_OBJECT (aiff, "pausing task, reason %s", reason); in gst_aiff_parse_loop()
1511 aiff->segment_running = FALSE; in gst_aiff_parse_loop()
1516 if (aiff->segment.flags & GST_SEEK_FLAG_SEGMENT) { in gst_aiff_parse_loop()
1519 if ((stop = aiff->segment.stop) == -1) in gst_aiff_parse_loop()
1520 stop = aiff->segment.duration; in gst_aiff_parse_loop()
1522 gst_element_post_message (GST_ELEMENT_CAST (aiff), in gst_aiff_parse_loop()
1523 gst_message_new_segment_done (GST_OBJECT_CAST (aiff), in gst_aiff_parse_loop()
1524 aiff->segment.format, stop)); in gst_aiff_parse_loop()
1525 gst_pad_push_event (aiff->srcpad, in gst_aiff_parse_loop()
1526 gst_event_new_segment_done (aiff->segment.format, stop)); in gst_aiff_parse_loop()
1528 gst_pad_push_event (aiff->srcpad, gst_event_new_eos ()); in gst_aiff_parse_loop()
1533 GST_ELEMENT_FLOW_ERROR (aiff, ret); in gst_aiff_parse_loop()
1534 gst_pad_push_event (aiff->srcpad, gst_event_new_eos ()); in gst_aiff_parse_loop()
1544 GstAiffParse *aiff = GST_AIFF_PARSE (parent); in gst_aiff_parse_chain() local
1546 GST_LOG_OBJECT (aiff, "adapter_push %" G_GSIZE_FORMAT " bytes", in gst_aiff_parse_chain()
1549 gst_adapter_push (aiff->adapter, buf); in gst_aiff_parse_chain()
1551 switch (aiff->state) { in gst_aiff_parse_chain()
1553 GST_INFO_OBJECT (aiff, "AIFF_PARSE_START"); in gst_aiff_parse_chain()
1554 if ((ret = gst_aiff_parse_parse_stream_init (aiff)) != GST_FLOW_OK) in gst_aiff_parse_chain()
1557 if (aiff->state != AIFF_PARSE_HEADER) in gst_aiff_parse_chain()
1562 GST_INFO_OBJECT (aiff, "AIFF_PARSE_HEADER"); in gst_aiff_parse_chain()
1563 if ((ret = gst_aiff_parse_stream_headers (aiff)) != GST_FLOW_OK) in gst_aiff_parse_chain()
1566 if (!aiff->got_comm || aiff->datastart == 0) in gst_aiff_parse_chain()
1569 aiff->state = AIFF_PARSE_DATA; in gst_aiff_parse_chain()
1570 GST_INFO_OBJECT (aiff, "AIFF_PARSE_DATA"); in gst_aiff_parse_chain()
1574 if ((ret = gst_aiff_parse_stream_data (aiff)) != GST_FLOW_OK) in gst_aiff_parse_chain()
1674 GstAiffParse *aiff = GST_AIFF_PARSE (parent); in gst_aiff_parse_pad_query() local
1683 if (aiff->state != AIFF_PARSE_DATA) in gst_aiff_parse_pad_query()
1690 if ((res = gst_aiff_parse_calculate_duration (aiff))) { in gst_aiff_parse_pad_query()
1691 duration = aiff->duration; in gst_aiff_parse_pad_query()
1697 duration = aiff->datasize; in gst_aiff_parse_pad_query()
1709 if (aiff->state != AIFF_PARSE_DATA) in gst_aiff_parse_pad_query()
1724 if (aiff->state != AIFF_PARSE_DATA) in gst_aiff_parse_pad_query()
1731 if (!gst_aiff_parse_calculate_duration (aiff)) { in gst_aiff_parse_pad_query()
1735 0, aiff->duration); in gst_aiff_parse_pad_query()
1806 GstAiffParse *aiff = GST_AIFF_PARSE (parent); in gst_aiff_parse_sink_activate_mode() local
1808 if (aiff->adapter) { in gst_aiff_parse_sink_activate_mode()
1809 g_object_unref (aiff->adapter); in gst_aiff_parse_sink_activate_mode()
1810 aiff->adapter = NULL; in gst_aiff_parse_sink_activate_mode()
1816 aiff->streaming = TRUE; in gst_aiff_parse_sink_activate_mode()
1817 aiff->adapter = gst_adapter_new (); in gst_aiff_parse_sink_activate_mode()
1823 aiff->streaming = FALSE; in gst_aiff_parse_sink_activate_mode()
1824 aiff->adapter = NULL; in gst_aiff_parse_sink_activate_mode()
1825 aiff->segment_running = TRUE; in gst_aiff_parse_sink_activate_mode()
1830 aiff->segment_running = FALSE; in gst_aiff_parse_sink_activate_mode()
1842 gst_aiff_parse_flush_data (GstAiffParse * aiff) in gst_aiff_parse_flush_data() argument
1847 if ((av = gst_adapter_available (aiff->adapter)) > 0) { in gst_aiff_parse_flush_data()
1848 aiff->dataleft = av; in gst_aiff_parse_flush_data()
1849 aiff->end_offset = aiff->offset + av; in gst_aiff_parse_flush_data()
1850 ret = gst_aiff_parse_stream_data (aiff); in gst_aiff_parse_flush_data()
1860 GstAiffParse *aiff = GST_AIFF_PARSE (parent); in gst_aiff_parse_sink_event() local
1863 GST_DEBUG_OBJECT (aiff, "handling %s event", GST_EVENT_TYPE_NAME (event)); in gst_aiff_parse_sink_event()
1879 GST_DEBUG_OBJECT (aiff, "received segment %" GST_SEGMENT_FORMAT, in gst_aiff_parse_sink_event()
1890 start -= aiff->datastart; in gst_aiff_parse_sink_event()
1895 stop -= aiff->datastart; in gst_aiff_parse_sink_event()
1898 if (aiff->state == AIFF_PARSE_DATA && in gst_aiff_parse_sink_event()
1899 aiff->segment.format == GST_FORMAT_TIME) { in gst_aiff_parse_sink_event()
1901 if (aiff->bps) { in gst_aiff_parse_sink_event()
1905 (guint64) aiff->bps); in gst_aiff_parse_sink_event()
1909 (guint64) aiff->bps); in gst_aiff_parse_sink_event()
1911 GST_DEBUG_OBJECT (aiff, "unable to compute segment start/stop"); in gst_aiff_parse_sink_event()
1916 GST_DEBUG_OBJECT (aiff, "unsupported segment format, ignoring"); in gst_aiff_parse_sink_event()
1924 if (aiff->state == AIFF_PARSE_DATA) { in gst_aiff_parse_sink_event()
1925 segment.format = aiff->segment.format; in gst_aiff_parse_sink_event()
1927 segment.duration = aiff->segment.duration; in gst_aiff_parse_sink_event()
1930 gst_segment_copy_into (&segment, &aiff->segment); in gst_aiff_parse_sink_event()
1932 if (aiff->start_segment) in gst_aiff_parse_sink_event()
1933 gst_event_unref (aiff->start_segment); in gst_aiff_parse_sink_event()
1935 aiff->start_segment = gst_event_new_segment (&segment); in gst_aiff_parse_sink_event()
1941 if (aiff->end_offset > 0 && offset < aiff->end_offset && in gst_aiff_parse_sink_event()
1942 offset >= aiff->datastart && end_offset == -1) { in gst_aiff_parse_sink_event()
1943 end_offset = aiff->end_offset; in gst_aiff_parse_sink_event()
1947 if (aiff->state == AIFF_PARSE_DATA) in gst_aiff_parse_sink_event()
1948 gst_aiff_parse_flush_data (aiff); in gst_aiff_parse_sink_event()
1950 aiff->offset = offset; in gst_aiff_parse_sink_event()
1951 aiff->end_offset = end_offset; in gst_aiff_parse_sink_event()
1952 if (aiff->end_offset > 0) { in gst_aiff_parse_sink_event()
1953 aiff->dataleft = aiff->end_offset - aiff->offset; in gst_aiff_parse_sink_event()
1956 aiff->dataleft = G_MAXUINT64; in gst_aiff_parse_sink_event()
1963 ret = gst_pad_push_event (aiff->srcpad, event); in gst_aiff_parse_sink_event()
1966 ret = gst_pad_push_event (aiff->srcpad, event); in gst_aiff_parse_sink_event()
1967 gst_adapter_clear (aiff->adapter); in gst_aiff_parse_sink_event()
1970 ret = gst_pad_event_default (aiff->sinkpad, parent, event); in gst_aiff_parse_sink_event()
1981 GstAiffParse *aiff = GST_AIFF_PARSE (element); in gst_aiff_parse_change_state() local
1987 gst_aiff_parse_reset (aiff); in gst_aiff_parse_change_state()
2001 gst_aiff_parse_reset (aiff); in gst_aiff_parse_change_state()