Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: media/capture/video/android/java/src/org/chromium/media/VideoCaptureTango.java

Issue 2983473002: Android Tango depth camera capture support.
Patch Set: rename tango_api files to tango_client_api_glue Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/capture/video/android/java/src/org/chromium/media/VideoCaptureTango.java
diff --git a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureTango.java b/media/capture/video/android/java/src/org/chromium/media/VideoCaptureTango.java
new file mode 100644
index 0000000000000000000000000000000000000000..43f26d8bd8deafd870b19262a1ee81e0f2e39c6a
--- /dev/null
+++ b/media/capture/video/android/java/src/org/chromium/media/VideoCaptureTango.java
@@ -0,0 +1,77 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.media;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.IBinder;
+
+import org.chromium.base.ContextUtils;
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+
+/**
+ * This class used for establishing connection to Tango service. Most of the code implementing Tango
+ *capture is native, in VideoCaptureDevicetangoAndroid class.
+ **/
+@JNINamespace("media")
+public class VideoCaptureTango {
+ private static final String TAG = "cr.mediatango";
+
+ // Native callback context variable.
+ private final long mNativeVideoCaptureDeviceTangoAndroid;
+ private boolean mBound = false;
+
+ private ServiceConnection mTangoServiceConnection = new ServiceConnection() {
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mBound = true;
+ nativeOnTangoServiceConnected(mNativeVideoCaptureDeviceTangoAndroid, service);
+ }
+
+ public void onServiceDisconnected(ComponentName name) {
+ mBound = false;
+ }
+ };
+
+ private static final boolean bindTangoService(
+ final Context context, ServiceConnection connection) {
+ Intent intent = new Intent();
+ intent.setClassName("com.google.tango", "com.google.atap.tango.TangoService");
+
+ if (context.getPackageManager().resolveService(intent, 0) == null) return false;
+ return context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
+ }
+
+ VideoCaptureTango(long nativeVideoCaptureDeviceTangoAndroid) {
+ mNativeVideoCaptureDeviceTangoAndroid = nativeVideoCaptureDeviceTangoAndroid;
+ }
+
+ @CalledByNative
+ public boolean startCapture() {
+ final Context context = ContextUtils.getApplicationContext();
+ return bindTangoService(context, mTangoServiceConnection);
+ }
+
+ @CalledByNative
+ public void stopCapture() {
+ nativeTangoDisconnect(mNativeVideoCaptureDeviceTangoAndroid);
+ if (mBound) {
+ ContextUtils.getApplicationContext().unbindService(mTangoServiceConnection);
+ mBound = false;
+ }
+ }
+
+ // Factory method.
+ @CalledByNative
+ static VideoCaptureTango create(long nativeVideoCaptureDeviceTangoAndroid) {
+ return new VideoCaptureTango(nativeVideoCaptureDeviceTangoAndroid);
+ }
+
+ public native void nativeOnTangoServiceConnected(
+ long nativeVideoCaptureDeviceTangoAndroid, IBinder service);
+ public native void nativeTangoDisconnect(long nativeVideoCaptureDeviceTangoAndroid);
+}
« no previous file with comments | « media/capture/video/android/capture_jni_registrar.cc ('k') | media/capture/video/android/tango_client_api_glue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698