Changeset 4837
- Timestamp:
- May 7, 2014 5:30:29 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-videodev/ios_dev.m
r4836 r4837 97 97 VOutDelegate *vout_delegate; 98 98 void *capture_buf; 99 AVCaptureVideoPreviewLayer *prev_layer; 99 100 100 101 void *render_buf; … … 715 716 ios_init_view(strm); 716 717 717 CALayer *view_layer = strm->render_view.layer;718 CGRect r = strm->render_view.bounds;719 720 718 /* Preview layer instantiation should be in main thread! */ 721 719 dispatch_async(dispatch_get_main_queue(), ^{ … … 726 724 727 725 /* Attach preview layer to a UIView */ 728 prev_layer.videoGravity = AVLayerVideoGravityResizeAspectFill; 729 prev_layer.frame = r; 730 [view_layer addSublayer:prev_layer]; 726 prev_layer.videoGravity = AVLayerVideoGravityResize; 727 prev_layer.frame = strm->render_view.bounds; 728 [strm->render_view.layer addSublayer:prev_layer]; 729 strm->prev_layer = prev_layer; 731 730 PJ_LOG(4, (THIS_FILE, "Native preview initialized")); 732 731 }); … … 832 831 dispatch_async(dispatch_get_main_queue(), ^{ 833 832 strm->render_view.bounds = r; 833 if (strm->prev_layer) 834 strm->prev_layer.frame = r; 834 835 }); 835 836 return PJ_SUCCESS; … … 891 892 892 893 if (stream->cap_session) { 893 [stream->cap_session startRunning]; 894 if ([NSThread isMainThread]) { 895 [stream->cap_session startRunning]; 896 } else { 897 dispatch_sync(dispatch_get_main_queue(), ^{ 898 [stream->cap_session startRunning]; 899 }); 900 } 894 901 895 902 if (![stream->cap_session isRunning]) … … 906 913 { 907 914 struct ios_stream *stream = (struct ios_stream*)strm; 908 //NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];909 915 910 916 if (stream->frame_size >= frame->size) … … 914 920 915 921 /* Perform video display in a background thread */ 916 dispatch_async(dispatch_get_main_queue(), 917 ^{[stream->vout_delegate update_image];}); 918 919 //[pool release]; 922 dispatch_async(dispatch_get_main_queue(), ^{ 923 [stream->vout_delegate update_image]; 924 }); 920 925 921 926 return PJ_SUCCESS; … … 931 936 PJ_LOG(4, (THIS_FILE, "Stopping iOS video stream")); 932 937 933 if (stream->cap_session && [stream->cap_session isRunning]) 934 [stream->cap_session stopRunning]; 938 if (stream->cap_session && [stream->cap_session isRunning]) { 939 if ([NSThread isMainThread]) { 940 [stream->cap_session stopRunning]; 941 } else { 942 dispatch_sync(dispatch_get_main_queue(), ^{ 943 [stream->cap_session stopRunning]; 944 }); 945 } 946 } 935 947 936 948 return PJ_SUCCESS; … … 965 977 } 966 978 979 if (stream->prev_layer) { 980 CALayer *prev_layer = stream->prev_layer; 981 dispatch_async(dispatch_get_main_queue(), ^{ 982 [prev_layer removeFromSuperlayer]; 983 [prev_layer release]; 984 }); 985 stream->prev_layer = nil; 986 } 987 967 988 if (stream->render_view) { 968 989 UIView *view = stream->render_view; 969 dispatch_async(dispatch_get_main_queue(), 970 ^{ 971 [view removeFromSuperview]; 972 [view release]; 973 }); 974 stream->render_view = NULL; 990 dispatch_async(dispatch_get_main_queue(), ^{ 991 [view removeFromSuperview]; 992 [view release]; 993 }); 994 stream->render_view = nil; 975 995 } 976 996 977 997 if (stream->render_data_provider) { 978 998 CGDataProviderRelease(stream->render_data_provider); 979 stream->render_data_provider = NULL;999 stream->render_data_provider = nil; 980 1000 } 981 1001
Note: See TracChangeset
for help on using the changeset viewer.