onvif

package
v0.0.0-...-d3febc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetONVIFVideoTransmitters

func GetONVIFVideoTransmitters(log *slog.Logger, ifaceName string) ([]string, error)

Types

type Capabilities

type Capabilities struct {
	Events struct {
		Address                                       string `xml:"XAddr"`
		WSSubscriptionPolicySupport                   bool   `xml:"WSSubscriptionPolicySupport"`
		WSPullPointSupport                            bool   `xml:"WSPullPointSupport"`
		WSPausableSubscriptionManagerInterfaceSupport bool   `xml:"WSPausableSubscriptionManagerInterfaceSupport"`
	} `xml:"Body>GetCapabilitiesResponse>Capabilities>Events"`
	Media struct {
		Address string `xml:"XAddr"`
	} `xml:"Body>GetCapabilitiesResponse>Capabilities>Media"`
}

<s:Envelope xmlns:sc=\"http://www.w3.org/2003/05/soap-encoding\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tt=\"http://www.onvif.org/ver10/schema\" xmlns:tds=\"http://www.onvif.org/ver10/device/wsdl\"> <s:Header/> <s:Body>

<tds:Capabilities>
  <tds:Capabilities>
    <tt:Analytics>..</tt:Analytics>
    <tt:Device>..</tt:Device>
    <tt:Events>
      <tt:XAddr>http://192.168.10.108/onvif/event_service</tt:XAddr>
      <tt:WSSubscriptionPolicySupport>true</tt:WSSubscriptionPolicySupport>
      <tt:WSPullPointSupport>true</tt:WSPullPointSupport>
      <tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport>
    </tt:Events>
    <tt:Imaging>
      <tt:XAddr>http://192.168.10.108/onvif/imaging_service</tt:XAddr>
    </tt:Imaging>
    <tt:Media>
      <tt:XAddr>http://192.168.10.108/onvif/media_service</tt:XAddr>
      <tt:StreamingCapabilities>
        <tt:RTPMulticast>true</tt:RTPMulticast>
        <tt:RTP_TCP>true</tt:RTP_TCP>
        <tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP>
      </tt:StreamingCapabilities>
      <tt:Extension>
        <tt:ProfileCapabilities>
          <tt:MaximumNumberOfProfiles>6</tt:MaximumNumberOfProfiles>
        </tt:ProfileCapabilities>
      </tt:Extension>
    </tt:Media>
    <tt:Extension>..</tt:Extension>

</s:Body> </s:Envelope>

type Device

type Device struct {
	Address  string
	Username string
	Password string

	// cameras often have a clock that is off by some amount which then causes auth to fail, this is the offset
	// to apply from our system clock to the camera clock to account for that
	ClockOffset time.Duration

	Capabilities      Capabilities
	DeviceInformation DeviceInformation
	Profiles          []Profile
	MediaProfiles     []MediaProfile
}

func NewDevice

func NewDevice(address string, username string, password string) *Device

func (*Device) GetCapabilities

func (d *Device) GetCapabilities(log *slog.Logger) (*Capabilities, error)

func (*Device) GetDeviceInformation

func (d *Device) GetDeviceInformation(log *slog.Logger) (*DeviceInformation, error)

func (*Device) GetProfiles

func (d *Device) GetProfiles(log *slog.Logger) ([]Profile, error)

func (*Device) GetSystemDateAndTime

func (d *Device) GetSystemDateAndTime(log *slog.Logger) (time.Time, error)

func (*Device) Probe

func (d *Device) Probe(log *slog.Logger) (bool, error)

type DeviceInformation

type DeviceInformation struct {
	Manufacturer    string `xml:"Body>GetDeviceInformationResponse>Manufacturer"`
	Model           string `xml:"Body>GetDeviceInformationResponse>Model"`
	FirmwareVersion string `xml:"Body>GetDeviceInformationResponse>FirmwareVersion"`
	SerialNumber    string `xml:"Body>GetDeviceInformationResponse>SerialNumber"`
	HardwareID      string `xml:"Body>GetDeviceInformationResponse>HardwareID"`
}

type GetProfileResponse

type GetProfileResponse struct {
	Profiles []Profile `xml:"Body>GetProfilesResponse>Profiles"`
}

type GetStreamUriResponse

type GetStreamUriResponse struct {
	MediaURI struct {
		URI                 string `xml:"Uri"`
		InvalidAfterConnect bool   `xml:"InvalidAfterConnect"`
		InvalidAfterReboot  bool   `xml:"InvalidAfterReboot"`
		Timeout             string `xml:"Timeout"`
	} `xml:"Body>GetStreamUriResponse>MediaUri"`
}

type GetSystemDateAndTimeResponse

type GetSystemDateAndTimeResponse struct {
	UTCDateTime struct {
		Time struct {
			Hour   int `xml:"Hour"`
			Minute int `xml:"Minute"`
			Second int `xml:"Second"`
		}
		Date struct {
			Year  int `xml:"Year"`
			Month int `xml:"Month"`
			Day   int `xml:"Day"`
		}
	} `xml:"Body>GetSystemDateAndTimeResponse>SystemDateAndTime>UTCDateTime"`
}

type MediaProfile

type MediaProfile struct {
	Token         string
	URI           string
	SourceStreams []Stream
	RTSPStreams   []ffmpeg.Stream
}

type ProbeResponse

type ProbeResponse struct {
	UUID    string `xml:"Header>RelatesTo"`
	Matches []struct {
		EndpointReference string `xml:"EndpointReference>Address"`
		Types             string `xml:"Types"`
		Scopes            string `xml:"Scopes"`
		XAddrs            string `xml:"XAddrs"`
	} `xml:"Body>ProbeMatches>ProbeMatch"`
}

<?xml version=\"1.0\" encoding=\"UTF-8\" ?> <s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:sc=\"http://www.w3.org/2003/05/soap-encoding\" xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\" xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:dn=\"http://www.onvif.org/ver10/network/wsdl\" xmlns:tds=\"http://www.onvif.org/ver10/device/wsdl\"> <s:Header>

 <a:MessageID>uuid:6f3f15ac-9f75-9eb4-697b-26774d859f75</a:MessageID>
 <a:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>
 <a:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</a:Action>
 <a:RelatesTo>urn:uuid:eccb3c9d-8031-4215-a1f6-b25e8efa52a6</a:RelatesTo>
 </s:Header>
 <s:Body>
 <d:ProbeMatches>
   <d:ProbeMatch>
     <a:EndpointReference>
       <a:Address>uuid:b1fc8184-b342-a2b0-8db5-cc7447feb342</a:Address>
     </a:EndpointReference>
     <d:Types>dn:NetworkVideoTransmitter tds:Device</d:Types>
     <d:Scopes>onvif://www.onvif.org/location/country/china onvif://www.onvif.org/name/Amcrest onvif://www.onvif.org/hardware/IP5M-T1179E onvif://www.onvif.org/Profile/Streaming onvif://www.onvif.org/type/Network_Video_Transmitter onvif://www.onvif.org/extension/unique_identifier onvif://www.onvif.org/Profile/T</d:Scopes>
     <d:XAddrs>http://192.168.10.108/onvif/device_service</d:XAddrs>
     <d:MetadataVersion>1</d:MetadataVersion>
   </d:ProbeMatch>
</d:ProbeMatches>

</s:Body></s:Envelope>

type Profile

type Profile struct {
	Token                    string `xml:"token,attr"`
	Name                     string `xml:"Name"`
	URI                      string
	VideoSourceConfiguration struct {
		Bounds struct {
			Width  int `xml:"width,attr"`
			Height int `xml:"height,attr"`
		} `xml:"Bounds"`
	} `xml:"VideoSourceConfiguration"`
	Streams []ffmpeg.Stream
}

type Stream

type Stream struct {
	Index         int    `json:"index"`
	CodecType     string `json:"codec_type"`
	CodecName     string `json:"codec_name"`
	CodecLongName string `json:"codec_long_name"`
	Width         int    `json:"width"`
	Height        int    `json:"height"`
	FrameRate     string `json:"avg_frame_rate"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL