support publishing AV1/H265 with OBS 30 (#2217) (#2234)
Some checks reported warnings
lint / code (push) Has been cancelled
lint / mod-tidy (push) Has been cancelled
lint / apidocs (push) Has been cancelled
test / test64 (push) Has been cancelled
test / test32 (push) Has been cancelled
test / test_highlevel (push) Has been cancelled

This commit is contained in:
Alessandro Ros
2023-08-22 22:56:23 +02:00
committed by GitHub
parent accfc49f9c
commit 1133c734ab
14 changed files with 193 additions and 80 deletions

View File

@@ -1,6 +1,8 @@
package message
import (
"fmt"
"github.com/bluenviron/mediamtx/internal/rtmp/rawmessage"
)
@@ -8,26 +10,37 @@ import (
type ExtendedSequenceStart struct {
ChunkStreamID byte
MessageStreamID uint32
FourCC [4]byte
FourCC FourCC
Config []byte
}
// Unmarshal implements Message.
func (m *ExtendedSequenceStart) Unmarshal(raw *rawmessage.Message) error {
if len(raw.Body) < 6 {
return fmt.Errorf("not enough bytes")
}
m.ChunkStreamID = raw.ChunkStreamID
m.MessageStreamID = raw.MessageStreamID
copy(m.FourCC[:], raw.Body[1:5])
m.FourCC = FourCC(raw.Body[1])<<24 | FourCC(raw.Body[2])<<16 | FourCC(raw.Body[3])<<8 | FourCC(raw.Body[4])
m.Config = raw.Body[5:]
return nil
}
func (m ExtendedSequenceStart) marshalBodySize() int {
return 5 + len(m.Config)
}
// Marshal implements Message.
func (m ExtendedSequenceStart) Marshal() (*rawmessage.Message, error) {
body := make([]byte, 5+len(m.Config))
body := make([]byte, m.marshalBodySize())
body[0] = 0b10000000 | byte(ExtendedTypeSequenceStart)
copy(body[1:5], m.FourCC[:])
body[1] = uint8(m.FourCC >> 24)
body[2] = uint8(m.FourCC >> 16)
body[3] = uint8(m.FourCC >> 8)
body[4] = uint8(m.FourCC)
copy(body[5:], m.Config)
return &rawmessage.Message{