Creating a Channel
Let's create your first channel! Make sure you have a client set up so you can follow along with the examples below.
info
Channel creation is entirely self-service. iStreamPlanet will not stop or cleanup your channels. Every channel you create may incur billing charges, including the demo channel below. View your dashboard to see an overview of charges on your account.
Choosing a Source
Before creating a new channel, you must have a source to create it from. The source represents the incoming live video feed. First, get a list of sources that you have access to so that you can pick one:
- CLI
- Javascript
- Go
$ restish isp list-sources
HTTP/2.0 200 OK
Content-Encoding: br
Content-Type: application/cbor
[
{
id: "stn-abc123"
name: "iStreamPlanet Demo 1"
self: "https://api.istreamplanet.com/v2/sources/stn-abc123"
}
{
id: "stn-def456"
name: "iStreamPlanet Demo 2"
self: "https://api.istreamplanet.com/v2/sources/stn-def456"
}
]
// TODO
package main
import (
"context"
"fmt"
"github.com/istreamlabs/go-sdk/isp"
)
func main() {
// Create a new API client.
client := isp.NewWithClientCredentials("CLIENT_ID", "CLIENT_SECRET", "ORGANIZATION")
// Get a list of all source summaries. Pagination is handled automatically.
ctx := context.Background()
summaries, _, err := client.SourcesApi.ListSources(ctx).Execute()
if err.Error() != "" {
panic(err)
}
// For each source, print out its ID and self link.
for _, s := range summaries {
fmt.Println(s.Id + " " + *s.Self)
}
}
Each returned source has an id
field. Pick one and we will use it to create a new channel.
Creating a Channel
Create a new channel with default settings by passing in your source at creation time. Here we assume that SOURCE_ID
is the value picked above and CHANNEL_ID
is the ID you want to use for the channel.
- CLI
- Javascript
- Go
$ restish isp put-channel $CHANNEL_ID ingest.source.id: $SOURCE_ID
HTTP/2.0 201 Created
Date: Wed, 23 Dec 2020 22:07:29 GMT
Location: /v2/channels/CHANNEL_ID
Alternatively you can pass in a JSON representation of the channel you wish to create:
$ restish isp put-channel $CHANNEL_ID <input.json
Your channel will get created and immediately start encoding and publishing. You can fetch the channel to see its configuration details:
# Via the `Location` header
$ restish api.istreamplanet.com/v2/channels/CHANNEL_ID
# Via the get operation
$ restish isp get-channel $CHANNEL_ID
// TODO
// Create the request, setting up a basic channel with just a source ID.
request := client.ChannelsApi.PutChannel(context.Background(), "CHANNEL_ID")
body := isp.PutChannelRequest{}
body.Ingest.Source.Id = "SOURCE_ID"
request.PutChannelRequest(body)
// Perform the request and check for errors.
resp, err := request.Execute()
if err.Error() != "" {
panic(err)
}
Your channel will get created and immediately start encoding and publishing. You can use the Location
header from the response to find out the encoding settings and playback URLs:
// Print out the URI for the new channel's details.
fmt.Println(resp.Header.Get("Location"))
Keep your playback URL handy for viewing the running channel.
Viewing the Channel
You can use a tool like VLC to view your video, or paste it into the embedded video player below:
Customizing Channel Settings
TODO This section isn't finished yet!
Deleting a Channel
When finished, you can stop a channel from publishing by deleting it using either the channel's unique ID or the channel's location URI returned from creating the channel.
- CLI
- Javascript
- Go
# If you know the ID:
$ restish isp delete-channel $CHANNEL_ID
# If you know the location:
$ restish delete api.istreamplanet.com/v2/channels/...
// TODO
// Delete the channel. Set your own CHANNEL_ID!
request := client.ChannelsApi.DeleteChannel(context.Background(), "CHANNEL_ID")
_, err = request.Execute()
if err.Error() != "" {
panic(err)
}
This covers the most basic channel workflow. Read on to find out how to perform live channel operations in the next section.