blob: c4becf4819d5a0e9bb08e45b57180d66f20fcf9a [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.content.Context;
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020014import android.hardware.camera2.CameraManager;
Byoungchan Lee02334e02021-08-14 11:41:59 +090015import androidx.annotation.Nullable;
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020016
sakald30e0ad2016-08-11 01:00:37 -070017public class Camera2Capturer extends CameraCapturer {
18 private final Context context;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010019 @Nullable private final CameraManager cameraManager;
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020020
sakald30e0ad2016-08-11 01:00:37 -070021 public Camera2Capturer(Context context, String cameraName, CameraEventsHandler eventsHandler) {
22 super(cameraName, eventsHandler, new Camera2Enumerator(context));
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020023
sakald30e0ad2016-08-11 01:00:37 -070024 this.context = context;
25 cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020026 }
27
28 @Override
sakalb6760f92016-09-29 04:12:44 -070029 protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback,
30 CameraSession.Events events, Context applicationContext,
Magnus Jedvert5ebb82b2018-04-12 16:23:34 +020031 SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height,
32 int framerate) {
sakalb6760f92016-09-29 04:12:44 -070033 Camera2Session.create(createSessionCallback, events, applicationContext, cameraManager,
Magnus Jedvert5ebb82b2018-04-12 16:23:34 +020034 surfaceTextureHelper, cameraName, width, height, framerate);
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020035 }
36}