-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcam2.c
More file actions
107 lines (84 loc) · 2.27 KB
/
cam2.c
File metadata and controls
107 lines (84 loc) · 2.27 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
#include "stream-acq.h"
int cam2(s8* ipaddr, u32 time)
{
s32 sfd, sfd_rtp, sfd_rtcp;
s32 status;
s16 port_rtp, port_rtcp;
FILE* fptr;
rtspOpts ropts;
fptr = fopen("/home/root/camera2/cam2.264","w");
if(NULL == fptr) {
perror("Error opening File");
exit(-1);
}
// Init Socet
// Init File open
// IP address settings
status = StreamAcqInit2(&sfd, ipaddr);
status = RecvStreamInit2(&sfd_rtp, &sfd_rtcp, ipaddr, &port_rtp, &port_rtcp);
if(SUCCESS != status) {
perror("Unable to initialize stream Acquisition Module");
exit(-1);
}
status = SetRTSPOpts2(&ropts);
if(SUCCESS != status) {
perror("Unable set RTSP Options");
exit(-1);
}
if(ropts.optionsOpt) {
status = ReqRTSPOpts2(&sfd, ipaddr, NULL);
if(SUCCESS != status) {
perror("Unable to send OPTIONS Req");
exit(-1);
}
}
if(ropts.describeOpt) {
status = ReqRTSPDscrb2(&sfd, ipaddr, NULL);
if(SUCCESS != status) {
perror("Unable to send DESCRIBE Req");
exit(-1);
}
}
{
char sess_num[9] = "01234567";
if(ropts.setupOpt) {
status = ReqRTSPSetup2(&sfd, ipaddr, sess_num, port_rtp, port_rtcp);
if(SUCCESS != status) {
perror("Unable to send SETUP Req");
exit(-1);
}
}
if(ropts.playOpt) {
status = ReqRTSPPlay2(&sfd, ipaddr, sess_num);
if(SUCCESS != status) {
perror("Unable to send PLAY Req");
exit(-1);
}
}
//Get Options that are available
// status = InitFile(fptr);
printf("**Camera 2 Configured**\n");
{
s32 ind;
// for(ind = 0; ind < 500; ind++)
status = GetTimedStream2(&sfd_rtp, fptr, time);
}
if(ropts.teardownOpt) {
status = ReqRTSPTeardown2(&sfd, ipaddr, sess_num);
if(SUCCESS != status) {
perror("Unable to send TEARDOWN Req");
}
}
}
fclose(fptr);
close(sfd);
return 0;
}