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_ST_TEST_PLAYER 16 #define HISTREAMER_ST_TEST_PLAYER 17 18 #include <cstring> 19 #include <format.h> 20 #include <string> 21 #include <vector> 22 #include "common/plugin_types.h" 23 #include "media_data_source_impl.h" 24 #include "securec.h" 25 26 namespace OHOS::Media::Test { 27 enum class TestSourceType : int32_t { 28 URI = 0, 29 STREAM = 1 30 }; 31 32 class TestSource { 33 public: 34 static TestSource CreateTestSource(std::string& url, TestSourceType type, Plugin::Seekable seekable); TestSource(std::string url)35 explicit TestSource(std::string url) : url_(std::move(url)), type_(TestSourceType::URI) {} TestSource(std::string url,Plugin::Seekable seekable)36 TestSource(std::string url, Plugin::Seekable seekable) : url_(std::move(url)), 37 type_(TestSourceType::STREAM), seekable_(seekable) {} 38 39 std::string url_; 40 TestSourceType type_; 41 Plugin::Seekable seekable_ {Plugin::Seekable::INVALID}; 42 }; 43 44 class TestPlayer { 45 public: 46 static std::unique_ptr<TestPlayer> Create(); 47 virtual ~TestPlayer() = default; 48 virtual int32_t SetSource(const TestSource& source) = 0; 49 virtual int32_t SetSingleLoop(bool loop) = 0; 50 virtual bool IsPlaying() = 0; 51 virtual int32_t Prepare() = 0; 52 virtual int32_t Play() = 0; 53 virtual int32_t Pause() = 0; 54 virtual int32_t Stop() = 0; 55 virtual int32_t Reset() = 0; 56 virtual int32_t Release() = 0; 57 virtual int32_t Seek(int64_t timeMs) = 0; 58 virtual int32_t GetCurrentTime(int64_t& currentMs) = 0; 59 virtual int32_t GetDuration(int64_t& durationMs) = 0; 60 virtual int32_t SetVolume(float leftVolume, float rightVolume) = 0; 61 virtual int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) = 0; 62 }; 63 } 64 #endif