Files
hisi_SS524V100_SDK/mpp/sample/rtsp_switch/rtsp_switch.c
T

177 lines
3.9 KiB
C
Executable File

#include <linux/input.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <arpa/inet.h>
#include <netdb.h>
int switch_video;
unsigned char key_value;
int *switch_memory_open(void) {
char buf[128];
int fd;
sprintf(buf, "/video_switch");
fd = shm_open(buf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
if(fd < 0) { perror("shm_open"); exit(1); }
if (ftruncate(fd, 4096) == -1) { perror("ftruncate"); exit(1); }
int *retval = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
return retval;
}
int main(int argc, char **argv)
{
int ret;
int *switch_mode;
int switch_video=0;
int switch_video_pre=0;
unsigned char buf[1024];
unsigned char buf_kill_rtsp[1024];
switch_mode = switch_memory_open();
switch_video = switch_mode[0];
switch_video_pre = switch_video;
//sprintf(buf_kill_rtsp,"./kill_rtsp.sh");
sprintf(buf,"./start_rtsp.sh %d",1);
system(buf);
//else{
// sprintf(buf,"./start_rtsp.sh %d",switch_video+5);
// system(buf);
//}
while(1)
{
switch_video = switch_mode[0];
if(switch_mode[2] == 0x55){
printf("+++++++++++++++++++++++++1 time out\n");
sprintf(buf_kill_rtsp,"./kill_rtsp.sh %d",6);
system(buf_kill_rtsp);
sprintf(buf,"./start_rtsp.sh %d",6);
system(buf);
}
if(switch_mode[3] == 0x55){
printf("+++++++++++++++++++++++++2 time out\n");
sprintf(buf_kill_rtsp,"./kill_rtsp.sh %d",7);
system(buf_kill_rtsp);
sprintf(buf,"./start_rtsp.sh %d",7);
system(buf);
}
if(switch_mode[4] == 0x55){
printf("+++++++++++++++++++++++++3 time out\n");
sprintf(buf_kill_rtsp,"./kill_rtsp.sh %d",8);
system(buf_kill_rtsp);
sprintf(buf,"./start_rtsp.sh %d",8);
system(buf);
//sprintf(buf,"./start_rtsp.sh %d",8);
//system(buf);
}
# if 1
if(switch_mode[5] == 0x55){
printf("+++++++++++++++++++++++++4 time out\n");
sprintf(buf_kill_rtsp,"./kill_rtsp.sh %d",9);
system(buf_kill_rtsp);
sprintf(buf,"./start_rtsp.sh %d",9);
system(buf);
}
#endif
#if 0
//6lu
if(switch_mode[6] == 0x55){
printf("+++++++++++++++++++++++++5 time out\n");
sprintf(buf_kill_rtsp,"./kill_rtsp.sh %d",10);
system(buf_kill_rtsp);
sprintf(buf,"./start_rtsp.sh %d",10);
system(buf);
}
#endif
#if 0
if(switch_mode[7] == 0x55){
printf("+++++++++++++++++++++++++6 time out\n");
sprintf(buf_kill_rtsp,"./kill_rtsp.sh %d",11);
system(buf_kill_rtsp);
sprintf(buf,"./start_rtsp.sh %d",11);
system(buf);
}
#endif
//if((switch_mode[2] == 0x55) || (switch_mode[3] == 0x55) || (switch_mode[4] == 0x55)|| (switch_mode[5] == 0x55) || (switch_mode[6] == 0x55) || (switch_mode[7] == 0x55 )){
// usleep(7000000);
// usleep(6000000);
usleep(6000000);
}
}