Fix code so that it at least compiles.
parent
966dd7b507
commit
dee2142a0b
|
@ -35,17 +35,23 @@ func (channel *Channel) Metadata(ctx context.Context) <-chan map[string]string {
|
|||
go func() {
|
||||
for {
|
||||
select {
|
||||
case data := <-channel.metadataChannel:
|
||||
case data, ok := <-channel.metadataChannel:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
metadataChan <- data
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
return metadataChan
|
||||
}
|
||||
|
||||
func NewChannel() *Channel {
|
||||
return &Channel{
|
||||
metadataChannel: make(chan map[string]string),
|
||||
OutputStreams: map[string]ChannelOutputStream
|
||||
OutputStreams: map[string]ChannelOutputStream{},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,6 @@ import (
|
|||
type ChannelManager struct {
|
||||
channels map[string]*Channel
|
||||
channelsLock sync.RWMutex
|
||||
|
||||
channelStreams map[string]*ChannelStreams
|
||||
channelStreamsLock sync.RWMutex
|
||||
}
|
||||
|
||||
func (manager *ChannelManager) Channel(uuid string) *Channel {
|
||||
|
@ -25,25 +22,10 @@ func (manager *ChannelManager) Channel(uuid string) *Channel {
|
|||
return channel
|
||||
}
|
||||
|
||||
func (manager *ChannelManager) Streams(uuid string) *ChannelStreams {
|
||||
manager.channelStreamsLock.RLock()
|
||||
defer manager.channelStreamsLock.RUnlock()
|
||||
|
||||
streams, ok := manager.channelStreams[uuid]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
return streams
|
||||
}
|
||||
|
||||
func (manager *ChannelManager) Close(uuid string) (err error) {
|
||||
manager.channelsLock.Lock()
|
||||
defer manager.channelsLock.Unlock()
|
||||
|
||||
manager.channelStreamsLock.Lock()
|
||||
defer manager.channelStreamsLock.Unlock()
|
||||
|
||||
_, ok := manager.channels[uuid]
|
||||
if !ok {
|
||||
err = errors.New("channel uuid is not known")
|
||||
|
@ -51,7 +33,6 @@ func (manager *ChannelManager) Close(uuid string) (err error) {
|
|||
}
|
||||
|
||||
delete(manager.channels, uuid)
|
||||
delete(manager.channelStreams, uuid)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -65,13 +46,8 @@ func (manager *ChannelManager) Open(uuid string) (channel *Channel, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
manager.channelStreamsLock.Lock()
|
||||
defer manager.channelStreamsLock.Unlock()
|
||||
|
||||
channel = new(Channel)
|
||||
manager.channels[uuid] = channel
|
||||
|
||||
manager.channelStreams[uuid] = new(ChannelStreams)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -4,14 +4,8 @@ import (
|
|||
"io"
|
||||
|
||||
"git.icedream.tech/icedream/uplink/internal"
|
||||
"git.icedream.tech/icedream/uplink/internal/transcoders/options"
|
||||
)
|
||||
|
||||
type Transcoder interface {
|
||||
Options() map[string]options.TranscoderOptionType
|
||||
New(options map[string]interface{}) *TranscoderInstance
|
||||
}
|
||||
|
||||
type TranscoderInstance interface {
|
||||
io.WriteCloser
|
||||
Init(out *internal.Stream)
|
||||
|
|
|
@ -20,9 +20,7 @@ func (transcoder *Transcoder) Options() map[string]options.TranscoderOptionType
|
|||
}
|
||||
|
||||
func (transcoder *Transcoder) New(options map[string]interface{}) transcoders.TranscoderInstance {
|
||||
return &TranscoderInstance{
|
||||
options: options,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type TranscoderInstance struct {
|
||||
|
@ -30,7 +28,7 @@ type TranscoderInstance struct {
|
|||
*lame.LameWriter
|
||||
}
|
||||
|
||||
func (instance *TranscoderInstance) Init(out *internal.Stream) {
|
||||
func (instance *TranscoderInstance) Init(out *internal.Stream, samplerate int, channels int) {
|
||||
instance.LameWriter = lame.NewWriter(out)
|
||||
instance.LameWriter.Encoder.SetBitrate(int(instance.options["bitrate"].(int64)))
|
||||
instance.LameWriter.Encoder.SetQuality(int(instance.options["quality"].(int64)))
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
package transcoders
|
|
@ -0,0 +1,10 @@
|
|||
package transcoders
|
||||
|
||||
import (
|
||||
"git.icedream.tech/icedream/uplink/internal/transcoders/options"
|
||||
)
|
||||
|
||||
type Transcoder interface {
|
||||
Options() map[string]options.TranscoderOptionType
|
||||
New(options map[string]interface{}) *TranscoderInstance
|
||||
}
|
Loading…
Reference in New Issue