#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);
}
fprintf(stderr, "------------------------------------------------------------------\n");
fprintf(stderr, "Usage: oss-stream" \
" [-h | --help ]........: display this help\n" \
- " [-d | --device ]......: video device to open (your camera)\n" \
+ " [-d | --device ]......: audio device to open (your camera)\n" \
" [-p | --port ]........: TCP-port for the server\n" \
" [-v | --version ].....: display version information\n" \
" [-b | --background]...: fork to the background, daemon mode\n");
/* allocate audio datastructure */
- /* open video device and prepare data structure */
- source_dev = open(dev,O_RDONLY);
- if (source_dev < 0) {
+ /* open audio device and prepare data structure */
+ 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);
}