Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions pjmedia/src/pjmedia-videodev/android/PjCamera2.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ public class PjCamera2
private int camIdx;
private final long userData;
private final int fps;
private final int w;
private final int h;
private final int fmt;

private final ImageReader imageReader;
private ImageReader imageReader;
private HandlerThread handlerThread = null;
private Handler handler;

Expand Down Expand Up @@ -151,16 +154,16 @@ public void surfaceDestroyed(SurfaceHolder holder)
}
};

public PjCamera2(int idx, int w, int h, int fmt, int fps_,
public PjCamera2(int idx, int w_, int h_, int fmt_, int fps_,
long userData_, SurfaceView surface)
{
camIdx = idx;
w = w_;
h = h_;
fmt = fmt_;
userData = userData_;
fps = fps_;
surfaceView = surface;

/* Some say to put a larger maxImages to improve FPS */
imageReader = ImageReader.newInstance(w, h, fmt, 3);
}

public int SwitchDevice(int idx)
Expand Down Expand Up @@ -246,6 +249,9 @@ public int Start()
handlerThread = new HandlerThread("Cam2HandlerThread");
handlerThread.start();
handler = new Handler(handlerThread.getLooper());

/* Some say to put a larger maxImages to improve FPS */
imageReader = ImageReader.newInstance(w, h, fmt, 3);
imageReader.setOnImageAvailableListener(imageAvailListener, handler);
isRunning = true;

Expand Down Expand Up @@ -296,6 +302,11 @@ public void Stop()
}
}

if (imageReader != null) {
imageReader.close();
imageReader = null;
}

/* Reset setting */
start_with_fps = true;

Expand Down