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
This commit is contained in:
parent
000fb758a5
commit
7bb3ae3f18
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -60,6 +60,7 @@ struct _Ecdb_Source
|
||||
unsigned char rec:1;
|
||||
unsigned char num_children;
|
||||
Ecdb_Source **children;
|
||||
Ecdb_Source *parent;
|
||||
IsoNode *node;
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user