1 /*
2  * Copyright (C) 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 I_STANDARD_PLAYER_SERVICE_H
17 #define I_STANDARD_PLAYER_SERVICE_H
18 
19 #include "ipc_types.h"
20 #include "iremote_broker.h"
21 #include "iremote_proxy.h"
22 #include "iremote_stub.h"
23 #include "player.h"
24 
25 namespace OHOS {
26 namespace Media {
27 class IStandardPlayerService : public IRemoteBroker {
28 public:
29     virtual ~IStandardPlayerService() = default;
30     virtual int32_t SetListenerObject(const sptr<IRemoteObject> &object) = 0;
31     virtual int32_t SetSource(const std::string &url) = 0;
32     virtual int32_t SetSource(const sptr<IRemoteObject> &object) = 0;
33     virtual int32_t SetSource(int32_t fd, int64_t offset, int64_t size) = 0;
34     virtual int32_t AddSubSource(const std::string &url) = 0;
35     virtual int32_t AddSubSource(int32_t fd, int64_t offset, int64_t size) = 0;
36     virtual int32_t Play() = 0;
37     virtual int32_t Prepare() = 0;
SetRenderFirstFrame(bool display)38     virtual int32_t SetRenderFirstFrame(bool display)
39     {
40         (void)display;
41         return 0;
42     }
SetPlayRange(int64_t start,int64_t end)43     virtual int32_t SetPlayRange(int64_t start, int64_t end)
44     {
45         (void)start;
46         (void)end;
47         return 0;
48     }
SetPlayRangeWithMode(int64_t start,int64_t end,PlayerSeekMode mode)49     virtual int32_t SetPlayRangeWithMode(int64_t start, int64_t end, PlayerSeekMode mode)
50     {
51         (void)start;
52         (void)end;
53         (void)mode;
54         return 0;
55     }
56     virtual int32_t PrepareAsync() = 0;
57     virtual int32_t Pause() = 0;
58     virtual int32_t Stop() = 0;
59     virtual int32_t Reset() = 0;
60     virtual int32_t Release() = 0;
ReleaseSync()61     virtual int32_t ReleaseSync() // Only client rewrite is required
62     {
63         return ERR_OK;
64     }
65     virtual int32_t SetVolume(float leftVolume, float rightVolume) = 0;
66     virtual int32_t Seek(int32_t mSeconds, PlayerSeekMode mode) = 0;
67     virtual int32_t GetCurrentTime(int32_t &currentTime) = 0;
68     virtual int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) = 0;
69     virtual int32_t GetPlaybackInfo(Format &playbackInfo) = 0;
70     virtual int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) = 0;
71     virtual int32_t GetSubtitleTrackInfo(std::vector<Format> &subtitleTrack) = 0;
72     virtual int32_t GetVideoWidth() = 0;
73     virtual int32_t GetVideoHeight() = 0;
74     virtual int32_t GetDuration(int32_t &duration) = 0;
75     virtual int32_t SetPlaybackSpeed(PlaybackRateMode mode) = 0;
76     virtual int32_t GetPlaybackSpeed(PlaybackRateMode &mode) = 0;
77     virtual int32_t SetMediaSource(const std::shared_ptr<AVMediaSource> &mediaSource, AVPlayStrategy strategy) = 0;
78 #ifdef SUPPORT_VIDEO
79     virtual int32_t SetVideoSurface(sptr<Surface> surface) = 0;
80 #endif
81     virtual bool IsPlaying() = 0;
82     virtual bool IsLooping() = 0;
83     virtual int32_t SetLooping(bool loop) = 0;
84     virtual int32_t SetParameter(const Format &param) = 0;
85     virtual int32_t DestroyStub() = 0;
86     virtual int32_t SetPlayerCallback() = 0;
87     virtual int32_t SelectBitRate(uint32_t bitRate) = 0;
88     virtual int32_t SelectTrack(int32_t index, PlayerSwitchMode mode = PlayerSwitchMode::SWITCH_SMOOTH) = 0;
89     virtual int32_t DeselectTrack(int32_t index) = 0;
90     virtual int32_t GetCurrentTrack(int32_t trackType, int32_t &index) = 0;
SetPlaybackStrategy(AVPlayStrategy playbackStrategy)91     virtual int32_t SetPlaybackStrategy(AVPlayStrategy playbackStrategy)
92     {
93         (void)playbackStrategy;
94         return 0;
95     }
SetMediaMuted(MediaType mediaType,bool isMuted)96     virtual int32_t SetMediaMuted(MediaType mediaType, bool isMuted)
97     {
98         (void)mediaType;
99         (void)isMuted;
100         return 0;
101     }
102 
SetDecryptConfig(const sptr<OHOS::DrmStandard::IMediaKeySessionService> & keySessionProxy,bool svp)103     virtual int32_t SetDecryptConfig(const sptr<OHOS::DrmStandard::IMediaKeySessionService> &keySessionProxy,
104         bool svp)
105     {
106         (void)keySessionProxy;
107         (void)svp;
108         return 0;
109     }
110 
SetMaxAmplitudeCbStatus(bool status)111     virtual int32_t SetMaxAmplitudeCbStatus(bool status)
112     {
113         (void)status;
114         return 0;
115     }
116 
SetDeviceChangeCbStatus(bool status)117     virtual int32_t SetDeviceChangeCbStatus(bool status)
118     {
119         (void)status;
120         return 0;
121     }
122 
GetApiVersion(int32_t & apiVersion)123     virtual int32_t GetApiVersion(int32_t &apiVersion)
124     {
125         (void)apiVersion;
126         return 0;
127     }
128 
IsSeekContinuousSupported()129     virtual bool IsSeekContinuousSupported()
130     {
131         return false;
132     }
133     /**
134      * IPC code ID
135      */
136     enum PlayerServiceMsg {
137         SET_LISTENER_OBJ = 0,
138         SET_SOURCE,
139         SET_MEDIA_DATA_SRC_OBJ,
140         SET_FD_SOURCE,
141         ADD_SUB_SOURCE,
142         ADD_SUB_FD_SOURCE,
143         PLAY,
144         PREPARE,
145         SET_RENDER_FIRST_FRAME,
146         SET_PLAY_RANGE,
147         SET_PLAY_RANGE_WITH_MODE,
148         PREPAREASYNC,
149         PAUSE,
150         STOP,
151         RESET,
152         RELEASE,
153         SET_VOLUME,
154         SEEK,
155         GET_CURRENT_TIME,
156         GET_DURATION,
157         SET_PLAYERBACK_SPEED,
158         GET_PLAYERBACK_SPEED,
159         SET_MEDIA_SOURCE,
160         SET_VIDEO_SURFACE,
161         IS_PLAYING,
162         IS_LOOPING,
163         SET_LOOPING,
164         SET_RENDERER_DESC,
165         DESTROY,
166         SET_CALLBACK,
167         GET_VIDEO_TRACK_INFO,
168         GET_AUDIO_TRACK_INFO,
169         GET_VIDEO_WIDTH,
170         GET_VIDEO_HEIGHT,
171         SELECT_BIT_RATE,
172         SELECT_TRACK,
173         DESELECT_TRACK,
174         GET_CURRENT_TRACK,
175         GET_SUBTITLE_TRACK_INFO,
176         SET_DECRYPT_CONFIG,
177         SET_PLAYBACK_STRATEGY,
178         SET_MEDIA_MUTED,
179         SET_MAX_AMPLITUDE_CB_STATUS,
180         GET_PLAYBACK_INFO,
181         SET_DEVICE_CHANGE_CB_STATUS,
182         GET_API_VERSION,
183         IS_SEEK_CONTINUOUS_SUPPORTED,
184         MAX_IPC_ID,                   // all IPC codes should be added before MAX_IPC_ID
185     };
186 
187     DECLARE_INTERFACE_DESCRIPTOR(u"IStandardPlayerService");
188 };
189 } // namespace Media
190 } // namespace OHOS
191 #endif // I_STANDARD_PLAYER_SERVICE_H
192