broadcast

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package broadcast provides functionality for setting up a YouTube livestream service and broadcast scheduling.

Index

Constants

View Source
const (
	StatusComplete = "complete"
	StatusRevoked  = "revoked"
)

Exported status strings.

Variables

View Source
var ErrGeneratedToken = errors.New("needed to generate token")

Exported error values.

View Source
var (
	ErrNoBroadcastItems = errors.New("no broadcast items")
)

Exported errors.

Functions

func CompleteBroadcast

func CompleteBroadcast(svc *youtube.Service, bID string) error

CompleteBroadcast uses the YouTube API to set the broadcast status of the broadcast with bId to "complete".

func GenerateToken

func GenerateToken(ctx context.Context, w http.ResponseWriter, r *http.Request, scope string) error

GenerateToken manually generates/regenerates a token. This can be called in the case that there's an indication the current token has expired.

func GetBroadcastStatus

func GetBroadcastStatus(svc *youtube.Service, id string) (string, error)

GetBroadcastStatus gets the status of the broadcast with the provided ID.

func GetHealthStatus

func GetHealthStatus(svc *youtube.Service, id string) (*youtube.LiveStreamHealthStatus, error)

getHealthStatus provides the LiveStreamHealthStatus struct for the given stream ID.

func GetService

func GetService(ctx context.Context, scope string) (*youtube.Service, error)

getService returns a google authorised and configured youtube service for use by the google YouTube API.

func PostChatMessage

func PostChatMessage(cID, msg string) error

PostChatMessage posts the provided message to the chat with the provided chat identification.

func RTMPKey

func RTMPKey(svc *youtube.Service, title string) (string, error)

RTMPKey retrieves the RTMP Key required for appending to the RTMP destination URL given to the encoder, for the provided stream title.

func Start

func Start(
	name, bID, sID string,
	saveLink func(key, link string) error,
	extStart, extStop func() error,
	notify func(msg string) error,
	onLiveActions func() error,
) error

Start transitions a youtube broadcast object into the live state and calls the provided extStart function to start external streaming hardware. extStop is called in the case of issues and retry. The live broadcast link is provided to the saveLink function and once we are live the onLiveActions function is called.

Types

type IDs

type IDs struct {
	BID, SID, CID string
}

func BroadcastStream

func BroadcastStream(
	svc *youtube.Service,
	broadcast, description, stream, privacy, resolution, typ, framerate string,
	start, end time.Time,
	opts ...googleapi.CallOption) (googleapi.ServerResponse, IDs, error)

BroadcastStream uses the youtube API to create and schedule a broadcast with a bound stream to which we can send video data. This corresponds to the logic in https://github.com/youtube/api-samples/blob/07263305b59a7c3275bc7e925f9ce6cabf774022/python/create_broadcast.py#L135-L138

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL