rename MPEG2Video into MPEG1Video, MPEG2Audio into MPEG1Audio

This commit is contained in:
aler9
2023-08-05 14:01:16 +02:00
committed by Alessandro Ros
parent 4e789ff6b9
commit 33bc1c874b
20 changed files with 120 additions and 84 deletions

View File

@@ -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:|
|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-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:|
### 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)||
|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-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)||
|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:|

View File

@@ -55,7 +55,7 @@ func Unmarshal(mediaType string, payloadType uint8, rtpMap string, fmtp map[stri
return &MJPEG{}
case payloadType == 32:
return &MPEG2Video{}
return &MPEG1Video{}
case payloadType == 33:
return &MPEGTS{}
@@ -98,7 +98,7 @@ func Unmarshal(mediaType string, payloadType uint8, rtpMap string, fmtp map[stri
return &G726{}
case payloadType == 14:
return &MPEG2Audio{}
return &MPEG1Audio{}
case codec == "l8", codec == "l16", codec == "l24":
return &LPCM{}

View File

@@ -190,7 +190,7 @@ var casesFormat = []struct {
14,
"",
nil,
&MPEG2Audio{},
&MPEG1Audio{},
"",
nil,
},
@@ -573,12 +573,12 @@ var casesFormat = []struct {
nil,
},
{
"video mpeg2 video",
"video mpeg1 video",
"video",
32,
"",
nil,
&MPEG2Video{},
&MPEG1Video{},
"",
nil,
},

View File

@@ -3,65 +3,65 @@ package formats //nolint:dupl
import (
"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
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
}
// Codec implements Format.
func (f *MPEG2Audio) Codec() string {
func (f *MPEG1Audio) Codec() string {
return "MPEG-1/2 Audio"
}
// String implements Format.
//
// Deprecated: replaced by Codec().
func (f *MPEG2Audio) String() string {
func (f *MPEG1Audio) String() string {
return f.Codec()
}
// ClockRate implements Format.
func (f *MPEG2Audio) ClockRate() int {
func (f *MPEG1Audio) ClockRate() int {
return 90000
}
// PayloadType implements Format.
func (f *MPEG2Audio) PayloadType() uint8 {
func (f *MPEG1Audio) PayloadType() uint8 {
return 14
}
// RTPMap implements Format.
func (f *MPEG2Audio) RTPMap() string {
func (f *MPEG1Audio) RTPMap() string {
return ""
}
// FMTP implements Format.
func (f *MPEG2Audio) FMTP() map[string]string {
func (f *MPEG1Audio) FMTP() map[string]string {
return nil
}
// PTSEqualsDTS implements Format.
func (f *MPEG2Audio) PTSEqualsDTS(*rtp.Packet) bool {
func (f *MPEG1Audio) PTSEqualsDTS(*rtp.Packet) bool {
return true
}
// 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.
func (f *MPEG2Audio) CreateDecoder() *rtpmpeg2audio.Decoder {
func (f *MPEG1Audio) CreateDecoder() *rtpmpeg1audio.Decoder {
d, _ := f.CreateDecoder2()
return d
}
// CreateDecoder2 creates a decoder able to decode the content of the format.
func (f *MPEG2Audio) CreateDecoder2() (*rtpmpeg2audio.Decoder, error) {
d := &rtpmpeg2audio.Decoder{}
func (f *MPEG1Audio) CreateDecoder2() (*rtpmpeg1audio.Decoder, error) {
d := &rtpmpeg1audio.Decoder{}
err := d.Init()
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.
//
// 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()
return e
}
// CreateEncoder2 creates an encoder able to encode the content of the format.
func (f *MPEG2Audio) CreateEncoder2() (*rtpmpeg2audio.Encoder, error) {
e := &rtpmpeg2audio.Encoder{}
func (f *MPEG1Audio) CreateEncoder2() (*rtpmpeg1audio.Encoder, error) {
e := &rtpmpeg1audio.Encoder{}
err := e.Init()
if err != nil {
@@ -90,3 +90,8 @@ func (f *MPEG2Audio) CreateEncoder2() (*rtpmpeg2audio.Encoder, error) {
return e, nil
}
// MPEG2Audio is an alias for MPEG1Audio.
//
// Deprecated: replaced by MPEG1Audio.
type MPEG2Audio = MPEG1Audio

View File

@@ -7,15 +7,15 @@ import (
"github.com/stretchr/testify/require"
)
func TestMPEG2AudioAttributes(t *testing.T) {
format := &MPEG2Audio{}
func TestMPEG1AudioAttributes(t *testing.T) {
format := &MPEG1Audio{}
require.Equal(t, "MPEG-1/2 Audio", format.Codec())
require.Equal(t, 90000, format.ClockRate())
require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{}))
}
func TestMPEG2AudioDecEncoder(t *testing.T) {
format := &MPEG2Audio{}
func TestMPEG1AudioDecEncoder(t *testing.T) {
format := &MPEG1Audio{}
enc, err := format.CreateEncoder2()
require.NoError(t, err)

View 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

View File

@@ -7,8 +7,8 @@ import (
"github.com/stretchr/testify/require"
)
func TestMPEG2VideoAttributes(t *testing.T) {
format := &MPEG2Video{}
func TestMPEG1VideoAttributes(t *testing.T) {
format := &MPEG1Video{}
require.Equal(t, "MPEG-1/2 Video", format.Codec())
require.Equal(t, 90000, format.ClockRate())
require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{}))

View File

@@ -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
}

View File

@@ -1,4 +1,4 @@
package rtpmpeg2audio
package rtpmpeg1audio
import (
"errors"

View File

@@ -1,4 +1,4 @@
package rtpmpeg2audio
package rtpmpeg1audio
import (
"testing"

View File

@@ -1,4 +1,4 @@
package rtpmpeg2audio
package rtpmpeg1audio
import (
"crypto/rand"

View File

@@ -1,4 +1,4 @@
package rtpmpeg2audio
package rtpmpeg1audio
import (
"testing"

View File

@@ -0,0 +1,2 @@
// Package rtpmpeg1audio contains a RTP/MPEG-1/2 Audio decoder and encoder.
package rtpmpeg1audio

View File

@@ -1,2 +1,26 @@
// Package rtpmpeg2audio contains a RTP/MPEG-1/2 Audio decoder and encoder.
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