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_STD_STREAM_SOURCE_PLUGIN_H 16 #define HISTREAMER_STD_STREAM_SOURCE_PLUGIN_H 17 18 #ifndef OHOS_LITE 19 20 #include "avsharedmemorypool.h" 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 StdStreamSource { 28 class StdStreamSourcePlugin : public SourcePlugin { 29 public: 30 explicit StdStreamSourcePlugin(std::string name); 31 ~StdStreamSourcePlugin() override; 32 33 Status Init() override; 34 Status Deinit() override; 35 Status Prepare() override; 36 Status Reset() override; 37 Status Start() override; 38 Status Stop() override; 39 Status GetParameter(Tag tag, ValueType& value) override; 40 Status SetParameter(Tag tag, const ValueType& value) 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(uint64_t& size) override; 45 Seekable GetSeekable() override; 46 Status SeekTo(uint64_t offset) override; 47 private: 48 std::shared_ptr<Buffer> WrapAVSharedMemory(const std::shared_ptr<AVSharedMemory>& avSharedMemory, int32_t realLen); 49 void InitPool(); 50 std::shared_ptr<AVSharedMemory> GetMemory(); 51 void ResetPool(); 52 Seekable seekable_ {Seekable::INVALID}; 53 std::shared_ptr<IMediaDataSource> dataSrc_; 54 std::shared_ptr<AVSharedMemoryPool> pool_; 55 int64_t size_ {0}; 56 uint64_t offset_ {0}; 57 }; 58 } // namespace StdStreamSource 59 } // namespace Plugin 60 } // namespace Media 61 } // namespace OHOS 62 #endif 63 #endif // HISTREAMER_STD_STREAM_SOURCE_PLUGIN_H 64