Add rtsp_client for testing ghost exec process

This commit is contained in:
Alex X
2024-06-05 20:00:41 +03:00
parent 9bb36ebb6c
commit e0b1a50356
3 changed files with 59 additions and 2 deletions

View File

@@ -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()
}

View File

@@ -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}
```

View File

@@ -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
}