Add Mac and iOS implementation of guid generation (#2784)

This commit is contained in:
sauwming 2021-08-09 11:12:04 +08:00 committed by GitHub
parent 5c1fa437cc
commit 0ceb274989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 1 deletions

View File

@ -6015,6 +6015,9 @@ case $target in
*android*)
ac_os_objs="$ac_os_objs guid_android.o"
;;
*darwin*)
ac_os_objs="$ac_os_objs guid_darwin.o"
;;
*)
if test "$ac_has_uuid_lib" = "1" -a "$ac_has_uuid_h" = "1"; then
ac_os_objs="$ac_os_objs guid_uuid.o"
@ -9380,7 +9383,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
$as_echo "Checking if libwebrtc-aec3 is enabled...no" >&6; }
fi
else
ac_no_webrtc_aec3=1
$as_echo "#define PJMEDIA_HAS_LIBWEBRTC_AEC3 0" >>confdefs.h

View File

@ -517,6 +517,9 @@ case $target in
*android*)
ac_os_objs="$ac_os_objs guid_android.o"
;;
*darwin*)
ac_os_objs="$ac_os_objs guid_darwin.o"
;;
*)
if test "$ac_has_uuid_lib" = "1" -a "$ac_has_uuid_h" = "1"; then
ac_os_objs="$ac_os_objs guid_uuid.o"

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2021-2021 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <pj/guid.h>
#include <pj/assert.h>
#include <pj/os.h>
#include <pj/string.h>
#include <CoreFoundation/CoreFoundation.h>
PJ_DEF_DATA(const unsigned) PJ_GUID_STRING_LENGTH=36;
PJ_DEF(unsigned) pj_GUID_STRING_LENGTH()
{
return PJ_GUID_STRING_LENGTH;
}
PJ_DEF(pj_str_t*) pj_generate_unique_string(pj_str_t *str)
{
CFUUIDRef uuid_obj;
CFStringRef uuid_str;
pj_str_t sguid;
PJ_ASSERT_RETURN(str->ptr != NULL, NULL);
PJ_CHECK_STACK();
/* Create universally unique identifier (object). */
uuid_obj = CFUUIDCreate(kCFAllocatorDefault);
/* Get the string representation of CFUUID object. */
uuid_str = CFUUIDCreateString(kCFAllocatorDefault, uuid_obj);
CFRelease(uuid_obj);
sguid.ptr = (char*)CFStringGetCStringPtr(uuid_str, kCFStringEncodingUTF8);
pj_assert(sguid.ptr);
sguid.slen = pj_ansi_strlen(sguid.ptr);
pj_strncpy(str, &sguid, PJ_GUID_STRING_LENGTH);
CFRelease(uuid_str);
return str;
}