Teach you how to integrate audio and video functions of SonicNet from scratch (iOS version)

illustrate

1. Huanxin audio and video and Acoustics audio and video are two different systems, so if you want to switch, you need to integrate the SDK of Acoustics, and the sdk of Huanxin audio and video can be discarded directly

2. The article will introduce how to use the audio and video of the sound network to run through the demo, so that you can understand the entire audio and video call process,

3. The article will introduce how to add audio and video functions to the integrated sound network after the Huanxin im function has been integrated

prerequisite

1. Have Huanxin developer account and Shengwang developer account

2. macOS system, installed xcode integrated environment

Run through Demo

1. Download iOS Demo address: https://www.easemob.com/download/im
insert image description here

2. I downloaded the 4.0.3 version here. If your Xcode version runs the demo and reports an error, first find the podfile file to open the comment, and add: , config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0’as shown below, in pod install
insert image description here

3. For the convenience of testing, you can first configure this appkey as your own
insert image description here

4. Click the version number continuously, switch to the account password to log in, and the im part is completed here
insert image description here

Build an App Server to generate a voice network token

1. Refer to the documentation to build the APP server: https://docportal.shengwang.cn/cn/live-streaming-standard-legacy/token_server?platform=Android#%E5%AE%9E%E7%8E%B0%E9%89%B4%E6%9D%83%E6%B5%81%E7%A8%8BCopy
all of them and replace them with your own appid and appCertific ate
insert image description here

2. If Starting server at port 8082 appears, it means the build is successful
insert image description here

3. In the picture below, replace it with the appid of your own voice network
insert image description here

4. Make some changes in the callDidRequestRTCTokenForAppId method, mainly replacing it with the token generated by your own server.
insert image description here

5. After the above modifications are completed, audio and video calls can be made. If the call is normal, you can go to the console of the sound network to see the call record.
insert image description here

Congratulations on running through the demo

Integrate SoundNet into existing projects

Note: If you have integrated the audio and video of Huanxin before, then just discard it and integrate the audio and video of the sound network from the beginning. I will start from a new project here.

1. Create a new project, add the corresponding library, pod install, add microphone and camera permissions
insert image description here

2. Initialize the ring letter in the AppDelegate file
insert image description here

3. Use xib to create several controls and bind them
insert image description here

4. Call the login operation in the login click event, and initialize the EaseCallManager class after the login is successful

Note: EaseCallManager can only be initialized after successful login, otherwise an error will be reported when initiating a call

insert image description here

5. To implement the EaseCallDelegate proxy method, you need to obtain the token of the APPserver in the callDidRequestRTCToken callback and set it, as shown in the figure below
insert image description here

6. Initiate a one-to-one video call in the call method, as shown in the figure below
insert image description here

So far the code is complete, you can run it on two devices to check the effect, if the video call can be made normally, then congratulations on the successful integration

Summarize

1. Create an im project in the Huanxin console and get the appkey

2. Create an audio and video project on the SoundNet console to get the appid and appCertificate

3. Refer to the APPserver example in go language given by Shengwang, copy all of them, fill in the appid and appCertificate of Shengwang, and run it directly

4. Create an iOS project and integrate

pod 'AgoraRtcEngine_iOS/RtcBasic' //声网音视频库

pod 'HyphenateChat', '~> 4.0.3' //环信im库

pod 'EaseCallKit' //环信IMSDK作为信令封装的声网音视频SDK通话带UI组件库

These three libraries

5. In the AppDelegate file, initialize the ring letter and fill in the appkey of the ring letter

6. Initialize EaseCallManager in the successful login method

7. Initiate a video call invitation

8. Both the inviter and the invitee will use func callDidRequestRTCToken(forAppId aAppId: String, channelName aChannelName: String, account aUserAccount: String, uid aAgoraUid: Int) to trigger this callback before joining the audio and video call channel, obtain their respective voice network tokens in this callback function, and then call the setRTCToken:channelName: method to set the token
in

complete

reference link

Register Huanxin: https://console.easemob.com/user/registerOfficial
Demo download: https://www.easemob.com/download/imMore
integration tutorials: https://www.imgeek.net/video/

Guess you like

Origin blog.csdn.net/huan132456765/article/details/131682796