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

Side by Side Diff: webrtc/examples/unityplugin/java/src/org/webrtc/UnityUtility.java

Issue 2993273002: Add Android Camera To Unity Plugin (Closed)
Patch Set: Presubmit Fix 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 package org.webrtc;
12
13 import android.content.Context;
14 import java.util.List;
15
16 public class UnityUtility {
17 private static final String VIDEO_CAPTURER_THREAD_NAME = "VideoCapturerThread" ;
18
19 public static SurfaceTextureHelper LoadSurfaceTextureHelper() {
20 final SurfaceTextureHelper surfaceTextureHelper =
21 SurfaceTextureHelper.create(VIDEO_CAPTURER_THREAD_NAME, null);
22 return surfaceTextureHelper;
23 }
24
25 private static boolean useCamera2() {
26 return Camera2Enumerator.isSupported(ContextUtils.getApplicationContext());
27 }
28
29 private static VideoCapturer createCameraCapturer(CameraEnumerator enumerator) {
30 final String[] deviceNames = enumerator.getDeviceNames();
31
32 for (String deviceName : deviceNames) {
33 if (enumerator.isFrontFacing(deviceName)) {
34 VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null );
35
36 if (videoCapturer != null) {
37 return videoCapturer;
38 }
39 }
40 }
41
42 return null;
43 }
44
45 public static VideoCapturer LinkCamera(
46 long nativeTrackSource, SurfaceTextureHelper surfaceTextureHelper) {
47 VideoCapturer capturer =
48 createCameraCapturer(new Camera2Enumerator(ContextUtils.getApplicationCo ntext()));
49
50 VideoCapturer.CapturerObserver capturerObserver =
51 new AndroidVideoTrackSourceObserver(nativeTrackSource);
52
53 capturer.initialize(
54 surfaceTextureHelper, ContextUtils.getApplicationContext(), capturerObse rver);
55
56 capturer.startCapture(720, 480, 30);
57 return capturer;
58 }
59
60 public static void StopCamera(VideoCapturer camera) throws InterruptedExceptio n {
61 camera.stopCapture();
62 camera.dispose();
63 }
64 }
OLDNEW
« no previous file with comments | « webrtc/examples/unityplugin/classreferenceholder.cc ('k') | webrtc/examples/unityplugin/jni_onload.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698