sip.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package isapi
  2. import (
  3. "encoding/xml"
  4. "github.com/sirupsen/logrus"
  5. )
  6. type SIPServerList struct {
  7. SIPServer []struct {
  8. ID string `xml:"id" yaml:"ID"`
  9. LocalPort string `xml:"localPort" yaml:"localPort"`
  10. StreamID string `xml:"streamID" yaml:"streamID"`
  11. Standard struct {
  12. RegisterStatus string `xml:"registerStatus" yaml:"registerStatus"`
  13. Enabled string `xml:"enabled" yaml:"enabled"`
  14. Registrar string `xml:"registrar" yaml:"registrar"`
  15. RegistrarPort string `xml:"registrarPort" yaml:"registrarPort"`
  16. Proxy string `xml:"proxy" yaml:"proxy"`
  17. ProxyPort string `xml:"proxyPort" yaml:"proxyPort"`
  18. DisplayName string `xml:"displayName" yaml:"displayName"`
  19. UserName string `xml:"userName" yaml:"userName"`
  20. AuthID string `xml:"authID" yaml:"authID"`
  21. Password string `xml:"password" yaml:"password"`
  22. Expires string `xml:"expires" yaml:"expires"`
  23. } `xml:"Standard" yaml:"Standard"`
  24. GB28181 struct {
  25. RegisterStatus string `xml:"registerStatus" yaml:"registerStatus"`
  26. Enabled string `xml:"enabled" yaml:"enabled"`
  27. Registrar string `xml:"registrar" yaml:"registrar"`
  28. RegistrarPort string `xml:"registrarPort" yaml:"registrarPort"`
  29. ServerId string `xml:"serverId" yaml:"serverId"`
  30. ServerDomain string `xml:"serverDomain" yaml:"serverDomain"`
  31. UserName string `xml:"userName" yaml:"userName"`
  32. AuthID string `xml:"authID" yaml:"authID"`
  33. Expires string `xml:"expires" yaml:"expires"`
  34. Password string `xml:"password" yaml:"password"`
  35. LiveTime string `xml:"liveTime" yaml:"liveTime"`
  36. HeartbeatTime string `xml:"heartbeatTime" yaml:"heartbeatTime"`
  37. HeartbeatCount string `xml:"heartbeatCount" yaml:"heartbeatCount"`
  38. TransportType string `xml:"transportType" yaml:"transportType"`
  39. RegisterInterval string `xml:"registerInterval" yaml:"registerInterval"`
  40. ProtocolVersion string `xml:"protocolVersion" yaml:"protocolVersion"`
  41. PlatformNo string `xml:"platformNo" yaml:"platformNo"`
  42. LocalPort string `xml:"localPort" yaml:"localPort"`
  43. UnidirectionEnabled string `xml:"unidirectionEnabled" yaml:"unidirectionEnabled"`
  44. VoiceBroadcastEnabled string `xml:"voiceBroadcastEnabled" yaml:"voiceBroadcastEnabled"`
  45. } `xml:"GB28181" yaml:"GB28181"`
  46. } `xml:"SIPServer"`
  47. }
  48. func (c *Client) PutSip(data []byte) (resp ResponseStatus, err error) {
  49. bytes, err := c.CommonPut(data, "/ISAPI/System/Network/SIP")
  50. if err != nil {
  51. logrus.Error("请求出错", err)
  52. return
  53. }
  54. err = xml.Unmarshal(bytes, &resp)
  55. return
  56. }
  57. func (c *Client) PutSipInfo(data []byte) (resp ResponseStatus, err error) {
  58. bytes, err := c.CommonPut(data, "/ISAPI/System/Network/SIP/1/SIPInfo")
  59. if err != nil {
  60. logrus.Error("请求出错", err)
  61. return
  62. }
  63. err = xml.Unmarshal(bytes, &resp)
  64. return
  65. }
  66. type SIPInfo struct {
  67. VideoID string `xml:"videoID"`
  68. AlarmInList []string `xml:"AlarmInList"`
  69. VideoInputList []struct {
  70. VideoInput struct {
  71. ID string `xml:"id"`
  72. VideoInputID string `xml:"videoInputID"`
  73. } `xml:"VideoInput"`
  74. } `xml:"VideoInputList"`
  75. AudioOutputList []struct {
  76. AudioOutput struct {
  77. ID string `xml:"id"`
  78. AudioOutputID string `xml:"audioOutputID"`
  79. } `xml:"AudioOutput"`
  80. } `xml:"AudioOutputList"`
  81. }