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_PLAYER_SERVICE_STUB_H 17 #define LPP_PLAYER_SERVICE_STUB_H 18 19 #include "i_standard_lpp_audio_streamer_service.h" 20 #include "lpp_audio_streamer_server.h" 21 #include "task_queue.h" 22 23 namespace OHOS { 24 namespace Media { 25 using PlayerStubFunc = std::function<int32_t(MessageParcel &, MessageParcel &)>; 26 class LppAudioStreamerServiceStub : public IRemoteStub<IStandardLppAudioStreamerService>, public NoCopyable { 27 public: 28 static sptr<LppAudioStreamerServiceStub> Create(); 29 ~LppAudioStreamerServiceStub(); 30 31 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 32 33 int32_t Init(const std::string &mime) override; 34 35 int32_t SetParameter(const Format ¶m) override; 36 37 int32_t Configure(const Format ¶m) override; 38 39 int32_t Prepare() override; 40 41 int32_t Start() override; 42 43 int32_t Pause() override; 44 45 int32_t Resume() override; 46 47 int32_t Flush() override; 48 49 int32_t Stop() override; 50 51 int32_t Reset() override; 52 53 int32_t Release() override; 54 55 int32_t SetVolume(float volume) override; 56 57 int32_t SetPlaybackSpeed(float speed) override; 58 59 int32_t ReturnFrames(sptr<LppDataPacket> framePacket) override; 60 61 int32_t RegisterCallback() override; 62 63 int32_t SetListenerObject(const sptr<IRemoteObject> &object) override; 64 65 int32_t SetLppAudioStreamerCallback() override; 66 67 std::string GetStreamerId() override; 68 69 int32_t SetLppVideoStreamerId(const std::string videoStreamId) override; 70 71 int32_t Init(); 72 void SetPlayerFuncs(); 73 void FillPlayerFuncPart1(); 74 75 private: 76 LppAudioStreamerServiceStub(); 77 78 public: 79 int32_t Init(MessageParcel &data, MessageParcel &reply); 80 int32_t SetParameter(MessageParcel &data, MessageParcel &reply); 81 int32_t Configure(MessageParcel &data, MessageParcel &reply); 82 int32_t Prepare(MessageParcel &data, MessageParcel &reply); 83 int32_t Start(MessageParcel &data, MessageParcel &reply); 84 int32_t Pause(MessageParcel &data, MessageParcel &reply); 85 int32_t Resume(MessageParcel &data, MessageParcel &reply); 86 int32_t Flush(MessageParcel &data, MessageParcel &reply); 87 int32_t Stop(MessageParcel &data, MessageParcel &reply); 88 int32_t Reset(MessageParcel &data, MessageParcel &reply); 89 int32_t Release(MessageParcel &data, MessageParcel &reply); 90 int32_t SetVolume(MessageParcel &data, MessageParcel &reply); 91 int32_t SetPlaybackSpeed(MessageParcel &data, MessageParcel &reply); 92 int32_t ReturnFrames(MessageParcel &data, MessageParcel &reply); 93 int32_t RegisterCallback(MessageParcel &data, MessageParcel &reply); 94 int32_t SetListenerObject(MessageParcel &data, MessageParcel &reply); 95 int32_t SetLppAudioStreamerCallback(MessageParcel &data, MessageParcel &reply); 96 int32_t SetLppVideoStreamerId(MessageParcel &data, MessageParcel &reply); 97 int32_t GetStreamerId(MessageParcel &data, MessageParcel &reply); 98 99 std::shared_ptr<ILppAudioStreamerService> lppAudioPlayerServer_ = nullptr; 100 std::map<uint32_t, std::pair<std::string, PlayerStubFunc>> playerFuncs_; 101 std::shared_ptr<AudioStreamerCallback> playerCallback_ = nullptr; 102 sptr<LppDataPacket> framePacket_ = nullptr; 103 TaskQueue taskQue_; 104 }; 105 } // namespace Media 106 } // namespace OHOS 107 #endif // PLAYER_SERVICE_STUB_H 108