+2004-08-03 Benjamin Otte <otte@gnome.org>
+
+ * examples/dynparams/filter.c: (ui_control_create):
+ * examples/gstplay/player.c: (print_tag):
+ * ext/alsa/gstalsa.c: (gst_alsa_request_new_pad):
+ * ext/gdk_pixbuf/gstgdkanimation.c:
+ (gst_gdk_animation_iter_may_advance):
+ * ext/jack/gstjack.c: (gst_jack_request_new_pad):
+ * ext/mad/gstid3tag.c: (gst_mad_id3_to_tag_list),
+ (tag_list_to_id3_tag_foreach), (gst_id3_tag_handle_event):
+ * ext/vorbis/oggvorbisenc.c: (gst_oggvorbisenc_get_tag_value):
+ * ext/vorbis/vorbisenc.c: (gst_vorbisenc_get_tag_value):
+ * ext/xine/xineaudiodec.c: (gst_xine_audio_dec_chain):
+ * gst-libs/gst/media-info/media-info-test.c: (print_tag):
+ * gst/sine/demo-dparams.c: (main):
+ * gst/tags/gstvorbistag.c: (gst_tag_to_vorbis_comments):
+ * testsuite/alsa/formats.c: (create_pipeline):
+ * testsuite/alsa/sinesrc.c: (sinesrc_force_caps), (sinesrc_get):
+ fixes for G_DISABLE_ASSERT and friends
+ * gst/typefind/gsttypefindfunctions.c: (aac_type_find),
+ (mp3_type_frame_length_from_header), (mp3_type_find),
+ (plugin_init):
+ require mp3 typefinding to have at least MIN_HEADERS valid headers
+ add typefinding for AAC adts files
+
2004-08-04 Jan Schmidt <thaytan@mad.scientist.com>
* sys/ximage/ximagesink.c:
/* create the dparam object */
dparam = gst_dpsmooth_new (G_PARAM_SPEC_VALUE_TYPE (specs[i]));
g_object_set (G_OBJECT (dparam), "update_period", 2000000LL, NULL);
- g_assert (gst_dpman_attach_dparam (dpman,
- (gchar *) g_param_spec_get_name (specs[i]), dparam));
+ if (!gst_dpman_attach_dparam (dpman,
+ (gchar *) g_param_spec_get_name (specs[i]), dparam))
+ g_assert_not_reached ();
gst_dpman_set_mode (dpman, "asynchronous");
g_signal_connect (widget, "value-changed",
G_CALLBACK (cb_dynparm_value_changed), dparam);
gchar *str;
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
- g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
+ if (!gst_tag_list_get_string_index (list, tag, i, &str))
+ g_assert_not_reached ();
} else {
str =
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
GstAlsa *this;
gint track = 0;
- g_return_val_if_fail ((this = GST_ALSA (element)), NULL);
+ g_return_val_if_fail (GST_IS_ALSA (element), NULL);
g_return_val_if_fail (!GST_FLAG_IS_SET (element, GST_ALSA_RUNNING), NULL);
+ this = GST_ALSA (element);
if (name) {
/* locate the track number in the requested pad name. */
|| (strcmp (tag, GST_TAG_ALBUM_VOLUME_COUNT) == 0)) {
guint track_no;
- g_assert (gst_tag_list_get_uint_index (list, tag, index, &track_no));
+ if (!gst_tag_list_get_uint_index (list, tag, index, &track_no))
+ g_assert_not_reached ();
vorbisvalue = g_strdup_printf ("%u", track_no);
} else if (strcmp (tag, GST_TAG_DATE) == 0) {
/* FIXME: how are dates represented in vorbis files? */
GDate *date;
guint u;
- g_assert (gst_tag_list_get_uint_index (list, tag, index, &u));
+ if (!gst_tag_list_get_uint_index (list, tag, index, &u))
+ g_assert_not_reached ();
date = g_date_new_julian (u);
vorbisvalue =
g_strdup_printf ("%04d-%02d-%02d", (gint) g_date_get_year (date),
(gint) g_date_get_month (date), (gint) g_date_get_day (date));
g_date_free (date);
} else if (gst_tag_get_type (tag) == G_TYPE_STRING) {
- g_assert (gst_tag_list_get_string_index (list, tag, index, &vorbisvalue));
+ if (!gst_tag_list_get_string_index (list, tag, index, &vorbisvalue))
+ g_assert_not_reached ();
}
return vorbisvalue;
|| (strcmp (tag, GST_TAG_ALBUM_VOLUME_COUNT) == 0)) {
guint track_no;
- g_assert (gst_tag_list_get_uint_index (list, tag, index, &track_no));
+ if (!gst_tag_list_get_uint_index (list, tag, index, &track_no))
+ g_assert_not_reached ();
vorbisvalue = g_strdup_printf ("%u", track_no);
} else if (strcmp (tag, GST_TAG_DATE) == 0) {
/* FIXME: how are dates represented in vorbis files? */
GDate *date;
guint u;
- g_assert (gst_tag_list_get_uint_index (list, tag, index, &u));
+ if (!gst_tag_list_get_uint_index (list, tag, index, &u))
+ g_assert_not_reached ();
date = g_date_new_julian (u);
vorbisvalue =
g_strdup_printf ("%04d-%02d-%02d", (gint) g_date_get_year (date),
(gint) g_date_get_month (date), (gint) g_date_get_day (date));
g_date_free (date);
} else if (gst_tag_get_type (tag) == G_TYPE_STRING) {
- g_assert (gst_tag_list_get_string_index (list, tag, index, &vorbisvalue));
+ if (!gst_tag_list_get_string_index (list, tag, index, &vorbisvalue))
+ g_assert_not_reached ();
}
return vorbisvalue;
gchar *str;
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
- g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
+ if (!gst_tag_list_get_string_index (list, tag, i, &str))
+ g_assert_not_reached ();
} else {
str =
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
g_object_set (G_OBJECT (freq), "slope_time", 50000000LL, NULL);
dpman = gst_dpman_get_manager (sinesrc);
- g_assert (gst_dpman_attach_dparam (dpman, "freq", freq));
+ if (!gst_dpman_attach_dparam (dpman, "freq", freq))
+ g_assert_not_reached ();
gst_dpman_set_mode (dpman, "asynchronous");
spec = (GParamSpecDouble *) gst_dpman_get_param_spec (dpman, "freq");
g_object_set (G_OBJECT (volume), "slope_time", 50000000LL, NULL);
dpman = gst_dpman_get_manager (volfilter);
- g_assert (gst_dpman_attach_dparam (dpman, "volume", volume));
+ if (!gst_dpman_attach_dparam (dpman, "volume", volume))
+ g_assert_not_reached ();
gst_dpman_set_mode (dpman, "asynchronous");
g_object_set (G_OBJECT (volfilter), "mute", FALSE, NULL);
GDate *date;
guint u;
- g_assert (gst_tag_list_get_uint_index (list, tag, i, &u));
+ if (!gst_tag_list_get_uint_index (list, tag, i, &u))
+ g_assert_not_reached ();
date = g_date_new_julian (u);
/* vorbis suggests using ISO date formats */
result =
} else {
guint u;
- g_assert (gst_tag_list_get_uint_index (list, tag, i, &u));
+ if (!gst_tag_list_get_uint_index (list, tag, i, &u))
+ g_assert_not_reached ();
result = g_strdup_printf ("%s=%u", vorbis_tag, u);
}
break;
case G_TYPE_STRING:{
gchar *str;
- g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
+ if (!gst_tag_list_get_string_index (list, tag, i, &str))
+ g_assert_not_reached ();
result = g_strdup_printf ("%s=%s", vorbis_tag, str);
break;
}
case G_TYPE_DOUBLE:{
gdouble value;
- g_assert (gst_tag_list_get_double_index (list, tag, i, &value));
+ if (!gst_tag_list_get_double_index (list, tag, i, &value))
+ g_assert_not_reached ();
result = g_strdup_printf ("%s=%f", vorbis_tag, value);
}
default:
}
}
-/*** audio/mpeg **************************************************************/
+/*** audio/mpeg version 2, 4 *************************************************/
+
+static GstStaticCaps aac_caps = GST_STATIC_CAPS ("audio/mpeg, "
+ "mpegversion = (int) { 2, 4 }, framed = (bool) false");
+#define AAC_CAPS (gst_static_caps_get(&aac_caps))
+static void
+aac_type_find (GstTypeFind * tf, gpointer unused)
+{
+ guint8 *data = gst_type_find_peek (tf, 0, 2);
+
+ /* detect adts header
+ * note that this is a pretty lame typefind method (14 bits, 0.006%), so
+ * we'll only use LIKELY
+ */
+ if (data[0] == 0xFF && (data[1] & 0xF6) == 0xF0) {
+ gboolean mpegversion = (data[1] & 0x08) ? 2 : 4;
+ GstCaps *caps = gst_caps_new_simple ("audio/mpeg",
+ "framed", G_TYPE_BOOLEAN, FALSE,
+ "mpegversion", G_TYPE_INT, mpegversion,
+ NULL);
+
+ gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, caps);
+ gst_caps_free (caps);
+ }
+}
+
+/*** audio/mpeg version 1 ****************************************************/
/**
* The chance that random data is identified as a valid mp3 header is 63 / 2^18
&& version != 3) ? 72000 : 144000) * bitrate / samplerate;
}
- GST_LOG ("mp3typefind: alculated mp3 frame length of %u bytes", length);
+ GST_LOG ("mp3typefind: calculated mp3 frame length of %u bytes", length);
GST_LOG
("mp3typefind: samplerate = %u - bitrate = %u - layer = %u - version = %u"
" - channels = %u", samplerate, bitrate, layer, version, channels);
* random values for typefinding
* if no more data is available, we will return a probability of
* (found_headers/TRY_HEADERS) * (MAXIMUM * (TRY_SYNC - bytes_skipped)
- * / TRY_SYNC)
+ * / TRY_SYNC)
+ * if found_headers >= MIN_HEADERS
*/
-#define GST_MP3_TYPEFIND_TRY_HEADERS 5
+#define GST_MP3_TYPEFIND_MIN_HEADERS (2)
+#define GST_MP3_TYPEFIND_TRY_HEADERS (5)
#define GST_MP3_TYPEFIND_TRY_SYNC (GST_TYPE_FIND_MAXIMUM * 100) /* 10kB */
-#define GST_MP3_TYPEFIND_SYNC_SIZE 2048
+#define GST_MP3_TYPEFIND_SYNC_SIZE (2048)
static void
mp3_type_find (GstTypeFind * tf, gpointer unused)
if (!(length = mp3_type_frame_length_from_header (head, &layer,
&channels, &bitrate, &samplerate))) {
GST_LOG ("%d. header at offset %" G_GUINT64_FORMAT
- " was not an mp3 header", found + 1, offset);
+ " (0x%X) was not an mp3 header", found + 1, offset,
+ (guint) offset);
break;
}
if ((prev_layer && prev_layer != layer) ||
prev_samplerate = samplerate;
} else {
found++;
+ GST_LOG ("found %d. header at offset %" G_GUINT64_FORMAT " (0x%X)",
+ found, offset, (guint) offset);
}
offset += length;
}
g_assert (found <= GST_MP3_TYPEFIND_TRY_HEADERS);
- if (found == GST_MP3_TYPEFIND_TRY_HEADERS || head_data == NULL) {
+ if (found == GST_MP3_TYPEFIND_TRY_HEADERS ||
+ (found >= GST_MP3_TYPEFIND_MIN_HEADERS && head_data == NULL)) {
/* we can make a valid guess */
guint probability = found * GST_TYPE_FIND_MAXIMUM *
(GST_MP3_TYPEFIND_TRY_SYNC - skipped) /
GST_MP3_TYPEFIND_TRY_HEADERS / GST_MP3_TYPEFIND_TRY_SYNC;
+
if (probability < GST_TYPE_FIND_MINIMUM)
probability = GST_TYPE_FIND_MINIMUM;
-
+ GST_INFO
+ ("audio/mpeg calculated %u = %u * %u / %u * (%u - %u) / %u",
+ probability, GST_TYPE_FIND_MAXIMUM, found,
+ GST_MP3_TYPEFIND_TRY_HEADERS, GST_MP3_TYPEFIND_TRY_SYNC, skipped,
+ GST_MP3_TYPEFIND_TRY_SYNC);
/* make sure we're not id3 tagged */
head_data = gst_type_find_peek (tf, -128, 3);
if (!head_data) {
/*** audio/x-m4a *********************************************/
-static GstStaticCaps aac_caps = GST_STATIC_CAPS ("audio/x-m4a");
+static GstStaticCaps m4a_caps = GST_STATIC_CAPS ("audio/x-m4a");
-#define AAC_CAPS (gst_static_caps_get(&aac_caps))
+#define M4A_CAPS (gst_static_caps_get(&m4a_caps))
static void
m4a_type_find (GstTypeFind * tf, gpointer unused)
{
static gchar *zip_exts[] = { "zip", NULL };
static gchar *compress_exts[] = { "Z", NULL };
static gchar *m4a_exts[] = { "m4a", NULL };
+ static gchar *aac_exts[] = { "aac", NULL };
GST_DEBUG_CATEGORY_INIT (type_find_debug, "typefindfunctions",
GST_DEBUG_FG_GREEN | GST_DEBUG_BG_RED, "generic type find functions");
TYPE_FIND_REGISTER (plugin, "audio/x-speex", GST_RANK_PRIMARY,
speex_type_find, NULL, SPEEX_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "audio/x-m4a", GST_RANK_PRIMARY, m4a_type_find,
- m4a_exts, AAC_CAPS, NULL);
+ m4a_exts, M4A_CAPS, NULL);
TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-executable",
GST_RANK_MARGINAL, NULL, "\177ELF", 4, GST_TYPE_FIND_MAXIMUM);
+ TYPE_FIND_REGISTER (plugin, "adts_mpeg_stream", GST_RANK_SECONDARY,
+ aac_type_find, aac_exts, AAC_CAPS, NULL);
return TRUE;
}
/* create the dparam object */
dparam = gst_dpsmooth_new (G_PARAM_SPEC_VALUE_TYPE (specs[i]));
g_object_set (G_OBJECT (dparam), "update_period", 2000000LL, NULL);
- g_assert (gst_dpman_attach_dparam (dpman,
- (gchar *) g_param_spec_get_name (specs[i]), dparam));
+ if (!gst_dpman_attach_dparam (dpman,
+ (gchar *) g_param_spec_get_name (specs[i]), dparam))
+ g_assert_not_reached ();
gst_dpman_set_mode (dpman, "asynchronous");
g_signal_connect (widget, "value-changed",
G_CALLBACK (cb_dynparm_value_changed), dparam);
gchar *str;
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
- g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
+ if (!gst_tag_list_get_string_index (list, tag, i, &str))
+ g_assert_not_reached ();
} else {
str =
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
sinesrc->width = 16;
if (temp == 0) {
- g_assert ((law = gst_element_factory_make ("mulawenc", "mulaw")));
+ law = gst_element_factory_make ("mulawenc", "mulaw");
} else {
- g_assert ((law = gst_element_factory_make ("alawenc", "alaw")));
+ law = gst_element_factory_make ("alawenc", "alaw");
}
+ g_assert (law);
gst_element_unlink (src, alsasink);
gst_bin_add (GST_BIN (pipeline), law);
gst_element_link_many (src, law, alsasink, NULL);
"rate", G_TYPE_INT, src->rate,
"channels", G_TYPE_INT, src->channels, NULL);
- g_assert (gst_pad_try_set_caps (src->src, caps) == GST_PAD_LINK_OK);
+ if (gst_pad_try_set_caps (src->src, caps) != GST_PAD_LINK_OK)
+ g_assert_not_reached ();
}
/* always return 1 wave
if (src->pre_get_func)
src->pre_get_func (src);
- g_assert ((buf =
- gst_buffer_new_and_alloc ((src->width / 8) * src->channels *
- SAMPLES_PER_WAVE)));
- g_assert ((data = GST_BUFFER_DATA (buf)));
+ buf = gst_buffer_new_and_alloc ((src->width / 8) * src->channels *
+ SAMPLES_PER_WAVE);
+ g_assert (buf);
+ data = GST_BUFFER_DATA (buf);
+ g_assert (data);
for (i = 0; i < SAMPLES_PER_WAVE; i++) {
value = sin (i * 2 * M_PI / SAMPLES_PER_WAVE);
sinesrc->width = 16;
if (temp == 0) {
- g_assert ((law = gst_element_factory_make ("mulawenc", "mulaw")));
+ law = gst_element_factory_make ("mulawenc", "mulaw");
} else {
- g_assert ((law = gst_element_factory_make ("alawenc", "alaw")));
+ law = gst_element_factory_make ("alawenc", "alaw");
}
+ g_assert (law);
gst_element_unlink (src, alsasink);
gst_bin_add (GST_BIN (pipeline), law);
gst_element_link_many (src, law, alsasink, NULL);
"rate", G_TYPE_INT, src->rate,
"channels", G_TYPE_INT, src->channels, NULL);
- g_assert (gst_pad_try_set_caps (src->src, caps) == GST_PAD_LINK_OK);
+ if (gst_pad_try_set_caps (src->src, caps) != GST_PAD_LINK_OK)
+ g_assert_not_reached ();
}
/* always return 1 wave
if (src->pre_get_func)
src->pre_get_func (src);
- g_assert ((buf =
- gst_buffer_new_and_alloc ((src->width / 8) * src->channels *
- SAMPLES_PER_WAVE)));
- g_assert ((data = GST_BUFFER_DATA (buf)));
+ buf = gst_buffer_new_and_alloc ((src->width / 8) * src->channels *
+ SAMPLES_PER_WAVE);
+ g_assert (buf);
+ data = GST_BUFFER_DATA (buf);
+ g_assert (data);
for (i = 0; i < SAMPLES_PER_WAVE; i++) {
value = sin (i * 2 * M_PI / SAMPLES_PER_WAVE);