Skip to content

Commit f06b8bd

Browse files
authored
Merge pull request #332 from webrtc-rs/fix/ext-serialize
Marshalled extension types derive Serialize/Deserialize
2 parents 3bd134f + 4e9df79 commit f06b8bd

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

rtp/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ bytes = "1"
1717
rand = "0.8.5"
1818
thiserror = "1.0"
1919
async-trait = "0.1.56"
20+
serde = { version = "1.0.102", features = ["derive"] }
2021

2122
[dev-dependencies]
2223
chrono = "0.4.19"

rtp/src/extension/audio_level_extension/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
mod audio_level_extension_test;
33

44
use crate::error::Error;
5+
use serde::{Deserialize, Serialize};
56
use util::marshal::{Marshal, MarshalSize, Unmarshal};
67

78
use bytes::{Buf, BufMut};
@@ -28,7 +29,7 @@ pub const AUDIO_LEVEL_EXTENSION_SIZE: usize = 1;
2829
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2930
/// | ID | len=1 |V| level | 0 (pad) |
3031
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31-
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
32+
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone, Serialize, Deserialize)]
3233
pub struct AudioLevelExtension {
3334
pub level: u8,
3435
pub voice: bool,

rtp/src/extension/transport_cc_extension/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
mod transport_cc_extension_test;
33

44
use crate::error::Error;
5+
use serde::{Deserialize, Serialize};
56
use util::marshal::{Marshal, MarshalSize, Unmarshal};
67

78
use bytes::{Buf, BufMut};
@@ -18,7 +19,7 @@ pub const TRANSPORT_CC_EXTENSION_SIZE: usize = 2;
1819
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1920
/// | ID | L=1 |transport-wide sequence number | zero padding |
2021
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
21-
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
22+
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone, Serialize, Deserialize)]
2223
pub struct TransportCcExtension {
2324
pub transport_sequence: u16,
2425
}

rtp/src/extension/video_orientation_extension/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod video_orientation_extension_test;
44
use std::convert::{TryFrom, TryInto};
55

66
use bytes::BufMut;
7+
use serde::{Deserialize, Serialize};
78
use util::{marshal::Unmarshal, Marshal, MarshalSize};
89

910
use crate::Error;
@@ -34,20 +35,20 @@ pub const VIDEO_ORIENTATION_EXTENSION_SIZE: usize = 1;
3435
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3536
/// | ID | len=0 |0 0 0 0 C F R R|
3637
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37-
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
38+
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone, Serialize, Deserialize)]
3839
pub struct VideoOrientationExtension {
3940
pub direction: CameraDirection,
4041
pub flip: bool,
4142
pub rotation: VideoRotation,
4243
}
4344

44-
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
45+
#[derive(PartialEq, Eq, Debug, Copy, Clone, Serialize, Deserialize)]
4546
pub enum CameraDirection {
4647
Front = 0,
4748
Back = 1,
4849
}
4950

50-
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
51+
#[derive(PartialEq, Eq, Debug, Copy, Clone, Serialize, Deserialize)]
5152
pub enum VideoRotation {
5253
Degree0 = 0,
5354
Degree90 = 1,

webrtc/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
directions that should not send. [#316](https://github.com/webrtc-rs/webrtc/pull/316)
1010
* Add support for a mime type "audio/telephone-event" (rfc4733) [#322](https://github.com/webrtc-rs/webrtc/pull/322)
1111
* 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).
12+
* 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)
13+
1214

1315
#### Breaking changes
1416

0 commit comments

Comments
 (0)