• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 LPP_VIDEO_SERVICE_STUB_H
17 #define LPP_VIDEO_SERVICE_STUB_H
18 
19 #include "i_standard_lpp_video_streamer_service.h"
20 #include "lpp_video_streamer_server.h"
21 #include "i_lpp_video_streamer_service.h"
22 #include "task_queue.h"
23 
24 namespace OHOS {
25 namespace Media {
26 using PlayerStubFunc = std::function<int32_t(MessageParcel &, MessageParcel &)>;
27 class LppVideoStreamerServiceStub : public IRemoteStub<IStandardLppVideoStreamerService>, public NoCopyable {
28 public:
29     static sptr<LppVideoStreamerServiceStub> Create();
30     ~LppVideoStreamerServiceStub();
31 
32     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
33 
34     int32_t Init(const std::string &mime) override;
35 
36     int32_t SetParameter(const Format &param) override;
37 
38     int32_t Configure(const Format &param) override;
39 
40     int32_t Prepare() override;
41 
42     int32_t Start() override;
43 
44     int32_t Pause() override;
45 
46     int32_t Resume() override;
47 
48     int32_t Flush() override;
49 
50     int32_t Stop() override;
51 
52     int32_t Reset() override;
53 
54     int32_t Release() override;
55 
56     int32_t StartDecode() override;
57 
58     int32_t StartRender() override;
59 
60     int32_t SetOutputSurface(sptr<Surface> surface) override;
61 
62     int32_t SetSyncAudioStreamer(AudioStreamer *audioStreamer) override;
63 
64     int32_t SetTargetStartFrame(const int64_t targetPts, const int timeoutMs) override;
65 
66     int32_t SetVolume(float volume) override;
67 
68     int32_t SetPlaybackSpeed(float speed) override;
69 
70     int32_t ReturnFrames(sptr<LppDataPacket> framePacket) override;
71 
72     int32_t RegisterCallback() override;
73 
74     int32_t SetListenerObject(const sptr<IRemoteObject> &object) override;
75 
76     int32_t SetLppVideoStreamerCallback() override;
77 
78     int32_t SetLppAudioStreamerId(const std::string videoStreamId) override;
79 
80     std::string GetStreamerId() override;
81 
82     int32_t RenderFirstFrame() override;
83 
84     int32_t Init();
85     void SetPlayerFuncs();
86     void FillPlayerFuncPart1();
87 
88 private:
89     LppVideoStreamerServiceStub();
90 
91 public:
92     int32_t Init(MessageParcel &data, MessageParcel &reply);
93     int32_t SetParameter(MessageParcel &data, MessageParcel &reply);
94     int32_t Configure(MessageParcel &data, MessageParcel &reply);
95     int32_t Prepare(MessageParcel &data, MessageParcel &reply);
96     int32_t Start(MessageParcel &data, MessageParcel &reply);
97     int32_t Pause(MessageParcel &data, MessageParcel &reply);
98     int32_t Resume(MessageParcel &data, MessageParcel &reply);
99     int32_t Flush(MessageParcel &data, MessageParcel &reply);
100     int32_t Stop(MessageParcel &data, MessageParcel &reply);
101     int32_t Reset(MessageParcel &data, MessageParcel &reply);
102     int32_t Release(MessageParcel &data, MessageParcel &reply);
103     int32_t SetVolume(MessageParcel &data, MessageParcel &reply);
104     int32_t StartDecode(MessageParcel &data, MessageParcel &reply);
105     int32_t StartRender(MessageParcel &data, MessageParcel &reply);
106     int32_t SetOutputSurface(MessageParcel &data, MessageParcel &reply);
107     int32_t SetSyncAudioStreamer(MessageParcel &data, MessageParcel &reply);
108     int32_t SetTargetStartFrame(MessageParcel &data, MessageParcel &reply);
109     int32_t SetPlaybackSpeed(MessageParcel &data, MessageParcel &reply);
110     int32_t ReturnFrames(MessageParcel &data, MessageParcel &reply);
111     int32_t RegisterCallback(MessageParcel &data, MessageParcel &reply);
112     int32_t SetListenerObject(MessageParcel &data, MessageParcel &reply);
113     int32_t SetLppVideoStreamerCallback(MessageParcel &data, MessageParcel &reply);
114     int32_t SetLppAudioStreamerId(MessageParcel &data, MessageParcel &reply);
115     int32_t GetStreamerId(MessageParcel &data, MessageParcel &reply);
116     int32_t RenderFirstFrame(MessageParcel &data, MessageParcel &reply);
117 
118     std::shared_ptr<ILppVideoStreamerService> lppVideoPlayerServer_ = nullptr;
119     std::map<uint32_t, std::pair<std::string, PlayerStubFunc>> playerFuncs_;
120     std::shared_ptr<VideoStreamerCallback> playerCallback_ = nullptr;
121     sptr<LppDataPacket> framePacket_ = nullptr;
122     TaskQueue taskQue_;
123 };
124 }  // namespace Media
125 }  // namespace OHOS
126 #endif  // LPP_VIDEO_SERVICE_STUB_H
127