mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-09-26 20:31:11 +08:00
Change codec channels from uint16 to uint8
This commit is contained in:
@@ -53,7 +53,7 @@ func ConfigToCodec(conf []byte) *core.Codec {
|
|||||||
codec.ClockRate = rd.ReadBits(24)
|
codec.ClockRate = rd.ReadBits(24)
|
||||||
}
|
}
|
||||||
|
|
||||||
codec.Channels = rd.ReadBits16(4)
|
codec.Channels = rd.ReadBits8(4)
|
||||||
|
|
||||||
return codec
|
return codec
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ func ADTSToCodec(b []byte) *core.Codec {
|
|||||||
objType := rd.ReadBits8(2) + 1 // Profile, the MPEG-4 Audio Object Type minus 1
|
objType := rd.ReadBits8(2) + 1 // Profile, the MPEG-4 Audio Object Type minus 1
|
||||||
sampleRateIdx := rd.ReadBits8(4) // MPEG-4 Sampling Frequency Index
|
sampleRateIdx := rd.ReadBits8(4) // MPEG-4 Sampling Frequency Index
|
||||||
_ = rd.ReadBit() // Private bit, guaranteed never to be used by MPEG, set to 0 when encoding, ignore when decoding
|
_ = rd.ReadBit() // Private bit, guaranteed never to be used by MPEG, set to 0 when encoding, ignore when decoding
|
||||||
channels := rd.ReadBits16(3) // MPEG-4 Channel Configuration
|
channels := rd.ReadBits8(3) // MPEG-4 Channel Configuration
|
||||||
|
|
||||||
//_ = rd.ReadBit() // Originality, set to 1 to signal originality of the audio and 0 otherwise
|
//_ = rd.ReadBit() // Originality, set to 1 to signal originality of the audio and 0 otherwise
|
||||||
//_ = rd.ReadBit() // Home, set to 1 to signal home usage of the audio and 0 otherwise
|
//_ = rd.ReadBit() // Home, set to 1 to signal home usage of the audio and 0 otherwise
|
||||||
@@ -43,7 +43,7 @@ func ADTSToCodec(b []byte) *core.Codec {
|
|||||||
wr := bits.NewWriter(nil)
|
wr := bits.NewWriter(nil)
|
||||||
wr.WriteBits8(objType, 5)
|
wr.WriteBits8(objType, 5)
|
||||||
wr.WriteBits8(sampleRateIdx, 4)
|
wr.WriteBits8(sampleRateIdx, 4)
|
||||||
wr.WriteBits16(channels, 4)
|
wr.WriteBits8(channels, 4)
|
||||||
conf := wr.Bytes()
|
conf := wr.Bytes()
|
||||||
|
|
||||||
codec := &core.Codec{
|
codec := &core.Codec{
|
||||||
|
@@ -13,7 +13,7 @@ import (
|
|||||||
type Codec struct {
|
type Codec struct {
|
||||||
Name string // H264, PCMU, PCMA, opus...
|
Name string // H264, PCMU, PCMA, opus...
|
||||||
ClockRate uint32 // 90000, 8000, 16000...
|
ClockRate uint32 // 90000, 8000, 16000...
|
||||||
Channels uint16 // 0, 1, 2
|
Channels uint8 // 0, 1, 2
|
||||||
FmtpLine string
|
FmtpLine string
|
||||||
PayloadType uint8
|
PayloadType uint8
|
||||||
}
|
}
|
||||||
|
@@ -139,7 +139,7 @@ func MarshalSDP(name string, medias []*Media) ([]byte, error) {
|
|||||||
Protos: []string{"RTP", "AVP"},
|
Protos: []string{"RTP", "AVP"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
md.WithCodec(codec.PayloadType, name, codec.ClockRate, codec.Channels, codec.FmtpLine)
|
md.WithCodec(codec.PayloadType, name, codec.ClockRate, uint16(codec.Channels), codec.FmtpLine)
|
||||||
|
|
||||||
if media.Direction != "" {
|
if media.Direction != "" {
|
||||||
md.WithPropertyAttribute(media.Direction)
|
md.WithPropertyAttribute(media.Direction)
|
||||||
|
@@ -50,7 +50,7 @@ func audioToMedia(codecs []camera.AudioCodec) *core.Media {
|
|||||||
mediaCodec := &core.Codec{
|
mediaCodec := &core.Codec{
|
||||||
Name: audioCodecs[codec.CodecType],
|
Name: audioCodecs[codec.CodecType],
|
||||||
ClockRate: audioSampleRates[sampleRate],
|
ClockRate: audioSampleRates[sampleRate],
|
||||||
Channels: uint16(param.Channels),
|
Channels: param.Channels,
|
||||||
}
|
}
|
||||||
|
|
||||||
if mediaCodec.Name == core.CodecELD {
|
if mediaCodec.Name == core.CodecELD {
|
||||||
|
@@ -89,12 +89,12 @@ func (m *Muxer) GetInit() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mv.WriteAudioTrack(
|
mv.WriteAudioTrack(
|
||||||
uint32(i+1), codec.Name, codec.ClockRate, codec.Channels, b,
|
uint32(i+1), codec.Name, codec.ClockRate, uint16(codec.Channels), b,
|
||||||
)
|
)
|
||||||
|
|
||||||
case core.CodecOpus, core.CodecMP3, core.CodecPCMA, core.CodecPCMU, core.CodecFLAC:
|
case core.CodecOpus, core.CodecMP3, core.CodecPCMA, core.CodecPCMU, core.CodecFLAC:
|
||||||
mv.WriteAudioTrack(
|
mv.WriteAudioTrack(
|
||||||
uint32(i+1), codec.Name, codec.ClockRate, codec.Channels, nil,
|
uint32(i+1), codec.Name, codec.ClockRate, uint16(codec.Channels), nil,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ func Open(r io.Reader) (*Producer, error) {
|
|||||||
codec.Name = core.CodecPCMU
|
codec.Name = core.CodecPCMU
|
||||||
}
|
}
|
||||||
|
|
||||||
codec.Channels = uint16(data[2])
|
codec.Channels = data[2]
|
||||||
codec.ClockRate = binary.LittleEndian.Uint32(data[4:])
|
codec.ClockRate = binary.LittleEndian.Uint32(data[4:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ func (c *Conn) GetTrack(media *core.Media, codec *core.Codec) (*core.Receiver, e
|
|||||||
RTPCodecCapability: webrtc.RTPCodecCapability{
|
RTPCodecCapability: webrtc.RTPCodecCapability{
|
||||||
MimeType: MimeType(codec),
|
MimeType: MimeType(codec),
|
||||||
ClockRate: codec.ClockRate,
|
ClockRate: codec.ClockRate,
|
||||||
Channels: codec.Channels,
|
Channels: uint16(codec.Channels),
|
||||||
},
|
},
|
||||||
PayloadType: 0, // don't know if this necessary
|
PayloadType: 0, // don't know if this necessary
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user