BIG rewrite stream info

This commit is contained in:
Alex X
2024-06-15 16:46:03 +03:00
parent ecfe802065
commit 96504e2fb0
88 changed files with 1043 additions and 854 deletions
+14 -10
View File
@@ -13,7 +13,7 @@ import (
)
type Producer struct {
core.SuperProducer
core.Connection
rd *core.ReadBuffer
}
@@ -28,26 +28,35 @@ func Open(r io.Reader) (*Producer, error) {
buf = annexb.EncodeToAVCC(buf, false) // won't break original buffer
var codec *core.Codec
var format string
switch {
case h264.NALUType(buf) == h264.NALUTypeSPS:
codec = h264.AVCCToCodec(buf)
format = "h264"
case h265.NALUType(buf) == h265.NALUTypeVPS:
codec = h265.AVCCToCodec(buf)
format = "hevc"
default:
return nil, errors.New("bitstream: unsupported header: " + hex.EncodeToString(buf[:8]))
}
prod := &Producer{rd: rd}
prod.Type = "Bitstream producer"
prod.Medias = []*core.Media{
medias := []*core.Media{
{
Kind: core.KindVideo,
Direction: core.DirectionRecvonly,
Codecs: []*core.Codec{codec},
},
}
return prod, nil
return &Producer{
Connection: core.Connection{
ID: core.NewID(),
FormatName: format,
Medias: medias,
Transport: r,
},
rd: rd,
}, nil
}
func (c *Producer) Start() error {
@@ -84,8 +93,3 @@ func (c *Producer) Start() error {
}
}
}
func (c *Producer) Stop() error {
_ = c.SuperProducer.Close()
return c.rd.Close()
}