How do i get a pointer to i.e a filesource in the pipelines' upstream?
What i want to do is: from my plugin filter i need to use the file descriptor of the connected filesrc. So i want to use g_object_get to receive a GValue for the "fd" property of the filesrc. But i need to pass a GObject to this function. How do i get the GObject associated with the filesrc? Thanks for any suggestion. Daniel. |
Administrator
|
There are functions gst_bin_get_by_name, gst_bin_iterate_sources, gst_bin_iterate_elements and several similar. |
Yes i know.
But i do not have a reference to the pipeline yet. And i do not know the name of the pipeline. The pipline gets build by the Qt application "mediaplayer". My decoder plugin gets loaded. But i need the file descriptor of the opened media file. At the moment i do: GstPad *pUpPad = gst_pad_get_peer(decoder->sinkpad); GstElemnt *pElement = (GstElement*) gst_pad_get_parent_element (pUpPad); g_object_get(pElement,"name",&nameVal,NULL); g_print("### name is %s\n",nameVal); //here i get typefind then i do: GstPad *pUpPadSink = gst_element_get_pad (pElement,"sink"); GstPad *pUpPadNext= gst_pad_get_peer(pUpPadSink); pElement = (GstElement*) gst_pad_get_parent_element (pUpPadNext); /* here: (<unknown>:1300): GLib-GObject-CRITICAL **: g_object_get: assertion `G_IS_OBJECT (object)' failed */ g_object_get(pElement,"name",&nameVal,NULL); g_print("### name is %s\n",nameVal); Can you help me out? |
Administrator
|
I would browse the mediaplayer's sources and look for the GStreamer-related code. |
Administrator
|
A-ha! There is a macros GST_ELEMENT_PARENT(). If you have a decoder element, then, some bin will be its parent, and you can get it. However, I'm in doubts about correctness of your approach. In my understanding, the 'transforming' element just gets data from outside and processes them. It should not deal with the sources of that data. What if the data would come from a live stream, or would be application-generated, such that the file descriptor simply doesn't exist? |
Hm. Parent is the decoder plugin itself ??!
Yes you are right. I think it is not the best way i go. But my decoder api uses file descriptor to initialize its' FrameExtraction. For the moment i just want to get the video decoding runnning. Next version i will improve that. But for the moment i am going to check if a filesrc element is on top of the upstream and the try to get the file descriptor. If that fails - fail to decode and exit with error. |
Administrator
|
No. If you have a reference to the decoder element, than you can get its parent, which will be some bin. Then you can use gst_bin_get_* and gst_bin_iterate_* functions to find source elements, and then you can query them for the file descriptor. Another way, your decoder has a sink pad, where data come, and you can get a reference to it. Then, there is a function gst_pad_get_peer, which return a peer pad, which belongs to another element. Hopefully, this element is the one, feeding your decoder with data. Then you can query the pad for its parent and query that parent for fd. |
Right - the *_peer function i try at the moment (see post above).
i get: proxypad2 --> typefind --> mydecoder hopefully i get something like: filesrc --> XXX --> proxypad2 --> |
Hi wl2776,
i can do: GstElement* pDEC = (GstElement*) gst_pad_get_parent_element (dec->sinkpad); g_object_get(pDEC,"name",&valName,NULL); //valName is then mydecoder0 But i can not call: GstElement *pFS = gst_bin_get_by_name(GST_BIN(pDEC),"filesrc"); here the errormsg comes: (<unknown>:1196): GLib-GObject-WARNING **: invalid cast from `GstMyDecoder' to `GstBin' Do you know what i can do to enumerate / find all elements within the pipeline? Do you know how to receive the name of the pipeline where my element belongs to? Thanks you. |
Administrator
|
Not exactly, theoretically. http://www.gstreamer.net/data/doc/gstreamer/head/gstreamer/html/GstBin.html#gst-bin-iterate-elements http://www.gstreamer.net/data/doc/gstreamer/head/gstreamer/html/GstBin.html#gst-bin-iterate-sources name can be retrieved by g_object_get() |
Administrator
|
In reply to this post by ericcardmanNo3
If dec is your decoder, then now you've got a pad in pDEC. Of course, because, pDEC is a pad not a bin. What do you get, if you call GST_ELEMENT_PARENT(dec) ? This should be a bin. |
i do:
GstPad *pP = gst_pad_get_peer(dec->sinkpad); GstElement* pDEC = (GstElement*) gst_pad_get_parent_element (dec->sinkpad); GstElement *pEE = gst_bin_get_by_name(GST_ELEMENT_PARENT(pDEC),"filesrc"); GstElement *pEE1 = gst_bin_get_by_name(dec,"filesrc"); g_print("§§§§ GST_ELEMENT_PARENT is 0x%x pEE is 0x%x pEE1 is 0x%x\n",GST_ELEMENT_PARENT(pDEC),pEE, pEE1); g_object_get(pDEC,"name",&fb_fd,NULL); g_print("### pP is 0x%x (pDEC is 0x%x [%s])\n",pP,pDEC,fb_fd); OUTPUT IS: (<unknown>:1493): GStreamer-CRITICAL **: gst_bin_get_by_name: assertion `GST_IS_BIN (bin)' failed ???? GST_ELEMENT_PARENT is 0xf4040 pEE is 0x0 pEE1 is 0x0 ### pP is 0xaad80 (pDEC is 0x165128 [my264decoder0]) Do you know what i am doing wrong here? |
Administrator
|
You didn't specify what dec is. I suppose, it is your decoder element. Then dec->sinkpad is the sink pad of it. Then, after GstElement* pDEC = (GstElement*) gst_pad_get_parent_element (dec->sinkpad); pDEC should contain the same as dec - the pointer to your decoder element. Next instruction. GstElement *pEE = gst_bin_get_by_name(GST_ELEMENT_PARENT(pDEC),"filesrc"); Here you're getting a bin, containing your decoder and querying it for element, named "filesrc". However, this bin doesn't contain the element with such name. How do you know that the element's name is "filesrc"? This could be "source", "filesrc0", etc. Next instuction. GstElement *pEE1 = gst_bin_get_by_name(dec,"filesrc"); Here you're querying your decoder element for an element, named "filesrc". Your decoder is not a bin, so, you're getting error message. I would recommend you putenv("GST_DEBUG_DUMP_DOT_DIR=/home/your/favorite/dir/goes/here"); then go to the topmost level with calls to GST_ELEMENT_PARENT in cycle, then GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(topmost_bin), GST_DEBUG_GRAPH_SHOW_ALL, "player"); This will result in the /home/you/favorive/dir/player.dot file, which you can convert to png with the following command. dot -Tpng -o/home/you/favorive/dir/player.png /home/you/favorive/dir/player.dot Somethig [!!! untested ] GstElement *el, *el1; el=el1=GST_ELEMENT_PARENT(dec); while(el){ el1=el; el=GST_ELEMENT_PARENT(el1); } [!!! untested ] The code above should give you a pointer to a topmost container. Then do GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(topmost_bin), GST_DEBUG_GRAPH_SHOW_ALL, "player"); and explore the resulting player.dot file. It will show you all names, links and capabilites. |
wl2776
Thank you very much! Now I make progess. Problem solved I think. I will post my results after examine the results of the below postet code to get access to the file descriptor soon. GstElement *pFirst = GST_ELEMENT_PARENT(avi); fb_fd=0; g_object_get(pFirst,"name",&fb_fd,NULL); g_print("### name is %s (0x%x)\n",fb_fd,pFirst); GstIterator *pIt = gst_bin_iterate_elements(pFirst); gpointer p; GstIteratorResult res; do{ res = gst_iterator_next(pIt,&p); g_print("======> res = 0x%x pIt = 0x%x p = 0x%x\n",res,pIt,p); }while(res != 0x0); GstElement *pSecond = GST_ELEMENT_PARENT(pFirst); fb_fd=0; g_object_get(pSecond,"name",&fb_fd,NULL); g_print("### name is %s (0x%x)\n",fb_fd,pSecond); pIt = gst_bin_iterate_elements(pSecond); do{ res = gst_iterator_next(pIt,&p); g_print("======> res = 0x%x pIt = 0x%x p = 0x%x\n",res,pIt,p); }while(res != 0x0); Best regards, daniel.- |
Free forum by Nabble | Edit this page |