1 /* 2 * Copyright (c) 2022 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 OHOS_AUDIO_CTRL_TRANSPORT_H 17 #define OHOS_AUDIO_CTRL_TRANSPORT_H 18 19 #include <memory> 20 21 #include "iaudio_ctrl_trans_callback.h" 22 #include "iaudio_ctrl_transport.h" 23 #include "iaudio_channel.h" 24 25 #include "audio_event.h" 26 #include "audio_data.h" 27 #include "daudio_log.h" 28 #include "daudio_errorcode.h" 29 30 namespace OHOS { 31 namespace DistributedHardware { 32 class AudioCtrlTransport : public IAudioCtrlTransport, 33 public IAudioChannelListener, 34 public std::enable_shared_from_this<AudioCtrlTransport> { 35 public: AudioCtrlTransport(const std::string & devId)36 explicit AudioCtrlTransport(const std::string &devId) : devId_(devId) {}; 37 ~AudioCtrlTransport() override = default; 38 39 int32_t SetUp(const std::shared_ptr<IAudioCtrlTransCallback> &callback) override; 40 int32_t Release() override; 41 int32_t Start() override; 42 int32_t Stop() override; 43 int32_t SendAudioEvent(const AudioEvent &event) override; 44 45 void OnSessionOpened() override; 46 void OnSessionClosed() override; 47 void OnDataReceived(const std::shared_ptr<AudioData> &data) override; 48 void OnEventReceived(const AudioEvent &event) override; 49 50 private: 51 int32_t InitAudioCtrlTrans(const std::string &devId); 52 int32_t RegisterChannelListener(); 53 54 private: 55 const std::string devId_; 56 std::weak_ptr<IAudioCtrlTransCallback> ctrlTransCallback_; 57 std::shared_ptr<IAudioChannel> audioChannel_; 58 }; 59 } // namespace DistributedHardware 60 } // namespace OHOS 61 #endif // OHOS_AUDIO_CTRL_TRANSPORT_H 62