#include "videoview1.h"

using namespace rtc;
///
CVideoView1::CVideoView1(QWidget* parent)
: CVideoViewHost(parent), m_videoRendererView(NULL), m_videoRenderer(NULL) {
}
CVideoView1::~CVideoView1() {
	if (m_videoRendererView) {
		m_videoRendererView->StopRender(0);
		m_videoRendererView->DeleteVideoRender(0);
        IVideoRenderView::DestroyVideoRenderView(m_videoRendererView);
		m_videoRendererView = NULL;
	}
}
rtc::IVideoRender* CVideoView1::GetRender()
{
	return m_videoRenderer;
}
//
bool CVideoView1::setScalingType(IVideoRenderView::ScalingType type) {
	return m_videoRendererView->SetScalingType(0, type);
}
void CVideoView1::onCreateWnd(HWND hwnd) {
	if (NULL != m_videoRenderer) {
		return;
	}
	m_videoRendererView = IVideoRenderView::CreateVideoRenderView(1, hwnd, false, false);
	m_videoRenderer = m_videoRendererView->CreateVideoRender(0, 0, IVideoRenderView::Scale_Aspect_Fit, 0.0f, 0.0f, 1.0f, 1.0f);
	m_videoRendererView->StartRender(0);
}
void CVideoView1::resizeEvent(QResizeEvent* event) {
	CVideoViewHost::resizeEvent(event);
	if (m_videoRendererView) {
		m_videoRendererView->UpdateWindowSize();
	}
}
