| 288 | |
| 289 | ==== When video orientation signaling is available ==== |
| 290 | |
| 291 | In case application has the capability to signal remote about video orientation (e.g: via SIP INFO or RTP header extension), instead of telling video device capturer (via {{{pjsua_vid_dev_set_setting()}}} or {{{setCaptureOrient()}}}), it may signal remote directly about the new orientation. This way the video sent to remote will always in full frame (no black bands in left+right sides due to forcing landscape video in portrait frame or vice versa), but it may not be in "proper" orientation, this should not be problem though as remote could get the orientation info from out of band signaling, so it should be able to render the incoming video frames in "proper" orientation. |
| 292 | |
| 293 | However note that if '''portrait''' mode is prefered as the initial orientation in a video call session (default settings are set for landscape video orientation), the encoding part of video codec param should be configured as portrait too, i.e: width < height, e.g: |
| 294 | {{{ |
| 295 | /* Sending 240 x 320 */ |
| 296 | param.enc_fmt.det.vid.size.w = 240; |
| 297 | param.enc_fmt.det.vid.size.h = 320; |
| 298 | }}} |
| 299 | and the initial video device orientation should be set as portrait too, e.g: |
| 300 | {{{ |
| 301 | /* After the capturer device is opened, e.g: using pjsua_vid_preview_start() |
| 302 | * or opened automatically by video call, tell the capture device about |
| 303 | * current orientation. Note this need to be done once only, so when orientation |
| 304 | * is changed, never update the device about the new orientation. |
| 305 | */ |
| 306 | |
| 307 | /* On Android, portrait mode is defined as PJMEDIA_ORIENT_ROTATE_270DEG */ |
| 308 | current_orient = PJMEDIA_ORIENT_ROTATE_270DEG; |
| 309 | |
| 310 | /* On iOS, portrait mode is defined as PJMEDIA_ORIENT_ROTATE_90DEG*/ |
| 311 | current_orient = PJMEDIA_ORIENT_ROTATE_90DEG; |
| 312 | |
| 313 | pjsua_vid_dev_set_setting(dev_id, PJMEDIA_VID_DEV_CAP_ORIENTATION, ¤t_orient, PJ_TRUE); |
| 314 | ... |
| 315 | }}} |
| 316 | then when device orientation is changed, application '''must not''' update the video device orientation, instead, it should just signal remote about device orientation. Updating orientation info to video capture device will cause device to rotate (and perhaps downsize the image) to make sure that the image always has 'proper' orientation (head upside). |