#include <fcntl.h>
#define SOURCE_VERSION "0.0"
-#define BOUNDARY "arflebarfle"
typedef enum { SNAPSHOT, STREAM } answer_t;
int stop=0, sd;
int force_delay=0;
#define BUF_SIZE 4096
-int source_dev;
+FILE *source_dev;
/* signal fresh frames */
pthread_mutex_t db = PTHREAD_MUTEX_INITIALIZER;
while( !stop ) {
/* grab a frame */
- if( read(source_dev,rbuffer,BUF_SIZE) < 0 ) {
+ if( fread(rbuffer,1,BUF_SIZE,source_dev) < 0 ) {
fprintf(stderr, "Error grabbing\n");
exit(1);
}
/* allocate audio datastructure */
/* open video device and prepare data structure */
- source_dev = open(dev,O_RDONLY);
- if (source_dev < 0) {
+ if (strcmp(dev,"stdin")==0) {
+ source_dev = stdin;
+ } else {
+ source_dev = fopen(dev,"r");
+ }
+ if (source_dev == NULL) {
fprintf(stderr, "error opening source device\n");
exit(1);
}