mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-09-27 03:56:08 +08:00
对其他音频的支持
This commit is contained in:
@@ -231,10 +231,10 @@ func (client *RTSP) requestStream() (err error) {
|
||||
client.Conn.timeout = 0 // UDP ignore timeout
|
||||
}
|
||||
case "audio":
|
||||
if len(sdpInfo.Config) < 2 {
|
||||
Printf("Setup audio err codec not support: %s", client.ASdp.Codec)
|
||||
} else {
|
||||
if len(sdpInfo.Config) > 0 {
|
||||
client.WriteASC(sdpInfo.Config)
|
||||
}else{
|
||||
client.setAudioFormat()
|
||||
}
|
||||
if client.TransType == TRANS_TYPE_TCP {
|
||||
headers["Transport"] = fmt.Sprintf("RTP/AVP/TCP;unicast;interleaved=%d-%d", client.aRTPChannel, client.aRTPControlChannel)
|
||||
@@ -337,9 +337,6 @@ func (client *RTSP) startStream() {
|
||||
pack = &RTPPack{
|
||||
Type: RTP_TYPE_AUDIO,
|
||||
}
|
||||
if client.ASdp.Codec != "aac" {
|
||||
continue
|
||||
}
|
||||
case client.aRTPControlChannel:
|
||||
pack = &RTPPack{
|
||||
Type: RTP_TYPE_AUDIOCONTROL,
|
||||
|
4
go.mod
4
go.mod
@@ -3,8 +3,8 @@ module github.com/Monibuca/plugin-rtsp
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/Monibuca/engine/v2 v2.1.9
|
||||
github.com/Monibuca/plugin-rtp v0.0.0-20200531014802-504413c0dfcb
|
||||
github.com/Monibuca/engine/v2 v2.2.0
|
||||
github.com/Monibuca/plugin-rtp v1.0.0
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
|
||||
github.com/mattn/go-colorable v0.1.7 // indirect
|
||||
github.com/pion/rtp v1.6.0 // indirect
|
||||
|
4
go.sum
4
go.sum
@@ -6,8 +6,11 @@ github.com/Monibuca/engine/v2 v2.1.2 h1:7dUrHJAPEtvGFOO4GsKGjfMCmcbMrtLyYQ7WoK5E
|
||||
github.com/Monibuca/engine/v2 v2.1.2/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc=
|
||||
github.com/Monibuca/engine/v2 v2.1.9 h1:IulMIeP24qv8xWaI+tcg233Y7w3mCaLXxt4iQaVpT7s=
|
||||
github.com/Monibuca/engine/v2 v2.1.9/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc=
|
||||
github.com/Monibuca/engine/v2 v2.2.0 h1:A4SyWwzVLegd8Oa6LfSW3LpNfBmWq+MHJJLO55gvaYI=
|
||||
github.com/Monibuca/engine/v2 v2.2.0/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc=
|
||||
github.com/Monibuca/plugin-rtp v0.0.0-20200531014802-504413c0dfcb h1:CnmoQ8XsWxs/6mulbQfTGUa8cPr6c/3bkkTsNozRBwE=
|
||||
github.com/Monibuca/plugin-rtp v0.0.0-20200531014802-504413c0dfcb/go.mod h1:8HxBilkF835Lepe/DLUCjaw1mRiu3MxTDsG7g9UcfZA=
|
||||
github.com/Monibuca/plugin-rtp v1.0.0/go.mod h1:0xkNm23a/BjVnEMz1zXyOqfEjoVmGe3PJqPNF1KyFGc=
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
@@ -22,6 +25,7 @@ github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRn
|
||||
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/mask-pp/rtp-ps v1.0.0/go.mod h1:jCxsZ2G7z/jX+aqFypEWMePnhNrfnUiXUEKm6Xp0vgU=
|
||||
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
|
||||
|
14
main.go
14
main.go
@@ -144,6 +144,20 @@ type RTSP struct {
|
||||
UDPClient *UDPClient
|
||||
Auth func(string) string
|
||||
}
|
||||
func (rtsp *RTSP) setAudioFormat(){
|
||||
switch rtsp.ASdp.Codec {
|
||||
case "aac":
|
||||
rtsp.AudioInfo.SoundFormat = 10
|
||||
case "pcma":
|
||||
rtsp.AudioInfo.SoundFormat = 7
|
||||
rtsp.AudioInfo.SoundRate = rtsp.ASdp.TimeScale
|
||||
rtsp.AudioInfo.SoundSize = 16
|
||||
case "pcmu":
|
||||
rtsp.AudioInfo.SoundFormat = 8
|
||||
rtsp.AudioInfo.SoundRate = rtsp.ASdp.TimeScale
|
||||
rtsp.AudioInfo.SoundSize = 16
|
||||
}
|
||||
}
|
||||
type RTSPClientInfo struct {
|
||||
Agent string
|
||||
Session string
|
||||
|
@@ -318,12 +318,15 @@ func (session *RTSP) handleRequest(req *Request) {
|
||||
session.SDPRaw = req.Body
|
||||
session.SDPMap = ParseSDP(req.Body)
|
||||
if session.Publish(streamPath) {
|
||||
var ok bool
|
||||
if session.ASdp, ok = session.SDPMap["audio"]; ok {
|
||||
if session.ASdp, session.HasAudio = session.SDPMap["audio"]; session.HasAudio {
|
||||
if len(session.ASdp.Control) >0 {
|
||||
session.WriteASC(session.ASdp.Config)
|
||||
}else{
|
||||
session.setAudioFormat()
|
||||
}
|
||||
Printf("audio codec[%s]\n", session.ASdp.Codec)
|
||||
}
|
||||
if session.VSdp, ok = session.SDPMap["video"]; ok {
|
||||
if session.VSdp, session.HasVideo = session.SDPMap["video"]; session.HasVideo {
|
||||
if len(session.VSdp.SpropParameterSets) > 1 {
|
||||
session.WriteSPS(session.VSdp.SpropParameterSets[0])
|
||||
session.WritePPS(session.VSdp.SpropParameterSets[1])
|
||||
|
Reference in New Issue
Block a user