Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more packet details for rtp 2110 #11

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 84 additions & 2 deletions src/bin/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,39 @@ fn process_smpte2110_packet(packet: &[u8]) -> Vec<Vec<u8>> {
let timestamp = u32::from_be_bytes([packet[start + 4], packet[start + 5], packet[start + 6], packet[start + 7]]);
let ssrc = u32::from_be_bytes([packet[start + 8], packet[start + 9], packet[start + 10], packet[start + 11]]);

// Extract the payload type from the RTP header
let payload_type = packet[start + 1] & 0x7F;

// Extract the marker bit from the RTP header
let marker_bit = (packet[start + 1] & 0x80) >> 7;

// Check if interlaced video
let interlaced = (packet[start + 12] & 0x80) >> 7;

// Check if UHD
let uhd = (packet[start + 12] & 0x40) >> 6;

// Check if 10-bit
let ten_bit = (packet[start + 12] & 0x20) >> 5;

// Check if 422
let four_two_two = (packet[start + 12] & 0x10) >> 4;

// Check if 444
let four_four_four = (packet[start + 12] & 0x08) >> 3;

// Construct JSON object with RTP header information
let rtp_header_info = json!({
"sequence_number": sequence_number,
"timestamp": timestamp,
"ssrc": ssrc
"ssrc": ssrc,
"payload_type": payload_type,
"marker_bit": marker_bit,
"interlaced": interlaced,
"uhd": uhd,
"ten_bit": ten_bit,
"four_two_two": four_two_two,
"four_four_four": four_four_four
});

// Print out the JSON structure
Expand All @@ -331,9 +359,63 @@ fn process_mpegts_packet(packet: &[u8]) -> Vec<Vec<u8>> {
// Extract the PID from the MPEG-TS header
let pid = ((chunk[1] as u16 & 0x1F) << 8) | chunk[2] as u16;

// Extract the continuity counter from the MPEG-TS header
let continuity_counter = chunk[3] & 0x0F;

// Extract the adaptation field control from the MPEG-TS header
let adaptation_field_control = (chunk[3] & 0x30) >> 4;

// Extract the payload unit start indicator from the MPEG-TS header
let payload_unit_start_indicator = chunk[1] & 0x40;

// Extract the transport scrambling control from the MPEG-TS header
let transport_scrambling_control = (chunk[3] & 0xC0) >> 6;

// Extract the transport error indicator from the MPEG-TS header
let transport_error_indicator = chunk[1] & 0x80;

// Extract the transport priority from the MPEG-TS header
let transport_priority = chunk[2] & 0x20;

// Extract the transport private data from the MPEG-TS header
let transport_private_data = chunk[2] & 0x80;

// extract the timestamp from the MPEG-TS header
let timestamp = ((chunk[4] as u64) << 25) | ((chunk[5] as u64) << 17) | ((chunk[6] as u64) << 9) | ((chunk[7] as u64) << 1) | ((chunk[8] as u64) >> 7);

/*
// extrace the interlaced status from the MPEG-TS header
let interlaced = chunk[8] & 0x40;

// extract the uhd status from the MPEG-TS header
let uhd = chunk[8] & 0x20;

// extract the 10-bit status from the MPEG-TS header
let ten_bit = chunk[8] & 0x10;

// extract the 422 status from the MPEG-TS header
let four_two_two = chunk[8] & 0x08;

// extract the 444 status from the MPEG-TS header
let four_four_four = chunk[8] & 0x04;
*/

// Construct JSON object with MPEG-TS header information
let mpegts_header_info = json!({
"pid": pid
"pid": pid,
"continuity_counter": continuity_counter,
"adaptation_field_control": adaptation_field_control,
"payload_unit_start_indicator": payload_unit_start_indicator,
"transport_scrambling_control": transport_scrambling_control,
"transport_error_indicator": transport_error_indicator,
"transport_priority": transport_priority,
"transport_private_data": transport_private_data,
"timestamp": timestamp,
/*"interlaced": interlaced,
"uhd": uhd,
"ten_bit": ten_bit,
"four_two_two": four_two_two,
"four_four_four": four_four_four*/
});

// Print out the JSON structure
Expand Down