rtc_plugins/test_time_r.py

33 lines
1.0 KiB
Python
Raw Normal View History

2025-04-14 16:38:06 +08:00
import rtc_plugins
import time
import numpy as np
2025-04-14 17:02:42 +08:00
srcUserId = "srcUser1"
destUserId = "destUser1"
2025-04-14 16:38:06 +08:00
2025-04-14 17:02:42 +08:00
srcDisplayName = "srcDisplayName1"
destDisplayName = "destDisplayName1"
srcRoomId = "srcRoom1"
destRoomId = "destRoomId1"
srcChannelIndex = 42
destChannelIndex = 43
def my_callback(npData, dataSize, dataCount, sampleRate, numChannels, channelIndex):
print(f"dataSize:{dataSize}, dataCount:{dataCount}, sampleRate:{sampleRate}, numChannels:{numChannels}, channelIndex:{channelIndex}")
2025-04-14 16:38:06 +08:00
audioData = np.array([0, 1, -1, 0], dtype=np.int16)
2025-04-14 17:02:42 +08:00
ret = rtc_plugins.sendCustomAudioData(srcChannelIndex, audioData, 48000, 1, len(audioData))
ret = rtc_plugins.init(destUserId, destDisplayName, destRoomId, my_callback)
2025-04-14 16:38:06 +08:00
if ret != 0:
print(f"init fail, ret:{ret}")
exit(1)
2025-04-14 17:02:42 +08:00
ret = rtc_plugins.initRecv(destRoomId, srcUserId, destChannelIndex)
2025-04-14 16:38:06 +08:00
if ret != 0:
2025-04-14 17:02:42 +08:00
print(f"initRecv fail, ret:{ret}")
2025-04-14 16:38:06 +08:00
exit(1)
2025-04-14 17:02:42 +08:00
ret = rtc_plugins.initSend(srcRoomId, srcChannelIndex)
2025-04-14 16:38:06 +08:00
if ret != 0:
2025-04-14 17:02:42 +08:00
print(f"initSend fail, ret:{ret}")
2025-04-14 16:38:06 +08:00
exit(1)
2025-04-14 17:02:42 +08:00
while True:
time.sleep(3)