Merged in get-first-pid (pull request #228)

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

Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
Saxon Milton 2019-08-07 07:10:54 +00:00 committed by Alan Noble
commit e78b38a4da
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 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 // FillPayload takes a channel and fills the packets Payload field until the
// channel is empty or we've the packet reaches capacity // channel is empty or we've the packet reaches capacity
func (p *Packet) FillPayload(data []byte) int { func (p *Packet) FillPayload(data []byte) int {