Skip to content

Commit ec051bc

Browse files
committed
Add DecodeBin, URIDecodeBin
1 parent 9e0652a commit ec051bc

File tree

4 files changed

+475
-9
lines changed

4 files changed

+475
-9
lines changed

src/org/freedesktop/gstreamer/Gst.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@
3939
import org.freedesktop.gstreamer.elements.AppSrc;
4040
import org.freedesktop.gstreamer.elements.BaseSink;
4141
import org.freedesktop.gstreamer.elements.BaseSrc;
42+
import org.freedesktop.gstreamer.elements.BaseTransform;
43+
import org.freedesktop.gstreamer.elements.DecodeBin;
4244
import org.freedesktop.gstreamer.elements.PlayBin;
45+
import org.freedesktop.gstreamer.elements.URIDecodeBin;
4346
import org.freedesktop.gstreamer.glib.GDate;
4447
import org.freedesktop.gstreamer.glib.MainContextExecutorService;
45-
import org.freedesktop.gstreamer.interfaces.ColorBalanceChannel;
4648
import org.freedesktop.gstreamer.lowlevel.GMainContext;
4749
import org.freedesktop.gstreamer.lowlevel.GValueAPI.GValue;
4850
import org.freedesktop.gstreamer.lowlevel.GValueAPI.GValueArray;
@@ -58,7 +60,6 @@
5860
import com.sun.jna.Pointer;
5961
import com.sun.jna.ptr.IntByReference;
6062
import com.sun.jna.ptr.PointerByReference;
61-
import org.freedesktop.gstreamer.elements.BaseTransform;
6263

6364
/**
6465
* Media library supporting arbitrary formats and filter graphs.
@@ -478,9 +479,11 @@ private static synchronized void loadAllClasses() {
478479
BaseSink.class,
479480
BaseTransform.class,
480481
Bin.class,
482+
DecodeBin.class,
481483
Pipeline.class,
482484
PlayBin.class,
483-
//
484-
TagList.class
485+
URIDecodeBin.class,
486+
//
487+
TagList.class
485488
};
486489
}
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/*
2+
* Copyright (c) 2010 DHoyt <[email protected]>
3+
*
4+
* This file is part of gstreamer-java.
5+
*
6+
* This code is free software: you can redistribute it and/or modify it under
7+
* the terms of the GNU Lesser General Public License version 3 only, as
8+
* published by the Free Software Foundation.
9+
*
10+
* This code is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13+
* version 3 for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
package org.freedesktop.gstreamer.elements;
20+
21+
import org.freedesktop.gstreamer.Bin;
22+
import org.freedesktop.gstreamer.Caps;
23+
import org.freedesktop.gstreamer.Element;
24+
import org.freedesktop.gstreamer.Pad;
25+
import org.freedesktop.gstreamer.lowlevel.GValueAPI.GValueArray;
26+
import org.freedesktop.gstreamer.lowlevel.GstAPI.GstCallback;
27+
28+
/**
29+
* Utility {@link org.gstreamer.Element} to automatically identify media stream types and hook
30+
* up elements.
31+
*/
32+
public class DecodeBin extends Bin {
33+
public static final String GST_NAME = "decodebin";
34+
public static final String GTYPE_NAME = "GstDecodeBin";
35+
36+
/**
37+
* Creates a new DecodeBin.
38+
*
39+
* @param name The name used to identify this DecodeBin.
40+
*/
41+
public DecodeBin(String name) {
42+
super(makeRawElement(GST_NAME, name));
43+
}
44+
45+
public DecodeBin(Initializer init) {
46+
super(init);
47+
}
48+
49+
/**
50+
* Signal is emitted when a pad for which there is no further possible decoding is added to the {@link DecodeBin}.
51+
*/
52+
public static interface UNKNOWN_TYPE {
53+
/**
54+
* @param element The element which has the new Pad.
55+
* @param pad the new Pad.
56+
* @param caps the caps of the pad that cannot be resolved.
57+
*/
58+
public void unknownType(DecodeBin element, Pad pad, Caps caps);
59+
}
60+
/**
61+
* Adds a listener for the <code>unknown-type</code> signal
62+
*
63+
* @param listener Listener to be called when a new {@link Pad} is encountered
64+
* on the {@link Element}
65+
*/
66+
public void connect(final UNKNOWN_TYPE listener) {
67+
connect(UNKNOWN_TYPE.class, listener, new GstCallback() {
68+
@SuppressWarnings("unused")
69+
public void callback(DecodeBin elem, Pad pad, Caps caps) {
70+
listener.unknownType(elem, pad, caps);
71+
}
72+
});
73+
}
74+
/**
75+
* Removes a listener for the <code>unknown-type</code> signal
76+
*
77+
* @param listener The listener that was previously added.
78+
*/
79+
public void disconnect(UNKNOWN_TYPE listener) {
80+
disconnect(UNKNOWN_TYPE.class, listener);
81+
}
82+
83+
/**
84+
* Signal is emitted when a pad for which there is no further possible decoding is added to the {@link DecodeBin}.
85+
*/
86+
public static interface AUTOPLUG_CONTINUE {
87+
/**
88+
* @param element The element which has the new Pad.
89+
* @param pad the new Pad.
90+
* @param caps the caps of the pad that cannot be resolved.
91+
*/
92+
public boolean autoplugContinue(DecodeBin element, Pad pad, Caps caps);
93+
}
94+
/**
95+
* Adds a listener for the <code>autoplug-continue</code> signal
96+
*
97+
* @param listener Listener to be called when a new {@link Pad} is encountered
98+
* on the {@link Element}
99+
*/
100+
public void connect(final AUTOPLUG_CONTINUE listener) {
101+
connect(AUTOPLUG_CONTINUE.class, listener, new GstCallback() {
102+
@SuppressWarnings("unused")
103+
public boolean callback(DecodeBin elem, Pad pad, Caps caps) {
104+
return listener.autoplugContinue(elem, pad, caps);
105+
}
106+
});
107+
}
108+
/**
109+
* Removes a listener for the <code>autoplug-continue</code> signal
110+
*
111+
* @param listener The listener that was previously added.
112+
*/
113+
public void disconnect(AUTOPLUG_CONTINUE listener) {
114+
disconnect(AUTOPLUG_CONTINUE.class, listener);
115+
}
116+
117+
/**
118+
* This function is emitted when an array of possible factories for caps on pad is needed.
119+
* {@link DecodeBin} will by default return an array with all compatible factories, sorted by rank.
120+
*
121+
* If this function returns NULL, pad will be exposed as a final caps.
122+
*
123+
* If this function returns an empty array, the pad will be considered as having an unhandled type media type.
124+
*/
125+
public static interface AUTOPLUG_FACTORIES {
126+
/**
127+
* @param element The element which has the new Pad.
128+
* @param pad the new Pad.
129+
* @param caps the caps of the pad that cannot be resolved.
130+
*/
131+
public GValueArray autoplugFactories(DecodeBin element, Pad pad, Caps caps);
132+
}
133+
/**
134+
* Adds a listener for the <code>autoplug-factories</code> signal
135+
*
136+
* @param listener Listener to be called when a new {@link Pad} is encountered
137+
* on the {@link Element}
138+
*/
139+
public void connect(final AUTOPLUG_FACTORIES listener) {
140+
connect(AUTOPLUG_FACTORIES.class, listener, new GstCallback() {
141+
@SuppressWarnings("unused")
142+
public GValueArray callback(DecodeBin elem, Pad pad, Caps caps) {
143+
return listener.autoplugFactories(elem, pad, caps);
144+
}
145+
});
146+
}
147+
/**
148+
* Removes a listener for the <code>autoplug-factories</code> signal
149+
*
150+
* @param listener The listener that was previously added.
151+
*/
152+
public void disconnect(AUTOPLUG_FACTORIES listener) {
153+
disconnect(AUTOPLUG_FACTORIES.class, listener);
154+
}
155+
156+
/**
157+
* Once {@link DecodeBin} has found the possible ElementFactory objects to
158+
* try for caps on pad, this signal is emitted. The purpose of the signal is
159+
* for the application to perform additional sorting or filtering on the
160+
* element factory array.
161+
*
162+
* The callee should copy and modify factories.
163+
*/
164+
public static interface AUTOPLUG_SORT {
165+
/**
166+
* @param element The element which has the new Pad.
167+
* @param pad the new Pad.
168+
* @param caps the caps of the pad that cannot be resolved.
169+
* @param factories A GValueArray of possible GstElementFactory to use.
170+
*/
171+
public GValueArray autoplugSort(DecodeBin element, Pad pad, Caps caps, GValueArray factories);
172+
}
173+
/**
174+
* Adds a listener for the <code>autoplug-sort</code> signal
175+
*
176+
* @param listener Listener to be called when a new {@link Pad} is encountered
177+
* on the {@link Element}
178+
*/
179+
public void connect(final AUTOPLUG_SORT listener) {
180+
connect(AUTOPLUG_SORT.class, listener, new GstCallback() {
181+
@SuppressWarnings("unused")
182+
public GValueArray callback(DecodeBin elem, Pad pad, Caps caps, GValueArray factories) {
183+
return listener.autoplugSort(elem, pad, caps, factories);
184+
}
185+
});
186+
}
187+
/**
188+
* Removes a listener for the <code>autoplug-sort</code> signal
189+
*
190+
* @param listener The listener that was previously added.
191+
*/
192+
public void disconnect(AUTOPLUG_SORT listener) {
193+
disconnect(AUTOPLUG_SORT.class, listener);
194+
}
195+
196+
/**
197+
* This signal is emitted once {@link DecodeBin} has finished decoding all the data.
198+
*/
199+
public static interface DRAINED {
200+
/**
201+
* @param element The element
202+
*/
203+
public GValueArray drained(DecodeBin element);
204+
}
205+
/**
206+
* Adds a listener for the <code>drained</code> signal
207+
*
208+
* @param listener Listener to be called when a new {@link Pad} is encountered
209+
* on the {@link Element}
210+
*/
211+
public void connect(final DRAINED listener) {
212+
connect(DRAINED.class, listener, new GstCallback() {
213+
@SuppressWarnings("unused")
214+
public GValueArray callback(DecodeBin elem) {
215+
return listener.drained(elem);
216+
}
217+
});
218+
}
219+
/**
220+
* Removes a listener for the <code>drained</code> signal
221+
*
222+
* @param listener The listener that was previously added.
223+
*/
224+
public void disconnect(DRAINED listener) {
225+
disconnect(DRAINED.class, listener);
226+
}
227+
}

0 commit comments

Comments
 (0)