1fa7767c5Sopenharmony_ci/*
2fa7767c5Sopenharmony_ci * Copyright (c) 2022-2022 Huawei Device Co., Ltd.
3fa7767c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fa7767c5Sopenharmony_ci * you may not use this file except in compliance with the License.
5fa7767c5Sopenharmony_ci * You may obtain a copy of the License at
6fa7767c5Sopenharmony_ci *
7fa7767c5Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fa7767c5Sopenharmony_ci *
9fa7767c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fa7767c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fa7767c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fa7767c5Sopenharmony_ci * See the License for the specific language governing permissions and
13fa7767c5Sopenharmony_ci * limitations under the License.
14fa7767c5Sopenharmony_ci */
15fa7767c5Sopenharmony_ci#ifndef HISTREAMER_ST_TEST_PLAYER
16fa7767c5Sopenharmony_ci#define HISTREAMER_ST_TEST_PLAYER
17fa7767c5Sopenharmony_ci
18fa7767c5Sopenharmony_ci#include <cstring>
19fa7767c5Sopenharmony_ci#include <format.h>
20fa7767c5Sopenharmony_ci#include <string>
21fa7767c5Sopenharmony_ci#include <vector>
22fa7767c5Sopenharmony_ci#include "media_data_source_impl.h"
23fa7767c5Sopenharmony_ci#include "plugin/common/plugin_types.h"
24fa7767c5Sopenharmony_ci#include "securec.h"
25fa7767c5Sopenharmony_ci#include "player.h"
26fa7767c5Sopenharmony_ci
27fa7767c5Sopenharmony_ci#ifndef WIN32
28fa7767c5Sopenharmony_ci#define HST_TEST(UtObject, function, level) HWTEST_F(UtObject, function, level)
29fa7767c5Sopenharmony_ci#else
30fa7767c5Sopenharmony_ci#define HST_TEST(UtObject, function, level) TEST_F(UtObject, function)
31fa7767c5Sopenharmony_ci#endif
32fa7767c5Sopenharmony_ci
33fa7767c5Sopenharmony_cinamespace OHOS::Media::Test {
34fa7767c5Sopenharmony_cienum class TestSourceType : int32_t {
35fa7767c5Sopenharmony_ci    URI = 0,
36fa7767c5Sopenharmony_ci    STREAM = 1
37fa7767c5Sopenharmony_ci};
38fa7767c5Sopenharmony_ci
39fa7767c5Sopenharmony_ciclass TestSource {
40fa7767c5Sopenharmony_cipublic:
41fa7767c5Sopenharmony_ci    static TestSource CreateTestSource(const std::string& url, TestSourceType type, Plugin::Seekable seekable);
42fa7767c5Sopenharmony_ci    explicit TestSource(std::string url) : url_(std::move(url)), type_(TestSourceType::URI) {}
43fa7767c5Sopenharmony_ci    TestSource(std::string url, Plugin::Seekable seekable) : url_(std::move(url)),
44fa7767c5Sopenharmony_ci        type_(TestSourceType::STREAM), seekable_(seekable) {}
45fa7767c5Sopenharmony_ci
46fa7767c5Sopenharmony_ci    std::string url_;
47fa7767c5Sopenharmony_ci    TestSourceType type_;
48fa7767c5Sopenharmony_ci    Plugin::Seekable seekable_ {Plugin::Seekable::INVALID};
49fa7767c5Sopenharmony_ci};
50fa7767c5Sopenharmony_ci
51fa7767c5Sopenharmony_ciclass TestPlayer {
52fa7767c5Sopenharmony_cipublic:
53fa7767c5Sopenharmony_ci    static std::unique_ptr<TestPlayer> Create();
54fa7767c5Sopenharmony_ci    virtual ~TestPlayer() = default;
55fa7767c5Sopenharmony_ci    virtual int32_t SetSource(const TestSource& source) = 0;
56fa7767c5Sopenharmony_ci    virtual int32_t SetSingleLoop(bool loop) = 0;
57fa7767c5Sopenharmony_ci    virtual bool IsPlaying() = 0;
58fa7767c5Sopenharmony_ci    virtual int32_t Prepare() = 0;
59fa7767c5Sopenharmony_ci    virtual int32_t Play() = 0;
60fa7767c5Sopenharmony_ci    virtual int32_t Pause() = 0;
61fa7767c5Sopenharmony_ci    virtual int32_t Stop() = 0;
62fa7767c5Sopenharmony_ci    virtual int32_t Reset() = 0;
63fa7767c5Sopenharmony_ci    virtual int32_t Release() = 0;
64fa7767c5Sopenharmony_ci    virtual int32_t Seek(int64_t timeMs, PlayerSeekMode mode = PlayerSeekMode::SEEK_NEXT_SYNC) = 0;
65fa7767c5Sopenharmony_ci    virtual int32_t GetCurrentTime(int64_t& currentMs) = 0;
66fa7767c5Sopenharmony_ci    virtual int32_t GetDuration(int64_t& durationMs) = 0;
67fa7767c5Sopenharmony_ci    virtual int32_t SetVolume(float leftVolume, float rightVolume) = 0;
68fa7767c5Sopenharmony_ci    virtual int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) = 0;
69fa7767c5Sopenharmony_ci    virtual int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) = 0;
70fa7767c5Sopenharmony_ci    virtual int32_t SetPlaybackSpeed(PlaybackRateMode mode)  = 0;
71fa7767c5Sopenharmony_ci    virtual int32_t GetPlaybackSpeed(PlaybackRateMode &mode) = 0;
72fa7767c5Sopenharmony_ci};
73fa7767c5Sopenharmony_ci}
74fa7767c5Sopenharmony_ci#endif