enum {
ARG_0,
- ARG_CONTROL
+ ARG_COMMAND
};
gstelement_class->change_state = gst_pipefilter_change_state;
- //gtk_object_add_arg_type("GstPipefilter::control", GTK_TYPE_INT,
- // GTK_ARG_READWRITE, ARG_CONTROL);
+ gtk_object_add_arg_type("GstPipefilter::command", GTK_TYPE_STRING,
+ GTK_ARG_READWRITE, ARG_COMMAND);
- //gtkobject_class->set_arg = gst_pipefilter_set_arg;
- //gtkobject_class->get_arg = gst_pipefilter_get_arg;
+ gtkobject_class->set_arg = gst_pipefilter_set_arg;
+ gtkobject_class->get_arg = gst_pipefilter_get_arg;
}
static void gst_pipefilter_init(GstPipefilter *pipefilter) {
pipefilter->srcpad = gst_pad_new("src",GST_PAD_SRC);
gst_element_add_pad(GST_ELEMENT(pipefilter),pipefilter->srcpad);
- pipefilter->control = 0;
+ pipefilter->command = NULL;
pipefilter->curoffset = 0;
pipefilter->bytes_per_read = 4096;
pipefilter->seq = 0;
pipefilter = GST_PIPEFILTER(object);
switch(id) {
- case ARG_CONTROL:
- pipefilter->control = GTK_VALUE_INT(*arg);
+ case ARG_COMMAND:
+ pipefilter->orig_command = g_strdup(GTK_VALUE_STRING(*arg));
+ pipefilter->command = g_strsplit(GTK_VALUE_STRING(*arg), " ", 0);
break;
default:
break;
pipefilter = GST_PIPEFILTER(object);
switch (id) {
- case ARG_CONTROL:
- GTK_VALUE_INT(*arg) = pipefilter->control;
+ case ARG_COMMAND:
+ GTK_VALUE_STRING(*arg) = pipefilter->orig_command;
break;
default:
arg->type = GTK_TYPE_INVALID;
if(src->childpid == 0)
{
- close(1);
- dup(src->fdout[1]); /* set the childs output stream */
- close(0);
- dup(src->fdin[0]); /* set the childs output stream */
- execlp("lame", "lame", "-x", "-", "-", NULL);
+ // child
+ dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
+ dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
+ //execlp("lame", "lame", "-x", "-s", "48", "--resample", "44.1", "-", "-", NULL);
+ execvp(src->command[0], &src->command[0]);
+ // will only reach if error
+ perror("exec");
+ gst_element_error(GST_ELEMENT(src),"starting child process");
+ return FALSE;
+
}
GST_FLAG_SET(src,GST_PIPEFILTER_OPEN);
GstPad *sinkpad;
GstPad *srcpad;
- /* filename */
- gchar *filename;
+ /* command */
+ gchar **command;
+ gchar *orig_command;
/* fd */
gint fdout[2];
gint fdin[2];
gulong bytes_per_read; /* bytes per read */
gulong seq; /* buffer sequence number */
-
- gint control;
};
struct _GstPipefilterClass {
enum {
ARG_0,
- ARG_CONTROL
+ ARG_COMMAND
};
gstelement_class->change_state = gst_pipefilter_change_state;
- //gtk_object_add_arg_type("GstPipefilter::control", GTK_TYPE_INT,
- // GTK_ARG_READWRITE, ARG_CONTROL);
+ gtk_object_add_arg_type("GstPipefilter::command", GTK_TYPE_STRING,
+ GTK_ARG_READWRITE, ARG_COMMAND);
- //gtkobject_class->set_arg = gst_pipefilter_set_arg;
- //gtkobject_class->get_arg = gst_pipefilter_get_arg;
+ gtkobject_class->set_arg = gst_pipefilter_set_arg;
+ gtkobject_class->get_arg = gst_pipefilter_get_arg;
}
static void gst_pipefilter_init(GstPipefilter *pipefilter) {
pipefilter->srcpad = gst_pad_new("src",GST_PAD_SRC);
gst_element_add_pad(GST_ELEMENT(pipefilter),pipefilter->srcpad);
- pipefilter->control = 0;
+ pipefilter->command = NULL;
pipefilter->curoffset = 0;
pipefilter->bytes_per_read = 4096;
pipefilter->seq = 0;
pipefilter = GST_PIPEFILTER(object);
switch(id) {
- case ARG_CONTROL:
- pipefilter->control = GTK_VALUE_INT(*arg);
+ case ARG_COMMAND:
+ pipefilter->orig_command = g_strdup(GTK_VALUE_STRING(*arg));
+ pipefilter->command = g_strsplit(GTK_VALUE_STRING(*arg), " ", 0);
break;
default:
break;
pipefilter = GST_PIPEFILTER(object);
switch (id) {
- case ARG_CONTROL:
- GTK_VALUE_INT(*arg) = pipefilter->control;
+ case ARG_COMMAND:
+ GTK_VALUE_STRING(*arg) = pipefilter->orig_command;
break;
default:
arg->type = GTK_TYPE_INVALID;
if(src->childpid == 0)
{
- close(1);
- dup(src->fdout[1]); /* set the childs output stream */
- close(0);
- dup(src->fdin[0]); /* set the childs output stream */
- execlp("lame", "lame", "-x", "-", "-", NULL);
+ // child
+ dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
+ dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
+ //execlp("lame", "lame", "-x", "-s", "48", "--resample", "44.1", "-", "-", NULL);
+ execvp(src->command[0], &src->command[0]);
+ // will only reach if error
+ perror("exec");
+ gst_element_error(GST_ELEMENT(src),"starting child process");
+ return FALSE;
+
}
GST_FLAG_SET(src,GST_PIPEFILTER_OPEN);
GstPad *sinkpad;
GstPad *srcpad;
- /* filename */
- gchar *filename;
+ /* command */
+ gchar **command;
+ gchar *orig_command;
/* fd */
gint fdout[2];
gint fdin[2];
gulong bytes_per_read; /* bytes per read */
gulong seq; /* buffer sequence number */
-
- gint control;
};
struct _GstPipefilterClass {
avi2mpg
vidcapture
mp2tomp1
+mp1tomp1
+pipetest
g_return_if_fail(decode != NULL);
audio_encode = gst_elementfactory_make("pipefilter","audio_encode");
g_return_if_fail(audio_encode != NULL);
+ gtk_object_set(GTK_OBJECT(audio_encode),"command",
+ "lame -x -s 48 --resample 44.1 - -", NULL);
// create the thread and pack stuff into it
audio_thread = gst_thread_new("audio_thread");