Ejemplo n.º 1
0
static int UpdateWindowSize(vout_display_sys_t *sys, video_format_t *p_fmt,
                            bool b_cropped)
{
    unsigned int i_width, i_height;
    unsigned int i_sar_num = 1, i_sar_den = 1;
    video_format_t rot_fmt;

    video_format_ApplyRotation(&rot_fmt, p_fmt);

    if (rot_fmt.i_sar_num != 0 && rot_fmt.i_sar_den != 0) {
        i_sar_num = rot_fmt.i_sar_num;
        i_sar_den = rot_fmt.i_sar_den;
    }
    if (b_cropped) {
        i_width = rot_fmt.i_visible_width;
        i_height = rot_fmt.i_visible_height;
    } else {
        i_width = rot_fmt.i_width;
        i_height = rot_fmt.i_height;
    }

    AWindowHandler_setWindowLayout(sys->p_awh, i_width, i_height,
                                   rot_fmt.i_visible_width,
                                   rot_fmt.i_visible_height,
                                   i_sar_num, i_sar_den);
    return 0;
}
Ejemplo n.º 2
0
/**
 * Window control.
 */
static int Control(vout_window_t *wnd, int cmd, va_list ap)
{
    switch (cmd)
    {
    case VOUT_WINDOW_SET_SIZE:
    {
        unsigned width = va_arg(ap, unsigned);
        unsigned height = va_arg(ap, unsigned);
        AWindowHandler_setWindowLayout(wnd->sys->p_awh, width, height,
                                       width, height, 1, 1);
        break;
    }
    case VOUT_WINDOW_SET_STATE:
    case VOUT_WINDOW_SET_FULLSCREEN:
        return VLC_EGENERIC;
    default:
        msg_Err (wnd, "request %d not implemented", cmd);
        return VLC_EGENERIC;
    }
    return VLC_SUCCESS;
}
Ejemplo n.º 3
0
/**
 * Create an Android native window.
 */
static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
    ANativeWindow *p_anw;

    if (cfg->type != VOUT_WINDOW_TYPE_INVALID
            && cfg->type != VOUT_WINDOW_TYPE_ANDROID_NATIVE)
        return VLC_EGENERIC;

    vout_window_sys_t *p_sys = malloc(sizeof (*p_sys));
    if (p_sys == NULL)
        return VLC_ENOMEM;

    p_sys->p_awh = AWindowHandler_new(VLC_OBJECT(wnd));
    if (!p_sys->p_awh)
        goto error;
    p_anw = AWindowHandler_getANativeWindow(p_sys->p_awh, AWindow_Video);
    if (!p_anw)
        goto error;

    wnd->type = VOUT_WINDOW_TYPE_ANDROID_NATIVE;
    wnd->handle.anativewindow = p_anw;
    wnd->control = Control;
    wnd->sys = p_sys;

    // Set the Java surface size.
    AWindowHandler_setWindowLayout(p_sys->p_awh, cfg->width, cfg->height,
                                   cfg->width, cfg->height, 1, 1);

    return VLC_SUCCESS;

error:
    if (p_sys->p_awh)
        AWindowHandler_destroy(p_sys->p_awh);
    free(p_sys);
    return VLC_EGENERIC;
}