mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
video library updates
This commit is contained in:
@@ -26,10 +26,8 @@ PFont font;
|
||||
float fontSize = 1.5;
|
||||
|
||||
|
||||
public void setup() {
|
||||
size(640, 480, P3D);
|
||||
// Or run full screen, more fun! Use with Sketch -> Present
|
||||
//size(screen.width, screen.height, OPENGL);
|
||||
void setup() {
|
||||
size(640, 480, P2D);
|
||||
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
video = new Capture(this, 160, 120);
|
||||
@@ -59,7 +57,7 @@ public void setup() {
|
||||
}
|
||||
|
||||
|
||||
public void captureEvent(Capture c) {
|
||||
void captureEvent(Capture c) {
|
||||
c.read();
|
||||
}
|
||||
|
||||
@@ -76,6 +74,7 @@ void draw() {
|
||||
textFont(font, fontSize);
|
||||
|
||||
int index = 0;
|
||||
video.loadPixels();
|
||||
for (int y = 1; y < video.height; y++) {
|
||||
|
||||
// Move down for next line
|
||||
@@ -127,7 +126,7 @@ void draw() {
|
||||
* 'g' grabs an image and saves the frame to a tiff image
|
||||
* 'f' and 'F' increase and decrease the font size
|
||||
*/
|
||||
public void keyPressed() {
|
||||
void keyPressed() {
|
||||
switch (key) {
|
||||
case 'g': saveFrame(); break;
|
||||
case 'c': cheatScreen = !cheatScreen; break;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ Capture video;
|
||||
|
||||
void setup() {
|
||||
// Change size to 320 x 240 if too slow at 640 x 480
|
||||
size(640, 480);
|
||||
size(640, 480, P2D);
|
||||
|
||||
video = new Capture(this, width, height);
|
||||
video.start();
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ int numPixels;
|
||||
Capture video;
|
||||
|
||||
void setup() {
|
||||
size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
|
||||
size(640, 480, P2D); // Change size to 320 x 240 if too slow at 640 x 480
|
||||
strokeWeight(5);
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
video = new Capture(this, width, height);
|
||||
|
||||
@@ -11,7 +11,7 @@ import processing.video.*;
|
||||
Capture video;
|
||||
|
||||
void setup() {
|
||||
size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
|
||||
size(640, 480, P2D); // Change size to 320 x 240 if too slow at 640 x 480
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
video = new Capture(this, width, height);
|
||||
video.start();
|
||||
|
||||
@@ -20,8 +20,8 @@ int[] bright;
|
||||
int increment = 5;
|
||||
|
||||
|
||||
public void setup() {
|
||||
size(800, 600, P3D);
|
||||
void setup() {
|
||||
size(800, 600, P2D);
|
||||
|
||||
noCursor();
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
@@ -39,9 +39,10 @@ public void setup() {
|
||||
}
|
||||
|
||||
|
||||
public void draw() {
|
||||
void draw() {
|
||||
if (video.available()) {
|
||||
video.read();
|
||||
video.loadPixels();
|
||||
|
||||
background(0);
|
||||
noStroke();
|
||||
@@ -85,7 +86,7 @@ public void draw() {
|
||||
}
|
||||
|
||||
|
||||
public void keyPressed() {
|
||||
void keyPressed() {
|
||||
if (key == 'g') {
|
||||
saveFrame();
|
||||
} else if (key == 'c') {
|
||||
|
||||
@@ -3,26 +3,26 @@
|
||||
class Tuple {
|
||||
float x, y, z;
|
||||
|
||||
public Tuple() { }
|
||||
Tuple() { }
|
||||
|
||||
public Tuple(float x, float y, float z) {
|
||||
Tuple(float x, float y, float z) {
|
||||
set(x, y, z);
|
||||
}
|
||||
|
||||
public void set(float x, float y, float z) {
|
||||
void set(float x, float y, float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void target(Tuple another, float amount) {
|
||||
void target(Tuple another, float amount) {
|
||||
float amount1 = 1.0 - amount;
|
||||
x = x*amount1 + another.x*amount;
|
||||
y = y*amount1 + another.y*amount;
|
||||
z = z*amount1 + another.z*amount;
|
||||
}
|
||||
|
||||
public void phil() {
|
||||
void phil() {
|
||||
fill(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ int[] bright;
|
||||
int increment = 5;
|
||||
|
||||
|
||||
public void setup() {
|
||||
size(800, 600, P3D);
|
||||
void setup() {
|
||||
size(800, 600, P2D);
|
||||
|
||||
noCursor();
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
@@ -38,9 +38,10 @@ public void setup() {
|
||||
}
|
||||
|
||||
|
||||
public void draw() {
|
||||
void draw() {
|
||||
if (video.available()) {
|
||||
video.read();
|
||||
video.loadPixels();
|
||||
|
||||
background(0);
|
||||
noStroke();
|
||||
@@ -84,7 +85,7 @@ public void draw() {
|
||||
}
|
||||
|
||||
|
||||
public void keyPressed() {
|
||||
void keyPressed() {
|
||||
if (key == 'g') {
|
||||
saveFrame();
|
||||
} else if (key == 'c') {
|
||||
|
||||
@@ -3,26 +3,26 @@
|
||||
class Tuple {
|
||||
float x, y, z;
|
||||
|
||||
public Tuple() { }
|
||||
Tuple() { }
|
||||
|
||||
public Tuple(float x, float y, float z) {
|
||||
Tuple(float x, float y, float z) {
|
||||
set(x, y, z);
|
||||
}
|
||||
|
||||
public void set(float x, float y, float z) {
|
||||
void set(float x, float y, float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void target(Tuple another, float amount) {
|
||||
void target(Tuple another, float amount) {
|
||||
float amount1 = 1.0 - amount;
|
||||
x = x*amount1 + another.x*amount;
|
||||
y = y*amount1 + another.y*amount;
|
||||
z = z*amount1 + another.z*amount;
|
||||
}
|
||||
|
||||
public void phil() {
|
||||
void phil() {
|
||||
fill(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ int[] previousFrame;
|
||||
Capture video;
|
||||
|
||||
void setup() {
|
||||
size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
|
||||
size(640, 480, P2D); // Change size to 320 x 240 if too slow at 640 x 480
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
video = new Capture(this, width, height);
|
||||
video.start();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Currently broken with the P2D renderer.
|
||||
|
||||
/**
|
||||
* Framingham
|
||||
* by Ben Fry.
|
||||
@@ -18,7 +20,7 @@ int[] scoot;
|
||||
|
||||
|
||||
void setup() {
|
||||
size(640, 480, P3D);
|
||||
size(640, 480, P2D);
|
||||
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
video = new Capture(this, 160, 120);
|
||||
@@ -39,6 +41,7 @@ void draw() {
|
||||
// By using video.available, only the frame rate need be set inside setup()
|
||||
if (video.available()) {
|
||||
video.read();
|
||||
video.loadPixels();
|
||||
set(video.width*column, video.height*lastRow, video);
|
||||
column++;
|
||||
if (column == columnCount) {
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import processing.video.*;
|
||||
Capture cam;
|
||||
|
||||
void setup() {
|
||||
size(640, 480);
|
||||
size(640, 480, P2D);
|
||||
|
||||
String[] cameras = Capture.list();
|
||||
|
||||
|
||||
@@ -34,9 +34,8 @@ boolean motion;
|
||||
boolean blobby = false;
|
||||
|
||||
|
||||
public void setup() {
|
||||
void setup() {
|
||||
size(640, 480, P3D);
|
||||
//size(screen.width, screen.height, OPENGL);
|
||||
|
||||
video = new Capture(this, 160, 120);
|
||||
video.start();
|
||||
@@ -84,6 +83,7 @@ void draw() {
|
||||
}
|
||||
|
||||
noStroke();
|
||||
video.loadPixels();
|
||||
for (int i = 0; i < count; i++) {
|
||||
int pixelColor = video.pixels[i];
|
||||
int r = (pixelColor >> 16) & 0xff;
|
||||
@@ -133,7 +133,6 @@ void draw() {
|
||||
|
||||
void captureEvent(Capture c) {
|
||||
c.read();
|
||||
c.loadPixels();
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +199,7 @@ void wireCone(float radius, float height, int stepX, int stepY) {
|
||||
noFill();
|
||||
pushMatrix();
|
||||
translate(0, 0, height);
|
||||
ellipseMode(CENTER_RADIUS);
|
||||
ellipseMode(CENTER);
|
||||
ellipse(0, 0, radius, radius);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
@@ -3,30 +3,30 @@
|
||||
class Tuple {
|
||||
float x, y, z;
|
||||
|
||||
public Tuple() { }
|
||||
Tuple() { }
|
||||
|
||||
public Tuple(float x, float y, float z) {
|
||||
Tuple(float x, float y, float z) {
|
||||
set(x, y, z);
|
||||
}
|
||||
|
||||
public void set(float x, float y, float z) {
|
||||
void set(float x, float y, float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void target(Tuple another, float amount) {
|
||||
void target(Tuple another, float amount) {
|
||||
float amount1 = 1.0 - amount;
|
||||
x = x*amount1 + another.x*amount;
|
||||
y = y*amount1 + another.y*amount;
|
||||
z = z*amount1 + another.z*amount;
|
||||
}
|
||||
|
||||
public void phil() {
|
||||
void phil() {
|
||||
fill(x, y, z);
|
||||
}
|
||||
|
||||
public void tran() {
|
||||
void tran() {
|
||||
translate(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ int buffer[];
|
||||
|
||||
|
||||
void setup() {
|
||||
size(600, 400);
|
||||
size(600, 400, P2D);
|
||||
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
video = new Capture(this, 160, 120);
|
||||
|
||||
@@ -17,7 +17,7 @@ Capture video;
|
||||
|
||||
|
||||
void setup() {
|
||||
size(640, 480, P3D);
|
||||
size(640, 480, P2D);
|
||||
frameRate(30);
|
||||
cols = width / cellSize;
|
||||
rows = height / cellSize;
|
||||
|
||||
@@ -16,7 +16,7 @@ Capture video;
|
||||
|
||||
|
||||
void setup() {
|
||||
size(640, 480, P3D);
|
||||
size(640, 480, P2D);
|
||||
//set up columns and rows
|
||||
cols = width / cellSize;
|
||||
rows = height / cellSize;
|
||||
|
||||
@@ -19,7 +19,7 @@ int angles[];
|
||||
|
||||
void setup() {
|
||||
// size must be set to video.width*video.height*2 in both directions
|
||||
size(600, 600);
|
||||
size(600, 600, P2D);
|
||||
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
video = new Capture(this, 160, 120);
|
||||
|
||||
@@ -18,7 +18,7 @@ int videoSliceX;
|
||||
int drawPositionX;
|
||||
|
||||
void setup() {
|
||||
size(600, 240);
|
||||
size(600, 240, P2D);
|
||||
|
||||
// Uses the default video input, see the reference if this causes an error
|
||||
video = new Capture(this, 320, 240);
|
||||
|
||||
@@ -18,18 +18,18 @@ import processing.video.*;
|
||||
Movie myMovie;
|
||||
boolean speedSet = false;
|
||||
|
||||
public void setup() {
|
||||
void setup() {
|
||||
size(320, 240);
|
||||
background(0);
|
||||
myMovie = new Movie(this, "balloon.ogg");
|
||||
myMovie.play();
|
||||
}
|
||||
|
||||
public void movieEvent(Movie myMovie) {
|
||||
void movieEvent(Movie myMovie) {
|
||||
myMovie.read();
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
void draw() {
|
||||
if (myMovie.ready()) {
|
||||
if (!speedSet) {
|
||||
// Setting the speed should be done only once,
|
||||
|
||||
@@ -10,7 +10,7 @@ import processing.video.*;
|
||||
|
||||
Movie movie;
|
||||
|
||||
public void setup() {
|
||||
void setup() {
|
||||
size(320, 240);
|
||||
background(0);
|
||||
movie = new Movie(this, "balloon.ogg");
|
||||
@@ -20,11 +20,11 @@ public void setup() {
|
||||
textFont(font, 24);
|
||||
}
|
||||
|
||||
public void movieEvent(Movie movie) {
|
||||
void movieEvent(Movie movie) {
|
||||
movie.read();
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
void draw() {
|
||||
image(movie, 0, 0, width, height);
|
||||
|
||||
float newSpeed = map(mouseX, 0, width, 0.1, 2);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class Capture extends PImage implements PConstants {
|
||||
protected int reqHeight;
|
||||
|
||||
protected boolean useBufferSink = false;
|
||||
protected boolean useGLSink = true;
|
||||
// protected boolean useGLSink = true;
|
||||
protected Object bufferSink;
|
||||
protected Method sinkCopyMethod;
|
||||
protected Method sinkSetMethod;
|
||||
@@ -253,7 +253,7 @@ public class Capture extends PImage implements PConstants {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean newFrame() {
|
||||
public synchronized boolean newFrame() {
|
||||
boolean res = newFrame;
|
||||
newFrame = false;
|
||||
return res;
|
||||
@@ -338,9 +338,9 @@ public class Capture extends PImage implements PConstants {
|
||||
* @usage web_application
|
||||
*/
|
||||
public synchronized void read() {
|
||||
// We loadPixels() first to ensure that at least we always have a non-null
|
||||
// pixels array, even if without any valid image inside.
|
||||
loadPixels();
|
||||
// if (pixels == null) {
|
||||
// pixels = new int[width * height];
|
||||
// }
|
||||
|
||||
if (useBufferSink) { // The native buffer from gstreamer is copied to the buffer sink.
|
||||
if (natBuffer == null) {
|
||||
@@ -349,7 +349,7 @@ public class Capture extends PImage implements PConstants {
|
||||
|
||||
if (firstFrame) {
|
||||
super.init(bufWidth, bufHeight, ARGB);
|
||||
loadPixels();
|
||||
//loadPixels();
|
||||
firstFrame = false;
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ public class Capture extends PImage implements PConstants {
|
||||
|
||||
if (firstFrame) {
|
||||
super.init(bufWidth, bufHeight, RGB);
|
||||
loadPixels();
|
||||
//loadPixels();
|
||||
firstFrame = false;
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ public class Capture extends PImage implements PConstants {
|
||||
fpsStr = ", framerate=" + fps;
|
||||
}
|
||||
|
||||
if (bufferSink != null || (useGLSink && parent.g.isGL())) {
|
||||
if (bufferSink != null || (Video.useGLBufferSink && parent.g.isGL())) {
|
||||
useBufferSink = true;
|
||||
|
||||
if (bufferSink != null) {
|
||||
@@ -671,10 +671,9 @@ public class Capture extends PImage implements PConstants {
|
||||
public void rgbFrame(int w, int h, IntBuffer buffer) {
|
||||
invokeEvent(w, h, buffer);
|
||||
}
|
||||
});
|
||||
// Setting direct buffer passing in the video sink, so no new buffers are created
|
||||
// and disposed by the GC on each frame (thanks to Octavi Estape for pointing
|
||||
// out this one).
|
||||
});
|
||||
|
||||
// Setting direct buffer passing in the video sink.
|
||||
rgbSink.setPassDirectBuffer(Video.passDirectBuffer);
|
||||
|
||||
// No need for rgbSink.dispose(), because the addMany() doesn't increment the
|
||||
@@ -817,9 +816,9 @@ public class Capture extends PImage implements PConstants {
|
||||
* renderers.
|
||||
*
|
||||
*/
|
||||
public void noGL() {
|
||||
useGLSink = false;
|
||||
}
|
||||
// public void noGL() {
|
||||
// useGLSink = false;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Sets the object to use as destination for the frames read from the stream.
|
||||
@@ -844,6 +843,10 @@ public class Capture extends PImage implements PConstants {
|
||||
copyMask = mask;
|
||||
}
|
||||
|
||||
public boolean hasBufferSink() {
|
||||
return bufferSink != null;
|
||||
}
|
||||
|
||||
public synchronized void disposeBuffer(Object buf) {
|
||||
((Buffer)buf).dispose();
|
||||
}
|
||||
|
||||
@@ -39,23 +39,6 @@ class LibraryPath {
|
||||
int n0 = path.indexOf('/');
|
||||
|
||||
int n1 = -1;
|
||||
/*
|
||||
if (Platform.isWindows()) {
|
||||
n1 = path.indexOf("/lib/video.jar"); // location of video.jar in
|
||||
// exported apps.
|
||||
if (n1 == -1)
|
||||
n1 = path.indexOf("/video.jar"); // location of video.jar in
|
||||
// library folder.
|
||||
|
||||
// In Windows, path string starts with "jar file/C:/..."
|
||||
// so the substring up to the first / is removed.
|
||||
n0++;
|
||||
} else if (Platform.isMac()) {
|
||||
// In Mac, getting the index of video.jar is enough in the case of sketches running from the PDE
|
||||
// as well as exported applications.
|
||||
n1 = path.indexOf("video.jar");
|
||||
*/
|
||||
|
||||
|
||||
if (Platform.isLinux()) {
|
||||
return "";
|
||||
|
||||
@@ -80,7 +80,7 @@ public class Movie extends PImage implements PConstants {
|
||||
protected boolean seeking = false;
|
||||
|
||||
protected boolean useBufferSink = false;
|
||||
protected boolean useGLSink = true;
|
||||
// protected boolean useGLSink = true;
|
||||
protected Object bufferSink;
|
||||
protected Method sinkCopyMethod;
|
||||
protected Method sinkSetMethod;
|
||||
@@ -528,11 +528,7 @@ public class Movie extends PImage implements PConstants {
|
||||
// which is already playing since we are in read().
|
||||
fps = getSourceFrameRate();
|
||||
}
|
||||
|
||||
// We loadPixels() first to ensure that at least we always have a non-null
|
||||
// pixels array, even if without any valid image inside.
|
||||
loadPixels();
|
||||
|
||||
|
||||
if (useBufferSink) { // The native buffer from gstreamer is copied to the buffer sink.
|
||||
if (natBuffer == null) {
|
||||
return;
|
||||
@@ -540,7 +536,7 @@ public class Movie extends PImage implements PConstants {
|
||||
|
||||
if (firstFrame) {
|
||||
super.init(bufWidth, bufHeight, ARGB);
|
||||
loadPixels();
|
||||
//loadPixels();
|
||||
firstFrame = false;
|
||||
}
|
||||
|
||||
@@ -568,7 +564,8 @@ public class Movie extends PImage implements PConstants {
|
||||
}
|
||||
|
||||
if (firstFrame) {
|
||||
resize(bufWidth, bufHeight);
|
||||
//resize(bufWidth, bufHeight);
|
||||
super.init(bufWidth, bufHeight, RGB);
|
||||
firstFrame = false;
|
||||
}
|
||||
|
||||
@@ -726,7 +723,7 @@ public class Movie extends PImage implements PConstants {
|
||||
}
|
||||
|
||||
protected void initSink() {
|
||||
if (bufferSink != null || (useGLSink && parent.g.isGL())) {
|
||||
if (bufferSink != null || (Video.useGLBufferSink && parent.g.isGL())) {
|
||||
useBufferSink = true;
|
||||
|
||||
if (bufferSink != null) {
|
||||
@@ -758,9 +755,7 @@ public class Movie extends PImage implements PConstants {
|
||||
}
|
||||
});
|
||||
|
||||
// Setting direct buffer passing in the video sink, so no new buffers are created
|
||||
// and disposed by the GC on each frame (thanks to Octavi Estape for pointing
|
||||
// out this one).
|
||||
// Setting direct buffer passing in the video sink.
|
||||
rgbSink.setPassDirectBuffer(Video.passDirectBuffer);
|
||||
gplayer.setVideoSink(rgbSink);
|
||||
// The setVideoSink() method sets the videoSink as a property of the PlayBin,
|
||||
@@ -859,9 +854,9 @@ public class Movie extends PImage implements PConstants {
|
||||
* renderers.
|
||||
*
|
||||
*/
|
||||
public void noGL() {
|
||||
useGLSink = false;
|
||||
}
|
||||
// public void noGL() {
|
||||
// useGLSink = false;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Sets the object to use as destination for the frames read from the stream.
|
||||
@@ -885,6 +880,10 @@ public class Movie extends PImage implements PConstants {
|
||||
bufferSink = sink;
|
||||
copyMask = mask;
|
||||
}
|
||||
|
||||
public boolean hasBufferSink() {
|
||||
return bufferSink != null;
|
||||
}
|
||||
|
||||
public synchronized void disposeBuffer(Object buf) {
|
||||
((Buffer)buf).dispose();
|
||||
|
||||
@@ -37,48 +37,57 @@ import java.util.List;
|
||||
* this library.
|
||||
*/
|
||||
public class Video implements PConstants {
|
||||
protected static long INSTANCES_COUNT = 0;
|
||||
// Streams type constants.
|
||||
static public final int AUDIO = 0;
|
||||
static public final int VIDEO = 1;
|
||||
static public final int RAW = 2;
|
||||
|
||||
protected static String gstreamerBinPath = "";
|
||||
protected static String gstreamerPluginsPath = "";
|
||||
|
||||
protected static boolean defaultGLibContext = false;
|
||||
|
||||
// Priority is given to global install of GStreamer if this is set to true.
|
||||
public static boolean globalGStreamer = false;
|
||||
|
||||
// Direct buffer pass enabled by default.
|
||||
public static boolean passDirectBuffer = true;
|
||||
|
||||
public static String globalGStreamerPath;
|
||||
public static String globalPluginsFolder = "gstreamer-0.10";
|
||||
// Priority is given to the system install of GStreamer if this is set to true.
|
||||
public static boolean systemGStreamer = false;
|
||||
public static String systemGStreamerPath;
|
||||
public static String systemPluginsFolder = "gstreamer-0.10";
|
||||
// Default locations of the global install of gstreamer for each platform:
|
||||
static {
|
||||
if (PApplet.platform == MACOSX) {
|
||||
globalGStreamerPath = "/System/Library/Frameworks/GStreamer.framework/Versions/Current/lib";
|
||||
systemGStreamerPath = "/System/Library/Frameworks/GStreamer.framework/Versions/Current/lib";
|
||||
} else if (PApplet.platform == WINDOWS) {
|
||||
globalGStreamerPath = "";
|
||||
systemGStreamerPath = "";
|
||||
} else if (PApplet.platform == LINUX) {
|
||||
globalGStreamerPath = "/usr/lib";
|
||||
systemGStreamerPath = "/usr/lib";
|
||||
} else {}
|
||||
}
|
||||
|
||||
protected static int bitsJVM;
|
||||
static {
|
||||
bitsJVM = PApplet.parseInt(System.getProperty("sun.arch.data.model"));
|
||||
}
|
||||
|
||||
|
||||
// Default location of the local install of gstreamer. Suggested by Charles Bourasseau.
|
||||
// When it is left as empty string, GSVideo will attempt to use the path from GSLibraryPath.get(),
|
||||
// otherwise it will use it as the path to the folder where the libgstreamer.dylib and other
|
||||
// files are located.
|
||||
public static String localGStreamerPath = "";
|
||||
public static String localPluginsFolder = "plugins";
|
||||
|
||||
// Direct buffer pass enabled by default. With this mode enabled, no new buffers are created
|
||||
// and disposed by the GC in each frame (thanks to Octavi Estape for suggesting this improvement)
|
||||
// which should help performance in most situations.
|
||||
public static boolean passDirectBuffer = true;
|
||||
|
||||
// OpenGL texture used as buffer sink by default, when the renderer is GL-based. This
|
||||
// can improve performance significantly, since the video frames are automatically
|
||||
// copied into the texture without passing through the pixels arrays, as well as
|
||||
// having the color conversion into RGBA handled natively by gstreamer.
|
||||
public static boolean useGLBufferSink = false;
|
||||
|
||||
// Some constants to identify AUDIO, VIDEO and RAW streams.
|
||||
static public final int AUDIO = 0;
|
||||
static public final int VIDEO = 1;
|
||||
static public final int RAW = 2;
|
||||
// Path that the video library will use to load the gstreamer native libs from.
|
||||
// It is buit either from the system or local paths.
|
||||
protected static String gstreamerBinPath = "";
|
||||
protected static String gstreamerPluginsPath = "";
|
||||
|
||||
protected static boolean defaultGLibContext = false;
|
||||
|
||||
protected static long INSTANCES_COUNT = 0;
|
||||
|
||||
protected static int bitsJVM;
|
||||
static {
|
||||
bitsJVM = PApplet.parseInt(System.getProperty("sun.arch.data.model"));
|
||||
}
|
||||
|
||||
static public void init() {
|
||||
if (INSTANCES_COUNT == 0) {
|
||||
@@ -96,7 +105,7 @@ public class Video implements PConstants {
|
||||
static protected void initImpl() {
|
||||
if (PApplet.platform == LINUX) {
|
||||
// Linux only supports global gstreamer for now.
|
||||
globalGStreamer = true;
|
||||
systemGStreamer = true;
|
||||
setLinuxPath();
|
||||
} else if (PApplet.platform == WINDOWS) {
|
||||
setWindowsPath();
|
||||
@@ -108,18 +117,18 @@ public class Video implements PConstants {
|
||||
System.setProperty("jna.library.path", gstreamerBinPath);
|
||||
}
|
||||
|
||||
if ((PApplet.platform == LINUX) && !globalGStreamer) {
|
||||
if ((PApplet.platform == LINUX) && !systemGStreamer) {
|
||||
System.err.println("Loading local version of GStreamer not supported in Linux at this time.");
|
||||
}
|
||||
|
||||
if ((PApplet.platform == WINDOWS) && !globalGStreamer) {
|
||||
if ((PApplet.platform == WINDOWS) && !systemGStreamer) {
|
||||
LibraryLoader loader = LibraryLoader.getInstance();
|
||||
if (loader == null) {
|
||||
System.err.println("Cannot load local version of GStreamer libraries.");
|
||||
}
|
||||
}
|
||||
|
||||
if ((PApplet.platform == MACOSX) && !globalGStreamer) {
|
||||
if ((PApplet.platform == MACOSX) && !systemGStreamer) {
|
||||
// Nothing to do here, since the dylib mechanism in OSX doesn't require the
|
||||
// library loader.
|
||||
}
|
||||
@@ -151,11 +160,11 @@ public class Video implements PConstants {
|
||||
}
|
||||
|
||||
static protected void setLinuxPath() {
|
||||
if (globalGStreamer && lookForGlobalGStreamer()) {
|
||||
if (systemGStreamer && lookForGlobalGStreamer()) {
|
||||
gstreamerBinPath = "";
|
||||
gstreamerPluginsPath = "";
|
||||
} else {
|
||||
globalGStreamer = false;
|
||||
systemGStreamer = false;
|
||||
if (localGStreamerPath.equals("")) {
|
||||
LibraryPath libPath = new LibraryPath();
|
||||
String path = libPath.get();
|
||||
@@ -169,11 +178,11 @@ public class Video implements PConstants {
|
||||
}
|
||||
|
||||
static protected void setWindowsPath() {
|
||||
if (globalGStreamer && lookForGlobalGStreamer()) {
|
||||
if (systemGStreamer && lookForGlobalGStreamer()) {
|
||||
gstreamerBinPath = "";
|
||||
gstreamerPluginsPath = "";
|
||||
} else {
|
||||
globalGStreamer = false;
|
||||
systemGStreamer = false;
|
||||
if (localGStreamerPath.equals("")) {
|
||||
LibraryPath libPath = new LibraryPath();
|
||||
String path = libPath.get();
|
||||
@@ -187,11 +196,11 @@ public class Video implements PConstants {
|
||||
}
|
||||
|
||||
static protected void setMacOSXPath() {
|
||||
if (globalGStreamer && lookForGlobalGStreamer()) {
|
||||
gstreamerBinPath = globalGStreamerPath;
|
||||
gstreamerPluginsPath = globalGStreamerPath + "/" + globalPluginsFolder;
|
||||
if (systemGStreamer && lookForGlobalGStreamer()) {
|
||||
gstreamerBinPath = systemGStreamerPath;
|
||||
gstreamerPluginsPath = systemGStreamerPath + "/" + systemPluginsFolder;
|
||||
} else {
|
||||
globalGStreamer = false;
|
||||
systemGStreamer = false;
|
||||
if (localGStreamerPath.equals("")) {
|
||||
LibraryPath libPath = new LibraryPath();
|
||||
String path = libPath.get();
|
||||
@@ -210,8 +219,8 @@ public class Video implements PConstants {
|
||||
locPath = locPath.replace("/", System.getProperty("file.separator"));
|
||||
|
||||
String[] searchPaths = null;
|
||||
if (!globalGStreamerPath.equals("")) {
|
||||
searchPaths = new String[] {globalGStreamerPath};
|
||||
if (!systemGStreamerPath.equals("")) {
|
||||
searchPaths = new String[] {systemGStreamerPath};
|
||||
}
|
||||
|
||||
if (searchPaths == null) {
|
||||
@@ -223,7 +232,7 @@ public class Video implements PConstants {
|
||||
for (int i = 0; i < searchPaths.length; i++) {
|
||||
String path = searchPaths[i];
|
||||
if ((locPath.equals("") || path.indexOf(locPath) == -1) && libgstreamerPresent(path, "libgstreamer")) {
|
||||
globalGStreamerPath = path;
|
||||
systemGStreamerPath = path;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user