Streams
Managing live streams happens through the stream store component that you can retrieve with
VideoKit.streams()
. Just like other network APIs, you will need a valid session
to perform these operation successfully. All functions of this component are asynchronous
and will accept a completion handler as described here.
Creating streams
We recommend to let the stream host component create streams for you, but should you need to do it, you can do so as follows:
let streams: StreamStore = VideoKit.streams()
streams.create(profile: .lowLatency) { stream, err in
// Got stream!
}
Fetching a stream
To retrieve a stream by its id, simply use get
:
let streams: StreamStore = VideoKit.streams()
streams.get(id: "streamId") { stream, err in
// Got stream!
}
Deleting streams
To delete a stream, all you need is its id:
let streams: StreamStore = VideoKit.streams()
streams.delete(id: stream.id) { err in
// Deleted!
}
Querying streams
To query for available streams, you can use the list
API. The function accepts a
request object which can be configured to filter streams by state. For example, to retrieve
all streams that are in the live state:
let streams: StreamStore = VideoKit.streams()
streams.list(StreamRequest(state: "live")) { streams, err in
// Got streams!
}