Exemple #1
0
int send_video_directory(char* cam_name, char* dir_name, char* remote_host, char* remote_port) {
    syslog (LOG_INFO, "send_video_directory called in vidlib.c");

    // Open ports to the video server
    //int fd;
    fd = initializeModule();

    openConnection(fd,remote_host,remote_port);

    // Write camera name to socket, plus one to include the null byte
    //TODO puts + null byte to avoid strlen call
    int n = write(fd, cam_name, strlen(cam_name) + 1);
    if (n < 0) {
      //error("ERROR writing to socket");
      syslog(LOG_ERR, "ERROR writing to socket");
      goto ERROR;
    }

    chdir(dir_name);

    DIR *dir;
    struct dirent *ent;
    if ((dir = opendir(".")) != NULL) {
        /* print all the files and directories within directory */
        while ((ent = readdir(dir)) != NULL) {
            if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) {
                continue;
            }
            //printf ("%s, ", ent->d_name);
            if (send_video(fd, ent->d_name) == -1) {
                syslog(LOG_ERR, "error in send_video in vidlib");
                break;
            }
        }
        closedir (dir);
    } else {
        /* could not open directory */
        //perror ("");
        syslog(LOG_ERR, "could not open video directory");
    }

ERROR:
    closeConnection(fd);
    serialClose(fd);
    return 0;

}
void video_encoder_queue::Impl::send_video(const video_data_timed * _VideoDataTimed)
{
    if (_VideoDataTimed)
        send_video(_VideoDataTimed->get_media_data().get());
}
Exemple #3
0
int handle_web(int http_fd)
{
	char buffer[4096];
	int len = 0;

    bzero(buffer,4096);
    len = read(http_fd, buffer, 4096);

    if (strncmp(buffer,"\n\n",len) < 0)
    	goto end_close;

    if (strncmp(buffer,"GET ",4))
		goto end_close;

    /* Look for known documents */
    if (!strncmp(buffer,"GET /index.html",15)){
    	send_index(http_fd);
    	goto end_close;
    }

    if (!strncmp(buffer,"GET /stat.html",14)){
    	send_status(http_fd);
    	goto end_close;
    }

    if (!strncmp(buffer,"GET /video.html",15)){
    	send_video(http_fd);
    	goto end_leave;
    }

    if (!strncmp(buffer,"GET /command.html",17)){
        send_command(http_fd);
        goto end_close;
    }

    if (!strncmp(buffer,"GET /log.html",13)){
        send_log(http_fd);
        goto end_leave;
    }

    if (!strncmp(buffer,"GET /cmd.html?",14)){
    	printf("WEB-CMD\n");
        send_cmd(http_fd, buffer+14);
        goto end_close;
    }

    if (!strncmp(buffer,"GET /emer.html",14)){
        send_emergency(http_fd);
        goto end_close;
    }

    /* Send 404 error */
    send_404(http_fd);


end_close:
	close(http_fd);

end_leave:
	return 0;
}