⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vncencodemgr.h

📁 teamviewer source code vc++
💻 H
📖 第 1 页 / 共 2 页
字号:

		vnclog.Print(LL_INTINFO, VNCLOG("CoRRE encoder requested"));

		// Create a CoRRE encoder
		m_encoder = new vncEncodeCoRRE;
		if (m_encoder == NULL)
			return FALSE;
		break;

	case rfbEncodingHextile:

		vnclog.Print(LL_INTINFO, VNCLOG("Hextile encoder requested"));

		// Create a CoRRE encoder
		m_encoder = new vncEncodeHexT;
		if (m_encoder == NULL)
			return FALSE;
		break;

	case rfbEncodingUltra:

		vnclog.Print(LL_INTINFO, VNCLOG("Ultra encoder requested"));

		// Create a Zlib encoder, if needed.
		// If a Zlib encoder was used previously, then reuse it here
		// to maintain zlib dictionary synchronization with the viewer.
		if ( m_hold_ultra_encoder == NULL )
		{
			m_encoder = new vncEncodeUltra;
		}
		else
		{
			m_encoder = m_hold_ultra_encoder;
		}
		if (m_encoder == NULL)
			return FALSE;
		ultra_encoder_in_use = true;//

		// sf@2003 - UltraEncoder Queing does not work with DSM - Disable it in this case until
		// some work is done to improve Queuing/DSM compatibility
		((vncEncodeUltra*)(m_encoder))->EnableQueuing(m_fEnableQueuing);
		EnableXCursor(false);
		EnableRichCursor(false);
		EnableCache(false);
		break;

	case rfbEncodingZRLE:
		vnclog.Print(LL_INTINFO, VNCLOG("ZRLE encoder requested"));
		if (!zrleEncoder)
			zrleEncoder = new vncEncodeZRLE;
		m_encoder = zrleEncoder;
		break;

	case rfbEncodingZlib:

		vnclog.Print(LL_INTINFO, VNCLOG("Zlib encoder requested"));

		// Create a Zlib encoder, if needed.
		// If a Zlib encoder was used previously, then reuse it here
		// to maintain zlib dictionary synchronization with the viewer.
		if ( m_hold_zlib_encoder == NULL )
		{
			m_encoder = new vncEncodeZlib;
		}
		else
		{
			m_encoder = m_hold_zlib_encoder;
		}
		if (m_encoder == NULL)
			return FALSE;
		zlib_encoder_in_use = true;//
		break;


	case rfbEncodingZlibHex:
		vnclog.Print(LL_INTINFO, VNCLOG("ZlibHex encoder requested"));

		// Create a ZlibHex encoder, if needed.
		// If a Zlibhex encoder was used previously, then reuse it here
		// to maintain zlib dictionary synchronization with the viewer.
		if ( m_hold_zlibhex_encoder == NULL )
		{
			m_encoder = new vncEncodeZlibHex;
		}
		else
		{
			m_encoder = m_hold_zlibhex_encoder;
		}
		if (m_encoder == NULL)
			return FALSE;
		zlibhex_encoder_in_use = true;//
		break;


	case rfbEncodingTight:
		vnclog.Print(LL_INTINFO, VNCLOG("Tight encoder requested"));

		// Create a Tight encoder, if needed.
		// If a Tight encoder was used previously, then reuse it here
		// to maintain zlib dictionaries synchronization with the viewer.
		if ( m_hold_tight_encoder == NULL )
		{
			m_encoder = new vncEncodeTight;
		}
		else
		{
			m_encoder = m_hold_tight_encoder;
		}
		if (m_encoder == NULL)
			return FALSE;
		tight_encoder_in_use = true;
		break;
		

	default:
		// An unknown encoding was specified
		vnclog.Print(LL_INTERR, VNCLOG("unknown encoder requested"));

		return FALSE;
	}

	// Initialise it and give it the pixel format
	m_encoder->Init();
	m_encoder->SetLocalFormat(
			m_scrinfo.format,
			m_scrinfo.framebufferWidth,
			m_scrinfo.framebufferHeight);
	if (m_clientfmtset)
		if (!m_encoder->SetRemoteFormat(m_clientformat))
		{
			vnclog.Print(LL_INTERR, VNCLOG("client pixel format is not supported"));

			return FALSE;
		}

	if (reinitialize)
	{
		if (m_encoder != NULL)
		{
			m_encoder->EnableXCursor(m_use_xcursor);
			m_encoder->EnableRichCursor(m_use_richcursor);
			m_encoder->SetCompressLevel(m_compresslevel);
			m_encoder->SetQualityLevel(m_qualitylevel);
			m_encoder->EnableLastRect(m_use_lastrect);
		}

	}
		m_buffer->ClearCache();
		m_buffer->ClearBack();
		m_encoder->SetSWOffset(m_SWOffsetx,m_SWOffsety);
	// Check that the client buffer is compatible
	return CheckBuffer();
}

// Predict how many update rectangles a given rect will encode to
// For Raw, RRE or Hextile, this is always 1.  For CoRRE, may be more,
// because each update rect is limited in size.
inline UINT
vncEncodeMgr::GetNumCodedRects(const rfb::Rect &rect)
{
	// sf@2002 - Tight encoding
	// TODO: Add the appropriate virtual NumCodedRects function to Tight encoder instead.
	if (tight_encoder_in_use || zlibhex_encoder_in_use)
	{
		RECT TRect;
		TRect.right = rect.br.x;
		TRect.left = rect.tl.x;
		TRect.top = rect.tl.y;
		TRect.bottom = rect.br.y;
		return m_encoder->NumCodedRects(TRect);
	}

	return m_encoder->NumCodedRects(rect);
}

//
// -=- Pixel format translation
//

// Update the local pixel format used by the encoder
inline BOOL
vncEncodeMgr::SetServerFormat()
{
	if (m_encoder) {
		CheckBuffer();
		return m_encoder->SetLocalFormat(
			m_scrinfo.format,
			m_scrinfo.framebufferWidth,
			m_scrinfo.framebufferHeight);
	}
	return FALSE;
}

// Specify the client's pixel format
inline BOOL
vncEncodeMgr::SetClientFormat(rfbPixelFormat &format)
{
	vnclog.Print(LL_INTINFO, VNCLOG("SetClientFormat called"));
	
	// Save the desired format
	m_clientfmtset = TRUE;
	m_clientformat = format;

	// Tell the encoder of the new format
	if (m_encoder != NULL)
		m_encoder->SetRemoteFormat(format);

	// Check that the output buffer is sufficient
	if (!CheckBuffer())
		return FALSE;

	return TRUE;
}

// Translate a rectangle to the client's pixel format
inline UINT
vncEncodeMgr::EncodeRect(const rfb::Rect &rect,VSocket *outconn)
{
	// Call the encoder to encode the rectangle into the client buffer...
	/*if (!m_clientbackbuffif){*/
	if (!m_buffer->m_backbuff){
		vnclog.Print(LL_INTERR, VNCLOG("no client back-buffer available in EncodeRect"));
		return 0;
	}
	if (zlib_encoder_in_use)
	{
		if (m_use_xor)
		{
		return m_encoder->EncodeRect(m_buffer->m_backbuff, m_buffer->m_cachebuff, outconn ,m_clientbuff, rect);
		}
		else return m_encoder->EncodeRect(m_buffer->m_backbuff, NULL, outconn ,m_clientbuff, rect);
	}
	if (ultra_encoder_in_use)
	{
		return m_encoder->EncodeRect(m_buffer->m_backbuff, outconn ,m_clientbuff, rect);
	}

	// sf@2002 - Tight encoding
	if (tight_encoder_in_use || zlibhex_encoder_in_use  || ultra_encoder_in_use)
	{
		RECT TRect;
		TRect.right = rect.br.x;
		TRect.left = rect.tl.x;
		TRect.top = rect.tl.y;
		TRect.bottom = rect.br.y;
		return m_encoder->EncodeRect(m_buffer->m_backbuff, outconn, m_clientbuff, TRect); // sf@2002 - For Tight...
	}

	return m_encoder->EncodeRect(m_buffer->m_backbuff, m_clientbuff, rect);
}

rfb::Rect 
vncEncodeMgr::GetSize()
{
	return m_buffer->GetSize();
}
inline void
vncEncodeMgr::SetSWOffset(int x,int y)
{
	m_SWOffsetx=x;
	m_SWOffsety=y;
	m_encoder->SetSWOffset(x,y);
}

inline void
vncEncodeMgr::EnableXCursor(BOOL enable)
{
	m_use_xcursor = enable;
	if (m_encoder != NULL) {
		m_encoder->EnableXCursor(enable);
	}
	m_hcursor = NULL;
}

inline void
vncEncodeMgr::EnableRichCursor(BOOL enable)
{
	m_use_richcursor = enable;
	if (m_encoder != NULL) {
		m_encoder->EnableRichCursor(enable);
	}
	m_hcursor = NULL;
}

// Check if cursor shape update should be sent
inline BOOL
vncEncodeMgr::IsCursorUpdatePending()
{
	if (m_use_xcursor || m_use_richcursor) {
		return m_buffer->IsCursorUpdatePending();
	}
	return false;
}

inline BOOL
vncEncodeMgr::WasCursorUpdatePending()
{
	BOOL pending=m_buffer->IsCursorUpdatePending();
	m_buffer->SetCursorPending(FALSE);
	return pending;
}

inline BOOL
vncEncodeMgr::SendCursorShape(VSocket *outConn) {
	return m_encoder->SendCursorShape(outConn, m_buffer->m_desktop);
}

inline BOOL
vncEncodeMgr::SendEmptyCursorShape(VSocket *outConn) {
	return m_encoder->SendEmptyCursorShape(outConn);
}

inline BOOL
vncEncodeMgr::IsXCursorSupported() {
	return m_encoder->IsXCursorSupported();
}

// Tight
inline void
vncEncodeMgr::SetCompressLevel(int level)
{
	m_compresslevel = (level >= 0 && level <= 9) ? level : 6;
	if (m_encoder != NULL)
		m_encoder->SetCompressLevel(m_compresslevel);
}

inline void
vncEncodeMgr::SetQualityLevel(int level)
{
	m_qualitylevel = (level >= 0 && level <= 9) ? level : -1;
	if (m_encoder != NULL)
		m_encoder->SetQualityLevel(m_qualitylevel);
}

inline void
vncEncodeMgr::EnableLastRect(BOOL enable)
{
	m_use_lastrect = enable;
	if (m_encoder != NULL) {
		m_encoder->EnableLastRect(enable);
	}
}

inline BOOL
vncEncodeMgr::IsMouseWheelTight()
{
	if (m_use_tight && !m_use_xor) //tight client
		return true;
	return false;
}

// sf@2005
inline void vncEncodeMgr::EnableGreyPalette(BOOL enable)
{
	m_buffer->EnableGreyPalette(enable);
}

inline void
vncEncodeMgr::EnableCache(BOOL enabled)
{
	m_cache_enabled = enabled;
	// if (enabled)
	m_buffer->EnableCache(enabled);
}

inline BOOL
vncEncodeMgr::IsCacheEnabled()
{
	return m_cache_enabled;
}

inline void
vncEncodeMgr::LastRect(VSocket *outConn)
{
	m_encoder->LastRect(outConn);
}
// Modif cs@2005
#ifdef DSHOW
inline BOOL
vncEncodeMgr::ResetZRLEEncoding(void)
{
	if (NULL != zrleEncoder)
	{
		delete zrleEncoder;

		zrleEncoder = NULL;

		zrleEncoder = new vncEncodeZRLE;

		m_encoder = zrleEncoder;

		// Initialise it and give it the pixel format
		m_encoder->Init();

		m_encoder->SetLocalFormat(	m_scrinfo.format,
									m_scrinfo.framebufferWidth,
									m_scrinfo.framebufferHeight);

		if (m_clientfmtset)
		{
			if (!m_encoder->SetRemoteFormat(m_clientformat))
			{
				vnclog.Print(LL_INTERR, VNCLOG("client pixel format is not supported"));

				return FALSE;
			}
		}

		if (m_encoder != NULL)
		{
			m_encoder->EnableXCursor(m_use_xcursor);
			m_encoder->EnableRichCursor(m_use_richcursor);
			m_encoder->SetCompressLevel(m_compresslevel);
			m_encoder->SetQualityLevel(m_qualitylevel);
			m_encoder->EnableLastRect(m_use_lastrect);
		}

		m_buffer->ClearCache();
		m_buffer->ClearBack();

		// Check that the client buffer is compatible
		return CheckBuffer();
	}

	return FALSE;
}			
#endif

#endif // _WINVNC_VNCENCODEMGR

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -