mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-06 16:57:29 +08:00
Change HomeKit codec from AAC to ELD
This commit is contained in:
@@ -1,3 +1,17 @@
|
|||||||
|
## FFplay output
|
||||||
|
|
||||||
|
[FFplay](https://stackoverflow.com/questions/27778678/what-are-mv-fd-aq-vq-sq-and-f-in-a-video-stream) `7.11 A-V: 0.003 fd= 1 aq= 21KB vq= 321KB sq= 0B f=0/0`:
|
||||||
|
|
||||||
|
- `7.11` - master clock, is the time from start of the stream/video
|
||||||
|
- `A-V` - av_diff, difference between audio and video timestamps
|
||||||
|
- `fd` - frames dropped
|
||||||
|
- `aq` - audio queue (0 - no delay)
|
||||||
|
- `vq` - video queue (0 - no delay)
|
||||||
|
- `sq` - subtitle queue
|
||||||
|
- `f` - timestamp error correction rate (Not 100% sure)
|
||||||
|
|
||||||
|
`M-V`, `M-A` means video stream only, audio stream only respectively.
|
||||||
|
|
||||||
## Devices Windows
|
## Devices Windows
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@@ -163,7 +163,7 @@ func (c *Client) Start() error {
|
|||||||
switch track.Codec.Name {
|
switch track.Codec.Name {
|
||||||
case streamer.CodecH264:
|
case streamer.CodecH264:
|
||||||
vs.Track = track
|
vs.Track = track
|
||||||
case streamer.CodecAAC:
|
case streamer.CodecELD:
|
||||||
as.Track = track
|
as.Track = track
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,14 +233,6 @@ func (c *Client) getMedias() []*streamer.Media {
|
|||||||
Channels: uint16(hkCodec.Parameters.Channels),
|
Channels: uint16(hkCodec.Parameters.Channels),
|
||||||
}
|
}
|
||||||
|
|
||||||
switch hkCodec.Type {
|
|
||||||
case rtp.AudioCodecType_AAC_ELD:
|
|
||||||
codec.Name = streamer.CodecAAC
|
|
||||||
default:
|
|
||||||
fmt.Printf("unknown codec: %d", hkCodec.Type)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
switch hkCodec.Parameters.Samplerate {
|
switch hkCodec.Parameters.Samplerate {
|
||||||
case rtp.AudioCodecSampleRate8Khz:
|
case rtp.AudioCodecSampleRate8Khz:
|
||||||
codec.ClockRate = 8000
|
codec.ClockRate = 8000
|
||||||
@@ -252,6 +244,16 @@ func (c *Client) getMedias() []*streamer.Media {
|
|||||||
panic(fmt.Sprintf("unknown clockrate: %d", hkCodec.Parameters.Samplerate))
|
panic(fmt.Sprintf("unknown clockrate: %d", hkCodec.Parameters.Samplerate))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch hkCodec.Type {
|
||||||
|
case rtp.AudioCodecType_AAC_ELD:
|
||||||
|
codec.Name = streamer.CodecELD
|
||||||
|
// only this value supported by FFmpeg
|
||||||
|
codec.FmtpLine = "profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=F8EC3000"
|
||||||
|
default:
|
||||||
|
fmt.Printf("unknown codec: %d", hkCodec.Type)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
media := &streamer.Media{
|
media := &streamer.Media{
|
||||||
Kind: streamer.KindAudio, Direction: streamer.DirectionSendonly,
|
Kind: streamer.KindAudio, Direction: streamer.DirectionSendonly,
|
||||||
Codecs: []*streamer.Codec{codec},
|
Codecs: []*streamer.Codec{codec},
|
||||||
|
@@ -33,6 +33,8 @@ const (
|
|||||||
CodecOpus = "OPUS" // payloadType: 111
|
CodecOpus = "OPUS" // payloadType: 111
|
||||||
CodecG722 = "G722"
|
CodecG722 = "G722"
|
||||||
CodecMPA = "MPA" // payload: 14
|
CodecMPA = "MPA" // payload: 14
|
||||||
|
|
||||||
|
CodecELD = "ELD" // AAC-ELD
|
||||||
)
|
)
|
||||||
|
|
||||||
const PayloadTypeMP4 byte = 255
|
const PayloadTypeMP4 byte = 255
|
||||||
@@ -41,7 +43,7 @@ func GetKind(name string) string {
|
|||||||
switch name {
|
switch name {
|
||||||
case CodecH264, CodecH265, CodecVP8, CodecVP9, CodecAV1, CodecJPEG:
|
case CodecH264, CodecH265, CodecVP8, CodecVP9, CodecAV1, CodecJPEG:
|
||||||
return KindVideo
|
return KindVideo
|
||||||
case CodecPCMU, CodecPCMA, CodecAAC, CodecOpus, CodecG722, CodecMPA:
|
case CodecPCMU, CodecPCMA, CodecAAC, CodecOpus, CodecG722, CodecMPA, CodecELD:
|
||||||
return KindAudio
|
return KindAudio
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -187,13 +189,19 @@ func MarshalSDP(medias []*Media) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
codec := media.Codecs[0]
|
codec := media.Codecs[0]
|
||||||
|
|
||||||
|
name := codec.Name
|
||||||
|
if name == CodecELD {
|
||||||
|
name = CodecAAC
|
||||||
|
}
|
||||||
|
|
||||||
md := &sdp.MediaDescription{
|
md := &sdp.MediaDescription{
|
||||||
MediaName: sdp.MediaName{
|
MediaName: sdp.MediaName{
|
||||||
Media: media.Kind,
|
Media: media.Kind,
|
||||||
Protos: []string{"RTP", "AVP"},
|
Protos: []string{"RTP", "AVP"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
md.WithCodec(payloadType, codec.Name, codec.ClockRate, codec.Channels, codec.FmtpLine)
|
md.WithCodec(payloadType, name, codec.ClockRate, codec.Channels, codec.FmtpLine)
|
||||||
|
|
||||||
sd.MediaDescriptions = append(sd.MediaDescriptions, md)
|
sd.MediaDescriptions = append(sd.MediaDescriptions, md)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user