From 7a2a088c53a229c8bf103c55c7fd8782972ab576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 7 Apr 2011 13:26:41 +0100 Subject: [PATCH] audioparsers: port to new GstBaseParse in core --- gst/audioparsers/Makefile.am | 2 -- gst/audioparsers/gstaacparse.c | 28 +++++++++++++++------------- gst/audioparsers/gstaacparse.h | 2 +- gst/audioparsers/gstac3parse.c | 8 ++++---- gst/audioparsers/gstac3parse.h | 2 +- gst/audioparsers/gstamrparse.c | 2 +- gst/audioparsers/gstamrparse.h | 2 +- gst/audioparsers/gstdcaparse.c | 4 ++-- gst/audioparsers/gstdcaparse.h | 2 +- gst/audioparsers/gstflacparse.c | 9 +++++---- gst/audioparsers/gstflacparse.h | 2 +- gst/audioparsers/gstmpegaudioparse.c | 18 ++++++++++-------- gst/audioparsers/gstmpegaudioparse.h | 2 +- 13 files changed, 43 insertions(+), 40 deletions(-) diff --git a/gst/audioparsers/Makefile.am b/gst/audioparsers/Makefile.am index 77039c7154..13a9c83d0c 100644 --- a/gst/audioparsers/Makefile.am +++ b/gst/audioparsers/Makefile.am @@ -6,10 +6,8 @@ libgstaudioparsersbad_la_SOURCES = \ plugin.c libgstaudioparsersbad_la_CFLAGS = \ - -I$(top_srcdir)/gst-libs \ $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) libgstaudioparsersbad_la_LIBADD = \ - $(top_builddir)/gst-libs/gst/baseparse/libgstbaseparse-$(GST_MAJORMINOR).la \ $(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_MAJORMINOR) \ -lgstaudio-$(GST_MAJORMINOR) \ $(GST_BASE_LIBS) $(GST_LIBS) diff --git a/gst/audioparsers/gstaacparse.c b/gst/audioparsers/gstaacparse.c index 09e3e71f2c..7b9c505a02 100644 --- a/gst/audioparsers/gstaacparse.c +++ b/gst/audioparsers/gstaacparse.c @@ -267,14 +267,15 @@ gst_aacparse_sink_setcaps (GstBaseParse * parse, GstCaps * caps) /* arrange for metadata and get out of the way */ gst_aacparse_set_src_caps (aacparse, caps); - gst_base_parse_set_format (parse, - GST_BASE_PARSE_FORMAT_PASSTHROUGH, TRUE); + gst_base_parse_set_passthrough (parse, TRUE); } else return FALSE; /* caps info overrides */ gst_structure_get_int (structure, "rate", &aacparse->sample_rate); gst_structure_get_int (structure, "channels", &aacparse->channels); + } else { + gst_base_parse_set_passthrough (parse, FALSE); } return TRUE; @@ -460,6 +461,8 @@ gst_aacparse_detect_stream (GstAacParse * aacparse, GST_DEBUG ("ADTS: samplerate %d, channels %d, objtype %d, version %d", rate, channels, aacparse->object_type, aacparse->mpegversion); + gst_base_parse_set_syncable (GST_BASE_PARSE (aacparse), TRUE); + return TRUE; } else if (need_data) { /* This tells the parent class not to skip any data */ @@ -479,10 +482,6 @@ gst_aacparse_detect_stream (GstAacParse * aacparse, aacparse->header_type = DSPAAC_HEADER_ADIF; aacparse->mpegversion = 4; - /* no way to seek this */ - gst_base_parse_set_seek (GST_BASE_PARSE (aacparse), - GST_BASE_PARSE_SEEK_NONE, 0); - /* Skip the "ADIF" bytes */ adif = data + i + 4; @@ -543,8 +542,11 @@ gst_aacparse_detect_stream (GstAacParse * aacparse, /* arrange for metadata and get out of the way */ gst_aacparse_set_src_caps (aacparse, GST_PAD_CAPS (GST_BASE_PARSE_SINK_PAD (aacparse))); - gst_base_parse_set_format (GST_BASE_PARSE (aacparse), - GST_BASE_PARSE_FORMAT_PASSTHROUGH, TRUE); + + /* not syncable, not easily seekable (unless we push data from start */ + gst_base_parse_set_syncable (GST_BASE_PARSE_CAST (aacparse), FALSE); + gst_base_parse_set_passthrough (GST_BASE_PARSE_CAST (aacparse), TRUE); + gst_base_parse_set_average_bitrate (GST_BASE_PARSE_CAST (aacparse), 0); *framesize = avail; return TRUE; @@ -574,14 +576,14 @@ gst_aacparse_check_valid_frame (GstBaseParse * parse, const guint8 *data; GstAacParse *aacparse; gboolean ret = FALSE; - gboolean sync; + gboolean lost_sync; GstBuffer *buffer; aacparse = GST_AACPARSE (parse); buffer = frame->buffer; data = GST_BUFFER_DATA (buffer); - sync = GST_BASE_PARSE_FRAME_SYNC (frame); + lost_sync = GST_BASE_PARSE_LOST_SYNC (parse); if (aacparse->header_type == DSPAAC_HEADER_ADIF || aacparse->header_type == DSPAAC_HEADER_NONE) { @@ -589,16 +591,16 @@ gst_aacparse_check_valid_frame (GstBaseParse * parse, *framesize = GST_BUFFER_SIZE (buffer); ret = TRUE; - } else if (aacparse->header_type == DSPAAC_HEADER_NOT_PARSED || sync == FALSE) { + } else if (aacparse->header_type == DSPAAC_HEADER_NOT_PARSED || lost_sync) { ret = gst_aacparse_detect_stream (aacparse, data, GST_BUFFER_SIZE (buffer), - GST_BASE_PARSE_FRAME_DRAIN (frame), framesize, skipsize); + GST_BASE_PARSE_DRAINING (parse), framesize, skipsize); } else if (aacparse->header_type == DSPAAC_HEADER_ADTS) { guint needed_data = 1024; ret = gst_aacparse_check_adts_frame (aacparse, data, - GST_BUFFER_SIZE (buffer), GST_BASE_PARSE_FRAME_DRAIN (frame), + GST_BUFFER_SIZE (buffer), GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data); if (!ret) { diff --git a/gst/audioparsers/gstaacparse.h b/gst/audioparsers/gstaacparse.h index e62bf651f0..6b781d48ea 100644 --- a/gst/audioparsers/gstaacparse.h +++ b/gst/audioparsers/gstaacparse.h @@ -23,7 +23,7 @@ #define __GST_AACPARSE_H__ #include -#include +#include G_BEGIN_DECLS diff --git a/gst/audioparsers/gstac3parse.c b/gst/audioparsers/gstac3parse.c index e001bc37ec..986b28b071 100644 --- a/gst/audioparsers/gstac3parse.c +++ b/gst/audioparsers/gstac3parse.c @@ -391,7 +391,7 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse, GstBuffer *buf = frame->buffer; GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buf); gint off; - gboolean sync, drain; + gboolean lost_sync, draining; if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < 6)) return FALSE; @@ -422,10 +422,10 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse, GST_LOG_OBJECT (parse, "got frame"); - sync = GST_BASE_PARSE_FRAME_SYNC (frame); - drain = GST_BASE_PARSE_FRAME_DRAIN (frame); + lost_sync = GST_BASE_PARSE_LOST_SYNC (parse); + draining = GST_BASE_PARSE_DRAINING (parse); - if (!sync && !drain) { + if (lost_sync && !draining) { guint16 word = 0; GST_DEBUG_OBJECT (ac3parse, "resyncing; checking next frame syncword"); diff --git a/gst/audioparsers/gstac3parse.h b/gst/audioparsers/gstac3parse.h index 781554be5f..6ed01ddf50 100644 --- a/gst/audioparsers/gstac3parse.h +++ b/gst/audioparsers/gstac3parse.h @@ -24,7 +24,7 @@ #define __GST_AC3_PARSE_H__ #include -#include +#include G_BEGIN_DECLS diff --git a/gst/audioparsers/gstamrparse.c b/gst/audioparsers/gstamrparse.c index 42481a2b29..8d55335214 100644 --- a/gst/audioparsers/gstamrparse.c +++ b/gst/audioparsers/gstamrparse.c @@ -308,7 +308,7 @@ gst_amrparse_check_valid_frame (GstBaseParse * parse, * perform this check) */ if (fsize && - (GST_BASE_PARSE_FRAME_SYNC (frame) || GST_BASE_PARSE_FRAME_DRAIN (frame) + (!GST_BASE_PARSE_LOST_SYNC (parse) || GST_BASE_PARSE_DRAINING (parse) || (dsize > fsize && (data[fsize] & 0x83) == 0))) { *framesize = fsize; return TRUE; diff --git a/gst/audioparsers/gstamrparse.h b/gst/audioparsers/gstamrparse.h index 04cd6e7639..01fbb8b47d 100644 --- a/gst/audioparsers/gstamrparse.h +++ b/gst/audioparsers/gstamrparse.h @@ -24,7 +24,7 @@ #define __GST_AMRPARSE_H__ #include -#include +#include G_BEGIN_DECLS diff --git a/gst/audioparsers/gstdcaparse.c b/gst/audioparsers/gstdcaparse.c index 7e478e47dd..bc522330d3 100644 --- a/gst/audioparsers/gstdcaparse.c +++ b/gst/audioparsers/gstdcaparse.c @@ -322,7 +322,7 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse, if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < 16)) return FALSE; - parser_in_sync = GST_BASE_PARSE_FRAME_SYNC (frame); + parser_in_sync = !GST_BASE_PARSE_LOST_SYNC (parse); if (G_LIKELY (parser_in_sync && dcaparse->last_sync != 0)) { off = gst_byte_reader_masked_scan_uint32 (&r, 0xffffffff, @@ -362,7 +362,7 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse, dcaparse->last_sync = sync; - parser_draining = GST_BASE_PARSE_FRAME_DRAIN (frame); + parser_draining = GST_BASE_PARSE_DRAINING (parse); if (!parser_in_sync && !parser_draining) { /* check for second frame to be sure */ diff --git a/gst/audioparsers/gstdcaparse.h b/gst/audioparsers/gstdcaparse.h index eefc2526c6..b3e066bd0b 100644 --- a/gst/audioparsers/gstdcaparse.h +++ b/gst/audioparsers/gstdcaparse.h @@ -21,7 +21,7 @@ #define __GST_DCA_PARSE_H__ #include -#include +#include G_BEGIN_DECLS diff --git a/gst/audioparsers/gstflacparse.c b/gst/audioparsers/gstflacparse.c index 8306e8e8b1..376ab30994 100644 --- a/gst/audioparsers/gstflacparse.c +++ b/gst/audioparsers/gstflacparse.c @@ -326,9 +326,10 @@ gst_flac_parse_start (GstBaseParse * parse) /* "fLaC" marker */ gst_base_parse_set_min_frame_size (GST_BASE_PARSE (flacparse), 4); + /* inform baseclass we can come up with ts, based on counters in packets */ - gst_base_parse_set_format (GST_BASE_PARSE (flacparse), - GST_BASE_PARSE_FORMAT_HAS_TIME, TRUE); + gst_base_parse_set_has_timing_info (GST_BASE_PARSE_CAST (flacparse), TRUE); + gst_base_parse_set_syncable (GST_BASE_PARSE_CAST (flacparse), TRUE); return TRUE; } @@ -622,7 +623,7 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse, } /* For the last frame output everything to the end */ - if (G_UNLIKELY (GST_BASE_PARSE_FRAME_DRAIN (frame))) { + if (G_UNLIKELY (GST_BASE_PARSE_DRAINING (flacparse))) { if (flacparse->check_frame_checksums) { guint16 actual_crc = gst_flac_calculate_crc16 (data, size - 2); guint16 expected_crc = GST_READ_UINT16_BE (data + size - 2); @@ -697,7 +698,7 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse, return TRUE; } else { /* If we're at EOS and the frame was not valid, drop it! */ - if (G_UNLIKELY (GST_BASE_PARSE_FRAME_DRAIN (frame))) { + if (G_UNLIKELY (GST_BASE_PARSE_DRAINING (flacparse))) { GST_WARNING_OBJECT (flacparse, "EOS"); return FALSE; } diff --git a/gst/audioparsers/gstflacparse.h b/gst/audioparsers/gstflacparse.h index 664b2a6bc9..1c6db0e581 100644 --- a/gst/audioparsers/gstflacparse.h +++ b/gst/audioparsers/gstflacparse.h @@ -25,7 +25,7 @@ #define __GST_FLAC_PARSE_H__ #include -#include +#include G_BEGIN_DECLS diff --git a/gst/audioparsers/gstmpegaudioparse.c b/gst/audioparsers/gstmpegaudioparse.c index 5d1ec4c9d3..9452e57279 100644 --- a/gst/audioparsers/gstmpegaudioparse.c +++ b/gst/audioparsers/gstmpegaudioparse.c @@ -489,7 +489,7 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse, GstBuffer *buf = frame->buffer; GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buf); gint off, bpf; - gboolean sync, drain, valid, caps_change; + gboolean lost_sync, draining, valid, caps_change; guint32 header; guint bitrate, layer, rate, channels, version, mode, crc; @@ -532,11 +532,11 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse, else caps_change = FALSE; - sync = GST_BASE_PARSE_FRAME_SYNC (frame); - drain = GST_BASE_PARSE_FRAME_DRAIN (frame); + lost_sync = GST_BASE_PARSE_LOST_SYNC (parse); + draining = GST_BASE_PARSE_DRAINING (parse); - if (!drain && (!sync || caps_change)) { - if (!gst_mp3parse_validate_extended (mp3parse, buf, header, bpf, drain, + if (!draining && (lost_sync || caps_change)) { + if (!gst_mp3parse_validate_extended (mp3parse, buf, header, bpf, draining, &valid)) { /* not enough data */ gst_base_parse_set_min_frame_size (parse, valid); @@ -548,7 +548,7 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse, return FALSE; } } - } else if (drain && !sync && caps_change) { + } else if (draining && lost_sync && caps_change) { /* avoid caps jitter that we can't be sure of */ *skipsize = off + 2; return FALSE; @@ -572,7 +572,6 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse, GstFormat fmt = GST_FORMAT_BYTES; guint32 read_id; const guint8 *data; - GstBaseParseSeekable seekable; guint bitrate; if (mp3parse->sent_codec_tag) @@ -926,6 +925,8 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse, } /* tell baseclass how nicely we can seek, and a bitrate if one found */ + /* FIXME: fill index with seek table */ +#if 0 seekable = GST_BASE_PARSE_SEEK_DEFAULT; if ((mp3parse->xing_flags & XING_TOC_FLAG) && mp3parse->xing_bytes && mp3parse->xing_total_time) @@ -934,6 +935,7 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse, if (mp3parse->vbri_seek_table && mp3parse->vbri_bytes && mp3parse->vbri_total_time) seekable = GST_BASE_PARSE_SEEK_TABLE; +#endif if (mp3parse->xing_bitrate) bitrate = mp3parse->xing_bitrate; @@ -942,7 +944,7 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse, else bitrate = 0; - gst_base_parse_set_seek (GST_BASE_PARSE (mp3parse), seekable, bitrate); + gst_base_parse_set_average_bitrate (GST_BASE_PARSE (mp3parse), bitrate); } static GstFlowReturn diff --git a/gst/audioparsers/gstmpegaudioparse.h b/gst/audioparsers/gstmpegaudioparse.h index 68b2597515..7580001309 100644 --- a/gst/audioparsers/gstmpegaudioparse.h +++ b/gst/audioparsers/gstmpegaudioparse.h @@ -24,7 +24,7 @@ #define __GST_MPEG_AUDIO_PARSE_H__ #include -#include +#include G_BEGIN_DECLS