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_PIPELINE_DATA_SPLITER_H 17 #define HISTREAMER_PIPELINE_DATA_SPLITER_H 18 19 #include <memory> 20 #include <utility> 21 #include "pipeline/core/error_code.h" 22 #include "pipeline/core/type_define.h" 23 24 namespace OHOS { 25 namespace Media { 26 namespace Pipeline { 27 class DataSpliter { 28 public: 29 DataSpliter() = default; SetNextFilter(std::shared_ptr<Filter> output)30 void SetNextFilter(std::shared_ptr<Filter> output) 31 { 32 nextFilter_ = std::move(output); 33 } 34 SetMuxerPlugin(std::shared_ptr<Plugin::Muxer> muxer)35 void SetMuxerPlugin(std::shared_ptr<Plugin::Muxer> muxer) 36 { 37 muxer_ = std::move(muxer); 38 } 39 FinishWithoutDrain()40 ErrorCode FinishWithoutDrain() 41 { 42 return ErrorCode::SUCCESS; 43 } 44 SetMaxOutputSize(size_t size)45 void SetMaxOutputSize(size_t size) 46 { 47 maxOutputSize_ = size; 48 } SetMaxDurationUs(size_t duration)49 void SetMaxDurationUs(size_t duration) 50 { 51 maxDurationUs_ = duration; 52 } 53 virtual ErrorCode PushData(int32_t trackId, std::shared_ptr<AVBuffer> buffer) = 0; 54 Start()55 virtual ErrorCode Start() 56 { 57 return ErrorCode::SUCCESS; 58 } Stop()59 virtual ErrorCode Stop() 60 { 61 return ErrorCode::SUCCESS; 62 } 63 64 protected: 65 static const size_t DEFAULT_MAX_DURATION_US = 60 * 1000 * 1000; 66 static const size_t DEFAULT_MAX_OUTPUT_SIZE = 0; 67 std::shared_ptr<Filter> nextFilter_ {}; 68 std::shared_ptr<Plugin::Muxer> muxer_ {}; 69 size_t maxOutputSize_{DEFAULT_MAX_OUTPUT_SIZE}; 70 size_t maxDurationUs_{DEFAULT_MAX_DURATION_US}; 71 }; 72 } // Pipeline 73 } // Media 74 } // OHOS 75 #endif // HISTREAMER_PIPELINE_DATA_SPLITER_H 76