Add rtsp_client for testing ghost exec process
This commit is contained in:
@@ -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()
|
||||||
|
}
|
||||||
@@ -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}
|
||||||
|
```
|
||||||
+12
-2
@@ -186,10 +186,20 @@ func (c *Conn) Announce() (err error) {
|
|||||||
return err
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user