mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 17:51:16 +00:00
Rewrote the mpeg2 system parser like the mpeg1 parser.
Original commit message from CVS: Rewrote the mpeg2 system parser like the mpeg1 parser. Added a command property to the pipefilter.
This commit is contained in:
parent
0fa1747e56
commit
987d66af1a
6 changed files with 52 additions and 38 deletions
|
@ -48,7 +48,7 @@ enum {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ARG_0,
|
ARG_0,
|
||||||
ARG_CONTROL
|
ARG_COMMAND
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,11 +98,11 @@ static void gst_pipefilter_class_init(GstPipefilterClass *klass) {
|
||||||
|
|
||||||
gstelement_class->change_state = gst_pipefilter_change_state;
|
gstelement_class->change_state = gst_pipefilter_change_state;
|
||||||
|
|
||||||
//gtk_object_add_arg_type("GstPipefilter::control", GTK_TYPE_INT,
|
gtk_object_add_arg_type("GstPipefilter::command", GTK_TYPE_STRING,
|
||||||
// GTK_ARG_READWRITE, ARG_CONTROL);
|
GTK_ARG_READWRITE, ARG_COMMAND);
|
||||||
|
|
||||||
//gtkobject_class->set_arg = gst_pipefilter_set_arg;
|
gtkobject_class->set_arg = gst_pipefilter_set_arg;
|
||||||
//gtkobject_class->get_arg = gst_pipefilter_get_arg;
|
gtkobject_class->get_arg = gst_pipefilter_get_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gst_pipefilter_init(GstPipefilter *pipefilter) {
|
static void gst_pipefilter_init(GstPipefilter *pipefilter) {
|
||||||
|
@ -112,7 +112,7 @@ static void gst_pipefilter_init(GstPipefilter *pipefilter) {
|
||||||
pipefilter->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
pipefilter->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||||
gst_element_add_pad(GST_ELEMENT(pipefilter),pipefilter->srcpad);
|
gst_element_add_pad(GST_ELEMENT(pipefilter),pipefilter->srcpad);
|
||||||
|
|
||||||
pipefilter->control = 0;
|
pipefilter->command = NULL;
|
||||||
pipefilter->curoffset = 0;
|
pipefilter->curoffset = 0;
|
||||||
pipefilter->bytes_per_read = 4096;
|
pipefilter->bytes_per_read = 4096;
|
||||||
pipefilter->seq = 0;
|
pipefilter->seq = 0;
|
||||||
|
@ -199,8 +199,9 @@ static void gst_pipefilter_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||||
pipefilter = GST_PIPEFILTER(object);
|
pipefilter = GST_PIPEFILTER(object);
|
||||||
|
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case ARG_CONTROL:
|
case ARG_COMMAND:
|
||||||
pipefilter->control = GTK_VALUE_INT(*arg);
|
pipefilter->orig_command = g_strdup(GTK_VALUE_STRING(*arg));
|
||||||
|
pipefilter->command = g_strsplit(GTK_VALUE_STRING(*arg), " ", 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -215,8 +216,8 @@ static void gst_pipefilter_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||||
pipefilter = GST_PIPEFILTER(object);
|
pipefilter = GST_PIPEFILTER(object);
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case ARG_CONTROL:
|
case ARG_COMMAND:
|
||||||
GTK_VALUE_INT(*arg) = pipefilter->control;
|
GTK_VALUE_STRING(*arg) = pipefilter->orig_command;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
arg->type = GTK_TYPE_INVALID;
|
arg->type = GTK_TYPE_INVALID;
|
||||||
|
@ -246,11 +247,16 @@ static gboolean gst_pipefilter_open_file(GstPipefilter *src) {
|
||||||
|
|
||||||
if(src->childpid == 0)
|
if(src->childpid == 0)
|
||||||
{
|
{
|
||||||
close(1);
|
// child
|
||||||
dup(src->fdout[1]); /* set the childs output stream */
|
dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
|
||||||
close(0);
|
dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
|
||||||
dup(src->fdin[0]); /* set the childs output stream */
|
//execlp("lame", "lame", "-x", "-s", "48", "--resample", "44.1", "-", "-", NULL);
|
||||||
execlp("lame", "lame", "-x", "-", "-", 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);
|
GST_FLAG_SET(src,GST_PIPEFILTER_OPEN);
|
||||||
|
|
|
@ -58,8 +58,9 @@ struct _GstPipefilter {
|
||||||
GstPad *sinkpad;
|
GstPad *sinkpad;
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
|
|
||||||
/* filename */
|
/* command */
|
||||||
gchar *filename;
|
gchar **command;
|
||||||
|
gchar *orig_command;
|
||||||
/* fd */
|
/* fd */
|
||||||
gint fdout[2];
|
gint fdout[2];
|
||||||
gint fdin[2];
|
gint fdin[2];
|
||||||
|
@ -69,8 +70,6 @@ struct _GstPipefilter {
|
||||||
gulong bytes_per_read; /* bytes per read */
|
gulong bytes_per_read; /* bytes per read */
|
||||||
|
|
||||||
gulong seq; /* buffer sequence number */
|
gulong seq; /* buffer sequence number */
|
||||||
|
|
||||||
gint control;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstPipefilterClass {
|
struct _GstPipefilterClass {
|
||||||
|
|
|
@ -48,7 +48,7 @@ enum {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ARG_0,
|
ARG_0,
|
||||||
ARG_CONTROL
|
ARG_COMMAND
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,11 +98,11 @@ static void gst_pipefilter_class_init(GstPipefilterClass *klass) {
|
||||||
|
|
||||||
gstelement_class->change_state = gst_pipefilter_change_state;
|
gstelement_class->change_state = gst_pipefilter_change_state;
|
||||||
|
|
||||||
//gtk_object_add_arg_type("GstPipefilter::control", GTK_TYPE_INT,
|
gtk_object_add_arg_type("GstPipefilter::command", GTK_TYPE_STRING,
|
||||||
// GTK_ARG_READWRITE, ARG_CONTROL);
|
GTK_ARG_READWRITE, ARG_COMMAND);
|
||||||
|
|
||||||
//gtkobject_class->set_arg = gst_pipefilter_set_arg;
|
gtkobject_class->set_arg = gst_pipefilter_set_arg;
|
||||||
//gtkobject_class->get_arg = gst_pipefilter_get_arg;
|
gtkobject_class->get_arg = gst_pipefilter_get_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gst_pipefilter_init(GstPipefilter *pipefilter) {
|
static void gst_pipefilter_init(GstPipefilter *pipefilter) {
|
||||||
|
@ -112,7 +112,7 @@ static void gst_pipefilter_init(GstPipefilter *pipefilter) {
|
||||||
pipefilter->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
pipefilter->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||||
gst_element_add_pad(GST_ELEMENT(pipefilter),pipefilter->srcpad);
|
gst_element_add_pad(GST_ELEMENT(pipefilter),pipefilter->srcpad);
|
||||||
|
|
||||||
pipefilter->control = 0;
|
pipefilter->command = NULL;
|
||||||
pipefilter->curoffset = 0;
|
pipefilter->curoffset = 0;
|
||||||
pipefilter->bytes_per_read = 4096;
|
pipefilter->bytes_per_read = 4096;
|
||||||
pipefilter->seq = 0;
|
pipefilter->seq = 0;
|
||||||
|
@ -199,8 +199,9 @@ static void gst_pipefilter_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||||
pipefilter = GST_PIPEFILTER(object);
|
pipefilter = GST_PIPEFILTER(object);
|
||||||
|
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case ARG_CONTROL:
|
case ARG_COMMAND:
|
||||||
pipefilter->control = GTK_VALUE_INT(*arg);
|
pipefilter->orig_command = g_strdup(GTK_VALUE_STRING(*arg));
|
||||||
|
pipefilter->command = g_strsplit(GTK_VALUE_STRING(*arg), " ", 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -215,8 +216,8 @@ static void gst_pipefilter_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||||
pipefilter = GST_PIPEFILTER(object);
|
pipefilter = GST_PIPEFILTER(object);
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case ARG_CONTROL:
|
case ARG_COMMAND:
|
||||||
GTK_VALUE_INT(*arg) = pipefilter->control;
|
GTK_VALUE_STRING(*arg) = pipefilter->orig_command;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
arg->type = GTK_TYPE_INVALID;
|
arg->type = GTK_TYPE_INVALID;
|
||||||
|
@ -246,11 +247,16 @@ static gboolean gst_pipefilter_open_file(GstPipefilter *src) {
|
||||||
|
|
||||||
if(src->childpid == 0)
|
if(src->childpid == 0)
|
||||||
{
|
{
|
||||||
close(1);
|
// child
|
||||||
dup(src->fdout[1]); /* set the childs output stream */
|
dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
|
||||||
close(0);
|
dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
|
||||||
dup(src->fdin[0]); /* set the childs output stream */
|
//execlp("lame", "lame", "-x", "-s", "48", "--resample", "44.1", "-", "-", NULL);
|
||||||
execlp("lame", "lame", "-x", "-", "-", 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);
|
GST_FLAG_SET(src,GST_PIPEFILTER_OPEN);
|
||||||
|
|
|
@ -58,8 +58,9 @@ struct _GstPipefilter {
|
||||||
GstPad *sinkpad;
|
GstPad *sinkpad;
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
|
|
||||||
/* filename */
|
/* command */
|
||||||
gchar *filename;
|
gchar **command;
|
||||||
|
gchar *orig_command;
|
||||||
/* fd */
|
/* fd */
|
||||||
gint fdout[2];
|
gint fdout[2];
|
||||||
gint fdin[2];
|
gint fdin[2];
|
||||||
|
@ -69,8 +70,6 @@ struct _GstPipefilter {
|
||||||
gulong bytes_per_read; /* bytes per read */
|
gulong bytes_per_read; /* bytes per read */
|
||||||
|
|
||||||
gulong seq; /* buffer sequence number */
|
gulong seq; /* buffer sequence number */
|
||||||
|
|
||||||
gint control;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstPipefilterClass {
|
struct _GstPipefilterClass {
|
||||||
|
|
2
test/.gitignore
vendored
2
test/.gitignore
vendored
|
@ -39,3 +39,5 @@ aviparse
|
||||||
avi2mpg
|
avi2mpg
|
||||||
vidcapture
|
vidcapture
|
||||||
mp2tomp1
|
mp2tomp1
|
||||||
|
mp1tomp1
|
||||||
|
pipetest
|
||||||
|
|
|
@ -36,6 +36,8 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
|
||||||
g_return_if_fail(decode != NULL);
|
g_return_if_fail(decode != NULL);
|
||||||
audio_encode = gst_elementfactory_make("pipefilter","audio_encode");
|
audio_encode = gst_elementfactory_make("pipefilter","audio_encode");
|
||||||
g_return_if_fail(audio_encode != NULL);
|
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
|
// create the thread and pack stuff into it
|
||||||
audio_thread = gst_thread_new("audio_thread");
|
audio_thread = gst_thread_new("audio_thread");
|
||||||
|
|
Loading…
Reference in a new issue