Support channels for DVRIP
This commit is contained in:
+18
-5
@@ -66,11 +66,25 @@ func (c *Client) Dial() (err error) {
|
|||||||
|
|
||||||
c.reader = bufio.NewReader(c.conn)
|
c.reader = bufio.NewReader(c.conn)
|
||||||
|
|
||||||
c.stream = u.Path
|
query := u.Query()
|
||||||
if c.stream == "" {
|
channel := query.Get("channel")
|
||||||
c.stream = "Main"
|
if channel == "" {
|
||||||
|
channel = "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subtype := query.Get("subtype")
|
||||||
|
switch subtype {
|
||||||
|
case "", "0":
|
||||||
|
subtype = "Main"
|
||||||
|
case "1":
|
||||||
|
subtype = "Extra1"
|
||||||
|
}
|
||||||
|
|
||||||
|
c.stream = fmt.Sprintf(
|
||||||
|
`{"Channel":%s,"CombinMode":"NONE","StreamType":"%s","TransMode":"TCP"}`,
|
||||||
|
channel, subtype,
|
||||||
|
)
|
||||||
|
|
||||||
if u.User != nil {
|
if u.User != nil {
|
||||||
pass, _ := u.User.Password()
|
pass, _ := u.User.Password()
|
||||||
return c.Login(u.User.Username(), pass)
|
return c.Login(u.User.Username(), pass)
|
||||||
@@ -94,8 +108,7 @@ func (c *Client) Login(user, pass string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Play() (err error) {
|
func (c *Client) Play() (err error) {
|
||||||
format := `{"Name":"OPMonitor","SessionID":"0x%08X","OPMonitor":{"Action":"%s","Parameter":` +
|
format := `{"Name":"OPMonitor","SessionID":"0x%08X","OPMonitor":{"Action":"%s","Parameter":%s}}`
|
||||||
`{"Channel":0,"CombinMode":"NONE","StreamType":"%s","TransMode":"TCP"}}}`
|
|
||||||
|
|
||||||
data := fmt.Sprintf(format, c.session, "Claim", c.stream)
|
data := fmt.Sprintf(format, c.session, "Claim", c.stream)
|
||||||
if err = c.Request(OPMonitorClaim, data); err != nil {
|
if err = c.Request(OPMonitorClaim, data); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user