• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: Stream Player interface.
15  * Author: huangchanggui
16  * Create: 2023-01-11
17  */
18 
19 #ifndef I_STREAM_PLAYER_H
20 #define I_STREAM_PLAYER_H
21 
22 #include "cast_engine_common.h"
23 #include "pixel_map.h"
24 
25 namespace OHOS {
26 namespace CastEngine {
27 class EXPORT IStreamPlayerListener {
28 public:
29     IStreamPlayerListener() = default;
30     IStreamPlayerListener(const IStreamPlayerListener &) = delete;
31     IStreamPlayerListener &operator=(const IStreamPlayerListener &) = delete;
32     IStreamPlayerListener(IStreamPlayerListener &&) = delete;
33     IStreamPlayerListener &operator=(IStreamPlayerListener &&) = delete;
34     virtual ~IStreamPlayerListener() = default;
35 
36     virtual void OnStateChanged(const PlayerStates playbackState, bool isPlayWhenReady) = 0;
37     virtual void OnPositionChanged(int position, int bufferPosition, int duration) = 0;
38     virtual void OnMediaItemChanged(const MediaInfo &mediaInfo) = 0;
39     virtual void OnVolumeChanged(int volume, int maxVolume) = 0;
40     virtual void OnLoopModeChanged(const LoopMode loopMode) = 0;
41     virtual void OnPlaySpeedChanged(const PlaybackSpeed speed) = 0;
42     virtual void OnPlayerError(int errorCode, const std::string &errorMsg) = 0;
43     virtual void OnVideoSizeChanged(int width, int height) = 0;
44     virtual void OnNextRequest() = 0;
45     virtual void OnPreviousRequest() = 0;
46     virtual void OnSeekDone(int position) = 0;
47     virtual void OnEndOfStream(int isLooping) = 0;
48     virtual void OnPlayRequest(const MediaInfo &mediaInfo) = 0;
49     virtual void OnImageChanged(std::shared_ptr<Media::PixelMap> pixelMap) = 0;
50     virtual void OnAlbumCoverChanged(std::shared_ptr<Media::PixelMap> pixelMap) = 0;
51 };
52 
53 class EXPORT IStreamPlayer {
54 public:
55     IStreamPlayer() = default;
56     IStreamPlayer(const IStreamPlayer &) = delete;
57     IStreamPlayer &operator=(const IStreamPlayer &) = delete;
58     IStreamPlayer(IStreamPlayer &&) = delete;
59     IStreamPlayer &operator=(IStreamPlayer &&) = delete;
60     virtual ~IStreamPlayer() = default;
61 
62     virtual int32_t RegisterListener(std::shared_ptr<IStreamPlayerListener> listener) = 0;
63     virtual int32_t UnregisterListener() = 0;
64     virtual int32_t SetSurface(const std::string &surfaceId) = 0;
65     virtual int32_t Load(const MediaInfo &mediaInfo) = 0;
66     virtual int32_t Play(const MediaInfo &mediaInfo) = 0;
67     virtual int32_t Play(int index) = 0;
68     virtual int32_t Play() = 0;
69     virtual int32_t Pause() = 0;
70     virtual int32_t Stop() = 0;
71     virtual int32_t Next() = 0;
72     virtual int32_t Previous() = 0;
73     virtual int32_t Seek(int position) = 0;
74     virtual int32_t FastForward(int delta) = 0;
75     virtual int32_t FastRewind(int delta) = 0;
76     virtual int32_t SetVolume(int volume) = 0;
77     virtual int32_t SetMute(bool mute) = 0;
78     virtual int32_t SetLoopMode(const LoopMode mode) = 0;
79     virtual int32_t SetSpeed(const PlaybackSpeed speed) = 0;
80     virtual int32_t GetPlayerStatus(PlayerStates &playerStates) = 0;
81     virtual int32_t GetPosition(int &position) = 0;
82     virtual int32_t GetDuration(int &duration) = 0;
83     virtual int32_t GetVolume(int &volume, int &maxVolume) = 0;
84     virtual int32_t GetMute(bool &mute) = 0;
85     virtual int32_t GetLoopMode(LoopMode &loopMode) = 0;
86     virtual int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) = 0;
87     virtual int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) = 0;
88     virtual int32_t Release() = 0;
89 };
90 } // namespace CastEngine
91 } // namespace OHOS
92 
93 #endif
94