mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-20 17:40:12 +00:00
BMD: implement get_bmd_api_str_from_cstr abstraction
This commit is contained in:
@@ -97,6 +97,22 @@ char *get_cstr_from_bmd_api_str(BMD_STR bmd_string)
|
||||
return cstr;
|
||||
}
|
||||
|
||||
BMD_STR get_bmd_api_str_from_cstr(const char *cstr)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
return CFStringCreateWithCString(kCFAllocatorMalloc, cstr, kCFStringEncodingUTF8);
|
||||
#elif defined _WIN32
|
||||
mbstate_t mbstate{};
|
||||
const char *tmp = cstr;
|
||||
size_t required_size = mbsrtowcs(NULL, &tmp, 0, &mbstate) + 1;
|
||||
BMD_STR out = (wchar_t *) malloc(required_size * sizeof(wchar_t));
|
||||
mbsrtowcs(out, &tmp, required_size, &mbstate);
|
||||
return out;
|
||||
#else
|
||||
return strdup(cstr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void release_bmd_api_str(BMD_STR string)
|
||||
{
|
||||
#ifdef HAVE_MACOSX
|
||||
|
||||
@@ -91,6 +91,7 @@ static std::vector<std::pair<codec_t, BMDPixelFormat>> uv_to_bmd_codec_map = {
|
||||
#define BMD_STR const char *
|
||||
#endif
|
||||
char *get_cstr_from_bmd_api_str(BMD_STR string);
|
||||
BMD_STR get_bmd_api_str_from_cstr(const char *cstr);
|
||||
void release_bmd_api_str(BMD_STR string);
|
||||
|
||||
IDeckLinkIterator *create_decklink_iterator(bool verbose = true, bool coinit = true);
|
||||
|
||||
@@ -188,17 +188,9 @@ class DeckLinkTimecode : public IDeckLinkTimecode{
|
||||
char *out = (char *) malloc(14);
|
||||
assert(minutes <= 59 && seconds <= 59);
|
||||
sprintf(out, "%02" PRIu8 ":%02" PRIu8 ":%02" PRIu8 ":%02" PRIu8, hours, minutes, seconds, frames);
|
||||
#ifdef _WIN32
|
||||
mbstate_t mbstate{};
|
||||
const char *tmp = out;
|
||||
size_t required_size = mbsrtowcs(NULL, &tmp, 0, &mbstate) + 1;
|
||||
*timecode = (wchar_t *) malloc(required_size * sizeof(wchar_t));
|
||||
mbsrtowcs(*timecode, &tmp, required_size, &mbstate);
|
||||
*timecode = get_bmd_api_str_from_cstr(out);
|
||||
free(out);
|
||||
#else
|
||||
*timecode = out;
|
||||
#endif
|
||||
return S_OK;
|
||||
return *timecode ? S_OK : E_FAIL;
|
||||
}
|
||||
virtual BMDTimecodeFlags STDMETHODCALLTYPE GetFlags (void) { return bmdTimecodeFlagDefault; }
|
||||
virtual HRESULT STDMETHODCALLTYPE GetTimecodeUserBits (/* out */ BMDTimecodeUserBits *userBits) { if (!userBits) return E_POINTER; else return S_OK; }
|
||||
|
||||
Reference in New Issue
Block a user