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; 34 virtual void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody) = 0; 35 }; 36 37 class IPlayerEngine { 38 public: 39 virtual ~IPlayerEngine() = default; 40 41 virtual int32_t SetSource(const std::string &url) = 0; 42 virtual int32_t SetSource(const std::shared_ptr<IMediaDataSource> &dataSrc) = 0; 43 virtual int32_t Play() = 0; 44 virtual int32_t Prepare() = 0; 45 virtual int32_t PrepareAsync() = 0; 46 virtual int32_t Pause() = 0; 47 virtual int32_t Stop() = 0; 48 virtual int32_t Reset() = 0; 49 virtual int32_t SetVolume(float leftVolume, float rightVolume) = 0; 50 virtual int32_t Seek(int32_t mSeconds, PlayerSeekMode mode) = 0; 51 virtual int32_t GetCurrentTime(int32_t ¤tTime) = 0; 52 virtual int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) = 0; 53 virtual int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) = 0; 54 virtual int32_t GetVideoWidth() = 0; 55 virtual int32_t GetVideoHeight() = 0; 56 virtual int32_t GetDuration(int32_t &duration) = 0; 57 virtual int32_t SetPlaybackSpeed(PlaybackRateMode mode) = 0; 58 virtual int32_t GetPlaybackSpeed(PlaybackRateMode &mode) = 0; 59 virtual int32_t SetVideoSurface(sptr<Surface> surface) = 0; 60 virtual int32_t SetLooping(bool loop) = 0; 61 virtual int32_t SetParameter(const Format ¶m) = 0; 62 virtual int32_t SetObs(const std::weak_ptr<IPlayerEngineObs> &obs) = 0; 63 }; 64 } // namespace Media 65 } // namespace OHOS 66 #endif // I_PLAYER_ENGINE_H 67