Skip to content

Commit

Permalink
Add media filter for RTSP source #198
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Aug 21, 2023
1 parent f80f179 commit 69a3a30
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/rtsp/rtsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func rtspHandler(rawURL string) (core.Producer, error) {
if rawQuery != "" {
query := streams.ParseQuery(rawQuery)
conn.Backchannel = query.Get("backchannel") == "1"
conn.Media = query.Get("media")
conn.Transport = query.Get("transport")
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/rtsp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ func (c *Conn) Describe() error {
return err
}

if c.Media != "" {
clone := make([]*core.Media, 0, len(medias))
for _, media := range medias {
if strings.Contains(c.Media, media.Kind) {
clone = append(clone, media)
}
}
medias = clone
}

// TODO: rewrite more smart
if c.Medias == nil {
c.Medias = medias
Expand Down
1 change: 1 addition & 0 deletions pkg/rtsp/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Conn struct {
// public

Backchannel bool
Media string
PacketSize uint16
SessionName string
Transport string // custom transport support, ex. RTSP over WebSocket
Expand Down

0 comments on commit 69a3a30

Please sign in to comment.