Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/65-is-the-rtmp-chunk-type-not-fu…
Browse files Browse the repository at this point in the history
…lly-supported' into fix_71
  • Loading branch information
hailiang8 committed Nov 10, 2023
2 parents f38d38a + 646c077 commit 5dac8d2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions protocol/rtmp/src/chunk/packetizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ impl ChunkPacketizer {
}
fn zip_chunk_header(&mut self, chunk_info: &mut ChunkInfo) -> Result<PackResult, PackError> {
chunk_info.basic_header.format = 0;
//save the header data for update
let cur_chunk_header = ChunkHeader {
basic_header: chunk_info.basic_header.clone(),
message_header: chunk_info.message_header.clone(),
};

let pre_header = self
if let Some(pre_header) = self
.csid_2_chunk_header
.get_mut(&chunk_info.basic_header.chunk_stream_id);

if let Some(val) = pre_header {
.get_mut(&chunk_info.basic_header.chunk_stream_id)
{
let cur_msg_header = &mut chunk_info.message_header;
let pre_msg_header = &val.message_header;
let pre_msg_header = &mut pre_header.message_header;

if cur_msg_header.msg_streamd_id == pre_msg_header.msg_streamd_id {
chunk_info.basic_header.format = 1;
Expand All @@ -53,12 +57,16 @@ impl ChunkPacketizer {
&& cur_msg_header.msg_length == pre_msg_header.msg_length
{
chunk_info.basic_header.format = 2;
if chunk_info.message_header.timestamp == pre_msg_header.timestamp {
if cur_msg_header.timestamp == pre_msg_header.timestamp {
chunk_info.basic_header.format = 3;
}
}
}
}
//update pre header
self.csid_2_chunk_header
.insert(chunk_info.basic_header.chunk_stream_id, cur_chunk_header);

Ok(PackResult::Success)
}

Expand Down Expand Up @@ -101,6 +109,7 @@ impl ChunkPacketizer {
self.writer.write_u24::<BigEndian>(timestamp)?;
self.writer
.write_u24::<BigEndian>(message_header.msg_length)?;
self.writer.write_u8(message_header.msg_type_id)?;
}
2 => {
self.writer.write_u24::<BigEndian>(timestamp)?;
Expand Down

0 comments on commit 5dac8d2

Please sign in to comment.