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 PLAYER_SERVICE_CLIENT_H 17 #define PLAYER_SERVICE_CLIENT_H 18 19 #include "i_player_service.h" 20 #include "i_standard_player_service.h" 21 #include "player_listener_stub.h" 22 #include "media_data_source_stub.h" 23 #include "monitor_client_object.h" 24 25 namespace OHOS { 26 namespace Media { 27 class PlayerClient : public IPlayerService, public MonitorClientObject { 28 public: 29 static std::shared_ptr<PlayerClient> Create(const sptr<IStandardPlayerService> &ipcProxy); 30 explicit PlayerClient(const sptr<IStandardPlayerService> &ipcProxy); 31 ~PlayerClient(); 32 33 // IPlayerService override 34 int32_t SetSource(const std::string &url) override; 35 int32_t Play() override; 36 int32_t Reset() override; 37 int32_t Stop() override; 38 int32_t SetRenderFirstFrame(bool display) override; 39 int32_t SetPlayRange(int64_t start, int64_t end) override; 40 int32_t SetPlayRangeWithMode(int64_t start, int64_t end, PlayerSeekMode mode) override; 41 int32_t PrepareAsync() override; 42 int32_t Prepare() override; 43 int32_t Pause() override; 44 int32_t SetSource(const std::shared_ptr<IMediaDataSource> &dataSrc) override; 45 int32_t AddSubSource(int32_t fd, int64_t offset, int64_t size) override; 46 int32_t SetSource(int32_t fd, int64_t offset, int64_t size) override; 47 int32_t AddSubSource(const std::string &url) override; 48 int32_t Release() override; 49 int32_t ReleaseSync() override; 50 int32_t SetVolume(float leftVolume, float rightVolume) override; 51 int32_t GetCurrentTime(int32_t ¤tTime) override; 52 int32_t Seek(int32_t mSeconds, PlayerSeekMode mode) override; 53 int32_t GetSubtitleTrackInfo(std::vector<Format> &subtitleTrack) override; 54 int32_t GetPlaybackSpeed(PlaybackRateMode &mode) override; 55 int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) override; 56 int32_t GetVideoHeight() override; 57 int32_t SetPlaybackSpeed(PlaybackRateMode mode) override; 58 int32_t SetMediaSource(const std::shared_ptr<AVMediaSource> &mediaSource, AVPlayStrategy strategy) override; 59 int32_t GetDuration(int32_t &duration) override; 60 int32_t GetApiVersion(int32_t &apiVersion) override; 61 int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) override; 62 int32_t GetPlaybackInfo(Format &playbackInfo) override; 63 int32_t GetVideoWidth() override; 64 int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySessionProxy, 65 bool svp) override; 66 #ifdef SUPPORT_VIDEO 67 int32_t SetVideoSurface(sptr<Surface> surface) override; 68 #endif 69 bool IsPlaying() override; 70 bool IsLooping() override; 71 int32_t SetLooping(bool loop) override; 72 int32_t SetParameter(const Format ¶m) override; 73 int32_t SetPlayerCallback(const std::shared_ptr<PlayerCallback> &callback) override; 74 int32_t SelectBitRate(uint32_t bitRate) override; 75 int32_t SelectTrack(int32_t index, PlayerSwitchMode mode) override; 76 int32_t DeselectTrack(int32_t index) override; 77 int32_t GetCurrentTrack(int32_t trackType, int32_t &index) override; 78 int32_t SetPlaybackStrategy(AVPlayStrategy playbackStrategy) override; 79 int32_t SetMediaMuted(OHOS::Media::MediaType mediaType, bool isMuted) override; 80 // PlayerClient 81 void MediaServerDied(); 82 int32_t SetMaxAmplitudeCbStatus(bool status) override; 83 int32_t SetDeviceChangeCbStatus(bool status) override; 84 bool IsSeekContinuousSupported() override; 85 86 private: 87 int32_t CreateListenerObject(); 88 int32_t DisableWhenOK(int32_t ret); 89 90 sptr<IStandardPlayerService> playerProxy_ = nullptr; 91 sptr<PlayerListenerStub> listenerStub_ = nullptr; 92 sptr<MediaDataSourceStub> dataSrcStub_ = nullptr; 93 std::shared_ptr<PlayerCallback> callback_ = nullptr; 94 std::mutex mutex_; 95 }; 96 } // namespace Media 97 } // namespace OHOS 98 #endif // PLAYER_SERVICE_CLIENT_H 99