blob: baf1e96b6bdc27b3b877779b963b16076187c5df [file] [log] [blame]
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +02001/*
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
11package org.webrtc;
12
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020013import android.annotation.TargetApi;
14import android.content.Context;
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020015import android.hardware.camera2.CameraManager;
Artem Titarenko69540f42018-12-10 12:30:46 +010016import android.support.annotation.Nullable;
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020017
18@TargetApi(21)
sakald30e0ad2016-08-11 01:00:37 -070019public class Camera2Capturer extends CameraCapturer {
20 private final Context context;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010021 @Nullable private final CameraManager cameraManager;
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020022
sakald30e0ad2016-08-11 01:00:37 -070023 public Camera2Capturer(Context context, String cameraName, CameraEventsHandler eventsHandler) {
24 super(cameraName, eventsHandler, new Camera2Enumerator(context));
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020025
sakald30e0ad2016-08-11 01:00:37 -070026 this.context = context;
27 cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020028 }
29
30 @Override
sakalb6760f92016-09-29 04:12:44 -070031 protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback,
32 CameraSession.Events events, Context applicationContext,
Magnus Jedvert5ebb82b2018-04-12 16:23:34 +020033 SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height,
34 int framerate) {
sakalb6760f92016-09-29 04:12:44 -070035 Camera2Session.create(createSessionCallback, events, applicationContext, cameraManager,
Magnus Jedvert5ebb82b2018-04-12 16:23:34 +020036 surfaceTextureHelper, cameraName, width, height, framerate);
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020037 }
38}