codec/h264/h264dec: added helper function to get first MediaPID found in a stream map

This commit is contained in:
Saxon 2019-08-07 16:15:50 +09:30
parent f6c296de01
commit c9d30ad807
1 changed files with 13 additions and 0 deletions

View File

@ -286,6 +286,19 @@ func FindPSI(d []byte) (int, map[uint16]uint8, map[string]string, error) {
return i, streamMap, meta, nil
}
var (
ErrStreamMap = errors.New("stream map is empty")
)
// FirstMediaPID returns the first PID and it's type in the given streamMap.
func FirstMediaPID(streamMap map[uint16]uint8) (p uint16, t uint8, err error) {
for p, t = range streamMap {
return
}
err = ErrStreamMap
return
}
// FillPayload takes a channel and fills the packets Payload field until the
// channel is empty or we've the packet reaches capacity
func (p *Packet) FillPayload(data []byte) int {