avdevice/decklink_common: Move DECKLINK_* string functions into header

This allows other decklink source access to these cross-platform
convenience functions.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Jon Morley 2018-05-25 11:41:06 -07:00 committed by Marton Balint
parent ba8a1d1618
commit fb480a1f1e
2 changed files with 30 additions and 30 deletions

View File

@ -77,36 +77,6 @@ static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx)
return iter; return iter;
} }
#ifdef _WIN32
static char *dup_wchar_to_utf8(wchar_t *w)
{
char *s = NULL;
int l = WideCharToMultiByte(CP_UTF8, 0, w, -1, 0, 0, 0, 0);
s = (char *) av_malloc(l);
if (s)
WideCharToMultiByte(CP_UTF8, 0, w, -1, s, l, 0, 0);
return s;
}
#define DECKLINK_STR OLECHAR *
#define DECKLINK_STRDUP dup_wchar_to_utf8
#define DECKLINK_FREE(s) SysFreeString(s)
#elif defined(__APPLE__)
static char *dup_cfstring_to_utf8(CFStringRef w)
{
char s[256];
CFStringGetCString(w, s, 255, kCFStringEncodingUTF8);
return av_strdup(s);
}
#define DECKLINK_STR const __CFString *
#define DECKLINK_STRDUP dup_cfstring_to_utf8
#define DECKLINK_FREE(s) CFRelease(s)
#else
#define DECKLINK_STR const char *
#define DECKLINK_STRDUP av_strdup
/* free() is needed for a string returned by the DeckLink SDL. */
#define DECKLINK_FREE(s) free((void *) s)
#endif
HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName) HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName)
{ {
DECKLINK_STR tmpDisplayName; DECKLINK_STR tmpDisplayName;

View File

@ -34,6 +34,36 @@
#define DECKLINK_BOOL bool #define DECKLINK_BOOL bool
#endif #endif
#ifdef _WIN32
static char *dup_wchar_to_utf8(wchar_t *w)
{
char *s = NULL;
int l = WideCharToMultiByte(CP_UTF8, 0, w, -1, 0, 0, 0, 0);
s = (char *) av_malloc(l);
if (s)
WideCharToMultiByte(CP_UTF8, 0, w, -1, s, l, 0, 0);
return s;
}
#define DECKLINK_STR OLECHAR *
#define DECKLINK_STRDUP dup_wchar_to_utf8
#define DECKLINK_FREE(s) SysFreeString(s)
#elif defined(__APPLE__)
static char *dup_cfstring_to_utf8(CFStringRef w)
{
char s[256];
CFStringGetCString(w, s, 255, kCFStringEncodingUTF8);
return av_strdup(s);
}
#define DECKLINK_STR const __CFString *
#define DECKLINK_STRDUP dup_cfstring_to_utf8
#define DECKLINK_FREE(s) CFRelease(s)
#else
#define DECKLINK_STR const char *
#define DECKLINK_STRDUP av_strdup
/* free() is needed for a string returned by the DeckLink SDL. */
#define DECKLINK_FREE(s) free((void *) s)
#endif
class decklink_output_callback; class decklink_output_callback;
class decklink_input_callback; class decklink_input_callback;