Update RTSP server filters
This commit is contained in:
+17
-6
@@ -209,16 +209,27 @@ func initMedias(conn *rtsp.Conn) {
|
|||||||
for key, value := range conn.URL.Query() {
|
for key, value := range conn.URL.Query() {
|
||||||
switch key {
|
switch key {
|
||||||
case streamer.KindVideo, streamer.KindAudio:
|
case streamer.KindVideo, streamer.KindAudio:
|
||||||
for _, value := range value {
|
for _, name := range value {
|
||||||
|
name = strings.ToUpper(name)
|
||||||
|
|
||||||
|
// check aliases
|
||||||
|
switch name {
|
||||||
|
case "COPY":
|
||||||
|
name = "" // pass empty codecs list
|
||||||
|
case "MJPEG":
|
||||||
|
name = streamer.CodecJPEG
|
||||||
|
case "AAC":
|
||||||
|
name = streamer.CodecAAC
|
||||||
|
}
|
||||||
|
|
||||||
media := &streamer.Media{
|
media := &streamer.Media{
|
||||||
Kind: key, Direction: streamer.DirectionRecvonly,
|
Kind: key, Direction: streamer.DirectionRecvonly,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch value {
|
// empty codecs match all codecs
|
||||||
case "", "copy": // pass empty codecs list
|
if name != "" {
|
||||||
default:
|
// empty clock rate and channels match any values
|
||||||
codec := streamer.NewCodec(value)
|
media.Codecs = []*streamer.Codec{{Name: name}}
|
||||||
media.Codecs = append(media.Codecs, codec)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.Medias = append(conn.Medias, media)
|
conn.Medias = append(conn.Medias, media)
|
||||||
|
|||||||
@@ -129,22 +129,6 @@ type Codec struct {
|
|||||||
PayloadType uint8
|
PayloadType uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCodec(name string) *Codec {
|
|
||||||
name = strings.ToUpper(name)
|
|
||||||
switch name {
|
|
||||||
case CodecH264, CodecH265, CodecVP8, CodecVP9, CodecAV1, CodecJPEG:
|
|
||||||
return &Codec{Name: name, ClockRate: 90000}
|
|
||||||
case CodecPCMU, CodecPCMA:
|
|
||||||
return &Codec{Name: name, ClockRate: 8000}
|
|
||||||
case CodecOpus:
|
|
||||||
return &Codec{Name: name, ClockRate: 48000, Channels: 2}
|
|
||||||
case "MJPEG":
|
|
||||||
return &Codec{Name: CodecJPEG, ClockRate: 90000}
|
|
||||||
}
|
|
||||||
|
|
||||||
panic(fmt.Sprintf("unsupported codec: %s", name))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Codec) String() string {
|
func (c *Codec) String() string {
|
||||||
s := fmt.Sprintf("%d %s/%d", c.PayloadType, c.Name, c.ClockRate)
|
s := fmt.Sprintf("%d %s/%d", c.PayloadType, c.Name, c.ClockRate)
|
||||||
if c.Channels > 0 {
|
if c.Channels > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user