You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
lavd/avfoundation: Introduce device alias 'none' to allow the user to record only audio or video.
Changes the selection of a default device to none instead of the system default device. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
committed by
Michael Niedermayer
parent
cde0ad5ea7
commit
2045334239
@@ -604,7 +604,10 @@ static int avf_read_header(AVFormatContext *s)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else if (ctx->video_filename &&
|
} else if (ctx->video_filename &&
|
||||||
strncmp(ctx->video_filename, "default", 7)) {
|
strncmp(ctx->video_filename, "none", 4)) {
|
||||||
|
if (!strncmp(ctx->video_filename, "default", 7)) {
|
||||||
|
video_device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||||
|
} else {
|
||||||
// looking for video inputs
|
// looking for video inputs
|
||||||
for (AVCaptureDevice *device in video_devices) {
|
for (AVCaptureDevice *device in video_devices) {
|
||||||
if (!strncmp(ctx->video_filename, [[device localizedName] UTF8String], strlen(ctx->video_filename))) {
|
if (!strncmp(ctx->video_filename, [[device localizedName] UTF8String], strlen(ctx->video_filename))) {
|
||||||
@@ -626,13 +629,12 @@ static int avf_read_header(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (!video_device) {
|
if (!video_device) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Video device not found\n");
|
av_log(ctx, AV_LOG_ERROR, "Video device not found\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
video_device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get audio device
|
// get audio device
|
||||||
@@ -646,7 +648,10 @@ static int avf_read_header(AVFormatContext *s)
|
|||||||
|
|
||||||
audio_device = [devices objectAtIndex:ctx->audio_device_index];
|
audio_device = [devices objectAtIndex:ctx->audio_device_index];
|
||||||
} else if (ctx->audio_filename &&
|
} else if (ctx->audio_filename &&
|
||||||
strncmp(ctx->audio_filename, "default", 7)) {
|
strncmp(ctx->audio_filename, "none", 4)) {
|
||||||
|
if (!strncmp(ctx->audio_filename, "default", 7)) {
|
||||||
|
audio_device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
|
||||||
|
} else {
|
||||||
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio];
|
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio];
|
||||||
|
|
||||||
for (AVCaptureDevice *device in devices) {
|
for (AVCaptureDevice *device in devices) {
|
||||||
@@ -655,13 +660,12 @@ static int avf_read_header(AVFormatContext *s)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!audio_device) {
|
if (!audio_device) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Audio device not found\n");
|
av_log(ctx, AV_LOG_ERROR, "Audio device not found\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
audio_device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video nor Audio capture device not found, looking for AVMediaTypeVideo/Audio
|
// Video nor Audio capture device not found, looking for AVMediaTypeVideo/Audio
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "libavutil/version.h"
|
#include "libavutil/version.h"
|
||||||
|
|
||||||
#define LIBAVDEVICE_VERSION_MAJOR 56
|
#define LIBAVDEVICE_VERSION_MAJOR 56
|
||||||
#define LIBAVDEVICE_VERSION_MINOR 2
|
#define LIBAVDEVICE_VERSION_MINOR 3
|
||||||
#define LIBAVDEVICE_VERSION_MICRO 100
|
#define LIBAVDEVICE_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
|
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
|
||||||
|
Reference in New Issue
Block a user