feat: ios端xp2p添加事件监听回调

This commit is contained in:
fanpeng 2025-07-01 15:33:58 +08:00
parent a01ac4a237
commit 5859f78b36
3 changed files with 41 additions and 3 deletions

View File

@ -81,7 +81,7 @@
listenerUI: {
cameraRotation: 270,
objectFit: 'fill',
enableToggleCamera: false
enableToggleCamera: true
}
})
wmpfVoip.setVoipEndPagePath({

View File

@ -104,7 +104,6 @@
"modules" : {
"Bluetooth" : {},
"VideoPlayer" : {},
"LivePusher" : {},
"Camera" : {},
"Record" : {}
},

View File

@ -4,6 +4,42 @@
import { Result } from '../interface.uts'
function avRecvHandle(
id: Optional<UnsafePointer<Int8>>,
recv_buf: Optional<UnsafeMutablePointer<UInt8>>,
recv_len: Int
) {
if (id != null) {
const idString = P2PConversionHelper.cStringToString(id)
// console.log(`avRecvHandle: ${idString}`)
}
}
function msgHandle(
id: Optional<UnsafePointer<Int8>>,
type: XP2PType,
msg: Optional<UnsafePointer<Int8>>
): Optional<UnsafePointer<Int8>> {
const idString = id != null ? P2PConversionHelper.cStringToString(id) : ''
const msgString = msg != null ? P2PConversionHelper.cStringToString(msg) : ''
if (type == XP2PTypeLog) {
console.log(`${msgString}`)
}
return null
}
function deviceDataHandle(
id: Optional<UnsafePointer<Int8>>,
recv_buf: Optional<UnsafeMutablePointer<UInt8>>,
recv_len: Int
): Optional<UnsafeMutablePointer<Int8>> {
if (id != null) {
const idString = P2PConversionHelper.cStringToString(id)
// console.log(`deviceDataHandle: ${idString}, len: ${recv_len}`)
}
return null
}
export const startServiceFunction = async function (
appKey: string,
appSecret: string,
@ -18,7 +54,10 @@ export const startServiceFunction = async function (
config.ip = UnsafePointer(strdup('')!)
config.port = 20002
config.type = XP2P_PROTOCOL_AUTO
config.cross = false
config.cross = true
// 设置回调
setUserCallbackToXp2p(avRecvHandle, msgHandle, deviceDataHandle)
const result = startService(`${productId}/${deviceName}`, productId, deviceName, config)