1. Install

go get github.com/clutchcall/clutchcall-sdk/go@latest

2. Create a live input + mint a playback URL

package main

import (
  "context"
  "fmt"
  "os"
  "github.com/clutchcall/clutchcall-sdk/go/pkg/streams"
)

func main() {
  ctx := context.Background()
  s, _ := streams.New(streams.Config{
    BaseURL: "https://app.clutchcall.dev",
    APIKey:  os.Getenv("CLUTCHCALL_API_KEY"),
    OrgID:   "org_abc",
  })

  input, streamKey, _ := s.LiveInputs.Create(ctx, streams.CreateLiveInput{
    Name: "My First Stream",
  })
  fmt.Println("inputId:", input.ExternalInputID, "streamKey:", streamKey)

  signed, _ := input.SignedPlaybackURL(ctx, 3600, nil)
  fmt.Println("playback URL:", signed.URL)
}

3. Push a broadcast

pub, _ := streams.OpenBroadcastPublisher(ctx, streams.PublisherArgs{
  InputID:   input.ExternalInputID,
  StreamKey: streamKey,
  Codecs:    streams.Codecs{Video: "avc1.42E01F", Audio: "opus"},
})
// pub.Write(chunk)  for every fMP4 segment
pub.Close("finished")

4. Subscribe (server-side tap)

viewer, _ := streams.OpenBroadcastViewer(ctx, signed.URL, streams.ViewerOpts{
  OnChunk: func(init, chunk []byte) { file.Write(chunk) },
  OnClose: func(reason string) { fmt.Println("closed:", reason) },
})
defer viewer.Close()

Other modalities

Voice

voice.New + Calls.Originate + AudioBridge.Attach

Robotics

robotics.New + PublishTelemetry / SubscribeCommand

Games

games.New + PublishState / SubscribeInputs

Data

data.New + Publish / Subscribe