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_FILE_FD_SOURCE_PLUGIN_H 17 #define HISTREAMER_FILE_FD_SOURCE_PLUGIN_H 18 19 #include <cstdio> 20 #include <string> 21 #include "plugin/common/plugin_types.h" 22 #include "plugin/interface/source_plugin.h" 23 24 namespace OHOS { 25 namespace Media { 26 namespace Plugin { 27 namespace FileFdSource { 28 class FileFdSourcePlugin : public SourcePlugin { 29 public: 30 explicit FileFdSourcePlugin(std::string name); 31 ~FileFdSourcePlugin() = default; 32 Status SetCallback(Callback* cb) override; 33 Status SetSource(std::shared_ptr<MediaSource> source) override; 34 Status Read(std::shared_ptr<Buffer>& buffer, size_t expectedLen) override; 35 Status GetSize(size_t& size) override; 36 Seekable GetSeekable() override; 37 Status SeekTo(uint64_t offset) override; 38 private: 39 Status ParseUriInfo(const std::string& uri); 40 41 int32_t fd_ {-1}; 42 int64_t offset_ {0}; 43 int64_t size_ {0}; 44 45 size_t fileSize_ {0}; 46 Seekable seekable_ {Seekable::SEEKABLE}; 47 uint64_t position_ {0}; 48 }; 49 } // namespace FileSource 50 } // namespace Plugin 51 } // namespace Media 52 } // namespace OHOS 53 54 #endif // HISTREAMER_FILE_FD_SOURCE_PLUGIN_H