mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-09-26 20:31:11 +08:00
Add rtsp_client for testing ghost exec process
This commit is contained in:
39
examples/rtsp_client/main.go
Normal file
39
examples/rtsp_client/main.go
Normal 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()
|
||||
}
|
8
internal/streams/README.md
Normal file
8
internal/streams/README.md
Normal 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}
|
||||
```
|
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user