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

Renegotiate media with different directions #1137

Open
wants to merge 72 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
451667e
testing
jpsantosbh Jul 17, 2024
0bbb68a
Merge branch 'main' into joao/renegotiation
jpsantosbh Jul 22, 2024
56ac7b5
cleanup
jpsantosbh Jul 22, 2024
b73d367
Merge branch 'main' into joao/renegotiation
jpsantosbh Sep 9, 2024
d312dc7
test hacking renegotiation passing
jpsantosbh Sep 11, 2024
f1cfd61
added renegotiateMedia
jpsantosbh Oct 2, 2024
9109a44
Merge branch 'main' into joao/renegotiation
jpsantosbh Oct 8, 2024
96b0c42
fix getMediaConstraints
jpsantosbh Oct 14, 2024
8607fa6
Merge branch 'joao/fix_media_constraints' into joao/renegotiation
jpsantosbh Oct 14, 2024
02b2d5c
start with offering true
jpsantosbh Oct 14, 2024
1249777
check MCU
jpsantosbh Oct 14, 2024
e350878
Merge branch 'main' into joao/renegotiation
jpsantosbh Oct 14, 2024
b7fcd79
changeset
jpsantosbh Oct 14, 2024
5708919
fixes
jpsantosbh Oct 15, 2024
46b833c
Update internal/e2e-js/tests/callfabric/renegotiation.spec.ts
jpsantosbh Oct 21, 2024
cbdacc0
Update packages/webrtc/src/RTCPeer.ts
jpsantosbh Oct 21, 2024
3a0be5f
Update packages/webrtc/src/RTCPeer.ts
jpsantosbh Oct 21, 2024
dec5f50
Update internal/e2e-js/tests/callfabric/renegotiation.spec.ts
jpsantosbh Oct 21, 2024
e5485e7
added to the public contract
jpsantosbh Oct 21, 2024
6231930
refactor
jpsantosbh Oct 21, 2024
2ca56ad
add to playground
jpsantosbh Oct 21, 2024
fc3803a
Merge branch 'main' into joao/renegotiation
jpsantosbh Oct 21, 2024
e821a1c
merge fix
jpsantosbh Oct 21, 2024
fb875a6
Update packages/webrtc/src/RTCPeer.ts
jpsantosbh Oct 22, 2024
a5ab32e
Update internal/playground-js/src/fabric/index.js
jpsantosbh Oct 22, 2024
3b9e3ea
use updateConstraints
jpsantosbh Oct 22, 2024
a89457a
Update packages/webrtc/src/BaseConnection.ts
jpsantosbh Oct 23, 2024
b401750
renaming
jpsantosbh Oct 23, 2024
e15d215
Update internal/e2e-js/tests/callfabric/renegotiation.spec.ts
jpsantosbh Oct 24, 2024
dd97f47
Merge branch 'main' into joao/renegotiation
jpsantosbh Oct 24, 2024
dd8fd6a
review
jpsantosbh Oct 24, 2024
613ce32
fix interface
jpsantosbh Oct 24, 2024
0833288
testing
jpsantosbh Jul 17, 2024
da30fef
added to the public contract
jpsantosbh Oct 21, 2024
4426dd7
fix interface
jpsantosbh Oct 24, 2024
dc1e18c
rengotiate with different direction
iAmmar7 Oct 25, 2024
e8eee01
fix build
iAmmar7 Oct 25, 2024
125ee6f
refactor the enableVideo logi
iAmmar7 Oct 25, 2024
b948222
refactor video media
iAmmar7 Oct 25, 2024
0d89795
correct api usage in e2e test
iAmmar7 Oct 25, 2024
4ee636d
update e2e tests
iAmmar7 Oct 25, 2024
73df834
update playwright config
iAmmar7 Oct 25, 2024
5e0c6a0
disable video method
iAmmar7 Oct 25, 2024
02c4455
refactor the media methods
iAmmar7 Oct 28, 2024
2cac04f
refactor types
iAmmar7 Oct 28, 2024
34ad127
include more e2e tests
iAmmar7 Oct 28, 2024
3f225d7
remove commits
iAmmar7 Oct 28, 2024
3ceec19
include disable video in e2e tests
iAmmar7 Oct 28, 2024
ba7b19d
update the default value for disableVideo method
iAmmar7 Oct 28, 2024
be13512
run tests
iAmmar7 Oct 28, 2024
9aac270
comment test issue
iAmmar7 Oct 28, 2024
99f32b0
set the offer when adding the transceiver
iAmmar7 Oct 29, 2024
af8c48e
refactor test
iAmmar7 Oct 29, 2024
f98ac95
include audio renegotiation as well
iAmmar7 Oct 29, 2024
4b97f40
update e2e test
iAmmar7 Oct 29, 2024
b640911
add negotiate audio tests
iAmmar7 Oct 29, 2024
ffd0799
remove branch from the CI
iAmmar7 Oct 29, 2024
8f43a77
update the changeset
iAmmar7 Oct 29, 2024
9f92488
update the changeset
iAmmar7 Oct 29, 2024
9d6c621
include test in the callfabric project
iAmmar7 Oct 29, 2024
8097d75
remove the enable video button
iAmmar7 Oct 29, 2024
0ea3fa0
remove helper changes
iAmmar7 Oct 29, 2024
1a5a4f4
remove helper changes
iAmmar7 Oct 29, 2024
02f95c9
introduce promise to wait for renegotiation
iAmmar7 Oct 31, 2024
38ad7e5
include sdp unit tests
iAmmar7 Oct 31, 2024
349672b
refacor video negotiation test
iAmmar7 Oct 31, 2024
d676c10
update negotiate audio test
iAmmar7 Oct 31, 2024
098bd5b
remove only from e2e test
iAmmar7 Oct 31, 2024
d965071
dedicated renegotiation project for playwright
iAmmar7 Oct 31, 2024
2eeaf3e
check for negotiation update
iAmmar7 Oct 31, 2024
fcb6425
refactor the toggleMedia code
iAmmar7 Oct 31, 2024
bca43b8
fix unit tests
iAmmar7 Nov 1, 2024
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
37 changes: 37 additions & 0 deletions .changeset/sweet-garlics-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
'@signalwire/webrtc': minor
---

Include public APIs for media renegotiation

```ts
// Enable audio with "sendrecv" direction
await call.enableAudio()

// Enable audio with "sendonly" direction
await call.enableAudio({ audio: true, negotiateAudio: false })

// Enable audio with "recvonly" direction
await call.enableAudio({ audio: false, negotiateAudio: true })

// Disable audio while keeps on receiving it
await call.disableAudio({ negotiateAudio: true })

// Disable audio completely
await call.disableAudio()

// Enable video with "sendrecv" direction
await call.enableVideo()

// Enable video with "sendonly" direction
await call.enableVideo({ video: true, negotiateVideo: false })

// Enable video with "recvonly" direction
await call.enableVideo({ video: false, negotiateVideo: true })

// Disable video while keeps on receiving it
await call.disableVideo({ negotiateVideo: true })

// Disable video completely
await call.disableVideo()
```
1 change: 1 addition & 0 deletions .github/workflows/browser-js-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
audience,
reattach,
callfabric,
cfRenegotiation,
v2WebRTC,
]
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/browser-js-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
# audience,
# reattach,
callfabric,
cfRenegotiation,
v2WebRTC,
]
steps:
Expand Down
10 changes: 10 additions & 0 deletions internal/e2e-js/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const callfabricTests = [
'videoRoom.spec.ts',
'videoRoomLayout.spec.ts',
]
const cfRenegotiationTests = [
'renegotiateAudio.spec.ts',
'renegotiateVideo.spec.ts',
]
const v2WebRTC = ['v2WebrtcFromRest.spec.ts', 'webrtcCalling.spec.ts']

const useDesktopChrome = {
Expand Down Expand Up @@ -86,6 +90,7 @@ const config: PlaywrightTestConfig = {
...audienceTests,
...reattachTests,
...callfabricTests,
...cfRenegotiationTests,
...v2WebRTC,
],
},
Expand Down Expand Up @@ -124,6 +129,11 @@ const config: PlaywrightTestConfig = {
use: useDesktopChrome,
testMatch: callfabricTests,
},
{
name: 'cfRenegotiation',
use: useDesktopChrome,
testMatch: cfRenegotiationTests,
},
{
name: 'v2WebRTC',
use: useDesktopChrome,
Expand Down
216 changes: 216 additions & 0 deletions internal/e2e-js/tests/callfabric/renegotiateAudio.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
import { uuid } from '@signalwire/core'
import { test, expect } from '../../fixtures'
import {
SERVER_URL,
createCFClient,
dialAddress,
expectMCUVisible,
getStats,
getTransceiverStates,
} from '../../utils'
import { CallFabricRoomSession } from '@signalwire/js'

test.describe('CallFabric Audio Renegotiation', () => {
test('it should enable audio with "sendrecv" and then disable', async ({
createCustomPage,
resource,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

const roomName = `e2e-video-room_${uuid()}`
await resource.createVideoRoomResource(roomName)

await createCFClient(page)

// Dial an address with video only channel
await dialAddress(page, {
address: `/public/${roomName}`,
dialOptions: {
audio: false,
negotiateAudio: false,
},
})

// Expect MCU is visible
await expectMCUVisible(page)

const stats = await getStats(page)
expect(stats.outboundRTP).toHaveProperty('video')
expect(stats.inboundRTP).toHaveProperty('video')
expect(stats.outboundRTP).not.toHaveProperty('audio')
expect(stats.inboundRTP).not.toHaveProperty('audio')

await page.evaluate(async () => {
// @ts-expect-error
const cfRoomSession: CallFabricRoomSession = window._roomObj
await cfRoomSession.enableAudio()
})

const newStats = await getStats(page)
expect(newStats.outboundRTP).toHaveProperty('audio')
expect(newStats.inboundRTP).toHaveProperty('audio')

await test.step('it should disable the audio', async () => {
await page.evaluate(async () => {
// @ts-expect-error
const cfRoomSession: CallFabricRoomSession = window._roomObj
await cfRoomSession.disableAudio()
})

const statsAfterDisabling = await getStats(page)

if (statsAfterDisabling.inboundRTP.audio) {
expect(statsAfterDisabling.inboundRTP.audio.packetsReceived).toBe(0)
} else {
expect(statsAfterDisabling.inboundRTP).not.toHaveProperty('audio')
}

if (statsAfterDisabling.outboundRTP.audio) {
expect(statsAfterDisabling.outboundRTP.audio.packetsSent).toBe(0)
} else {
expect(statsAfterDisabling.outboundRTP).not.toHaveProperty('audio')
}

const { audio, video } = await getTransceiverStates(page)
expect(video.direction).toBe('sendrecv')
expect(audio.direction).toBe('inactive')
expect(audio.sender.trackReadyState).toBe('ended')
})
})

test('it should enable audio with "sendonly" and then disable with "recvonly"', async ({
createCustomPage,
resource,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

const roomName = `e2e-video-room_${uuid()}`
await resource.createVideoRoomResource(roomName)

await createCFClient(page)

// Dial an address with video only channel
await dialAddress(page, {
address: `/public/${roomName}`,
dialOptions: {
audio: false,
negotiateAudio: false,
},
})

// Expect MCU is visible
await expectMCUVisible(page)

const stats = await getStats(page)
expect(stats.outboundRTP).toHaveProperty('video')
expect(stats.inboundRTP).toHaveProperty('video')
expect(stats.outboundRTP).not.toHaveProperty('audio')
expect(stats.inboundRTP).not.toHaveProperty('audio')

await page.evaluate(async () => {
// @ts-expect-error
const cfRoomSession: CallFabricRoomSession = window._roomObj
await cfRoomSession.enableAudio({ audio: true, negotiateAudio: false })
})

const newStats = await getStats(page)
expect(newStats.outboundRTP).toHaveProperty('audio')
if (newStats.inboundRTP.audio) {
expect(newStats.inboundRTP.audio.packetsReceived).toBe(0)
} else {
expect(newStats.inboundRTP).not.toHaveProperty('audio')
}

await test.step('it should disable the audio with "recvonly"', async () => {
await page.evaluate(async () => {
// @ts-expect-error
const cfRoomSession: CallFabricRoomSession = window._roomObj
await cfRoomSession.disableAudio({ negotiateAudio: true })
})

const statsAfterDisabling = await getStats(page)
expect(statsAfterDisabling.inboundRTP).toHaveProperty('audio')
if (statsAfterDisabling.outboundRTP.audio) {
expect(statsAfterDisabling.outboundRTP.audio.packetsSent).toBe(0)
} else {
expect(statsAfterDisabling.outboundRTP).not.toHaveProperty('audio')
}

const { audio, video } = await getTransceiverStates(page)
expect(video.direction).toBe('sendrecv')
expect(audio.direction).toBe('recvonly')
expect(audio.sender.trackReadyState).toBe('ended')
expect(audio.receiver.trackReadyState).toBe('live')
})
})

test('it should enable video with "recvonly" and then disable', async ({
createCustomPage,
resource,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

const roomName = `e2e-video-room_${uuid()}`
await resource.createVideoRoomResource(roomName)

await createCFClient(page)

// Dial an address with video only channel
await dialAddress(page, {
address: `/public/${roomName}`,
dialOptions: {
audio: false,
negotiateAudio: false,
},
})

// Expect MCU is visible
await expectMCUVisible(page)

const stats = await getStats(page)
expect(stats.outboundRTP).toHaveProperty('video')
expect(stats.inboundRTP).toHaveProperty('video')
expect(stats.outboundRTP).not.toHaveProperty('audio')
expect(stats.inboundRTP).not.toHaveProperty('audio')

await page.evaluate(async () => {
// @ts-expect-error
const cfRoomSession: CallFabricRoomSession = window._roomObj
await cfRoomSession.enableAudio({ audio: false, negotiateAudio: true })
})

const newStats = await getStats(page)
expect(newStats.outboundRTP).not.toHaveProperty('audio')
expect(newStats.inboundRTP).toHaveProperty('audio')

await test.step('it should disable the audio', async () => {
await page.evaluate(async () => {
// @ts-expect-error
const cfRoomSession: CallFabricRoomSession = window._roomObj
await cfRoomSession.disableAudio()
})

const statsAfterDisabling = await getStats(page)

if (statsAfterDisabling.inboundRTP.audio) {
expect(statsAfterDisabling.inboundRTP.audio.packetsReceived).toBe(0)
} else {
expect(statsAfterDisabling.inboundRTP).not.toHaveProperty('audio')
}

if (statsAfterDisabling.outboundRTP.audio) {
expect(statsAfterDisabling.outboundRTP.audio.packetsSent).toBe(0)
} else {
expect(statsAfterDisabling.outboundRTP).not.toHaveProperty('audio')
}

const { audio, video } = await getTransceiverStates(page)
expect(video.direction).toBe('sendrecv')
expect(audio.direction).toBe('inactive')
expect(audio.sender.hasTrack).toBe(false)
})
})
})
Loading
Loading