Skip to content

Commit ed54e62

Browse files
author
Thomas
committed
catch repacketizer exceptions
1 parent d761de9 commit ed54e62

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/libdatachannel/src/webrtc_device_rtsp/rtsp-client/tcp_rtp_client.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ size_t TcpRtpClient::rtp_write(void* ptr, size_t size, size_t nmemb,
140140
std::lock_guard<std::mutex> lock(self->mutex_);
141141
if (self->videoTrack_ != nullptr && self->videoTrack_->isOpen()) {
142142
uint8_t* buf = ((uint8_t*)ptr) + 4;
143-
auto packets = self->videoRepacketizer_->handlePacket(
144-
std::vector<uint8_t>(buf, buf + dataLen));
145143
try {
144+
auto packets = self->videoRepacketizer_->handlePacket(
145+
std::vector<uint8_t>(buf, buf + dataLen));
146146
for (auto p : packets) {
147147
self->videoTrack_->send((rtc::byte*)p.data(), p.size());
148148
}
@@ -152,6 +152,10 @@ size_t TcpRtpClient::rtp_write(void* ptr, size_t size, size_t nmemb,
152152
// condition. Both us and libdatachannel have mutex protection, so this
153153
// will not be a memory issue. However, libdatachannel can still change
154154
// the Open state between the check above and this.
155+
156+
// We have also observed a runtime error from the repacketizer due to
157+
// mistakenly sending H265 data instead of H264. Since the uncaught
158+
// exception will crash the device, we need to catch it as well.
155159
NPLOGE << "Caught send runtime error: " << err.what();
156160
}
157161
}

0 commit comments

Comments
 (0)