Documentation
¶
Overview ¶
Package broadcast provides functionality for setting up a YouTube livestream service and broadcast scheduling.
Index ¶
- Constants
- Variables
- func CompleteBroadcast(svc *youtube.Service, bID string) error
- func GenerateToken(ctx context.Context, w http.ResponseWriter, r *http.Request, scope string) error
- func GetBroadcastStatus(svc *youtube.Service, id string) (string, error)
- func GetHealthStatus(svc *youtube.Service, id string) (*youtube.LiveStreamHealthStatus, error)
- func GetService(ctx context.Context, scope string) (*youtube.Service, error)
- func PostChatMessage(cID, msg string) error
- func RTMPKey(svc *youtube.Service, title string) (string, error)
- func Start(name, bID, sID string, saveLink func(key, link string) error, ...) error
- type IDs
Constants ¶
const ( StatusComplete = "complete" StatusRevoked = "revoked" )
Exported status strings.
Variables ¶
var ErrGeneratedToken = errors.New("needed to generate token")
Exported error values.
var (
ErrNoBroadcastItems = errors.New("no broadcast items")
)
Exported errors.
Functions ¶
func CompleteBroadcast ¶
CompleteBroadcast uses the YouTube API to set the broadcast status of the broadcast with bId to "complete".
func GenerateToken ¶
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 ¶
GetBroadcastStatus gets the status of the broadcast with the provided ID.
func GetHealthStatus ¶
getHealthStatus provides the LiveStreamHealthStatus struct for the given stream ID.
func GetService ¶
getService returns a google authorised and configured youtube service for use by the google YouTube API.
func PostChatMessage ¶
PostChatMessage posts the provided message to the chat with the provided chat identification.
func RTMPKey ¶
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