diff --git a/container/mts/mpegts.go b/container/mts/mpegts.go index 2dc608ed..8ca509ba 100644 --- a/container/mts/mpegts.go +++ b/container/mts/mpegts.go @@ -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 {