Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit ef63dde

Browse files
committed
add marshal and upgrade to v0.6.1
1 parent 337e84e commit ef63dde

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rtcp"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
authors = ["Rain Liu <[email protected]>", "Michael Uti <[email protected]>"]
55
edition = "2018"
66
description = "A pure Rust implementation of RTCP"

src/packet.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
use util::marshal::{Marshal, Unmarshal};
1212

1313
use crate::extended_report::ExtendedReport;
14-
use bytes::Buf;
14+
use bytes::{Buf, BufMut, Bytes, BytesMut};
1515
use std::any::Any;
1616
use std::fmt;
1717

@@ -38,6 +38,16 @@ impl Clone for Box<dyn Packet + Send + Sync> {
3838
}
3939
}
4040

41+
/// marshal takes an array of Packets and serializes them to a single buffer
42+
pub fn marshal(packets: &[Box<dyn Packet + Send + Sync>]) -> Result<Bytes> {
43+
let mut out = BytesMut::new();
44+
for p in packets {
45+
let data = p.marshal()?;
46+
out.put(data);
47+
}
48+
Ok(out.freeze())
49+
}
50+
4151
/// Unmarshal takes an entire udp datagram (which may consist of multiple RTCP packets) and
4252
/// returns the unmarshaled packets it contains.
4353
///

0 commit comments

Comments
 (0)