• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_IMPL_H
17 #define PLAYER_IMPL_H
18 
19 #include "player.h"
20 #include "nocopyable.h"
21 #include "i_player_service.h"
22 
23 namespace OHOS {
24 namespace Media {
25 class PlayerImpl : public Player, public NoCopyable {
26 public:
27     PlayerImpl();
28     ~PlayerImpl();
29 
30     int32_t SetSource(const std::string &url) override;
31     int32_t SetSource(const std::shared_ptr<IMediaDataSource> &dataSrc) override;
32     int32_t SetSource(int32_t fd, int64_t offset, int64_t size) override;
33     int32_t AddSubSource(const std::string &url) override;
34     int32_t AddSubSource(int32_t fd, int64_t offset, int64_t size) override;
35     int32_t Play() override;
36     int32_t Prepare() override;
37     int32_t PrepareAsync() override;
38     int32_t Pause() override;
39     int32_t Stop() override;
40     int32_t Reset() override;
41     int32_t Release() override;
42     int32_t ReleaseSync() override;
43     int32_t SetVolume(float leftVolume, float rightVolume) override;
44     int32_t Seek(int32_t mSeconds, PlayerSeekMode mode) override;
45     int32_t GetCurrentTime(int32_t &currentTime) override;
46     int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) override;
47     int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) override;
48     int32_t GetSubtitleTrackInfo(std::vector<Format> &subtitleTrack) override;
49     int32_t GetVideoWidth() override;
50     int32_t GetVideoHeight() override;
51     int32_t GetDuration(int32_t &duration) override;
52     int32_t SetPlaybackSpeed(PlaybackRateMode mode) override;
53     int32_t GetPlaybackSpeed(PlaybackRateMode &mode) override;
54 #ifdef SUPPORT_VIDEO
55     int32_t SetVideoSurface(sptr<Surface> surface) override;
56 #endif
57     bool IsPlaying() override;
58     bool IsLooping() override;
59     int32_t SetLooping(bool loop) override;
60     int32_t SetPlayerCallback(const std::shared_ptr<PlayerCallback> &callback) override;
61     int32_t SetParameter(const Format &param) override;
62     int32_t SelectBitRate(uint32_t bitRate) override;
63     int32_t SelectTrack(int32_t index) override;
64     int32_t DeselectTrack(int32_t index) override;
65     int32_t GetCurrentTrack(int32_t trackType, int32_t &index) override;
66     int32_t Init();
67 private:
68     std::shared_ptr<IPlayerService> playerService_ = nullptr;
69     sptr<Surface> surface_ = nullptr;
70 };
71 } // namespace Media
72 } // namespace OHOS
73 #endif // PLAYER_IMPL_H
74