Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FlatBuffers to 24.3.6-1 (fix cannot set temporal layer 0) #1348

Merged
merged 10 commits into from
Mar 8, 2024
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Node: Fix missing `bitrateByLayer` field in stats of `RtpRecvStream` in Node ([PR #1349](https://github.com/versatica/mediasoup/pull/1349)).
- Update worker dependency libuv to 1.48.0.
- Update worker FlatBuffers to 24.3.6-1 (fix cannot set temporal layer 0) ([PR #1348](https://github.com/versatica/mediasoup/pull/1348)).

### 3.13.23

Expand Down Expand Up @@ -123,7 +124,7 @@

### 3.13.0

- Switch from JSON based messages to `flatbuffers` ([PR #1064](https://github.com/versatica/mediasoup/pull/1064)).
- Switch from JSON based messages to FlatBuffers ([PR #1064](https://github.com/versatica/mediasoup/pull/1064)).
- Add `ListenInfo` in all transports and send/recv buffer size options ([PR #1084](https://github.com/versatica/mediasoup/pull/1084)).
- Add optional `rtcpListenInfo` in `PlainTransportOptions` ([PR #1099](https://github.com/versatica/mediasoup/pull/1099)).
- Add pause/resume API in `DataProducer` and `DataConsumer` ([PR #1104](https://github.com/versatica/mediasoup/pull/1104)).
Expand Down
40 changes: 34 additions & 6 deletions node/src/test/test-Consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ const ctx: TestContext = {
},
],
encodings: [
{ ssrc: 22222222, rtx: { ssrc: 22222223 } },
{ ssrc: 22222224, rtx: { ssrc: 22222225 } },
{ ssrc: 22222226, rtx: { ssrc: 22222227 } },
{ ssrc: 22222228, rtx: { ssrc: 22222229 } },
{ ssrc: 22222222, scalabilityMode: 'L1T5', rtx: { ssrc: 22222223 } },
{ ssrc: 22222224, scalabilityMode: 'L1T5', rtx: { ssrc: 22222225 } },
{ ssrc: 22222226, scalabilityMode: 'L1T5', rtx: { ssrc: 22222227 } },
{ ssrc: 22222228, scalabilityMode: 'L1T5', rtx: { ssrc: 22222229 } },
],
rtcp: {
cname: 'FOOBAR',
Expand Down Expand Up @@ -343,7 +343,7 @@ test('transport.consume() succeeds', async () => {
producerId: ctx.videoProducer!.id,
rtpCapabilities: ctx.consumerDeviceCapabilities,
paused: true,
preferredLayers: { spatialLayer: 12 },
preferredLayers: { spatialLayer: 12, temporalLayer: 0 },
appData: { baz: 'LOL' },
});

Expand Down Expand Up @@ -729,29 +729,33 @@ test('consumer.dump() succeeds', async () => {
rtx: {
ssrc: videoConsumer.rtpParameters.encodings?.[0].rtx?.ssrc,
},
scalabilityMode: 'L4T1',
scalabilityMode: 'L4T5',
},
]);
expect(Array.isArray(dump2.consumableRtpEncodings)).toBe(true);
expect(dump2.consumableRtpEncodings!.length).toBe(4);
expect(dump2.consumableRtpEncodings![0]).toEqual(
expect.objectContaining({
ssrc: ctx.videoProducer!.consumableRtpParameters.encodings?.[0].ssrc,
scalabilityMode: 'L1T5',
})
);
expect(dump2.consumableRtpEncodings![1]).toEqual(
expect.objectContaining({
ssrc: ctx.videoProducer!.consumableRtpParameters.encodings?.[1].ssrc,
scalabilityMode: 'L1T5',
})
);
expect(dump2.consumableRtpEncodings![2]).toEqual(
expect.objectContaining({
ssrc: ctx.videoProducer!.consumableRtpParameters.encodings?.[2].ssrc,
scalabilityMode: 'L1T5',
})
);
expect(dump2.consumableRtpEncodings![3]).toEqual(
expect.objectContaining({
ssrc: ctx.videoProducer!.consumableRtpParameters.encodings?.[3].ssrc,
scalabilityMode: 'L1T5',
})
);
expect(dump2.supportedCodecPayloadTypes).toEqual([103]);
Expand Down Expand Up @@ -870,8 +874,32 @@ test('consumer.setPreferredLayers() succeed', async () => {

expect(videoConsumer.preferredLayers).toEqual({
spatialLayer: 2,
temporalLayer: 3,
});

await videoConsumer.setPreferredLayers({ spatialLayer: 3 });

expect(videoConsumer.preferredLayers).toEqual({
spatialLayer: 3,
temporalLayer: 4,
});

await videoConsumer.setPreferredLayers({ spatialLayer: 3, temporalLayer: 0 });

expect(videoConsumer.preferredLayers).toEqual({
spatialLayer: 3,
temporalLayer: 0,
});

await videoConsumer.setPreferredLayers({
spatialLayer: 66,
temporalLayer: 66,
});

expect(videoConsumer.preferredLayers).toEqual({
spatialLayer: 3,
temporalLayer: 4,
});
}, 2000);

test('consumer.setPreferredLayers() with wrong arguments rejects with TypeError', async () => {
Expand Down
23 changes: 19 additions & 4 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import * as path from 'node:path';
import { execSync } from 'node:child_process';
import fetch from 'node-fetch';
import tar from 'tar';
import * as ini from 'ini';

const PKG = JSON.parse(fs.readFileSync('./package.json').toString());
const PKG = JSON.parse(
fs.readFileSync('./package.json', { encoding: 'utf-8' })
);
const IS_WINDOWS = os.platform() === 'win32';
const MAYOR_VERSION = PKG.version.split('.')[0];
const PYTHON = getPython();
const PIP_INVOKE_DIR = path.resolve('worker/pip_invoke');
const FLATBUFFERS_VERSION = '23.3.3';
const WORKER_RELEASE_DIR = 'worker/out/Release';
const WORKER_RELEASE_BIN = IS_WINDOWS
? 'mediasoup-worker.exe'
Expand Down Expand Up @@ -362,17 +364,30 @@ function flatcNode() {

const buildType = process.env.MEDIASOUP_BUILDTYPE || 'Release';
const extension = IS_WINDOWS ? '.exe' : '';
const flatbuffersWrapFilePath = path.join(
'worker',
'subprojects',
'flatbuffers.wrap'
);
const flatbuffersWrap = ini.parse(
fs.readFileSync(flatbuffersWrapFilePath, {
encoding: 'utf-8',
})
);
const flatbuffersDir = flatbuffersWrap['wrap-file']['directory'];

const flatc = path.resolve(
path.join(
'worker',
'out',
buildType,
'build',
'subprojects',
`flatbuffers-${FLATBUFFERS_VERSION}`,
flatbuffersDir,
`flatc${extension}`
)
);

const out = path.resolve(path.join('node', 'src'));

for (const dirent of fs.readdirSync(path.join('worker', 'fbs'), {
Expand Down Expand Up @@ -601,7 +616,7 @@ async function getVersionChanges() {
// NOTE: Load dep on demand since it's a devDependency.
const marked = await import('marked');

const changelog = fs.readFileSync('./CHANGELOG.md').toString();
const changelog = fs.readFileSync('./CHANGELOG.md', { encoding: 'utf-8' });
const entries = marked.lexer(changelog);

for (let idx = 0; idx < entries.length; ++idx) {
Expand Down
39 changes: 32 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@
]
},
"dependencies": {
"@types/ini": "^4.1.0",
"debug": "^4.3.4",
"flatbuffers": "^23.5.26",
"flatbuffers": "^24.3.6",
"h264-profile-level-id": "^2.0.0",
"ini": "^4.1.2",
"node-fetch": "^3.3.2",
"supports-color": "^9.4.0",
"tar": "^6.2.0"
Expand Down
58 changes: 55 additions & 3 deletions rust/tests/integration/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,25 @@ fn video_producer_options() -> ProducerOptions {
encodings: vec![
RtpEncodingParameters {
ssrc: Some(22222222),
scalability_mode: "L1T5".parse().unwrap(),
rtx: Some(RtpEncodingParametersRtx { ssrc: 22222223 }),
..RtpEncodingParameters::default()
},
RtpEncodingParameters {
ssrc: Some(22222224),
scalability_mode: "L1T5".parse().unwrap(),
rtx: Some(RtpEncodingParametersRtx { ssrc: 22222225 }),
..RtpEncodingParameters::default()
},
RtpEncodingParameters {
ssrc: Some(22222226),
scalability_mode: "L1T5".parse().unwrap(),
rtx: Some(RtpEncodingParametersRtx { ssrc: 22222227 }),
..RtpEncodingParameters::default()
},
RtpEncodingParameters {
ssrc: Some(22222228),
scalability_mode: "L1T5".parse().unwrap(),
rtx: Some(RtpEncodingParametersRtx { ssrc: 22222229 }),
..RtpEncodingParameters::default()
},
Expand Down Expand Up @@ -499,7 +503,7 @@ fn consume_succeeds() {
options.paused = true;
options.preferred_layers = Some(ConsumerLayers {
spatial_layer: 12,
temporal_layer: None,
temporal_layer: Some(0),
});
options.app_data = AppData::new(ConsumerAppData { baz: "LOL" });
options
Expand Down Expand Up @@ -1091,7 +1095,7 @@ fn dump_succeeds() {
.unwrap()
.rtx,
dtx: None,
scalability_mode: "L4T1".parse().unwrap(),
scalability_mode: "L4T5".parse().unwrap(),
rid: None,
max_bitrate: None,
}],
Expand All @@ -1110,7 +1114,7 @@ fn dump_succeeds() {
rtx: None,
max_bitrate: None,
dtx: None,
scalability_mode: ScalabilityMode::None,
scalability_mode: "L1T5".parse().unwrap(),
})
.collect::<Vec<_>>()
);
Expand Down Expand Up @@ -1324,9 +1328,57 @@ fn set_preferred_layers_succeeds() {
video_consumer.preferred_layers(),
Some(ConsumerLayers {
spatial_layer: 2,
temporal_layer: Some(3),
})
);

video_consumer
.set_preferred_layers(ConsumerLayers {
spatial_layer: 3,
temporal_layer: None,
})
.await
.expect("Failed to set preferred layers consumer");

assert_eq!(
video_consumer.preferred_layers(),
Some(ConsumerLayers {
spatial_layer: 3,
temporal_layer: Some(4),
})
);

video_consumer
.set_preferred_layers(ConsumerLayers {
spatial_layer: 3,
temporal_layer: Some(0),
})
.await
.expect("Failed to set preferred layers consumer");

assert_eq!(
video_consumer.preferred_layers(),
Some(ConsumerLayers {
spatial_layer: 3,
temporal_layer: Some(0),
})
);

video_consumer
.set_preferred_layers(ConsumerLayers {
spatial_layer: 66,
temporal_layer: Some(66),
})
.await
.expect("Failed to set preferred layers consumer");

assert_eq!(
video_consumer.preferred_layers(),
Some(ConsumerLayers {
spatial_layer: 3,
temporal_layer: Some(4),
})
);
}
});
}
Expand Down
Loading
Loading