1 2 /* 3 * Copyright (C) 2023 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #pragma once 19 20 #include <aidl/android/hardware/radio/ims/media/BnImsMediaListener.h> 21 #include <aidl/android/hardware/radio/ims/media/BnImsMediaSessionListener.h> 22 #include <aidl/android/hardware/radio/ims/media/IImsMedia.h> 23 #include <aidl/android/hardware/radio/ims/media/IImsMediaSession.h> 24 25 #include "radio_aidl_hal_utils.h" 26 27 #define SERIAL_SET_LISTENER 1 28 #define SERIAL_OPEN_SESSION 2 29 #define SERIAL_CLOSE_SESSION 3 30 #define SERIAL_MODIFY_SESSION 4 31 32 using namespace aidl::android::hardware::radio::ims::media; 33 34 class RadioImsMediaTest; 35 36 /* Listener class for ImsMedia. */ 37 class ImsMediaListener : public BnImsMediaListener { 38 protected: 39 RadioServiceTest& parent_imsmedia; 40 41 public: 42 ImsMediaListener(RadioServiceTest& parent_imsmedialistener); 43 virtual ~ImsMediaListener() = default; 44 45 int32_t mSessionId; 46 std::shared_ptr<::aidl::android::hardware::radio::ims::media::IImsMediaSession> mSession; 47 RtpError mError; 48 49 virtual ndk::ScopedAStatus onOpenSessionSuccess( 50 int32_t in_sessionId, const std::shared_ptr<IImsMediaSession>& in_session) override; 51 virtual ndk::ScopedAStatus onOpenSessionFailure(int32_t in_sessionId, 52 RtpError in_error) override; 53 virtual ndk::ScopedAStatus onSessionClosed(int32_t in_sessionId) override; 54 }; 55 56 /* Listener class for ImsMediaSession. */ 57 class ImsMediaSessionListener : public BnImsMediaSessionListener { 58 protected: 59 RadioServiceTest& parent_imsmedia; 60 61 public: 62 ImsMediaSessionListener(RadioServiceTest& parent_imsmediasessionlistener); 63 virtual ~ImsMediaSessionListener() = default; 64 65 RtpConfig mConfig; 66 RtpError mError; 67 68 virtual ndk::ScopedAStatus onModifySessionResponse(const RtpConfig& in_config, 69 RtpError in_error) override; 70 virtual ndk::ScopedAStatus onFirstMediaPacketReceived(const RtpConfig& in_config) override; 71 virtual ndk::ScopedAStatus onHeaderExtensionReceived( 72 const std::vector<RtpHeaderExtension>& in_extensions) override; 73 virtual ndk::ScopedAStatus notifyMediaQualityStatus( 74 const MediaQualityStatus& in_quality) override; 75 virtual ndk::ScopedAStatus triggerAnbrQuery(const RtpConfig& in_config) override; 76 virtual ndk::ScopedAStatus onDtmfReceived(char16_t in_dtmfDigit, 77 int32_t in_durationMs) override; 78 virtual ndk::ScopedAStatus onCallQualityChanged(const CallQuality& in_callQuality) override; 79 virtual ndk::ScopedAStatus notifyRtpReceptionStats(const RtpReceptionStats& in_stats) override; 80 }; 81 82 /* The main test class for Radio AIDL ImsMedia. */ 83 class RadioImsMediaTest : public RadioServiceTest { 84 protected: 85 virtual void verifyError(RtpError inError); 86 virtual ndk::ScopedAStatus triggerOpenSession(int32_t sessionId); 87 88 public: 89 void SetUp() override; 90 91 /* radio imsmedia service handle */ 92 std::shared_ptr<IImsMedia> radio_imsmedia; 93 /* radio imsmediasession service handle */ 94 std::shared_ptr<IImsMediaSession> radio_imsmediasession; 95 /* radio imsmedia listener handle */ 96 std::shared_ptr<ImsMediaListener> radio_imsmedialistener; 97 /* radio imsmediasession listener handle */ 98 std::shared_ptr<ImsMediaSessionListener> radio_imsmediasessionlistener; 99 }; 100