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 16 #ifndef OHOS_CAMERA_VIDEO_OUTPUT_H 17 #define OHOS_CAMERA_VIDEO_OUTPUT_H 18 19 #include <iostream> 20 #include <vector> 21 #include "camera_metadata_info.h" 22 #include "output/capture_output.h" 23 #include "istream_repeat.h" 24 #include "istream_repeat_callback.h" 25 #include "session/capture_session.h" 26 27 namespace OHOS { 28 namespace CameraStandard { 29 class VideoStateCallback { 30 public: 31 VideoStateCallback() = default; 32 virtual ~VideoStateCallback() = default; 33 34 /** 35 * @brief Called when video frame is started rendering. 36 */ 37 virtual void OnFrameStarted() const = 0; 38 39 /** 40 * @brief Called when video frame is ended. 41 * 42 * @param frameCount Indicates number of frames captured. 43 */ 44 virtual void OnFrameEnded(const int32_t frameCount) const = 0; 45 46 /** 47 * @brief Called when error occured during video rendering. 48 * 49 * @param errorCode Indicates a {@link ErrorCode} which will give information for video callback error. 50 */ 51 virtual void OnError(const int32_t errorCode) const = 0; 52 }; 53 54 class VideoOutput : public CaptureOutput { 55 public: 56 explicit VideoOutput(sptr<IStreamRepeat> &streamRepeat); 57 virtual ~VideoOutput(); 58 59 /** 60 * @brief Releases a instance of the VideoOutput. 61 */ 62 int32_t Release() override; 63 64 /** 65 * @brief Set the video callback for the video output. 66 * 67 * @param VideoStateCallback pointer to be triggered. 68 */ 69 void SetCallback(std::shared_ptr<VideoStateCallback> callback); 70 71 /** 72 * @brief Start the video capture. 73 */ 74 int32_t Start(); 75 76 /** 77 * @brief Stop the video capture. 78 */ 79 int32_t Stop(); 80 81 /** 82 * @brief Pause the video capture. 83 */ 84 int32_t Pause(); 85 86 /** 87 * @brief Resume the paused video capture. 88 */ 89 int32_t Resume(); 90 91 /** 92 * @brief Get the application callback information. 93 * 94 * @return VideoStateCallback pointer set by application. 95 */ 96 std::shared_ptr<VideoStateCallback> GetApplicationCallback(); 97 98 /** 99 * @brief Get the supported video frame rate range. 100 * 101 * @return Returns vector<int32_t> of supported exposure compensation range. 102 */ 103 const std::vector<int32_t>& GetFrameRateRange(); 104 105 /** 106 * @brief Set the Video fps range. If fixed frame rate 107 * to be set the both min and max framerate should be same. 108 * 109 * @param min frame rate value of range. 110 * @param max frame rate value of range. 111 */ 112 void SetFrameRateRange(int32_t minFrameRate, int32_t maxFrameRate); 113 114 private: 115 std::shared_ptr<VideoStateCallback> appCallback_; 116 sptr<IStreamRepeatCallback> svcCallback_; 117 std::vector<int32_t> videoFrameRateRange_; 118 }; 119 } // namespace CameraStandard 120 } // namespace OHOS 121 #endif // OHOS_CAMERA_VIDEO_OUTPUT_H 122