Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cmd/oceanbench/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ type BroadcastConfig struct {
CID string // ID of associated chat.
StreamName string // The name of the stream we'll bind to the broadcast.
Description string // The broadcast description shown below viewing window.
Privacy string // Privacy of the broadcast i.e. public, private or unlisted.
LivePrivacy string // Privacy of the broadcast while live i.e. public, private or unlisted.
PostLivePrivacy string // Privacy of the broadcast after it has ended i.e. public, private or unlisted.
Resolution string // Resolution of the stream e.g. 1080p.
StartTimestamp string // Start time of the broadcast in unix format.
Start time.Time // Start time in native go format for easy operations.
Expand Down Expand Up @@ -207,7 +208,8 @@ func broadcastHandler(w http.ResponseWriter, r *http.Request) {
ID: r.FormValue("broadcast-id"),
StreamName: r.FormValue("stream-name"),
Description: r.FormValue("description"),
Privacy: r.FormValue("privacy"),
LivePrivacy: r.FormValue("live-privacy"),
PostLivePrivacy: r.FormValue("post-live-privacy"),
Resolution: r.FormValue("resolution"),
StartTimestamp: r.FormValue("start-timestamp"),
EndTimestamp: r.FormValue("end-timestamp"),
Expand Down
2 changes: 1 addition & 1 deletion cmd/oceanbench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import (
)

const (
version = "v0.27.1"
version = "v0.28.0"
localSite = "localhost"
localDevice = "localdevice"
localEmail = "localuser@localhost"
Expand Down
15 changes: 13 additions & 2 deletions cmd/oceanbench/t/broadcast.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,22 @@ <h2 class="pt-5">Stream Settings</h2>
</div>
</div>
<div class="d-flex align-items-center gap-1 mb-1">
<div class="w-25"></div>
<label for="account" class="w-25 text-end">Live Privacy:</label>
<div class="d-flex align-items-center gap-3 flex-row">
{{range .Settings.Privacy}}
<div>
<input type="radio" name="live-privacy" value="{{.}}" id="{{.}}-radio" {{if eq . $.CurrentBroadcast.LivePrivacy}}checked{{end}} />
<label class="text-capitalize" for="{{.}}-radio">{{.}}</label>
</div>
{{end}}
</div>
</div>
<div class="d-flex align-items-center gap-1 mb-1">
<label for="account" class="w-25 text-end">Post Live Privacy:</label>
<div class="d-flex align-items-center gap-3 flex-row">
{{range .Settings.Privacy}}
<div>
<input type="radio" name="privacy" value="{{.}}" id="{{.}}-radio" {{if eq . $.CurrentBroadcast.Privacy}}checked{{end}} />
<input type="radio" name="post-live-privacy" value="{{.}}" id="{{.}}-radio" {{if eq . $.CurrentBroadcast.PostLivePrivacy}}checked{{end}} />
<label class="text-capitalize" for="{{.}}-radio">{{.}}</label>
</div>
{{end}}
Expand Down
10 changes: 9 additions & 1 deletion cmd/oceantv/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ type BroadcastConfig struct {
CID string // ID of associated chat.
StreamName string // The name of the stream we'll bind to the broadcast.
Description string // The broadcast description shown below viewing window.
Privacy string // Privacy of the broadcast i.e. public, private or unlisted.
LivePrivacy string // Privacy of the broadcast whilst live i.e. public, private or unlisted.
PostLivePrivacy string // Privacy of the broadcast after it has ended i.e. public, private or unlisted.
Resolution string // Resolution of the stream e.g. 1080p.
StartTimestamp string // Start time of the broadcast in unix format.
Start time.Time // Start time in native go format for easy operations.
Expand Down Expand Up @@ -428,6 +429,13 @@ func stopBroadcast(ctx context.Context, cfg *BroadcastConfig, store datastore.St
return fmt.Errorf("save broadcast error: %w", err)
}

// Change privacy to post live privacy.
// This will also set the privacy of the video after the broadcast has ended.
err = svc.SetBroadcastPrivacy(ctx, cfg.ID, cfg.PostLivePrivacy)
if err != nil {
return fmt.Errorf("could not update broadcast privacy: %w", err)
}

return nil
}

Expand Down
11 changes: 6 additions & 5 deletions cmd/oceantv/broadcast_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (m *OceanBroadcastManager) CreateBroadcast(
cfg.Name+" "+dateStr,
cfg.Description,
cfg.StreamName,
cfg.Privacy,
cfg.LivePrivacy,
cfg.Resolution,
timeCreated,
cfg.End,
Expand Down Expand Up @@ -356,10 +356,11 @@ func (m *OceanBroadcastManager) SetupSecondary(ctx Ctx, cfg *Cfg, store Store) e
// configuration, except for a few of the fields.
_cfg.Name = secondaryName
_cfg.StreamName = secondaryName
_cfg.Privacy = "unlisted" // We don't want the secondary broadcast to be easily discovered by youtube watchers.
_cfg.OnActions = "" // We don't need it to have any control of the camera hardware.
_cfg.OffActions = "" // Ditto.
_cfg.SendMsg = true // It would be handy to have sensors stored in the store broadcasts too.
_cfg.LivePrivacy = "unlisted" // We don't want the secondary broadcast to be easily discovered by youtube watchers.
_cfg.PostLivePrivacy = "unlisted" // This will be public eventually, but not while the software is young.
_cfg.OnActions = "" // We don't need it to have any control of the camera hardware.
_cfg.OffActions = "" // Ditto.
_cfg.SendMsg = true // It would be handy to have sensors stored in the store broadcasts too.
_cfg.Start = cfg.Start
_cfg.End = cfg.End
_cfg.Resolution = cfg.Resolution
Expand Down
27 changes: 27 additions & 0 deletions cmd/oceantv/broadcast_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type BroadcastService interface {
RTMPKey(ctx context.Context, streamName string) (string, error)
CompleteBroadcast(ctx context.Context, id string) error
PostChatMessage(cID, msg string) error
SetBroadcastPrivacy(ctx context.Context, id, privacy string) error
}

// YouTubeResponse implements the ServerResponse interface for YouTube.
Expand Down Expand Up @@ -298,3 +299,29 @@ func (s *YouTubeBroadcastService) RTMPKey(ctx context.Context, streamName string
func (s *YouTubeBroadcastService) PostChatMessage(cID, msg string) error {
return broadcast.PostChatMessage(cID, s.tokenURI, msg)
}

// SetBroadcastPrivacy sets the broadcast privacy of the broadcast with
// identification ID to the provided privacy using the YouTube API.
// The privacy can be one of "public", "unlisted", or "private".
// This can be called before, during or after the broadcast.
// The broadcast and resulting video share ID and privacy settings.
func (s *YouTubeBroadcastService) SetBroadcastPrivacy(ctx context.Context, id, privacy string) error {
video := &youtube.Video{
Id: id,
Status: &youtube.VideoStatus{
PrivacyStatus: privacy,
},
}

svc, err := broadcast.GetService(ctx, youtube.YoutubeScope, s.tokenURI)
if err != nil {
return fmt.Errorf("could not get youtube service: %w", err)
}

call := svc.Videos.Update([]string{"status"}, video)
resp, err := call.Do()
if err != nil {
return fmt.Errorf("could not update video: %w, resp: %v", err, resp)
}
return nil
}
9 changes: 5 additions & 4 deletions cmd/oceantv/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,11 @@ func (d *dummyService) BroadcastStatus(ctx Ctx, id string) (string, error) { ret
func (d *dummyService) BroadcastScheduledStartTime(ctx Ctx, id string) (time.Time, error) {
return d.start, nil
}
func (d *dummyService) BroadcastHealth(ctx Ctx, id string) (string, error) { return "", nil }
func (d *dummyService) RTMPKey(ctx Ctx, streamName string) (string, error) { return "", nil }
func (d *dummyService) CompleteBroadcast(ctx Ctx, id string) error { return nil }
func (d *dummyService) PostChatMessage(id, msg string) error { return nil }
func (d *dummyService) BroadcastHealth(ctx Ctx, id string) (string, error) { return "", nil }
func (d *dummyService) RTMPKey(ctx Ctx, streamName string) (string, error) { return "", nil }
func (d *dummyService) CompleteBroadcast(ctx Ctx, id string) error { return nil }
func (d *dummyService) PostChatMessage(id, msg string) error { return nil }
func (d *dummyService) SetBroadcastPrivacy(ctx Ctx, id, privacy string) error { return nil }

type dummyForwardingService struct{}

Expand Down
2 changes: 1 addition & 1 deletion cmd/oceantv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (

const (
projectID = "oceantv"
version = "v0.6.0"
version = "v0.7.0"
projectURL = "https://oceantv.appspot.com"
cronServiceAccount = "oceancron@appspot.gserviceaccount.com"
locationID = "Australia/Adelaide" // TODO: Use site location.
Expand Down
Loading