Ignore:
Timestamp:
Aug 21, 2015 6:46:32 AM (8 years ago)
Author:
ming
Message:

Fixed #1880: Incorrect orientation after switching video capture or when using back camera

Included in this fix:

  • Change the spec & doc of pjmedia_orient enumeration
  • Change iOS sample app to rotate all video devices upon orientation change event.
  • Set orientation as well when fast switching cameras (for iOS and Android)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/android_dev.c

    r5138 r5166  
    7272    pjmedia_vid_dev_info         info;          /**< Base info         */ 
    7373    unsigned                     dev_idx;       /**< Original dev ID   */ 
     74    pj_bool_t                    facing;        /**< Front/back camera?*/ 
    7475    unsigned                     sup_size_cnt;  /**< # of supp'd size  */ 
    7576    pjmedia_rect_size           *sup_size;      /**< Supported size    */ 
     
    526527        /* Set driver & name info */ 
    527528        pj_ansi_strncpy(vdi->driver, "Android", sizeof(vdi->driver)); 
     529        adi->facing = facing; 
    528530        if (facing == 0) { 
    529531            pj_ansi_strncpy(vdi->name, "Back camera", sizeof(vdi->name)); 
     
    954956            } else { 
    955957                strm->param.cap_id = p->target_id; 
     958                 
     959                /* If successful, set the orientation as well */ 
     960                and_stream_set_cap(s, PJMEDIA_VID_DEV_CAP_ORIENTATION, 
     961                                   &strm->param.orient); 
    956962            } 
    957963            jni_detach_env(with_attach); 
     
    962968        { 
    963969            pjmedia_orient orient = *(pjmedia_orient *)pval; 
     970            pjmedia_orient eff_ori; 
     971            and_dev_info *adi; 
    964972 
    965973            pj_assert(orient >= PJMEDIA_ORIENT_UNKNOWN && 
     
    985993            } 
    986994             
    987             pjmedia_vid_dev_conv_set_rotation(&strm->conv, strm->param.orient); 
     995            eff_ori = strm->param.orient; 
     996            adi = &strm->factory->dev_info[strm->param.cap_id]; 
     997            /* Normalize the orientation for back-facing camera */ 
     998            if (!adi->facing) { 
     999                if (eff_ori == PJMEDIA_ORIENT_ROTATE_90DEG) 
     1000                    eff_ori = PJMEDIA_ORIENT_ROTATE_270DEG; 
     1001                else if (eff_ori == PJMEDIA_ORIENT_ROTATE_270DEG) 
     1002                    eff_ori = PJMEDIA_ORIENT_ROTATE_90DEG; 
     1003            } 
     1004            pjmedia_vid_dev_conv_set_rotation(&strm->conv, eff_ori); 
    9881005             
    9891006            PJ_LOG(4, (THIS_FILE, "Video capture orientation set to %d", 
Note: See TracChangeset for help on using the changeset viewer.