mirror of
https://github.com/aler9/gortsplib
synced 2025-10-18 21:14:38 +08:00
HeaderTransport: add support for destination, ttl, ports
This commit is contained in:
@@ -14,6 +14,15 @@ type HeaderTransport struct {
|
|||||||
// (optional) cast of the stream
|
// (optional) cast of the stream
|
||||||
Cast *StreamCast
|
Cast *StreamCast
|
||||||
|
|
||||||
|
// (optional) destination
|
||||||
|
Destination *string
|
||||||
|
|
||||||
|
// (optional) TTL
|
||||||
|
TTL *uint
|
||||||
|
|
||||||
|
// (optional) ports
|
||||||
|
Ports *[2]int
|
||||||
|
|
||||||
// (optional) client ports
|
// (optional) client ports
|
||||||
ClientPorts *[2]int
|
ClientPorts *[2]int
|
||||||
|
|
||||||
@@ -66,22 +75,47 @@ func ReadHeaderTransport(v HeaderValue) (*HeaderTransport, error) {
|
|||||||
switch parts[0] {
|
switch parts[0] {
|
||||||
case "RTP/AVP", "RTP/AVP/UDP":
|
case "RTP/AVP", "RTP/AVP/UDP":
|
||||||
ht.Protocol = StreamProtocolUDP
|
ht.Protocol = StreamProtocolUDP
|
||||||
|
parts = parts[1:]
|
||||||
|
|
||||||
case "RTP/AVP/TCP":
|
case "RTP/AVP/TCP":
|
||||||
ht.Protocol = StreamProtocolTCP
|
ht.Protocol = StreamProtocolTCP
|
||||||
|
parts = parts[1:]
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("invalid protocol (%v)", v)
|
return nil, fmt.Errorf("invalid protocol (%v)", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range parts[1:] {
|
switch parts[0] {
|
||||||
if t == "unicast" {
|
case "unicast":
|
||||||
v := StreamUnicast
|
v := StreamUnicast
|
||||||
ht.Cast = &v
|
ht.Cast = &v
|
||||||
|
parts = parts[1:]
|
||||||
|
|
||||||
} else if t == "multicast" {
|
case "multicast":
|
||||||
v := StreamMulticast
|
v := StreamMulticast
|
||||||
ht.Cast = &v
|
ht.Cast = &v
|
||||||
|
parts = parts[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, t := range parts {
|
||||||
|
if strings.HasPrefix(t, "destination=") {
|
||||||
|
v := t[len("destination="):]
|
||||||
|
ht.Destination = &v
|
||||||
|
|
||||||
|
} else if strings.HasPrefix(t, "ttl=") {
|
||||||
|
v, err := strconv.ParseUint(t[len("ttl="):], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
vu := uint(v)
|
||||||
|
ht.TTL = &vu
|
||||||
|
|
||||||
|
} else if strings.HasPrefix(t, "port=") {
|
||||||
|
ports, err := parsePorts(t[len("port="):])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ht.Ports = ports
|
||||||
|
|
||||||
} else if strings.HasPrefix(t, "client_port=") {
|
} else if strings.HasPrefix(t, "client_port=") {
|
||||||
ports, err := parsePorts(t[len("client_port="):])
|
ports, err := parsePorts(t[len("client_port="):])
|
||||||
|
@@ -53,6 +53,15 @@ var casesHeaderTransport = []struct {
|
|||||||
v := StreamMulticast
|
v := StreamMulticast
|
||||||
return &v
|
return &v
|
||||||
}(),
|
}(),
|
||||||
|
Destination: func() *string {
|
||||||
|
v := "225.219.201.15"
|
||||||
|
return &v
|
||||||
|
}(),
|
||||||
|
TTL: func() *uint {
|
||||||
|
v := uint(127)
|
||||||
|
return &v
|
||||||
|
}(),
|
||||||
|
Ports: &[2]int{7000, 7001},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user