1 #ifndef _INCLUDE_NETCAM_HTTP_H
2 #define _INCLUDE_NETCAM_HTTP_H
3 
4 
5 #include <netdb.h>
6 #include <netinet/in.h>
7 #include <sys/socket.h>
8 
9 #define MJPG_MH_MAGIC          "MJPG"
10 #define MJPG_MH_MAGIC_SIZE          4
11 
12 typedef struct file_context {
13     char      *path;               /* the path within the URL */
14     int       control_file_desc;   /* file descriptor for the control socket */
15     time_t    last_st_mtime;       /* time this image was modified */
16 } tfile_context;
17 
18 
19 /*
20  * MJPG Chunk header for MJPG streaming.
21  * Little-endian data is read from the network.
22  */
23 typedef struct {
24     char mh_magic[MJPG_MH_MAGIC_SIZE];     /* must contain the string MJP
25                                               not null-terminated. */
26     unsigned int mh_framesize;             /* Total size of the current
27                                               frame in bytes (~45kb on WVC200) */
28     unsigned short mh_framewidth;          /* Frame width in pixels */
29     unsigned short mh_frameheight;         /* Frame height in pixels */
30     unsigned int mh_frameoffset;           /* Offset of this chunk relative
31                                               to the beginning of frame. */
32     unsigned short mh_chunksize;           /* The size of the chunk data
33                                               following this header. */
34     char mh_reserved[30];                  /* Unknown data, seems to be
35                                               constant between all headers */
36 } mjpg_header;
37 
38 
39 void netcam_disconnect(netcam_context_ptr netcam);
40 int netcam_connect(netcam_context_ptr netcam, int err_flag);
41 int netcam_read_first_header(netcam_context_ptr netcam);
42 int netcam_setup_html(netcam_context_ptr netcam, struct url_t *url);
43 int netcam_setup_mjpg(netcam_context_ptr netcam, struct url_t *url);
44 int netcam_setup_file(netcam_context_ptr netcam, struct url_t *url);
45 int netcam_read_next_header(netcam_context_ptr netcam);
46 
47 #endif // _INCLUDE_NETCAM_HTTP_H
48