gortsplib升级到v3.2.1

增加默认缓存大小,解决高码率推拉流问题
增加英文文档
This commit is contained in:
langhuihui
2023-04-23 11:26:02 +08:00
parent a4773b4044
commit 1ad45bfbc1
9 changed files with 147 additions and 90 deletions

70
README.en.md Normal file
View File

@@ -0,0 +1,70 @@
_[简体中文](https://github.com/Monibuca/plugin-rtsp/README.md) | English_
# RTSP Plugin
The RTSP plugin provides the ability to push and pull the RTSP protocol and also to push and pull the RTSP protocol to remote servers.
## Plugin address
https://github.com/Monibuca/plugin-rtsp
## Plugin introduction
```go
import (
_ "m7s.live/plugin/rtsp/v4"
)
```
## Push and Pull address form
```
rtsp://localhost/live/test
```
- `localhost` is the m7s server domain name or IP address, and the default port `554` can be omitted, otherwise it is required to be written.
- `live` represents `appName`
- `test` represents `streamName`
- `live/test` in m7s will serve as the stream identity.
For example, push stream to m7s through ffmpeg
```bash
ffmpeg -i [video source] -c:v h264 -c:a aac -f rtsp rtsp://localhost/live/test
```
This will create a stream named `live/test` inside m7s.
If the `live/test` stream already exists in m7s, then you can use the RTSP protocol to play it.
```bash
ffplay rtsp://localhost/live/test
```
## Configuration
```yaml
rtsp:
publish: # Refer to the global configuration format
subscribe: # Refer to the global configuration format
pull: # Format reference document https://m7s.live/guide/config.html#%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE
push: # Format reference document https://m7s.live/guide/config.html#%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE
listenaddr: :554
udpaddr: :8000
rtcpaddr: :8001
readbuffercount: 2048
writebuffercount: 2048
pullprotocol: 'auto' # auto, tcp, udp
```
:::tip Configuration override
publish and subscribe, any section not configured will use global configuration.
:::
## API
### `rtsp/api/list`
Get all RTSP streams
### `rtsp/api/pull?target=[RTSP address]&streamPath=[Stream identity]`
Pull the RTSP to m7s from a remote server
### `rtsp/api/push?target=[RTSP address]&streamPath=[Stream identity]`
Push local streams to remote servers

View File

@@ -1,3 +1,4 @@
_[English](https://github.com/Monibuca/plugin-rtsp/README.en.md) | 简体中文_
# RTSP插件
rtsp插件提供rtsp协议的推拉流能力以及向远程服务器推拉rtsp协议的能力。
## 插件地址
@@ -35,42 +36,20 @@ ffmpeg -i [视频源] -c:v h264 -c:a aac -f rtsp rtsp://localhost/live/test
ffplay rtsp://localhost/live/test
```
## 配置
```yaml
rtsp:
publish:
pubaudio: true # 是否发布音频流
pubvideo: true # 是否发布视频流
kickexist: false # 剔出已经存在的发布者,用于顶替原有发布者
publishtimeout: 10s # 发布流默认过期时间,超过该时间发布者没有恢复流将被删除
delayclosetimeout: 0 # 自动关闭触发后延迟的时间(期间内如果有新的订阅则取消触发关闭)0为关闭该功能保持连接。
waitclosetimeout: 0 # 发布者断开后等待时间超过该时间发布者没有恢复流将被删除0为关闭该功能由订阅者决定是否删除
buffertime: 0 # 缓存时间用于时光回溯0为关闭缓存
subscribe:
subaudio: true # 是否订阅音频流
subvideo: true # 是否订阅视频流
subaudioargname: ats # 订阅音频轨道参数名
subvideoargname: vts # 订阅视频轨道参数名
subdataargname: dts # 订阅数据轨道参数名
subaudiotracks: [] # 订阅音频轨道名称列表
subvideotracks: [] # 订阅视频轨道名称列表
submode: 0 # 订阅模式0为跳帧追赶模式1为不追赶多用于录制2为时光回溯模式
iframeonly: false # 只订阅关键帧
waittimeout: 10s # 等待发布者的超时时间,用于订阅尚未发布的流
pull:
repull: 0
pullonstart: {}
pullonsub: {}
push:
repush: 0
pushlist: {}
publish: # 参考全局配置格式
subscribe: # 参考全局配置格式
pull: # 格式参考文档 https://m7s.live/guide/config.html#%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE
push: # 格式参考文档 https://m7s.live/guide/config.html#%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE
listenaddr: :554
udpaddr: :8000
rtcpaddr: :8001
readbuffersize: 2048
pullprotocol: 'auto'
readbuffercount: 2048 # 读取缓存队列大小
writebuffercount: 2048 # 写出缓存队列大小
pullprotocol: 'auto' # auto, tcp, udp
```
:::tip 配置覆盖
publish
@@ -82,7 +61,7 @@ subscribe
### `rtsp/api/list`
获取所有rtsp流
### `rtsp/api/pull?target=[RTSP地址]&streamPath=[流标识]`
### `rtsp/api/pull?target=[RTSP地址]&streamPath=[流标识]&save=[0|1]`
从远程拉取rtsp到m7s中
### `rtsp/api/push?target=[RTSP地址]&streamPath=[流标识]`

View File

@@ -1,27 +1,30 @@
package rtsp
import (
"github.com/aler9/gortsplib/v2"
"github.com/aler9/gortsplib/v2/pkg/url"
"context"
"net"
"github.com/bluenviron/gortsplib/v3"
"github.com/bluenviron/gortsplib/v3/pkg/url"
"go.uber.org/zap"
"m7s.live/engine/v4"
)
type RTSPClient struct {
*gortsplib.Client `json:"-" yaml:"-"`
gortsplib.Transport
DialContext func(ctx context.Context, network, address string) (net.Conn, error) `json:"-" yaml:"-"`
}
type RTSPPuller struct {
RTSPPublisher
engine.Puller
*gortsplib.Client `json:"-" yaml:"-"`
gortsplib.Transport
RTSPClient
}
func (p *RTSPPuller) Connect() error {
p.Client = &gortsplib.Client{
// OnPacketRTP: func(ctx *gortsplib.ClientOnPacketRTPCtx) {
// if p.RTSPPublisher.Tracks[ctx.TrackID] != nil {
// p.RTSPPublisher.Tracks[ctx.TrackID].WriteRTPPack(ctx.Packet)
// }
// },
ReadBufferCount: rtspConfig.ReadBufferSize,
DialContext: p.DialContext,
ReadBufferCount: rtspConfig.ReadBufferCount,
}
switch rtspConfig.PullProtocol {
@@ -80,8 +83,7 @@ func (p *RTSPPuller) Pull() (err error) {
type RTSPPusher struct {
RTSPSubscriber
engine.Pusher
*gortsplib.Client
gortsplib.Transport
RTSPClient
}
func (p *RTSPPusher) OnEvent(event any) {
@@ -96,7 +98,8 @@ func (p *RTSPPusher) OnEvent(event any) {
}
func (p *RTSPPusher) Connect() error {
p.Client = &gortsplib.Client{
ReadBufferCount: rtspConfig.ReadBufferSize,
DialContext: p.DialContext,
WriteBufferCount: rtspConfig.WriteBufferCount,
}
// parse URL
u, err := url.Parse(p.RemoteURL)

8
go.mod
View File

@@ -3,7 +3,8 @@ module m7s.live/plugin/rtsp/v4
go 1.18
require (
github.com/aler9/gortsplib/v2 v2.1.0
github.com/bluenviron/gortsplib/v3 v3.2.1
github.com/bluenviron/mediacommon v0.2.1
github.com/pion/rtp v1.7.13
go.uber.org/zap v1.23.0
m7s.live/engine/v4 v4.11.18
@@ -11,6 +12,7 @@ require (
require (
github.com/aler9/gortsplib v1.0.1 // indirect
github.com/aler9/gortsplib/v2 v2.2.2 // indirect
github.com/cnotch/ipchub v1.1.0 // indirect
github.com/denisbrodbeck/machineid v1.0.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
@@ -42,9 +44,9 @@ require (
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/tools v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

20
go.sum
View File

@@ -1,9 +1,13 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/aler9/gortsplib v1.0.1 h1:R13+hxlvg2Hvu98+0hzg0o5fPjyUA9ZPJneMIBxKGXk=
github.com/aler9/gortsplib v1.0.1/go.mod h1:BOWNZ/QBkY/eVcRqUzJbPFEsRJshwxaxBT01K260Jeo=
github.com/aler9/gortsplib/v2 v2.1.0 h1:HKQjFugTGH32FScSXPL2p4SGLpxGBRnyBSzR3GKYG9U=
github.com/aler9/gortsplib/v2 v2.1.0/go.mod h1:jZy239Qg+C9OSvJrPs2vIPalm9/pam1ljFir5DdydnA=
github.com/aler9/gortsplib/v2 v2.2.2 h1:tTw8pdKSOEjlZjjE1S4ftXPHJkYOqjNNv3hjQ0Nto9M=
github.com/aler9/gortsplib/v2 v2.2.2/go.mod h1:k6uBVHGwsIc/0L5SLLqWwi6bSJUb4VR0HfvncyHlKQI=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/bluenviron/gortsplib/v3 v3.2.1 h1:wdMocTWu1EWa9PPWb8F/S6LY2hZikgrs7zgDtnwBPO0=
github.com/bluenviron/gortsplib/v3 v3.2.1/go.mod h1:AzHdywoBckre5q9Y581xg93PVthXayVHVqYMc3hwBlk=
github.com/bluenviron/mediacommon v0.2.1 h1:NkbbXwjMqspatQwSyGDYqxg14ftxJSjNsnPNocUxScw=
github.com/bluenviron/mediacommon v0.2.1/go.mod h1:t0dqPsWUTchyvib0MhixIwXEgvDX4V9G+I0GzWLQRb8=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
@@ -141,8 +145,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
@@ -196,8 +200,8 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -231,8 +235,8 @@ golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -242,7 +246,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=

20
main.go
View File

@@ -6,7 +6,7 @@ import (
"sync"
"time"
"github.com/aler9/gortsplib/v2"
"github.com/bluenviron/gortsplib/v3"
"go.uber.org/zap"
. "m7s.live/engine/v4"
"m7s.live/engine/v4/config"
@@ -18,10 +18,11 @@ type RTSPConfig struct {
config.Subscribe
config.Pull
config.Push
ListenAddr string
UDPAddr string
RTCPAddr string
ReadBufferSize int
ListenAddr string `default:":554"`
UDPAddr string `default:":8000"`
RTCPAddr string `default:":8001"`
ReadBufferCount int `default:"2048"`
WriteBufferCount int `default:"2048"`
PullProtocol string //tcp、udp、 autodefault
sync.Map
}
@@ -37,6 +38,8 @@ func (conf *RTSPConfig) OnEvent(event any) {
MulticastIPRange: "224.1.0.0/16",
MulticastRTPPort: 8002,
MulticastRTCPPort: 8003,
ReadBufferCount: conf.ReadBufferCount,
WriteBufferCount: conf.WriteBufferCount,
}
if err := s.Start(); err != nil {
RTSPPlugin.Error("server start", zap.Error(err))
@@ -67,12 +70,7 @@ func (conf *RTSPConfig) OnEvent(event any) {
}
}
var rtspConfig = &RTSPConfig{
ListenAddr: ":554",
UDPAddr: ":8000",
RTCPAddr: ":8001",
ReadBufferSize: 2048,
}
var rtspConfig = &RTSPConfig{}
var RTSPPlugin = InstallPlugin(rtspConfig)
func filterStreams() (ss []*Stream) {

View File

@@ -1,14 +1,15 @@
package rtsp
import (
"github.com/aler9/gortsplib/v2/pkg/codecs/mpeg4audio"
"github.com/aler9/gortsplib/v2/pkg/format"
"github.com/aler9/gortsplib/v2/pkg/media"
"github.com/bluenviron/mediacommon/pkg/codecs/mpeg4audio"
"github.com/bluenviron/gortsplib/v3/pkg/formats"
"github.com/bluenviron/gortsplib/v3/pkg/media"
"github.com/pion/rtp"
"go.uber.org/zap"
. "m7s.live/engine/v4"
"m7s.live/engine/v4/common"
. "m7s.live/engine/v4/track"
"m7s.live/engine/v4/util"
)
type RTSPPublisher struct {
@@ -27,10 +28,10 @@ func (p *RTSPPublisher) SetTracks() error {
for _, track := range p.tracks {
for _, forma := range track.Formats {
switch f := forma.(type) {
case *format.H264:
case *formats.H264:
vt := p.VideoTrack
if vt == nil {
vt = NewH264(p.Stream, f.PayloadType())
vt = NewH264(p.Stream, f.PayloadType(), make(util.BytesPool, 17))
p.VideoTrack = vt
}
p.Tracks[track] = p.VideoTrack
@@ -40,10 +41,10 @@ func (p *RTSPPublisher) SetTracks() error {
if len(f.PPS) > 0 {
vt.WriteSliceBytes(f.PPS)
}
case *format.H265:
case *formats.H265:
vt := p.VideoTrack
if vt == nil {
vt = NewH265(p.Stream, f.PayloadType())
vt = NewH265(p.Stream, f.PayloadType(), make(util.BytesPool, 17))
p.VideoTrack = vt
}
p.Tracks[track] = p.VideoTrack
@@ -56,10 +57,10 @@ func (p *RTSPPublisher) SetTracks() error {
if len(f.PPS) > 0 {
vt.WriteSliceBytes(f.PPS)
}
case *format.MPEG4Audio:
case *formats.MPEG4Audio:
at := p.AudioTrack
if at == nil {
at := NewAAC(p.Stream, f.PayloadType(), uint32(f.Config.SampleRate))
at := NewAAC(p.Stream, f.PayloadType(), uint32(f.Config.SampleRate), make(util.BytesPool, 17))
at.IndexDeltaLength = f.IndexDeltaLength
at.IndexLength = f.IndexLength
at.SizeLength = f.SizeLength
@@ -73,10 +74,10 @@ func (p *RTSPPublisher) SetTracks() error {
p.AudioTrack = at
}
p.Tracks[track] = p.AudioTrack
case *format.G711:
case *formats.G711:
at := p.AudioTrack
if at == nil {
at := NewG711(p.Stream, !f.MULaw, f.PayloadType(), uint32(f.ClockRate()))
at := NewG711(p.Stream, !f.MULaw, f.PayloadType(), uint32(f.ClockRate()), make(util.BytesPool, 17))
at.AVCCHead = []byte{(byte(at.CodecID) << 4) | (1 << 1)}
p.AudioTrack = at
}
@@ -95,7 +96,7 @@ func (p *RTSPPublisher) SetTracks() error {
return nil
}
func (p *RTSPPublisher) OnPacket(m *media.Media, f format.Format, pack *rtp.Packet) {
func (p *RTSPPublisher) OnPacket(m *media.Media, f formats.Format, pack *rtp.Packet) {
if t, ok := p.Tracks[m]; ok {
t.WriteRTPPack(pack)
}

View File

@@ -1,9 +1,9 @@
package rtsp
import (
"github.com/aler9/gortsplib/v2"
"github.com/aler9/gortsplib/v2/pkg/base"
"github.com/aler9/gortsplib/v2/pkg/media"
"github.com/bluenviron/gortsplib/v3"
"github.com/bluenviron/gortsplib/v3/pkg/base"
"github.com/bluenviron/gortsplib/v3/pkg/media"
. "m7s.live/engine/v4"
)

View File

@@ -1,10 +1,10 @@
package rtsp
import (
"github.com/aler9/gortsplib/v2"
"github.com/aler9/gortsplib/v2/pkg/codecs/mpeg4audio"
"github.com/aler9/gortsplib/v2/pkg/format"
"github.com/aler9/gortsplib/v2/pkg/media"
"github.com/bluenviron/gortsplib/v3"
"github.com/bluenviron/mediacommon/pkg/codecs/mpeg4audio"
"github.com/bluenviron/gortsplib/v3/pkg/formats"
"github.com/bluenviron/gortsplib/v3/pkg/media"
. "m7s.live/engine/v4"
"m7s.live/engine/v4/codec"
"m7s.live/engine/v4/track"
@@ -25,7 +25,7 @@ func (s *RTSPSubscriber) OnEvent(event any) {
case codec.CodecID_H264:
video := &media.Media{
Type: media.TypeVideo,
Formats: []format.Format{&format.H264{
Formats: []formats.Format{&formats.H264{
PacketizationMode: 1,
PayloadTyp: v.PayloadType,
SPS: v.ParamaterSets[0],
@@ -37,7 +37,7 @@ func (s *RTSPSubscriber) OnEvent(event any) {
case codec.CodecID_H265:
video := &media.Media{
Type: media.TypeVideo,
Formats: []format.Format{&format.H265{
Formats: []formats.Format{&formats.H265{
PayloadTyp: v.PayloadType,
VPS: v.ParamaterSets[0],
SPS: v.ParamaterSets[1],
@@ -56,7 +56,7 @@ func (s *RTSPSubscriber) OnEvent(event any) {
case codec.CodecID_AAC:
audio := &media.Media{
Type: media.TypeAudio,
Formats: []format.Format{&format.MPEG4Audio{
Formats: []formats.Format{&formats.MPEG4Audio{
PayloadTyp: v.PayloadType,
Config: &mpeg4audio.Config{
Type: mpeg4audio.ObjectTypeAACLC,
@@ -73,14 +73,14 @@ func (s *RTSPSubscriber) OnEvent(event any) {
case codec.CodecID_PCMA:
audio := &media.Media{
Type: media.TypeAudio,
Formats: []format.Format{&format.G711{}},
Formats: []formats.Format{&formats.G711{}},
}
s.audioTrack = audio
s.tracks = append(s.tracks, audio)
case codec.CodecID_PCMU:
audio := &media.Media{
Type: media.TypeAudio,
Formats: []format.Format{&format.G711{
Formats: []formats.Format{&formats.G711{
MULaw: true,
}},
}