blob: 769a94a60c0b07611745fa19e0a17034c71c26ba [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 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 Kalliomaki8cf2a3a2016-06-29 13:27:37 +020021 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,
glaznev37adc5e2017-04-27 13:38:29 -070033 SurfaceTextureHelper surfaceTextureHelper, MediaRecorder mediaRecoder, String cameraName,
34 int width, int height, int framerate) {
sakalb6760f92016-09-29 04:12:44 -070035 Camera2Session.create(createSessionCallback, events, applicationContext, cameraManager,
glaznev37adc5e2017-04-27 13:38:29 -070036 surfaceTextureHelper, mediaRecoder, cameraName, width, height, framerate);
Sami Kalliomaki8cf2a3a2016-06-29 13:27:37 +020037 }
38}