Originally committed as revision 1499 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -28,8 +28,6 @@ | |||||
| #include <sys/mman.h> | #include <sys/mman.h> | ||||
| #include <sys/time.h> | #include <sys/time.h> | ||||
| const char *audio_device = "/dev/dsp"; | |||||
| #define AUDIO_BLOCK_SIZE 4096 | #define AUDIO_BLOCK_SIZE 4096 | ||||
| typedef struct { | typedef struct { | ||||
| @@ -43,13 +41,16 @@ typedef struct { | |||||
| int buffer_ptr; | int buffer_ptr; | ||||
| } AudioData; | } AudioData; | ||||
| static int audio_open(AudioData *s, int is_output) | |||||
| static int audio_open(AudioData *s, int is_output, const char *audio_device) | |||||
| { | { | ||||
| int audio_fd; | int audio_fd; | ||||
| int tmp, err; | int tmp, err; | ||||
| char *flip = getenv("AUDIO_FLIP_LEFT"); | char *flip = getenv("AUDIO_FLIP_LEFT"); | ||||
| /* open linux audio device */ | /* open linux audio device */ | ||||
| if (!audio_device) | |||||
| audio_device = "/dev/dsp"; | |||||
| if (is_output) | if (is_output) | ||||
| audio_fd = open(audio_device, O_WRONLY); | audio_fd = open(audio_device, O_WRONLY); | ||||
| else | else | ||||
| @@ -155,7 +156,7 @@ static int audio_write_header(AVFormatContext *s1) | |||||
| st = s1->streams[0]; | st = s1->streams[0]; | ||||
| s->sample_rate = st->codec.sample_rate; | s->sample_rate = st->codec.sample_rate; | ||||
| s->channels = st->codec.channels; | s->channels = st->codec.channels; | ||||
| ret = audio_open(s, 1); | |||||
| ret = audio_open(s, 1, NULL); | |||||
| if (ret < 0) { | if (ret < 0) { | ||||
| return -EIO; | return -EIO; | ||||
| } else { | } else { | ||||
| @@ -217,7 +218,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||||
| s->sample_rate = ap->sample_rate; | s->sample_rate = ap->sample_rate; | ||||
| s->channels = ap->channels; | s->channels = ap->channels; | ||||
| ret = audio_open(s, 0); | |||||
| ret = audio_open(s, 0, ap->device); | |||||
| if (ret < 0) { | if (ret < 0) { | ||||
| av_free(st); | av_free(st); | ||||
| return -EIO; | return -EIO; | ||||
| @@ -61,6 +61,8 @@ typedef struct AVFormatParameters { | |||||
| int height; | int height; | ||||
| enum PixelFormat pix_fmt; | enum PixelFormat pix_fmt; | ||||
| struct AVImageFormat *image_format; | struct AVImageFormat *image_format; | ||||
| int channel; /* used to select dv channel */ | |||||
| const char *device; /* video4linux, audio or DV device */ | |||||
| } AVFormatParameters; | } AVFormatParameters; | ||||
| #define AVFMT_NOFILE 0x0001 /* no file should be opened */ | #define AVFMT_NOFILE 0x0001 /* no file should be opened */ | ||||
| @@ -381,10 +383,6 @@ int audio_init(void); | |||||
| /* DV1394 */ | /* DV1394 */ | ||||
| int dv1394_init(void); | int dv1394_init(void); | ||||
| extern int dv1394_channel; | |||||
| extern const char *video_device; | |||||
| extern const char *audio_device; | |||||
| #ifdef HAVE_AV_CONFIG_H | #ifdef HAVE_AV_CONFIG_H | ||||
| int strstart(const char *str, const char *val, const char **ptr); | int strstart(const char *str, const char *val, const char **ptr); | ||||
| @@ -34,9 +34,6 @@ extern "C" { | |||||
| /* enable performance checks */ | /* enable performance checks */ | ||||
| //#define PERF_CHECK | //#define PERF_CHECK | ||||
| //const char *audio_device = "/dev/dsp"; | |||||
| const char *audio_device = "beosaudio:"; | |||||
| /* Pipes are 4k in BeOS IIRC */ | /* Pipes are 4k in BeOS IIRC */ | ||||
| #define AUDIO_BLOCK_SIZE 4096 | #define AUDIO_BLOCK_SIZE 4096 | ||||
| //#define AUDIO_BLOCK_SIZE 2048 | //#define AUDIO_BLOCK_SIZE 2048 | ||||
| @@ -76,6 +76,7 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap | |||||
| { | { | ||||
| struct dv1394_data *dv = context->priv_data; | struct dv1394_data *dv = context->priv_data; | ||||
| AVStream *st; | AVStream *st; | ||||
| const char *video_device; | |||||
| st = av_new_stream(context, 0); | st = av_new_stream(context, 0); | ||||
| if (!st) | if (!st) | ||||
| @@ -83,14 +84,16 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap | |||||
| dv->width = DV1394_WIDTH; | dv->width = DV1394_WIDTH; | ||||
| dv->height = DV1394_HEIGHT; | dv->height = DV1394_HEIGHT; | ||||
| dv->channel = dv1394_channel; | |||||
| dv->channel = ap->channel; | |||||
| dv->frame_rate = 30; | dv->frame_rate = 30; | ||||
| dv->frame_size = DV1394_NTSC_FRAME_SIZE; | dv->frame_size = DV1394_NTSC_FRAME_SIZE; | ||||
| /* Open and initialize DV1394 device */ | /* Open and initialize DV1394 device */ | ||||
| video_device = ap->device; | |||||
| if (!video_device) | |||||
| video_device = "/dev/dv1394/0"; | |||||
| dv->fd = open(video_device, O_RDONLY); | dv->fd = open(video_device, O_RDONLY); | ||||
| if (dv->fd < 0) { | if (dv->fd < 0) { | ||||
| perror("Failed to open DV interface"); | perror("Failed to open DV interface"); | ||||
| @@ -62,6 +62,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||||
| int ret, frame_rate; | int ret, frame_rate; | ||||
| int desired_palette; | int desired_palette; | ||||
| struct video_audio audio; | struct video_audio audio; | ||||
| const char *video_device; | |||||
| if (!ap || ap->width <= 0 || ap->height <= 0 || ap->frame_rate <= 0) | if (!ap || ap->width <= 0 || ap->height <= 0 || ap->frame_rate <= 0) | ||||
| return -1; | return -1; | ||||
| @@ -78,6 +79,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||||
| s->height = height; | s->height = height; | ||||
| s->frame_rate = frame_rate; | s->frame_rate = frame_rate; | ||||
| video_device = ap->device; | |||||
| if (!video_device) | |||||
| video_device = "/dev/video"; | |||||
| video_fd = open(video_device, O_RDWR); | video_fd = open(video_device, O_RDWR); | ||||
| if (video_fd < 0) { | if (video_fd < 0) { | ||||
| perror(video_device); | perror(video_device); | ||||
| @@ -41,8 +41,6 @@ AVInputFormat *first_iformat; | |||||
| AVOutputFormat *first_oformat; | AVOutputFormat *first_oformat; | ||||
| AVImageFormat *first_image_format; | AVImageFormat *first_image_format; | ||||
| const char *video_device = "none"; | |||||
| void av_register_input_format(AVInputFormat *format) | void av_register_input_format(AVInputFormat *format) | ||||
| { | { | ||||
| AVInputFormat **p; | AVInputFormat **p; | ||||