Files
hisi_SS524V100_SDK/mpp/sample/vdec_udp_h265/test_shm.c
T

44 lines
1.0 KiB
C

#include <stdio.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 <fcntl.h>
#include <pthread.h>
#include <sched.h>
#include <sys/syscall.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <stdint.h>
#include <signal.h>
#include <linux/input.h>
#include <math.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/time.h>
#include <string.h>
int *switch_video;
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;
}
void main()
{
switch_video = switch_memory_open();
}