{"action":"closed","issue":{"url":"https://api.github.com/repos/gstreamer-java/gst1-java-core/issues/2","repository_url":"https://api.github.com/repos/gstreamer-java/gst1-java-core","labels_url":"https://api.github.com/repos/gstreamer-java/gst1-java-core/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/gstreamer-java/gst1-java-core/issues/2/comments","events_url":"https://api.github.com/repos/gstreamer-java/gst1-java-core/issues/2/events","html_url":"https://github.com/gstreamer-java/gst1-java-core/issues/2","id":121642281,"number":2,"title":" Pipleline \"p.getElements();\" gives error","user":{"login":"ashishgupta-mca","id":16250857,"avatar_url":"https://avatars.githubusercontent.com/u/16250857?v=3","gravatar_id":"","url":"https://api.github.com/users/ashishgupta-mca","html_url":"https://github.com/ashishgupta-mca","followers_url":"https://api.github.com/users/ashishgupta-mca/followers","following_url":"https://api.github.com/users/ashishgupta-mca/following{/other_user}","gists_url":"https://api.github.com/users/ashishgupta-mca/gists{/gist_id}","starred_url":"https://api.github.com/users/ashishgupta-mca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashishgupta-mca/subscriptions","organizations_url":"https://api.github.com/users/ashishgupta-mca/orgs","repos_url":"https://api.github.com/users/ashishgupta-mca/repos","events_url":"https://api.github.com/users/ashishgupta-mca/events{/privacy}","received_events_url":"https://api.github.com/users/ashishgupta-mca/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-11T05:48:17Z","updated_at":"2016-03-03T13:33:15Z","closed_at":"2016-03-03T13:33:15Z","body":"public class MultipleSinks {\r\n\r\n\t/* receives messages from pipeline elements */\r\n\tpublic static Bus bus = null;\r\n\r\n\t/* send an EOS to this element to shutdown pipeline */\r\n\tpublic static Element src = null;\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\t\r\n\t\t/* initialize gstreamer library */\r\n\t\targs = Gst.init(\"MultiSinkPipe\", args);\r\n\r\n\t\t/* create pipeline */\r\n\t\tfinal Pipeline pipe = new Pipeline(\"MultiSinkPipe\");\r\n\r\n\t\t/* create all pipeline elements */\r\n\t\tsrc = ElementFactory.make(\"filesrc\", \"filesrc0\");\r\n\t\tElement tee = ElementFactory.make(\"tee\", \"tee0\");\r\n\t\tElement h264q = ElementFactory.make(\"queue\", \"queue0\");\r\n\t\tElement decodebin = ElementFactory.make(\"decodebin\", \"decodebin0\");\r\n\t\tfinal Element enc = ElementFactory.make(\"x264enc\", \"x264enc0\");\r\n\t\tElement mux = ElementFactory.make(\"avmux_mp4\", \"avmux_mp40\");\r\n\t\tfinal Element sink = ElementFactory.make(\"filesink\", \"filesink0\");\r\n\t\tElement mpegq = ElementFactory.make(\"queue\", \"queue1\");\r\n\t\tfinal Element mpegsink = ElementFactory.make(\"filesink\", \"filesink1\");\r\n\t\t\r\n\t\t/* set all necessary pipeline attributes */\r\n\t\tsrc.set(\"location\", \"D:\\\\backupx\\\\Twinkle Twinkle Little Star.mp4\");\r\n\t\ttee.set(\"silent\", \"false\");\r\n\t\tenc.set(\"bitrate\", 4096);\r\n\t\tsink.set(\"location\", \"D:\\\\movies\\\\new\\\\output.mp4\");\r\n\t\tmpegsink.set(\"location\", \"D:\\\\movies\\\\new\\\\output.mpg\");\r\n\t\t\r\n\t\t/* store all elements in the pipeline bin */\r\n\t\tpipe.addMany(src, tee, h264q, decodebin, enc, mux, sink, \r\n\t\t\t\t\tmpegq, mpegsink);\r\n\r\n\t\t/* linking each element separately and check for errors */\r\n\t\tif(!src.link(tee)) {\r\n\t\t\tSystem.out.println(\"src-tee\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!tee.link(h264q)) {\r\n\t\t\tSystem.out.println(\"tee-h264q\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!h264q.link(decodebin)) {\r\n\t\t\tSystem.out.println(\"h264q-bin\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t/* need to connect a signal for dynamic pads */\r\n\t\tdecodebin.connect(new Element.PAD_ADDED() {\r\n\t\t\tpublic void padAdded(Element e, final Pad p) {\r\n\t\t\t\tp.link(enc.getStaticPad(\"sink\"));\r\n\t\t\t}\r\n\t\t});\r\n\t\tPad np = new Pad(null, PadDirection.SRC);\r\n\t\tdecodebin.addPad(np);\r\n\t\tif (!enc.link(mux)) {\r\n\t\t\tSystem.out.println(\"Enc-Mux\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!mux.link(sink)) {\r\n\t\t\tSystem.out.println(\"Mux-Sink\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!tee.link(mpegq)) {\r\n\t\t\tSystem.out.println(\"tee-mpegq\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!mpegq.link(mpegsink)) {\r\n\t\t\tSystem.out.println(\"mpegq-mpegsink\");\r\n\t\t}\r\n\r\n\t\t/* listen for EOS signal (to shut pipeline down smoothly) and error\r\n\t\t * messages. */\r\n\t\tbus = pipe.getBus();\r\n\t\tbus.connect(new Bus.EOS() {\r\n\t\t\tpublic void endOfStream(GstObject source) {\r\n\t\t\t\tSystem.out.println(\"EOS\");\r\n\t\t\t\tpipe.setState(State.NULL);\r\n\t\t\t\tGst.quit();\r\n\t\t\t}\r\n\t\t});\r\n\t\tbus.connect(new Bus.ERROR() {\r\n\t\t\tpublic void errorMessage(GstObject arg0, int arg1, String arg2) {\r\n\t\t\t\tSystem.out.println(\"Error: \" + arg2 + \" \" + arg0);\r\n\t\t\t\tGst.quit();\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t/* display some detailed information about the pipeline */\r\n\t\t//printPipeline(pipe);\r\n\r\n\t\t/* start up pipeline. use timer thread for now */\r\n\t\tpipe.setState(State.PLAYING);\r\n\t\tSystem.out.println(\"Starting pipeline...\");\r\n\t\twhile (pipe.getState() != State.PLAYING);\r\n\t\tSystem.out.println(\"Pipeline started.\");\r\n\t\tnew Thread(new TimerThread()).start();\r\n\t\t\r\n\t\tGst.main();\r\n\t\tGst.deinit();\r\n\t}\r\n\r\n\t/* Iterate through all the elements in the pipeline and display their\r\n\t * caps. Useful for debugging and general information about the pipeline */\r\n\tpublic static void printPipeline(Pipeline p) {\r\n\t\t\r\n\t\tList<Element> elements = p.getElements();\r\n\t\t\r\n\t\tif (elements.size() > 0) {\r\n\t\t\tIterator<Element> elemiter = elements.iterator();\r\n\t\t\tElement e = null;\r\n\t\t\twhile (elemiter.hasNext()) {\r\n\t\t\t\te = (Element) elemiter.next();\r\n\r\n\t\t\t\tList<Pad> pads = e.getPads();\r\n\t\t\t\t\r\n\t\t\t\tif (pads.size() > 0) {\r\n\t\t\t\t\tIterator<Pad> paditer = pads.iterator();\r\n\t\t\t\t\tPad pad = null;\r\n\t\t\t\t\twhile (paditer.hasNext()) {\r\n\t\t\t\t\t\tpad = (Pad) paditer.next();\r\n\t\t\t\t\t\tSystem.out.print(e + \" \" + pad.getDirection()); \r\n\t\t\t\t\t\tSystem.out.println(\"\\t\" + pad.getCaps());\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/* Used to time pipeline. A more appropriate method will be implemented later.\r\n * This is simply a quick solution to show the pipelines work */\r\nclass TimerThread implements Runnable {\r\n\t\r\n\t/* two minute timer */\r\n\tlong sleepTime = 2 * 60 * 1000;\r\n\tpublic void run() {\r\n\t\ttry {\r\n\t\t\tThread.sleep(sleepTime);\r\n\t\t} catch (Exception e) {\r\n\t\t\tSystem.out.println(\"Thread error.\");\r\n\t\t}\r\n\t\tSystem.out.println(\"Sending EOS...\");\r\n\t\tMultipleSinks.src.sendEvent(new EOSEvent());\r\n\t}\r\n}\r\n\r\nprintPipeline method gives the below error \r\n\r\nException in thread \"main\" java.lang.Error: Invalid memory access\r\n\tat com.sun.jna.Native.getInt(Native Method)\r\n\tat com.sun.jna.Pointer.getInt(Pointer.java:601)\r\n\tat com.sun.jna.Pointer.getNativeLong(Pointer.java:625)\r\n\tat org.freedesktop.gstreamer.lowlevel.GstTypes.classFor(GstTypes.java:87)\r\n\tat org.freedesktop.gstreamer.lowlevel.NativeObject.classFor(NativeObject.java:211)\r\n\tat org.freedesktop.gstreamer.lowlevel.NativeObject.objectFor(NativeObject.java:188)\r\n\tat org.freedesktop.gstreamer.GstIterator$IteratorImpl.getNext(GstIterator.java:69)\r\n\tat org.freedesktop.gstreamer.GstIterator$IteratorImpl.<init>(GstIterator.java:64)\r\n\tat org.freedesktop.gstreamer.GstIterator.iterator(GstIterator.java:47)\r\n\tat org.freedesktop.gstreamer.GstIterator.asList(GstIterator.java:55)\r\n\tat org.freedesktop.gstreamer.Bin.elementList(Bin.java:166)\r\n\tat org.freedesktop.gstreamer.Bin.getElements(Bin.java:174)\r\n\tat com.MultipleSinks.printPipeline(MultipleSinks.java:138)\r\n\tat com.MultipleSinks.main(MultipleSinks.java:121)\r\n"}}