mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
gst/typefind/gsttypefindfunctions.c: backout typefind patch #340375
Original commit message from CVS: * gst/typefind/gsttypefindfunctions.c: (m4a_type_find), (plugin_init): backout typefind patch #340375 * tests/check/elements/adder.c: (message_received), (GST_START_TEST), (adder_suite): redo, signal-handling of test
This commit is contained in:
parent
758b974cbb
commit
ba26d458e2
3 changed files with 80 additions and 100 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2006-05-09 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
|
* gst/typefind/gsttypefindfunctions.c: (m4a_type_find),
|
||||||
|
(plugin_init):
|
||||||
|
backout typefind patch #340375
|
||||||
|
|
||||||
|
* tests/check/elements/adder.c: (message_received),
|
||||||
|
(GST_START_TEST), (adder_suite):
|
||||||
|
redo, signal-handling of test
|
||||||
|
|
||||||
2006-05-09 Wim Taymans <wim@fluendo.com>
|
2006-05-09 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/adder/gstadder.c: (gst_adder_request_new_pad),
|
* gst/adder/gstadder.c: (gst_adder_request_new_pad),
|
||||||
|
|
|
@ -1385,104 +1385,21 @@ ape_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
/*** ISO FORMATS ***/
|
/*** ISO FORMATS ***/
|
||||||
|
|
||||||
/*** audio/x-m4a ***/
|
/*** audio/x-m4a ***/
|
||||||
/*** video/mp4 ***/
|
|
||||||
|
|
||||||
static GstStaticCaps m4a_caps = GST_STATIC_CAPS ("audio/x-m4a");
|
static GstStaticCaps m4a_caps = GST_STATIC_CAPS ("audio/x-m4a");
|
||||||
static GstStaticCaps m4v_caps = GST_STATIC_CAPS ("video/mp4");
|
|
||||||
static GstStaticCaps mp4_caps = GST_STATIC_CAPS ("video/mp4;audio/x-m4a");
|
|
||||||
|
|
||||||
#define M4A_CAPS (gst_static_caps_get(&m4a_caps))
|
#define M4A_CAPS (gst_static_caps_get(&m4a_caps))
|
||||||
#define M4V_CAPS (gst_static_caps_get(&m4v_caps))
|
|
||||||
#define MP4_CAPS (gst_static_caps_get(&mp4_caps))
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
mp4_find_box (GstTypeFind * tf,
|
|
||||||
guint32 pos,
|
|
||||||
guint32 * found_offset, guint32 * found_size, const gchar * box_type)
|
|
||||||
{
|
|
||||||
gboolean found = FALSE;
|
|
||||||
guint8 *data = NULL;
|
|
||||||
|
|
||||||
while (!found) {
|
|
||||||
|
|
||||||
if ((data = gst_type_find_peek (tf, pos + 4, 4)) != NULL) {
|
|
||||||
if (memcmp (data, box_type, 4) == 0) {
|
|
||||||
*found_offset = pos;
|
|
||||||
found = TRUE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((data = gst_type_find_peek (tf, pos, 4)) != NULL) {
|
|
||||||
*found_size = GST_READ_UINT32_BE (data);
|
|
||||||
if (*found_size == 0 || *found_size == 1) {
|
|
||||||
/* largesize boxes or boxes that extend to eof not handled */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pos += *found_size;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mp4_type_find (GstTypeFind * tf, gpointer unused)
|
m4a_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
{
|
{
|
||||||
guint32 box_size = 0;
|
guint8 *data = gst_type_find_peek (tf, 4, 8);
|
||||||
guint32 pos = 0;
|
|
||||||
guint32 offset = 0;
|
|
||||||
guint32 next_trak_offset = 0;
|
|
||||||
gboolean found_hdlr = TRUE;
|
|
||||||
gboolean found_video = FALSE;
|
|
||||||
|
|
||||||
guint8 *data = NULL;
|
if (data &&
|
||||||
|
(memcmp (data, "ftypM4A ", 8) == 0 ||
|
||||||
if ((data = gst_type_find_peek (tf, pos, 12)) != NULL) {
|
memcmp (data, "ftypmp42", 8) == 0)) {
|
||||||
data += 4;
|
|
||||||
if (memcmp (data, "ftypM4A ", 8) == 0) {
|
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, M4A_CAPS);
|
|
||||||
} else if (memcmp (data, "ftypmp42", 8) == 0) {
|
|
||||||
/* parsing based on ISO 14496-12:ISO base media file format, 1st edition */
|
|
||||||
if (mp4_find_box (tf, pos, &offset, &box_size, "moov")) {
|
|
||||||
pos = offset + 8;
|
|
||||||
|
|
||||||
/*loop all trak boxes to see if they contain video */
|
|
||||||
while (found_hdlr) {
|
|
||||||
found_hdlr = FALSE;
|
|
||||||
if (mp4_find_box (tf, pos, &offset, &box_size, "trak")) {
|
|
||||||
next_trak_offset = offset + box_size;
|
|
||||||
pos = offset + 8;
|
|
||||||
if (mp4_find_box (tf, pos, &offset, &box_size, "mdia")) {
|
|
||||||
pos = offset + 8;
|
|
||||||
if (mp4_find_box (tf, pos, &offset, &box_size, "hdlr")) {
|
|
||||||
found_hdlr = TRUE;
|
|
||||||
pos = offset + 12; // hdlr is FullBox
|
|
||||||
data = gst_type_find_peek (tf, pos + 4, 4);
|
|
||||||
if (data && (memcmp (data, "vide", 4) == 0)) {
|
|
||||||
found_video = TRUE;
|
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, M4V_CAPS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pos = next_trak_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!found_video) {
|
|
||||||
/* if video wasn't found, let's interpret this as audio */
|
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, M4A_CAPS);
|
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, M4A_CAPS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** application/x-3gp ***/
|
/*** application/x-3gp ***/
|
||||||
|
|
||||||
|
@ -2434,7 +2351,7 @@ plugin_init (GstPlugin * plugin)
|
||||||
static gchar *gz_exts[] = { "gz", NULL };
|
static gchar *gz_exts[] = { "gz", NULL };
|
||||||
static gchar *zip_exts[] = { "zip", NULL };
|
static gchar *zip_exts[] = { "zip", NULL };
|
||||||
static gchar *compress_exts[] = { "Z", NULL };
|
static gchar *compress_exts[] = { "Z", NULL };
|
||||||
static gchar *mp4_exts[] = { "m4a", "mp4", NULL };
|
static gchar *m4a_exts[] = { "m4a", NULL };
|
||||||
static gchar *q3gp_exts[] = { "3gp", NULL };
|
static gchar *q3gp_exts[] = { "3gp", NULL };
|
||||||
static gchar *aac_exts[] = { "aac", NULL };
|
static gchar *aac_exts[] = { "aac", NULL };
|
||||||
static gchar *spc_exts[] = { "spc", NULL };
|
static gchar *spc_exts[] = { "spc", NULL };
|
||||||
|
@ -2503,8 +2420,8 @@ plugin_init (GstPlugin * plugin)
|
||||||
mpeg4_video_type_find, m4v_exts, MPEG_VIDEO_CAPS, NULL, NULL);
|
mpeg4_video_type_find, m4v_exts, MPEG_VIDEO_CAPS, NULL, NULL);
|
||||||
|
|
||||||
/* ISO formats */
|
/* ISO formats */
|
||||||
TYPE_FIND_REGISTER (plugin, "application/x-mp4", GST_RANK_PRIMARY,
|
TYPE_FIND_REGISTER (plugin, "audio/x-m4a", GST_RANK_PRIMARY, m4a_type_find,
|
||||||
mp4_type_find, mp4_exts, MP4_CAPS, NULL, NULL);
|
m4a_exts, M4A_CAPS, NULL, NULL);
|
||||||
TYPE_FIND_REGISTER (plugin, "application/x-3gp", GST_RANK_PRIMARY,
|
TYPE_FIND_REGISTER (plugin, "application/x-3gp", GST_RANK_PRIMARY,
|
||||||
q3gp_type_find, q3gp_exts, Q3GP_CAPS, NULL, NULL);
|
q3gp_type_find, q3gp_exts, Q3GP_CAPS, NULL, NULL);
|
||||||
TYPE_FIND_REGISTER (plugin, "video/quicktime", GST_RANK_SECONDARY,
|
TYPE_FIND_REGISTER (plugin, "video/quicktime", GST_RANK_SECONDARY,
|
||||||
|
|
|
@ -24,9 +24,11 @@
|
||||||
|
|
||||||
#include <gst/check/gstcheck.h>
|
#include <gst/check/gstcheck.h>
|
||||||
|
|
||||||
|
static GMainLoop *main_loop;
|
||||||
static GstFormat format = GST_FORMAT_UNDEFINED;
|
static GstFormat format = GST_FORMAT_UNDEFINED;
|
||||||
static gint64 position = -1;
|
static gint64 position = -1;
|
||||||
|
|
||||||
|
/*
|
||||||
static void
|
static void
|
||||||
event_loop (GstElement * bin)
|
event_loop (GstElement * bin)
|
||||||
{
|
{
|
||||||
|
@ -74,20 +76,61 @@ event_loop (GstElement * bin)
|
||||||
gst_message_unref (message);
|
gst_message_unref (message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
message_received (GstBus * bus, GstMessage * message, GstPipeline * bin)
|
||||||
|
{
|
||||||
|
GstObject *object = GST_MESSAGE_SRC (message);
|
||||||
|
|
||||||
|
GST_INFO ("bus message from \"%s\" (%s): ",
|
||||||
|
GST_STR_NULL (GST_ELEMENT_NAME (object)),
|
||||||
|
gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
|
||||||
|
|
||||||
|
switch (message->type) {
|
||||||
|
case GST_MESSAGE_EOS:
|
||||||
|
g_main_loop_quit (main_loop);
|
||||||
|
break;
|
||||||
|
case GST_MESSAGE_SEGMENT_DONE:
|
||||||
|
gst_message_parse_segment_done (message, &format, &position);
|
||||||
|
GST_INFO ("received segment_done : %" G_GINT64_FORMAT, position);
|
||||||
|
g_main_loop_quit (main_loop);
|
||||||
|
break;
|
||||||
|
case GST_MESSAGE_WARNING:
|
||||||
|
case GST_MESSAGE_ERROR:{
|
||||||
|
GError *gerror;
|
||||||
|
gchar *debug;
|
||||||
|
|
||||||
|
gst_message_parse_error (message, &gerror, &debug);
|
||||||
|
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
|
||||||
|
g_error_free (gerror);
|
||||||
|
g_free (debug);
|
||||||
|
g_main_loop_quit (main_loop);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GST_START_TEST (test_event)
|
GST_START_TEST (test_event)
|
||||||
{
|
{
|
||||||
GstElement *bin, *src1, *src2, *adder, *sink;
|
GstElement *bin, *src1, *src2, *adder, *sink;
|
||||||
|
GstBus *bus;
|
||||||
GstEvent *seek_event;
|
GstEvent *seek_event;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
|
GST_INFO ("starting test");
|
||||||
|
|
||||||
/* build pipeline */
|
/* build pipeline */
|
||||||
bin = gst_pipeline_new ("pipeline");
|
bin = gst_pipeline_new ("pipeline");
|
||||||
src1 = gst_element_factory_make ("audiotestsrc", "src1");
|
bus = gst_element_get_bus (bin);
|
||||||
g_object_set (src1, "wave", 4, NULL); /* silence */
|
gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
|
||||||
src2 = gst_element_factory_make ("audiotestsrc", "src2");
|
|
||||||
g_object_set (src2, "wave", 4, NULL); /* silence */
|
src1 = gst_element_factory_make ("fakesrc", "src1");
|
||||||
|
//g_object_set (src1, "wave", 4, NULL); /* silence */
|
||||||
|
src2 = gst_element_factory_make ("fakesrc", "src2");
|
||||||
|
//g_object_set (src2, "wave", 4, NULL); /* silence */
|
||||||
adder = gst_element_factory_make ("adder", "adder");
|
adder = gst_element_factory_make ("adder", "adder");
|
||||||
sink = gst_element_factory_make ("fakesink", "sink");
|
sink = gst_element_factory_make ("fakesink", "sink");
|
||||||
gst_bin_add_many (GST_BIN (bin), src1, src2, adder, sink, NULL);
|
gst_bin_add_many (GST_BIN (bin), src1, src2, adder, sink, NULL);
|
||||||
|
@ -102,11 +145,18 @@ GST_START_TEST (test_event)
|
||||||
seek_event = gst_event_new_seek (1.0, GST_FORMAT_TIME,
|
seek_event = gst_event_new_seek (1.0, GST_FORMAT_TIME,
|
||||||
GST_SEEK_FLAG_SEGMENT,
|
GST_SEEK_FLAG_SEGMENT,
|
||||||
GST_SEEK_TYPE_SET, (GstClockTime) 0,
|
GST_SEEK_TYPE_SET, (GstClockTime) 0,
|
||||||
GST_SEEK_TYPE_SET, (GstClockTime) GST_SECOND);
|
GST_SEEK_TYPE_SET, (GstClockTime) 2 * GST_SECOND);
|
||||||
|
|
||||||
format = GST_FORMAT_UNDEFINED;
|
format = GST_FORMAT_UNDEFINED;
|
||||||
position = -1;
|
position = -1;
|
||||||
|
|
||||||
|
main_loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
g_signal_connect (bus, "message::segment-done", (GCallback) message_received,
|
||||||
|
bin);
|
||||||
|
g_signal_connect (bus, "message::error", (GCallback) message_received, bin);
|
||||||
|
g_signal_connect (bus, "message::warning", (GCallback) message_received, bin);
|
||||||
|
g_signal_connect (bus, "message::eos", (GCallback) message_received, bin);
|
||||||
|
|
||||||
/* prepare playing */
|
/* prepare playing */
|
||||||
res = gst_element_set_state (bin, GST_STATE_PAUSED);
|
res = gst_element_set_state (bin, GST_STATE_PAUSED);
|
||||||
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
|
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
|
||||||
|
@ -118,14 +168,17 @@ GST_START_TEST (test_event)
|
||||||
res = gst_element_set_state (bin, GST_STATE_PLAYING);
|
res = gst_element_set_state (bin, GST_STATE_PLAYING);
|
||||||
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
|
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
|
||||||
|
|
||||||
event_loop (bin);
|
//event_loop (bin);
|
||||||
|
g_main_loop_run (main_loop);
|
||||||
|
|
||||||
res = gst_element_set_state (bin, GST_STATE_NULL);
|
res = gst_element_set_state (bin, GST_STATE_NULL);
|
||||||
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
|
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
|
||||||
|
|
||||||
fail_unless (position == GST_SECOND, NULL);
|
fail_unless (position == 2 * GST_SECOND, NULL);
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
|
g_main_loop_unref (main_loop);
|
||||||
|
gst_object_unref (G_OBJECT (bus));
|
||||||
gst_object_unref (G_OBJECT (bin));
|
gst_object_unref (G_OBJECT (bin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +194,7 @@ adder_suite (void)
|
||||||
tcase_add_test (tc_chain, test_event);
|
tcase_add_test (tc_chain, test_event);
|
||||||
|
|
||||||
/* Use a longer timeout */
|
/* Use a longer timeout */
|
||||||
tcase_set_timeout (tc_chain, 10);
|
tcase_set_timeout (tc_chain, 4);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue