1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef CAMERA_VIDEO_CAPTURE_H 16 #define CAMERA_VIDEO_CAPTURE_H 17 18 #include "test_common.h" 19 20 namespace OHOS { 21 namespace CameraStandard { 22 enum class State { 23 PHOTO_CAPTURE = 1, 24 VIDEO_RECORDING, 25 DOUBLE_PREVIEW 26 }; 27 28 class CameraCaptureVideo { 29 public: 30 static const int32_t GAP_AFTER_CAPTURE = 1; 31 static const int32_t VIDEO_CAPTURE_DURATION = 10; 32 static const int32_t PREVIEW_WIDTH = 640; 33 static const int32_t PREVIEW_HEIGHT = 480; 34 static const int32_t SECOND_PREVIEW_WIDTH = 832; 35 static const int32_t SECOND_PREVIEW_HEIGHT = 480; 36 static const int32_t PHOTO_WIDTH = 1280; 37 static const int32_t PHOTO_HEIGHT = 960; 38 static const int32_t VIDEO_WIDTH = 640; 39 static const int32_t VIDEO_HEIGHT = 360; 40 static const int32_t GAP_AFTER_STOP = 1; 41 std::vector<int32_t> videoframerates_; 42 const char* testName_ = "Camera_capture_video"; 43 State currentState_; 44 CameraCaptureVideo(); 45 virtual ~CameraCaptureVideo() = default; 46 int32_t InitCameraManager(); 47 int32_t InitCameraInput(); 48 int32_t InitPreviewOutput(); 49 int32_t InitSecondPreviewOutput(); 50 int32_t InitPhotoOutput(); 51 int32_t InitVideoOutput(); 52 int32_t StartPreview(); 53 int32_t TakePhoto(); 54 int32_t RecordVideo(); 55 void Release(); 56 57 private: 58 int32_t AddOutputbyState(); 59 int32_t InitCameraFormatAndResolution(sptr<CameraInput> &cameraInput); 60 int32_t previewWidth_; 61 int32_t previewHeight_; 62 int32_t previewWidth2_; 63 int32_t previewHeight2_; 64 int32_t photoWidth_; 65 int32_t photoHeight_; 66 int32_t videoWidth_; 67 int32_t videoHeight_; 68 int32_t previewFormat_; 69 int32_t photoFormat_; 70 int32_t videoFormat_; 71 int32_t fd_; 72 73 sptr<CameraManager> cameraManager_; 74 std::shared_ptr<TestCameraMngerCallback> cameraMngrCallback_; 75 76 sptr<CaptureSession> captureSession_; 77 78 sptr<CaptureInput> cameraInput_; 79 std::shared_ptr<TestDeviceCallback> cameraInputCallback_; 80 81 sptr<IConsumerSurface> previewSurface_; 82 sptr<SurfaceListener> previewSurfaceListener_; 83 sptr<CaptureOutput> previewOutput_; 84 std::shared_ptr<TestPreviewOutputCallback> previewOutputCallback_; 85 86 sptr<IConsumerSurface> photoSurface_; 87 sptr<SurfaceListener> photoSurfaceListener_; 88 sptr<CaptureOutput> photoOutput_; 89 std::shared_ptr<TestPhotoOutputCallback> photoOutputCallback_; 90 91 sptr<IConsumerSurface> videoSurface_; 92 sptr<SurfaceListener> videoSurfaceListener_; 93 sptr<CaptureOutput> videoOutput_; 94 std::shared_ptr<TestVideoOutputCallback> videoOutputCallback_; 95 96 sptr<IConsumerSurface> secondPreviewSurface_; 97 sptr<SurfaceListener> secondPreviewSurfaceListener_; 98 sptr<CaptureOutput> secondPreviewOutput_; 99 std::shared_ptr<TestPreviewOutputCallback> secondPreviewOutputCallback_; 100 }; 101 } // namespace CameraStandard 102 } // namespace OHOS 103 #endif // CAMERA_VIDEO_CAPTURE_H 104