This commit is contained in:
wangjiyu 2025-04-16 15:59:45 +08:00
parent e089162220
commit 7c11d681f9
4 changed files with 10 additions and 4 deletions

View File

@ -109,6 +109,9 @@ int sendCustomAudioData(int16_t destChannelIndex, py::object pD,
return -1;
}
}
RetAudioFrame getData() {
return RTCContext::instance().getData();
}
/*
int sendCustomAudioData(const int16_t destChannelIndex, py::object pyData, int32_t sampleRate, uint64_t channelNum,
@ -200,6 +203,7 @@ BOOST_PYTHON_MODULE(rtc_plugins) {
py::def("initSend", &initSend);
py::def("sendCustomAudioData", &sendCustomAudioData);
py::def("getSize", &getSize);
py::def("getData", &getData);
} catch (...) {
PyErr_SetString(PyExc_RuntimeError, "Module initialization failed");
}

View File

@ -58,4 +58,6 @@ while True:
print("resend succ")
size = rtc_plugins.getSize()
print(f"data size:{size}")
time.sleep(30)
frame = rtc_plugins.getData()
print(f"dataCount:{frame.dataCount}")
time.sleep(3)

View File

@ -305,7 +305,7 @@ void printTimestamp() {
// 转换为本地时间(可读格式)
std::time_t time = std::chrono::system_clock::to_time_t(now);
std::cout << "Timestamp: " << timestamp << "." << milliseconds
<< " (Local: " << std::ctime(&time) << ")";
<< " (Local: " << std::ctime(&time) << ")" << std::endl;
}
void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
mrtc::MRTCAudioFrame& audioFrame,

View File

@ -96,6 +96,8 @@ public:
bool initRecv(const char* destRoomId, const char* srcUserId, const int16_t destChannelIndex);
bool initSend(const char* srcRoomId, const char* destRoomId, const int16_t destChannelIndex, const uint8_t channelNum);
int16_t getSize();
void setData(const mrtc::MRTCAudioFrame& frame);
RetAudioFrame getData();
void* getpData() const;
void setpData(void* pData);
@ -137,6 +139,4 @@ private:
void onAudioProcess(const char* roomId, const char* peerId,
mrtc::MRTCAudioFrame& audioFrame, mrtc::MRTCAudioSourceType audioSourceType);
void onProducer(uint32_t msgId, mrtc::MRTCProducerInfo& info);
void setData(const mrtc::MRTCAudioFrame& frame);
RetAudioFrame getData();
};