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_MEDIA_DATA_SOURCE_CALLBACK_H 17 #define CJ_MEDIA_DATA_SOURCE_CALLBACK_H 18 19 #include "media_data_source.h" 20 #include "cj_avplayer_utils.h" 21 #include "cj_common_ffi.h" 22 #include "nocopyable.h" 23 24 namespace OHOS { 25 namespace Media { 26 class CJMediaDataSourceCallback : public IMediaDataSource, public NoCopyable { 27 public: 28 explicit CJMediaDataSourceCallback(int64_t fileSize); 29 virtual ~CJMediaDataSourceCallback(); 30 int32_t ReadAt(const std::shared_ptr<AVSharedMemory> &mem, uint32_t length, int64_t pos = -1) override; 31 int32_t GetSize(int64_t &size) override; 32 int64_t GetCallbackId(); 33 void SetCallback(int64_t callbackId); 34 void ClearCallbackReference(); 35 36 // This interface has been deprecated 37 int32_t ReadAt(int64_t pos, uint32_t length, const std::shared_ptr<AVSharedMemory> &mem) override; 38 // This interface has been deprecated 39 int32_t ReadAt(uint32_t length, const std::shared_ptr<AVSharedMemory> &mem) override; 40 41 private: 42 int64_t size_ = -1; 43 std::function<int32_t(const CArrUI8 mem, uint32_t length, int64_t pos)> cb_ = nullptr; 44 int64_t callbackId_ = -1; 45 }; 46 } // namespace Media 47 } // namespace OHOS 48 #endif // MEDIA_DATA_SOURCE_CALLBACK_IMPL_H 49