Changeset 5347
- Timestamp:
- Jun 16, 2016 10:38:34 AM (8 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/aconfigure
r5303 r5347 670 670 ac_qt_cflags 671 671 ac_pjmedia_video_has_qt 672 ac_ios_cflags 673 ac_pjmedia_video_has_ios 672 ac_darwin_cflags 673 ac_pjmedia_video_has_ios_opengl 674 ac_pjmedia_video_has_darwin 674 675 ac_android_cflags 675 676 ac_pjmedia_video_has_android … … 6279 6280 ac_android_cflags="$ac_android_cflags -DPJMEDIA_VIDEO_DEV_HAS_ANDROID=1" 6280 6281 ;; 6281 *-apple-darwin_ios*) 6282 ac_pjmedia_video=iphone_os 6282 *darwin*) 6283 ac_pjmedia_video=darwin_os 6284 6283 6285 6284 6286 … … 6297 6299 _ACEOF 6298 6300 if 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 6302 else 6303 ac_pjmedia_video_has_darwin=no 6304 fi 6305 rm -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 6311 int 6312 main () 6313 { 6314 6315 ; 6316 return 0; 6317 } 6318 _ACEOF 6319 if ac_fn_c_try_link "$LINENO"; then : 6320 ac_pjmedia_video_has_ios_opengl=yes 6321 else 6322 ac_pjmedia_video_has_ios_opengl=no 6302 6323 fi 6303 6324 rm -f core conftest.err conftest.$ac_objext \ 6304 6325 conftest$ac_exeext conftest.$ac_ext 6305 6326 LIBS="$SAVED_LIBS" 6306 if test "$ac_pjmedia_video_has_ ios" = "yes"; then6307 ac_ ios_cflags="-DPJMEDIA_VIDEO_DEV_HAS_IOS=1 -DPJMEDIA_VIDEO_DEV_HAS_IOS_OPENGL=1"6308 LIBS="$LIBS -framework OpenGLES -frameworkAVFoundation -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" 6309 6330 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if AVFoundation framework is available... yes" >&5 6310 6331 $as_echo "Checking if AVFoundation framework is available... yes" >&6; } … … 6313 6334 $as_echo "Checking if AVFoundation framework is available... no" >&6; } 6314 6335 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 6323 6353 /* end confdefs.h. */ 6324 6354 … … 6338 6368 rm -f core conftest.err conftest.$ac_objext \ 6339 6369 conftest$ac_exeext conftest.$ac_ext 6340 LIBS="$SAVED_LIBS"6341 if test "$ac_pjmedia_video_has_qt" = "yes"; then6342 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" >&56370 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 6345 6375 $as_echo "Checking if QTKit framework is available... yes" >&6; } 6346 else6347 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if QTKit framework is available... no" >&56376 else 6377 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if QTKit framework is available... no" >&5 6348 6378 $as_echo "Checking if QTKit framework is available... no" >&6; } 6349 fi 6350 ;; 6379 fi 6380 fi 6381 ;; 6351 6382 esac 6352 6383 fi -
pjproject/trunk/aconfigure.ac
r5310 r5347 734 734 ac_android_cflags="$ac_android_cflags -DPJMEDIA_VIDEO_DEV_HAS_ANDROID=1" 735 735 ;; 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) 740 741 SAVED_LIBS="$LIBS" 741 742 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]) 743 750 LIBS="$SAVED_LIBS" 744 if test "$ac_pjmedia_video_has_ ios" = "yes"; then745 ac_ ios_cflags="-DPJMEDIA_VIDEO_DEV_HAS_IOS=1 -DPJMEDIA_VIDEO_DEV_HAS_IOS_OPENGL=1"746 LIBS="$LIBS -framework OpenGLES -frameworkAVFoundation -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" 747 754 AC_MSG_RESULT([Checking if AVFoundation framework is available... yes]) 748 755 else 749 756 AC_MSG_RESULT([Checking if AVFoundation framework is available... no]) 750 757 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]) 764 762 else 765 AC_MSG_RESULT([Checking if QTKitframework is available... no])763 AC_MSG_RESULT([Checking if OpenGLES framework is available... no]) 766 764 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 ;; 768 783 esac 769 784 fi -
pjproject/trunk/build.mak.in
r5086 r5347 148 148 # QT 149 149 AC_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) 153 AC_PJMEDIA_VIDEO_HAS_DARWIN = @ac_pjmedia_video_has_darwin@ 154 AC_PJMEDIA_VIDEO_HAS_IOS_OPENGL = @ac_pjmedia_video_has_ios_opengl@ 155 DARWIN_CFLAGS = @ac_darwin_cflags@ 154 156 155 157 # Android … … 162 164 # PJMEDIA features exclusion 163 165 PJ_VIDEO_CFLAGS += $(SDL_CFLAGS) $(FFMPEG_CFLAGS) $(V4L2_CFLAGS) $(QT_CFLAGS) \ 164 $(OPENH264_CFLAGS) $( IOS_CFLAGS) $(LIBYUV_CFLAGS)166 $(OPENH264_CFLAGS) $(DARWIN_CFLAGS) $(LIBYUV_CFLAGS) 165 167 PJ_VIDEO_LDFLAGS += $(SDL_LDFLAGS) $(FFMPEG_LDFLAGS) $(V4L2_LDFLAGS) \ 166 168 $(OPENH264_LDFLAGS) $(LIBYUV_LDFLAGS) -
pjproject/trunk/pjmedia/build/os-auto.mak.in
r5268 r5347 3 3 # Define the desired video device backend 4 4 # Valid values are: 5 # - mac_os 6 # - iphone_os 5 # - darwin_os 7 6 # - android_os 8 7 AC_PJMEDIA_VIDEO = @ac_pjmedia_video@ … … 22 21 # QT 23 22 AC_PJMEDIA_VIDEO_HAS_QT = @ac_pjmedia_video_has_qt@ 24 QT_CFLAGS = @ac_qt_cflags@25 26 # iOS27 IOS_CFLAGS = @ac_ios_cflags@23 # QT_CFLAGS = @ac_qt_cflags@ 24 25 # Darwin (Mac and iOS) 26 DARWIN_CFLAGS = @ac_darwin_cflags@ 28 27 29 28 # Android … … 46 45 export CFLAGS += @ac_no_small_filter@ @ac_no_large_filter@ @ac_no_speex_aec@ \ 47 46 $(SDL_CFLAGS) $(FFMPEG_CFLAGS) $(V4L2_CFLAGS) $(QT_CFLAGS) \ 48 $( IOS_CFLAGS) $(ANDROID_CFLAGS) $(LIBYUV_CFLAGS) \47 $(DARWIN_CFLAGS) $(ANDROID_CFLAGS) $(LIBYUV_CFLAGS) \ 49 48 $(OPENH264_CFLAGS) $(WEBRTC_CFLAGS) 50 49 export LDFLAGS += $(SDL_LDFLAGS) $(FFMPEG_LDFLAGS) $(V4L2_LDFLAGS) \ … … 249 248 250 249 # 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 # 252 ifeq ($(AC_PJMEDIA_VIDEO_HAS_DARWIN),yes) 253 export PJMEDIA_VIDEODEV_OBJS += darwin_dev.o 254 endif 255 256 # 257 # iOS OpenGL video device 258 # 259 ifeq ($(AC_PJMEDIA_VIDEO_HAS_IOS_OPENGL),yes) 260 export PJMEDIA_VIDEODEV_OBJS += ios_opengl_dev.o 255 261 endif 256 262 … … 266 272 # source code 267 273 # 268 ifneq (,$(filter $(AC_PJMEDIA_VIDEO), mac_os iphone_os))274 ifneq (,$(filter $(AC_PJMEDIA_VIDEO),darwin_os)) 269 275 # Mac and iPhone OS specific, use obj-c 270 276 export PJMEDIA_VIDEODEV_OBJS += sdl_dev_m.o -
pjproject/trunk/pjmedia/src/pjmedia-videodev/darwin_dev.m
r5344 r5347 24 24 25 25 #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 32 35 #import <AVFoundation/AVFoundation.h> 33 36 #import <QuartzCore/QuartzCore.h> 34 37 35 #define THIS_FILE " ios_dev.c"38 #define THIS_FILE "darwin_dev.c" 36 39 #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 39 47 #define DEFAULT_FPS 15 40 48 … … 44 52 #define MAINTAIN_ASPECT_RATIO PJ_TRUE 45 53 46 typedef struct ios_fmt_info54 typedef struct darwin_fmt_info 47 55 { 48 56 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 60 static 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 54 66 { PJMEDIA_FORMAT_BGRA, kCVPixelFormatType_32BGRA }, 55 67 { PJMEDIA_FORMAT_I420, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange } 56 68 }; 57 69 58 typedef struct ios_supported_size70 typedef struct darwin_supported_size 59 71 { 60 72 pj_size_t supported_size_w; 61 73 pj_size_t supported_size_h; 62 74 NSString *preset_str; 63 } ios_supported_size;75 } darwin_supported_size; 64 76 65 77 /* Set the preset_str on set_preset_str method. */ 66 static ios_supported_size ios_sizes[] = 67 { 78 static darwin_supported_size darwin_sizes[] = 79 { 80 #if TARGET_OS_IPHONE 68 81 { 352, 288, NULL }, 69 82 { 640, 480, NULL }, 70 83 { 1280, 720, NULL }, 71 84 { 1920, 1080, NULL } 85 #else 86 { 1280, 720, NULL } 87 #endif 72 88 }; 73 89 74 /* iosdevice info */75 struct ios_dev_info90 /* darwin device info */ 91 struct darwin_dev_info 76 92 { 77 93 pjmedia_vid_dev_info info; … … 79 95 }; 80 96 81 /* iosfactory */82 struct ios_factory97 /* darwin factory */ 98 struct darwin_factory 83 99 { 84 100 pjmedia_vid_dev_factory base; … … 87 103 88 104 unsigned dev_count; 89 struct ios_dev_info*dev_info;105 struct darwin_dev_info *dev_info; 90 106 }; 91 107 … … 94 110 { 95 111 @public 96 struct ios_stream *stream;112 struct darwin_stream *stream; 97 113 } 98 114 @end 99 115 100 116 /* Video stream. */ 101 struct ios_stream117 struct darwin_stream 102 118 { 103 119 pjmedia_vid_dev_stream base; /**< Base stream */ 104 120 pjmedia_vid_dev_param param; /**< Settings */ 105 121 pj_pool_t *pool; /**< Memory pool */ 106 struct ios_factory*factory; /**< Factory */122 struct darwin_factory *factory; /**< Factory */ 107 123 108 124 pjmedia_vid_dev_cb vid_cb; /**< Stream callback */ … … 127 143 AVCaptureVideoPreviewLayer *prev_layer; 128 144 145 #if TARGET_OS_IPHONE 129 146 void *render_buf; 130 147 pj_size_t render_buf_size; 131 148 CGDataProviderRef render_data_provider; 132 149 UIView *render_view; 133 150 #endif 151 134 152 pj_timestamp frame_ts; 135 153 unsigned ts_inc; … … 138 156 139 157 /* 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 149 unsigned index,150 pjmedia_vid_dev_param *param);151 static pj_status_t ios_factory_create_stream(158 static pj_status_t darwin_factory_init(pjmedia_vid_dev_factory *f); 159 static pj_status_t darwin_factory_destroy(pjmedia_vid_dev_factory *f); 160 static pj_status_t darwin_factory_refresh(pjmedia_vid_dev_factory *f); 161 static unsigned darwin_factory_get_dev_count(pjmedia_vid_dev_factory *f); 162 static pj_status_t darwin_factory_get_dev_info(pjmedia_vid_dev_factory *f, 163 unsigned index, 164 pjmedia_vid_dev_info *info); 165 static 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); 169 static pj_status_t darwin_factory_create_stream( 152 170 pjmedia_vid_dev_factory *f, 153 171 pjmedia_vid_dev_param *param, … … 156 174 pjmedia_vid_dev_stream **p_vid_strm); 157 175 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);176 static pj_status_t darwin_stream_get_param(pjmedia_vid_dev_stream *strm, 177 pjmedia_vid_dev_param *param); 178 static pj_status_t darwin_stream_get_cap(pjmedia_vid_dev_stream *strm, 179 pjmedia_vid_dev_cap cap, 180 void *value); 181 static pj_status_t darwin_stream_set_cap(pjmedia_vid_dev_stream *strm, 182 pjmedia_vid_dev_cap cap, 183 const void *value); 184 static pj_status_t darwin_stream_start(pjmedia_vid_dev_stream *strm); 185 static pj_status_t darwin_stream_get_frame(pjmedia_vid_dev_stream *strm, 186 pjmedia_frame *frame); 187 static pj_status_t darwin_stream_put_frame(pjmedia_vid_dev_stream *strm, 188 const pjmedia_frame *frame); 189 static pj_status_t darwin_stream_stop(pjmedia_vid_dev_stream *strm); 190 static pj_status_t darwin_stream_destroy(pjmedia_vid_dev_stream *strm); 173 191 174 192 /* Operations */ 175 193 static pjmedia_vid_dev_factory_op factory_op = 176 194 { 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_refresh195 &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 184 202 }; 185 203 186 204 static pjmedia_vid_dev_stream_op stream_op = 187 205 { 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_destroy206 &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 196 214 }; 197 215 198 216 static void set_preset_str() 199 217 { 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 204 226 } 205 227 … … 208 230 */ 209 231 /* 210 * Init ios_ video driver.232 * Init darwin_ video driver. 211 233 */ 212 pjmedia_vid_dev_factory* pjmedia_ ios_factory(pj_pool_factory *pf)213 { 214 struct ios_factory *f;234 pjmedia_vid_dev_factory* pjmedia_darwin_factory(pj_pool_factory *pf) 235 { 236 struct darwin_factory *f; 215 237 pj_pool_t *pool; 216 238 217 pool = pj_pool_create(pf, " iosvideo", 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); 219 241 f->pf = pf; 220 242 f->pool = pool; … … 226 248 227 249 /* 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;250 static 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; 232 254 unsigned i, l, first_idx, front_idx = -1; 233 255 enum { MAX_DEV_COUNT = 8 }; … … 236 258 237 259 /* Initialize input and output devices here */ 238 qf->dev_info = (struct ios_dev_info*)260 qf->dev_info = (struct darwin_dev_info*) 239 261 pj_pool_calloc(qf->pool, MAX_DEV_COUNT, 240 sizeof(struct ios_dev_info));262 sizeof(struct darwin_dev_info)); 241 263 qf->dev_count = 0; 242 264 265 #if TARGET_OS_IPHONE 243 266 /* Init output device */ 244 267 qdi = &qf->dev_info[qf->dev_count++]; … … 248 271 qdi->info.dir = PJMEDIA_DIR_RENDER; 249 272 qdi->info.has_callback = PJ_FALSE; 273 #endif 250 274 251 275 /* Init input device */ … … 269 293 pj_ansi_strncpy(qdi->info.name, [device.localizedName UTF8String], 270 294 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)); 272 296 qdi->info.dir = PJMEDIA_DIR_CAPTURE; 273 297 qdi->info.has_callback = PJ_FALSE; 298 #if TARGET_OS_IPHONE 274 299 qdi->info.caps = PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW | 275 300 PJMEDIA_VID_DEV_CAP_SWITCH; 301 #endif 276 302 qdi->dev = device; 277 303 } … … 280 306 /* Set front camera to be the first input device (as default dev) */ 281 307 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]; 283 309 qf->dev_info[first_idx] = qf->dev_info[front_idx]; 284 310 qf->dev_info[front_idx] = tmp_dev_info; … … 295 321 PJMEDIA_VID_DEV_CAP_ORIENTATION; 296 322 297 for (l = 0; l < PJ_ARRAY_SIZE( ios_fmts); l++) {323 for (l = 0; l < PJ_ARRAY_SIZE(darwin_fmts); l++) { 298 324 pjmedia_format *fmt; 299 325 300 326 /* Simple renderer UIView only supports BGRA */ 301 327 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) 303 329 { 304 330 continue; … … 308 334 fmt = &qdi->info.fmt[qdi->info.fmt_cnt++]; 309 335 pjmedia_format_init_video(fmt, 310 ios_fmts[l].pjmedia_format,336 darwin_fmts[l].pjmedia_format, 311 337 DEFAULT_WIDTH, 312 338 DEFAULT_HEIGHT, … … 317 343 318 344 /* 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; 321 348 m++) 322 349 { 323 350 if ([dev supportsAVCaptureSessionPreset: 324 ios_sizes[m].preset_str])351 darwin_sizes[m].preset_str]) 325 352 { 326 353 /* Landscape video */ 327 354 fmt = &qdi->info.fmt[qdi->info.fmt_cnt++]; 328 355 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 356 darwin_fmts[l].pjmedia_format, 357 darwin_sizes[m].supported_size_w, 358 darwin_sizes[m].supported_size_h, 359 DEFAULT_FPS, 1); 333 360 /* Portrait video */ 334 361 fmt = &qdi->info.fmt[qdi->info.fmt_cnt++]; 335 362 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 363 darwin_fmts[l].pjmedia_format, 364 darwin_sizes[m].supported_size_h, 365 darwin_sizes[m].supported_size_w, 366 DEFAULT_FPS, 1); 340 367 } 341 368 } … … 344 371 } 345 372 346 PJ_LOG(4, (THIS_FILE, " iOSvideo initialized with %d devices:",373 PJ_LOG(4, (THIS_FILE, "Darwin video initialized with %d devices:", 347 374 qf->dev_count)); 348 375 for (i = 0; i < qf->dev_count; i++) { … … 357 384 358 385 /* 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;386 static pj_status_t darwin_factory_destroy(pjmedia_vid_dev_factory *f) 387 { 388 struct darwin_factory *qf = (struct darwin_factory*)f; 362 389 pj_pool_t *pool = qf->pool; 363 390 … … 369 396 370 397 /* API: refresh the list of devices */ 371 static pj_status_t ios_factory_refresh(pjmedia_vid_dev_factory *f)398 static pj_status_t darwin_factory_refresh(pjmedia_vid_dev_factory *f) 372 399 { 373 400 PJ_UNUSED_ARG(f); … … 376 403 377 404 /* 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;405 static unsigned darwin_factory_get_dev_count(pjmedia_vid_dev_factory *f) 406 { 407 struct darwin_factory *qf = (struct darwin_factory*)f; 381 408 return qf->dev_count; 382 409 } 383 410 384 411 /* 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;412 static 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; 390 417 391 418 PJ_ASSERT_RETURN(index < qf->dev_count, PJMEDIA_EVID_INVDEV); … … 397 424 398 425 /* 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;426 static 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; 406 433 407 434 PJ_ASSERT_RETURN(index < qf->dev_count, PJMEDIA_EVID_INVDEV); … … 431 458 432 459 @implementation VOutDelegate 460 #if TARGET_OS_IPHONE 433 461 - (void)update_image 434 462 { … … 447 475 448 476 [pool release]; 449 } 477 } 478 #endif 450 479 451 480 - (void)captureOutput:(AVCaptureOutput *)captureOutput … … 474 503 475 504 [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 476 510 if (stream->is_planar && stream->capture_buf) { 477 511 if (stream->param.fmt.id == PJMEDIA_FORMAT_I420) { … … 552 586 @end 553 587 554 static pj_status_t ios_stream_get_frame(pjmedia_vid_dev_stream *strm,588 static pj_status_t darwin_stream_get_frame(pjmedia_vid_dev_stream *strm, 555 589 pjmedia_frame *frame) 556 590 { 557 struct ios_stream *stream = (struct ios_stream *)strm;591 struct darwin_stream *stream = (struct darwin_stream *)strm; 558 592 559 593 frame->type = PJMEDIA_FRAME_TYPE_VIDEO; … … 571 605 572 606 573 static ios_fmt_info* get_ios_format_info(pjmedia_format_id id)607 static darwin_fmt_info* get_darwin_format_info(pjmedia_format_id id) 574 608 { 575 609 unsigned i; 576 610 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]; 580 614 } 581 615 … … 584 618 585 619 586 static pj_status_t ios_init_view(struct ios_stream *strm) 620 #if TARGET_OS_IPHONE 621 static pj_status_t darwin_init_view(struct darwin_stream *strm) 587 622 { 588 623 pjmedia_vid_dev_param *param = &strm->param; … … 602 637 strm->render_view = [[UIView alloc] initWithFrame:view_rect]; 603 638 strm->param.window.info.ios.window = strm->render_view; 604 639 605 640 if (param->flags & PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW) { 606 641 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, 608 643 param->window.info.ios.window); 609 644 } 610 645 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, 612 647 ¶m->window_hide); 613 648 } 614 649 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, 616 651 ¶m->orient); 617 652 } … … 619 654 return PJ_SUCCESS; 620 655 } 656 #endif /* TARGET_OS_IPHONE */ 621 657 622 658 623 659 /* API: create stream */ 624 static pj_status_t ios_factory_create_stream(660 static pj_status_t darwin_factory_create_stream( 625 661 pjmedia_vid_dev_factory *f, 626 662 pjmedia_vid_dev_param *param, … … 629 665 pjmedia_vid_dev_stream **p_vid_strm) 630 666 { 631 struct ios_factory *qf = (struct ios_factory*)f;667 struct darwin_factory *qf = (struct darwin_factory*)f; 632 668 pj_pool_t *pool; 633 struct ios_stream *strm;669 struct darwin_stream *strm; 634 670 pjmedia_video_format_detail *vfd; 635 671 const pjmedia_video_format_info *vfi; 636 672 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); 638 674 639 675 PJ_ASSERT_RETURN(f && param && p_vid_strm, PJ_EINVAL); … … 644 680 PJ_EINVAL); 645 681 646 if (!(ifi = get_ ios_format_info(param->fmt.id)))682 if (!(ifi = get_darwin_format_info(param->fmt.id))) 647 683 return PJMEDIA_EVID_BADFORMAT; 648 684 … … 652 688 653 689 /* 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); 655 691 PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM); 656 692 657 strm = PJ_POOL_ZALLOC_T(pool, struct ios_stream);693 strm = PJ_POOL_ZALLOC_T(pool, struct darwin_stream); 658 694 pj_memcpy(&strm->param, param, sizeof(*param)); 659 695 strm->pool = pool; … … 681 717 AVCaptureDevice *dev = qf->dev_info[param->cap_id].dev; 682 718 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))) 688 724 { 689 725 break; … … 691 727 } 692 728 693 strm->cap_session.sessionPreset = ios_sizes[i].preset_str;729 strm->cap_session.sessionPreset = darwin_sizes[i].preset_str; 694 730 695 731 /* If the requested size is portrait (or landscape), we make … … 697 733 */ 698 734 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; 701 737 } 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; 704 740 } 705 741 strm->size = vfd->size; … … 711 747 param->fmt = strm->param.fmt; 712 748 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 */ 714 756 if ([dev respondsToSelector:@selector(activeVideoMinFrameDuration)] && 715 757 [dev lockForConfiguration:NULL]) 716 758 { 717 759 dev.activeVideoMinFrameDuration = CMTimeMake(vfd->fps.denum, 718 760 vfd->fps.num); 719 761 dev.activeVideoMaxFrameDuration = CMTimeMake(vfd->fps.denum, 720 762 vfd->fps.num); 721 763 [dev unlockForConfiguration]; 722 764 } 765 #endif 723 766 724 767 /* Add the video device to the session as a device input */ … … 752 795 strm->video_output.videoSettings = 753 796 [NSDictionary dictionaryWithObjectsAndKeys: 754 [NSNumber numberWithInt:ifi-> ios_format],797 [NSNumber numberWithInt:ifi->darwin_format], 755 798 kCVPixelBufferPixelFormatTypeKey, nil]; 756 799 … … 776 819 /* Native preview */ 777 820 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, 779 822 ¶m->native_preview); 780 823 } … … 789 832 if (param->orient == PJMEDIA_ORIENT_UNKNOWN) 790 833 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, 792 835 ¶m->orient); 793 836 } 794 837 795 838 } else if (param->dir & PJMEDIA_DIR_RENDER) { 796 839 #if TARGET_OS_IPHONE 797 840 /* Create renderer stream here */ 798 841 799 status = ios_init_view(strm);842 status = darwin_init_view(strm); 800 843 if (status != PJ_SUCCESS) 801 844 goto on_error; … … 811 854 strm->render_buf, strm->frame_size, 812 855 NULL); 856 #endif 813 857 } 814 858 … … 820 864 821 865 on_error: 822 ios_stream_destroy((pjmedia_vid_dev_stream *)strm);866 darwin_stream_destroy((pjmedia_vid_dev_stream *)strm); 823 867 824 868 return status; … … 826 870 827 871 /* 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;872 static 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; 832 876 833 877 PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL); … … 839 883 840 884 /* 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;885 static 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; 846 890 847 891 PJ_ASSERT_RETURN(s && pval, PJ_EINVAL); 892 PJ_UNUSED_ARG(strm); 848 893 849 894 switch (cap) { 895 #if TARGET_OS_IPHONE 850 896 case PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW: 851 897 { … … 855 901 return PJ_SUCCESS; 856 902 } 857 903 #endif /* TARGET_OS_IPHONE */ 858 904 default: 859 905 break; … … 864 910 865 911 /* 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;912 static 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; 871 917 872 918 PJ_ASSERT_RETURN(s && pval, PJ_EINVAL); … … 902 948 return PJ_EINVALIDOP; 903 949 950 #if TARGET_OS_IPHONE 904 951 /* Create view, if none */ 905 952 if (!strm->render_view) 906 ios_init_view(strm);953 darwin_init_view(strm); 907 954 908 955 /* Preview layer instantiation should be in main thread! */ … … 920 967 }); 921 968 PJ_LOG(4, (THIS_FILE, "Native preview initialized")); 969 #endif 922 970 923 971 return PJ_SUCCESS; … … 930 978 931 979 NSError *error; 932 struct ios_dev_info* di = strm->factory->dev_info;980 struct darwin_dev_info* di = strm->factory->dev_info; 933 981 pjmedia_vid_dev_switch_param *p = 934 982 (pjmedia_vid_dev_switch_param*)pval; … … 964 1012 965 1013 /* 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, 967 1015 &strm->param.orient); 968 1016 … … 970 1018 } 971 1019 1020 #if TARGET_OS_IPHONE 972 1021 case PJMEDIA_VID_DEV_CAP_FORMAT: 973 1022 { … … 975 1024 pjmedia_video_format_detail *vfd; 976 1025 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))) 980 1029 return PJMEDIA_EVID_BADFORMAT; 981 1030 … … 1052 1101 return PJ_SUCCESS; 1053 1102 } 1054 1103 #endif /* TARGET_OS_IPHONE */ 1104 1055 1105 case PJMEDIA_VID_DEV_CAP_ORIENTATION: 1056 1106 { … … 1067 1117 1068 1118 if (strm->param.dir == PJMEDIA_DIR_RENDER) { 1119 #if TARGET_OS_IPHONE 1069 1120 dispatch_async(dispatch_get_main_queue(), ^{ 1070 1121 strm->render_view.transform = … … 1072 1123 ((int)strm->param.orient-1) * -M_PI_2); 1073 1124 }); 1125 #endif 1074 1126 1075 1127 return PJ_SUCCESS; … … 1142 1194 1143 1195 /* 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;1196 static pj_status_t darwin_stream_start(pjmedia_vid_dev_stream *strm) 1197 { 1198 struct darwin_stream *stream = (struct darwin_stream*)strm; 1147 1199 1148 1200 PJ_UNUSED_ARG(stream); 1149 1201 1150 PJ_LOG(4, (THIS_FILE, "Starting iOSvideo stream"));1202 PJ_LOG(4, (THIS_FILE, "Starting Darwin video stream")); 1151 1203 1152 1204 if (stream->cap_session) { … … 1160 1212 1161 1213 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")); 1163 1216 return PJ_EUNKNOWN; 1164 1217 } … … 1170 1223 1171 1224 /* 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; 1225 static 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; 1176 1230 1177 1231 if (stream->frame_size >= frame->size) … … 1184 1238 [stream->vout_delegate update_image]; 1185 1239 }); 1186 1240 #endif 1241 1187 1242 return PJ_SUCCESS; 1188 1243 } 1189 1244 1190 1245 /* 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;1246 static pj_status_t darwin_stream_stop(pjmedia_vid_dev_stream *strm) 1247 { 1248 struct darwin_stream *stream = (struct darwin_stream*)strm; 1194 1249 1195 1250 if (!stream->cap_session || ![stream->cap_session isRunning]) 1196 1251 return PJ_SUCCESS; 1197 1252 1198 PJ_LOG(4, (THIS_FILE, "Stopping iOSvideo stream"));1253 PJ_LOG(4, (THIS_FILE, "Stopping Darwin video stream")); 1199 1254 1200 1255 if ([NSThread isMainThread]) { … … 1211 1266 1212 1267 /* 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;1268 static pj_status_t darwin_stream_destroy(pjmedia_vid_dev_stream *strm) 1269 { 1270 struct darwin_stream *stream = (struct darwin_stream*)strm; 1216 1271 1217 1272 PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL); 1218 1273 1219 ios_stream_stop(strm);1274 darwin_stream_stop(strm); 1220 1275 1221 1276 if (stream->cap_session) { … … 1239 1294 } 1240 1295 1296 #if TARGET_OS_IPHONE 1241 1297 if (stream->prev_layer) { 1242 1298 CALayer *prev_layer = stream->prev_layer; … … 1261 1317 stream->render_data_provider = nil; 1262 1318 } 1319 #endif /* TARGET_OS_IPHONE */ 1263 1320 1264 1321 if (stream->queue) { … … 1279 1336 } 1280 1337 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 56 56 #endif 57 57 58 #if PJMEDIA_VIDEO_DEV_HAS_ IOS59 pjmedia_vid_dev_factory* pjmedia_ ios_factory(pj_pool_factory *pf);58 #if PJMEDIA_VIDEO_DEV_HAS_DARWIN 59 pjmedia_vid_dev_factory* pjmedia_darwin_factory(pj_pool_factory *pf); 60 60 #endif 61 61 … … 106 106 vid_subsys->drv[vid_subsys->drv_cnt++].create = &pjmedia_opengl_factory; 107 107 #endif 108 #if PJMEDIA_VIDEO_DEV_HAS_ IOS109 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; 110 110 #endif 111 111 #if PJMEDIA_VIDEO_DEV_HAS_DSHOW
Note: See TracChangeset
for help on using the changeset viewer.