mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 07:37:07 +08:00
add MPEG-TS format (#244)
This commit is contained in:
@@ -51,6 +51,9 @@ func Unmarshal(mediaType string, payloadType uint8, rtpMap string, fmtp map[stri
|
|||||||
case payloadType == 32:
|
case payloadType == 32:
|
||||||
return &MPEG2Video{}
|
return &MPEG2Video{}
|
||||||
|
|
||||||
|
case payloadType == 33:
|
||||||
|
return &MPEGTS{}
|
||||||
|
|
||||||
case codec == "mp4v-es" && clock == "90000":
|
case codec == "mp4v-es" && clock == "90000":
|
||||||
return &MPEG4Video{}
|
return &MPEG4Video{}
|
||||||
|
|
||||||
|
@@ -343,6 +343,16 @@ var casesFormat = []struct {
|
|||||||
"",
|
"",
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"video mpeg-ts",
|
||||||
|
"video",
|
||||||
|
33,
|
||||||
|
"",
|
||||||
|
nil,
|
||||||
|
&MPEGTS{},
|
||||||
|
"MP2T/90000",
|
||||||
|
nil,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"video mpeg4 video",
|
"video mpeg4 video",
|
||||||
"video",
|
"video",
|
||||||
|
38
pkg/formats/mpegts.go
Normal file
38
pkg/formats/mpegts.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package formats
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pion/rtp"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MPEGTS is a RTP format that uses MPEG-TS to wrap underlying tracks.
|
||||||
|
// Specification: https://datatracker.ietf.org/doc/html/rfc2250
|
||||||
|
type MPEGTS struct{}
|
||||||
|
|
||||||
|
// String implements Format.
|
||||||
|
func (f *MPEGTS) String() string {
|
||||||
|
return "MPEG-TS"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClockRate implements Format.
|
||||||
|
func (f *MPEGTS) ClockRate() int {
|
||||||
|
return 90000
|
||||||
|
}
|
||||||
|
|
||||||
|
// PayloadType implements Format.
|
||||||
|
func (f *MPEGTS) PayloadType() uint8 {
|
||||||
|
return 33
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *MPEGTS) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marshal implements Format.
|
||||||
|
func (f *MPEGTS) Marshal() (string, map[string]string) {
|
||||||
|
return "MP2T/90000", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PTSEqualsDTS implements Format.
|
||||||
|
func (f *MPEGTS) PTSEqualsDTS(*rtp.Packet) bool {
|
||||||
|
return true
|
||||||
|
}
|
16
pkg/formats/mpegts_test.go
Normal file
16
pkg/formats/mpegts_test.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package formats
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/pion/rtp"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMPEGTSAttributes(t *testing.T) {
|
||||||
|
format := &MPEGTS{}
|
||||||
|
require.Equal(t, "MPEG-TS", format.String())
|
||||||
|
require.Equal(t, 90000, format.ClockRate())
|
||||||
|
require.Equal(t, uint8(33), format.PayloadType())
|
||||||
|
require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{}))
|
||||||
|
}
|
Reference in New Issue
Block a user