1 /* 2 * Copyright 2016 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 android.hardware.camera2.CameraManager; 15 import androidx.annotation.Nullable; 16 17 public class Camera2Capturer extends CameraCapturer { 18 private final Context context; 19 @Nullable private final CameraManager cameraManager; 20 Camera2Capturer(Context context, String cameraName, CameraEventsHandler eventsHandler)21 public Camera2Capturer(Context context, String cameraName, CameraEventsHandler eventsHandler) { 22 super(cameraName, eventsHandler, new Camera2Enumerator(context)); 23 24 this.context = context; 25 cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); 26 } 27 28 @Override createCameraSession(CameraSession.CreateSessionCallback createSessionCallback, CameraSession.Events events, Context applicationContext, SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height, int framerate)29 protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback, 30 CameraSession.Events events, Context applicationContext, 31 SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height, 32 int framerate) { 33 Camera2Session.create(createSessionCallback, events, applicationContext, cameraManager, 34 surfaceTextureHelper, cameraName, width, height, framerate); 35 } 36 } 37