1 /*
2  * Copyright (C) 2023-2023 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  * Description: supply Stream Player definition.
15  * Author: huangchanggui
16  * Create: 2023-01-12
17  */
18 
19 #ifndef STREAM_PLAYER_H
20 #define STREAM_PLAYER_H
21 
22 #include "i_stream_player.h"
23 #include "i_stream_player_ipc.h"
24 #include "cast_engine_common.h"
25 
26 namespace OHOS {
27 namespace CastEngine {
28 namespace CastEngineClient {
29 class StreamPlayer : public IStreamPlayer {
30 public:
StreamPlayer(sptr<IStreamPlayerIpc> proxy)31     explicit StreamPlayer(sptr<IStreamPlayerIpc> proxy) : proxy_(proxy) {}
32     ~StreamPlayer() override;
33 
34     int32_t RegisterListener(std::shared_ptr<IStreamPlayerListener> listener) override;
35     int32_t UnregisterListener() override;
36     int32_t SetSurface(const std::string &surfaceId) override;
37     int32_t Load(const MediaInfo &mediaInfo) override;
38     int32_t Play(const MediaInfo &mediaInfo) override;
39     int32_t Play(int index) override;
40     int32_t Play() override;
41     int32_t Pause() override;
42     int32_t Stop() override;
43     int32_t Next() override;
44     int32_t Previous() override;
45     int32_t Seek(int position) override;
46     int32_t FastForward(int delta) override;
47     int32_t FastRewind(int delta) override;
48     int32_t SetVolume(int volume) override;
49     int32_t SetMute(bool mute) override;
50     int32_t SetLoopMode(const LoopMode mode) override;
51     int32_t SetSpeed(const PlaybackSpeed speed) override;
52     int32_t GetPlayerStatus(PlayerStates &playerStates) override;
53     int32_t GetPosition(int &position) override;
54     int32_t GetDuration(int &duration) override;
55     int32_t GetVolume(int &volume, int &maxVolume) override;
56     int32_t GetMute(bool &mute) override;
57     int32_t GetLoopMode(LoopMode &loopMode) override;
58     int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) override;
59     int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) override;
60     int32_t Release() override;
61 
62 private:
63     static const int GET_FAILED = -1;
64     sptr<IStreamPlayerIpc> proxy_;
65 };
66 } // namespace CastEngineClient
67 } // namespace CastEngine
68 } // namespace OHOS
69 
70 #endif
71