示例#1
0
void player_impl::init_video(vo_context *vo)
{
	int ret = 0;

	do
	{
		ret = ddraw_init_video((void*)vo, 10, 10, PIX_FMT_YUV420P);
		ddraw_destory_render(vo);
		if (ret == 0)
		{
			vo->init_video = ddraw_init_video;
			m_draw_frame = ddraw_render_one_frame;
			vo->re_size = ddraw_re_size;
			vo->aspect_ratio = ddraw_aspect_ratio;
			vo->use_overlay = ddraw_use_overlay;
			vo->destory_video = ddraw_destory_render;
			vo->render_one_frame = &player_impl::draw_frame;
			break;
		}

		ret = d3d_init_video((void*)vo, 10, 10, PIX_FMT_YUV420P);
		d3d_destory_render(vo);
		if (ret == 0)
		{
			vo->init_video = d3d_init_video;
			m_draw_frame = d3d_render_one_frame;
			vo->re_size = d3d_re_size;
			vo->aspect_ratio = d3d_aspect_ratio;
			vo->use_overlay = d3d_use_overlay;
			vo->destory_video = d3d_destory_render;
			vo->render_one_frame = &player_impl::draw_frame;
			break;
		}

		ret = ogl_init_video((void*)vo, 10, 10, PIX_FMT_YUV420P);
		ogl_destory_render(vo);
		if (ret == 0)
		{
			vo->init_video = ogl_init_video;
			m_draw_frame = ogl_render_one_frame;
			vo->re_size = ogl_re_size;
			vo->aspect_ratio = ogl_aspect_ratio;
			vo->use_overlay = ogl_use_overlay;
			vo->destory_video = ogl_destory_render;
			vo->render_one_frame = &player_impl::draw_frame;
			break;
		}

		// 表示视频渲染器初始化失败!!!
		assert(0);
	} while (0);

	// 保存this为user_ctx.
	vo->user_ctx = (void*)this;
}
示例#2
0
void player_impl::init_video(vo_context *vo, int render_type/* = RENDER_SOFT*/)
{
	int ret = 0;
	int check = 0;

	do
	{
#ifdef USE_Y4M_OUT
		if (render_type == RENDER_Y4M || check == -1)
		{
			ret = y4m_init_video(vo, 10, 10, PIX_FMT_YUV420P);
			y4m_destory_render(vo);
			if (ret == 0)
			{
				vo->init_video = y4m_init_video;
				m_draw_frame = y4m_render_one_frame;
				vo->re_size = y4m_re_size;
				vo->aspect_ratio = y4m_aspect_ratio;
				vo->use_overlay = y4m_use_overlay;
				vo->destory_video = y4m_destory_render;
				vo->render_one_frame = &player_impl::draw_frame;

				::logger("init video render to y4m.\n");

				break;
			}
		}
#endif

		if (render_type == RENDER_D3D || check == -1)
		{
			ret = d3d_init_video(vo, 10, 10, PIX_FMT_YUV420P);
			d3d_destory_render(vo);
			if (ret == 0)
			{
				vo->init_video = d3d_init_video;
				m_draw_frame = d3d_render_one_frame;
				vo->re_size = d3d_re_size;
				vo->aspect_ratio = d3d_aspect_ratio;
				vo->use_overlay = d3d_use_overlay;
				vo->destory_video = d3d_destory_render;
				vo->render_one_frame = &player_impl::draw_frame;

				::logger("init video render to d3d.\n");

				break;
			}
		}

		if (render_type == RENDER_DDRAW || check == -1)
		{
			ret = ddraw_init_video(vo, 10, 10, PIX_FMT_YUV420P);
			ddraw_destory_render(vo);
			if (ret == 0)
			{
				vo->init_video = ddraw_init_video;
				m_draw_frame = ddraw_render_one_frame;
				vo->re_size = ddraw_re_size;
				vo->aspect_ratio = ddraw_aspect_ratio;
				vo->use_overlay = ddraw_use_overlay;
				vo->destory_video = ddraw_destory_render;
				vo->render_one_frame = &player_impl::draw_frame;

				::logger("init video render to ddraw.\n");

				break;
			}
		}

		if (render_type == RENDER_OGL || check == -1)
		{
			ret = ogl_init_video(vo, 10, 10, PIX_FMT_YUV420P);
			ogl_destory_render(vo);
			if (ret == 0)
			{
				vo->init_video = ogl_init_video;
				m_draw_frame = ogl_render_one_frame;
				vo->re_size = ogl_re_size;
				vo->aspect_ratio = ogl_aspect_ratio;
				vo->use_overlay = ogl_use_overlay;
				vo->destory_video = ogl_destory_render;
				vo->render_one_frame = &player_impl::draw_frame;

				::logger("init video render to ogl.\n");

				break;
			}
		}

		if (render_type == RENDER_SOFT || check == -1)
		{
			ret = gdi_init_video(vo, 10, 10, PIX_FMT_YUV420P);
			gdi_destory_render(vo);
			if (ret == 0)
			{
				vo->init_video = gdi_init_video;
				m_draw_frame = gdi_render_one_frame;
				vo->re_size = gdi_re_size;
				vo->aspect_ratio = gdi_aspect_ratio;
				vo->use_overlay = gdi_use_overlay;
				vo->destory_video = gdi_destory_render;
				vo->render_one_frame = &player_impl::draw_frame;

				::logger("init video render to gdi.\n");

				break;
			}
		}

	} while (check-- == 0);

	// 表示视频渲染器初始化失败!!!
	assert(check != -2);

	// 保存this为user_ctx.
	vo->user_ctx = (void*)this;
}
示例#3
0
void player_impl::init_video(vo_context *vo, int render_type/* = RENDER_D3D*/)
{
    int ret = 0;

    do
    {
#ifdef USE_Y4M_OUT
        ret = y4m_init_video((void*)vo, 10, 10, PIX_FMT_YUV420P);
        y4m_destory_render(vo);
        if (ret == 0)
        {
            vo->init_video = y4m_init_video;
            m_draw_frame = y4m_render_one_frame;
            vo->re_size = y4m_re_size;
            vo->aspect_ratio = y4m_aspect_ratio;
            vo->use_overlay = y4m_use_overlay;
            vo->destory_video = y4m_destory_render;
            vo->render_one_frame = &player_impl::draw_frame;

            ::logger("init video render to y4m.\n");

            break;
        }
#endif


        ret = d3d_init_video((void*)vo, 10, 10, PIX_FMT_YUV420P);
        d3d_destory_render(vo);
        if (ret == 0)
        {
            vo->init_video = d3d_init_video;
            m_draw_frame = d3d_render_one_frame;
            vo->re_size = d3d_re_size;
            vo->aspect_ratio = d3d_aspect_ratio;
            vo->use_overlay = d3d_use_overlay;
            vo->destory_video = d3d_destory_render;
            vo->render_one_frame = &player_impl::draw_frame;

            ::logger("init video render to d3d.\n");

            break;
        }

        ret = ddraw_init_video((void*)vo, 10, 10, PIX_FMT_YUV420P);
        ddraw_destory_render(vo);
        if (ret == 0)
        {
            vo->init_video = ddraw_init_video;
            m_draw_frame = ddraw_render_one_frame;
            vo->re_size = ddraw_re_size;
            vo->aspect_ratio = ddraw_aspect_ratio;
            vo->use_overlay = ddraw_use_overlay;
            vo->destory_video = ddraw_destory_render;
            vo->render_one_frame = &player_impl::draw_frame;

            ::logger("init video render to ddraw.\n");

            break;
        }

        ret = ogl_init_video((void*)vo, 10, 10, PIX_FMT_YUV420P);
        ogl_destory_render(vo);
        if (ret == 0)
        {
            vo->init_video = ogl_init_video;
            m_draw_frame = ogl_render_one_frame;
            vo->re_size = ogl_re_size;
            vo->aspect_ratio = ogl_aspect_ratio;
            vo->use_overlay = ogl_use_overlay;
            vo->destory_video = ogl_destory_render;
            vo->render_one_frame = &player_impl::draw_frame;

            ::logger("init video render to ogl.\n");

            break;
        }

        ::logger("init video render failed!\n");

        // 表示视频渲染器初始化失败!!!
        assert(0);
    } while (0);

    // 保存this为user_ctx.
    vo->user_ctx = (void*)this;
}