1 /*
2  * Copyright (c) 2021-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 HISTREAMER_PLUGIN_CORE_SOURCE_H
17 #define HISTREAMER_PLUGIN_CORE_SOURCE_H
18 
19 #include <cstddef>
20 #include <cstdint>
21 #include <memory>
22 
23 #include "plugin/common/media_source.h"
24 #include "plugin/common/plugin_types.h"
25 #include "plugin/core/base.h"
26 
27 namespace OHOS {
28 namespace Media {
29 namespace Plugin {
30 struct SourcePlugin;
31 
32 class Source : public Base {
33 public:
34     Source(const Source &) = delete;
35     Source operator=(const Source &) = delete;
36     ~Source() override = default;
37 
38     Status SetSource(std::shared_ptr<MediaSource> source);
39 
40     Status Read(std::shared_ptr<Buffer> &buffer, size_t expectedLen);
41 
42     Status GetSize(uint64_t& size);
43 
44     Seekable GetSeekable();
45 
46     Status SeekTo(uint64_t offset);
47 
48 private:
49     friend class PluginManager;
50 
51     Source(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr<SourcePlugin> plugin);
52 
53 private:
54     std::shared_ptr<SourcePlugin> source_;
55 };
56 } // namespace Plugin
57 } // namespace Media
58 } // namespace OHOS
59 #endif // HISTREAMER_PLUGIN_CORE_SOURCE_H
60