我目前正在尝试制作一个应用程序,将一个ndi视频源通道,一个音频源通道,并最终将其组合成一个作为自己的流,但截至目前,我的程序甚至没有被NDI分析工具识别,我不知道该怎么办。我希望至少现在是我的程序注册运行源,并允许我选择一个sour视频和音频之一。
#include <iostream>
#include "Processing.NDI.Lib.h"
int main() {
// Initialize the NDI library
NDIlib_initialize();
// Find all available sources on the local network
const NDIlib_find_create_t NDI_find_create_desc = { true, nullptr };
NDIlib_find_instance_t pNDI_find = NDIlib_find_create_v2(&NDI_find_create_desc);
if (!pNDI_find) {
std::cerr << "Failed to create NDI find instance\n";
return -1;
}
std::cout << "Searching for NDI sources...\n";
uint32_t num_sources = 0;
const NDIlib_source_t* pSources = nullptr;
NDIlib_find_wait_for_sources(pNDI_find, 1000 /* timeout_ms */);
pSources = NDIlib_find_get_current_sources(pNDI_find, &num_sources);
if (num_sources == 0) {
std::cout << "No NDI sources found\n";
return 0;
}
// Print out the available sources`your text`
std::cout << "Available NDI sources:\n";
for (uint32_t i = 0; i < num_sources; ++i) {
const NDIlib_source_t* pSource = &pSources[i];
if (pSource->p_ndi_name && pSource->p_url_address && pSource->fourcc_type == NDIlib_fourCC_type_video) { //unable to find version 5.5 names
std::cout << i << ": " << pSource->p_ndi_name << " (" << pSource->p_url_address << ")\n";
}
}
// Prompt the user to select an audio and video source
uint32_t video_source_idx = 0;
uint32_t audio_source_idx = 0;
std::cout << "Enter the index of the video source you want to use: ";
std::cin >> video_source_idx;
std::cout << "Enter the index of the audio source you want to use: ";
std::cin >> audio_source_idx;
// Create an NDI source that combines the selected audio and video sources
const NDIlib_send_create_t NDI_send_create_desc = {
"Combined Source", // Name of the NDI source
nullptr, // Groups (optional)
true, // Clock video (required for synchronization)
true // Clock audio (required for synchronization)
};
NDIlib_send_instance_t pNDI_send = NDIlib_send_create(&NDI_send_create_desc);
if (!pNDI_send) {
std::cerr << "Failed to create NDI send instance\n";
return -1;
}
// Connect to the selected video and audio sources
const NDIlib_routing_create_t NDI_routing_create_desc = {
nullptr, // Groups (optional)
1 // Number of inputs to create
};
NDIlib_routing_instance_t pNDI_routing = NDIlib_routing_create_v3(&NDI_routing_create_desc);
if (!pNDI_routing) {
std::cerr << "Failed to create NDI routing instance\n";
return -1;
}
const NDIlib_source_t* pVideoSource = &pSources[video_source_idx];
if (NDIlib_routing_change_v3(pNDI_routing, &pVideoSource->source_id, nullptr, NDIlib_routing_preference_best_quality) != NDIlib_frame_type_none) {
std::cout << "Connected\n";
return 0;
}
}
1条答案
按热度按时间gzszwxb41#
你不需要使用路由来做这件事。