예제 #1
0
파일: handlers.go 프로젝트: tarantoj/gumble
func (c *Client) handleCodecVersion(buffer []byte) error {
	var packet MumbleProto.CodecVersion
	if err := proto.Unmarshal(buffer, &packet); err != nil {
		return err
	}
	event := ServerConfigEvent{
		Client: c,
	}
	event.CodecAlpha = packet.Alpha
	event.CodecBeta = packet.Beta
	{
		val := packet.GetPreferAlpha()
		event.CodecPreferAlpha = &val
	}
	{
		val := packet.GetOpus()
		event.CodecOpus = &val
	}

	var codec AudioCodec
	switch {
	case *event.CodecOpus:
		codec = audioCodecs[audioCodecIDOpus]
	}
	if codec != nil {
		c.audioCodec = codec
		c.AudioEncoder = codec.NewEncoder()
		for _, user := range c.Users {
			user.decoder = codec.NewDecoder()
		}
	}

	c.listeners.OnServerConfig(&event)
	return nil
}
예제 #2
0
func (c *Client) handleCodecVersion(buffer []byte) error {
	var packet MumbleProto.CodecVersion
	if err := proto.Unmarshal(buffer, &packet); err != nil {
		return err
	}
	event := ServerConfigEvent{
		Client: c,
	}
	event.CodecAlpha = packet.Alpha
	event.CodecBeta = packet.Beta
	{
		val := packet.GetPreferAlpha()
		event.CodecPreferAlpha = &val
	}
	{
		val := packet.GetOpus()
		event.CodecOpus = &val
	}

	var codec AudioCodec
	switch {
	case *event.CodecOpus:
		codec = getAudioCodec(audioCodecIDOpus)
	}
	if codec != nil {
		c.audioCodec = codec

		{
			c.volatileLock.Lock()
			c.volatileWg.Wait()

			c.AudioEncoder = codec.NewEncoder()

			c.volatileLock.Unlock()
		}
	}

	c.Config.Listeners.onServerConfig(&event)
	return nil
}