Ignore:
Timestamp:
Oct 16, 2013 8:04:59 AM (11 years ago)
Author:
riza
Message:

Re #1704: Initial implementation with cli/telnet mode pjsua

Location:
pjproject/branches/projects/winphone
Files:
75 added
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/winphone/pjlib/include/pj/config.h

    r4537 r4618  
    7777#   define PJ_WIN32 1 
    7878 
     79#elif defined(PJ_WIN32_WINPHONE) || defined(_WIN32_WINPHONE) 
     80    /* 
     81     * Windows Phone 
     82     */ 
     83#   undef PJ_WIN32_WINPHONE 
     84#   define PJ_WIN32_WINPHONE   1 
     85#   include <pj/compat/os_winphone.h> 
     86 
     87    /* Also define Win32 */ 
     88#   define PJ_WIN32 1 
     89 
    7990#elif defined(PJ_WIN32) || defined(_WIN32) || defined(__WIN32__) || \ 
    8091        defined(WIN32) || defined(PJ_WIN64) || defined(_WIN64) || \ 
     
    236247#   define PJ_IS_BIG_ENDIAN     1 
    237248 
    238 #elif defined (PJ_M_ARMV4) || defined(ARM) || defined(_ARM_) ||  \ 
    239         defined(ARMV4) || defined(__arm__) 
     249#elif defined(ARM) || defined(_ARM_) ||  defined(__arm__) || defined(_M_ARM) 
     250#   define PJ_HAS_PENTIUM       0 
    240251    /* 
    241252     * ARM, bi-endian, so raise error if endianness is not configured 
    242253     */ 
    243 #   undef PJ_M_ARMV4 
    244 #   define PJ_M_ARMV4           1 
    245 #   define PJ_M_NAME            "armv4" 
    246 #   define PJ_HAS_PENTIUM       0 
    247254#   if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN 
    248255#       error Endianness must be declared for this processor 
    249256#   endif 
     257#   if defined (PJ_M_ARMV7) || defined(ARMV7) 
     258#       undef PJ_M_ARMV7 
     259#       define PJ_M_ARM7                1 
     260#       define PJ_M_NAME                "armv7" 
     261#   elif defined (PJ_M_ARMV4) || defined(ARMV4) 
     262#       undef PJ_M_ARMV4 
     263#       define PJ_M_ARMV4               1 
     264#       define PJ_M_NAME                "armv4" 
     265#   endif  
    250266 
    251267#elif defined (PJ_M_POWERPC) || defined(__powerpc) || defined(__powerpc__) || \ 
  • pjproject/branches/projects/winphone/pjlib/src/pj/file_access_win32.c

    r3553 r4618  
    3434#endif 
    3535 
     36static HANDLE WINAPI create_file(LPCTSTR filename, DWORD desired_access, 
     37                                 DWORD share_mode,  
     38                                 LPSECURITY_ATTRIBUTES security_attributes, 
     39                                 DWORD creation_disposition, 
     40                                 DWORD flags_and_attributes, 
     41                                 HANDLE template_file) 
     42{ 
     43#ifdef PJ_WIN32_WINPHONE   
     44    return CreateFile2(filename, desired_access, share_mode,  
     45                       creation_disposition, NULL); 
     46#else 
     47    return CreateFile(filename, desired_access, share_mode,  
     48                      security_attributes, creation_disposition,  
     49                      flags_and_attributes, template_file); 
     50#endif 
     51} 
    3652 
    3753/* 
     
    4561    PJ_ASSERT_RETURN(filename != NULL, 0); 
    4662 
    47     hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)),  
    48                        CONTROL_ACCESS,  
    49                        FILE_SHARE_READ, NULL, 
    50                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 
     63    hFile = create_file(PJ_STRING_TO_NATIVE(filename, 
     64                                            wfilename,sizeof(wfilename)),  
     65                        CONTROL_ACCESS,  
     66                        FILE_SHARE_READ, NULL, 
     67                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 
     68 
    5169    if (hFile == INVALID_HANDLE_VALUE) 
    5270        return 0; 
     
    6987    PJ_ASSERT_RETURN(filename != NULL, -1); 
    7088 
    71     hFile = CreateFile(PJ_STRING_TO_NATIVE(filename, wfilename,sizeof(wfilename)),  
    72                        CONTROL_ACCESS,  
    73                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, 
    74                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 
     89    hFile = create_file(PJ_STRING_TO_NATIVE(filename,  
     90                                            wfilename,sizeof(wfilename)),  
     91                        CONTROL_ACCESS,  
     92                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, 
     93                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 
    7594    if (hFile == INVALID_HANDLE_VALUE) 
    7695        return -1; 
     
    178197    PJ_ASSERT_RETURN(filename!=NULL && stat!=NULL, PJ_EINVAL); 
    179198 
    180     hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)),  
    181                        CONTROL_ACCESS,  
    182                        FILE_SHARE_READ, NULL, 
    183                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 
     199    hFile = create_file(PJ_STRING_TO_NATIVE(filename, 
     200                                            wfilename,sizeof(wfilename)),  
     201                        CONTROL_ACCESS,  
     202                        FILE_SHARE_READ, NULL, 
     203                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 
    184204    if (hFile == INVALID_HANDLE_VALUE) 
    185205        return PJ_RETURN_OS_ERROR(GetLastError()); 
  • pjproject/branches/projects/winphone/pjlib/src/pj/file_io_win32.c

    r4537 r4618  
    8989    dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL; 
    9090 
    91     hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname,wpathname,sizeof(wpathname)),  
     91#ifdef PJ_WIN32_WINPHONE   
     92    hFile = CreateFile2(PJ_STRING_TO_NATIVE(pathname, 
     93                                            wpathname,sizeof(wpathname)),  
     94                        dwDesiredAccess, dwShareMode, dwCreationDisposition,  
     95                        NULL); 
     96#else 
     97    hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname, 
     98                                           wpathname,sizeof(wpathname)),  
    9299                       dwDesiredAccess, dwShareMode, NULL, 
    93100                       dwCreationDisposition, dwFlagsAndAttributes, NULL); 
     101#endif 
     102 
    94103    if (hFile == INVALID_HANDLE_VALUE) { 
    95104        *fd = 0; 
  • pjproject/branches/projects/winphone/pjlib/src/pj/os_core_win32.c

    r4537 r4618  
    3939#endif 
    4040 
     41#if PJ_WIN32_WINPHONE 
     42#   include "../../third_party/threademulation/include/ThreadEmulation.h" 
     43#endif 
     44 
     45#if PJ_WIN32_WINNT >= 0x0602 
     46#  include <synchapi.h> 
     47#endif 
     48 
    4149/* Activate mutex related logging if PJ_DEBUG_MUTEX is set, otherwise 
    4250 * use default level 6 logging. 
     
    298306PJ_DEF(int) pj_thread_get_prio(pj_thread_t *thread) 
    299307{ 
     308#if PJ_WIN32_WINPHONE 
     309    PJ_UNUSED_ARG(thread); 
     310    return -1; 
     311#else 
    300312    return GetThreadPriority(thread->hthread); 
     313#endif 
    301314} 
    302315 
     
    507520    rec->proc = proc; 
    508521    rec->arg = arg; 
     522 
     523#ifdef PJ_WIN32_WINPHONE 
     524    rec->hthread = CreateThread(NULL, stack_size,  
     525                                thread_main, rec, 
     526                                dwflags, NULL); 
     527#else 
    509528    rec->hthread = CreateThread(NULL, stack_size,  
    510529                                thread_main, rec, 
    511530                                dwflags, &rec->idthread); 
     531#endif 
     532 
    512533    if (rec->hthread == NULL) 
    513534        return PJ_RETURN_OS_ERROR(GetLastError()); 
     
    552573PJ_DEF(pj_thread_t*) pj_thread_this(void) 
    553574{ 
    554     pj_thread_t *rec = pj_thread_local_get(thread_tls_id); 
     575    pj_thread_t *rec = (pj_thread_t *)pj_thread_local_get(thread_tls_id); 
    555576 
    556577    if (rec == NULL) { 
     
    585606    PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name)); 
    586607 
     608#if PJ_WIN32_WINPHONE 
     609    rc = WaitForSingleObjectEx(rec->hthread, INFINITE, FALSE); 
     610#else 
    587611    rc = WaitForSingleObject(rec->hthread, INFINITE); 
     612#endif 
    588613 
    589614    if (rc==WAIT_OBJECT_0) 
     
    859884    PJ_CHECK_STACK(); 
    860885 
    861 #if PJ_WIN32_WINNT >= 0x0400 
    862     InitializeCriticalSection(&mutex->crit); 
     886#if PJ_WIN32_WINPHONE 
     887    InitializeCriticalSectionEx(&mutex->crit, 0, 0); 
     888#elif PJ_WIN32_WINNT >= 0x0400 
     889    InitializeCriticalSection(&mutex->crit);    
    863890#else 
    864891    mutex->hMutex = CreateMutex(NULL, FALSE, NULL); 
     
    11121139    PJ_ASSERT_RETURN(pool && sem_ptr, PJ_EINVAL); 
    11131140 
    1114     sem = pj_pool_alloc(pool, sizeof(*sem));     
     1141    sem = pj_pool_alloc(pool, sizeof(*sem));  
     1142#if PJ_WIN32_WINPHONE 
     1143    /** SEMAPHORE_ALL_ACCESS **/ 
     1144    sem->hSemaphore = CreateSemaphoreEx(NULL, initial, max, NULL, 0,  
     1145                                        SEMAPHORE_ALL_ACCESS); 
     1146#else 
    11151147    sem->hSemaphore = CreateSemaphore(NULL, initial, max, NULL); 
     1148#endif 
    11161149    if (!sem->hSemaphore) 
    11171150        return PJ_RETURN_OS_ERROR(GetLastError()); 
     
    11441177                              pj_thread_this()->obj_name)); 
    11451178 
     1179#if PJ_WIN32_WINPHONE 
     1180    result = WaitForSingleObjectEx(sem->hSemaphore, timeout, FALSE); 
     1181#else 
    11461182    result = WaitForSingleObject(sem->hSemaphore, timeout); 
     1183#endif 
     1184 
    11471185    if (result == WAIT_OBJECT_0) { 
    11481186        LOG_MUTEX((sem->obj_name, "Semaphore acquired by thread %s",  
     
    12411279        return PJ_ENOMEM; 
    12421280 
     1281#if PJ_WIN32_WINPHONE 
     1282    event->hEvent = CreateEventEx(NULL, NULL,  
     1283                                  (manual_reset?0x1:0x0)|(initial?0x2:0x0),  
     1284                                  EVENT_ALL_ACCESS); 
     1285#else 
    12431286    event->hEvent = CreateEvent(NULL, manual_reset?TRUE:FALSE,  
    12441287                                initial?TRUE:FALSE, NULL); 
     1288#endif 
    12451289 
    12461290    if (!event->hEvent) 
     
    12741318                                pj_thread_this()->obj_name)); 
    12751319 
     1320#if PJ_WIN32_WINPHONE 
     1321    result = WaitForSingleObjectEx(event->hEvent, timeout, FALSE); 
     1322#else 
    12761323    result = WaitForSingleObject(event->hEvent, timeout); 
     1324#endif 
    12771325    if (result == WAIT_OBJECT_0) { 
    12781326        PJ_LOG(6, (event->obj_name, "Event: thread %s is released",  
     
    13321380PJ_DEF(pj_status_t) pj_event_pulse(pj_event_t *event) 
    13331381{ 
     1382#ifdef PJ_WIN32_WINPHONE 
     1383    PJ_UNUSED_ARG(event); 
     1384    pj_assert(!"pj_event_pulse() not supported!"); 
     1385    return PJ_ENOTSUP; 
     1386#else 
    13341387    PJ_CHECK_STACK(); 
    13351388    PJ_ASSERT_RETURN(event, PJ_EINVAL); 
     
    13411394    else 
    13421395        return PJ_RETURN_OS_ERROR(GetLastError()); 
     1396#endif 
    13431397} 
    13441398 
  • pjproject/branches/projects/winphone/pjlib/src/pj/os_info.c

    r4537 r4618  
    191191        ovi.dwOSVersionInfoSize = sizeof(ovi); 
    192192 
     193#ifdef PJ_WIN32_WINPHONE 
     194        goto get_sdk_info; 
     195#else 
    193196        if (GetVersionEx(&ovi) == FALSE) 
    194197            goto get_sdk_info; 
     198#endif 
    195199 
    196200        si.os_ver = (ovi.dwMajorVersion << 24) | 
Note: See TracChangeset for help on using the changeset viewer.