mirror of
https://github.com/aler9/gortsplib
synced 2025-10-11 01:50:30 +08:00
add TrackMPV
This commit is contained in:
@@ -81,6 +81,7 @@ func (p *Cleaner) processH264(pkt *rtp.Packet) ([]*Output, error) {
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ptsEqualsDTS := h264.IDRPresent(nalus)
|
ptsEqualsDTS := h264.IDRPresent(nalus)
|
||||||
|
|
||||||
// re-encode
|
// re-encode
|
||||||
|
3
track.go
3
track.go
@@ -66,6 +66,9 @@ func newTrackFromMediaDescription(md *psdp.MediaDescription) (Track, error) {
|
|||||||
case md.MediaName.Formats[0] == "26":
|
case md.MediaName.Formats[0] == "26":
|
||||||
return newTrackJPEGFromMediaDescription(control)
|
return newTrackJPEGFromMediaDescription(control)
|
||||||
|
|
||||||
|
case md.MediaName.Formats[0] == "32":
|
||||||
|
return newTrackMPVFromMediaDescription(control)
|
||||||
|
|
||||||
case rtpmapPart1 == "H264/90000":
|
case rtpmapPart1 == "H264/90000":
|
||||||
return newTrackH264FromMediaDescription(control, payloadType, md)
|
return newTrackH264FromMediaDescription(control, payloadType, md)
|
||||||
|
|
||||||
|
53
track_mpv.go
Normal file
53
track_mpv.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package gortsplib //nolint:dupl
|
||||||
|
|
||||||
|
import (
|
||||||
|
psdp "github.com/pion/sdp/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TrackMPV is a MPEG-1 or MPEG-2 video track.
|
||||||
|
type TrackMPV struct {
|
||||||
|
trackBase
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTrackMPV allocates a TrackMPV.
|
||||||
|
func NewTrackMPV() *TrackMPV {
|
||||||
|
return &TrackMPV{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTrackMPVFromMediaDescription(
|
||||||
|
control string) (*TrackMPV, error,
|
||||||
|
) {
|
||||||
|
return &TrackMPV{
|
||||||
|
trackBase: trackBase{
|
||||||
|
control: control,
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClockRate returns the track clock rate.
|
||||||
|
func (t *TrackMPV) ClockRate() int {
|
||||||
|
return 90000
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TrackMPV) clone() Track {
|
||||||
|
return &TrackMPV{
|
||||||
|
trackBase: t.trackBase,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MediaDescription returns the track media description in SDP format.
|
||||||
|
func (t *TrackMPV) MediaDescription() *psdp.MediaDescription {
|
||||||
|
return &psdp.MediaDescription{
|
||||||
|
MediaName: psdp.MediaName{
|
||||||
|
Media: "video",
|
||||||
|
Protos: []string{"RTP", "AVP"},
|
||||||
|
Formats: []string{"32"},
|
||||||
|
},
|
||||||
|
Attributes: []psdp.Attribute{
|
||||||
|
{
|
||||||
|
Key: "control",
|
||||||
|
Value: t.control,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
39
track_mpv_test.go
Normal file
39
track_mpv_test.go
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package gortsplib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
psdp "github.com/pion/sdp/v3"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTrackMPVNew(t *testing.T) {
|
||||||
|
track := NewTrackMPV()
|
||||||
|
require.Equal(t, "", track.GetControl())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTrackMPVClone(t *testing.T) {
|
||||||
|
track := NewTrackMPV()
|
||||||
|
|
||||||
|
clone := track.clone()
|
||||||
|
require.NotSame(t, track, clone)
|
||||||
|
require.Equal(t, track, clone)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTrackMPVMediaDescription(t *testing.T) {
|
||||||
|
track := NewTrackMPV()
|
||||||
|
|
||||||
|
require.Equal(t, &psdp.MediaDescription{
|
||||||
|
MediaName: psdp.MediaName{
|
||||||
|
Media: "video",
|
||||||
|
Protos: []string{"RTP", "AVP"},
|
||||||
|
Formats: []string{"32"},
|
||||||
|
},
|
||||||
|
Attributes: []psdp.Attribute{
|
||||||
|
{
|
||||||
|
Key: "control",
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, track.MediaDescription())
|
||||||
|
}
|
@@ -202,6 +202,17 @@ func TestTrackNewFromMediaDescription(t *testing.T) {
|
|||||||
},
|
},
|
||||||
&TrackJPEG{},
|
&TrackJPEG{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"mpv",
|
||||||
|
&psdp.MediaDescription{
|
||||||
|
MediaName: psdp.MediaName{
|
||||||
|
Media: "video",
|
||||||
|
Protos: []string{"RTP", "AVP"},
|
||||||
|
Formats: []string{"32"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
&TrackMPV{},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"h264",
|
"h264",
|
||||||
&psdp.MediaDescription{
|
&psdp.MediaDescription{
|
||||||
|
Reference in New Issue
Block a user