| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef __HIKVISION_H__
- #define __HIKVISION_H__
- /* Hikvision ISAPI helper.
- *
- * The ISAPI RTSP URL is fixed by protocol:
- * sub = rtsp://USER:PASS@IP:554/Streaming/Channels/{chan*100+2}
- * main = rtsp://USER:PASS@IP:554/Streaming/Channels/{chan*100+1}
- * where `chan` is the login channel number (usually 1).
- *
- * ISAPI read/write (device parameter access) goes over HTTP Digest auth and is
- * performed by shelling out to the system `curl` binary (no compile-time deps).
- */
- /* One camera credential from [camera_list]. */
- typedef struct {
- int id; /* index used by layouts / workers */
- char ip[64]; /* camera host/IP */
- char user[64];
- char pass[64];
- int login_chan; /* Hikvision login channel (default 1) */
- int port; /* RTSP port, default 554 */
- int http_port; /* ISAPI HTTP port, default 80 */
- } HvCam;
- /* Resolved RTSP URLs for one camera. */
- typedef struct {
- char sub[512]; /* sub-stream URL (e.g. .../Channels/102) */
- char main[512]; /* main-stream URL (e.g. .../Channels/101) */
- } HvUrls;
- /* Build sub/main RTSP URLs for a camera into out->sub / out->main. */
- void hv_build_urls(const HvCam *cam, HvUrls *out);
- /* Perform a single ISAPI HTTP(S) request via system curl.
- * method : "GET" or "PUT"
- * url : full http://host/ISAPI/... path
- * body : for PUT, the XML payload (may be NULL)
- * outbuf : on success receives the response body (caller must free with
- * free()); on failure NULL.
- * Returns 0 on success (HTTP 2xx), non-zero on failure.
- * SAFETY: caller must sanitise cam->user/pass/url (we quote them). */
- int hv_request(const HvCam *cam, const char *method, const char *urlpath,
- const char *body, char **outbuf);
- /* Read a streaming channel's encoding params (resolution/bitrate/etc.) and log
- * a one-line summary via flog(). Returns 0 on success, non-zero on failure. */
- int hv_read_and_log(const HvCam *cam, int chan_enc_id);
- /* Write a channel's main encoding params (resolution / fps / bitrate).
- * enc_id : encoding channel id (101 main, 102 sub for login chan 1)
- * width/height : video resolution
- * fps : frame rate
- * bitrate_kbps : target bitrate in kbps
- * Returns 0 on success, non-zero on failure. */
- int hv_write_params(const HvCam *cam, int enc_id,
- int width, int height, int fps, int bitrate_kbps);
- #endif
|