-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcam1.c
More file actions
108 lines (85 loc) · 2.31 KB
/
cam1.c
File metadata and controls
108 lines (85 loc) · 2.31 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
108
#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 cam1(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/camera1/cam1.264","w");
if(NULL == fptr) {
perror("Error opening File");
exit(-1);
}
// Init Socet
// Init File open
// IP address settings
status = StreamAcqInit1(&sfd, ipaddr);
status = RecvStreamInit1(&sfd_rtp, &sfd_rtcp, ipaddr, &port_rtp, &port_rtcp);
if(SUCCESS != status) {
perror("Unable to initialize stream Acquisition Module");
exit(-1);
}
status = SetRTSPOpts1(&ropts);
if(SUCCESS != status) {
perror("Unable set RTSP Options");
exit(-1);
}
if(ropts.optionsOpt) {
status = ReqRTSPOpts1(&sfd, ipaddr, NULL);
if(SUCCESS != status) {
perror("Unable to send OPTIONS Req");
exit(-1);
}
}
if(ropts.describeOpt) {
status = ReqRTSPDscrb1(&sfd, ipaddr, NULL);
if(SUCCESS != status) {
perror("Unable to send DESCRIBE Req");
exit(-1);
}
}
{
char sess_num[9] = "01234567";
if(ropts.setupOpt) {
status = ReqRTSPSetup1(&sfd, ipaddr, sess_num, port_rtp, port_rtcp);
if(SUCCESS != status) {
perror("Unable to send SETUP Req");
exit(-1);
}
}
if(ropts.playOpt) {
status = ReqRTSPPlay1(&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 1 Configured**\n");
{
s32 ind;
// for(ind = 0; ind < 50; ind++)
// status = GetStream1(&sfd_rtp, fptr);
status = GetTimedStream1(&sfd_rtp, fptr, time);
}
if(ropts.teardownOpt) {
status = ReqRTSPTeardown1(&sfd, ipaddr, sess_num);
if(SUCCESS != status) {
perror("Unable to send TEARDOWN Req");
}
}
}
fclose(fptr);
close(sfd);
return 0;
}