Add support new audio codec for tapo source #1954
This commit is contained in:
@@ -330,6 +330,7 @@ const (
|
|||||||
StreamTypeH264 = 0x1B
|
StreamTypeH264 = 0x1B
|
||||||
StreamTypeH265 = 0x24
|
StreamTypeH265 = 0x24
|
||||||
StreamTypePCMATapo = 0x90
|
StreamTypePCMATapo = 0x90
|
||||||
|
StreamTypePCMUTapo = 0x91
|
||||||
StreamTypePrivateOPUS = 0xEB
|
StreamTypePrivateOPUS = 0xEB
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -392,7 +393,7 @@ func (p *PES) GetPacket() (pkt *rtp.Packet) {
|
|||||||
|
|
||||||
//p.Timestamp += aac.RTPTimeSize(pkt.Payload) // update next timestamp!
|
//p.Timestamp += aac.RTPTimeSize(pkt.Payload) // update next timestamp!
|
||||||
|
|
||||||
case StreamTypePCMATapo:
|
case StreamTypePCMATapo, StreamTypePCMUTapo:
|
||||||
p.Sequence++
|
p.Sequence++
|
||||||
|
|
||||||
pkt = &rtp.Packet{
|
pkt = &rtp.Packet{
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
|
|
||||||
"github.com/AlexxIT/go2rtc/pkg/core"
|
"github.com/AlexxIT/go2rtc/pkg/core"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/mpegts"
|
"github.com/AlexxIT/go2rtc/pkg/mpegts"
|
||||||
|
"github.com/AlexxIT/go2rtc/pkg/pcm"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -185,6 +186,8 @@ func (c *Client) Handle() error {
|
|||||||
rd := multipart.NewReader(c.conn1, "--device-stream-boundary--")
|
rd := multipart.NewReader(c.conn1, "--device-stream-boundary--")
|
||||||
demux := mpegts.NewDemuxer()
|
demux := mpegts.NewDemuxer()
|
||||||
|
|
||||||
|
var transcode func([]byte) []byte
|
||||||
|
|
||||||
for {
|
for {
|
||||||
p, err := rd.NextRawPart()
|
p, err := rd.NextRawPart()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -226,6 +229,23 @@ func (c *Client) Handle() error {
|
|||||||
return err2
|
return err2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if pkt.PayloadType == mpegts.StreamTypePCMUTapo {
|
||||||
|
// TODO: rewrite this part in the future
|
||||||
|
// Some cameras in the new firmware began to use PCMU/16000.
|
||||||
|
// https://github.com/AlexxIT/go2rtc/issues/1954
|
||||||
|
// I don't know why Tapo considers this an improvement. The codec is no better than the previous one.
|
||||||
|
// Unfortunately, we don't know in advance what codec the camera will use.
|
||||||
|
// Therefore, it's easier to transcode to a standard codec that all Tapo cameras have.
|
||||||
|
if transcode == nil {
|
||||||
|
transcode = pcm.Transcode(
|
||||||
|
&core.Codec{Name: core.CodecPCMA, ClockRate: 8000},
|
||||||
|
&core.Codec{Name: core.CodecPCMU, ClockRate: 16000},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pkt.PayloadType = mpegts.StreamTypePCMATapo
|
||||||
|
pkt.Payload = transcode(pkt.Payload)
|
||||||
|
}
|
||||||
|
|
||||||
for _, receiver := range c.receivers {
|
for _, receiver := range c.receivers {
|
||||||
if receiver.ID == pkt.PayloadType {
|
if receiver.ID == pkt.PayloadType {
|
||||||
mpegts.TimestampToRTP(pkt, receiver.Codec)
|
mpegts.TimestampToRTP(pkt, receiver.Codec)
|
||||||
|
|||||||
Reference in New Issue
Block a user