Skip to content

Commit

Permalink
Merge pull request #332 from webrtc-rs/fix/ext-serialize
Browse files Browse the repository at this point in the history
Marshalled extension types derive Serialize/Deserialize
  • Loading branch information
algesten authored Oct 26, 2022
2 parents 3bd134f + 4e9df79 commit f06b8bd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions rtp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ bytes = "1"
rand = "0.8.5"
thiserror = "1.0"
async-trait = "0.1.56"
serde = { version = "1.0.102", features = ["derive"] }

[dev-dependencies]
chrono = "0.4.19"
Expand Down
3 changes: 2 additions & 1 deletion rtp/src/extension/audio_level_extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
mod audio_level_extension_test;

use crate::error::Error;
use serde::{Deserialize, Serialize};
use util::marshal::{Marshal, MarshalSize, Unmarshal};

use bytes::{Buf, BufMut};
Expand All @@ -28,7 +29,7 @@ pub const AUDIO_LEVEL_EXTENSION_SIZE: usize = 1;
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | ID | len=1 |V| level | 0 (pad) |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone, Serialize, Deserialize)]
pub struct AudioLevelExtension {
pub level: u8,
pub voice: bool,
Expand Down
3 changes: 2 additions & 1 deletion rtp/src/extension/transport_cc_extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
mod transport_cc_extension_test;

use crate::error::Error;
use serde::{Deserialize, Serialize};
use util::marshal::{Marshal, MarshalSize, Unmarshal};

use bytes::{Buf, BufMut};
Expand All @@ -18,7 +19,7 @@ pub const TRANSPORT_CC_EXTENSION_SIZE: usize = 2;
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | ID | L=1 |transport-wide sequence number | zero padding |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone, Serialize, Deserialize)]
pub struct TransportCcExtension {
pub transport_sequence: u16,
}
Expand Down
7 changes: 4 additions & 3 deletions rtp/src/extension/video_orientation_extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod video_orientation_extension_test;
use std::convert::{TryFrom, TryInto};

use bytes::BufMut;
use serde::{Deserialize, Serialize};
use util::{marshal::Unmarshal, Marshal, MarshalSize};

use crate::Error;
Expand Down Expand Up @@ -34,20 +35,20 @@ pub const VIDEO_ORIENTATION_EXTENSION_SIZE: usize = 1;
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | ID | len=0 |0 0 0 0 C F R R|
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone, Serialize, Deserialize)]
pub struct VideoOrientationExtension {
pub direction: CameraDirection,
pub flip: bool,
pub rotation: VideoRotation,
}

#[derive(PartialEq, Eq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone, Serialize, Deserialize)]
pub enum CameraDirection {
Front = 0,
Back = 1,
}

#[derive(PartialEq, Eq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone, Serialize, Deserialize)]
pub enum VideoRotation {
Degree0 = 0,
Degree90 = 1,
Expand Down
2 changes: 2 additions & 0 deletions webrtc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
directions that should not send. [#316](https://github.com/webrtc-rs/webrtc/pull/316)
* Add support for a mime type "audio/telephone-event" (rfc4733) [#322](https://github.com/webrtc-rs/webrtc/pull/322)
* Fixed a panic that would sometimes happen when collecting stats. [#327](https://github.com/webrtc-rs/webrtc/pull/327) by [@k0nserv](https://github.com/k0nserv).
* Added new extension marshaller/unmarshaller for VideoOrientation, and made marshallers serializable via serde [#331](https://github.com/webrtc-rs/webrtc/pull/331) [#332](https://github.com/webrtc-rs/webrtc/pull/332)


#### Breaking changes

Expand Down

0 comments on commit f06b8bd

Please sign in to comment.