1 /* 2 * Copyright (C) 2025 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 MEDIA_MOVING_PHOTO_CALLBACK_H 17 #define MEDIA_MOVING_PHOTO_CALLBACK_H 18 19 #include <atomic> 20 21 #include "moving_photo_call_transcoder.h" 22 #include "napi/native_api.h" 23 #include "transcoder.h" 24 25 namespace OHOS { 26 namespace Media { 27 class MovingphotoTranscoderObserver : public TransCoderCallback { 28 public: 29 MovingphotoTranscoderObserver() = default; 30 ~MovingphotoTranscoderObserver() = default; 31 void SetMovingPhotoProgress(const std::shared_ptr<MovingPhotoProgressHandler> &movingPhotoProgressHandler); 32 void CallMovingProgressCallback(bool isComplete = false); 33 bool DoTranscodePrepareError(const std::string &errorMsg); setTransCoder(std::shared_ptr<TransCoder> transCoder)34 void setTransCoder(std::shared_ptr<TransCoder> transCoder) 35 { 36 transCoder_ = transCoder; 37 } 38 protected: 39 void OnError(int32_t errCode, const std::string &errorMsg) override; 40 void OnInfo(int32_t type, int32_t extra) override; 41 private: 42 std::shared_ptr<MovingPhotoProgressHandler> movingPhotoProgressHandler_ { nullptr }; 43 std::shared_ptr<TransCoder> transCoder_ { nullptr }; 44 std::atomic_bool isPrepareError { false }; 45 }; 46 } // namespace Media 47 } // namespace OHOS 48 #endif // MEDIA_MOVING_PHOTO_CALLBACK_H 49