Rewrite AnnexB/AVCC parsers

This commit is contained in:
Alexey Khit
2023-08-16 16:50:55 +03:00
parent e1be2d9e48
commit 1dd3dbbcd8
28 changed files with 513 additions and 176 deletions
+8 -6
View File
@@ -8,14 +8,16 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/h264"
"github.com/AlexxIT/go2rtc/pkg/h265"
"github.com/pion/rtp"
"io"
"net"
"net/url"
"time"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/h264"
"github.com/AlexxIT/go2rtc/pkg/h264/annexb"
"github.com/AlexxIT/go2rtc/pkg/h265"
"github.com/pion/rtp"
)
type Client struct {
@@ -173,7 +175,7 @@ func (c *Client) Handle() error {
switch dataType {
case 0x1FC, 0x1FE: // video IFrame
payload := h264.AnnexB2AVC(b[16:])
payload := annexb.EncodeToAVCC(b[16:], false)
if c.videoTrack == nil {
fps := b[5]
@@ -208,7 +210,7 @@ func (c *Client) Handle() error {
packet := &rtp.Packet{
Header: rtp.Header{Timestamp: c.videoTS},
Payload: h264.AnnexB2AVC(b[8:]),
Payload: annexb.EncodeToAVCC(b[8:], false),
}
//log.Printf("[DVR] %v, len: %d, ts: %10d", h265.Types(packet.Payload), len(packet.Payload), packet.Timestamp)