Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 1 addition & 7 deletions dConnectDevicePlugin/dConnectDeviceHost/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,7 @@ dependencies {
implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.8.2'
implementation project(':dconnect-demo-lib')
implementation project(':libstreaming')
implementation('com.serenegiant:common:2.12.5') {
exclude module: 'support-v4'
//exclude module: 'recyclerview-v7'
exclude module: 'support-fragment'
exclude module: 'support-core-ui'
exclude module: 'appcompat-v7'
}
implementation 'com.serenegiant:common:2.12.5'
}

task zipDemo(type:Zip) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Camera2RTSPPreviewServer extends AbstractRTSPPreviewServer implements Rtsp

static final String MIME_TYPE = "video/x-rtp";

private static final String SERVER_NAME = "Android Host Screen RTSP Server";
private static final String SERVER_NAME = "Android Host Camera2 RTSP Server";

private final Object mLockObj = new Object();

Expand All @@ -62,7 +62,7 @@ class Camera2RTSPPreviewServer extends AbstractRTSPPreviewServer implements Rtsp
private final Object mSync = new Object();
private volatile boolean mIsRecording;
private boolean requestDraw;
private DrawTask mScreenCaptureTask;
private DrawTask mCameraCaptureTask;
private AACStream mAac;

Camera2RTSPPreviewServer(final Context context,
Expand Down Expand Up @@ -108,7 +108,7 @@ public void startWebServer(final OnWebServerStartCallback callback) {
}
}
if (mHandler == null) {
HandlerThread thread = new HandlerThread("ScreenCastRTSPPreviewServer");
HandlerThread thread = new HandlerThread("Camera2RTSPPreviewServer");
thread.start();
mHandler = new Handler(thread.getLooper());
}
Expand Down Expand Up @@ -159,7 +159,7 @@ public void onDisplayRotation(final int rotation) {
if (DEBUG) {
Log.d(TAG, "onDisplayRotation: rotation=" + rotation);
}
DrawTask drawTask = mScreenCaptureTask;
DrawTask drawTask = mCameraCaptureTask;
synchronized (mLockObj) {
if (drawTask != null) {
drawTask.onDisplayRotationChange(rotation);
Expand Down Expand Up @@ -209,9 +209,9 @@ private Session startPreviewStreaming(final Socket clientSocket) throws IOExcept
synchronized (mLockObj) {
mClientSocket = clientSocket;
mVideoStream = new SurfaceH264Stream(prefs, videoQuality);
mScreenCaptureTask = new DrawTask(null, 0, videoQuality);
mCameraCaptureTask = new DrawTask(null, 0, videoQuality);
mIsRecording = true;
new Thread(mScreenCaptureTask, "ScreenCaptureThread").start();
new Thread(mCameraCaptureTask, "CameraCaptureThread").start();
}

SessionBuilder builder = new SessionBuilder();
Expand Down Expand Up @@ -335,7 +335,7 @@ protected void onStop() {

@Override
protected boolean onError(final Exception e) {
Log.w(TAG, "mScreenCaptureTask:", e);
Log.w(TAG, "mCameraCaptureTask:", e);
return false;
}

Expand All @@ -354,43 +354,46 @@ protected Object processRequest(final int request, final int arg1, final int arg
}
};

private final Runnable mDrawTask = () -> {
boolean localRequestDraw;
synchronized (mSync) {
localRequestDraw = requestDraw;
if (!requestDraw) {
try {
mSync.wait(intervals);
localRequestDraw = requestDraw;
requestDraw = false;
} catch (final InterruptedException e) {
if (DEBUG) {
Log.v(TAG, "draw:InterruptedException");
private final Runnable mDrawTask = new Runnable() {
@Override
public void run() {
boolean localRequestDraw;
synchronized (mSync) {
localRequestDraw = requestDraw;
if (!requestDraw) {
try {
mSync.wait(intervals);
localRequestDraw = requestDraw;
requestDraw = false;
} catch (final InterruptedException e) {
if (DEBUG) {
Log.v(TAG, "draw:InterruptedException");
}
return;
}
return;
}
}
}
if (mIsRecording) {
synchronized (mDrawSync) {
if (localRequestDraw) {
mSourceTexture.updateTexImage();
mSourceTexture.getTransformMatrix(mTexMatrix);
Matrix.rotateM(mTexMatrix, 0, mRotationDegree, 0, 0, 1);
Matrix.translateM(mTexMatrix, 0, mDeltaX, mDeltaY, 0);
if (mIsRecording) {
synchronized (mDrawSync) {
if (localRequestDraw) {
mSourceTexture.updateTexImage();
mSourceTexture.getTransformMatrix(mTexMatrix);
Matrix.rotateM(mTexMatrix, 0, mRotationDegree, 0, 0, 1);
Matrix.translateM(mTexMatrix, 0, mDeltaX, mDeltaY, 0);
}
// SurfaceTextureで受け取った画像をMediaCodecの入力用Surfaceへ描画する
mEncoderSurface.makeCurrent();
mDrawer.draw(mTexId, mTexMatrix, 0);
mEncoderSurface.swap();
// EGL保持用のオフスクリーンに描画しないとハングアップする機種の為のworkaround
makeCurrent();
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glFlush();
queueEvent(this);
}
// SurfaceTextureで受け取った画像をMediaCodecの入力用Surfaceへ描画する
mEncoderSurface.makeCurrent();
mDrawer.draw(mTexId, mTexMatrix, 0);
mEncoderSurface.swap();
// EGL保持用のオフスクリーンに描画しないとハングアップする機種の為のworkaround
makeCurrent();
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glFlush();
queueEvent(this);
} else {
releaseSelf();
}
} else {
releaseSelf();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,39 +306,42 @@ protected Object processRequest(final int request, final int arg1, final int arg
}
};

private final Runnable mDrawTask = () -> {
boolean localRequestDraw;
synchronized (mSync) {
localRequestDraw = requestDraw;
if (!requestDraw) {
try {
mSync.wait(intervals);
localRequestDraw = requestDraw;
requestDraw = false;
} catch (final InterruptedException e) {
if (DEBUG) {
Log.v(TAG, "draw:InterruptedException");
private final Runnable mDrawTask = new Runnable() {
@Override
public void run() {
boolean localRequestDraw;
synchronized (mSync) {
localRequestDraw = requestDraw;
if (!requestDraw) {
try {
mSync.wait(intervals);
localRequestDraw = requestDraw;
requestDraw = false;
} catch (final InterruptedException e) {
if (DEBUG) {
Log.v(TAG, "draw:InterruptedException");
}
return;
}
return;
}
}
}
if (mIsRecording) {
if (localRequestDraw) {
mSourceTexture.updateTexImage();
mSourceTexture.getTransformMatrix(mTexMatrix);
if (mIsRecording) {
if (localRequestDraw) {
mSourceTexture.updateTexImage();
mSourceTexture.getTransformMatrix(mTexMatrix);
}
// SurfaceTextureで受け取った画像をMediaCodecの入力用Surfaceへ描画する
mEncoderSurface.makeCurrent();
mDrawer.draw(mTexId, mTexMatrix, 0);
mEncoderSurface.swap();
// EGL保持用のオフスクリーンに描画しないとハングアップする機種の為のworkaround
makeCurrent();
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glFlush();
queueEvent(this);
} else {
releaseSelf();
}
// SurfaceTextureで受け取った画像をMediaCodecの入力用Surfaceへ描画する
mEncoderSurface.makeCurrent();
mDrawer.draw(mTexId, mTexMatrix, 0);
mEncoderSurface.swap();
// EGL保持用のオフスクリーンに描画しないとハングアップする機種の為のworkaround
makeCurrent();
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glFlush();
queueEvent(this);
} else {
releaseSelf();
}
};

Expand Down