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() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case data := <-channel.metadataChannel:
|
case data, ok := <-channel.metadataChannel:
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
metadataChan <- data
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
return metadataChan
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewChannel() *Channel {
|
func NewChannel() *Channel {
|
||||||
return &Channel{
|
return &Channel{
|
||||||
metadataChannel: make(chan map[string]string),
|
metadataChannel: make(chan map[string]string),
|
||||||
OutputStreams: map[string]ChannelOutputStream
|
OutputStreams: map[string]ChannelOutputStream{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,6 @@ import (
|
||||||
type ChannelManager struct {
|
type ChannelManager struct {
|
||||||
channels map[string]*Channel
|
channels map[string]*Channel
|
||||||
channelsLock sync.RWMutex
|
channelsLock sync.RWMutex
|
||||||
|
|
||||||
channelStreams map[string]*ChannelStreams
|
|
||||||
channelStreamsLock sync.RWMutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *ChannelManager) Channel(uuid string) *Channel {
|
func (manager *ChannelManager) Channel(uuid string) *Channel {
|
||||||
|
@ -25,25 +22,10 @@ func (manager *ChannelManager) Channel(uuid string) *Channel {
|
||||||
return 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) {
|
func (manager *ChannelManager) Close(uuid string) (err error) {
|
||||||
manager.channelsLock.Lock()
|
manager.channelsLock.Lock()
|
||||||
defer manager.channelsLock.Unlock()
|
defer manager.channelsLock.Unlock()
|
||||||
|
|
||||||
manager.channelStreamsLock.Lock()
|
|
||||||
defer manager.channelStreamsLock.Unlock()
|
|
||||||
|
|
||||||
_, ok := manager.channels[uuid]
|
_, ok := manager.channels[uuid]
|
||||||
if !ok {
|
if !ok {
|
||||||
err = errors.New("channel uuid is not known")
|
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.channels, uuid)
|
||||||
delete(manager.channelStreams, uuid)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -65,13 +46,8 @@ func (manager *ChannelManager) Open(uuid string) (channel *Channel, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
manager.channelStreamsLock.Lock()
|
|
||||||
defer manager.channelStreamsLock.Unlock()
|
|
||||||
|
|
||||||
channel = new(Channel)
|
channel = new(Channel)
|
||||||
manager.channels[uuid] = channel
|
manager.channels[uuid] = channel
|
||||||
|
|
||||||
manager.channelStreams[uuid] = new(ChannelStreams)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,8 @@ import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"git.icedream.tech/icedream/uplink/internal"
|
"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 {
|
type TranscoderInstance interface {
|
||||||
io.WriteCloser
|
io.WriteCloser
|
||||||
Init(out *internal.Stream)
|
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 {
|
func (transcoder *Transcoder) New(options map[string]interface{}) transcoders.TranscoderInstance {
|
||||||
return &TranscoderInstance{
|
return nil
|
||||||
options: options,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TranscoderInstance struct {
|
type TranscoderInstance struct {
|
||||||
|
@ -30,7 +28,7 @@ type TranscoderInstance struct {
|
||||||
*lame.LameWriter
|
*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 = lame.NewWriter(out)
|
||||||
instance.LameWriter.Encoder.SetBitrate(int(instance.options["bitrate"].(int64)))
|
instance.LameWriter.Encoder.SetBitrate(int(instance.options["bitrate"].(int64)))
|
||||||
instance.LameWriter.Encoder.SetQuality(int(instance.options["quality"].(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