blob: 423c6216829262e71957cc16d85456db457c9ba8 [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;
glaznev37adc5e2017-04-27 13:38:29 -070016import android.media.MediaRecorder;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010017import javax.annotation.Nullable;
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020018
19@TargetApi(21)
sakald30e0ad2016-08-11 01:00:37 -070020public class Camera2Capturer extends CameraCapturer {
21 private final Context context;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010022 @Nullable private final CameraManager cameraManager;
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020023
sakald30e0ad2016-08-11 01:00:37 -070024 public Camera2Capturer(Context context, String cameraName, CameraEventsHandler eventsHandler) {
25 super(cameraName, eventsHandler, new Camera2Enumerator(context));
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020026
sakald30e0ad2016-08-11 01:00:37 -070027 this.context = context;
28 cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020029 }
30
31 @Override
sakalb6760f92016-09-29 04:12:44 -070032 protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback,
33 CameraSession.Events events, Context applicationContext,
glaznev37adc5e2017-04-27 13:38:29 -070034 SurfaceTextureHelper surfaceTextureHelper, MediaRecorder mediaRecoder, String cameraName,
35 int width, int height, int framerate) {
sakalb6760f92016-09-29 04:12:44 -070036 Camera2Session.create(createSessionCallback, events, applicationContext, cameraManager,
glaznev37adc5e2017-04-27 13:38:29 -070037 surfaceTextureHelper, mediaRecoder, cameraName, width, height, framerate);
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020038 }
39}