Code refactoring after #967

This commit is contained in:
Alex X
2024-04-29 06:56:58 +03:00
parent d96701453d
commit e304035f76
2 changed files with 13 additions and 14 deletions
+10 -11
View File
@@ -2,12 +2,13 @@ package isapi
import (
"errors"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/tcp"
"io"
"net"
"net/http"
"net/url"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/tcp"
)
type Client struct {
@@ -84,15 +85,13 @@ func (c *Client) Dial() (err error) {
}
func (c *Client) Open() (err error) {
// Hikvision ISAPI may not accept a new open request if the previous one was not closed (e.g.
// using the test button on-camera or via curl command) but a close request can be sent even if
// the audio is already closed. So, we send a close request first and then open it again. Seems
// janky but it works.
err = c.Close()
if err != nil {
return err
}
// Hikvision ISAPI may not accept a new open request if the previous one was not closed (e.g.
// using the test button on-camera or via curl command) but a close request can be sent even if
// the audio is already closed. So, we send a close request first and then open it again. Seems
// janky but it works.
if err = c.Close(); err != nil {
return err
}
link := c.url + "/ISAPI/System/TwoWayAudio/channels/" + c.channel
req, err := http.NewRequest("PUT", link+"/open", nil)