mirror of
https://github.com/aler9/gortsplib
synced 2025-10-09 00:50:24 +08:00
rename MPEG2Video into MPEG1Video, MPEG2Audio into MPEG1Audio
This commit is contained in:
@@ -108,7 +108,7 @@ In RTSP, media streams are routed between server and clients by using RTP packet
|
|||||||
|H265||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#H265)|:heavy_check_mark:|
|
|H265||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#H265)|:heavy_check_mark:|
|
||||||
|H264||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#H264)|:heavy_check_mark:|
|
|H264||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#H264)|:heavy_check_mark:|
|
||||||
|MPEG-4 Video (H263, Xvid)||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG4VideoES)|:heavy_check_mark:|
|
|MPEG-4 Video (H263, Xvid)||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG4VideoES)|:heavy_check_mark:|
|
||||||
|MPEG-2 Video||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG2Video)||
|
|MPEG-1/2 Video||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG1Video)||
|
||||||
|M-JPEG||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MJPEG)|:heavy_check_mark:|
|
|M-JPEG||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MJPEG)|:heavy_check_mark:|
|
||||||
|
|
||||||
### Audio
|
### Audio
|
||||||
@@ -119,7 +119,7 @@ In RTSP, media streams are routed between server and clients by using RTP packet
|
|||||||
|Vorbis||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#Vorbis)||
|
|Vorbis||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#Vorbis)||
|
||||||
|MPEG-4 Audio (AAC)|Generic (RFC3640)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG4AudioGeneric)|:heavy_check_mark:|
|
|MPEG-4 Audio (AAC)|Generic (RFC3640)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG4AudioGeneric)|:heavy_check_mark:|
|
||||||
|MPEG-4 Audio (AAC)|LATM (RFC6416)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG4AudioLATM)|:heavy_check_mark:|
|
|MPEG-4 Audio (AAC)|LATM (RFC6416)|[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG4AudioLATM)|:heavy_check_mark:|
|
||||||
|MPEG-1/2 Audio (MP3)||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG2Audio)|:heavy_check_mark:|
|
|MPEG-1/2 Audio (MP3)||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#MPEG1Audio)|:heavy_check_mark:|
|
||||||
|G726||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#G726)||
|
|G726||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#G726)||
|
||||||
|G722||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#G722)|:heavy_check_mark:|
|
|G722||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#G722)|:heavy_check_mark:|
|
||||||
|G711 (PCMA, PCMU)||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#G711)|:heavy_check_mark:|
|
|G711 (PCMA, PCMU)||[link](https://pkg.go.dev/github.com/bluenviron/gortsplib/v3/pkg/formats#G711)|:heavy_check_mark:|
|
||||||
|
@@ -55,7 +55,7 @@ func Unmarshal(mediaType string, payloadType uint8, rtpMap string, fmtp map[stri
|
|||||||
return &MJPEG{}
|
return &MJPEG{}
|
||||||
|
|
||||||
case payloadType == 32:
|
case payloadType == 32:
|
||||||
return &MPEG2Video{}
|
return &MPEG1Video{}
|
||||||
|
|
||||||
case payloadType == 33:
|
case payloadType == 33:
|
||||||
return &MPEGTS{}
|
return &MPEGTS{}
|
||||||
@@ -98,7 +98,7 @@ func Unmarshal(mediaType string, payloadType uint8, rtpMap string, fmtp map[stri
|
|||||||
return &G726{}
|
return &G726{}
|
||||||
|
|
||||||
case payloadType == 14:
|
case payloadType == 14:
|
||||||
return &MPEG2Audio{}
|
return &MPEG1Audio{}
|
||||||
|
|
||||||
case codec == "l8", codec == "l16", codec == "l24":
|
case codec == "l8", codec == "l16", codec == "l24":
|
||||||
return &LPCM{}
|
return &LPCM{}
|
||||||
|
@@ -190,7 +190,7 @@ var casesFormat = []struct {
|
|||||||
14,
|
14,
|
||||||
"",
|
"",
|
||||||
nil,
|
nil,
|
||||||
&MPEG2Audio{},
|
&MPEG1Audio{},
|
||||||
"",
|
"",
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
@@ -573,12 +573,12 @@ var casesFormat = []struct {
|
|||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"video mpeg2 video",
|
"video mpeg1 video",
|
||||||
"video",
|
"video",
|
||||||
32,
|
32,
|
||||||
"",
|
"",
|
||||||
nil,
|
nil,
|
||||||
&MPEG2Video{},
|
&MPEG1Video{},
|
||||||
"",
|
"",
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
|
@@ -3,65 +3,65 @@ package formats //nolint:dupl
|
|||||||
import (
|
import (
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
"github.com/bluenviron/gortsplib/v3/pkg/formats/rtpmpeg2audio"
|
"github.com/bluenviron/gortsplib/v3/pkg/formats/rtpmpeg1audio"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MPEG2Audio is a RTP format for a MPEG-1/2 Audio codec.
|
// MPEG1Audio is a RTP format for a MPEG-1/2 Audio codec.
|
||||||
// Specification: https://datatracker.ietf.org/doc/html/rfc2250
|
// Specification: https://datatracker.ietf.org/doc/html/rfc2250
|
||||||
type MPEG2Audio struct{}
|
type MPEG1Audio struct{}
|
||||||
|
|
||||||
func (f *MPEG2Audio) unmarshal(_ uint8, _ string, _ string, _ string, _ map[string]string) error {
|
func (f *MPEG1Audio) unmarshal(_ uint8, _ string, _ string, _ string, _ map[string]string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Codec implements Format.
|
// Codec implements Format.
|
||||||
func (f *MPEG2Audio) Codec() string {
|
func (f *MPEG1Audio) Codec() string {
|
||||||
return "MPEG-1/2 Audio"
|
return "MPEG-1/2 Audio"
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements Format.
|
// String implements Format.
|
||||||
//
|
//
|
||||||
// Deprecated: replaced by Codec().
|
// Deprecated: replaced by Codec().
|
||||||
func (f *MPEG2Audio) String() string {
|
func (f *MPEG1Audio) String() string {
|
||||||
return f.Codec()
|
return f.Codec()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClockRate implements Format.
|
// ClockRate implements Format.
|
||||||
func (f *MPEG2Audio) ClockRate() int {
|
func (f *MPEG1Audio) ClockRate() int {
|
||||||
return 90000
|
return 90000
|
||||||
}
|
}
|
||||||
|
|
||||||
// PayloadType implements Format.
|
// PayloadType implements Format.
|
||||||
func (f *MPEG2Audio) PayloadType() uint8 {
|
func (f *MPEG1Audio) PayloadType() uint8 {
|
||||||
return 14
|
return 14
|
||||||
}
|
}
|
||||||
|
|
||||||
// RTPMap implements Format.
|
// RTPMap implements Format.
|
||||||
func (f *MPEG2Audio) RTPMap() string {
|
func (f *MPEG1Audio) RTPMap() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// FMTP implements Format.
|
// FMTP implements Format.
|
||||||
func (f *MPEG2Audio) FMTP() map[string]string {
|
func (f *MPEG1Audio) FMTP() map[string]string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PTSEqualsDTS implements Format.
|
// PTSEqualsDTS implements Format.
|
||||||
func (f *MPEG2Audio) PTSEqualsDTS(*rtp.Packet) bool {
|
func (f *MPEG1Audio) PTSEqualsDTS(*rtp.Packet) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateDecoder creates a decoder able to decode the content of the format.
|
// CreateDecoder creates a decoder able to decode the content of the format.
|
||||||
//
|
//
|
||||||
// Deprecated: this has been replaced by CreateDecoder2() that can also return an error.
|
// Deprecated: this has been replaced by CreateDecoder2() that can also return an error.
|
||||||
func (f *MPEG2Audio) CreateDecoder() *rtpmpeg2audio.Decoder {
|
func (f *MPEG1Audio) CreateDecoder() *rtpmpeg1audio.Decoder {
|
||||||
d, _ := f.CreateDecoder2()
|
d, _ := f.CreateDecoder2()
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateDecoder2 creates a decoder able to decode the content of the format.
|
// CreateDecoder2 creates a decoder able to decode the content of the format.
|
||||||
func (f *MPEG2Audio) CreateDecoder2() (*rtpmpeg2audio.Decoder, error) {
|
func (f *MPEG1Audio) CreateDecoder2() (*rtpmpeg1audio.Decoder, error) {
|
||||||
d := &rtpmpeg2audio.Decoder{}
|
d := &rtpmpeg1audio.Decoder{}
|
||||||
|
|
||||||
err := d.Init()
|
err := d.Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -74,14 +74,14 @@ func (f *MPEG2Audio) CreateDecoder2() (*rtpmpeg2audio.Decoder, error) {
|
|||||||
// CreateEncoder creates an encoder able to encode the content of the format.
|
// CreateEncoder creates an encoder able to encode the content of the format.
|
||||||
//
|
//
|
||||||
// Deprecated: this has been replaced by CreateEncoder2() that can also return an error.
|
// Deprecated: this has been replaced by CreateEncoder2() that can also return an error.
|
||||||
func (f *MPEG2Audio) CreateEncoder() *rtpmpeg2audio.Encoder {
|
func (f *MPEG1Audio) CreateEncoder() *rtpmpeg1audio.Encoder {
|
||||||
e, _ := f.CreateEncoder2()
|
e, _ := f.CreateEncoder2()
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateEncoder2 creates an encoder able to encode the content of the format.
|
// CreateEncoder2 creates an encoder able to encode the content of the format.
|
||||||
func (f *MPEG2Audio) CreateEncoder2() (*rtpmpeg2audio.Encoder, error) {
|
func (f *MPEG1Audio) CreateEncoder2() (*rtpmpeg1audio.Encoder, error) {
|
||||||
e := &rtpmpeg2audio.Encoder{}
|
e := &rtpmpeg1audio.Encoder{}
|
||||||
|
|
||||||
err := e.Init()
|
err := e.Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -90,3 +90,8 @@ func (f *MPEG2Audio) CreateEncoder2() (*rtpmpeg2audio.Encoder, error) {
|
|||||||
|
|
||||||
return e, nil
|
return e, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MPEG2Audio is an alias for MPEG1Audio.
|
||||||
|
//
|
||||||
|
// Deprecated: replaced by MPEG1Audio.
|
||||||
|
type MPEG2Audio = MPEG1Audio
|
@@ -7,15 +7,15 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMPEG2AudioAttributes(t *testing.T) {
|
func TestMPEG1AudioAttributes(t *testing.T) {
|
||||||
format := &MPEG2Audio{}
|
format := &MPEG1Audio{}
|
||||||
require.Equal(t, "MPEG-1/2 Audio", format.Codec())
|
require.Equal(t, "MPEG-1/2 Audio", format.Codec())
|
||||||
require.Equal(t, 90000, format.ClockRate())
|
require.Equal(t, 90000, format.ClockRate())
|
||||||
require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{}))
|
require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMPEG2AudioDecEncoder(t *testing.T) {
|
func TestMPEG1AudioDecEncoder(t *testing.T) {
|
||||||
format := &MPEG2Audio{}
|
format := &MPEG1Audio{}
|
||||||
|
|
||||||
enc, err := format.CreateEncoder2()
|
enc, err := format.CreateEncoder2()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
55
pkg/formats/mpeg1_video.go
Normal file
55
pkg/formats/mpeg1_video.go
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package formats //nolint:dupl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pion/rtp"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MPEG1Video is a RTP format for a MPEG-1/2 Video codec.
|
||||||
|
// Specification: https://datatracker.ietf.org/doc/html/rfc2250
|
||||||
|
type MPEG1Video struct{}
|
||||||
|
|
||||||
|
func (f *MPEG1Video) unmarshal(_ uint8, _ string, _ string, _ string, _ map[string]string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Codec implements Format.
|
||||||
|
func (f *MPEG1Video) Codec() string {
|
||||||
|
return "MPEG-1/2 Video"
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements Format.
|
||||||
|
//
|
||||||
|
// Deprecated: replaced by Codec().
|
||||||
|
func (f *MPEG1Video) String() string {
|
||||||
|
return f.Codec()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClockRate implements Format.
|
||||||
|
func (f *MPEG1Video) ClockRate() int {
|
||||||
|
return 90000
|
||||||
|
}
|
||||||
|
|
||||||
|
// PayloadType implements Format.
|
||||||
|
func (f *MPEG1Video) PayloadType() uint8 {
|
||||||
|
return 32
|
||||||
|
}
|
||||||
|
|
||||||
|
// RTPMap implements Format.
|
||||||
|
func (f *MPEG1Video) RTPMap() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// FMTP implements Format.
|
||||||
|
func (f *MPEG1Video) FMTP() map[string]string {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PTSEqualsDTS implements Format.
|
||||||
|
func (f *MPEG1Video) PTSEqualsDTS(*rtp.Packet) bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// MPEG2Video is an alias for MPEG1Video.
|
||||||
|
//
|
||||||
|
// Deprecated: replaced by MPEG1Video.
|
||||||
|
type MPEG2Video = MPEG1Video
|
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMPEG2VideoAttributes(t *testing.T) {
|
func TestMPEG1VideoAttributes(t *testing.T) {
|
||||||
format := &MPEG2Video{}
|
format := &MPEG1Video{}
|
||||||
require.Equal(t, "MPEG-1/2 Video", format.Codec())
|
require.Equal(t, "MPEG-1/2 Video", format.Codec())
|
||||||
require.Equal(t, 90000, format.ClockRate())
|
require.Equal(t, 90000, format.ClockRate())
|
||||||
require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{}))
|
require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{}))
|
@@ -1,50 +0,0 @@
|
|||||||
package formats //nolint:dupl
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/pion/rtp"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MPEG2Video is a RTP format for a MPEG-1/2 Video codec.
|
|
||||||
// Specification: https://datatracker.ietf.org/doc/html/rfc2250
|
|
||||||
type MPEG2Video struct{}
|
|
||||||
|
|
||||||
func (f *MPEG2Video) unmarshal(_ uint8, _ string, _ string, _ string, _ map[string]string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Codec implements Format.
|
|
||||||
func (f *MPEG2Video) Codec() string {
|
|
||||||
return "MPEG-1/2 Video"
|
|
||||||
}
|
|
||||||
|
|
||||||
// String implements Format.
|
|
||||||
//
|
|
||||||
// Deprecated: replaced by Codec().
|
|
||||||
func (f *MPEG2Video) String() string {
|
|
||||||
return f.Codec()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClockRate implements Format.
|
|
||||||
func (f *MPEG2Video) ClockRate() int {
|
|
||||||
return 90000
|
|
||||||
}
|
|
||||||
|
|
||||||
// PayloadType implements Format.
|
|
||||||
func (f *MPEG2Video) PayloadType() uint8 {
|
|
||||||
return 32
|
|
||||||
}
|
|
||||||
|
|
||||||
// RTPMap implements Format.
|
|
||||||
func (f *MPEG2Video) RTPMap() string {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// FMTP implements Format.
|
|
||||||
func (f *MPEG2Video) FMTP() map[string]string {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// PTSEqualsDTS implements Format.
|
|
||||||
func (f *MPEG2Video) PTSEqualsDTS(*rtp.Packet) bool {
|
|
||||||
return true
|
|
||||||
}
|
|
@@ -1,4 +1,4 @@
|
|||||||
package rtpmpeg2audio
|
package rtpmpeg1audio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
@@ -1,4 +1,4 @@
|
|||||||
package rtpmpeg2audio
|
package rtpmpeg1audio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
@@ -1,4 +1,4 @@
|
|||||||
package rtpmpeg2audio
|
package rtpmpeg1audio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
@@ -1,4 +1,4 @@
|
|||||||
package rtpmpeg2audio
|
package rtpmpeg1audio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
2
pkg/formats/rtpmpeg1audio/rtpmpeg1audio.go
Normal file
2
pkg/formats/rtpmpeg1audio/rtpmpeg1audio.go
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// Package rtpmpeg1audio contains a RTP/MPEG-1/2 Audio decoder and encoder.
|
||||||
|
package rtpmpeg1audio
|
@@ -1,2 +1,26 @@
|
|||||||
// Package rtpmpeg2audio contains a RTP/MPEG-1/2 Audio decoder and encoder.
|
// Package rtpmpeg2audio contains a RTP/MPEG-1/2 Audio decoder and encoder.
|
||||||
package rtpmpeg2audio
|
package rtpmpeg2audio
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/bluenviron/gortsplib/v3/pkg/formats/rtpmpeg1audio"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ErrMorePacketsNeeded is an alis for rtpmpeg1audio.ErrMorePacketsNeeded.
|
||||||
|
//
|
||||||
|
// Deprecated: replaced by rtpmpeg1audio.ErrMorePacketsNeeded.
|
||||||
|
var ErrMorePacketsNeeded = rtpmpeg1audio.ErrMorePacketsNeeded
|
||||||
|
|
||||||
|
// ErrNonStartingPacketAndNoPrevious is an alis for rtpmpeg1audio.ErrNonStartingPacketAndNoPrevious.
|
||||||
|
//
|
||||||
|
// Deprecated: replaced by rtpmpeg1audio.ErrNonStartingPacketAndNoPrevious.
|
||||||
|
var ErrNonStartingPacketAndNoPrevious = rtpmpeg1audio.ErrNonStartingPacketAndNoPrevious
|
||||||
|
|
||||||
|
// Decoder is an alis for rtpmpeg1audio.Decoder.
|
||||||
|
//
|
||||||
|
// Deprecated: replaced by rtpmpeg1audio.Decoder.
|
||||||
|
type Decoder = rtpmpeg1audio.Decoder
|
||||||
|
|
||||||
|
// Encoder is an alis for rtpmpeg1audio.Encoder.
|
||||||
|
//
|
||||||
|
// Deprecated: replaced by rtpmpeg1audio.Encoder.
|
||||||
|
type Encoder = rtpmpeg1audio.Encoder
|
||||||
|
Reference in New Issue
Block a user