mirror of
https://github.com/owncast/owncast.git
synced 2025-11-03 04:27:18 +08:00
Expanded linting + fix warnings (#1396)
* Expand the linters and types of warnings to improve consistency and safety * Fail lint workflow if there are errors * golint has been replaced by revive * Hand-pick some of the default exclude list * Ignore error when trying to delete preview gif * Ignore linter warning opening playlist path * Rename user field Id -> ID * A bunch of renames to address linter warnings * Rename ChatClient -> Client per linter suggestion best practice * Rename ChatServer -> Server per linter suggestion best practice * More linter warning fixes * Add missing comments to all exported functions and properties
This commit is contained in:
@ -29,35 +29,43 @@ var supportedCodecs = map[string]string{
|
||||
(&NvencCodec{}).Name(): "NVIDIA nvenc",
|
||||
}
|
||||
|
||||
// Libx264Codec represents an instance of the Libx264 Codec.
|
||||
type Libx264Codec struct {
|
||||
}
|
||||
|
||||
// Name returns the codec name.
|
||||
func (c *Libx264Codec) Name() string {
|
||||
return "libx264"
|
||||
}
|
||||
|
||||
// DisplayName returns the human readable name of the codec.
|
||||
func (c *Libx264Codec) DisplayName() string {
|
||||
return "x264"
|
||||
}
|
||||
|
||||
// GlobalFlags are the global flags used with this codec in the transcoder.
|
||||
func (c *Libx264Codec) GlobalFlags() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// PixelFormat is the pixel format required for this codec.
|
||||
func (c *Libx264Codec) PixelFormat() string {
|
||||
return "yuv420p" //nolint:goconst
|
||||
}
|
||||
|
||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||
func (c *Libx264Codec) ExtraArguments() string {
|
||||
return strings.Join([]string{
|
||||
"-tune", "zerolatency", // Option used for good for fast encoding and low-latency streaming (always includes iframes in each segment)
|
||||
}, " ")
|
||||
}
|
||||
|
||||
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
||||
func (c *Libx264Codec) ExtraFilters() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// VariantFlags returns a string representing a single variant processed by this codec.
|
||||
func (c *Libx264Codec) VariantFlags(v *HLSVariant) string {
|
||||
bufferSize := int(float64(v.videoBitrate) * 1.2) // How often it checks the bitrate of encoded segments to see if it's too high/low.
|
||||
|
||||
@ -68,6 +76,7 @@ func (c *Libx264Codec) VariantFlags(v *HLSVariant) string {
|
||||
}, " ")
|
||||
}
|
||||
|
||||
// GetPresetForLevel returns the string preset for this codec given an integer level.
|
||||
func (c *Libx264Codec) GetPresetForLevel(l int) string {
|
||||
presetMapping := []string{
|
||||
"ultrafast",
|
||||
@ -84,39 +93,48 @@ func (c *Libx264Codec) GetPresetForLevel(l int) string {
|
||||
return presetMapping[l]
|
||||
}
|
||||
|
||||
// OmxCodec represents an instance of the Omx codec.
|
||||
type OmxCodec struct {
|
||||
}
|
||||
|
||||
// Name returns the codec name.
|
||||
func (c *OmxCodec) Name() string {
|
||||
return "h264_omx"
|
||||
}
|
||||
|
||||
// DisplayName returns the human readable name of the codec.
|
||||
func (c *OmxCodec) DisplayName() string {
|
||||
return "OpenMAX (omx)"
|
||||
}
|
||||
|
||||
// GlobalFlags are the global flags used with this codec in the transcoder.
|
||||
func (c *OmxCodec) GlobalFlags() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// PixelFormat is the pixel format required for this codec.
|
||||
func (c *OmxCodec) PixelFormat() string {
|
||||
return "yuv420p"
|
||||
}
|
||||
|
||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||
func (c *OmxCodec) ExtraArguments() string {
|
||||
return strings.Join([]string{
|
||||
"-tune", "zerolatency", // Option used for good for fast encoding and low-latency streaming (always includes iframes in each segment)
|
||||
}, " ")
|
||||
}
|
||||
|
||||
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
||||
func (c *OmxCodec) ExtraFilters() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// VariantFlags returns a string representing a single variant processed by this codec.
|
||||
func (c *OmxCodec) VariantFlags(v *HLSVariant) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetPresetForLevel returns the string preset for this codec given an integer level.
|
||||
func (c *OmxCodec) GetPresetForLevel(l int) string {
|
||||
presetMapping := []string{
|
||||
"ultrafast",
|
||||
@ -133,17 +151,21 @@ func (c *OmxCodec) GetPresetForLevel(l int) string {
|
||||
return presetMapping[l]
|
||||
}
|
||||
|
||||
// VaapiCodec represents an instance of the Vaapi codec.
|
||||
type VaapiCodec struct {
|
||||
}
|
||||
|
||||
// Name returns the codec name.
|
||||
func (c *VaapiCodec) Name() string {
|
||||
return "h264_vaapi"
|
||||
}
|
||||
|
||||
// DisplayName returns the human readable name of the codec.
|
||||
func (c *VaapiCodec) DisplayName() string {
|
||||
return "VA-API"
|
||||
}
|
||||
|
||||
// GlobalFlags are the global flags used with this codec in the transcoder.
|
||||
func (c *VaapiCodec) GlobalFlags() string {
|
||||
flags := []string{
|
||||
"-vaapi_device", "/dev/dri/renderD128",
|
||||
@ -152,22 +174,27 @@ func (c *VaapiCodec) GlobalFlags() string {
|
||||
return strings.Join(flags, " ")
|
||||
}
|
||||
|
||||
// PixelFormat is the pixel format required for this codec.
|
||||
func (c *VaapiCodec) PixelFormat() string {
|
||||
return "vaapi_vld"
|
||||
}
|
||||
|
||||
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
||||
func (c *VaapiCodec) ExtraFilters() string {
|
||||
return "format=nv12,hwupload"
|
||||
}
|
||||
|
||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||
func (c *VaapiCodec) ExtraArguments() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// VariantFlags returns a string representing a single variant processed by this codec.
|
||||
func (c *VaapiCodec) VariantFlags(v *HLSVariant) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetPresetForLevel returns the string preset for this codec given an integer level.
|
||||
func (c *VaapiCodec) GetPresetForLevel(l int) string {
|
||||
presetMapping := []string{
|
||||
"ultrafast",
|
||||
@ -184,17 +211,21 @@ func (c *VaapiCodec) GetPresetForLevel(l int) string {
|
||||
return presetMapping[l]
|
||||
}
|
||||
|
||||
// NvencCodec represents an instance of the Nvenc Codec.
|
||||
type NvencCodec struct {
|
||||
}
|
||||
|
||||
// Name returns the codec name.
|
||||
func (c *NvencCodec) Name() string {
|
||||
return "h264_nvenc"
|
||||
}
|
||||
|
||||
// DisplayName returns the human readable name of the codec.
|
||||
func (c *NvencCodec) DisplayName() string {
|
||||
return "nvidia nvenc"
|
||||
}
|
||||
|
||||
// GlobalFlags are the global flags used with this codec in the transcoder.
|
||||
func (c *NvencCodec) GlobalFlags() string {
|
||||
flags := []string{
|
||||
"-hwaccel cuda",
|
||||
@ -203,23 +234,28 @@ func (c *NvencCodec) GlobalFlags() string {
|
||||
return strings.Join(flags, " ")
|
||||
}
|
||||
|
||||
// PixelFormat is the pixel format required for this codec.
|
||||
func (c *NvencCodec) PixelFormat() string {
|
||||
return "yuv420p"
|
||||
}
|
||||
|
||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||
func (c *NvencCodec) ExtraArguments() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
||||
func (c *NvencCodec) ExtraFilters() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// VariantFlags returns a string representing a single variant processed by this codec.
|
||||
func (c *NvencCodec) VariantFlags(v *HLSVariant) string {
|
||||
tuning := "ll" // low latency
|
||||
return fmt.Sprintf("-tune:v:%d %s", v.index, tuning)
|
||||
}
|
||||
|
||||
// GetPresetForLevel returns the string preset for this codec given an integer level.
|
||||
func (c *NvencCodec) GetPresetForLevel(l int) string {
|
||||
presetMapping := []string{
|
||||
"p1",
|
||||
@ -236,37 +272,46 @@ func (c *NvencCodec) GetPresetForLevel(l int) string {
|
||||
return presetMapping[l]
|
||||
}
|
||||
|
||||
// QuicksyncCodec represents an instance of the Intel Quicksync Codec.
|
||||
type QuicksyncCodec struct {
|
||||
}
|
||||
|
||||
// Name returns the codec name.
|
||||
func (c *QuicksyncCodec) Name() string {
|
||||
return "h264_qsv"
|
||||
}
|
||||
|
||||
// DisplayName returns the human readable name of the codec.
|
||||
func (c *QuicksyncCodec) DisplayName() string {
|
||||
return "Intel QuickSync"
|
||||
}
|
||||
|
||||
// GlobalFlags are the global flags used with this codec in the transcoder.
|
||||
func (c *QuicksyncCodec) GlobalFlags() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// PixelFormat is the pixel format required for this codec.
|
||||
func (c *QuicksyncCodec) PixelFormat() string {
|
||||
return "nv12"
|
||||
}
|
||||
|
||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||
func (c *QuicksyncCodec) ExtraArguments() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
||||
func (c *QuicksyncCodec) ExtraFilters() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// VariantFlags returns a string representing a single variant processed by this codec.
|
||||
func (c *QuicksyncCodec) VariantFlags(v *HLSVariant) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetPresetForLevel returns the string preset for this codec given an integer level.
|
||||
func (c *QuicksyncCodec) GetPresetForLevel(l int) string {
|
||||
presetMapping := []string{
|
||||
"ultrafast",
|
||||
@ -283,36 +328,45 @@ func (c *QuicksyncCodec) GetPresetForLevel(l int) string {
|
||||
return presetMapping[l]
|
||||
}
|
||||
|
||||
// Video4Linux represents an instance of the V4L Codec.
|
||||
type Video4Linux struct{}
|
||||
|
||||
// Name returns the codec name.
|
||||
func (c *Video4Linux) Name() string {
|
||||
return "h264_v4l2m2m"
|
||||
}
|
||||
|
||||
// DisplayName returns the human readable name of the codec.
|
||||
func (c *Video4Linux) DisplayName() string {
|
||||
return "Video4Linux"
|
||||
}
|
||||
|
||||
// GlobalFlags are the global flags used with this codec in the transcoder.
|
||||
func (c *Video4Linux) GlobalFlags() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// PixelFormat is the pixel format required for this codec.
|
||||
func (c *Video4Linux) PixelFormat() string {
|
||||
return "nv21"
|
||||
}
|
||||
|
||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||
func (c *Video4Linux) ExtraArguments() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
||||
func (c *Video4Linux) ExtraFilters() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// VariantFlags returns a string representing a single variant processed by this codec.
|
||||
func (c *Video4Linux) VariantFlags(v *HLSVariant) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetPresetForLevel returns the string preset for this codec given an integer level.
|
||||
func (c *Video4Linux) GetPresetForLevel(l int) string {
|
||||
presetMapping := []string{
|
||||
"ultrafast",
|
||||
|
||||
Reference in New Issue
Block a user