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; AddSubSource(const std::string & url)48 virtual int32_t AddSubSource(const std::string &url) 49 { 50 (void)url; 51 return 0; 52 } 53 virtual int32_t Play() = 0; Prepare()54 virtual int32_t Prepare() 55 { 56 return 0; 57 } 58 virtual int32_t PrepareAsync() = 0; 59 virtual int32_t Pause() = 0; 60 virtual int32_t Stop() = 0; 61 virtual int32_t Reset() = 0; 62 virtual int32_t SetVolume(float leftVolume, float rightVolume) = 0; 63 virtual int32_t Seek(int32_t mSeconds, PlayerSeekMode mode) = 0; 64 virtual int32_t GetCurrentTime(int32_t ¤tTime) = 0; 65 virtual int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) = 0; 66 virtual int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) = 0; GetSubtitleTrackInfo(std::vector<Format> & subtitleTrack)67 virtual int32_t GetSubtitleTrackInfo(std::vector<Format> &subtitleTrack) 68 { 69 (void)subtitleTrack; 70 return 0; 71 } 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 SetVideoSurface(sptr<Surface> surface) = 0; 78 virtual int32_t SetLooping(bool loop) = 0; 79 virtual int32_t SetParameter(const Format ¶m) = 0; 80 virtual int32_t SetObs(const std::weak_ptr<IPlayerEngineObs> &obs) = 0; SelectBitRate(uint32_t bitRate)81 virtual int32_t SelectBitRate(uint32_t bitRate) 82 { 83 (void)bitRate; 84 return 0; 85 } SetVideoScaleType(VideoScaleType videoScaleType)86 virtual int32_t SetVideoScaleType(VideoScaleType videoScaleType) 87 { 88 (void)videoScaleType; 89 return 0; 90 } SetAudioRendererInfo(const int32_t contentType,const int32_t streamUsage,const int32_t rendererFlag)91 virtual int32_t SetAudioRendererInfo(const int32_t contentType, const int32_t streamUsage, 92 const int32_t rendererFlag) 93 { 94 (void)contentType; 95 (void)streamUsage; 96 (void)rendererFlag; 97 return 0; 98 } SetAudioInterruptMode(const int32_t interruptMode)99 virtual int32_t SetAudioInterruptMode(const int32_t interruptMode) 100 { 101 (void)interruptMode; 102 return 0; 103 } 104 SelectTrack(int32_t index)105 virtual int32_t SelectTrack(int32_t index) 106 { 107 (void)index; 108 return 0; 109 } DeselectTrack(int32_t index)110 virtual int32_t DeselectTrack(int32_t index) 111 { 112 (void)index; 113 return 0; 114 } GetCurrentTrack(int32_t trackType,int32_t & index)115 virtual int32_t GetCurrentTrack(int32_t trackType, int32_t &index) 116 { 117 (void)trackType; 118 (void)index; 119 return 0; 120 } SetAudioEffectMode(const int32_t effectMode)121 virtual int32_t SetAudioEffectMode(const int32_t effectMode) 122 { 123 (void)effectMode; 124 return 0; 125 } GetHEBCMode()126 virtual int32_t GetHEBCMode() 127 { 128 return 0; 129 } HandleCodecBuffers(bool enable)130 virtual int32_t HandleCodecBuffers(bool enable) 131 { 132 (void)enable; 133 return 0; 134 } SeekToCurrentTime(int32_t mSeconds,PlayerSeekMode mode)135 virtual int32_t SeekToCurrentTime(int32_t mSeconds, PlayerSeekMode mode) 136 { 137 (void)mSeconds; 138 (void)mode; 139 return 0; 140 } 141 }; 142 } // namespace Media 143 } // namespace OHOS 144 #endif // I_PLAYER_ENGINE_H 145