summaryrefslogtreecommitdiff
path: root/pjsip-apps/src
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2015-06-25 08:17:52 +0000
committerLiong Sauw Ming <ming@teluu.com>2015-06-25 08:17:52 +0000
commit97f362db7fa1fad9a0258bdb5e218b80dab93031 (patch)
tree135ac5d783604db13ee17e6d78551851c4020b1d /pjsip-apps/src
parent6138b1938ddf639566e8cdccb016ad6be1da39fb (diff)
Re #1861: Initial implementation of video orientation support
- Utility to resize and rotate video frame - Support for iOS + sample - pjsua API to set video device's orientation git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5118 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src')
-rw-r--r--pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m52
1 files changed, 48 insertions, 4 deletions
diff --git a/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m b/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m
index 4c88fd2f..c00c1ff7 100644
--- a/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m
+++ b/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m
@@ -39,8 +39,6 @@ static pjsua_app_cfg_t app_cfg;
static bool isShuttingDown;
static char **restartArgv;
static int restartArgc;
-static pj_thread_desc a_thread_desc;
-static pj_thread_t *a_thread;
static void displayMsg(const char *msg)
{
@@ -117,12 +115,21 @@ static void pjsuaOnAppConfigCb(pjsua_app_config *cfg)
return;
}
+ /* Setup device orientation change notification */
+ [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
+ [[NSNotificationCenter defaultCenter] addObserver:app
+ selector:@selector(orientationChanged:)
+ name:UIDeviceOrientationDidChangeNotification
+ object:[UIDevice currentDevice]];
+
status = pjsua_app_run(PJ_TRUE);
if (status != PJ_SUCCESS) {
char errmsg[PJ_ERR_MSG_SIZE];
pj_strerror(status, errmsg, sizeof(errmsg));
displayMsg(errmsg);
}
+
+ [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
pjsua_app_destroy();
}
@@ -157,11 +164,46 @@ static void pjsuaOnAppConfigCb(pjsua_app_config *cfg)
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
+- (void)orientationChanged:(NSNotification *)note
+{
+#if PJSUA_HAS_VIDEO
+ const pjmedia_orient pj_ori[4] =
+ {
+ PJMEDIA_ORIENT_ROTATE_90DEG, /* UIDeviceOrientationPortrait */
+ PJMEDIA_ORIENT_ROTATE_270DEG, /* UIDeviceOrientationPortraitUpsideDown */
+ PJMEDIA_ORIENT_ROTATE_180DEG, /* UIDeviceOrientationLandscapeLeft,
+ home button on the right side */
+ PJMEDIA_ORIENT_NATURAL /* UIDeviceOrientationLandscapeRight,
+ home button on the left side */
+ };
+ static pj_thread_desc a_thread_desc;
+ static pj_thread_t *a_thread;
+ static UIDeviceOrientation prev_ori = 0;
+ UIDeviceOrientation dev_ori = [[UIDevice currentDevice] orientation];
+
+ if (dev_ori == prev_ori && !note) return;
+
+ NSLog(@"Device orientation changed: %d", (prev_ori = dev_ori));
+
+ if (dev_ori >= UIDeviceOrientationPortrait &&
+ dev_ori <= UIDeviceOrientationLandscapeRight)
+ {
+ if (!pj_thread_is_registered()) {
+ pj_thread_register("ipjsua", a_thread_desc, &a_thread);
+ }
+
+ pjsua_vid_dev_set_orient(PJMEDIA_VID_DEFAULT_CAPTURE_DEV,
+ pj_ori[dev_ori-1]);
+ }
+#endif
+}
+
- (void)keepAlive {
+ static pj_thread_desc a_thread_desc;
+ static pj_thread_t *a_thread;
int i;
- if (!pj_thread_is_registered())
- {
+ if (!pj_thread_is_registered()) {
pj_thread_register("ipjsua", a_thread_desc, &a_thread);
}
@@ -229,6 +271,8 @@ void displayWindow(pjsua_vid_win_id wid)
i = (wid == PJSUA_INVALID_ID) ? 0 : wid;
last = (wid == PJSUA_INVALID_ID) ? PJSUA_MAX_VID_WINS : wid+1;
+
+ [app orientationChanged:NULL];
for (;i < last; ++i) {
pjsua_vid_win_info wi;