Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### NEXT

- Bump up Meson from 1.5.0 to 1.9.1 ([PR #1634](https://github.com/versatica/mediasoup/pull/1634)).
- `RtpParameters`: Add `msid` optional field ([PR #1634](https://github.com/versatica/mediasoup/pull/1634)).

### 3.19.6

- AV1: Set DependencyDescriptor Header Extension to 'recvonly' but forward it between pipe transports ([#1632](https://github.com/versatica/mediasoup/pull/1632)).
Expand Down
10 changes: 10 additions & 0 deletions node/src/ortc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ export function validateRtpParameters(params: RtpParameters): void {
params.rtcp = {};
}

// msid is optional.
if (params.msid && typeof params.msid !== 'string') {
throw new TypeError('params.msid is not a string');
}

validateRtcpParameters(params.rtcp);
}

Expand Down Expand Up @@ -454,6 +459,7 @@ export function getConsumableRtpParameters(
headerExtensions: [],
encodings: [],
rtcp: {},
msid: undefined,
};

for (const codec of params.codecs) {
Expand Down Expand Up @@ -542,6 +548,8 @@ export function getConsumableRtpParameters(
reducedSize: true,
};

consumableParams.msid = params.msid;

return consumableParams;
}

Expand Down Expand Up @@ -600,6 +608,7 @@ export function getConsumerRtpParameters({
headerExtensions: [],
encodings: [],
rtcp: consumableRtpParameters.rtcp,
msid: consumableRtpParameters.msid,
};

for (const capCodec of remoteRtpCapabilities.codecs!) {
Expand Down Expand Up @@ -790,6 +799,7 @@ export function getPipeConsumerRtpParameters({
headerExtensions: [],
encodings: [],
rtcp: consumableRtpParameters.rtcp,
msid: consumableRtpParameters.msid,
};

const consumableCodecs =
Expand Down
12 changes: 7 additions & 5 deletions node/src/rtpParametersFbsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ export function serializeRtpParameters(
);

const midOffset = builder.createString(rtpParameters.mid);
const msidOffset = builder.createString(rtpParameters.msid);

FbsRtpParameters.startRtpParameters(builder);
FbsRtpParameters.addMid(builder, midOffset);
FbsRtpParameters.addCodecs(builder, codecsOffset);

FbsRtpParameters.addHeaderExtensions(builder, headerExtensionsOffset);
FbsRtpParameters.addEncodings(builder, encodingsOffset);
FbsRtpParameters.addRtcp(builder, rtcpOffset);
FbsRtpParameters.addMsid(builder, msidOffset);

return FbsRtpParameters.endRtpParameters(builder);
}
Expand Down Expand Up @@ -494,12 +495,12 @@ export function parseRtpEncodingParameters(
): RtpEncodingParameters {
return {
ssrc: data.ssrc() ?? undefined,
rid: data.rid() ?? undefined,
rid: data.rid() || undefined,
Comment on lines -497 to +498
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because if rid is empty string we want it to become undefined. Same in all similar changes below.

codecPayloadType:
data.codecPayloadType() !== null ? data.codecPayloadType()! : undefined,
rtx: data.rtx() ? { ssrc: data.rtx()!.ssrc() } : undefined,
dtx: data.dtx(),
scalabilityMode: data.scalabilityMode() ?? undefined,
scalabilityMode: data.scalabilityMode() || undefined,
maxBitrate: data.maxBitrate() !== null ? data.maxBitrate()! : undefined,
};
}
Expand Down Expand Up @@ -533,16 +534,17 @@ export function parseRtpParameters(data: FbsRtpParameters): RtpParameters {
const fbsRtcp = data.rtcp()!;

rtcp = {
cname: fbsRtcp.cname() ?? undefined,
cname: fbsRtcp.cname() || undefined,
reducedSize: fbsRtcp.reducedSize(),
};
}

return {
mid: data.mid() ?? undefined,
mid: data.mid() || undefined,
codecs,
headerExtensions,
encodings,
rtcp,
msid: data.msid() || undefined,
};
}
6 changes: 6 additions & 0 deletions node/src/rtpParametersTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ export type RtpParameters = {
* Parameters used for RTCP.
*/
rtcp?: RtcpParameters;
/**
* MSID (WebRTC MediaStream Identification).
*
* @see https://datatracker.ietf.org/doc/html/rfc8830
*/
msid?: string;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion node/src/rtpStreamStatsFbsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function parseBaseStreamStats(
timestamp: Number(binary.timestamp()),
ssrc: binary.ssrc(),
rtxSsrc: binary.rtxSsrc() ?? undefined,
rid: binary.rid() ?? undefined,
rid: binary.rid() || undefined,
kind:
binary.kind() === FbsRtpParameters.MediaKind.AUDIO ? 'audio' : 'video',
mimeType: binary.mimeType()!,
Expand Down
9 changes: 9 additions & 0 deletions node/src/test/test-Consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const ctx: TestContext = {
rtcp: {
cname: 'FOOBAR',
},
msid: '1111-1111-1111-1111 2222-2222-2222-2222',
},
appData: { foo: 1, bar: '2' },
}),
Expand Down Expand Up @@ -294,6 +295,9 @@ test('transport.consume() succeeds', async () => {
},
rtcpFeedback: [],
});
expect(audioConsumer.rtpParameters.msid).toBe(
'1111-1111-1111-1111 2222-2222-2222-2222'
);
expect(audioConsumer.type).toBe('simple');
expect(audioConsumer.paused).toBe(false);
expect(audioConsumer.producerPaused).toBe(false);
Expand Down Expand Up @@ -380,6 +384,7 @@ test('transport.consume() succeeds', async () => {
parameters: { apt: 103 },
rtcpFeedback: [],
});
expect(videoConsumer.rtpParameters.msid).toBe(undefined);
expect(videoConsumer.type).toBe('simulcast');
expect(videoConsumer.paused).toBe(true);
expect(videoConsumer.producerPaused).toBe(true);
Expand Down Expand Up @@ -654,6 +659,9 @@ test('consumer.dump() succeeds', async () => {
ssrc: audioConsumer.rtpParameters.encodings![0]!.ssrc,
}),
]);
expect(dump1.rtpParameters.msid).toBe(
'1111-1111-1111-1111 2222-2222-2222-2222'
);
expect(dump1.type).toBe('simple');
expect(Array.isArray(dump1.consumableRtpEncodings)).toBe(true);
expect(dump1.consumableRtpEncodings!.length).toBe(1);
Expand Down Expand Up @@ -734,6 +742,7 @@ test('consumer.dump() succeeds', async () => {
scalabilityMode: 'L4T5',
},
]);
expect(dump2.rtpParameters.msid).toBe(undefined);
expect(Array.isArray(dump2.consumableRtpEncodings)).toBe(true);
expect(dump2.consumableRtpEncodings!.length).toBe(4);
expect(dump2.consumableRtpEncodings![0]).toEqual(
Expand Down
2 changes: 2 additions & 0 deletions node/src/test/test-PipeTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const ctx: TestContext = {
rtcp: {
cname: 'FOOBAR',
},
msid: 'aaaa-bbbb',
},
appData: { foo: 'bar2' },
}),
Expand Down Expand Up @@ -854,6 +855,7 @@ test('transport.consume() for a pipe Producer succeeds', async () => {
expect(typeof videoConsumer.rtpParameters.encodings![0]!.rtx?.ssrc).toBe(
'number'
);
expect(videoConsumer.rtpParameters.msid).toBe('aaaa-bbbb');
expect(videoConsumer.type).toBe('simulcast');
expect(videoConsumer.paused).toBe(false);
expect(videoConsumer.producerPaused).toBe(false);
Expand Down
2 changes: 2 additions & 0 deletions rust/benches/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ fn audio_producer_options() -> ProducerOptions {
cname: Some("audio-1".to_string()),
..RtcpParameters::default()
},
msid: None,
},
)
}
Expand Down Expand Up @@ -202,6 +203,7 @@ fn video_producer_options() -> ProducerOptions {
cname: Some("video-1".to_string()),
..RtcpParameters::default()
},
msid: None,
},
)
}
Expand Down
4 changes: 4 additions & 0 deletions rust/src/ortc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ pub(crate) fn get_consumable_rtp_parameters(
reduced_size: true,
};

consumable_params.msid.clone_from(&params.msid);

consumable_params
}

Expand Down Expand Up @@ -753,6 +755,7 @@ pub(crate) fn get_consumer_rtp_parameters(
) -> Result<RtpParameters, ConsumerRtpParametersError> {
let mut consumer_params = RtpParameters {
rtcp: consumable_rtp_parameters.rtcp.clone(),
msid: consumable_rtp_parameters.msid.clone(),
..RtpParameters::default()
};

Expand Down Expand Up @@ -933,6 +936,7 @@ pub(crate) fn get_pipe_consumer_rtp_parameters(
header_extensions: vec![],
encodings: vec![],
rtcp: consumable_rtp_parameters.rtcp.clone(),
msid: consumable_rtp_parameters.msid.clone(),
};

for codec in &consumable_rtp_parameters.codecs {
Expand Down
2 changes: 2 additions & 0 deletions rust/src/ortc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
cname: Some("qwerty1234".to_string()),
..RtcpParameters::default()
},
msid: None,
};

let rtp_mapping =
Expand Down Expand Up @@ -696,6 +697,7 @@ fn get_producer_rtp_parameters_mapping_unsupported() {
cname: Some("qwerty1234".to_string()),
..RtcpParameters::default()
},
msid: None,
};

assert!(matches!(
Expand Down
2 changes: 2 additions & 0 deletions rust/src/rtp_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl<'a> TryFromFbs<'a> for RtpParameters {
.map(|cname| cname.to_string()),
reduced_size: rtp_parameters.rtcp()?.reduced_size()?,
},
msid: rtp_parameters.msid()?.map(|msid| msid.to_string()),
})
}
}
Expand Down Expand Up @@ -354,6 +355,7 @@ impl ToFbs for RtpParameters {
cname: self.rtcp.cname.clone(),
reduced_size: self.rtcp.reduced_size,
}),
msid: self.msid.clone(),
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions rust/tests/integration/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ fn audio_producer_options() -> ProducerOptions {
cname: Some("FOOBAR".to_string()),
..RtcpParameters::default()
},
msid: Some("1111-1111-1111-1111 2222-2222-2222-2222".to_string()),
},
);

Expand Down Expand Up @@ -186,6 +187,7 @@ fn video_producer_options() -> ProducerOptions {
cname: Some("FOOBAR".to_string()),
..RtcpParameters::default()
},
msid: None,
},
);

Expand Down Expand Up @@ -456,6 +458,10 @@ fn consume_succeeds() {
rtcp_feedback: vec![],
}]
);
assert_eq!(
audio_consumer.rtp_parameters().msid,
Some("1111-1111-1111-1111 2222-2222-2222-2222".to_string())
);
assert_eq!(audio_consumer.r#type(), ConsumerType::Simple);
assert!(!audio_consumer.paused());
assert!(!audio_consumer.producer_paused());
Expand Down Expand Up @@ -554,6 +560,7 @@ fn consume_succeeds() {
},
]
);
assert_eq!(video_consumer.rtp_parameters().msid, None);
assert_eq!(video_consumer.r#type(), ConsumerType::Simulcast);
assert!(video_consumer.paused());
assert!(video_consumer.producer_paused());
Expand Down
6 changes: 6 additions & 0 deletions rust/tests/integration/pipe_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ fn audio_producer_options() -> ProducerOptions {
cname: Some("FOOBAR".to_string()),
..RtcpParameters::default()
},
msid: None,
},
);

Expand Down Expand Up @@ -142,6 +143,7 @@ fn video_producer_options() -> ProducerOptions {
cname: Some("FOOBAR".to_string()),
..RtcpParameters::default()
},
msid: Some("aaaa-bbbb".to_string()),
},
);

Expand Down Expand Up @@ -1023,6 +1025,10 @@ fn consume_for_pipe_producer_succeeds() {
assert_eq!(video_consumer.rtp_parameters().encodings.len(), 1);
assert!(video_consumer.rtp_parameters().encodings[0].ssrc.is_some());
assert!(video_consumer.rtp_parameters().encodings[0].rtx.is_some());
assert_eq!(
video_consumer.rtp_parameters().msid,
Some("aaaa-bbbb".to_string())
);
assert_eq!(video_consumer.r#type(), ConsumerType::Simulcast);
assert!(!video_consumer.paused());
assert!(video_consumer.producer_paused());
Expand Down
Loading