From 85a862f2d34d84e5638520da1193e0193aff1bc0 Mon Sep 17 00:00:00 2001 From: Viktor Apostolski Date: Tue, 11 Jun 2024 15:40:37 +0200 Subject: [PATCH 1/5] add docs for backstage join ahead --- .../docs/api/streaming/backstage.mdx | 98 ++++++++++++++++++- 1 file changed, 93 insertions(+), 5 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx index f1774bd3..3c64bd47 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx @@ -13,10 +13,75 @@ import GoLive from '../_common_/go_live.mdx'; By default, livestreams are created in backstage mode, while in backstage mode, streams can only be accessed by admin-like users. This is necessary because it makes it possible to create the setup in advance and to notify and grant access to viewers when the event starts. +To allow regular users to join a call ahead of time, even if the call is still in backstage mode you can create the call and set the join ahead time backstage setting. +The default value of `join_ahead_time_seconds` is 0, which means that users can only join the call when the call starts. ## Configuration -You change the backstage mode settings on the call type or on the call level. +To create a call in backstage mode and allow users to join ahead of the scheduled time you can use the join_ahead_time_seconds settings option. + + + + +```js +client.call('livestream', 'test-outgoing-call').getOrCreate({ + data: { + created_by_id: 'john', + settings_override: { + backstage: { + enabled: true, + join_ahead_time_seconds: 300, + }, + }, + }, +}); +``` + + + + +```py +# create a call with backstage enabled, starts_at set +# and join_ahead_of_time_seconds set to 5 minutes +call.create( + data=CallRequest( + starts_at=2024-05-31T12:05:22+00:00), + settings_override=CallSettingsRequest( + backstage=BackstageSettingsRequest( + enabled=True, + join_ahead_time_seconds=300 + ), + ), +) +``` + + + + + +```bash +# create a call with backstage mode and join ahead time settings +curl -X POST "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE}/${CALL_ID}?api_key=${API_KEY}" \ + -H "Authorization: ${TOKEN}" \ + -H "Content-Type: application/json" \ + -H "stream-auth-type: jwt" \ + -d '{ + "data": { + "created_by_id": "john", + "settings_override": { + "backstage": { + "enabled": true, + "join_ahead_time_seconds": 300 + } + }, + } + }' +``` + + + + +You can change the backstage mode and join ahead time settings on the call type or on the call level. Allowing the users to join a call in backstage is optional. @@ -27,6 +92,7 @@ call.update({ settings_override: { backstage: { enabled: true, + join_ahead_time_seconds: 300, }, }, }); @@ -36,6 +102,7 @@ client.video.updateCallType('', { settings: { backstage: { enabled: true, + join_ahead_time_seconds: 300, }, }, }); @@ -50,6 +117,7 @@ call.update( settings_override=CallSettingsRequest( backstage=BackstageSettingsRequest( enabled=True, + join_ahead_time_seconds=300, ), ), ) @@ -60,6 +128,7 @@ client.video.update_call_type( settings=CallSettingsRequest( backstage=BackstageSettingsRequest( enabled=True, + join_ahead_time_seconds=300, ), ), ) @@ -77,7 +146,8 @@ curl -X PATCH "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE_NAM -d '{ "settings_override": { "backstage": { - "enabled": true + "enabled": true, + "join_ahead_time_seconds": 300 } } }' @@ -90,7 +160,8 @@ curl -X PUT "https://video.stream-io-api.com/api/v2/video/calltypes/${CALL_TYPE_ -d '{ "settings": { "backstage": { - "enabled": true + "enabled": true, + "join_ahead_time_seconds": 300 } } }' @@ -145,6 +216,7 @@ curl -X PUT "https://video.stream-io-api.com/api/v2/video/calltypes/${CALL_TYPE_ With this approach you can add multiple members that have the `join-backstage` capability, which allows you to have multiple hosts. +Or, you can bypass this check and allow users to join by creating time with specifying the join_ahead_time_seconds backstage option. ## Go Live @@ -158,15 +230,20 @@ It's also possible to send push notifications to call members on this event, for ## Stop Live -When the stream ends the `StopLive` endpoint will remove the viewers that are still in the call, and prevent from new viewers to join. +When the stream ends the `StopLive` endpoint will remove the viewers that are still in the call, and prevent from new viewers to join. + +A call can enter and leave backstage mode multiple times. If you use `join_ahead_time_seconds`, you might need to update the `starts_at` field as well. Otherwise, `stopLive` will not prevent regular users from joining the backstage. -A call can enter and leave backstage mode multiple times. +The stopLive endpoint allows you to update the `starts_at` call property as well. ```js call.stopLive(); + +// call stopLive() with startsAt update +call.stopLive({startsAt: '2024-05-31T12:05:22+00:00'}); ``` @@ -174,6 +251,9 @@ call.stopLive(); ```py call.stop_live() + +# call stopLive with starts_at update +call.stop_live(starts_at=2024-05-31T12:05:22+00:00) ``` @@ -183,6 +263,14 @@ call.stop_live() curl -X POST "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE_NAME}/${CALL_ID}/stop_live?api_key=${API_KEY}" \ -H "Authorization: ${TOKEN}" \ -H "stream-auth-type: jwt" + +# call stopLive with starts_at update +curl -X POST "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE_NAME}/${CALL_ID}/stop_live?api_key=${API_KEY}" \ + -H "Authorization: ${TOKEN}" \ + -H " stream-auth-type: jwt" \ + -d '{ + "starts_at": "2024-05-31T12:05:22+00:00" + }' ``` From b10f31dffc01489409cf57fbd11d656847b3ffa6 Mon Sep 17 00:00:00 2001 From: Viktor Apostolski Date: Wed, 12 Jun 2024 14:12:49 +0200 Subject: [PATCH 2/5] imrpove docs --- .../docs/api/streaming/backstage.mdx | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx index 3c64bd47..c6e9d576 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx @@ -43,15 +43,22 @@ client.call('livestream', 'test-outgoing-call').getOrCreate({ ```py # create a call with backstage enabled, starts_at set # and join_ahead_of_time_seconds set to 5 minutes -call.create( - data=CallRequest( - starts_at=2024-05-31T12:05:22+00:00), - settings_override=CallSettingsRequest( - backstage=BackstageSettingsRequest( - enabled=True, - join_ahead_time_seconds=300 +min30s = timedelta(minutes=30) +in_next_30_mins = datetime.now() + min30s +dt = datetime.fromtimestamp(in_next_30_mins.timestamp(), timezone.utc) + +call = client.video.call("livestream", uuid.uuid4()) +response = call.get_or_create( + data=CallRequest( + starts_at=dt, + created_by_id=user_id, + settings_override=CallSettingsRequest( + backstage=BackstageSettingsRequest( + enabled=True, + join_ahead_time_seconds=300, + ), ), - ), + ) ) ``` @@ -232,18 +239,13 @@ It's also possible to send push notifications to call members on this event, for When the stream ends the `StopLive` endpoint will remove the viewers that are still in the call, and prevent from new viewers to join. -A call can enter and leave backstage mode multiple times. If you use `join_ahead_time_seconds`, you might need to update the `starts_at` field as well. Otherwise, `stopLive` will not prevent regular users from joining the backstage. - -The stopLive endpoint allows you to update the `starts_at` call property as well. +A call can enter and leave backstage mode multiple times. ```js call.stopLive(); - -// call stopLive() with startsAt update -call.stopLive({startsAt: '2024-05-31T12:05:22+00:00'}); ``` @@ -251,9 +253,6 @@ call.stopLive({startsAt: '2024-05-31T12:05:22+00:00'}); ```py call.stop_live() - -# call stopLive with starts_at update -call.stop_live(starts_at=2024-05-31T12:05:22+00:00) ``` @@ -268,9 +267,6 @@ curl -X POST "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE_NAME curl -X POST "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE_NAME}/${CALL_ID}/stop_live?api_key=${API_KEY}" \ -H "Authorization: ${TOKEN}" \ -H " stream-auth-type: jwt" \ - -d '{ - "starts_at": "2024-05-31T12:05:22+00:00" - }' ``` From 2f5528c9c55c484640a1ada33036b306f641457e Mon Sep 17 00:00:00 2001 From: Viktor Apostolski Date: Wed, 12 Jun 2024 14:19:23 +0200 Subject: [PATCH 3/5] improve docs --- docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx index c6e9d576..168241e7 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx @@ -24,8 +24,10 @@ To create a call in backstage mode and allow users to join ahead of the schedule ```js +startsAt = new Date(Date.now() + 30 * 60 * 1000); client.call('livestream', 'test-outgoing-call').getOrCreate({ data: { + starts_at: startsAt.toISOString(), created_by_id: 'john', settings_override: { backstage: { @@ -74,6 +76,7 @@ curl -X POST "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE}/${C -H "stream-auth-type: jwt" \ -d '{ "data": { + "starts_at": "2022-01-01T00:00:00Z", "created_by_id": "john", "settings_override": { "backstage": { From d7728abb100aebff3af3141398eba65e8d59a5d3 Mon Sep 17 00:00:00 2001 From: Viktor Apostolski Date: Wed, 12 Jun 2024 14:20:22 +0200 Subject: [PATCH 4/5] add improts for python --- docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx index 168241e7..73c4fb87 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx @@ -45,6 +45,7 @@ client.call('livestream', 'test-outgoing-call').getOrCreate({ ```py # create a call with backstage enabled, starts_at set # and join_ahead_of_time_seconds set to 5 minutes +from datetime import datetime, timedelta, timezone min30s = timedelta(minutes=30) in_next_30_mins = datetime.now() + min30s dt = datetime.fromtimestamp(in_next_30_mins.timestamp(), timezone.utc) From e93b14de2ff128a18d6339e24512e562b026901c Mon Sep 17 00:00:00 2001 From: Viktor Apostolski Date: Sun, 16 Jun 2024 21:27:33 +0200 Subject: [PATCH 5/5] improve code --- .../video/docusaurus/docs/api/streaming/backstage.mdx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx index 73c4fb87..7ea1bc6f 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx @@ -46,14 +46,12 @@ client.call('livestream', 'test-outgoing-call').getOrCreate({ # create a call with backstage enabled, starts_at set # and join_ahead_of_time_seconds set to 5 minutes from datetime import datetime, timedelta, timezone -min30s = timedelta(minutes=30) -in_next_30_mins = datetime.now() + min30s -dt = datetime.fromtimestamp(in_next_30_mins.timestamp(), timezone.utc) +starts_at = datetime.now(timezone.utc) + timedelta(minutes=30) call = client.video.call("livestream", uuid.uuid4()) response = call.get_or_create( data=CallRequest( - starts_at=dt, + starts_at=starts_at, created_by_id=user_id, settings_override=CallSettingsRequest( backstage=BackstageSettingsRequest(