-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
executable file
·84 lines (71 loc) · 1.87 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <sys/select.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <pthread.h>
#include "rtspservice.h"
#include "rtputils.h"
#include "ringfifo.h"
#include "sample_comm.h"
#include "rtmpStream.h"
extern int g_s32Quit ;
/**************************************************************************************************
**
**
**
**************************************************************************************************/
extern void *SAMPLE_VENC_1080P_CLASSIC(void *p);
RTMP *rtmp = NULL;
RTMPMetadata MetaData;
int main(void)
{
int s32MainFd,temp;
struct timespec ts = { 2, 0 };
pthread_t id;
ringmalloc(256*1024);
printf("RTSP server START\n");
PrefsInit();
printf("listen for client connecting...\n");
signal(SIGINT, IntHandl);
s32MainFd = tcp_listen(SERVER_RTSP_PORT_DEFAULT);
if (ScheduleInit() == ERR_FATAL)
{
fprintf(stderr,"Fatal: Can't start scheduler %s, %i \nServer is aborting.\n", __FILE__, __LINE__);
return 0;
}
RTP_port_pool_init(RTP_DEFAULT_PORT);
rtmp = AllocRtmp();
if(rtmp==NULL)
{
printf("rtmp alloc failed\n");
return -1;
}
printf("Connected\n");
ConnectToServer(rtmp, "rtmp://moscow.restream.io/live/some_srteam_key");
memset(&MetaData, 0, sizeof(RTMPMetadata));
printf("SendH264File\n");
//SendH264File(rtmp, &MetaData, "avc.h264");
//printf("SendH264File11\n");
pthread_create(&id,NULL,SAMPLE_VENC_1080P_CLASSIC,NULL);
while (!g_s32Quit)
{
nanosleep(&ts, NULL);
EventLoop(s32MainFd);
}
sleep(2);
ringfree();
printf("The Server quit!\n");
return 0;
}