rtc_plugins/test_time_r.py

34 lines
1.1 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:35:06 +08:00
srcUserId = "srcUser12"
destUserId = "destUser12"
2025-04-14 16:38:06 +08:00
2025-04-14 17:35:06 +08:00
srcDisplayName = "srcDisplayName12"
destDisplayName = "destDisplayName12"
srcRoomId = "srcRoom12"
destRoomId = "destRoomId12"
srcChannelIndex = 46
destChannelIndex = 47
2025-04-14 17:02:42 +08:00
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 18:24:16 +08:00
ret = rtc_plugins.initSend(destRoomId, 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:
2025-04-14 17:47:39 +08:00
print("recv")
2025-04-14 17:02:42 +08:00
time.sleep(3)