From f3f6fbf0fc75ae65993b8833ea62e36401fd065a Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Thu, 22 May 2014 04:52:53 +0000 Subject: Re #1757: Modify display video function in r4813 so it can display video preview as well git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4848 74dad513-b988-da41-8d7b-12977e46ad98 --- .../src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m | 44 +++++++++++++++------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'pjsip-apps/src/pjsua/ios/ipjsua') diff --git a/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m b/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m index d415d94c..34be6262 100644 --- a/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m +++ b/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m @@ -225,23 +225,39 @@ pj_bool_t showNotification(pjsua_call_id call_id) void displayWindow(pjsua_vid_win_id wid) { #if PJSUA_HAS_VIDEO - pjsua_vid_win_info wi; + int i, last; - if (wid != PJSUA_INVALID_ID && - pjsua_vid_win_get_info(wid, &wi) == PJ_SUCCESS) - { - UIView *view = (__bridge UIView *)wi.hwnd.info.ios.window; - if (view) { - dispatch_async(dispatch_get_main_queue(), ^{ - UIView *parent = app.viewController.view; - /* Add the video window as subview */ - [parent addSubview:view]; - /* Center it */ - view.center = CGPointMake(parent.bounds.size.width/2.0, - parent.bounds.size.height/2.0); - }); + i = (wid == PJSUA_INVALID_ID) ? 0 : wid; + last = (wid == PJSUA_INVALID_ID) ? PJSUA_MAX_VID_WINS : wid+1; + + for (;i < last; ++i) { + pjsua_vid_win_info wi; + + if (pjsua_vid_win_get_info(i, &wi) == PJ_SUCCESS) { + UIView *parent = app.viewController.view; + UIView *view = (__bridge UIView *)wi.hwnd.info.ios.window; + + if (view && ![view isDescendantOfView:parent]) { + dispatch_async(dispatch_get_main_queue(), ^{ + /* Add the video window as subview */ + [parent addSubview:view]; + + if (!wi.is_native) { + /* Center it horizontally */ + view.center = CGPointMake(parent.bounds.size.width/2.0, + view.bounds.size.height/2.0); + } else { + /* Preview window, move it to the bottom */ + view.center = CGPointMake(parent.bounds.size.width/2.0, + parent.bounds.size.height- + view.bounds.size.height/2.0); + } + }); + } } } + + #endif } -- cgit v1.2.3