Sami Kalliomaki | 8cf2a3a | 2016-06-29 13:27:37 +0200 | [diff] [blame] | 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 | |
Sami Kalliomaki | 8cf2a3a | 2016-06-29 13:27:37 +0200 | [diff] [blame] | 13 | import android.annotation.TargetApi; |
| 14 | import android.content.Context; |
Sami Kalliomaki | 8cf2a3a | 2016-06-29 13:27:37 +0200 | [diff] [blame] | 15 | import android.hardware.camera2.CameraManager; |
glaznev | 37adc5e | 2017-04-27 13:38:29 -0700 | [diff] [blame] | 16 | import android.media.MediaRecorder; |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 17 | import javax.annotation.Nullable; |
Sami Kalliomaki | 8cf2a3a | 2016-06-29 13:27:37 +0200 | [diff] [blame] | 18 | |
| 19 | @TargetApi(21) |
sakal | d30e0ad | 2016-08-11 01:00:37 -0700 | [diff] [blame] | 20 | public class Camera2Capturer extends CameraCapturer { |
| 21 | private final Context context; |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 22 | @Nullable private final CameraManager cameraManager; |
Sami Kalliomaki | 8cf2a3a | 2016-06-29 13:27:37 +0200 | [diff] [blame] | 23 | |
sakal | d30e0ad | 2016-08-11 01:00:37 -0700 | [diff] [blame] | 24 | public Camera2Capturer(Context context, String cameraName, CameraEventsHandler eventsHandler) { |
| 25 | super(cameraName, eventsHandler, new Camera2Enumerator(context)); |
Sami Kalliomaki | 8cf2a3a | 2016-06-29 13:27:37 +0200 | [diff] [blame] | 26 | |
sakal | d30e0ad | 2016-08-11 01:00:37 -0700 | [diff] [blame] | 27 | this.context = context; |
| 28 | cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); |
Sami Kalliomaki | 8cf2a3a | 2016-06-29 13:27:37 +0200 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | @Override |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 32 | protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback, |
| 33 | CameraSession.Events events, Context applicationContext, |
glaznev | 37adc5e | 2017-04-27 13:38:29 -0700 | [diff] [blame] | 34 | SurfaceTextureHelper surfaceTextureHelper, MediaRecorder mediaRecoder, String cameraName, |
| 35 | int width, int height, int framerate) { |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 36 | Camera2Session.create(createSessionCallback, events, applicationContext, cameraManager, |
glaznev | 37adc5e | 2017-04-27 13:38:29 -0700 | [diff] [blame] | 37 | surfaceTextureHelper, mediaRecoder, cameraName, width, height, framerate); |
Sami Kalliomaki | 8cf2a3a | 2016-06-29 13:27:37 +0200 | [diff] [blame] | 38 | } |
| 39 | } |