pjsua2 sample(for android) 视频调用旋转-90度,调用setCaptureOrient时抛出异常

pjsua2 sample(for android) video call rotate -90 degree and throws exception when call setCaptureOrient

我正在使用 pjsua2 示例项目进行视频通话,一切正常,android 应用客户端可以看到和听到对方,但视频旋转了 -90 度。 在 CallActivity.java 中,调用 setCaptureOrient(cap_dev, orient, true).

时抛出异常
@Override
    public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    WindowManager wm;
    Display display;
    int rotation;
    pjmedia_orient orient;

    wm = (WindowManager)this.getSystemService(Context.WINDOW_SERVICE);
    display = wm.getDefaultDisplay();
    rotation = display.getRotation();
    System.out.println("Device orientation changed: " + rotation);

    switch (rotation) {
    case Surface.ROTATION_0:   // Portrait
        orient = pjmedia_orient.PJMEDIA_ORIENT_ROTATE_270DEG;
        break;
    case Surface.ROTATION_90:  // Landscape, home button on the right
        orient = pjmedia_orient.PJMEDIA_ORIENT_NATURAL;
        break;
    case Surface.ROTATION_180:
        orient = pjmedia_orient.PJMEDIA_ORIENT_ROTATE_90DEG;
        break;
    case Surface.ROTATION_270: // Landscape, home button on the left
        orient = pjmedia_orient.PJMEDIA_ORIENT_ROTATE_180DEG;
        break;
    default:
        orient = pjmedia_orient.PJMEDIA_ORIENT_UNKNOWN;
    }

    if (MyApp.ep != null && MainActivity.account != null) {
        try {
        AccountConfig cfg = MainActivity.account.cfg;
        int cap_dev = cfg.getVideoConfig().getDefaultCaptureDevice();




        //----------here throws an exception:option/operation is not support. ------------

        MyApp.ep.vidDevManager().setCaptureOrient(cap_dev, orient,true);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}    

异常信息:

media.cpp!pjsua_vid_dev_set_setting(dev_id,PJMEDIA_VID_DEV_CAP_ORIENTATION, &orient, keep) error: Option/operation is not supported (PJ_ENOTSUP) (status=70012) [../src/pjsua2/media.cpp:1483] Description: Option/operation is not supported (PJ_ENOTSUP)

我什么都没有改变,但它就是不起作用,为什么?

我已经知道错误的原因,就是pjsip源代码不支持ffmpeg库的捕获方向设置,我used.I在[=15=中找到了它.c

...
#include "util.h"

#include <pj/assert.h>
#include <pj/errno.h>
#include <pj/log.h>

#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)

#if defined(PJMEDIA_HAS_LIBYUV) && PJMEDIA_HAS_LIBYUV != 0
#include  <libyuv.h>
#define HAS_ROTATION 1
#else
    #define HAS_ROTATION 0     //the reason why ffmpeg not support capture orientation setting
#endif

#define THIS_FILE       "vid_util.c"

pj_status_t
pjmedia_vid_dev_conv_create_converter(pjmedia_vid_dev_conv *conv,
                  pj_pool_t *pool,
                  pjmedia_format *fmt,
                  pjmedia_rect_size src_size,
                  pjmedia_rect_size dst_size,
                  pj_bool_t handle_rotation,
                  pj_bool_t maintain_aspect_ratio)
{
    pj_status_t status;
    pjmedia_conversion_param conv_param;
    const pjmedia_video_format_info *vfi;   

    pj_assert((src_size.w == dst_size.w || src_size.h == dst_size.h) ||
          (src_size.w == dst_size.h || src_size.h == dst_size.w));

if (conv->conv)
    return PJ_SUCCESS;

if (fmt->id != PJMEDIA_FORMAT_I420 && fmt->id != PJMEDIA_FORMAT_BGRA)
    return PJ_EINVAL;

/* Currently, for BGRA format, device must handle the rotation. */
if (fmt->id == PJMEDIA_FORMAT_BGRA && handle_rotation)
    return PJ_ENOTSUP;

if (handle_rotation) {
#if !HAS_ROTATION
return PJ_ENOTSUP; // return ffmpeg not support capture orientation setting error
#endif
}
...