Skip to content

Commit

Permalink
Add rtsp_client for testing ghost exec process
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jun 5, 2024
1 parent 9bb36eb commit e0b1a50
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
39 changes: 39 additions & 0 deletions examples/rtsp_client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"log"
"os"

"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/rtsp"
"github.com/AlexxIT/go2rtc/pkg/shell"
)

func main() {
client := rtsp.NewClient(os.Args[1])
if err := client.Dial(); err != nil {
log.Panic(err)
}

client.Medias = []*core.Media{
{
Kind: core.KindAudio,
Direction: core.DirectionRecvonly,
Codecs: []*core.Codec{
{Name: core.CodecPCMU, ClockRate: 8000},
},
ID: "streamid=0",
},
}
if err := client.Announce(); err != nil {
log.Panic(err)
}
if _, err := client.SetupMedia(client.Medias[0]); err != nil {
log.Panic(err)
}
if err := client.Record(); err != nil {
log.Panic(err)
}

shell.RunUntilSignal()
}
8 changes: 8 additions & 0 deletions internal/streams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Testing notes

```yaml
streams:
test1-basic: ffmpeg:virtual?video#video=h264
test2-reconnect: ffmpeg:virtual?video&duration=10#video=h264
test3-execkill: exec:./examples/rtsp_client/rtsp_client/rtsp_client {output}
```
14 changes: 12 additions & 2 deletions pkg/rtsp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,20 @@ func (c *Conn) Announce() (err error) {
return err
}

res, err := c.Do(req)
_, err = c.Do(req)
return
}

_ = res
func (c *Conn) Record() (err error) {
req := &tcp.Request{
Method: MethodRecord,
URL: c.URL,
Header: map[string][]string{
"Range": {"npt=0.000-"},
},
}

_, err = c.Do(req)
return
}

Expand Down

0 comments on commit e0b1a50

Please sign in to comment.