mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 23:40:26 +00:00
Print audio capturers in capabilities
This commit is contained in:
@@ -44,13 +44,16 @@
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AUDIO_CAPTURE_ABI_VERSION 1
|
||||
#define AUDIO_CAPTURE_ABI_VERSION 2
|
||||
|
||||
struct audio_capture_info {
|
||||
void (*probe)(struct device_info **available_devices, int *count);
|
||||
void (*help)(const char *driver_name);
|
||||
void *(*init)(const char *cfg);
|
||||
struct audio_frame *(*read)(void *state);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @author Martin Pulec <pulec@cesnet.cz>
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2011-2015 CESNET, z. s. p. o.
|
||||
* Copyright (c) 2011-2016 CESNET, z. s. p. o.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -82,6 +82,14 @@ struct state_alsa_capture {
|
||||
bool non_interleaved;
|
||||
};
|
||||
|
||||
static void audio_cap_alsa_probe(struct device_info **available_devices, int *count)
|
||||
{
|
||||
*available_devices = malloc(sizeof(struct device_info));
|
||||
strcpy((*available_devices)[0].id, "alsa");
|
||||
strcpy((*available_devices)[0].name, "Default Linux audio input");
|
||||
*count = 1;
|
||||
}
|
||||
|
||||
static void audio_cap_alsa_help(const char *driver_name)
|
||||
{
|
||||
UNUSED(driver_name);
|
||||
@@ -389,6 +397,7 @@ static void audio_cap_alsa_done(void *state)
|
||||
}
|
||||
|
||||
static const struct audio_capture_info acap_alsa_info = {
|
||||
audio_cap_alsa_probe,
|
||||
audio_cap_alsa_help,
|
||||
audio_cap_alsa_init,
|
||||
audio_cap_alsa_read,
|
||||
|
||||
@@ -185,6 +185,17 @@ static OSStatus InputProc(void *inRefCon,
|
||||
return err;
|
||||
}
|
||||
|
||||
static void audio_cap_ca_probe(struct device_info **available_devices, int *count)
|
||||
{
|
||||
*available_devices = malloc(sizeof(struct device_info));
|
||||
strcpy((*available_devices)[0].id, "ca");
|
||||
strcpy((*available_devices)[0].name, "Default OS X audio input");
|
||||
*count = 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void audio_cap_ca_help(const char *driver_name)
|
||||
{
|
||||
UNUSED(driver_name);
|
||||
@@ -494,6 +505,7 @@ static void audio_cap_ca_done(void *state)
|
||||
}
|
||||
|
||||
static const struct audio_capture_info acap_coreaudio_info = {
|
||||
audio_cap_ca_probe,
|
||||
audio_cap_ca_help,
|
||||
audio_cap_ca_init,
|
||||
audio_cap_ca_read,
|
||||
|
||||
@@ -107,6 +107,14 @@ static int jack_process_callback(jack_nframes_t nframes, void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void audio_cap_jack_probe(struct device_info **available_devices, int *count)
|
||||
{
|
||||
*available_devices = malloc(sizeof(struct device_info));
|
||||
strcpy((*available_devices)[0].id, "jack");
|
||||
strcpy((*available_devices)[0].name, "JACK audio input");
|
||||
*count = 1;
|
||||
}
|
||||
|
||||
static void audio_cap_jack_help(const char *driver_name)
|
||||
{
|
||||
UNUSED(driver_name);
|
||||
@@ -277,6 +285,7 @@ static void audio_cap_jack_done(void *state)
|
||||
}
|
||||
|
||||
static const struct audio_capture_info acap_jack_info = {
|
||||
audio_cap_jack_probe,
|
||||
audio_cap_jack_help,
|
||||
audio_cap_jack_init,
|
||||
audio_cap_jack_read,
|
||||
|
||||
@@ -64,6 +64,12 @@ struct state_audio_capture_none {
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
static void audio_cap_none_probe(struct device_info **available_devices, int *count)
|
||||
{
|
||||
*available_devices = NULL;
|
||||
*count = 0;
|
||||
}
|
||||
|
||||
static void audio_cap_none_help(const char *driver_name)
|
||||
{
|
||||
UNUSED(driver_name);
|
||||
@@ -95,6 +101,7 @@ static void audio_cap_none_done(void *state)
|
||||
}
|
||||
|
||||
static const struct audio_capture_info acap_none_info = {
|
||||
audio_cap_none_probe,
|
||||
audio_cap_none_help,
|
||||
audio_cap_none_init,
|
||||
audio_cap_none_read,
|
||||
|
||||
@@ -133,6 +133,14 @@ static void print_device_info(PaDeviceIndex device)
|
||||
printf(" %s (output channels: %d; input channels: %d)", device_info->name, device_info->maxOutputChannels, device_info->maxInputChannels);
|
||||
}
|
||||
|
||||
static void audio_cap_portaudio_probe(struct device_info **available_devices, int *count)
|
||||
{
|
||||
*available_devices = malloc(sizeof(struct device_info));
|
||||
strcpy((*available_devices)[0].id, "portaudio");
|
||||
strcpy((*available_devices)[0].name, "Portaudio audio input");
|
||||
*count = 1;
|
||||
}
|
||||
|
||||
static void audio_cap_portaudio_help(const char *driver_name)
|
||||
{
|
||||
UNUSED(driver_name);
|
||||
@@ -364,6 +372,7 @@ static void audio_cap_portaudio_done(void *state)
|
||||
}
|
||||
|
||||
static const struct audio_capture_info acap_portaudio_info = {
|
||||
audio_cap_portaudio_probe,
|
||||
audio_cap_portaudio_help,
|
||||
audio_cap_portaudio_init,
|
||||
audio_cap_portaudio_read,
|
||||
|
||||
@@ -74,6 +74,30 @@ struct state_sdi_capture {
|
||||
|
||||
static void audio_cap_sdi_help(const char *driver_name);
|
||||
|
||||
static void audio_cap_sdi_probe_common(struct device_info **available_devices, int *count,
|
||||
const char *id, const char *name)
|
||||
{
|
||||
*available_devices = (struct device_info *) malloc(sizeof(struct device_info));
|
||||
strcpy((*available_devices)[0].id, id);
|
||||
strcpy((*available_devices)[0].name, name);
|
||||
*count = 1;
|
||||
}
|
||||
|
||||
static void audio_cap_sdi_probe_embedded(struct device_info **available_devices, int *count)
|
||||
{
|
||||
audio_cap_sdi_probe_common(available_devices, count, "embedded", "Embedded SDI/HDMI audio");
|
||||
}
|
||||
|
||||
static void audio_cap_sdi_probe_aesebu(struct device_info **available_devices, int *count)
|
||||
{
|
||||
audio_cap_sdi_probe_common(available_devices, count, "AESEBU", "Digital AES/EBU audio");
|
||||
}
|
||||
|
||||
static void audio_cap_sdi_probe_analog(struct device_info **available_devices, int *count)
|
||||
{
|
||||
audio_cap_sdi_probe_common(available_devices, count, "analog", "Analog audio through capture card");
|
||||
}
|
||||
|
||||
static void * audio_cap_sdi_init(const char *cfg)
|
||||
{
|
||||
if(cfg && strcmp(cfg, "help") == 0) {
|
||||
@@ -172,16 +196,32 @@ void sdi_capture_new_incoming_frame(void *state, struct audio_frame *frame)
|
||||
s->audio_frame_ready_cv.notify_one();
|
||||
}
|
||||
|
||||
|
||||
static const struct audio_capture_info acap_sdi_info = {
|
||||
static const struct audio_capture_info acap_sdi_info_embedded = {
|
||||
audio_cap_sdi_probe_embedded,
|
||||
audio_cap_sdi_help,
|
||||
audio_cap_sdi_init,
|
||||
audio_cap_sdi_read,
|
||||
audio_cap_sdi_done
|
||||
};
|
||||
|
||||
REGISTER_MODULE(embedded, &acap_sdi_info, LIBRARY_CLASS_AUDIO_CAPTURE, AUDIO_CAPTURE_ABI_VERSION);
|
||||
REGISTER_MODULE(AESEBU, &acap_sdi_info, LIBRARY_CLASS_AUDIO_CAPTURE, AUDIO_CAPTURE_ABI_VERSION);
|
||||
REGISTER_MODULE(analog, &acap_sdi_info, LIBRARY_CLASS_AUDIO_CAPTURE, AUDIO_CAPTURE_ABI_VERSION);
|
||||
static const struct audio_capture_info acap_sdi_info_aesebu = {
|
||||
audio_cap_sdi_probe_aesebu,
|
||||
audio_cap_sdi_help,
|
||||
audio_cap_sdi_init,
|
||||
audio_cap_sdi_read,
|
||||
audio_cap_sdi_done
|
||||
};
|
||||
|
||||
static const struct audio_capture_info acap_sdi_info_analog = {
|
||||
audio_cap_sdi_probe_analog,
|
||||
audio_cap_sdi_help,
|
||||
audio_cap_sdi_init,
|
||||
audio_cap_sdi_read,
|
||||
audio_cap_sdi_done
|
||||
};
|
||||
|
||||
REGISTER_MODULE(embedded, &acap_sdi_info_embedded, LIBRARY_CLASS_AUDIO_CAPTURE, AUDIO_CAPTURE_ABI_VERSION);
|
||||
REGISTER_MODULE(AESEBU, &acap_sdi_info_aesebu, LIBRARY_CLASS_AUDIO_CAPTURE, AUDIO_CAPTURE_ABI_VERSION);
|
||||
REGISTER_MODULE(analog, &acap_sdi_info_analog, LIBRARY_CLASS_AUDIO_CAPTURE, AUDIO_CAPTURE_ABI_VERSION);
|
||||
|
||||
/* vim: set expandtab: sw=8 */
|
||||
|
||||
@@ -87,6 +87,14 @@ struct state_audio_capture_testcard {
|
||||
unsigned int total_samples;
|
||||
};
|
||||
|
||||
static void audio_cap_testcard_probe(struct device_info **available_devices, int *count)
|
||||
{
|
||||
*available_devices = (struct device_info *) malloc(sizeof(struct device_info));
|
||||
strcpy((*available_devices)[0].id, "testcard");
|
||||
strcpy((*available_devices)[0].name, "Testing EBU signal");
|
||||
*count = 1;
|
||||
}
|
||||
|
||||
static void audio_cap_testcard_help(const char *driver_name)
|
||||
{
|
||||
UNUSED(driver_name);
|
||||
@@ -281,6 +289,7 @@ static void audio_cap_testcard_done(void *state)
|
||||
}
|
||||
|
||||
static const struct audio_capture_info acap_testcard_info = {
|
||||
audio_cap_testcard_probe,
|
||||
audio_cap_testcard_help,
|
||||
audio_cap_testcard_init,
|
||||
audio_cap_testcard_read,
|
||||
|
||||
15
src/host.cpp
15
src/host.cpp
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "host.h"
|
||||
|
||||
#include "audio/audio_capture.h"
|
||||
#include "lib_common.h"
|
||||
#include "messaging.h"
|
||||
#include "video_capture.h"
|
||||
@@ -104,5 +105,19 @@ void print_capabilities(struct module *root, bool use_vidcap)
|
||||
}
|
||||
free(devices);
|
||||
}
|
||||
|
||||
cout << "[cap] Audio capturers:" << endl;
|
||||
auto const & audio_capabilities =
|
||||
get_libraries_for_class(LIBRARY_CLASS_AUDIO_CAPTURE, AUDIO_CAPTURE_ABI_VERSION);
|
||||
for (auto const & it : audio_capabilities) {
|
||||
auto aci = static_cast<const struct audio_capture_info *>(it.second);
|
||||
int count;
|
||||
struct device_info *devices;
|
||||
aci->probe(&devices, &count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
cout << "[cap] (" << devices[i].id << ";" << devices[i].name << ")\n";
|
||||
}
|
||||
free(devices);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -239,6 +239,11 @@ enum tx_media_type {
|
||||
TX_MEDIA_VIDEO
|
||||
};
|
||||
|
||||
struct device_info {
|
||||
char id[1024];
|
||||
char name[1024];
|
||||
};
|
||||
|
||||
struct vidcap_params;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user