• 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 I_PLAYBIN_CTRLER_H
17 #define I_PLAYBIN_CTRLER_H
18 
19 #include <memory>
20 #include <string>
21 #include <unordered_map>
22 #include "nocopyable.h"
23 #include "playbin_msg_define.h"
24 #include "playbin_sink_provider.h"
25 #include "gst_appsrc_engine.h"
26 #include "format.h"
27 
28 namespace OHOS {
29 namespace Media {
30 class IPlayBinCtrler {
31 public:
32     enum class PlayBinKind : uint8_t {
33         PLAYBIN2,
34     };
35 
36     enum PlayBinRenderMode : uint8_t {
37         DEFAULT_RENDER = 0,
38         NATIVE_STREAM = 1 << 0,
39         DISABLE_TEXT = 1 << 1,
40     };
41 
42     enum PlayBinSeekMode : uint8_t {
43         NEXT_SYNC,
44         PREV_SYNC,
45         CLOSET_SYNC,
46         CLOSET,
47     };
48 
49     struct PlayBinCreateParam {
50         PlayBinRenderMode renderMode;
51         PlayBinMsgNotifier notifier;
52         std::shared_ptr<PlayBinSinkProvider> sinkProvider;
53     };
54 
55     virtual ~IPlayBinCtrler() = default;
56 
57     static std::shared_ptr<IPlayBinCtrler> Create(PlayBinKind kind, const PlayBinCreateParam &createParam);
58 
59     virtual int32_t SetSource(const std::string &url) = 0;
60     virtual int32_t SetSource(const std::shared_ptr<GstAppsrcEngine> &appsrcWrap) = 0;
61     virtual int32_t AddSubSource(const std::string &url) = 0;
62     virtual int32_t PrepareAsync() = 0; // async
63     virtual int32_t Play() = 0; // async
64     virtual int32_t Pause() = 0; // async
65     virtual int32_t Seek(int64_t timeUs, int32_t seekOption) = 0; // async
66     virtual int32_t Stop(bool needWait) = 0; // async
67     virtual int32_t SetRate(double rate) = 0;
68     virtual int32_t SetLoop(bool loop) = 0;
69     virtual void SetVolume(const float &leftVolume, const float &rightVolume) = 0;
70     virtual int32_t SelectBitRate(uint32_t bitRate) = 0;
71     virtual void SetAudioInterruptMode(const int32_t interruptMode) = 0;
72     virtual int32_t SetAudioRendererInfo(const uint32_t rendererInfo, const int32_t rendererFlag) = 0;
73     virtual int32_t SetAudioEffectMode(const int32_t effectMode) = 0;
74     using ElemSetupListener = std::function<void(GstElement &elem)>;
75     using AutoPlugSortListener = std::function<GValueArray *(GValueArray &factories)>;
76     virtual void SetElemSetupListener(ElemSetupListener listener) = 0;
77     virtual void SetElemUnSetupListener(ElemSetupListener listener) = 0;
78     virtual void SetAutoPlugSortListener(AutoPlugSortListener listener) = 0;
79     virtual void RemoveGstPlaySinkVideoConvertPlugin() = 0;
80     virtual int64_t QueryPosition() = 0;
81     virtual void SetNotifier(PlayBinMsgNotifier notifier) = 0;
82     virtual void SetAutoSelectBitrate(bool enable) = 0;
83     virtual int32_t SelectTrack(int32_t index) = 0;
84     virtual int32_t DeselectTrack(int32_t index) = 0;
85     virtual int32_t GetCurrentTrack(int32_t trackType, int32_t &index) = 0;
86     virtual int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) = 0;
87     virtual int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) = 0;
88     virtual int32_t GetSubtitleTrackInfo(std::vector<Format> &subtitleTrack) = 0;
89 };
90 } // namespace Media
91 } // namespace OHOS
92 #endif // I_PLAYBIN_CTRLER_H