mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-10-04 07:16:48 +08:00
修正升级带来的bug
This commit is contained in:
28
session.go
28
session.go
@@ -317,21 +317,21 @@ func (session *RTSP) handleRequest(req *Request) {
|
|||||||
|
|
||||||
session.SDPRaw = req.Body
|
session.SDPRaw = req.Body
|
||||||
session.SDPMap = ParseSDP(req.Body)
|
session.SDPMap = ParseSDP(req.Body)
|
||||||
sdp, ok := session.SDPMap["audio"]
|
|
||||||
if ok {
|
|
||||||
session.AControl = sdp.Control
|
|
||||||
session.ACodec = sdp.Codec
|
|
||||||
session.WriteASC(sdp.Config)
|
|
||||||
Printf("audio codec[%s]\n", session.ACodec)
|
|
||||||
}
|
|
||||||
if sdp, ok = session.SDPMap["video"]; ok {
|
|
||||||
session.VControl = sdp.Control
|
|
||||||
session.VCodec = sdp.Codec
|
|
||||||
session.WriteSPS(sdp.SpropParameterSets[0])
|
|
||||||
session.WritePPS(sdp.SpropParameterSets[1])
|
|
||||||
Printf("video codec[%s]\n", session.VCodec)
|
|
||||||
}
|
|
||||||
if session.Publish(streamPath) {
|
if session.Publish(streamPath) {
|
||||||
|
sdp, ok := session.SDPMap["audio"]
|
||||||
|
if ok {
|
||||||
|
session.AControl = sdp.Control
|
||||||
|
session.ACodec = sdp.Codec
|
||||||
|
session.WriteASC(sdp.Config)
|
||||||
|
Printf("audio codec[%s]\n", session.ACodec)
|
||||||
|
}
|
||||||
|
if sdp, ok = session.SDPMap["video"]; ok {
|
||||||
|
session.VControl = sdp.Control
|
||||||
|
session.VCodec = sdp.Codec
|
||||||
|
session.WriteSPS(sdp.SpropParameterSets[0])
|
||||||
|
session.WritePPS(sdp.SpropParameterSets[1])
|
||||||
|
Printf("video codec[%s]\n", session.VCodec)
|
||||||
|
}
|
||||||
session.Stream.Type = "RTSP"
|
session.Stream.Type = "RTSP"
|
||||||
session.RTSPInfo.StreamInfo = &session.Stream.StreamInfo
|
session.RTSPInfo.StreamInfo = &session.Stream.StreamInfo
|
||||||
collection.Store(streamPath, session)
|
collection.Store(streamPath, session)
|
||||||
|
@@ -2,13 +2,14 @@ package rtsp
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
. "github.com/Monibuca/engine/v2"
|
|
||||||
. "github.com/Monibuca/plugin-rtp"
|
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
. "github.com/Monibuca/engine/v2"
|
||||||
|
. "github.com/Monibuca/plugin-rtp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UDPServer struct {
|
type UDPServer struct {
|
||||||
@@ -94,7 +95,7 @@ func (s *UDPServer) SetupAudio() (err error) {
|
|||||||
pack := &RTPPack{
|
pack := &RTPPack{
|
||||||
Type: RTP_TYPE_AUDIO,
|
Type: RTP_TYPE_AUDIO,
|
||||||
}
|
}
|
||||||
pack.Unmarshal(bufUDP)
|
pack.Unmarshal(bufUDP[:n])
|
||||||
s.HandleRTP(pack)
|
s.HandleRTP(pack)
|
||||||
} else {
|
} else {
|
||||||
Println("udp server read audio pack error", err)
|
Println("udp server read audio pack error", err)
|
||||||
@@ -133,7 +134,7 @@ func (s *UDPServer) SetupAudio() (err error) {
|
|||||||
pack := &RTPPack{
|
pack := &RTPPack{
|
||||||
Type: RTP_TYPE_AUDIOCONTROL,
|
Type: RTP_TYPE_AUDIOCONTROL,
|
||||||
}
|
}
|
||||||
pack.Unmarshal(bufUDP)
|
pack.Unmarshal(bufUDP[:n])
|
||||||
s.HandleRTP(pack)
|
s.HandleRTP(pack)
|
||||||
} else {
|
} else {
|
||||||
Println("udp server read audio control pack error", err)
|
Println("udp server read audio control pack error", err)
|
||||||
@@ -182,7 +183,7 @@ func (s *UDPServer) SetupVideo() (err error) {
|
|||||||
pack := &RTPPack{
|
pack := &RTPPack{
|
||||||
Type: RTP_TYPE_VIDEO,
|
Type: RTP_TYPE_VIDEO,
|
||||||
}
|
}
|
||||||
pack.Unmarshal(bufUDP)
|
pack.Unmarshal(bufUDP[:n])
|
||||||
s.HandleRTP(pack)
|
s.HandleRTP(pack)
|
||||||
} else {
|
} else {
|
||||||
Println("udp server read video pack error", err)
|
Println("udp server read video pack error", err)
|
||||||
@@ -222,7 +223,7 @@ func (s *UDPServer) SetupVideo() (err error) {
|
|||||||
pack := &RTPPack{
|
pack := &RTPPack{
|
||||||
Type: RTP_TYPE_VIDEOCONTROL,
|
Type: RTP_TYPE_VIDEOCONTROL,
|
||||||
}
|
}
|
||||||
pack.Unmarshal(bufUDP)
|
pack.Unmarshal(bufUDP[:n])
|
||||||
s.HandleRTP(pack)
|
s.HandleRTP(pack)
|
||||||
} else {
|
} else {
|
||||||
Println("udp server read video control pack error", err)
|
Println("udp server read video control pack error", err)
|
||||||
|
Reference in New Issue
Block a user