-
Notifications
You must be signed in to change notification settings - Fork 2
/
grapsctl.c
59 lines (50 loc) · 1.29 KB
/
grapsctl.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
/* grapsctl.c
*
* Copyright (c)2005 Sunil Mohan Ranta <smr [at] smr.co.in>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "graps.h"
int main(){
int shmid;
key_t key;
char *shm;//, *s;
/* initialize shared memory */
key = SHMKEY;
if( (shmid = shmget(key, SHMSZ, 0666)) < 0 ){
perror("shmget");
printf("Probably you didnt run opengl application first using run.sh\n");
return 0;
}
if( (shm = shmat(shmid, NULL, 0)) == (char *) -1 ){
perror("shmat"); exit(1);
}
grap = (struct grapsStruct *)shm;
grap->data2 = (unsigned char *)shm + sizeof( struct grapsStruct );
/* mesg */
graps_mesg();
/* open videopipe if video mode */
if( grap->rawvideo_stream ){
grap->fp = fopen( "/tmp/grapsvideopipe", "w" );
if( !grap->fp ){
printf("Error : opening videopipe");
return 0;
}
}
// capture
printf("capture started. ctrl-c to end\n" );
while( 1 ){
while( !grap->frame_ready )
usleep( 10 );
graps_write( grap->data2 );
grap->frame_ready = 0;
}
/* close videopipe if video mode */
if( grap->rawvideo_stream ){
fclose( grap->fp );
}
return 0;
}