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