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