1 /*
2  * Copyright (c) 2023-2023 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 #ifndef HISTREAMER_MEDIA_DATA_SOURCE_IMPL_H
16 #define HISTREAMER_MEDIA_DATA_SOURCE_IMPL_H
17 
18 #include "common/media_data_source.h"
19 #include "plugin/common/plugin_types.h"
20 
21 namespace OHOS {
22 namespace Media {
23 class IMediaDataSourceImpl : public IMediaDataSource {
24 public:
25     IMediaDataSourceImpl(std::string url, Plugin::Seekable seekable);
26     int32_t ReadAt(int64_t pos, uint32_t length, const std::shared_ptr<AVSharedMemory> &mem) override;
27     int32_t ReadAt(uint32_t length, const std::shared_ptr<AVSharedMemory> &mem) override;
28     int32_t ReadAt(const std::shared_ptr<AVSharedMemory> &mem, uint32_t length, int64_t pos = -1) override;
29     int32_t GetSize(int64_t &size) override;
30 private:
31     int ReadDataFromFile();
32     uint32_t GetDataFromSource(const std::shared_ptr<AVSharedMemory> &mem, uint32_t length);
33 private:
34     std::string url_;
35     int32_t size_;
36     uint32_t readPos_;
37     std::vector<uint32_t> data_;
38     Plugin::Seekable seekable_;
39 };
40 }
41 }
42 
43 #endif //HISTREAMER_MEDIA_DATA_SOURCE_IMPL_H
44