From af7833c69d722abcabb8f25441012a187754afcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 29 Feb 2024 16:45:31 +0100 Subject: [PATCH 1/8] Add tests for consumer.setPreferredLayers() with temporal layer = 0 - Due to an issue in Flatbuffers (https://github.com/google/flatbuffers/issues/8245) when we call `consumer.setPreferredLayers()` with `temporalLayer: 0`, we are NOT passing `temporalLayer` to the worker so it selects the highest available temporal layer instead. - This PR tests that use case in both Node and Rust, and tests should fail until the Flatbuffers issue is resolved. - BTW the Flatbuffers issue was already fixed long ago (https://github.com/google/flatbuffers/issues/8245) but well, maintainers have not released a new version since May 2023 because whatever inexplicable reason. --- node/src/test/test-Consumer.ts | 38 ++++++++++++++++--- rust/tests/integration/consumer.rs | 59 +++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 8 deletions(-) diff --git a/node/src/test/test-Consumer.ts b/node/src/test/test-Consumer.ts index 829ee29fe1..de4b450438 100644 --- a/node/src/test/test-Consumer.ts +++ b/node/src/test/test-Consumer.ts @@ -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', @@ -389,7 +389,9 @@ test('transport.consume() succeeds', async () => { }); expect(videoConsumer.preferredLayers).toEqual({ spatialLayer: 3, - temporalLayer: 0, + // |temporalLayer| was not given in |preferredLayers| in transport.consume() + // so it should be set to the highest one. + temporalLayer: 4, }); expect(videoConsumer.currentLayers).toBeUndefined(); expect(videoConsumer.appData).toEqual({ baz: 'LOL' }); @@ -729,7 +731,7 @@ test('consumer.dump() succeeds', async () => { rtx: { ssrc: videoConsumer.rtpParameters.encodings?.[0].rtx?.ssrc, }, - scalabilityMode: 'L4T1', + scalabilityMode: 'L4T5', }, ]); expect(Array.isArray(dump2.consumableRtpEncodings)).toBe(true); @@ -870,8 +872,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 () => { diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index 35fdaa214e..f191c7bda9 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -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() }, @@ -555,7 +559,10 @@ fn consume_succeeds() { video_consumer.preferred_layers(), Some(ConsumerLayers { spatial_layer: 3, - temporal_layer: Some(0) + // |temporal_layer| was not given in |preferred_layers| in + // transport.consume() so it should be set to the highest + // one. + temporal_layer: Some(4) }) ); assert_eq!(video_consumer.current_layers(), None); @@ -1091,7 +1098,7 @@ fn dump_succeeds() { .unwrap() .rtx, dtx: None, - scalability_mode: "L4T1".parse().unwrap(), + scalability_mode: "L4T5".parse().unwrap(), rid: None, max_bitrate: None, }], @@ -1324,8 +1331,56 @@ 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), + }) ); } }); From a3bdf461809c4717240939dba2d31401cf5f6d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 29 Feb 2024 16:55:45 +0100 Subject: [PATCH 2/8] fix tests --- node/src/test/test-Consumer.ts | 4 ++++ rust/tests/integration/consumer.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/node/src/test/test-Consumer.ts b/node/src/test/test-Consumer.ts index de4b450438..3aa8a68b08 100644 --- a/node/src/test/test-Consumer.ts +++ b/node/src/test/test-Consumer.ts @@ -739,21 +739,25 @@ test('consumer.dump() succeeds', async () => { 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]); diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index f191c7bda9..fda8cf35ce 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -1117,7 +1117,7 @@ fn dump_succeeds() { rtx: None, max_bitrate: None, dtx: None, - scalability_mode: ScalabilityMode::None, + scalability_mode: "L1T5".parse().unwrap(), }) .collect::>() ); From 115e1164e2667a0147e4218e9e802e2b24622a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 1 Mar 2024 11:00:44 +0100 Subject: [PATCH 3/8] test: also use temporalLayer: 0 in preferredLayers consume() to trigger the flatbuffers bug --- node/src/test/test-Consumer.ts | 6 ++---- rust/tests/integration/consumer.rs | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/node/src/test/test-Consumer.ts b/node/src/test/test-Consumer.ts index 3aa8a68b08..ee643c7a25 100644 --- a/node/src/test/test-Consumer.ts +++ b/node/src/test/test-Consumer.ts @@ -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' }, }); @@ -389,9 +389,7 @@ test('transport.consume() succeeds', async () => { }); expect(videoConsumer.preferredLayers).toEqual({ spatialLayer: 3, - // |temporalLayer| was not given in |preferredLayers| in transport.consume() - // so it should be set to the highest one. - temporalLayer: 4, + temporalLayer: 0, }); expect(videoConsumer.currentLayers).toBeUndefined(); expect(videoConsumer.appData).toEqual({ baz: 'LOL' }); diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index fda8cf35ce..ed2fdbc3b0 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -503,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 @@ -559,10 +559,7 @@ fn consume_succeeds() { video_consumer.preferred_layers(), Some(ConsumerLayers { spatial_layer: 3, - // |temporal_layer| was not given in |preferred_layers| in - // transport.consume() so it should be set to the highest - // one. - temporal_layer: Some(4) + temporal_layer: Some(0) }) ); assert_eq!(video_consumer.current_layers(), None); From f8fd03697e967a962e3800f6a3096d5b38e6f99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 29 Feb 2024 16:45:31 +0100 Subject: [PATCH 4/8] Add tests for consumer.setPreferredLayers() with temporal layer = 0 - Due to an issue in Flatbuffers (https://github.com/google/flatbuffers/issues/8245) when we call `consumer.setPreferredLayers()` with `temporalLayer: 0`, we are NOT passing `temporalLayer` to the worker so it selects the highest available temporal layer instead. - This PR tests that use case in both Node and Rust, and tests should fail until the Flatbuffers issue is resolved. - BTW the Flatbuffers issue was already fixed long ago (https://github.com/google/flatbuffers/issues/8245) but well, maintainers have not released a new version since May 2023 because whatever inexplicable reason. --- node/src/test/test-Consumer.ts | 38 ++++++++++++++++--- rust/tests/integration/consumer.rs | 59 +++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 8 deletions(-) diff --git a/node/src/test/test-Consumer.ts b/node/src/test/test-Consumer.ts index 829ee29fe1..de4b450438 100644 --- a/node/src/test/test-Consumer.ts +++ b/node/src/test/test-Consumer.ts @@ -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', @@ -389,7 +389,9 @@ test('transport.consume() succeeds', async () => { }); expect(videoConsumer.preferredLayers).toEqual({ spatialLayer: 3, - temporalLayer: 0, + // |temporalLayer| was not given in |preferredLayers| in transport.consume() + // so it should be set to the highest one. + temporalLayer: 4, }); expect(videoConsumer.currentLayers).toBeUndefined(); expect(videoConsumer.appData).toEqual({ baz: 'LOL' }); @@ -729,7 +731,7 @@ test('consumer.dump() succeeds', async () => { rtx: { ssrc: videoConsumer.rtpParameters.encodings?.[0].rtx?.ssrc, }, - scalabilityMode: 'L4T1', + scalabilityMode: 'L4T5', }, ]); expect(Array.isArray(dump2.consumableRtpEncodings)).toBe(true); @@ -870,8 +872,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 () => { diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index 35fdaa214e..f191c7bda9 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -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() }, @@ -555,7 +559,10 @@ fn consume_succeeds() { video_consumer.preferred_layers(), Some(ConsumerLayers { spatial_layer: 3, - temporal_layer: Some(0) + // |temporal_layer| was not given in |preferred_layers| in + // transport.consume() so it should be set to the highest + // one. + temporal_layer: Some(4) }) ); assert_eq!(video_consumer.current_layers(), None); @@ -1091,7 +1098,7 @@ fn dump_succeeds() { .unwrap() .rtx, dtx: None, - scalability_mode: "L4T1".parse().unwrap(), + scalability_mode: "L4T5".parse().unwrap(), rid: None, max_bitrate: None, }], @@ -1324,8 +1331,56 @@ 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), + }) ); } }); From 9a41aa3210c98842d6694e284247017c9db0a7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 29 Feb 2024 16:55:45 +0100 Subject: [PATCH 5/8] fix tests --- node/src/test/test-Consumer.ts | 4 ++++ rust/tests/integration/consumer.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/node/src/test/test-Consumer.ts b/node/src/test/test-Consumer.ts index de4b450438..3aa8a68b08 100644 --- a/node/src/test/test-Consumer.ts +++ b/node/src/test/test-Consumer.ts @@ -739,21 +739,25 @@ test('consumer.dump() succeeds', async () => { 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]); diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index f191c7bda9..fda8cf35ce 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -1117,7 +1117,7 @@ fn dump_succeeds() { rtx: None, max_bitrate: None, dtx: None, - scalability_mode: ScalabilityMode::None, + scalability_mode: "L1T5".parse().unwrap(), }) .collect::>() ); From 045e5a99a4b8c18724123d869b884c07c1ead753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 1 Mar 2024 11:00:44 +0100 Subject: [PATCH 6/8] test: also use temporalLayer: 0 in preferredLayers consume() to trigger the flatbuffers bug --- node/src/test/test-Consumer.ts | 6 ++---- rust/tests/integration/consumer.rs | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/node/src/test/test-Consumer.ts b/node/src/test/test-Consumer.ts index 3aa8a68b08..ee643c7a25 100644 --- a/node/src/test/test-Consumer.ts +++ b/node/src/test/test-Consumer.ts @@ -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' }, }); @@ -389,9 +389,7 @@ test('transport.consume() succeeds', async () => { }); expect(videoConsumer.preferredLayers).toEqual({ spatialLayer: 3, - // |temporalLayer| was not given in |preferredLayers| in transport.consume() - // so it should be set to the highest one. - temporalLayer: 4, + temporalLayer: 0, }); expect(videoConsumer.currentLayers).toBeUndefined(); expect(videoConsumer.appData).toEqual({ baz: 'LOL' }); diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index fda8cf35ce..ed2fdbc3b0 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -503,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 @@ -559,10 +559,7 @@ fn consume_succeeds() { video_consumer.preferred_layers(), Some(ConsumerLayers { spatial_layer: 3, - // |temporal_layer| was not given in |preferred_layers| in - // transport.consume() so it should be set to the highest - // one. - temporal_layer: Some(4) + temporal_layer: Some(0) }) ); assert_eq!(video_consumer.current_layers(), None); From 3be2402d07948005e250b0d5a8f975d7457e5fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 7 Mar 2024 12:45:44 +0100 Subject: [PATCH 7/8] Update NPM flatbuffers dep to 24.3.6 --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index cb0ca861eb..409fbebd3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "ISC", "dependencies": { "debug": "^4.3.4", - "flatbuffers": "^23.5.26", + "flatbuffers": "^24.3.6", "h264-profile-level-id": "^2.0.0", "node-fetch": "^3.3.2", "supports-color": "^9.4.0", @@ -3408,9 +3408,9 @@ } }, "node_modules/flatbuffers": { - "version": "23.5.26", - "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-23.5.26.tgz", - "integrity": "sha512-vE+SI9vrJDwi1oETtTIFldC/o9GsVKRM+s6EL0nQgxXlYV1Vc4Tk30hj4xGICftInKQKj1F3up2n8UbIVobISQ==" + "version": "24.3.6", + "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-24.3.6.tgz", + "integrity": "sha512-R+LI8mP4YvuHfX3lUgKVmF/Y95hlxBtxQS7+zmYBSa9xvpxLvzQDQuTxIhrOCmnbsF71vk1NCZ7h9k0VYBa1PA==" }, "node_modules/flatted": { "version": "3.2.7", @@ -8717,9 +8717,9 @@ } }, "flatbuffers": { - "version": "23.5.26", - "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-23.5.26.tgz", - "integrity": "sha512-vE+SI9vrJDwi1oETtTIFldC/o9GsVKRM+s6EL0nQgxXlYV1Vc4Tk30hj4xGICftInKQKj1F3up2n8UbIVobISQ==" + "version": "24.3.6", + "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-24.3.6.tgz", + "integrity": "sha512-R+LI8mP4YvuHfX3lUgKVmF/Y95hlxBtxQS7+zmYBSa9xvpxLvzQDQuTxIhrOCmnbsF71vk1NCZ7h9k0VYBa1PA==" }, "flatted": { "version": "3.2.7", diff --git a/package.json b/package.json index 3f06384927..1e30c06a78 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ }, "dependencies": { "debug": "^4.3.4", - "flatbuffers": "^23.5.26", + "flatbuffers": "^24.3.6", "h264-profile-level-id": "^2.0.0", "node-fetch": "^3.3.2", "supports-color": "^9.4.0", From d242d5414dee29c218173726121921494909b25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 8 Mar 2024 10:06:48 +0100 Subject: [PATCH 8/8] Update flatbuffers wrap to 24.3.6-1 and read its directory from the wrap file --- CHANGELOG.md | 3 ++- npm-scripts.mjs | 23 +++++++++++++++++++---- package-lock.json | 25 +++++++++++++++++++++++++ package.json | 2 ++ worker/subprojects/flatbuffers.wrap | 18 +++++++++--------- 5 files changed, 57 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10fe06bb0f..d9148cb203 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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)). diff --git a/npm-scripts.mjs b/npm-scripts.mjs index 2094e1dd55..7cdffa32e4 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -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' @@ -362,6 +364,18 @@ 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', @@ -369,10 +383,11 @@ function flatcNode() { 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'), { @@ -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) { diff --git a/package-lock.json b/package-lock.json index 409fbebd3b..f0668b33b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,9 +10,11 @@ "hasInstallScript": true, "license": "ISC", "dependencies": { + "@types/ini": "^4.1.0", "debug": "^4.3.4", "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" @@ -1580,6 +1582,11 @@ "@types/node": "*" } }, + "node_modules/@types/ini": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@types/ini/-/ini-4.1.0.tgz", + "integrity": "sha512-mTehMtc+xtnWBBvqizcqYCktKDBH2WChvx1GU3Sfe4PysFDXiNe+1YwtpVX1MDtCa4NQrSPw2+3HmvXHY3gt1w==" + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", @@ -3748,6 +3755,14 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "node_modules/ini": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.2.tgz", + "integrity": "sha512-AMB1mvwR1pyBFY/nSevUX6y8nJWS63/SzUKD3JyQn97s4xgIdgQPT75IRouIiBAN4yLQBUShNYVW0+UG25daCw==", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/ip": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.9.tgz", @@ -7468,6 +7483,11 @@ "@types/node": "*" } }, + "@types/ini": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@types/ini/-/ini-4.1.0.tgz", + "integrity": "sha512-mTehMtc+xtnWBBvqizcqYCktKDBH2WChvx1GU3Sfe4PysFDXiNe+1YwtpVX1MDtCa4NQrSPw2+3HmvXHY3gt1w==" + }, "@types/istanbul-lib-coverage": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", @@ -8950,6 +8970,11 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "ini": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.2.tgz", + "integrity": "sha512-AMB1mvwR1pyBFY/nSevUX6y8nJWS63/SzUKD3JyQn97s4xgIdgQPT75IRouIiBAN4yLQBUShNYVW0+UG25daCw==" + }, "ip": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.9.tgz", diff --git a/package.json b/package.json index 1e30c06a78..7a14c80c24 100644 --- a/package.json +++ b/package.json @@ -99,9 +99,11 @@ ] }, "dependencies": { + "@types/ini": "^4.1.0", "debug": "^4.3.4", "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" diff --git a/worker/subprojects/flatbuffers.wrap b/worker/subprojects/flatbuffers.wrap index 630611bdb1..57cca8ca88 100644 --- a/worker/subprojects/flatbuffers.wrap +++ b/worker/subprojects/flatbuffers.wrap @@ -1,13 +1,13 @@ [wrap-file] -directory = flatbuffers-23.3.3 -source_url = https://github.com/google/flatbuffers/archive/v23.3.3.tar.gz -source_filename = flatbuffers-23.3.3.tar.gz -source_hash = 8aff985da30aaab37edf8e5b02fda33ed4cbdd962699a8e2af98fdef306f4e4d -patch_filename = flatbuffers_23.3.3-1_patch.zip -patch_url = https://wrapdb.mesonbuild.com/v2/flatbuffers_23.3.3-1/get_patch -patch_hash = fa5faa75a99d1161be532a5d5db19543c15cb193d116d24827a251fc03488a14 -source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/flatbuffers_23.3.3-1/flatbuffers-23.3.3.tar.gz -wrapdb_version = 23.3.3-1 +directory = flatbuffers-24.3.6 +source_url = https://github.com/google/flatbuffers/archive/v24.3.6.tar.gz +source_filename = flatbuffers-24.3.6.tar.gz +source_hash = 5d8bfbf5b1b4c47f516e7673677f0e8db0efd32f262f7a14c3fd5ff67e2bd8fc +patch_filename = flatbuffers_24.3.6-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/flatbuffers_24.3.6-1/get_patch +patch_hash = bc0e1035a67ae74b1f862491fe2b0fd49b2889d989508143fff0a45508421bd7 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/flatbuffers_24.3.6-1/flatbuffers-24.3.6.tar.gz +wrapdb_version = 24.3.6-1 [provide] flatbuffers = flatbuffers_dep