-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fd5345
commit 85610ae
Showing
5 changed files
with
175 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Boolean>` 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
File renamed without changes.