|
1 | 1 | /* |
2 | 2 | * |
3 | | - * Copyright (c) 2017 Neil C Smith |
| 3 | + * Copyright (c) 2019 Neil C Smith |
4 | 4 | * Copyright (c) 2015 Andres Colubri <[email protected]> |
5 | 5 | * Copyright (C) 2013 Olivier Crete <[email protected]> |
6 | 6 | * |
|
30 | 30 | import static org.freedesktop.gstreamer.lowlevel.GstDeviceAPI.GSTDEVICE_API; |
31 | 31 |
|
32 | 32 | /** |
33 | | - * |
34 | | - * @author andres |
| 33 | + * Devices are objects representing a device, they contain relevant metadata |
| 34 | + * about the device, such as its class and the GstCaps representing the media |
| 35 | + * types it can produce or handle. |
| 36 | + * <p> |
| 37 | + * See upstream documentation at |
| 38 | + * <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/gstreamer-GstDevice.html" |
| 39 | + * >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/gstreamer-GstDevice.html</a> |
| 40 | + * <p> |
| 41 | + * Device objects are created by {@link DeviceProvider} objects, which can be |
| 42 | + * aggregated by {@link DeviceMonitor} objects. |
35 | 43 | */ |
36 | 44 | public class Device extends GstObject { |
37 | 45 |
|
38 | 46 | public static final String GTYPE_NAME = "GstDevice"; |
39 | 47 |
|
40 | | - public Device(Initializer init) { |
| 48 | + Device(Initializer init) { |
41 | 49 | super(init); |
42 | 50 | } |
43 | 51 |
|
| 52 | + /** |
| 53 | + * Creates the element with all of the required parameters set to use this |
| 54 | + * device. |
| 55 | + * |
| 56 | + * @param name name of new element, or NULL to automatically create a unique |
| 57 | + * name |
| 58 | + * @return a new {@link Element} configured to use this device. |
| 59 | + */ |
44 | 60 | public Element createElement(String name) { |
45 | 61 | return GSTDEVICE_API.gst_device_create_element(this, name); |
46 | 62 | } |
47 | 63 |
|
| 64 | + /** |
| 65 | + * Get the {@link Caps} that this device supports. |
| 66 | + * |
| 67 | + * @return The Caps supported by this device. |
| 68 | + */ |
48 | 69 | public Caps getCaps() { |
49 | 70 | return GSTDEVICE_API.gst_device_get_caps(this); |
50 | 71 | } |
51 | 72 |
|
| 73 | + /** |
| 74 | + * Gets the "class" of a device. This is a "/" separated list of classes |
| 75 | + * that represent this device. They are a subset of the classes of the |
| 76 | + * {@link DeviceProvider} that produced this device. |
| 77 | + * |
| 78 | + * @return class the device class |
| 79 | + */ |
52 | 80 | public String getDeviceClass() { |
53 | 81 | Pointer ptr = GSTDEVICE_API.gst_device_get_device_class(this); |
54 | 82 | String ret = ptr.getString(0); |
55 | 83 | GLIB_API.g_free(ptr); |
56 | 84 | return ret; |
57 | 85 | } |
58 | 86 |
|
| 87 | + /** |
| 88 | + * Gets the user-friendly name of the device. |
| 89 | + * |
| 90 | + * @return name of the device |
| 91 | + */ |
59 | 92 | public String getDisplayName() { |
60 | 93 | Pointer ptr = GSTDEVICE_API.gst_device_get_display_name(this); |
61 | 94 | String ret = ptr.getString(0); |
62 | 95 | GLIB_API.g_free(ptr); |
63 | 96 | return ret; |
64 | 97 | } |
65 | 98 |
|
| 99 | + /** |
| 100 | + * Check if device matches all of the given classes. |
| 101 | + * |
| 102 | + * @param classes a "/"-separated list of device classes to match, only |
| 103 | + * match if all classes are matched |
| 104 | + * @return true if device matches |
| 105 | + */ |
66 | 106 | public boolean hasClasses(String classes) { |
67 | 107 | return GSTDEVICE_API.gst_device_has_classes(this, classes); |
68 | 108 | } |
69 | 109 |
|
| 110 | + /** |
| 111 | + * Check if device matches all of the given classes. |
| 112 | + * |
| 113 | + * @param classes an array of classes to match, only match if all classes |
| 114 | + * are matched. |
| 115 | + * @return true if device matches |
| 116 | + */ |
70 | 117 | public boolean hasClasses(String[] classes) { |
71 | 118 | return GSTDEVICE_API.gst_device_has_classesv(this, classes); |
72 | 119 | } |
73 | 120 |
|
| 121 | + /** |
| 122 | + * Tries to reconfigure an existing element to use the device. If this |
| 123 | + * function fails, then one must destroy the element and create a new one |
| 124 | + * using {@link #createElement(java.lang.String) } |
| 125 | + * <p> |
| 126 | + * Note: This should only be implemented for elements can change their |
| 127 | + * device in the PLAYING state. |
| 128 | + * |
| 129 | + * @param element the element to be configured |
| 130 | + * @return true if the element could be reconfigured to use this device |
| 131 | + */ |
74 | 132 | public boolean reconfigureElement(Element element) { |
75 | 133 | return GSTDEVICE_API.gst_device_reconfigure_element(this, element); |
76 | 134 | } |
77 | 135 |
|
| 136 | + /** |
| 137 | + * Gets the extra properties of a device. |
| 138 | + * |
| 139 | + * @return The extra properties or NULL when there are none. |
| 140 | + */ |
78 | 141 | public Structure getProperties() { |
79 | 142 | return GSTDEVICE_API.gst_device_get_properties(this); |
80 | 143 | } |
|
0 commit comments