新增webrtc播放器datachannel消息广播机制和接口

This commit is contained in:
xia-chu
2023-09-02 12:53:56 +08:00
parent 39dd886ec1
commit e3e7495c90
7 changed files with 52 additions and 1 deletions

View File

@@ -71,6 +71,21 @@ void WebRtcPlayer::onStartWebRTC() {
}
strong_self->onShutdown(SockException(Err_shutdown, "rtsp ring buffer detached"));
});
_reader->setMessageCB([weak_self] (const toolkit::Any &data) {
auto strong_self = weak_self.lock();
if (!strong_self) {
return;
}
if (data.is<Buffer>()) {
auto &buffer = data.get<Buffer>();
// PPID 51: 文本string
// PPID 53: 二进制
strong_self->sendDatachannel(0, 51, buffer.data(), buffer.size());
} else {
WarnL << "Send unknown message type to webrtc player: " << data.type_name();
}
});
}
}
void WebRtcPlayer::onDestory() {