bool show_property_pages(const wchar_t* camera, int index)
{
if (camera == NULL || camera[0] == 0)
{
XLOG_ERROR("invalid parameters");
return false;
}
AVInputFormat* ifmt = av_find_input_format("dshow");
if (ifmt == NULL)
{
XLOG_ERROR("av_find_input_format(\"dshow\") == null");
return false;
}
AVFormatContext* pFormatCtx = avformat_alloc_context();
if (pFormatCtx == NULL)
{
XLOG_ERROR("avformat_alloc_context == null");
return false;
}
std::string strUrlUtf8;
std::wstring wstrUrl = L"video=";
wstrUrl += camera;
utils::UTF16toUTF8(wstrUrl.c_str(), strUrlUtf8);
AVDictionary* opts = NULL;
av_dict_set_int(&opts, "show_video_device_dialog", true, 0);
if (index > 0)
av_dict_set_int(&opts, "video_device_number", index, 0);
int ffErr = avformat_open_input(&pFormatCtx, strUrlUtf8.c_str(), ifmt, &opts);
av_dict_free(&opts);
avformat_close_input(&pFormatCtx);
XLOG_TRACE("avformat_open_input == %d", ffErr);
return true;
}
};//cap