Created
November 25, 2011 11:06
-
-
Save shamun/1393272 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <gst/gst.h> | |
#include <gstreamer-0.10/gst/gstpad.h> | |
#include <gstreamer-0.10/gst/gstelement.h> | |
typedef struct | |
{ | |
const gchar *padname; | |
GstPad *target; | |
GstElement *bin; | |
} dynamicLink; | |
int main (int argc, char *argv[]) | |
{ | |
GstElement *myBin; | |
gst_init (&argc, &argv); | |
myBin = (GstElement *) | |
gst_parse_launch ( | |
"videotestsrc ! queue ! s.sink0 videotestsrc pattern=18 ! queue ! s.sink1 input-selector name=s ! videoscale ! video/x-raw-yuv,width=320,height=240,framerate=30/1 ! queue ! tee name=t ! queue ! xvimagesink name=gl t. ! queue ! fakesink" | |
, NULL); | |
gst_element_set_state (myBin, GST_STATE_PLAYING); | |
GstElement *mySink = gst_bin_get_by_name(GST_BIN (myBin), "s"); | |
//gchar *name; | |
//GstPad *myPad = gst_element_get_static_pad(mySink, &name); | |
g_object_set (G_OBJECT (mySink), "active-pad", | |
gst_element_get_pad (mySink, "sink0"), NULL); | |
gint signal = 0; | |
gchar * switchTo = "sink1"; | |
while(TRUE) | |
{ | |
usleep(9000000); | |
if (strcmp("sink1", switchTo) == 0 ) | |
{ | |
//g_print("%s ",switchTo); | |
g_object_set (G_OBJECT (mySink), "active-pad", | |
gst_element_get_pad (mySink, switchTo), NULL); | |
switchTo = "sink0"; | |
g_print("[delay]: sink1 match found\n"); | |
} else { | |
switchTo = "sink1"; | |
g_print("[delay]: sink1 match not found\n"); | |
} | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment