mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-04-05 06:04:50 +00:00
capabilities: Move capture printing to host.cpp
This commit is contained in:
50
src/host.cpp
50
src/host.cpp
@@ -392,13 +392,27 @@ struct init_data *common_preinit(int argc, char *argv[])
|
||||
}
|
||||
|
||||
static void print_device(std::string_view purpose, std::string_view mod, const device_info& device){
|
||||
cout << "[capability][device] {"
|
||||
"\"purpose\":" << std::quoted(purpose) << ", "
|
||||
"\"module\":" << std::quoted(mod) << ", "
|
||||
"\"device\":" << std::quoted(device.dev) << ", "
|
||||
"\"name\":" << std::quoted(device.name) << ", "
|
||||
"\"extra\": {" << device.extra << "}, "
|
||||
"\"repeatable\":\"" << device.repeatable << "\"}\n";
|
||||
cout << "[capability][device] {"
|
||||
"\"purpose\":" << std::quoted(purpose) << ", "
|
||||
"\"module\":" << std::quoted(mod) << ", "
|
||||
"\"device\":" << std::quoted(device.dev) << ", "
|
||||
"\"name\":" << std::quoted(device.name) << ", "
|
||||
"\"extra\": {" << device.extra << "}, "
|
||||
"\"repeatable\":\"" << device.repeatable << "\", "
|
||||
"\"modes\": [";
|
||||
|
||||
for(unsigned int j = 0; j < std::size(device.modes); j++) {
|
||||
if (device.modes[j].id[0] == '\0') { // last item
|
||||
break;
|
||||
}
|
||||
if (j > 0) {
|
||||
printf(", ");
|
||||
}
|
||||
std::cout << "{\"name\":" << std::quoted(device.modes[j].name) << ", "
|
||||
"\"opts\":" << device.modes[j].id << "}";
|
||||
}
|
||||
|
||||
std::cout << "]}\n";
|
||||
}
|
||||
|
||||
void print_capabilities()
|
||||
@@ -469,7 +483,27 @@ void print_capabilities()
|
||||
|
||||
// capturers
|
||||
cout << "[cap] Capturers:" << endl;
|
||||
print_available_capturers();
|
||||
const auto & vidcaps = get_libraries_for_class(LIBRARY_CLASS_VIDEO_CAPTURE, VIDEO_CAPTURE_ABI_VERSION);
|
||||
for (const auto& item : vidcaps) {
|
||||
auto vci = static_cast<const struct video_capture_info *>(item.second);
|
||||
|
||||
void (*deleter)(void *) = nullptr;
|
||||
struct vidcap_type *vt = vci->probe(true, &deleter);
|
||||
if (vt == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::cout << "[cap][capture] " << item.first << "\n";
|
||||
|
||||
for (int i = 0; i < vt->card_count; ++i) {
|
||||
print_device("video_cap", item.first, vt->cards[i]);
|
||||
}
|
||||
|
||||
if(!deleter)
|
||||
deleter = free;
|
||||
|
||||
deleter(vt->cards);
|
||||
deleter(vt);
|
||||
}
|
||||
|
||||
// displays
|
||||
cout << "[cap] Displays:" << endl;
|
||||
|
||||
@@ -87,49 +87,6 @@ void list_video_capture_devices(bool full)
|
||||
list_modules(LIBRARY_CLASS_VIDEO_CAPTURE, VIDEO_CAPTURE_ABI_VERSION, full);
|
||||
}
|
||||
|
||||
void print_available_capturers()
|
||||
{
|
||||
const auto & vidcaps = get_libraries_for_class(LIBRARY_CLASS_VIDEO_CAPTURE, VIDEO_CAPTURE_ABI_VERSION);
|
||||
for (auto && item : vidcaps) {
|
||||
auto vci = static_cast<const struct video_capture_info *>(item.second);
|
||||
|
||||
void (*deleter)(void *) = nullptr;
|
||||
struct vidcap_type *vt = vci->probe(true, &deleter);
|
||||
if (vt == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::cout << "[cap][capture] " << item.first << "\n";
|
||||
for (int i = 0; i < vt->card_count; ++i) {
|
||||
std::cout << "[capability][device] {"
|
||||
"\"purpose\":\"video_cap\", "
|
||||
"\"module\":" << std::quoted(vt->name) << ", "
|
||||
"\"device\":" << std::quoted(vt->cards[i].dev) << ", "
|
||||
"\"name\":" << std::quoted(vt->cards[i].name) << ", "
|
||||
"\"extra\": {" << vt->cards[i].extra << "}, "
|
||||
"\"modes\": [";
|
||||
for (unsigned int j = 0; j < sizeof vt->cards[i].modes
|
||||
/ sizeof vt->cards[i].modes[0]; j++) {
|
||||
if (vt->cards[i].modes[j].id[0] == '\0') { // last item
|
||||
break;
|
||||
}
|
||||
if (j > 0) {
|
||||
printf(", ");
|
||||
}
|
||||
std::cout << "{\"name\":" << std::quoted(vt->cards[i].modes[j].name) << ", "
|
||||
"\"opts\":" << vt->cards[i].modes[j].id << "}";
|
||||
}
|
||||
|
||||
std::cout << "]}\n";
|
||||
}
|
||||
if(!deleter)
|
||||
deleter = free;
|
||||
|
||||
deleter(vt->cards);
|
||||
deleter(vt);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Initializes video capture
|
||||
* @param[in] parent parent module
|
||||
* @param[in] param driver parameters
|
||||
|
||||
@@ -149,7 +149,6 @@ struct module;
|
||||
struct vidcap;
|
||||
|
||||
void list_video_capture_devices(bool);
|
||||
void print_available_capturers(void);
|
||||
int initialize_video_capture(struct module *parent,
|
||||
struct vidcap_params *params,
|
||||
struct vidcap **state);
|
||||
|
||||
Reference in New Issue
Block a user