#include #include #include #include #include "config.h" #include "commander.h" #include "streaming.h" int main(int argc, char** argv) { char buf[256]; char rtmp_handle[41]; buf[255] = '\0'; gst_init(&argc, &argv); config_load_default_values(); if(config_load_from_file("camera-manager.conf")) { exit(-1); } if(config_check_values()) { config_free(); exit(-2); } if(commander_connect(config_get("CAM_COMMANDER_HOST"), config_get("CAM_COMMANDER_PORT"), config_get("SERIAL_NUMBER"), config_get("PRODUCT_KEY"), rtmp_handle)) { config_free(); exit(-3); } for(;;) { if(streaming_pop_error()) { commander_send("streaming_error"); commander_close(); config_free(); exit(4); } if(!commander_wait_activity()) { continue; } if(commander_receive(buf, 255) == -1) { exit(3); } if(!strcmp(buf, "enable")) { if(streaming_enable(config_get("RTMP_HOST"), config_get("RTMP_PORT"), config_get("RTMP_APP"), config_get("SERIAL_NUMBER"), rtmp_handle)) { commander_send("streaming_start_error"); commander_close(); config_free(); exit(4); } if(commander_send("enabled")) { streaming_close(); commander_close(); config_free(); exit(3); } } else if(!strcmp(buf, "disable")) { if(streaming_disable()) { commander_send("streaming_stop_error"); commander_close(); config_free(); exit(4); } if(commander_send("disabled")) { commander_close(); config_free(); exit(3); } } else if(!strcmp(buf, "disconnect")) { if(streaming_disable()) { commander_send("streaming_stop_error"); commander_close(); config_free(); exit(4); } if(commander_send("disconnected")) { commander_close(); config_free(); exit(3); } break; } } printf("[CameraManager] : bye !!\n"); commander_close(); config_free(); return 0; }