add debug message on corrupt frames
This commit is contained in:
+5
-8
@@ -158,18 +158,12 @@ const deal_with_data = (session: Session, dv: DataView) => {
|
|||||||
const stream_type = dv.add(12).readU8();
|
const stream_type = dv.add(12).readU8();
|
||||||
if (stream_type == STREAM_TYPE_AUDIO) {
|
if (stream_type == STREAM_TYPE_AUDIO) {
|
||||||
const audio_len = u16_swap(dv.add(8 + 16).readU16());
|
const audio_len = u16_swap(dv.add(8 + 16).readU16());
|
||||||
// may have received the next 'data' packet id as an audio frame -- jpeg was fine
|
|
||||||
if (pkt_id == session.rcvSeqId + 1) {
|
|
||||||
session.rcvSeqId = session.rcvSeqId + 1;
|
|
||||||
}
|
|
||||||
const audio_buf = dv.add(32 + 8).readByteArray(audio_len).buffer; // 8 for pkt header, 32 for `stream_head_t`
|
const audio_buf = dv.add(32 + 8).readByteArray(audio_len).buffer; // 8 for pkt header, 32 for `stream_head_t`
|
||||||
session.eventEmitter.emit("audio", { gap: false, data: Buffer.from(audio_buf) });
|
session.eventEmitter.emit("audio", { gap: false, data: Buffer.from(audio_buf) });
|
||||||
} else if (stream_type == STREAM_TYPE_JPEG) {
|
} else if (stream_type == STREAM_TYPE_JPEG) {
|
||||||
const to_read = pkt_len - 4 - 32;
|
const to_read = pkt_len - 4 - 32;
|
||||||
if (to_read > 0) {
|
if (to_read > 0) {
|
||||||
// some cameras do not send the data with the frame, but rather
|
// some cameras do not send the data with the frame, but rather as a followup message
|
||||||
// as a followup message
|
|
||||||
logger.debug(`Reading ${to_read} bytes - should be 992?`);
|
|
||||||
// skip 8 bytes (drw header) + 32 bytes (data frame)
|
// skip 8 bytes (drw header) + 32 bytes (data frame)
|
||||||
const data = dv.add(32 + 8).readByteArray(to_read);
|
const data = dv.add(32 + 8).readByteArray(to_read);
|
||||||
startNewFrame(data.buffer);
|
startNewFrame(data.buffer);
|
||||||
@@ -200,7 +194,10 @@ const deal_with_data = (session: Session, dv: DataView) => {
|
|||||||
let b = Buffer.from(data.buffer);
|
let b = Buffer.from(data.buffer);
|
||||||
|
|
||||||
if (pkt_id > session.rcvSeqId + 1) {
|
if (pkt_id > session.rcvSeqId + 1) {
|
||||||
session.frame_is_bad = true;
|
if (!session.frame_is_bad) {
|
||||||
|
session.frame_is_bad = true;
|
||||||
|
logger.debug(`Dropping corrupt frame ${pkt_id}, expected ${session.rcvSeqId + 1}`);
|
||||||
|
}
|
||||||
// this should always be enabled but currently it seems to cause more visual distortion
|
// this should always be enabled but currently it seems to cause more visual distortion
|
||||||
// than just missing some frames
|
// than just missing some frames
|
||||||
if (!session.options.attempt_to_fix_packet_loss) {
|
if (!session.options.attempt_to_fix_packet_loss) {
|
||||||
|
|||||||
Reference in New Issue
Block a user