diff --git a/docusaurus/docs/Android/03-guides/07-querying-calls.mdx b/docusaurus/docs/Android/03-guides/07-querying-calls.mdx index c9c12fc39e..07a279560b 100644 --- a/docusaurus/docs/Android/03-guides/07-querying-calls.mdx +++ b/docusaurus/docs/Android/03-guides/07-querying-calls.mdx @@ -25,6 +25,16 @@ val sort = listOf(SortField.Asc("starts_at")) val result = client.queryCalls(filters=filters, sort=sort, limit=10, watch=true) ``` +**Calls that are ongoing / currently have participants** + +```kotlin +client.queryCalls(mapOf("ongoing" to true)).let { result -> + result + .onSuccess { calls: QueriedCalls -> Log.d(TAG, "Query success: $calls") } + .onError { error: Error -> Log.e(TAG, "Query failure: ${error.message}") } +} +``` + **Calls filters on a custom property** ```kotlin @@ -36,6 +46,7 @@ val result = client.queryCalls(filters=filters, sort=sort, limit=10, watch=true) ``` **Pagination** + The query response is paginated and the maximum count of items is defined by the `limit` parameter. Use the `prev` and `next` parameters from the last response as parameters for requesting the next page. @@ -54,12 +65,6 @@ val resultPage2 = client.queryCalls( ) ``` -**Calls that live/ currently have participants** - -```kotlin -TODO -``` - ### Fields for Query Calls You can filter on the following fields @@ -78,15 +83,15 @@ You can filter on the following fields | `members` | Check if you are a member of this call | | `custom` | You can query custom data using the "custom.myfield" syntax | -Sorting is supported on these fields below: +Sorting is supported on the fields below: -* starts_at -* created_at -* updated_at -* ended_at -* type -* id -* cid +* `starts_at` +* `created_at` +* `updated_at` +* `ended_at` +* `type` +* `id` +* `cid` If you specify `watch` the SDK will automatically keep the data about these calls updated. This allows you to show a live preview of who's in the call. \ No newline at end of file diff --git a/docusaurus/docs/Android/06-advanced/08-events.mdx b/docusaurus/docs/Android/06-advanced/08-events.mdx index 09fb99a9bb..4ca216ce87 100644 --- a/docusaurus/docs/Android/06-advanced/08-events.mdx +++ b/docusaurus/docs/Android/06-advanced/08-events.mdx @@ -3,7 +3,7 @@ title: Events description: How to listen to events --- -In most cases you can simply use the stateflow objects Stream exposes. +In most cases you can simply use the `Stateflow` objects Stream exposes. However for some customizations you'll want to listen to the underlying events that power these state objects. ### Listening to events @@ -19,7 +19,7 @@ val sub = client.subscribe { event: VideoEvent -> sub.dispose() ``` -You can also subscribe for a specific call +You can also subscribe to call events. ```kotlin val call = client.call("default", "123") @@ -30,11 +30,11 @@ val sub = call.subscribe { event: VideoEvent -> sub.dispose() ``` -Or listen to a specific event +Or listen to a specific event. ```kotlin -val sub = client.subscribeFor { newMessageEvent -> - logger.d { newMessageEvent.toString() } +val sub = client.subscribeFor { event -> + logger.d { event.toString() } } // stop listening sub.dispose() @@ -42,6 +42,45 @@ sub.dispose() ### Events -The following events are triggered by the client: +The following events are emitted by the client: -TODO \ No newline at end of file +| Event Name | Description | +|-------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `BlockedUserEvent` | This event is sent to call participants to notify when a user is blocked on a call. Clients can use this event to show a notification. If the user is the current user, the client should leave the call screen as well. | +| `CallAcceptedEvent` | This event is sent when a user accepts a notification to join a call. | +| `CallCreatedEvent` | This event is sent when a call is created. Clients receiving this event should check if the ringing field is set to true and if so, show the call screen. | +| `CallEndedEvent` | This event is sent when a call is marked as ended for all its participants. Clients receiving this event should leave the call screen. | +| `CallHLSBroadcastingStartedEvent` | This event is sent when call HLS broadcasting has started. | +| `CallHLSBroadcastingStoppedEvent` | This event is sent when call HLS broadcasting has stopped. | +| `CallHLSBroadcastingFailedEvent` | This event indicates that call HLS broadcasting has failed. | +| `CallLiveStartedEvent` | This event is sent when a livestream has started. | +| `CallMemberAddedEvent` | This event is sent when one or more members are added to a call. | +| `CallMemberRemovedEvent` | This event is sent when one or more members are removed from a call. | +| `CallMemberUpdatedEvent` | This event is sent when one or more members are updated. | +| `CallMemberUpdatedPermissionEvent` | This event is sent when one or more members get their role capabilities updated. | +| `CallReactionEvent` | This event is sent when a reaction is sent in a call, clients should use this to show the reaction in the call screen | +| `CallRecordingStartedEvent` | This event is sent when call recording has started. | +| `CallRecordingStoppedEvent` | This event is sent when call recording has stopped. | +| `CallRecordingReadyEvent` | Indicates that a call recording is ready. | +| `CallRecordingFailedEvent` | Indicates that recording a call failed. | +| `CallRejectedEvent` | This event is sent when a user rejects a notification to join a call. | +| `CallRingEvent` | This event is sent to all call members to notify they are getting called. | +| `CallSessionStartedEvent` | This event is sent when a call session starts. | +| `CallSessionEndedEvent` | This event is sent when a call session ends. | +| `CallSessionParticipantJoinedEvent` | This event is sent when a participant joins a call session. | +| `CallSessionParticipantLeftEvent` | This event is sent when a participant leaves a call session. | +| `CallTranscriptionStartedEvent` | This event indicates that call transcribing has started. | +| `CallTranscriptionStoppedEvent` | Indicates that call transcribing has stopped. | +| `CallTranscriptionReadyEvent` | This event is sent when call transcriptions are ready. | +| `CallTranscriptionFailedEvent` | Indicates that call transcribing failed. | +| `CallUpdatedEvent` | This event is sent when a call is updated. Clients should use this update the local state of the call. This event also contains the capabilities by role for the call, clients should update the own_capability for the current. | +| `ConnectedEvent` | This event is sent when the WS connection is established and authenticated. This event contains the full user object as it is stored on the server. | +| `ConnectionErrorEvent` | This event is sent when the WS connection attempt fails. | +| `HealthCheckEvent` | Periodic event used to check the connection health. | +| `PermissionRequestEvent` | This event is sent when a user requests access to a feature on a call, clients receiving this event should display a permission request to the user. | +| `UnblockedUserEvent` | This event is sent when a user is unblocked on a call. This can be useful to notify the user that they can now join the call again. | +| `UpdatedCallPermissionsEvent` | This event is sent to notify about permission changes for a user. Clients receiving this event should update their UI accordingly. | +| `VideoEvent` | The discriminator object for all websocket events, you should use this to map event payloads to the correct type. | +| `WSCallEvent` | Placeholder for all call events. | +| `WSClientEvent` | Placeholder for all client events. | +| `CustomVideoEvent` | A custom event. This event is used to send custom events to other participants in the call. | diff --git a/docusaurus/docs/Android/06-advanced/09-recording.mdx b/docusaurus/docs/Android/06-advanced/09-recording.mdx index 9c92a4a4c3..eba79edfc3 100644 --- a/docusaurus/docs/Android/06-advanced/09-recording.mdx +++ b/docusaurus/docs/Android/06-advanced/09-recording.mdx @@ -1,59 +1,62 @@ --- -title: Recording & Broadcasting -description: Recording & Broadcasting +title: Recording +description: Recording Calls --- -### Recording +In certain situations, you may need to record a call and share the recording with the participants. The Stream Video SDK supports this functionality via the `Call` recording API. -The example below shows how to start and stop recording a call +### Start and Stop Recording + +To start recording, we simply invoke `call.startRecording()`. To stop recording, we use `call.stopRecording()`. ```kotlin call.startRecording() call.stopRecording() ``` -You can retrieve recordings: +The `call.state.recording` property of type `StateFlow` will be updated when call recording starts/stops. ```kotlin -val result = call.listRecordings() +val isRecording by call.state.recording.collectAsStateWithLifecycle() // Use to update the UI ``` -There are several layout options... TODO - -### Broadcasting to HLS - -You can broadcast your call to HLS - -```kotlin -call.startBroadcasting() -call.stopBroadcasting() -``` +### Get a List of Recordings -The HLS url is available in the call state +You can retrieve recordings by using `call.listRecordings()`. If the query is successful, `result` will contain a list of recordings, each containing information about the filename, URL and the start and end times. You can use the URL to show the recording in a video player. ```kotlin +val result = call.listRecordings() +result + .onSuccess { response: ListRecordingsResponse -> + response.recordings.forEach { recording: CallRecording -> + Log.d(TAG, recording.filename) + Log.d(TAG, recording.url) + Log.d(TAG, recording.startTime.toString()) + Log.d(TAG, recording.endTime.toString()) + } + } + .onError { error: Error -> + Log.e(TAG, "Failure: ${error.message}") + } ``` -### RTMP-in - -You can also add RTMPs stream's to your call. - -```kotlin -val url = call.state.ingress.value?.rtmp?.address -// TODO: streaming key -``` - -We plan to add support for other livestreaming protocols in the future. If something is missing be sure to let us know. - -### Displaying HLS +### Listening to Recording Events -On android you can display HLS using ExoPlayer +You can listen to recording-related events and change to UI accordingly. ```kotlin -implementation "androidx.media3:media3-exoplayer:1.0.2" -implementation "androidx.media3:media3-ui:1.0.2" -implementation "androidx.media3:media3-exoplayer-hls:1.0.2" +val sub = call.subscribeFor( + CallRecordingStartedEvent::class.java, + CallRecordingStoppedEvent::class.java, + CallRecordingReadyEvent::class.java, + CallRecordingFailedEvent::class.java +) { + Log.e(TAG, "Event type: ${it.getEventType()}") +} + +// stop listening +sub.dispose() ``` -This article explains how to use (ExoPlayer with compose)[https://proandroiddev.com/learn-with-code-jetpack-compose-playing-media-part-3-3792bdfbe1ea]. +Read more about subscribing to events on the [events](08-events.mdx) page. \ No newline at end of file diff --git a/docusaurus/docs/Android/06-advanced/10-broadcasting.mdx b/docusaurus/docs/Android/06-advanced/10-broadcasting.mdx new file mode 100644 index 0000000000..b4a3b7a0ae --- /dev/null +++ b/docusaurus/docs/Android/06-advanced/10-broadcasting.mdx @@ -0,0 +1,73 @@ +--- +title: Broadcasting +description: Broadcasting Calls +--- + +The Stream Video SDK has support for HLS broadcasting. + +### Start and Stop HLS broadcasting + +```kotlin +call.startHLS() +call.stopHLS() +``` + +After few seconds of setup, broadcasting will start and the state of the call will be updated: the `call.state.broadcasting` boolean flag will become `true`. + +### Listening to Broadcasting Events + +You can listen to broadcasting-related events and change to UI accordingly. + +```kotlin +val sub = subscribeFor( + CallHLSBroadcastingStartedEvent::class.java, + CallHLSBroadcastingStoppedEvent::class.java, + CallHLSBroadcastingFailedEvent::class.java, +) { + Log.e(TAG, "Event type: ${it.getEventType()}") +} + +// stop listening +sub.dispose() +``` + +See more about subscribing to events on the [events](08-events.mdx) page. + +### Retrieving the Broadcast URL + +The URL for the broadcast can be retrieved from the `CallHLSBroadcastingStartedEvent` event. It can be used by others to watch the broadcast. + +```kotlin +call.subscribe { event -> + when (event) { + is CallHLSBroadcastingStartedEvent -> { + Log.d(TAG, event.hlsPlaylistUrl) + } + } +} +``` + +### Displaying HLS + +On Android you can play a HLS broadcast by using ExoPlayer. + +```kotlin +implementation "androidx.media3:media3-exoplayer:1.0.2" +implementation "androidx.media3:media3-ui:1.0.2" +implementation "androidx.media3:media3-exoplayer-hls:1.0.2" +``` + +[This](https://proandroiddev.com/learn-with-code-jetpack-compose-playing-media-part-3-3792bdfbe1ea) article explains how to use ExoPlayer with Compose. + +### RTMP-In + +You can also use RTMP streams as input for a call. + +```kotlin +val url = call.state.ingress.value?.rtmp?.address +val streamingKey = call.state.ingress.value?.rtmp?.streamKey +``` + +You can read more about RTMP-In in our [livestreaming tutorial](https://getstream.io/video/sdk/android/tutorial/livestreaming). + +We plan to add support for other livestreaming protocols in the future. If something is missing be sure to let us know. \ No newline at end of file diff --git a/docusaurus/docs/Android/06-advanced/10-custom-data.mdx b/docusaurus/docs/Android/06-advanced/11-custom-data.mdx similarity index 100% rename from docusaurus/docs/Android/06-advanced/10-custom-data.mdx rename to docusaurus/docs/Android/06-advanced/11-custom-data.mdx