• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CJ_AVTRANSCODER_CALLBACK_H
17 #define CJ_AVTRANSCODER_CALLBACK_H
18 
19 #include "transcoder.h"
20 #include "av_common.h"
21 #include "media_errors.h"
22 #include "media_log.h"
23 #include "cj_avtranscoder.h"
24 #include <shared_mutex>
25 #include <mutex>
26 
27 namespace OHOS {
28 namespace Media {
29 class CJAVTranscoderCallback : public TransCoderCallback {
30 public:
31     explicit CJAVTranscoderCallback();
32     virtual ~CJAVTranscoderCallback();
33 
34     void SaveCallbackReference(CJAVTranscoderEvent event, int64_t callbackId);
35     void CancelCallbackReference(CJAVTranscoderEvent event);
36     void ClearCallbackReference();
37     void SendErrorCallback(int32_t errCode, const std::string &msg);
38     void SendStateCallback(CjAVTransCoderState state, const StateChangeReason &reason);
39     void SendCompleteCallback();
40     void SendProgressUpdateCallback(int32_t progress);
41     CjAVTransCoderState GetState();
42 
43 protected:
44     void OnError(int32_t errCode, const std::string &errorMsg) override;
45     void OnInfo(int32_t type, int32_t extra) override;
46 
47 private:
48     std::mutex mutex_;
49     CjAVTransCoderState currentState_ = CjAVTransCoderState::STATE_IDLE;
50     std::function<void(int32_t)> onprogressfunc;
51     std::function<void(int32_t, const char*)> onerrorfunc;
52     std::function<void(void)> oncompletefunc;
53 };
54 }
55 }
56 #endif