Changeset 5347 for pjproject


Ignore:
Timestamp:
Jun 16, 2016 10:38:34 AM (8 years ago)
Author:
ming
Message:

Re #1931: Add support for AVFoundation on Mac

  • Deprecate QTKit
  • Rename ios_dev.m to darwin_dev.m
  • Important: Re-run configure and make dep after applying this change!
Location:
pjproject/trunk
Files:
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/aconfigure

    r5303 r5347  
    670670ac_qt_cflags 
    671671ac_pjmedia_video_has_qt 
    672 ac_ios_cflags 
    673 ac_pjmedia_video_has_ios 
     672ac_darwin_cflags 
     673ac_pjmedia_video_has_ios_opengl 
     674ac_pjmedia_video_has_darwin 
    674675ac_android_cflags 
    675676ac_pjmedia_video_has_android 
     
    62796280        ac_android_cflags="$ac_android_cflags -DPJMEDIA_VIDEO_DEV_HAS_ANDROID=1" 
    62806281        ;; 
    6281   *-apple-darwin_ios*) 
    6282         ac_pjmedia_video=iphone_os 
     6282  *darwin*) 
     6283        ac_pjmedia_video=darwin_os 
     6284 
    62836285 
    62846286 
     
    62976299_ACEOF 
    62986300if ac_fn_c_try_link "$LINENO"; then : 
    6299   ac_pjmedia_video_has_ios=yes 
    6300 else 
    6301   ac_pjmedia_video_has_ios=no 
     6301  ac_pjmedia_video_has_darwin=yes 
     6302else 
     6303  ac_pjmedia_video_has_darwin=no 
     6304fi 
     6305rm -f core conftest.err conftest.$ac_objext \ 
     6306    conftest$ac_exeext conftest.$ac_ext 
     6307        LIBS="-framework OpenGLES" 
     6308        cat confdefs.h - <<_ACEOF >conftest.$ac_ext 
     6309/* end confdefs.h.  */ 
     6310 
     6311int 
     6312main () 
     6313{ 
     6314 
     6315  ; 
     6316  return 0; 
     6317} 
     6318_ACEOF 
     6319if ac_fn_c_try_link "$LINENO"; then : 
     6320  ac_pjmedia_video_has_ios_opengl=yes 
     6321else 
     6322  ac_pjmedia_video_has_ios_opengl=no 
    63026323fi 
    63036324rm -f core conftest.err conftest.$ac_objext \ 
    63046325    conftest$ac_exeext conftest.$ac_ext 
    63056326        LIBS="$SAVED_LIBS" 
    6306         if test "$ac_pjmedia_video_has_ios" = "yes"; then 
    6307           ac_ios_cflags="-DPJMEDIA_VIDEO_DEV_HAS_IOS=1 -DPJMEDIA_VIDEO_DEV_HAS_IOS_OPENGL=1" 
    6308           LIBS="$LIBS -framework OpenGLES -framework AVFoundation -framework CoreGraphics -framework QuartzCore -framework CoreVideo -framework CoreMedia" 
     6327        if test "$ac_pjmedia_video_has_darwin" = "yes"; then 
     6328          ac_darwin_cflags="-DPJMEDIA_VIDEO_DEV_HAS_DARWIN=1" 
     6329          LIBS="$LIBS -framework AVFoundation -framework CoreGraphics -framework QuartzCore -framework CoreVideo -framework CoreMedia" 
    63096330          { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if AVFoundation framework is available... yes" >&5 
    63106331$as_echo "Checking if AVFoundation framework is available... yes" >&6; } 
     
    63136334$as_echo "Checking if AVFoundation framework is available... no" >&6; } 
    63146335        fi 
    6315         ;; 
    6316   *darwin*) 
    6317         ac_pjmedia_video=mac_os 
    6318  
    6319  
    6320         SAVED_LIBS="$LIBS" 
    6321         LIBS="-framework QTKit" 
    6322         cat confdefs.h - <<_ACEOF >conftest.$ac_ext 
     6336        if test "$ac_pjmedia_video_has_ios_opengl" = "yes"; then 
     6337          ac_darwin_cflags="-DPJMEDIA_VIDEO_DEV_HAS_IOS_OPENGL=1" 
     6338          LIBS="$LIBS -framework OpenGLES" 
     6339          { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if OpenGLES framework is available... yes" >&5 
     6340$as_echo "Checking if OpenGLES framework is available... yes" >&6; } 
     6341        else 
     6342          { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if OpenGLES framework is available... no" >&5 
     6343$as_echo "Checking if OpenGLES framework is available... no" >&6; } 
     6344        fi 
     6345        if false; then 
     6346          # QTKit is deprecated, see ticket #1931. 
     6347          ac_pjmedia_video=mac_os 
     6348 
     6349 
     6350          SAVED_LIBS="$LIBS" 
     6351          LIBS="-framework QTKit" 
     6352          cat confdefs.h - <<_ACEOF >conftest.$ac_ext 
    63236353/* end confdefs.h.  */ 
    63246354 
     
    63386368rm -f core conftest.err conftest.$ac_objext \ 
    63396369    conftest$ac_exeext conftest.$ac_ext 
    6340         LIBS="$SAVED_LIBS" 
    6341         if test "$ac_pjmedia_video_has_qt" = "yes"; then 
    6342           ac_qt_cflags="-DPJMEDIA_VIDEO_DEV_HAS_QT=1" 
    6343           LIBS="$LIBS -framework QTKit -framework QuartzCore -framework OpenGL" 
    6344           { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if QTKit framework is available... yes" >&5 
     6370          LIBS="$SAVED_LIBS" 
     6371          if test "$ac_pjmedia_video_has_qt" = "yes"; then 
     6372            ac_qt_cflags="-DPJMEDIA_VIDEO_DEV_HAS_QT=1" 
     6373            LIBS="$LIBS -framework QTKit -framework QuartzCore -framework OpenGL" 
     6374            { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if QTKit framework is available... yes" >&5 
    63456375$as_echo "Checking if QTKit framework is available... yes" >&6; } 
    6346         else 
    6347           { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if QTKit framework is available... no" >&5 
     6376          else 
     6377            { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if QTKit framework is available... no" >&5 
    63486378$as_echo "Checking if QTKit framework is available... no" >&6; } 
    6349         fi 
    6350         ;; 
     6379          fi 
     6380        fi 
     6381        ;; 
    63516382 esac 
    63526383fi 
  • pjproject/trunk/aconfigure.ac

    r5310 r5347  
    734734        ac_android_cflags="$ac_android_cflags -DPJMEDIA_VIDEO_DEV_HAS_ANDROID=1" 
    735735        ;; 
    736   *-apple-darwin_ios*) 
    737         ac_pjmedia_video=iphone_os 
    738         AC_SUBST(ac_pjmedia_video_has_ios) 
    739         AC_SUBST(ac_ios_cflags) 
     736  *darwin*) 
     737        ac_pjmedia_video=darwin_os 
     738        AC_SUBST(ac_pjmedia_video_has_darwin) 
     739        AC_SUBST(ac_pjmedia_video_has_ios_opengl) 
     740        AC_SUBST(ac_darwin_cflags) 
    740741        SAVED_LIBS="$LIBS" 
    741742        LIBS="-framework AVFoundation -framework CoreGraphics -framework QuartzCore -framework CoreVideo -framework CoreMedia" 
    742         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [])],[ac_pjmedia_video_has_ios=yes],[ac_pjmedia_video_has_ios=no]) 
     743        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [])], 
     744                       [ac_pjmedia_video_has_darwin=yes], 
     745                       [ac_pjmedia_video_has_darwin=no]) 
     746        LIBS="-framework OpenGLES" 
     747        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [])], 
     748                       [ac_pjmedia_video_has_ios_opengl=yes], 
     749                       [ac_pjmedia_video_has_ios_opengl=no]) 
    743750        LIBS="$SAVED_LIBS" 
    744         if test "$ac_pjmedia_video_has_ios" = "yes"; then 
    745           ac_ios_cflags="-DPJMEDIA_VIDEO_DEV_HAS_IOS=1 -DPJMEDIA_VIDEO_DEV_HAS_IOS_OPENGL=1" 
    746           LIBS="$LIBS -framework OpenGLES -framework AVFoundation -framework CoreGraphics -framework QuartzCore -framework CoreVideo -framework CoreMedia" 
     751        if test "$ac_pjmedia_video_has_darwin" = "yes"; then 
     752          ac_darwin_cflags="-DPJMEDIA_VIDEO_DEV_HAS_DARWIN=1" 
     753          LIBS="$LIBS -framework AVFoundation -framework CoreGraphics -framework QuartzCore -framework CoreVideo -framework CoreMedia" 
    747754          AC_MSG_RESULT([Checking if AVFoundation framework is available... yes]) 
    748755        else 
    749756          AC_MSG_RESULT([Checking if AVFoundation framework is available... no]) 
    750757        fi 
    751         ;; 
    752   *darwin*) 
    753         ac_pjmedia_video=mac_os 
    754         AC_SUBST(ac_pjmedia_video_has_qt) 
    755         AC_SUBST(ac_qt_cflags) 
    756         SAVED_LIBS="$LIBS" 
    757         LIBS="-framework QTKit" 
    758         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [])],[ac_pjmedia_video_has_qt=yes],[ac_pjmedia_video_has_qt=no]) 
    759         LIBS="$SAVED_LIBS" 
    760         if test "$ac_pjmedia_video_has_qt" = "yes"; then 
    761           ac_qt_cflags="-DPJMEDIA_VIDEO_DEV_HAS_QT=1" 
    762           LIBS="$LIBS -framework QTKit -framework QuartzCore -framework OpenGL" 
    763           AC_MSG_RESULT([Checking if QTKit framework is available... yes]) 
     758        if test "$ac_pjmedia_video_has_ios_opengl" = "yes"; then 
     759          ac_darwin_cflags="-DPJMEDIA_VIDEO_DEV_HAS_IOS_OPENGL=1" 
     760          LIBS="$LIBS -framework OpenGLES" 
     761          AC_MSG_RESULT([Checking if OpenGLES framework is available... yes]) 
    764762        else 
    765           AC_MSG_RESULT([Checking if QTKit framework is available... no]) 
     763          AC_MSG_RESULT([Checking if OpenGLES framework is available... no]) 
    766764        fi 
    767         ;; 
     765        if false; then 
     766          # QTKit is deprecated, see ticket #1931. 
     767          ac_pjmedia_video=mac_os 
     768          AC_SUBST(ac_pjmedia_video_has_qt) 
     769          AC_SUBST(ac_qt_cflags) 
     770          SAVED_LIBS="$LIBS" 
     771          LIBS="-framework QTKit" 
     772          AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [])],[ac_pjmedia_video_has_qt=yes],[ac_pjmedia_video_has_qt=no]) 
     773          LIBS="$SAVED_LIBS" 
     774          if test "$ac_pjmedia_video_has_qt" = "yes"; then 
     775            ac_qt_cflags="-DPJMEDIA_VIDEO_DEV_HAS_QT=1" 
     776            LIBS="$LIBS -framework QTKit -framework QuartzCore -framework OpenGL" 
     777            AC_MSG_RESULT([Checking if QTKit framework is available... yes]) 
     778          else 
     779            AC_MSG_RESULT([Checking if QTKit framework is available... no]) 
     780          fi 
     781        fi 
     782        ;; 
    768783 esac 
    769784fi 
  • pjproject/trunk/build.mak.in

    r5086 r5347  
    148148# QT 
    149149AC_PJMEDIA_VIDEO_HAS_QT = @ac_pjmedia_video_has_qt@ 
    150 QT_CFLAGS = @ac_qt_cflags@ 
    151  
    152 # iOS 
    153 IOS_CFLAGS = @ac_ios_cflags@ 
     150# QT_CFLAGS = @ac_qt_cflags@ 
     151 
     152# Darwin (Mac and iOS) 
     153AC_PJMEDIA_VIDEO_HAS_DARWIN = @ac_pjmedia_video_has_darwin@ 
     154AC_PJMEDIA_VIDEO_HAS_IOS_OPENGL = @ac_pjmedia_video_has_ios_opengl@ 
     155DARWIN_CFLAGS = @ac_darwin_cflags@ 
    154156 
    155157# Android 
     
    162164# PJMEDIA features exclusion 
    163165PJ_VIDEO_CFLAGS += $(SDL_CFLAGS) $(FFMPEG_CFLAGS) $(V4L2_CFLAGS) $(QT_CFLAGS) \ 
    164                    $(OPENH264_CFLAGS) $(IOS_CFLAGS) $(LIBYUV_CFLAGS) 
     166                   $(OPENH264_CFLAGS) $(DARWIN_CFLAGS) $(LIBYUV_CFLAGS) 
    165167PJ_VIDEO_LDFLAGS += $(SDL_LDFLAGS) $(FFMPEG_LDFLAGS) $(V4L2_LDFLAGS) \ 
    166168                   $(OPENH264_LDFLAGS) $(LIBYUV_LDFLAGS) 
  • pjproject/trunk/pjmedia/build/os-auto.mak.in

    r5268 r5347  
    33# Define the desired video device backend 
    44# Valid values are: 
    5 #   - mac_os 
    6 #   - iphone_os 
     5#   - darwin_os 
    76#   - android_os 
    87AC_PJMEDIA_VIDEO = @ac_pjmedia_video@ 
     
    2221# QT 
    2322AC_PJMEDIA_VIDEO_HAS_QT = @ac_pjmedia_video_has_qt@ 
    24 QT_CFLAGS = @ac_qt_cflags@ 
    25  
    26 # iOS 
    27 IOS_CFLAGS = @ac_ios_cflags@ 
     23# QT_CFLAGS = @ac_qt_cflags@ 
     24 
     25# Darwin (Mac and iOS) 
     26DARWIN_CFLAGS = @ac_darwin_cflags@ 
    2827 
    2928# Android 
     
    4645export CFLAGS += @ac_no_small_filter@ @ac_no_large_filter@ @ac_no_speex_aec@ \ 
    4746                 $(SDL_CFLAGS) $(FFMPEG_CFLAGS) $(V4L2_CFLAGS) $(QT_CFLAGS) \ 
    48                  $(IOS_CFLAGS) $(ANDROID_CFLAGS) $(LIBYUV_CFLAGS) \ 
     47                 $(DARWIN_CFLAGS) $(ANDROID_CFLAGS) $(LIBYUV_CFLAGS) \ 
    4948                 $(OPENH264_CFLAGS) $(WEBRTC_CFLAGS) 
    5049export LDFLAGS += $(SDL_LDFLAGS) $(FFMPEG_LDFLAGS) $(V4L2_LDFLAGS) \ 
     
    249248 
    250249# 
    251 # iOS video device 
    252 # 
    253 ifeq ($(AC_PJMEDIA_VIDEO),iphone_os) 
    254 export PJMEDIA_VIDEODEV_OBJS += ios_dev.o ios_opengl_dev.o 
     250# Darwin video device 
     251# 
     252ifeq ($(AC_PJMEDIA_VIDEO_HAS_DARWIN),yes) 
     253export PJMEDIA_VIDEODEV_OBJS += darwin_dev.o 
     254endif 
     255 
     256# 
     257# iOS OpenGL video device 
     258# 
     259ifeq ($(AC_PJMEDIA_VIDEO_HAS_IOS_OPENGL),yes) 
     260export PJMEDIA_VIDEODEV_OBJS += ios_opengl_dev.o 
    255261endif 
    256262 
     
    266272# source code 
    267273# 
    268 ifneq (,$(filter $(AC_PJMEDIA_VIDEO),mac_os iphone_os)) 
     274ifneq (,$(filter $(AC_PJMEDIA_VIDEO),darwin_os)) 
    269275# Mac and iPhone OS specific, use obj-c 
    270276export PJMEDIA_VIDEODEV_OBJS += sdl_dev_m.o 
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/darwin_dev.m

    r5344 r5347  
    2424 
    2525#if defined(PJMEDIA_HAS_VIDEO) && PJMEDIA_HAS_VIDEO != 0 && \ 
    26     defined(PJMEDIA_VIDEO_DEV_HAS_IOS) && PJMEDIA_VIDEO_DEV_HAS_IOS != 0 
    27  
    28 #include "Availability.h" 
    29 #ifdef __IPHONE_4_0 
    30  
    31 #import <UIKit/UIKit.h> 
     26    defined(PJMEDIA_VIDEO_DEV_HAS_DARWIN) && PJMEDIA_VIDEO_DEV_HAS_DARWIN != 0 
     27 
     28#include "TargetConditionals.h" 
     29 
     30#if TARGET_OS_IPHONE 
     31    /* On iOS, we supports rendering using UIView */ 
     32    #import <UIKit/UIKit.h> 
     33#endif 
     34 
    3235#import <AVFoundation/AVFoundation.h> 
    3336#import <QuartzCore/QuartzCore.h> 
    3437 
    35 #define THIS_FILE               "ios_dev.c" 
     38#define THIS_FILE               "darwin_dev.c" 
    3639#define DEFAULT_CLOCK_RATE      90000 
    37 #define DEFAULT_WIDTH           352 
    38 #define DEFAULT_HEIGHT          288 
     40#if TARGET_OS_IPHONE 
     41    #define DEFAULT_WIDTH       352 
     42    #define DEFAULT_HEIGHT      288 
     43#else 
     44    #define DEFAULT_WIDTH       1280 
     45    #define DEFAULT_HEIGHT      720 
     46#endif 
    3947#define DEFAULT_FPS             15 
    4048 
     
    4452#define MAINTAIN_ASPECT_RATIO   PJ_TRUE 
    4553 
    46 typedef struct ios_fmt_info 
     54typedef struct darwin_fmt_info 
    4755{ 
    4856    pjmedia_format_id   pjmedia_format; 
    49     UInt32              ios_format; 
    50 } ios_fmt_info; 
    51  
    52 static ios_fmt_info ios_fmts[] = 
    53 { 
     57    UInt32              darwin_format; 
     58} darwin_fmt_info; 
     59 
     60static darwin_fmt_info darwin_fmts[] = 
     61{ 
     62#if !TARGET_OS_IPHONE 
     63    { PJMEDIA_FORMAT_YUY2, kCVPixelFormatType_422YpCbCr8_yuvs }, 
     64    { PJMEDIA_FORMAT_UYVY, kCVPixelFormatType_422YpCbCr8 }, 
     65#endif 
    5466    { PJMEDIA_FORMAT_BGRA, kCVPixelFormatType_32BGRA }, 
    5567    { PJMEDIA_FORMAT_I420, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange } 
    5668}; 
    5769 
    58 typedef struct ios_supported_size 
     70typedef struct darwin_supported_size 
    5971{ 
    6072    pj_size_t supported_size_w; 
    6173    pj_size_t supported_size_h; 
    6274    NSString *preset_str; 
    63 } ios_supported_size; 
     75} darwin_supported_size; 
    6476 
    6577/* Set the preset_str on set_preset_str method. */ 
    66 static ios_supported_size ios_sizes[] = 
    67 { 
     78static darwin_supported_size darwin_sizes[] = 
     79{ 
     80#if TARGET_OS_IPHONE 
    6881    { 352, 288, NULL }, 
    6982    { 640, 480, NULL }, 
    7083    { 1280, 720, NULL }, 
    7184    { 1920, 1080, NULL } 
     85#else 
     86    { 1280, 720, NULL } 
     87#endif 
    7288}; 
    7389 
    74 /* ios device info */ 
    75 struct ios_dev_info 
     90/* darwin device info */ 
     91struct darwin_dev_info 
    7692{ 
    7793    pjmedia_vid_dev_info         info; 
     
    7995}; 
    8096 
    81 /* ios factory */ 
    82 struct ios_factory 
     97/* darwin factory */ 
     98struct darwin_factory 
    8399{ 
    84100    pjmedia_vid_dev_factory      base; 
     
    87103 
    88104    unsigned                     dev_count; 
    89     struct ios_dev_info         *dev_info; 
     105    struct darwin_dev_info      *dev_info; 
    90106}; 
    91107 
     
    94110{ 
    95111@public 
    96     struct ios_stream *stream; 
     112    struct darwin_stream *stream; 
    97113} 
    98114@end 
    99115 
    100116/* Video stream. */ 
    101 struct ios_stream 
     117struct darwin_stream 
    102118{ 
    103119    pjmedia_vid_dev_stream  base;               /**< Base stream       */ 
    104120    pjmedia_vid_dev_param   param;              /**< Settings          */ 
    105121    pj_pool_t              *pool;               /**< Memory pool       */ 
    106     struct ios_factory     *factory;            /**< Factory           */ 
     122    struct darwin_factory  *factory;            /**< Factory           */ 
    107123 
    108124    pjmedia_vid_dev_cb      vid_cb;             /**< Stream callback   */ 
     
    127143    AVCaptureVideoPreviewLayer  *prev_layer; 
    128144     
     145#if TARGET_OS_IPHONE 
    129146    void                *render_buf; 
    130147    pj_size_t            render_buf_size; 
    131148    CGDataProviderRef    render_data_provider; 
    132149    UIView              *render_view; 
    133      
     150#endif 
     151 
    134152    pj_timestamp         frame_ts; 
    135153    unsigned             ts_inc; 
     
    138156 
    139157/* Prototypes */ 
    140 static pj_status_t ios_factory_init(pjmedia_vid_dev_factory *f); 
    141 static pj_status_t ios_factory_destroy(pjmedia_vid_dev_factory *f); 
    142 static pj_status_t ios_factory_refresh(pjmedia_vid_dev_factory *f); 
    143 static unsigned    ios_factory_get_dev_count(pjmedia_vid_dev_factory *f); 
    144 static pj_status_t ios_factory_get_dev_info(pjmedia_vid_dev_factory *f, 
    145                                             unsigned index, 
    146                                             pjmedia_vid_dev_info *info); 
    147 static pj_status_t ios_factory_default_param(pj_pool_t *pool, 
    148                                              pjmedia_vid_dev_factory *f, 
    149                                              unsigned index, 
    150                                              pjmedia_vid_dev_param *param); 
    151 static pj_status_t ios_factory_create_stream( 
     158static pj_status_t darwin_factory_init(pjmedia_vid_dev_factory *f); 
     159static pj_status_t darwin_factory_destroy(pjmedia_vid_dev_factory *f); 
     160static pj_status_t darwin_factory_refresh(pjmedia_vid_dev_factory *f); 
     161static unsigned    darwin_factory_get_dev_count(pjmedia_vid_dev_factory *f); 
     162static pj_status_t darwin_factory_get_dev_info(pjmedia_vid_dev_factory *f, 
     163                                               unsigned index, 
     164                                               pjmedia_vid_dev_info *info); 
     165static pj_status_t darwin_factory_default_param(pj_pool_t *pool, 
     166                                                pjmedia_vid_dev_factory *f, 
     167                                                unsigned index, 
     168                                                pjmedia_vid_dev_param *param); 
     169static pj_status_t darwin_factory_create_stream( 
    152170                                        pjmedia_vid_dev_factory *f, 
    153171                                        pjmedia_vid_dev_param *param, 
     
    156174                                        pjmedia_vid_dev_stream **p_vid_strm); 
    157175 
    158 static pj_status_t ios_stream_get_param(pjmedia_vid_dev_stream *strm, 
    159                                         pjmedia_vid_dev_param *param); 
    160 static pj_status_t ios_stream_get_cap(pjmedia_vid_dev_stream *strm, 
    161                                       pjmedia_vid_dev_cap cap, 
    162                                       void *value); 
    163 static pj_status_t ios_stream_set_cap(pjmedia_vid_dev_stream *strm, 
    164                                       pjmedia_vid_dev_cap cap, 
    165                                       const void *value); 
    166 static pj_status_t ios_stream_start(pjmedia_vid_dev_stream *strm); 
    167 static pj_status_t ios_stream_get_frame(pjmedia_vid_dev_stream *strm, 
    168                                         pjmedia_frame *frame); 
    169 static pj_status_t ios_stream_put_frame(pjmedia_vid_dev_stream *strm, 
    170                                         const pjmedia_frame *frame); 
    171 static pj_status_t ios_stream_stop(pjmedia_vid_dev_stream *strm); 
    172 static pj_status_t ios_stream_destroy(pjmedia_vid_dev_stream *strm); 
     176static pj_status_t darwin_stream_get_param(pjmedia_vid_dev_stream *strm, 
     177                                           pjmedia_vid_dev_param *param); 
     178static pj_status_t darwin_stream_get_cap(pjmedia_vid_dev_stream *strm, 
     179                                         pjmedia_vid_dev_cap cap, 
     180                                         void *value); 
     181static pj_status_t darwin_stream_set_cap(pjmedia_vid_dev_stream *strm, 
     182                                         pjmedia_vid_dev_cap cap, 
     183                                         const void *value); 
     184static pj_status_t darwin_stream_start(pjmedia_vid_dev_stream *strm); 
     185static pj_status_t darwin_stream_get_frame(pjmedia_vid_dev_stream *strm, 
     186                                           pjmedia_frame *frame); 
     187static pj_status_t darwin_stream_put_frame(pjmedia_vid_dev_stream *strm, 
     188                                           const pjmedia_frame *frame); 
     189static pj_status_t darwin_stream_stop(pjmedia_vid_dev_stream *strm); 
     190static pj_status_t darwin_stream_destroy(pjmedia_vid_dev_stream *strm); 
    173191 
    174192/* Operations */ 
    175193static pjmedia_vid_dev_factory_op factory_op = 
    176194{ 
    177     &ios_factory_init, 
    178     &ios_factory_destroy, 
    179     &ios_factory_get_dev_count, 
    180     &ios_factory_get_dev_info, 
    181     &ios_factory_default_param, 
    182     &ios_factory_create_stream, 
    183     &ios_factory_refresh 
     195    &darwin_factory_init, 
     196    &darwin_factory_destroy, 
     197    &darwin_factory_get_dev_count, 
     198    &darwin_factory_get_dev_info, 
     199    &darwin_factory_default_param, 
     200    &darwin_factory_create_stream, 
     201    &darwin_factory_refresh 
    184202}; 
    185203 
    186204static pjmedia_vid_dev_stream_op stream_op = 
    187205{ 
    188     &ios_stream_get_param, 
    189     &ios_stream_get_cap, 
    190     &ios_stream_set_cap, 
    191     &ios_stream_start, 
    192     &ios_stream_get_frame, 
    193     &ios_stream_put_frame, 
    194     &ios_stream_stop, 
    195     &ios_stream_destroy 
     206    &darwin_stream_get_param, 
     207    &darwin_stream_get_cap, 
     208    &darwin_stream_set_cap, 
     209    &darwin_stream_start, 
     210    &darwin_stream_get_frame, 
     211    &darwin_stream_put_frame, 
     212    &darwin_stream_stop, 
     213    &darwin_stream_destroy 
    196214}; 
    197215 
    198216static void set_preset_str() 
    199217{ 
    200     ios_sizes[0].preset_str = AVCaptureSessionPreset352x288; 
    201     ios_sizes[1].preset_str = AVCaptureSessionPreset640x480; 
    202     ios_sizes[2].preset_str = AVCaptureSessionPreset1280x720; 
    203     ios_sizes[3].preset_str = AVCaptureSessionPreset1920x1080; 
     218#if TARGET_OS_IPHONE 
     219    darwin_sizes[0].preset_str = AVCaptureSessionPreset352x288; 
     220    darwin_sizes[1].preset_str = AVCaptureSessionPreset640x480; 
     221    darwin_sizes[2].preset_str = AVCaptureSessionPreset1280x720; 
     222    darwin_sizes[3].preset_str = AVCaptureSessionPreset1920x1080; 
     223#else 
     224    darwin_sizes[0].preset_str = AVCaptureSessionPreset1280x720; 
     225#endif 
    204226} 
    205227 
     
    208230 */ 
    209231/* 
    210  * Init ios_ video driver. 
     232 * Init darwin_ video driver. 
    211233 */ 
    212 pjmedia_vid_dev_factory* pjmedia_ios_factory(pj_pool_factory *pf) 
    213 { 
    214     struct ios_factory *f; 
     234pjmedia_vid_dev_factory* pjmedia_darwin_factory(pj_pool_factory *pf) 
     235{ 
     236    struct darwin_factory *f; 
    215237    pj_pool_t *pool; 
    216238 
    217     pool = pj_pool_create(pf, "ios video", 512, 512, NULL); 
    218     f = PJ_POOL_ZALLOC_T(pool, struct ios_factory); 
     239    pool = pj_pool_create(pf, "darwin video", 512, 512, NULL); 
     240    f = PJ_POOL_ZALLOC_T(pool, struct darwin_factory); 
    219241    f->pf = pf; 
    220242    f->pool = pool; 
     
    226248 
    227249/* API: init factory */ 
    228 static pj_status_t ios_factory_init(pjmedia_vid_dev_factory *f) 
    229 { 
    230     struct ios_factory *qf = (struct ios_factory*)f; 
    231     struct ios_dev_info *qdi; 
     250static pj_status_t darwin_factory_init(pjmedia_vid_dev_factory *f) 
     251{ 
     252    struct darwin_factory *qf = (struct darwin_factory*)f; 
     253    struct darwin_dev_info *qdi; 
    232254    unsigned i, l, first_idx, front_idx = -1; 
    233255    enum { MAX_DEV_COUNT = 8 }; 
     
    236258     
    237259    /* Initialize input and output devices here */ 
    238     qf->dev_info = (struct ios_dev_info*) 
     260    qf->dev_info = (struct darwin_dev_info*) 
    239261                   pj_pool_calloc(qf->pool, MAX_DEV_COUNT, 
    240                                   sizeof(struct ios_dev_info)); 
     262                                  sizeof(struct darwin_dev_info)); 
    241263    qf->dev_count = 0; 
    242264     
     265#if TARGET_OS_IPHONE 
    243266    /* Init output device */ 
    244267    qdi = &qf->dev_info[qf->dev_count++]; 
     
    248271    qdi->info.dir = PJMEDIA_DIR_RENDER; 
    249272    qdi->info.has_callback = PJ_FALSE; 
     273#endif 
    250274     
    251275    /* Init input device */ 
     
    269293            pj_ansi_strncpy(qdi->info.name, [device.localizedName UTF8String], 
    270294                            sizeof(qdi->info.name)); 
    271             pj_ansi_strncpy(qdi->info.driver, "iOS", sizeof(qdi->info.driver)); 
     295            pj_ansi_strncpy(qdi->info.driver, "AVF", sizeof(qdi->info.driver)); 
    272296            qdi->info.dir = PJMEDIA_DIR_CAPTURE; 
    273297            qdi->info.has_callback = PJ_FALSE; 
     298#if TARGET_OS_IPHONE 
    274299            qdi->info.caps = PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW | 
    275300                             PJMEDIA_VID_DEV_CAP_SWITCH; 
     301#endif 
    276302            qdi->dev = device; 
    277303        } 
     
    280306    /* Set front camera to be the first input device (as default dev) */ 
    281307    if (front_idx != -1 && front_idx != first_idx) { 
    282         struct ios_dev_info tmp_dev_info = qf->dev_info[first_idx]; 
     308        struct darwin_dev_info tmp_dev_info = qf->dev_info[first_idx]; 
    283309        qf->dev_info[first_idx] = qf->dev_info[front_idx]; 
    284310        qf->dev_info[front_idx] = tmp_dev_info; 
     
    295321                          PJMEDIA_VID_DEV_CAP_ORIENTATION; 
    296322         
    297         for (l = 0; l < PJ_ARRAY_SIZE(ios_fmts); l++) { 
     323        for (l = 0; l < PJ_ARRAY_SIZE(darwin_fmts); l++) { 
    298324            pjmedia_format *fmt; 
    299325             
    300326            /* Simple renderer UIView only supports BGRA */ 
    301327            if (qdi->info.dir == PJMEDIA_DIR_RENDER && 
    302                 ios_fmts[l].pjmedia_format != PJMEDIA_FORMAT_BGRA) 
     328                darwin_fmts[l].pjmedia_format != PJMEDIA_FORMAT_BGRA) 
    303329            { 
    304330                continue; 
     
    308334                fmt = &qdi->info.fmt[qdi->info.fmt_cnt++]; 
    309335                pjmedia_format_init_video(fmt, 
    310                                           ios_fmts[l].pjmedia_format, 
     336                                          darwin_fmts[l].pjmedia_format, 
    311337                                          DEFAULT_WIDTH, 
    312338                                          DEFAULT_HEIGHT, 
     
    317343                 
    318344                /* Set supported size for capture device */ 
    319                 for(m = 0; m < PJ_ARRAY_SIZE(ios_sizes) && 
    320                            qdi->info.fmt_cnt<PJMEDIA_VID_DEV_INFO_FMT_CNT; 
     345                for(m = 0; 
     346                    m < PJ_ARRAY_SIZE(darwin_sizes) && 
     347                    qdi->info.fmt_cnt<PJMEDIA_VID_DEV_INFO_FMT_CNT; 
    321348                    m++) 
    322349                { 
    323350                    if ([dev supportsAVCaptureSessionPreset: 
    324                                                        ios_sizes[m].preset_str]) 
     351                             darwin_sizes[m].preset_str]) 
    325352                    { 
    326353                        /* Landscape video */ 
    327354                        fmt = &qdi->info.fmt[qdi->info.fmt_cnt++]; 
    328355                        pjmedia_format_init_video(fmt, 
    329                                                   ios_fmts[l].pjmedia_format, 
    330                                                   ios_sizes[m].supported_size_w, 
    331                                                   ios_sizes[m].supported_size_h, 
    332                                                   DEFAULT_FPS, 1); 
     356                                darwin_fmts[l].pjmedia_format, 
     357                                darwin_sizes[m].supported_size_w, 
     358                                darwin_sizes[m].supported_size_h, 
     359                                DEFAULT_FPS, 1); 
    333360                        /* Portrait video */ 
    334361                        fmt = &qdi->info.fmt[qdi->info.fmt_cnt++]; 
    335362                        pjmedia_format_init_video(fmt, 
    336                                                   ios_fmts[l].pjmedia_format, 
    337                                                   ios_sizes[m].supported_size_h, 
    338                                                   ios_sizes[m].supported_size_w, 
    339                                                   DEFAULT_FPS, 1); 
     363                                darwin_fmts[l].pjmedia_format, 
     364                                darwin_sizes[m].supported_size_h, 
     365                                darwin_sizes[m].supported_size_w, 
     366                                DEFAULT_FPS, 1); 
    340367                    } 
    341368                }                 
     
    344371    } 
    345372     
    346     PJ_LOG(4, (THIS_FILE, "iOS video initialized with %d devices:", 
     373    PJ_LOG(4, (THIS_FILE, "Darwin video initialized with %d devices:", 
    347374               qf->dev_count)); 
    348375    for (i = 0; i < qf->dev_count; i++) { 
     
    357384 
    358385/* API: destroy factory */ 
    359 static pj_status_t ios_factory_destroy(pjmedia_vid_dev_factory *f) 
    360 { 
    361     struct ios_factory *qf = (struct ios_factory*)f; 
     386static pj_status_t darwin_factory_destroy(pjmedia_vid_dev_factory *f) 
     387{ 
     388    struct darwin_factory *qf = (struct darwin_factory*)f; 
    362389    pj_pool_t *pool = qf->pool; 
    363390 
     
    369396 
    370397/* API: refresh the list of devices */ 
    371 static pj_status_t ios_factory_refresh(pjmedia_vid_dev_factory *f) 
     398static pj_status_t darwin_factory_refresh(pjmedia_vid_dev_factory *f) 
    372399{ 
    373400    PJ_UNUSED_ARG(f); 
     
    376403 
    377404/* API: get number of devices */ 
    378 static unsigned ios_factory_get_dev_count(pjmedia_vid_dev_factory *f) 
    379 { 
    380     struct ios_factory *qf = (struct ios_factory*)f; 
     405static unsigned darwin_factory_get_dev_count(pjmedia_vid_dev_factory *f) 
     406{ 
     407    struct darwin_factory *qf = (struct darwin_factory*)f; 
    381408    return qf->dev_count; 
    382409} 
    383410 
    384411/* API: get device info */ 
    385 static pj_status_t ios_factory_get_dev_info(pjmedia_vid_dev_factory *f, 
    386                                             unsigned index, 
    387                                             pjmedia_vid_dev_info *info) 
    388 { 
    389     struct ios_factory *qf = (struct ios_factory*)f; 
     412static pj_status_t darwin_factory_get_dev_info(pjmedia_vid_dev_factory *f, 
     413                                               unsigned index, 
     414                                               pjmedia_vid_dev_info *info) 
     415{ 
     416    struct darwin_factory *qf = (struct darwin_factory*)f; 
    390417 
    391418    PJ_ASSERT_RETURN(index < qf->dev_count, PJMEDIA_EVID_INVDEV); 
     
    397424 
    398425/* API: create default device parameter */ 
    399 static pj_status_t ios_factory_default_param(pj_pool_t *pool, 
    400                                              pjmedia_vid_dev_factory *f, 
    401                                              unsigned index, 
    402                                              pjmedia_vid_dev_param *param) 
    403 { 
    404     struct ios_factory *qf = (struct ios_factory*)f; 
    405     struct ios_dev_info *di; 
     426static pj_status_t darwin_factory_default_param(pj_pool_t *pool, 
     427                                                pjmedia_vid_dev_factory *f, 
     428                                                unsigned index, 
     429                                                pjmedia_vid_dev_param *param) 
     430{ 
     431    struct darwin_factory *qf = (struct darwin_factory*)f; 
     432    struct darwin_dev_info *di; 
    406433 
    407434    PJ_ASSERT_RETURN(index < qf->dev_count, PJMEDIA_EVID_INVDEV); 
     
    431458 
    432459@implementation VOutDelegate 
     460#if TARGET_OS_IPHONE 
    433461- (void)update_image 
    434462{     
     
    447475 
    448476    [pool release]; 
    449 }     
     477} 
     478#endif 
    450479 
    451480- (void)captureOutput:(AVCaptureOutput *)captureOutput  
     
    474503 
    475504    [stream->frame_lock lock]; 
     505     
     506    // TODO: on Mac, nearly all frames, regardless of video format, 
     507    // have extra padding. So we may need to create a util function to 
     508    // remove the stride. 
     509     
    476510    if (stream->is_planar && stream->capture_buf) { 
    477511        if (stream->param.fmt.id == PJMEDIA_FORMAT_I420) { 
     
    552586@end 
    553587 
    554 static pj_status_t ios_stream_get_frame(pjmedia_vid_dev_stream *strm, 
     588static pj_status_t darwin_stream_get_frame(pjmedia_vid_dev_stream *strm, 
    555589                                        pjmedia_frame *frame) 
    556590{ 
    557     struct ios_stream *stream = (struct ios_stream *)strm; 
     591    struct darwin_stream *stream = (struct darwin_stream *)strm; 
    558592 
    559593    frame->type = PJMEDIA_FRAME_TYPE_VIDEO; 
     
    571605 
    572606 
    573 static ios_fmt_info* get_ios_format_info(pjmedia_format_id id) 
     607static darwin_fmt_info* get_darwin_format_info(pjmedia_format_id id) 
    574608{ 
    575609    unsigned i; 
    576610     
    577     for (i = 0; i < PJ_ARRAY_SIZE(ios_fmts); i++) { 
    578         if (ios_fmts[i].pjmedia_format == id) 
    579             return &ios_fmts[i]; 
     611    for (i = 0; i < PJ_ARRAY_SIZE(darwin_fmts); i++) { 
     612        if (darwin_fmts[i].pjmedia_format == id) 
     613            return &darwin_fmts[i]; 
    580614    } 
    581615     
     
    584618 
    585619 
    586 static pj_status_t ios_init_view(struct ios_stream *strm) 
     620#if TARGET_OS_IPHONE 
     621static pj_status_t darwin_init_view(struct darwin_stream *strm) 
    587622{ 
    588623    pjmedia_vid_dev_param *param = &strm->param; 
     
    602637    strm->render_view = [[UIView alloc] initWithFrame:view_rect]; 
    603638    strm->param.window.info.ios.window = strm->render_view; 
    604      
     639 
    605640    if (param->flags & PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW) { 
    606641        PJ_ASSERT_RETURN(param->window.info.ios.window, PJ_EINVAL); 
    607         ios_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW, 
     642        darwin_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW, 
    608643                           param->window.info.ios.window); 
    609644    } 
    610645    if (param->flags & PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE) { 
    611         ios_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE, 
     646        darwin_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE, 
    612647                           &param->window_hide); 
    613648    } 
    614649    if (param->flags & PJMEDIA_VID_DEV_CAP_ORIENTATION) { 
    615         ios_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_ORIENTATION, 
     650        darwin_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_ORIENTATION, 
    616651                           &param->orient); 
    617652    } 
     
    619654    return PJ_SUCCESS; 
    620655} 
     656#endif /* TARGET_OS_IPHONE */ 
    621657 
    622658 
    623659/* API: create stream */ 
    624 static pj_status_t ios_factory_create_stream( 
     660static pj_status_t darwin_factory_create_stream( 
    625661                                        pjmedia_vid_dev_factory *f, 
    626662                                        pjmedia_vid_dev_param *param, 
     
    629665                                        pjmedia_vid_dev_stream **p_vid_strm) 
    630666{ 
    631     struct ios_factory *qf = (struct ios_factory*)f; 
     667    struct darwin_factory *qf = (struct darwin_factory*)f; 
    632668    pj_pool_t *pool; 
    633     struct ios_stream *strm; 
     669    struct darwin_stream *strm; 
    634670    pjmedia_video_format_detail *vfd; 
    635671    const pjmedia_video_format_info *vfi; 
    636672    pj_status_t status = PJ_SUCCESS; 
    637     ios_fmt_info *ifi = get_ios_format_info(param->fmt.id); 
     673    darwin_fmt_info *ifi = get_darwin_format_info(param->fmt.id); 
    638674 
    639675    PJ_ASSERT_RETURN(f && param && p_vid_strm, PJ_EINVAL); 
     
    644680                     PJ_EINVAL); 
    645681 
    646     if (!(ifi = get_ios_format_info(param->fmt.id))) 
     682    if (!(ifi = get_darwin_format_info(param->fmt.id))) 
    647683        return PJMEDIA_EVID_BADFORMAT; 
    648684     
     
    652688 
    653689    /* Create and Initialize stream descriptor */ 
    654     pool = pj_pool_create(qf->pf, "ios-dev", 4000, 4000, NULL); 
     690    pool = pj_pool_create(qf->pf, "darwin-dev", 4000, 4000, NULL); 
    655691    PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM); 
    656692 
    657     strm = PJ_POOL_ZALLOC_T(pool, struct ios_stream); 
     693    strm = PJ_POOL_ZALLOC_T(pool, struct darwin_stream); 
    658694    pj_memcpy(&strm->param, param, sizeof(*param)); 
    659695    strm->pool = pool; 
     
    681717        AVCaptureDevice *dev = qf->dev_info[param->cap_id].dev; 
    682718  
    683         for (i = PJ_ARRAY_SIZE(ios_sizes)-1; i > 0; --i) { 
    684             if (((vfd->size.w == ios_sizes[i].supported_size_w) && 
    685                  (vfd->size.h == ios_sizes[i].supported_size_h)) || 
    686                 ((vfd->size.w == ios_sizes[i].supported_size_h) && 
    687                  (vfd->size.h == ios_sizes[i].supported_size_w))) 
     719        for (i = PJ_ARRAY_SIZE(darwin_sizes)-1; i > 0; --i) { 
     720            if (((vfd->size.w == darwin_sizes[i].supported_size_w) && 
     721                 (vfd->size.h == darwin_sizes[i].supported_size_h)) || 
     722                ((vfd->size.w == darwin_sizes[i].supported_size_h) && 
     723                 (vfd->size.h == darwin_sizes[i].supported_size_w))) 
    688724            { 
    689725                break; 
     
    691727        } 
    692728         
    693         strm->cap_session.sessionPreset = ios_sizes[i].preset_str; 
     729        strm->cap_session.sessionPreset = darwin_sizes[i].preset_str; 
    694730         
    695731        /* If the requested size is portrait (or landscape), we make 
     
    697733         */ 
    698734        if (vfd->size.w > vfd->size.h) { 
    699             vfd->size.w = ios_sizes[i].supported_size_w; 
    700             vfd->size.h = ios_sizes[i].supported_size_h; 
     735            vfd->size.w = darwin_sizes[i].supported_size_w; 
     736            vfd->size.h = darwin_sizes[i].supported_size_h; 
    701737        } else { 
    702             vfd->size.h = ios_sizes[i].supported_size_w; 
    703             vfd->size.w = ios_sizes[i].supported_size_h; 
     738            vfd->size.h = darwin_sizes[i].supported_size_w; 
     739            vfd->size.w = darwin_sizes[i].supported_size_h; 
    704740        } 
    705741        strm->size = vfd->size; 
     
    711747        param->fmt = strm->param.fmt; 
    712748 
    713         /* Set frame rate, this may only work on iOS 7 or later */ 
     749#if TARGET_OS_IPHONE 
     750        /* Set frame rate, this may only work on iOS 7 or later. 
     751         * On Mac, this may raise an exception if we set it to a value 
     752         * unsupported by the device. We need to query 
     753         * activeFormat.videoSupportedFrameRateRanges to get the valid 
     754         * range. 
     755         */ 
    714756        if ([dev respondsToSelector:@selector(activeVideoMinFrameDuration)] && 
    715757            [dev lockForConfiguration:NULL]) 
    716758        { 
    717759            dev.activeVideoMinFrameDuration = CMTimeMake(vfd->fps.denum, 
    718                                                             vfd->fps.num); 
     760                                                         vfd->fps.num); 
    719761            dev.activeVideoMaxFrameDuration = CMTimeMake(vfd->fps.denum, 
    720                                                             vfd->fps.num); 
     762                                                         vfd->fps.num); 
    721763            [dev unlockForConfiguration]; 
    722764        } 
     765#endif 
    723766         
    724767        /* Add the video device to the session as a device input */ 
     
    752795        strm->video_output.videoSettings = 
    753796            [NSDictionary dictionaryWithObjectsAndKeys: 
    754                           [NSNumber numberWithInt:ifi->ios_format], 
     797                          [NSNumber numberWithInt:ifi->darwin_format], 
    755798                          kCVPixelBufferPixelFormatTypeKey, nil]; 
    756799 
     
    776819        /* Native preview */ 
    777820        if (param->flags & PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW) { 
    778             ios_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW, 
     821            darwin_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW, 
    779822                               &param->native_preview); 
    780823        } 
     
    789832            if (param->orient == PJMEDIA_ORIENT_UNKNOWN) 
    790833                param->orient = PJMEDIA_ORIENT_NATURAL; 
    791             ios_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_ORIENTATION, 
     834            darwin_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_ORIENTATION, 
    792835                               &param->orient); 
    793836        } 
    794837         
    795838    } else if (param->dir & PJMEDIA_DIR_RENDER) { 
    796  
     839#if TARGET_OS_IPHONE 
    797840        /* Create renderer stream here */ 
    798841         
    799         status = ios_init_view(strm); 
     842        status = darwin_init_view(strm); 
    800843        if (status != PJ_SUCCESS) 
    801844            goto on_error; 
     
    811854                                            strm->render_buf, strm->frame_size, 
    812855                                            NULL); 
     856#endif 
    813857    } 
    814858     
     
    820864     
    821865on_error: 
    822     ios_stream_destroy((pjmedia_vid_dev_stream *)strm); 
     866    darwin_stream_destroy((pjmedia_vid_dev_stream *)strm); 
    823867     
    824868    return status; 
     
    826870 
    827871/* API: Get stream info. */ 
    828 static pj_status_t ios_stream_get_param(pjmedia_vid_dev_stream *s, 
    829                                         pjmedia_vid_dev_param *pi) 
    830 { 
    831     struct ios_stream *strm = (struct ios_stream*)s; 
     872static pj_status_t darwin_stream_get_param(pjmedia_vid_dev_stream *s, 
     873                                           pjmedia_vid_dev_param *pi) 
     874{ 
     875    struct darwin_stream *strm = (struct darwin_stream*)s; 
    832876 
    833877    PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL); 
     
    839883 
    840884/* API: get capability */ 
    841 static pj_status_t ios_stream_get_cap(pjmedia_vid_dev_stream *s, 
    842                                       pjmedia_vid_dev_cap cap, 
    843                                       void *pval) 
    844 { 
    845     struct ios_stream *strm = (struct ios_stream*)s; 
     885static pj_status_t darwin_stream_get_cap(pjmedia_vid_dev_stream *s, 
     886                                         pjmedia_vid_dev_cap cap, 
     887                                         void *pval) 
     888{ 
     889    struct darwin_stream *strm = (struct darwin_stream*)s; 
    846890     
    847891    PJ_ASSERT_RETURN(s && pval, PJ_EINVAL); 
     892    PJ_UNUSED_ARG(strm); 
    848893 
    849894    switch (cap) { 
     895#if TARGET_OS_IPHONE 
    850896        case PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW: 
    851897        { 
     
    855901            return PJ_SUCCESS; 
    856902        } 
    857              
     903#endif /* TARGET_OS_IPHONE */ 
    858904        default: 
    859905            break; 
     
    864910 
    865911/* API: set capability */ 
    866 static pj_status_t ios_stream_set_cap(pjmedia_vid_dev_stream *s, 
    867                                       pjmedia_vid_dev_cap cap, 
    868                                       const void *pval) 
    869 { 
    870     struct ios_stream *strm = (struct ios_stream*)s; 
     912static pj_status_t darwin_stream_set_cap(pjmedia_vid_dev_stream *s, 
     913                                         pjmedia_vid_dev_cap cap, 
     914                                         const void *pval) 
     915{ 
     916    struct darwin_stream *strm = (struct darwin_stream*)s; 
    871917 
    872918    PJ_ASSERT_RETURN(s && pval, PJ_EINVAL); 
     
    902948                return PJ_EINVALIDOP; 
    903949             
     950#if TARGET_OS_IPHONE 
    904951            /* Create view, if none */ 
    905952            if (!strm->render_view) 
    906                 ios_init_view(strm); 
     953                darwin_init_view(strm); 
    907954             
    908955            /* Preview layer instantiation should be in main thread! */ 
     
    920967            }); 
    921968            PJ_LOG(4, (THIS_FILE, "Native preview initialized")); 
     969#endif 
    922970             
    923971            return PJ_SUCCESS; 
     
    930978             
    931979            NSError *error; 
    932             struct ios_dev_info* di = strm->factory->dev_info; 
     980            struct darwin_dev_info* di = strm->factory->dev_info; 
    933981            pjmedia_vid_dev_switch_param *p = 
    934982                                    (pjmedia_vid_dev_switch_param*)pval; 
     
    9641012             
    9651013            /* Set the orientation as well */ 
    966             ios_stream_set_cap(s, PJMEDIA_VID_DEV_CAP_ORIENTATION, 
     1014            darwin_stream_set_cap(s, PJMEDIA_VID_DEV_CAP_ORIENTATION, 
    9671015                               &strm->param.orient); 
    9681016             
     
    9701018        } 
    9711019         
     1020#if TARGET_OS_IPHONE 
    9721021        case PJMEDIA_VID_DEV_CAP_FORMAT: 
    9731022        { 
     
    9751024            pjmedia_video_format_detail *vfd; 
    9761025            pjmedia_format *fmt = (pjmedia_format *)pval; 
    977             ios_fmt_info *ifi; 
    978          
    979             if (!(ifi = get_ios_format_info(fmt->id))) 
     1026            darwin_fmt_info *ifi; 
     1027         
     1028            if (!(ifi = get_darwin_format_info(fmt->id))) 
    9801029                return PJMEDIA_EVID_BADFORMAT; 
    9811030         
     
    10521101            return PJ_SUCCESS; 
    10531102        } 
    1054              
     1103#endif /* TARGET_OS_IPHONE */ 
     1104         
    10551105        case PJMEDIA_VID_DEV_CAP_ORIENTATION: 
    10561106        { 
     
    10671117         
    10681118            if (strm->param.dir == PJMEDIA_DIR_RENDER) { 
     1119#if TARGET_OS_IPHONE 
    10691120                dispatch_async(dispatch_get_main_queue(), ^{ 
    10701121                    strm->render_view.transform = 
     
    10721123                            ((int)strm->param.orient-1) * -M_PI_2); 
    10731124                }); 
     1125#endif 
    10741126 
    10751127                return PJ_SUCCESS; 
     
    11421194 
    11431195/* API: Start stream. */ 
    1144 static pj_status_t ios_stream_start(pjmedia_vid_dev_stream *strm) 
    1145 { 
    1146     struct ios_stream *stream = (struct ios_stream*)strm; 
     1196static pj_status_t darwin_stream_start(pjmedia_vid_dev_stream *strm) 
     1197{ 
     1198    struct darwin_stream *stream = (struct darwin_stream*)strm; 
    11471199 
    11481200    PJ_UNUSED_ARG(stream); 
    11491201 
    1150     PJ_LOG(4, (THIS_FILE, "Starting iOS video stream")); 
     1202    PJ_LOG(4, (THIS_FILE, "Starting Darwin video stream")); 
    11511203 
    11521204    if (stream->cap_session) { 
     
    11601212     
    11611213        if (![stream->cap_session isRunning]) { 
    1162             PJ_LOG(3, (THIS_FILE, "Unable to start iOS capture session")); 
     1214            PJ_LOG(3, (THIS_FILE, "Unable to start AVFoundation capture " 
     1215                                  "session")); 
    11631216            return PJ_EUNKNOWN; 
    11641217        } 
     
    11701223 
    11711224/* API: Put frame from stream */ 
    1172 static pj_status_t ios_stream_put_frame(pjmedia_vid_dev_stream *strm, 
    1173                                         const pjmedia_frame *frame) 
    1174 { 
    1175     struct ios_stream *stream = (struct ios_stream*)strm; 
     1225static pj_status_t darwin_stream_put_frame(pjmedia_vid_dev_stream *strm, 
     1226                                           const pjmedia_frame *frame) 
     1227{ 
     1228#if TARGET_OS_IPHONE 
     1229    struct darwin_stream *stream = (struct darwin_stream*)strm; 
    11761230 
    11771231    if (stream->frame_size >= frame->size) 
     
    11841238        [stream->vout_delegate update_image]; 
    11851239    }); 
    1186      
     1240#endif 
     1241 
    11871242    return PJ_SUCCESS; 
    11881243} 
    11891244 
    11901245/* API: Stop stream. */ 
    1191 static pj_status_t ios_stream_stop(pjmedia_vid_dev_stream *strm) 
    1192 { 
    1193     struct ios_stream *stream = (struct ios_stream*)strm; 
     1246static pj_status_t darwin_stream_stop(pjmedia_vid_dev_stream *strm) 
     1247{ 
     1248    struct darwin_stream *stream = (struct darwin_stream*)strm; 
    11941249 
    11951250    if (!stream->cap_session || ![stream->cap_session isRunning]) 
    11961251        return PJ_SUCCESS; 
    11971252     
    1198     PJ_LOG(4, (THIS_FILE, "Stopping iOS video stream")); 
     1253    PJ_LOG(4, (THIS_FILE, "Stopping Darwin video stream")); 
    11991254 
    12001255    if ([NSThread isMainThread]) { 
     
    12111266 
    12121267/* API: Destroy stream. */ 
    1213 static pj_status_t ios_stream_destroy(pjmedia_vid_dev_stream *strm) 
    1214 { 
    1215     struct ios_stream *stream = (struct ios_stream*)strm; 
     1268static pj_status_t darwin_stream_destroy(pjmedia_vid_dev_stream *strm) 
     1269{ 
     1270    struct darwin_stream *stream = (struct darwin_stream*)strm; 
    12161271 
    12171272    PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL); 
    12181273 
    1219     ios_stream_stop(strm); 
     1274    darwin_stream_stop(strm); 
    12201275     
    12211276    if (stream->cap_session) { 
     
    12391294    } 
    12401295 
     1296#if TARGET_OS_IPHONE 
    12411297    if (stream->prev_layer) { 
    12421298        CALayer *prev_layer = stream->prev_layer; 
     
    12611317        stream->render_data_provider = nil; 
    12621318    } 
     1319#endif /* TARGET_OS_IPHONE */ 
    12631320 
    12641321    if (stream->queue) { 
     
    12791336} 
    12801337 
    1281 #endif  /* __IPHONE_4_0 */ 
    1282 #endif  /* PJMEDIA_VIDEO_DEV_HAS_IOS */ 
     1338#endif  /* PJMEDIA_VIDEO_DEV_HAS_DARWIN */ 
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/videodev.c

    r5255 r5347  
    5656#endif 
    5757 
    58 #if PJMEDIA_VIDEO_DEV_HAS_IOS 
    59 pjmedia_vid_dev_factory* pjmedia_ios_factory(pj_pool_factory *pf); 
     58#if PJMEDIA_VIDEO_DEV_HAS_DARWIN 
     59pjmedia_vid_dev_factory* pjmedia_darwin_factory(pj_pool_factory *pf); 
    6060#endif 
    6161 
     
    106106    vid_subsys->drv[vid_subsys->drv_cnt++].create = &pjmedia_opengl_factory; 
    107107#endif 
    108 #if PJMEDIA_VIDEO_DEV_HAS_IOS 
    109     vid_subsys->drv[vid_subsys->drv_cnt++].create = &pjmedia_ios_factory; 
     108#if PJMEDIA_VIDEO_DEV_HAS_DARWIN 
     109    vid_subsys->drv[vid_subsys->drv_cnt++].create = &pjmedia_darwin_factory; 
    110110#endif 
    111111#if PJMEDIA_VIDEO_DEV_HAS_DSHOW 
Note: See TracChangeset for help on using the changeset viewer.