Browse Source

Fix godoc style comments (#356)

master
Christian Muehlhaeuser 10 months ago
committed by GitHub
parent
commit
2e1f8d29b5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 147 additions and 147 deletions
  1. +5
    -5
      config/config.go
  2. +1
    -1
      config/configUtils.go
  3. +1
    -1
      config/verifyInstall.go
  4. +1
    -1
      controllers/admin.go
  5. +1
    -1
      controllers/admin/changePageContent.go
  6. +1
    -1
      controllers/admin/changeStreamKey.go
  7. +1
    -1
      controllers/admin/disconnect.go
  8. +1
    -1
      controllers/admin/hardware.go
  9. +1
    -1
      controllers/admin/index.go
  10. +2
    -2
      controllers/admin/logs.go
  11. +1
    -1
      controllers/admin/serverConfig.go
  12. +1
    -1
      controllers/admin/status.go
  13. +1
    -1
      controllers/admin/viewers.go
  14. +1
    -1
      controllers/chat.go
  15. +1
    -1
      controllers/config.go
  16. +1
    -1
      controllers/connectedClients.go
  17. +2
    -2
      controllers/embed.go
  18. +1
    -1
      controllers/emoji.go
  19. +1
    -1
      controllers/index.go
  20. +1
    -1
      controllers/status.go
  21. +4
    -4
      core/chat/chat.go
  22. +6
    -6
      core/chat/client.go
  23. +6
    -6
      core/chat/server.go
  24. +6
    -6
      core/chatListener.go
  25. +1
    -1
      core/core.go
  26. +3
    -3
      core/ffmpeg/fileWriterReceiverService.go
  27. +4
    -4
      core/ffmpeg/hlsHandler.go
  28. +1
    -1
      core/ffmpeg/thumbnailGenerator.go
  29. +19
    -19
      core/ffmpeg/transcoder.go
  30. +1
    -1
      core/playlist/writer.go
  31. +1
    -1
      core/rtmp/rtmp.go
  32. +3
    -3
      core/stats.go
  33. +2
    -2
      core/status.go
  34. +5
    -5
      core/storageproviders/local.go
  35. +6
    -6
      core/storageproviders/s3Storage.go
  36. +4
    -4
      core/streamState.go
  37. +1
    -1
      geoip/geoip.go
  38. +3
    -3
      logging/logging.go
  39. +5
    -5
      main.go
  40. +4
    -4
      metrics/metrics.go
  41. +1
    -1
      metrics/viewers.go
  42. +1
    -1
      models/broadcaster.go
  43. +1
    -1
      models/chatListener.go
  44. +2
    -2
      models/chatMessage.go
  45. +1
    -1
      models/emoji.go
  46. +1
    -1
      models/nameChangeEvent.go
  47. +1
    -1
      models/pingMessage.go
  48. +3
    -3
      models/playlist.go
  49. +1
    -1
      models/stats.go
  50. +1
    -1
      models/status.go
  51. +1
    -1
      models/storageProvider.go
  52. +3
    -3
      router/middleware/caching.go
  53. +1
    -1
      router/middleware/cors.go
  54. +1
    -1
      router/router.go
  55. +2
    -2
      utils/clientId.go
  56. +4
    -4
      utils/performanceTimer.go
  57. +7
    -7
      utils/utils.go
  58. +1
    -1
      yp/api.go
  59. +3
    -3
      yp/yp.go

+ 5
- 5
config/config.go View File

@ -11,7 +11,7 @@ import (
"gopkg.in/yaml.v2"
)
//Config contains a reference to the configuration
// Config contains a reference to the configuration.
var Config *config
var _default config
@ -91,7 +91,7 @@ type files struct {
MaxNumberInPlaylist int `yaml:"maxNumberInPlaylist"`
}
//S3 is for configuring the S3 integration
// S3 is for configuring the S3 integration.
type S3 struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Endpoint string `yaml:"endpoint" json:"endpoint,omitempty"`
@ -229,7 +229,7 @@ func (c *config) GetVideoStreamQualities() []StreamQuality {
return _default.VideoSettings.StreamQualities
}
// GetFramerate returns the framerate or default
// GetFramerate returns the framerate or default.
func (q *StreamQuality) GetFramerate() int {
if q.Framerate > 0 {
return q.Framerate
@ -238,7 +238,7 @@ func (q *StreamQuality) GetFramerate() int {
return _default.VideoSettings.StreamQualities[0].Framerate
}
// GetEncoderPreset returns the preset or default
// GetEncoderPreset returns the preset or default.
func (q *StreamQuality) GetEncoderPreset() string {
if q.EncoderPreset != "" {
return q.EncoderPreset
@ -247,7 +247,7 @@ func (q *StreamQuality) GetEncoderPreset() string {
return _default.VideoSettings.StreamQualities[0].EncoderPreset
}
//Load tries to load the configuration file
// Load tries to load the configuration file.
func Load(filePath string, versionInfo string, versionNumber string) error {
Config = new(config)
_default = getDefaults()


+ 1
- 1
config/configUtils.go View File

@ -36,7 +36,7 @@ func findHighestQuality(qualities []StreamQuality) int {
return indexedQualities[0].index
}
// MarshalJSON is a custom JSON marshal function for video stream qualities
// MarshalJSON is a custom JSON marshal function for video stream qualities.
func (q *StreamQuality) MarshalJSON() ([]byte, error) {
type Alias StreamQuality
return json.Marshal(&struct {


+ 1
- 1
config/verifyInstall.go View File

@ -6,7 +6,7 @@ import (
"os"
)
//verifyFFMpegPath verifies that the path exists, is a file, and is executable
// verifyFFMpegPath verifies that the path exists, is a file, and is executable.
func verifyFFMpegPath(path string) error {
stat, err := os.Stat(path)


+ 1
- 1
controllers/admin.go View File

@ -6,7 +6,7 @@ import (
"github.com/owncast/owncast/core/rtmp"
)
// DisconnectInboundConnection will force-disconnect an inbound stream
// DisconnectInboundConnection will force-disconnect an inbound stream.
func DisconnectInboundConnection(w http.ResponseWriter, r *http.Request) {
rtmp.Disconnect()
w.WriteHeader(http.StatusOK)


+ 1
- 1
controllers/admin/changePageContent.go View File

@ -10,7 +10,7 @@ import (
log "github.com/sirupsen/logrus"
)
// ChangeExtraPageContent will change the optional page content
// ChangeExtraPageContent will change the optional page content.
func ChangeExtraPageContent(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
controllers.WriteSimpleResponse(w, false, r.Method+" not supported")


+ 1
- 1
controllers/admin/changeStreamKey.go View File

@ -10,7 +10,7 @@ import (
log "github.com/sirupsen/logrus"
)
// ChangeStreamKey will change the stream key (in memory)
// ChangeStreamKey will change the stream key (in memory).
func ChangeStreamKey(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
controllers.WriteSimpleResponse(w, false, r.Method+" not supported")


+ 1
- 1
controllers/admin/disconnect.go View File

@ -9,7 +9,7 @@ import (
"github.com/owncast/owncast/core/rtmp"
)
// DisconnectInboundConnection will force-disconnect an inbound stream
// DisconnectInboundConnection will force-disconnect an inbound stream.
func DisconnectInboundConnection(w http.ResponseWriter, r *http.Request) {
if !core.GetStatus().Online {
controllers.WriteSimpleResponse(w, false, "no inbound stream connected")


+ 1
- 1
controllers/admin/hardware.go View File

@ -7,7 +7,7 @@ import (
"github.com/owncast/owncast/metrics"
)
// GetHardwareStats will return hardware utilization over time
// GetHardwareStats will return hardware utilization over time.
func GetHardwareStats(w http.ResponseWriter, r *http.Request) {
m := metrics.Metrics


+ 1
- 1
controllers/admin/index.go View File

@ -11,7 +11,7 @@ import (
log "github.com/sirupsen/logrus"
)
// ServeAdmin will return admin web assets
// ServeAdmin will return admin web assets.
func ServeAdmin(w http.ResponseWriter, r *http.Request) {
// Set a cache control max-age header
middleware.SetCachingHeaders(w, r)


+ 2
- 2
controllers/admin/logs.go View File

@ -9,7 +9,7 @@ import (
"github.com/sirupsen/logrus"
)
// GetLogs will return all logs
// GetLogs will return all logs.
func GetLogs(w http.ResponseWriter, r *http.Request) {
logs := logging.Logger.AllEntries()
response := make([]logsResponse, 0)
@ -22,7 +22,7 @@ func GetLogs(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(response)
}
// GetWarnings will return only warning and error logs
// GetWarnings will return only warning and error logs.
func GetWarnings(w http.ResponseWriter, r *http.Request) {
logs := logging.Logger.WarningEntries()
response := make([]logsResponse, 0)


+ 1
- 1
controllers/admin/serverConfig.go View File

@ -7,7 +7,7 @@ import (
"github.com/owncast/owncast/config"
)
// GetServerConfig gets the config details of the server
// GetServerConfig gets the config details of the server.
func GetServerConfig(w http.ResponseWriter, r *http.Request) {
var videoQualityVariants = make([]config.StreamQuality, 0)
for _, variant := range config.Config.GetVideoStreamQualities() {


+ 1
- 1
controllers/admin/status.go View File

@ -9,7 +9,7 @@ import (
"github.com/owncast/owncast/models"
)
// Status gets the details of the inbound broadcaster
// Status gets the details of the inbound broadcaster.
func Status(w http.ResponseWriter, r *http.Request) {
broadcaster := core.GetBroadcaster()
status := core.GetStatus()


+ 1
- 1
controllers/admin/viewers.go View File

@ -7,7 +7,7 @@ import (
"github.com/owncast/owncast/metrics"
)
// GetViewersOverTime will return the number of viewers at points in time
// GetViewersOverTime will return the number of viewers at points in time.
func GetViewersOverTime(w http.ResponseWriter, r *http.Request) {
viewersOverTime := metrics.Metrics.Viewers
w.Header().Set("Content-Type", "application/json")


+ 1
- 1
controllers/chat.go View File

@ -9,7 +9,7 @@ import (
"github.com/owncast/owncast/router/middleware"
)
//GetChatMessages gets all of the chat messages
// GetChatMessages gets all of the chat messages.
func GetChatMessages(w http.ResponseWriter, r *http.Request) {
middleware.EnableCors(&w)


+ 1
- 1
controllers/config.go View File

@ -8,7 +8,7 @@ import (
"github.com/owncast/owncast/router/middleware"
)
//GetWebConfig gets the status of the server
// GetWebConfig gets the status of the server.
func GetWebConfig(w http.ResponseWriter, r *http.Request) {
middleware.EnableCors(&w)


+ 1
- 1
controllers/connectedClients.go View File

@ -7,7 +7,7 @@ import (
"github.com/owncast/owncast/core"
)
// GetConnectedClients returns currently connected clients
// GetConnectedClients returns currently connected clients.
func GetConnectedClients(w http.ResponseWriter, r *http.Request) {
clients := core.GetClients()
w.Header().Set("Content-Type", "application/json")


+ 2
- 2
controllers/embed.go View File

@ -4,12 +4,12 @@ import (
"net/http"
)
//GetChatEmbed gets the embed for chat
// GetChatEmbed gets the embed for chat.
func GetChatEmbed(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/index-standalone-chat.html", http.StatusMovedPermanently)
}
//GetVideoEmbed gets the embed for video
// GetVideoEmbed gets the embed for video.
func GetVideoEmbed(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/index-video-only.html", http.StatusMovedPermanently)
}

+ 1
- 1
controllers/emoji.go View File

@ -17,7 +17,7 @@ import (
// to need it to be. The config is getting a bit bloated.
const emojiDir = "/img/emoji" // Relative to webroot
//GetCustomEmoji returns a list of custom emoji via the API
// GetCustomEmoji returns a list of custom emoji via the API.
func GetCustomEmoji(w http.ResponseWriter, r *http.Request) {
emojiList := make([]models.CustomEmoji, 0)


+ 1
- 1
controllers/index.go View File

@ -25,7 +25,7 @@ type MetadataPage struct {
TagsString string
}
//IndexHandler handles the default index route
// IndexHandler handles the default index route.
func IndexHandler(w http.ResponseWriter, r *http.Request) {
middleware.EnableCors(&w)
isIndexRequest := r.URL.Path == "/" || filepath.Base(r.URL.Path) == "index.html" || filepath.Base(r.URL.Path) == ""


+ 1
- 1
controllers/status.go View File

@ -8,7 +8,7 @@ import (
"github.com/owncast/owncast/router/middleware"
)
//GetStatus gets the status of the server
// GetStatus gets the status of the server.
func GetStatus(w http.ResponseWriter, r *http.Request) {
middleware.EnableCors(&w)


+ 4
- 4
core/chat/chat.go View File

@ -7,7 +7,7 @@ import (
"github.com/owncast/owncast/models"
)
//Setup sets up the chat server
// Setup sets up the chat server.
func Setup(listener models.ChatListener) {
setupPersistence()
@ -32,7 +32,7 @@ func Setup(listener models.ChatListener) {
}
}
//Start starts the chat server
// Start starts the chat server.
func Start() error {
if _server == nil {
return errors.New("chat server is nil")
@ -53,7 +53,7 @@ func Start() error {
return errors.New("chat server failed to start")
}
//SendMessage sends a message to all
// SendMessage sends a message to all.
func SendMessage(message models.ChatMessage) {
if _server == nil {
return
@ -62,7 +62,7 @@ func SendMessage(message models.ChatMessage) {
_server.SendToAll(message)
}
//GetMessages gets all of the messages
// GetMessages gets all of the messages.
func GetMessages() []models.ChatMessage {
if _server == nil {
return []models.ChatMessage{}


+ 6
- 6
core/chat/client.go View File

@ -44,7 +44,7 @@ const (
PONG = "PONG"
)
//NewClient creates a new chat client
// NewClient creates a new chat client.
func NewClient(ws *websocket.Conn) *Client {
if ws == nil {
log.Panicln("ws cannot be nil")
@ -63,7 +63,7 @@ func NewClient(ws *websocket.Conn) *Client {
return &Client{time.Now(), 0, userAgent, ipAddress, nil, clientID, nil, socketID, ws, ch, pingch, usernameChangeChannel, doneCh}
}
//GetConnection gets the connection for the client
// GetConnection gets the connection for the client.
func (c *Client) GetConnection() *websocket.Conn {
return c.ws
}
@ -77,18 +77,18 @@ func (c *Client) Write(msg models.ChatMessage) {
}
}
//Done marks the client as done
// Done marks the client as done.
func (c *Client) Done() {
c.doneCh <- true
}
// Listen Write and Read request via chanel
// Listen Write and Read request via channel.
func (c *Client) Listen() {
go c.listenWrite()
c.listenRead()
}
// Listen write request via chanel
// Listen write request via channel.
func (c *Client) listenWrite() {
for {
select {
@ -110,7 +110,7 @@ func (c *Client) listenWrite() {
}
}
// Listen read request via chanel
// Listen read request via channel.
func (c *Client) listenRead() {
for {
select {


+ 6
- 6
core/chat/server.go View File

@ -16,7 +16,7 @@ var (
_server *server
)
//Server represents the server which handles the chat
// Server represents the server which handles the chat.
type server struct {
Clients map[string]*Client
@ -31,27 +31,27 @@ type server struct {
errCh chan error
}
//Add adds a client to the server
// Add adds a client to the server.
func (s *server) add(c *Client) {
s.addCh <- c
}
//Remove removes a client from the server
// Remove removes a client from the server.
func (s *server) remove(c *Client) {
s.delCh <- c
}
//SendToAll sends a message to all of the connected clients
// SendToAll sends a message to all of the connected clients.
func (s *server) SendToAll(msg models.ChatMessage) {
s.sendAllCh <- msg
}
//Done marks the server as done
// Done marks the server as done.
func (s *server) done() {
s.doneCh <- true
}
//Err handles an error
// Err handles an error.
func (s *server) err(err error) {
s.errCh <- err
}


+ 6
- 6
core/chatListener.go View File

@ -7,24 +7,24 @@ import (
"github.com/owncast/owncast/models"
)
//ChatListenerImpl the implementation of the chat client
// ChatListenerImpl the implementation of the chat client.
type ChatListenerImpl struct{}
//ClientAdded is for when a client is added the system
// ClientAdded is for when a client is added the system.
func (cl ChatListenerImpl) ClientAdded(client models.Client) {
SetClientActive(client)
}
//ClientRemoved is for when a client disconnects/is removed
// ClientRemoved is for when a client disconnects/is removed.
func (cl ChatListenerImpl) ClientRemoved(clientID string) {
RemoveClient(clientID)
}
//MessageSent is for when a message is sent
// MessageSent is for when a message is sent.
func (cl ChatListenerImpl) MessageSent(message models.ChatMessage) {
}
//SendMessageToChat sends a message to the chat server
// SendMessageToChat sends a message to the chat server.
func SendMessageToChat(message models.ChatMessage) error {
if !message.Valid() {
return errors.New("invalid chat message; id, author, and body are required")
@ -35,7 +35,7 @@ func SendMessageToChat(message models.ChatMessage) error {
return nil
}
//GetAllChatMessages gets all of the chat messages
// GetAllChatMessages gets all of the chat messages.
func GetAllChatMessages() []models.ChatMessage {
return chat.GetMessages()
}

+ 1
- 1
core/core.go View File

@ -28,7 +28,7 @@ var (
var handler ffmpeg.HLSHandler
var fileWriter = ffmpeg.FileWriterReceiverService{}
//Start starts up the core processing
// Start starts up the core processing.
func Start() error {
resetDirectories()


+ 3
- 3
core/ffmpeg/fileWriterReceiverService.go View File

@ -15,19 +15,19 @@ import (
log "github.com/sirupsen/logrus"
)
// FileWriterReceiverServiceCallback are to be fired when transcoder responses are written to disk
// FileWriterReceiverServiceCallback are to be fired when transcoder responses are written to disk.
type FileWriterReceiverServiceCallback interface {
SegmentWritten(localFilePath string)
VariantPlaylistWritten(localFilePath string)
MasterPlaylistWritten(localFilePath string)
}
// FileWriterReceiverService accepts transcoder responses via HTTP and fires the callbacks
// FileWriterReceiverService accepts transcoder responses via HTTP and fires the callbacks.
type FileWriterReceiverService struct {
callbacks FileWriterReceiverServiceCallback
}
// SetupFileWriterReceiverService will start listening for transcoder responses
// SetupFileWriterReceiverService will start listening for transcoder responses.
func (s *FileWriterReceiverService) SetupFileWriterReceiverService(callbacks FileWriterReceiverServiceCallback) {
s.callbacks = callbacks


+ 4
- 4
core/ffmpeg/hlsHandler.go View File

@ -4,22 +4,22 @@ import (
"github.com/owncast/owncast/models"
)
// HLSHandler gets told about available HLS playlists and segments
// HLSHandler gets told about available HLS playlists and segments.
type HLSHandler struct {
Storage models.StorageProvider
}
// SegmentWritten is fired when a HLS segment is written to disk
// SegmentWritten is fired when a HLS segment is written to disk.
func (h *HLSHandler) SegmentWritten(localFilePath string) {
h.Storage.SegmentWritten(localFilePath)
}
// VariantPlaylistWritten is fired when a HLS variant playlist is written to disk
// VariantPlaylistWritten is fired when a HLS variant playlist is written to disk.
func (h *HLSHandler) VariantPlaylistWritten(localFilePath string) {
h.Storage.VariantPlaylistWritten(localFilePath)
}
// MasterPlaylistWritten is fired when a HLS master playlist is written to disk
// MasterPlaylistWritten is fired when a HLS master playlist is written to disk.
func (h *HLSHandler) MasterPlaylistWritten(localFilePath string) {
h.Storage.MasterPlaylistWritten(localFilePath)
}

+ 1
- 1
core/ffmpeg/thumbnailGenerator.go View File

@ -21,7 +21,7 @@ func StopThumbnailGenerator() {
}
}
//StartThumbnailGenerator starts generating thumbnails
// StartThumbnailGenerator starts generating thumbnails.
func StartThumbnailGenerator(chunkPath string, variantIndex int) {
// Every 20 seconds create a thumbnail from the most
// recent video segment.


+ 19
- 19
core/ffmpeg/transcoder.go View File

@ -15,7 +15,7 @@ import (
var _commandExec *exec.Cmd
// Transcoder is a single instance of a video transcoder
// Transcoder is a single instance of a video transcoder.
type Transcoder struct {
input string
segmentOutputPath string
@ -30,7 +30,7 @@ type Transcoder struct {
TranscoderCompleted func(error)
}
// HLSVariant is a combination of settings that results in a single HLS stream
// HLSVariant is a combination of settings that results in a single HLS stream.
type HLSVariant struct {
index int
@ -45,13 +45,13 @@ type HLSVariant struct {
encoderPreset string // A collection of automatic settings for the encoder. https://trac.ffmpeg.org/wiki/Encode/H.264#crf
}
// VideoSize is the scaled size of the video output
// VideoSize is the scaled size of the video output.
type VideoSize struct {
Width int
Height int
}
// getString returns a WxH formatted getString for scaling video output
// getString returns a WxH formatted getString for scaling video output.
func (v *VideoSize) getString() string {
widthString := strconv.Itoa(v.Width)
heightString := strconv.Itoa(v.Height)
@ -197,7 +197,7 @@ func getVariantFromConfigQuality(quality config.StreamQuality, index int) HLSVar
return variant
}
// NewTranscoder will return a new Transcoder, populated by the config
// NewTranscoder will return a new Transcoder, populated by the config.
func NewTranscoder() *Transcoder {
transcoder := new(Transcoder)
transcoder.ffmpegPath = config.Config.GetFFMpegPath()
@ -248,7 +248,7 @@ func (v *HLSVariant) getVariantString(t *Transcoder) string {
return strings.Join(variantEncoderCommands, " ")
}
// Get the command flags for the variants
// Get the command flags for the variants.
func (t *Transcoder) getVariantsString() string {
var variantsCommandFlags = ""
var variantsStreamMaps = " -var_stream_map \""
@ -267,12 +267,12 @@ func (t *Transcoder) getVariantsString() string {
// If we'd like to keep the aspect ratio, we need to specify only one component, either width or height.
// Some codecs require the size of width and height to be a multiple of n. You can achieve this by setting the width or height to -n.
// SetVideoScalingWidth will set the scaled video width of this variant
// SetVideoScalingWidth will set the scaled video width of this variant.
func (v *HLSVariant) SetVideoScalingWidth(width int) {
v.videoSize.Width = width
}
// SetVideoScalingHeight will set the scaled video height of this variant
// SetVideoScalingHeight will set the scaled video height of this variant.
func (v *HLSVariant) SetVideoScalingHeight(height int) {
v.videoSize.Height = height
}
@ -284,7 +284,7 @@ func (v *HLSVariant) getScalingString() string {
// Video Quality
// SetVideoBitrate will set the output bitrate of this variant's video
// SetVideoBitrate will set the output bitrate of this variant's video.
func (v *HLSVariant) SetVideoBitrate(bitrate int) {
v.videoBitrate = bitrate
}
@ -321,19 +321,19 @@ func (v *HLSVariant) getVideoQualityString(t *Transcoder) string {
return strings.Join(cmd, " ")
}
// SetVideoFramerate will set the output framerate of this variant's video
// SetVideoFramerate will set the output framerate of this variant's video.
func (v *HLSVariant) SetVideoFramerate(framerate int) {
v.framerate = framerate
}
// SetEncoderPreset will set the video encoder preset of this variant
// SetEncoderPreset will set the video encoder preset of this variant.
func (v *HLSVariant) SetEncoderPreset(preset string) {
v.encoderPreset = preset
}
// Audio Quality
// SetAudioBitrate will set the output framerate of this variant's audio
// SetAudioBitrate will set the output framerate of this variant's audio.
func (v *HLSVariant) SetAudioBitrate(bitrate string) {
v.audioBitrate = bitrate
}
@ -348,38 +348,38 @@ func (v *HLSVariant) getAudioQualityString() string {
return fmt.Sprintf("-map a:0 -c:a:%d %s -b:a:%d %s", v.index, encoderCodec, v.index, v.audioBitrate)
}
// AddVariant adds a new HLS variant to include in the output
// AddVariant adds a new HLS variant to include in the output.
func (t *Transcoder) AddVariant(variant HLSVariant) {
variant.index = len(t.variants)
t.variants = append(t.variants, variant)
}
// SetInput sets the input stream on the filesystem
// SetInput sets the input stream on the filesystem.
func (t *Transcoder) SetInput(input string) {
t.input = input
}
// SetOutputPath sets the root directory that should include playlists and video segments
// SetOutputPath sets the root directory that should include playlists and video segments.
func (t *Transcoder) SetOutputPath(output string) {
t.segmentOutputPath = output
}
// SetHLSPlaylistLength will set the max number of items in a HLS variant's playlist
// SetHLSPlaylistLength will set the max number of items in a HLS variant's playlist.
func (t *Transcoder) SetHLSPlaylistLength(length int) {
t.hlsPlaylistLength = length
}
// SetSegmentLength Specifies the number of seconds each segment should be
// SetSegmentLength Specifies the number of seconds each segment should be.
func (t *Transcoder) SetSegmentLength(seconds int) {
t.segmentLengthSeconds = seconds
}
// SetAppendToStream enables appending to the HLS stream instead of overwriting
// SetAppendToStream enables appending to the HLS stream instead of overwriting.
func (t *Transcoder) SetAppendToStream(append bool) {
t.appendToStream = append
}
// SetIdentifer enables appending a unique identifier to segment file name
// SetIdentifer enables appending a unique identifier to segment file name.
func (t *Transcoder) SetIdentifier(output string) {
t.segmentIdentifier = output
}


+ 1
- 1
core/playlist/writer.go View File

@ -2,7 +2,7 @@ package playlist
import "os"
//WritePlaylist writes the playlist to disk
// WritePlaylist writes the playlist to disk.
func WritePlaylist(data string, filePath string) error {
f, err := os.Create(filePath)
if err != nil {


+ 1
- 1
core/rtmp/rtmp.go View File

@ -30,7 +30,7 @@ var _rtmpConnection net.Conn
var _setStreamAsConnected func()
var _setBroadcaster func(models.Broadcaster)
//Start starts the rtmp service, listening on port 1935
// Start starts the rtmp service, listening on port 1935.
func Start(setStreamAsConnected func(), setBroadcaster func(models.Broadcaster)) {
_setStreamAsConnected = setStreamAsConnected
_setBroadcaster = setBroadcaster


+ 3
- 3
core/stats.go View File

@ -46,7 +46,7 @@ func setupStats() error {
return nil
}
//IsStreamConnected checks if the stream is connected or not
// IsStreamConnected checks if the stream is connected or not.
func IsStreamConnected() bool {
if !_stats.StreamConnected {
return false
@ -62,7 +62,7 @@ func IsStreamConnected() bool {
return _stats.StreamConnected
}
//SetClientActive sets a client as active and connected
// SetClientActive sets a client as active and connected.
func SetClientActive(client models.Client) {
l.Lock()
// If this clientID already exists then update it.
@ -88,7 +88,7 @@ func SetClientActive(client models.Client) {
}
}
//RemoveClient removes a client from the active clients record
// RemoveClient removes a client from the active clients record.
func RemoveClient(clientID string) {
log.Trace("Removing the client:", clientID)


+ 2
- 2
core/status.go View File

@ -5,7 +5,7 @@ import (
"github.com/owncast/owncast/models"
)
//GetStatus gets the status of the system
// GetStatus gets the status of the system.
func GetStatus() models.Status {
if _stats == nil {
return models.Status{}
@ -22,7 +22,7 @@ func GetStatus() models.Status {
}
}
// setBroadcaster will store the current inbound broadcasting details
// setBroadcaster will store the current inbound broadcasting details.
func setBroadcaster(broadcaster models.Broadcaster) {
_broadcaster = &broadcaster
}


+ 5
- 5
core/storageproviders/local.go View File

@ -17,7 +17,7 @@ type LocalStorage struct {
// Cleanup old public HLS content every N min from the webroot.
var _onlineCleanupTicker *time.Ticker
// Setup configures this storage provider
// Setup configures this storage provider.
func (s *LocalStorage) Setup() error {
// NOTE: This cleanup timer will have to be disabled to support recordings in the future
// as all HLS segments have to be publicly available on disk to keep a recording of them.
@ -33,12 +33,12 @@ func (s *LocalStorage) Setup() error {
return nil
}
// SegmentWritten is called when a single segment of video is written
// SegmentWritten is called when a single segment of video is written.
func (s *LocalStorage) SegmentWritten(localFilePath string) {
s.Save(localFilePath, 0)
}
// VariantPlaylistWritten is called when a variant hls playlist is written
// VariantPlaylistWritten is called when a variant hls playlist is written.
func (s *LocalStorage) VariantPlaylistWritten(localFilePath string) {
_, err := s.Save(localFilePath, 0)
if err != nil {
@ -47,12 +47,12 @@ func (s *LocalStorage) VariantPlaylistWritten(localFilePath string) {
}
}
// MasterPlaylistWritten is called when the master hls playlist is written
// MasterPlaylistWritten is called when the master hls playlist is written.
func (s *LocalStorage) MasterPlaylistWritten(localFilePath string) {
s.Save(localFilePath, 0)
}
// Save will save a local filepath using the storage provider
// Save will save a local filepath using the storage provider.
func (s *LocalStorage) Save(filePath string, retryCount int) (string, error) {
newPath := ""


+ 6
- 6
core/storageproviders/s3Storage.go View File

@ -24,7 +24,7 @@ import (
// then keep a reference to it here.
var _queuedPlaylistUpdates = make(map[string]string, 0)
//S3Storage is the s3 implementation of the ChunkStorageProvider
// S3Storage is the s3 implementation of the ChunkStorageProvider.
type S3Storage struct {
sess *session.Session
host string
@ -40,7 +40,7 @@ type S3Storage struct {
var _uploader *s3manager.Uploader
//Setup sets up the s3 storage for saving the video to s3
// Setup sets up the s3 storage for saving the video to s3.
func (s *S3Storage) Setup() error {
log.Trace("Setting up S3 for external storage of video...")
@ -65,7 +65,7 @@ func (s *S3Storage) Setup() error {
return nil
}
// SegmentWritten is called when a single segment of video is written
// SegmentWritten is called when a single segment of video is written.
func (s *S3Storage) SegmentWritten(localFilePath string) {
index := utils.GetIndexFromFilePath(localFilePath)
performanceMonitorKey := "s3upload-" + index
@ -100,7 +100,7 @@ func (s *S3Storage) SegmentWritten(localFilePath string) {
}
}
// VariantPlaylistWritten is called when a variant hls playlist is written
// VariantPlaylistWritten is called when a variant hls playlist is written.
func (s *S3Storage) VariantPlaylistWritten(localFilePath string) {
// We are uploading the variant playlist after uploading the segment
// to make sure we're not referring to files in a playlist that don't
@ -115,13 +115,13 @@ func (s *S3Storage) VariantPlaylistWritten(localFilePath string) {
}
}
// MasterPlaylistWritten is called when the master hls playlist is written
// MasterPlaylistWritten is called when the master hls playlist is written.
func (s *S3Storage) MasterPlaylistWritten(localFilePath string) {
// Rewrite the playlist to use absolute remote S3 URLs
s.rewriteRemotePlaylist(localFilePath)
}
// Save saves the file to the s3 bucket
// Save saves the file to the s3 bucket.
func (s *S3Storage) Save(filePath string, retryCount int) (string, error) {
file, err := os.Open(filePath)
if err != nil {


+ 4
- 4
core/streamState.go View File

@ -23,7 +23,7 @@ var _offlineCleanupTimer *time.Timer
// While a stream takes place cleanup old HLS content every N min.
var _onlineCleanupTicker *time.Ticker
//setStreamAsConnected sets the stream as connected
// setStreamAsConnected sets the stream as connected.
func setStreamAsConnected() {
_stats.StreamConnected = true
_stats.LastConnectTime = utils.NullTime{time.Now(), true}
@ -53,7 +53,7 @@ func setStreamAsConnected() {
ffmpeg.StartThumbnailGenerator(segmentPath, config.Config.VideoSettings.HighestQualityStreamIndex)
}
//SetStreamAsDisconnected sets the stream as disconnected.
// SetStreamAsDisconnected sets the stream as disconnected.
func SetStreamAsDisconnected() {
_stats.StreamConnected = false
_stats.LastDisconnectTime = utils.NullTime{time.Now(), true}
@ -125,7 +125,7 @@ func SetStreamAsDisconnected() {
stopOnlineCleanupTimer()
}
// StartOfflineCleanupTimer will fire a cleanup after n minutes being disconnected
// StartOfflineCleanupTimer will fire a cleanup after n minutes being disconnected.
func StartOfflineCleanupTimer() {
_offlineCleanupTimer = time.NewTimer(5 * time.Minute)
go func() {
@ -141,7 +141,7 @@ func StartOfflineCleanupTimer() {
}()
}
// StopOfflineCleanupTimer will stop the previous cleanup timer
// StopOfflineCleanupTimer will stop the previous cleanup timer.
func StopOfflineCleanupTimer() {
if _offlineCleanupTimer != nil {
_offlineCleanupTimer.Stop()


+ 1
- 1
geoip/geoip.go View File

@ -15,7 +15,7 @@ import (
var _geoIPCache = map[string]GeoDetails{}
var _enabled = true // Try to use GeoIP support it by default.
// GeoDetails stores details about a location
// GeoDetails stores details about a location.
type GeoDetails struct {
CountryCode string `json:"countryCode"`
RegionName string `json:"regionName"`


+ 3
- 3
logging/logging.go View File

@ -20,7 +20,7 @@ type OCLogger struct {
var Logger *OCLogger
// Setup configures our custom logging destinations
// Setup configures our custom logging destinations.
func Setup() {
logger.SetOutput(os.Stdout) // Send all logs to console
@ -30,7 +30,7 @@ func Setup() {
Logger = _logger
}
// Fire runs for every logging request
// Fire runs for every logging request.
func (l *OCLogger) Fire(e *logger.Entry) error {
// Store all log messages to return back in the logging API
l.mu.Lock()
@ -44,7 +44,7 @@ func (l *OCLogger) Fire(e *logger.Entry) error {
return nil
}
// Levels specifies what log levels we care about
// Levels specifies what log levels we care about.
func (l *OCLogger) Levels() []logrus.Level {
return logrus.AllLevels
}


+ 5
- 5
main.go View File

@ -16,13 +16,13 @@ import (
"github.com/owncast/owncast/router"
)
// the following are injected at build-time
// the following are injected at build-time.
var (
//GitCommit is the commit which this version of owncast is running
// GitCommit is the commit which this version of owncast is running.
GitCommit = "unknown"
//BuildVersion is the version
// BuildVersion is the version.
BuildVersion = "0.0.0"
//BuildType is the type of build
// BuildType is the type of build.
BuildType = "localdev"
)
@ -77,7 +77,7 @@ func main() {
}
}
//getReleaseString gets the version string
// getReleaseString gets the version string.
func getReleaseString() string {
return fmt.Sprintf("Owncast v%s-%s (%s)", BuildVersion, BuildType, GitCommit)
}


+ 4
- 4
metrics/metrics.go View File

@ -4,10 +4,10 @@ import (
"time"
)
// How often we poll for updates
// How often we poll for updates.
const metricsPollingInterval = 1 * time.Minute
// CollectedMetrics stores different collected + timestamped values
// CollectedMetrics stores different collected + timestamped values.
type CollectedMetrics struct {
CPUUtilizations []timestampedValue `json:"cpu"`
RAMUtilizations []timestampedValue `json:"memory"`
@ -16,10 +16,10 @@ type CollectedMetrics struct {
Viewers []timestampedValue `json:"-"`
}
// Metrics is the shared Metrics instance
// Metrics is the shared Metrics instance.
var Metrics *CollectedMetrics
// Start will begin the metrics collection and alerting
// Start will begin the metrics collection and alerting.
func Start() {
Metrics = new(CollectedMetrics)
go startViewerCollectionMetrics()


+ 1
- 1
metrics/viewers.go View File

@ -6,7 +6,7 @@ import (
"github.com/owncast/owncast/core"
)
// How often we poll for updates
// How often we poll for updates.
const viewerMetricsPollingInterval = 5 * time.Minute
func startViewerCollectionMetrics() {


+ 1
- 1
models/broadcaster.go View File

@ -20,7 +20,7 @@ type InboundStreamDetails struct {
Encoder string `json:"encoder"`
}
// RTMPStreamMetadata is the raw metadata that comes in with a RTMP connection
// RTMPStreamMetadata is the raw metadata that comes in with a RTMP connection.
type RTMPStreamMetadata struct {
Width int `json:"width"`
Height int `json:"height"`


+ 1
- 1
models/chatListener.go View File

@ -1,6 +1,6 @@
package models
//ChatListener represents the listener for the chat server
// ChatListener represents the listener for the chat server.
type ChatListener interface {
ClientAdded(client Client)
ClientRemoved(clientID string)


+ 2
- 2
models/chatMessage.go View File

@ -12,7 +12,7 @@ import (
"mvdan.cc/xurls"
)
//ChatMessage represents a single chat message
// ChatMessage represents a single chat message.
type ChatMessage struct {
ClientID string `json:"-"`
@ -24,7 +24,7 @@ type ChatMessage struct {
Timestamp time.Time `json:"timestamp"`
}
//Valid checks to ensure the message is valid
// Valid checks to ensure the message is valid.
func (m ChatMessage) Valid() bool {
return m.Author != "" && m.Body != "" && m.ID != ""
}


+ 1
- 1
models/emoji.go View File

@ -1,6 +1,6 @@
package models
//CustomEmoji represents an image that can be used in chat as a custom emoji
// CustomEmoji represents an image that can be used in chat as a custom emoji.
type CustomEmoji struct {
Name string `json:"name"`
Emoji string `json:"emoji"`


+ 1
- 1
models/nameChangeEvent.go View File

@ -1,6 +1,6 @@
package models
//NameChangeEvent represents a user changing their name in chat
// NameChangeEvent represents a user changing their name in chat.
type NameChangeEvent struct {
OldName string `json:"oldName"`
NewName string `json:"newName"`


+ 1
- 1
models/pingMessage.go View File

@ -1,6 +1,6 @@
package models
//PingMessage represents a ping message between the client and server
// PingMessage represents a ping message between the client and server.
type PingMessage struct {
MessageType string `json:"type"`
}

+ 3
- 3
models/playlist.go View File

@ -1,6 +1,6 @@
package models
//Segment represents a segment of the live stream
// Segment represents a segment of the live stream.
type Segment struct {
VariantIndex int // The bitrate variant
FullDiskPath string // Where it lives on disk
@ -8,13 +8,13 @@ type Segment struct {
RemoteURL string
}
//Variant represents a single video variant and the segments that make it up
// Variant represents a single video variant and the segments that make it up.
type Variant struct {
VariantIndex int
Segments map[string]*Segment
}
//GetSegmentForFilename gets the segment for the provided filename
// GetSegmentForFilename gets the segment for the provided filename.
func (v *Variant) GetSegmentForFilename(filename string) *Segment {
return v.Segments[filename]
}

+ 1
- 1
models/stats.go View File

@ -4,7 +4,7 @@ import (
"github.com/owncast/owncast/utils"
)
//Stats holds the stats for the system
// Stats holds the stats for the system.
type Stats struct {
SessionMaxViewerCount int `json:"sessionMaxViewerCount"`
OverallMaxViewerCount int `json:"overallMaxViewerCount"`


+ 1
- 1
models/status.go View File

@ -2,7 +2,7 @@ package models
import "github.com/owncast/owncast/utils"
//Status represents the status of the system
// Status represents the status of the system.
type Status struct {
Online bool `json:"online"`
ViewerCount int `json:"viewerCount"`


+ 1
- 1
models/storageProvider.go View File

@ -1,6 +1,6 @@
package models
//StorageProvider is how a chunk storage provider should be implemented
// StorageProvider is how a chunk storage provider should be implemented.
type StorageProvider interface {
Setup() error
Save(filePath string, retryCount int) (string, error)


+ 3
- 3
router/middleware/caching.go View File

@ -10,7 +10,7 @@ import (
"github.com/owncast/owncast/utils"
)
//DisableCache writes the disable cache header on the responses
// DisableCache writes the disable cache header on the responses.
func DisableCache(w http.ResponseWriter) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Expires", "Thu, 1 Jan 1970 00:00:00 GMT")
@ -21,7 +21,7 @@ func setCacheSeconds(seconds int, w http.ResponseWriter) {
w.Header().Set("Cache-Control", "public, max-age="+secondsStr)
}
// ProcessEtags gets and sets ETags for caching purposes
// ProcessEtags gets and sets ETags for caching purposes.
func ProcessEtags(w http.ResponseWriter, r *http.Request) int {
info, err := os.Stat(filepath.Join("webroot", r.URL.Path))
if err != nil {
@ -40,7 +40,7 @@ func ProcessEtags(w http.ResponseWriter, r *http.Request) int {
return 0
}
// SetCachingHeaders will set the cache control header of a response
// SetCachingHeaders will set the cache control header of a response.
func SetCachingHeaders(w http.ResponseWriter, r *http.Request) {
setCacheSeconds(utils.GetCacheDurationSecondsForPath(r.URL.Path), w)
}

+ 1
- 1
router/middleware/cors.go View File

@ -4,7 +4,7 @@ import (
"net/http"
)
//EnableCors enables the cors header on the responses
// EnableCors enables the cors header on the responses.
func EnableCors(w *http.ResponseWriter) {
(*w).Header().Set("Access-Control-Allow-Origin", "*")
}

+ 1
- 1
router/router.go View File

@ -14,7 +14,7 @@ import (
"github.com/owncast/owncast/yp"
)
//Start starts the router for the http, ws, and rtmp
// Start starts the router for the http, ws, and rtmp.
func Start() error {
// static files
http.HandleFunc("/", controllers.IndexHandler)


+ 2
- 2
utils/clientId.go View File

@ -10,7 +10,7 @@ import (
log "github.com/sirupsen/logrus"
)
//GenerateClientIDFromRequest generates a client id from the provided request
// GenerateClientIDFromRequest generates a client id from the provided request.
func GenerateClientIDFromRequest(req *http.Request) string {
ipAddress := GetIPAddressFromRequest(req)
ipAddressComponents := strings.Split(ipAddress, ":")
@ -23,7 +23,7 @@ func GenerateClientIDFromRequest(req *http.Request) string {
return hex.EncodeToString(hasher.Sum(nil))
}
// GetIPAddressFromRequest returns the IP address from a http request
// GetIPAddressFromRequest returns the IP address from a http request.
func GetIPAddressFromRequest(req *http.Request) string {
ipAddressString := req.RemoteAddr
xForwardedFor := req.Header.Get("X-FORWARDED-FOR")


+ 4
- 4
utils/performanceTimer.go View File

@ -5,13 +5,13 @@ import (
"time"
)
// The "start" timestamp of a timing event
// The "start" timestamp of a timing event.
var _pointsInTime = make(map[string]time.Time)
// A collection of timestamp durations for returning the average of
// A collection of timestamp durations for returning the average of.
var _durationStorage = make(map[string][]float64)
// StartPerformanceMonitor will keep track of the start time of this event
// StartPerformanceMonitor will keep track of the start time of this event.
func StartPerformanceMonitor(key string) {
if len(_durationStorage[key]) > 30 {
_durationStorage[key] = removeHighAndLow(_durationStorage[key])
@ -19,7 +19,7 @@ func StartPerformanceMonitor(key string) {
_pointsInTime[key] = time.Now()
}
// GetAveragePerformance will return the average durations for the event
// GetAveragePerformance will return the average durations for the event.
func GetAveragePerformance(key string) float64 {
timestamp := _pointsInTime[key]
if timestamp.IsZero() {


+ 7
- 7
utils/utils.go View File

@ -15,12 +15,12 @@ import (
"mvdan.cc/xurls"
)
//GetTemporaryPipePath gets the temporary path for the streampipe.flv file
// GetTemporaryPipePath gets the temporary path for the streampipe.flv file.
func GetTemporaryPipePath() string {
return filepath.Join(os.TempDir(), "streampipe.flv")
}
//DoesFileExists checks if the file exists
// DoesFileExists checks if the file exists.
func DoesFileExists(name string) bool {
if _, err := os.Stat(name); err != nil {
if os.IsNotExist(err) {
@ -31,7 +31,7 @@ func DoesFileExists(name string) bool {
return true
}
//GetRelativePathFromAbsolutePath gets the relative path from the provided absolute path
// GetRelativePathFromAbsolutePath gets the relative path from the provided absolute path.
func GetRelativePathFromAbsolutePath(path string) string {
pathComponents := strings.Split(path, "/")
variant := pathComponents[len(pathComponents)-2]
@ -47,7 +47,7 @@ func GetIndexFromFilePath(path string) string {
return variant
}
//Copy copies the file to destination
// Copy copies the file to destination.
func Copy(source, destination string) error {
input, err := ioutil.ReadFile(source)
if err != nil {
@ -57,12 +57,12 @@ func Copy(source, destination string) error {
return ioutil.WriteFile(destination, input, 0644)
}
//Move moves the file to destination
// Move moves the file to destination.
func Move(source, destination string) error {
return os.Rename(source, destination)
}
// IsUserAgentABot returns if a web client user-agent is seen as a bot
// IsUserAgentABot returns if a web client user-agent is seen as a bot.
func IsUserAgentABot(userAgent string) bool {
if userAgent == "" {
return false
@ -111,7 +111,7 @@ func RenderSimpleMarkdown(raw string) string {
return buf.String()
}
// GetCacheDurationSecondsForPath will return the number of seconds to cache an item
// GetCacheDurationSecondsForPath will return the number of seconds to cache an item.
func GetCacheDurationSecondsForPath(filePath string) int {
if path.Base(filePath) == "thumbnail.jpg" {
// Thumbnails re-generate during live


+ 1
- 1
yp/api.go View File

@ -22,7 +22,7 @@ type ypDetailsResponse struct {
LastConnectTime utils.NullTime `json:"lastConnectTime"`
}
//GetYPResponse gets the status of the server for YP purposes
// GetYPResponse gets the status of the server for YP purposes.
func GetYPResponse(w http.ResponseWriter, r *http.Request) {
status := getStatus()


+ 3
- 3
yp/yp.go View File

@ -38,13 +38,13 @@ type ypPingRequest struct {
URL string `json:"url"`
}
// NewYP creates a new instance of the YP service handler
// NewYP creates a new instance of the YP service handler.
func NewYP(getStatusFunc func() models.Status) *YP {
getStatus = getStatusFunc
return &YP{}
}
// Start is run when a live stream begins to start pinging YP
// Start is run when a live stream begins to start pinging YP.
func (yp *YP) Start() {
yp.timer = time.NewTicker(pingInterval)
@ -60,7 +60,7 @@ func (yp *YP) Start() {
yp.ping()
}
// Stop stops the pinging of YP
// Stop stops the pinging of YP.
func (yp *YP) Stop() {
yp.timer.Stop()
}


Loading…
Cancel
Save