1 /* 2 * Copyright (c) 2022-2022 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_HTTP_SOURCE_PLUGIN_H 16 #define HISTREAMER_HTTP_SOURCE_PLUGIN_H 17 18 #include "foundation/osal/thread/scoped_lock.h" 19 #include "plugin/common/plugin_types.h" 20 #include "plugin/interface/source_plugin.h" 21 #include "streaming_executor.h" 22 23 namespace OHOS { 24 namespace Media { 25 namespace Plugin { 26 namespace HttpPlugin { 27 class HttpSourcePlugin : public SourcePlugin { 28 public: 29 explicit HttpSourcePlugin(std::string name) noexcept; 30 ~HttpSourcePlugin() override; 31 Status Init() override; 32 Status Deinit() override; 33 Status Prepare() override; 34 Status Reset() override; 35 Status Start() override; 36 Status Stop() override; 37 bool IsParameterSupported(Tag tag) override; 38 Status GetParameter(Tag tag, ValueType &value) override; 39 Status SetParameter(Tag tag, const ValueType &value) override; 40 std::shared_ptr<Allocator> GetAllocator() override; 41 Status SetCallback(Callback* cb) override; 42 Status SetSource(std::shared_ptr<MediaSource> source) override; 43 Status Read(std::shared_ptr<Buffer> &buffer, size_t expectedLen) override; 44 Status GetSize(size_t &size) override; 45 bool IsSeekable() override; 46 Status SeekTo(uint64_t offset) override; 47 48 private: 49 void CloseUri(); 50 51 bool isSeekable_; 52 uint32_t bufferSize_; 53 uint32_t waterline_; 54 size_t fileSize_; 55 Callback* callback_ {}; 56 std::shared_ptr<StreamingExecutor> executor_; 57 }; 58 } // namespace HttpPluginLite 59 } // namespace Plugin 60 } // namespace Media 61 } // namespace OHOS 62 #endif