1 /* 2 * Copyright (c) 2022-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 */ 15 16 #ifndef PLAYER_CLIENT_H 17 #define PLAYER_CLIENT_H 18 19 #include <pthread.h> 20 #include <unistd.h> 21 #include "format.h" 22 #include "media_log.h" 23 #include "player.h" 24 #include "source.h" 25 26 namespace OHOS { 27 namespace Media { 28 class PlayerImpl; 29 class Player::PlayerClient { 30 public: GetInstance()31 static PlayerClient* GetInstance() 32 { 33 PlayerClient *client = new PlayerClient(); 34 if (client == nullptr) { 35 MEDIA_ERR_LOG("InitPlayerClient failed\n"); 36 return nullptr; 37 } 38 return client; 39 } 40 PlayerClient(); 41 ~PlayerClient(); 42 43 int32_t SetSource(const Source &source); 44 int32_t Prepare(); 45 int32_t Play(); 46 bool IsPlaying(); 47 int32_t Pause(); 48 int32_t Stop(); 49 int32_t Rewind(int64_t mSeconds, int32_t mode); 50 int32_t SetVolume(float leftVolume, float rightVolume); 51 int32_t SetSurface(Surface *surface); 52 int32_t SetLoop(bool loop); 53 bool IsSingleLooping(); 54 int32_t GetCurrentPosition(int64_t &time) const; 55 int32_t GetDuration(int64_t &duration) const; 56 int32_t GetVideoWidth(int32_t &videoWidth); 57 int32_t GetVideoHeight(int32_t &videoHeight); 58 int32_t Reset(); 59 int32_t Release(); 60 void SetPlayerCallback(const std::shared_ptr<PlayerCallback> &cb); 61 int32_t GetPlayerState(int32_t &state) const; 62 int32_t SetPlaybackSpeed(float speed); 63 int32_t GetPlaybackSpeed(float &speed); 64 int32_t SetParameter(const Format ¶ms); 65 int32_t SetAudioStreamType(int32_t type); 66 void GetAudioStreamType(int32_t &type); 67 68 private: 69 std::unique_ptr<PlayerImpl> impl_; 70 }; 71 } 72 } 73 #endif