• 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_wrap.h"
26 
27 namespace OHOS {
28 namespace Media {
29 class IPlayBinCtrler {
30 public:
31     enum class PlayBinKind : uint8_t {
32         PLAYBIN2,
33     };
34 
35     enum PlayBinRenderMode : uint8_t {
36         DEFAULT_RENDER = 0,
37         NATIVE_STREAM = 1 << 0,
38         DISABLE_TEXT = 1 << 1,
39     };
40 
41     enum PlayBinSeekMode : uint8_t {
42         NEXT_SYNC,
43         PREV_SYNC,
44         CLOSET_SYNC,
45         CLOSET,
46     };
47 
48     struct PlayBinCreateParam {
49         PlayBinRenderMode renderMode;
50         PlayBinMsgNotifier notifier;
51         std::shared_ptr<PlayBinSinkProvider> sinkProvider;
52     };
53 
54     virtual ~IPlayBinCtrler() = default;
55 
56     static std::shared_ptr<IPlayBinCtrler> Create(PlayBinKind kind, const PlayBinCreateParam &createParam);
57 
58     virtual int32_t SetSource(const std::string &url) = 0;
59     virtual int32_t SetSource(const std::shared_ptr<GstAppsrcWrap> &appsrcWrap) = 0;
60     virtual int32_t Prepare() = 0; // sync
61     virtual int32_t PrepareAsync() = 0; // async
62     virtual int32_t Play() = 0; // async
63     virtual int32_t Pause() = 0; // async
64     virtual int32_t Seek(int64_t timeUs, int32_t seekOption) = 0; // async
65     virtual int32_t Stop(bool needWait) = 0; // async
66     virtual int32_t SetRate(double rate) = 0;
67     virtual double GetRate() = 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     using ElemSetupListener = std::function<void(GstElement &elem)>;
74     using AutoPlugSortListener = std::function<GValueArray *(GValueArray &factories)>;
75     virtual void SetElemSetupListener(ElemSetupListener listener) = 0;
76     virtual void SetElemUnSetupListener(ElemSetupListener listener) = 0;
77     virtual void SetAutoPlugSortListener(AutoPlugSortListener listener) = 0;
78     virtual void RemoveGstPlaySinkVideoConvertPlugin() = 0;
79     virtual int64_t QueryPosition() = 0;
80     virtual void SetNotifier(PlayBinMsgNotifier notifier) = 0;
81 };
82 } // namespace Media
83 } // namespace OHOS
84 #endif // I_PLAYBIN_CTRLER_H