1
1
/*
2
2
* Copyright (c) 2019 Neil C Smith
3
3
* Copyright (c) 2007 Wayne Meissner
4
- *
5
- * This file is part of gstreamer-java.
6
4
*
7
5
* This code is free software: you can redistribute it and/or modify it under
8
6
* the terms of the GNU Lesser General Public License version 3 only, as
52
50
import org .freedesktop .gstreamer .Sample ;
53
51
54
52
/**
55
- *
53
+ * A Swing component for displaying video from a GStreamer pipeline.
56
54
*/
57
55
public class GstVideoComponent extends javax .swing .JComponent {
58
56
59
57
private final Lock bufferLock = new ReentrantLock ();
60
58
private final AppSink videosink ;
61
59
private final boolean useVolatile ;
62
-
60
+
63
61
private BufferedImage currentImage = null ;
64
62
private RenderComponent renderComponent = new RenderComponent ();
65
63
private boolean keepAspect = true ;
@@ -69,14 +67,15 @@ public class GstVideoComponent extends javax.swing.JComponent {
69
67
private volatile boolean updatePending = false ;
70
68
71
69
/**
72
- * Creates a new instance of GstVideoComponent
70
+ * Create a GstVideoComponent. A new AppSink element will be created that
71
+ * can be accessed using {@link #getElement()} and added to a pipeline.
73
72
*/
74
73
public GstVideoComponent () {
75
74
this (new AppSink ("GstVideoComponent" ));
76
75
}
77
76
78
77
/**
79
- * Creates a new instance of GstVideoComponent
78
+ * Create a GstVideoComponent wrapping the provided AppSink element.
80
79
*/
81
80
public GstVideoComponent (AppSink appsink ) {
82
81
this .videosink = appsink ;
@@ -182,10 +181,21 @@ public void actionPerformed(ActionEvent arg0) {
182
181
}
183
182
};
184
183
184
+ /**
185
+ * Get the wrapped AppSink element.
186
+ *
187
+ * @return sink element
188
+ */
185
189
public Element getElement () {
186
190
return videosink ;
187
191
}
188
192
193
+ /**
194
+ * Set whether to respect the aspect ratio of the video when scaling.
195
+ * Defaults to true.
196
+ *
197
+ * @param keepAspect respect aspect ratio
198
+ */
189
199
public void setKeepAspect (boolean keepAspect ) {
190
200
this .keepAspect = keepAspect ;
191
201
}
0 commit comments