1 /* 2 * Copyright (c) 2021 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 HOS_CAMERA_OFFLINE_STREAM_H 17 #define HOS_CAMERA_OFFLINE_STREAM_H 18 19 #include "camera.h" 20 #include "offline_stream_context.h" 21 #include "istream_operator_callback.h" 22 #include <condition_variable> 23 #include <mutex> 24 #include "capture_message.h" 25 26 namespace OHOS::Camera { 27 class OfflineStream { 28 public: 29 OfflineStream() = default; 30 virtual ~OfflineStream(); 31 OfflineStream(int32_t id, OHOS::sptr<IStreamOperatorCallback>& callback); 32 33 RetCode Init(std::shared_ptr<OfflineStreamContext>& context); 34 RetCode CancelCapture(int32_t captureId); 35 RetCode Release(); 36 bool CheckCaptureIdExist(int32_t captureId); 37 void ReceiveOfflineBuffer(std::shared_ptr<IBuffer>& buffer); 38 int32_t GetStreamId() const; 39 40 private: 41 RetCode ReturnBuffer(std::shared_ptr<IBuffer>& buffer); 42 void HandleMessage(MessageGroup& message); 43 void OnCaptureEnded(int32_t captureId, const std::vector<std::shared_ptr<CaptureEndedInfo>>& infos); 44 void OnCaptureError(int32_t captureId, const std::vector<std::shared_ptr<CaptureErrorInfo>>& infos); 45 46 private: 47 int32_t streamId_ = -1; 48 std::shared_ptr<OfflineStreamContext> context_ = {}; 49 OHOS::sptr<IStreamOperatorCallback> callback_ = nullptr; 50 std::mutex lock_; 51 std::shared_ptr<CaptureMessageOperator> messenger_ = nullptr; 52 }; 53 } // namespace OHOS::Camera 54 #endif 55