Changeset 6078
- Timestamp:
- Sep 25, 2019 3:34:38 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/vid_toolbox.m
r6038 r6078 180 180 /* Prototypes */ 181 181 static OSStatus create_decoder(struct vtool_codec_data *vtool_data); 182 183 static void dispatch_sync_on_main_queue(void (^block)(void)) 184 { 185 if ([NSThread isMainThread]) { 186 block(); 187 } else { 188 dispatch_sync(dispatch_get_main_queue(), block); 189 } 190 } 182 191 183 192 PJ_DEF(pj_status_t) pjmedia_codec_vid_toolbox_init(pjmedia_vid_codec_mgr *mgr, … … 760 769 NSDictionary *frm_prop = NULL; 761 770 OSStatus ret; 762 #if TARGET_OS_IPHONE763 UIApplicationState state;764 #endif765 771 766 772 PJ_ASSERT_RETURN(codec && input && out_size && output && has_more, 767 773 PJ_EINVAL); 768 769 #if TARGET_OS_IPHONE770 /* Skip encoding if app is not active, i.e. in the bg. */771 state = [UIApplication sharedApplication].applicationState;772 if (state != UIApplicationStateActive) {773 *has_more = PJ_FALSE;774 output->size = 0;775 output->type = PJMEDIA_FRAME_TYPE_NONE;776 777 return PJ_SUCCESS;778 }779 #endif780 774 781 775 vtool_data = (vtool_codec_data*) codec->codec_data; … … 849 843 NULL, NULL); 850 844 if (ret == kVTInvalidSessionErr) { 845 #if TARGET_OS_IPHONE 846 /* Just return if app is not active, i.e. in the bg. */ 847 __block UIApplicationState state; 848 849 dispatch_sync_on_main_queue(^{ 850 state = [UIApplication sharedApplication].applicationState; 851 }); 852 if (state != UIApplicationStateActive) { 853 *has_more = PJ_FALSE; 854 output->size = 0; 855 output->type = PJMEDIA_FRAME_TYPE_NONE; 856 857 CVPixelBufferRelease(image_buf); 858 return PJ_SUCCESS; 859 } 860 #endif 861 851 862 /* Reset compression session */ 852 863 ret = create_encoder(vtool_data); … … 1113 1124 pj_bool_t decode_whole = DECODE_WHOLE; 1114 1125 OSStatus ret; 1115 #if TARGET_OS_IPHONE1116 UIApplicationState state;1117 #endif1118 1126 1119 1127 PJ_ASSERT_RETURN(codec && count && packets && out_size && output, 1120 1128 PJ_EINVAL); 1121 1129 PJ_ASSERT_RETURN(output->buf, PJ_EINVAL); 1122 1123 #if TARGET_OS_IPHONE1124 /* Skip decoding if app is not active, i.e. in the bg. */1125 state = [UIApplication sharedApplication].applicationState;1126 if (state != UIApplicationStateActive) {1127 output->type = PJMEDIA_FRAME_TYPE_NONE;1128 output->size = 0;1129 output->timestamp = packets[0].timestamp;1130 return PJ_SUCCESS;1131 }1132 #endif1133 1130 1134 1131 vtool_data = (vtool_codec_data*) codec->codec_data; … … 1281 1278 NULL, NULL); 1282 1279 if (ret == kVTInvalidSessionErr) { 1280 #if TARGET_OS_IPHONE 1281 /* Just return if app is not active, i.e. in the bg. */ 1282 __block UIApplicationState state; 1283 1284 dispatch_sync_on_main_queue(^{ 1285 state = [UIApplication sharedApplication].applicationState; 1286 }); 1287 if (state != UIApplicationStateActive) { 1288 output->type = PJMEDIA_FRAME_TYPE_NONE; 1289 output->size = 0; 1290 output->timestamp = packets[0].timestamp; 1291 1292 CFRelease(block_buf); 1293 CFRelease(sample_buf); 1294 return PJ_SUCCESS; 1295 } 1296 #endif 1283 1297 if (vtool_data->dec_format) 1284 1298 CFRelease(vtool_data->dec_format);
Note: See TracChangeset
for help on using the changeset viewer.