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 #ifndef I_PLAYER_ENGINE_H 16 #define I_PLAYER_ENGINE_H 17 18 #include <map> 19 #include <vector> 20 #include <cstdint> 21 #include <string> 22 #include <refbase.h> 23 #include "player.h" 24 #include "nocopyable.h" 25 26 namespace OHOS { 27 class Surface; 28 29 namespace Media { 30 class IPlayerEngineObs : public std::enable_shared_from_this<IPlayerEngineObs> { 31 public: 32 virtual ~IPlayerEngineObs() = default; 33 virtual void OnError(PlayerErrorType errorType, int32_t errorCode) = 0; OnErrorMessage(int32_t errorCode,const std::string & errorMsg)34 virtual void OnErrorMessage(int32_t errorCode, const std::string &errorMsg) 35 { 36 (void)errorCode; 37 (void)errorMsg; 38 } 39 virtual void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody) = 0; 40 }; 41 42 class IPlayerEngine { 43 public: 44 virtual ~IPlayerEngine() = default; 45 46 virtual int32_t SetSource(const std::string &url) = 0; 47 virtual int32_t SetSource(const std::shared_ptr<IMediaDataSource> &dataSrc) = 0; 48 virtual int32_t Play() = 0; 49 virtual int32_t Prepare() = 0; 50 virtual int32_t PrepareAsync() = 0; 51 virtual int32_t Pause() = 0; 52 virtual int32_t Stop() = 0; 53 virtual int32_t Reset() = 0; 54 virtual int32_t SetVolume(float leftVolume, float rightVolume) = 0; 55 virtual int32_t Seek(int32_t mSeconds, PlayerSeekMode mode) = 0; 56 virtual int32_t GetCurrentTime(int32_t ¤tTime) = 0; 57 virtual int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) = 0; 58 virtual int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) = 0; 59 virtual int32_t GetVideoWidth() = 0; 60 virtual int32_t GetVideoHeight() = 0; 61 virtual int32_t GetDuration(int32_t &duration) = 0; 62 virtual int32_t SetPlaybackSpeed(PlaybackRateMode mode) = 0; 63 virtual int32_t GetPlaybackSpeed(PlaybackRateMode &mode) = 0; 64 virtual int32_t SetVideoSurface(sptr<Surface> surface) = 0; 65 virtual int32_t SetLooping(bool loop) = 0; 66 virtual int32_t SetParameter(const Format ¶m) = 0; 67 virtual int32_t SetObs(const std::weak_ptr<IPlayerEngineObs> &obs) = 0; SelectBitRate(uint32_t bitRate)68 virtual int32_t SelectBitRate(uint32_t bitRate) 69 { 70 (void)bitRate; 71 return 0; 72 } SetVideoScaleType(VideoScaleType videoScaleType)73 virtual int32_t SetVideoScaleType(VideoScaleType videoScaleType) 74 { 75 (void)videoScaleType; 76 return 0; 77 } SetAudioRendererInfo(const int32_t contentType,const int32_t streamUsage,const int32_t rendererFlag)78 virtual int32_t SetAudioRendererInfo(const int32_t contentType, const int32_t streamUsage, 79 const int32_t rendererFlag) 80 { 81 (void)contentType; 82 (void)streamUsage; 83 (void)rendererFlag; 84 return 0; 85 } SetAudioInterruptMode(const int32_t interruptMode)86 virtual int32_t SetAudioInterruptMode(const int32_t interruptMode) 87 { 88 (void)interruptMode; 89 return 0; 90 } 91 }; 92 } // namespace Media 93 } // namespace OHOS 94 #endif // I_PLAYER_ENGINE_H 95