From c4568b11bca2b10dcab7323c245a59a13a33af57 Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Tue, 27 May 2008 23:28:01 +0000 Subject: [PATCH] Add child_remove, and get rid of all the gstreamer code I added. Doesn't work, and not going to do it that way anyways --- experimental/ecdb/trunk/src/ecdb_audio.c | 187 ---------------------- experimental/ecdb/trunk/src/ecdb_audio.h | 2 +- experimental/ecdb/trunk/src/ecdb_common.h | 1 + experimental/ecdb/trunk/src/ecdb_image.c | 38 +++++ experimental/ecdb/trunk/src/ecdb_image.h | 1 + 5 files changed, 41 insertions(+), 188 deletions(-) diff --git a/experimental/ecdb/trunk/src/ecdb_audio.c b/experimental/ecdb/trunk/src/ecdb_audio.c index 88e83c49..1c661213 100644 --- a/experimental/ecdb/trunk/src/ecdb_audio.c +++ b/experimental/ecdb/trunk/src/ecdb_audio.c @@ -1,189 +1,2 @@ #include "ecdb.h" -/* A lot of the code below is from brasero, so thanks to them for it */ -char *ecdb_audio_output_create(Ecdb_Source *src); -static gboolean cb_buscall(GstBus *bus, GstMessage *msg, gpointer data); -static void cb_newpad(GstElement *decodebin, GstPad *pad, - gboolean last, gpointer data); - -int -ecdb_audio_project_setup(Ecdb_Burn_Project *proj) -{ - int argc; - char **argv; - - GMainLoop *loop; - - ecore_app_args_get(&argc, &argv); - gst_init(&argc, &argv); - loop = g_main_loop_new(NULL, FALSE); - return TRUE; -} - -static gboolean -cb_buscall(GstBus *bus, GstMessage *msg, gpointer data) -{ - if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_EOS) - printf("End of stream\n"); - - else if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR) - { - gchar *debug; - GError *err; - - gst_message_parse_error(msg, &err, &debug); - g_free(debug); - g_print("Error: %s\n", err->message); - g_error_free(err); - } - - return TRUE; -} - -static void -cb_newpad(GstElement *decodebin, GstPad *pad, gboolean last, gpointer data) -{ - GstPad *sink; - GstCaps *caps; - GstStructure *structure; - GstElement *convert; - - convert = (GstElement *) data; - - sink = gst_element_get_pad (convert, "sink"); - if (GST_PAD_IS_LINKED (sink)) - return; - - /* make sure we only have audio */ - caps = gst_pad_get_caps (pad); - if (!caps) - return; - - structure = gst_caps_get_structure (caps, 0); - if (structure - && g_strrstr (gst_structure_get_name (structure), "audio")) - gst_pad_link (pad, sink); - - gst_object_unref (sink); - gst_caps_unref (caps); -} - -int -ecdb_audio_project_handle(Ecdb_Source *src, char *error) -{ - GstElement *decode; - GstElement *source; - GstBus *bus = NULL; - GstCaps *filtercaps; - GstElement *pipeline; - GstElement *sink = NULL; - GstElement *filter = NULL; - GstElement *convert = NULL; - GstElement *resample = NULL; - char *output; - - pipeline = gst_pipeline_new(NULL); - bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); - gst_bus_add_watch(bus, cb_buscall, NULL); - gst_object_unref(bus); - - /* source */ - source = gst_element_make_from_uri(GST_URI_SRC, src->dst, NULL); - if (!source) - { - error = "Source couldn't be created!"; - gst_object_unref(GST_OBJECT(pipeline)); - return FALSE; - } - gst_bin_add(GST_BIN(pipeline), source); - g_object_set(source, "typefind", FALSE, NULL); - - /* Output */ - sink = gst_element_factory_make("filesink", NULL); - output = ecdb_audio_output_create(src); - g_object_set(sink, "location", output, NULL); - src->dst = output; - if (!sink) - { - error = "Sink couldn't be created!"; - gst_object_unref(GST_OBJECT(pipeline)); - FREE(output); - return FALSE; - } - gst_bin_add(GST_BIN(pipeline), sink); - g_object_set(sink, "sync", FALSE, NULL); - - /* Audioconvert */ - convert = gst_element_factory_make("audioconvert", NULL); - if (!convert) - { - error = "Audioconvert couldn't be created!"; - gst_object_unref(GST_OBJECT(pipeline)); - FREE(output); - return FALSE; - } - - /* resample */ - resample = gst_element_factory_make("audioresample", NULL); - if (!resample) - { - error = "Audioresampler couldn't be create!"; - gst_object_unref(GST_OBJECT(pipeline)); - FREE(output); - return FALSE; - } - gst_bin_add(GST_BIN(pipeline), resample); - - /* Filter */ - filter = gst_element_factory_make("capsfilter", NULL); - if (!filter) - { - error = "Filter couldn't be created!"; - gst_object_unref(GST_OBJECT(pipeline)); - FREE(output); - return FALSE; - } - gst_bin_add(GST_BIN(pipeline), filter); - filtercaps = gst_caps_new_full(gst_structure_new("audio/x-raw-int", - "channels", G_TYPE_INT, 2, - "width", G_TYPE_INT, 16, - "depth", G_TYPE_INT, 16, - "endianness", G_TYPE_INT, 1234, - "rate", G_TYPE_INT, 44100, - "signed", G_TYPE_BOOLEAN, TRUE, - NULL), NULL); - g_object_set(GST_OBJECT(filter), "caps", filtercaps, NULL); - gst_caps_unref(filtercaps); - - /* decode */ - decode = gst_element_factory_make("decodebin", NULL); - if (!decode) - { - error = "Decode couldn't be created!"; - gst_object_unref(GST_OBJECT(pipeline)); - FREE(output); - return FALSE; - } - gst_bin_add(GST_BIN(pipeline), decode); - gst_element_link_many(source, decode, NULL); - g_signal_connect(G_OBJECT(decode), "new-decoded-pad", - G_CALLBACK(cb_newpad), resample); - gst_element_link_many(resample, convert, filter, sink, NULL); - - /* End stuff */ - gst_element_set_state(pipeline, GST_STATE_PLAYING); - FREE(output); - return TRUE; -} - -char * -ecdb_audio_output_create(Ecdb_Source *src) -{ - char ret[PATH_MAX]; - - snprintf(ret, PATH_MAX, "/tmp/ecdb/%s.wav", - ecore_file_file_get - (ecore_file_strip_ext(src->dst))); - return strdup(ret); -} - diff --git a/experimental/ecdb/trunk/src/ecdb_audio.h b/experimental/ecdb/trunk/src/ecdb_audio.h index fe1fc0c0..e2e4209c 100644 --- a/experimental/ecdb/trunk/src/ecdb_audio.h +++ b/experimental/ecdb/trunk/src/ecdb_audio.h @@ -1,6 +1,6 @@ #ifndef ECDB_AUDIO_H #define ECDB_AUDIO_H -Ecdb_Source *ecdb_audio_track_handle(Ecdb_Source *src); +int ecdb_audio_project_setup(Ecdb_Burn_Project *proj); #endif diff --git a/experimental/ecdb/trunk/src/ecdb_common.h b/experimental/ecdb/trunk/src/ecdb_common.h index d3a25431..1ebc4e30 100644 --- a/experimental/ecdb/trunk/src/ecdb_common.h +++ b/experimental/ecdb/trunk/src/ecdb_common.h @@ -60,6 +60,7 @@ struct _Ecdb_Source unsigned char rec:1; unsigned char num_children; Ecdb_Source **children; + Ecdb_Source *parent; IsoNode *node; }; diff --git a/experimental/ecdb/trunk/src/ecdb_image.c b/experimental/ecdb/trunk/src/ecdb_image.c index f9c7531e..6d857916 100644 --- a/experimental/ecdb/trunk/src/ecdb_image.c +++ b/experimental/ecdb/trunk/src/ecdb_image.c @@ -55,6 +55,44 @@ ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child) (src->num_children + 1)); src->children[src->num_children - 1] = child; src->children[src->num_children] = NULL; + child->parent = src; +} + +/* Basically here we can remove all occurences (who knows why we'd get + * multiple, but whatever), or just the first. For now remove the first, and + * see how that goes + */ +void +ecdb_source_child_remove(Ecdb_Source *src, Ecdb_Source *child) +{ + Ecdb_Source **temp; + int i, cidx, f; + + if (src == child) + { + printf("Trying to remove oneself\n"); + return; + } + + temp = calloc(src->num_children, sizeof(Ecdb_Source)); + temp[src->num_children - 1] = NULL; + + cidx = f = 0; + for (i = 0; src->children[i]; i++) + { + if ((src->children[i] == child) && (!f)) + { + f++; + continue; + } + temp[cidx] = src->children[i]; + cidx++; + } + + FREE(src->children); + src->children = temp; + src->num_children--; + child->parent = NULL; } void diff --git a/experimental/ecdb/trunk/src/ecdb_image.h b/experimental/ecdb/trunk/src/ecdb_image.h index 394a74ef..5cd91f12 100644 --- a/experimental/ecdb/trunk/src/ecdb_image.h +++ b/experimental/ecdb/trunk/src/ecdb_image.h @@ -5,6 +5,7 @@ Ecdb_Source *ecdb_source_new(void); void ecdb_source_data_set(Ecdb_Source *src, const char *dst, unsigned char rec); void ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child); +void ecdb_source_child_remove(Ecdb_Source *src, Ecdb_Source *child); BurnSource *ecdb_image_project(Ecdb_Burn_Project *proj); #endif