Example #1
0
//流名称格式化
void CDlgPanel::FormatStreamName(char* sStreamName)
{
	CString strStream = _T("");
	CString strFormatStreamName = _T("");
	strStream = sStreamName;
	int nTPos = strStream.Find(_T(".sdp"));
	if(nTPos>=0)
	{
		strFormatStreamName = strStream.Mid(0, nTPos);
	}
	else
	{
		strFormatStreamName = strStream;
	}
	strStream.Format(_T("%s%d%s"), strFormatStreamName, m_nWndId, _T(".sdp") ); 
	char sName[128] =  {0,};
	__WCharToMByte(strStream, sName, sizeof(sName)/sizeof(sName[0]));
	strcpy_s(sStreamName, 64, sName);
}
Example #2
0
void CDlgPanel::OnBnClickedButtonStart()
{
	if (m_pManager)
	{
		int nType = m_pCmbType->GetCurSel();
		if (nType == 0)
		{
			//采集
			CWnd* pCapWnd = GetDlgVideo();
			BOOL bInCap = m_pManager->IsInCapture();
			if (!bInCap)
			{
				CComboBox* pComboxMediaSource = m_pCmbSourceType;
				CComboBox* pVideoCombo = m_pCmbCamera ;
				CComboBox* pAudioCombo = m_pCmbMic ;
				CEdit* pEdtRtspSource = m_pEdtRtspStream;

				SOURCE_TYPE eType = (SOURCE_TYPE)pComboxMediaSource->GetCurSel();
				int nCamId = 0;
				int nAudioId = 0;
				char szURL[128] = {0,};
				CString strTemp = _T("");

				//视频参数设置
				int nWidth = m_sAVCapParamInfo.nVWidth;
				int nHeight = m_sAVCapParamInfo.nVHeight;
				int nFps = m_sAVCapParamInfo.nFps;
				int nBitrate = m_sAVCapParamInfo.nBitrate;
				char  szDataType[64];
				strcpy_s(szDataType, m_sAVCapParamInfo.strColorFormat )	;
				//音频参数设置
				int nASampleRate = m_sAVCapParamInfo.nASampleRate;
				int nAChannels =m_sAVCapParamInfo.nAChannels;

				if (eType == SOURCE_LOCAL_CAMERA)
				{
					nCamId = pVideoCombo->GetCurSel();
					nAudioId = pAudioCombo->GetCurSel();
					strTemp = _T("本地音视频采集");

				}
				else if ((eType == SOURCE_SCREEN_CAPTURE))
				{
					nCamId = -1;
					nAudioId = pAudioCombo->GetCurSel();
					strTemp = _T("屏幕采集");
					strcpy_s(szDataType , "RGB24");

					int nRet =m_pManager->GetScreenCapSize(nWidth, nHeight);
					if (nRet<1)
					{
						m_pManager->LogErr(_T("屏幕采集获取长宽失败,本地预览失败!"));
						return;
					}
				}
				else
				{
					//Start
					wchar_t wszURL[128] = {0,};
					if (NULL != pEdtRtspSource)
						pEdtRtspSource->GetWindowTextW(wszURL, sizeof(wszURL));
					if (wcslen(wszURL) < 1)		return;

					CString strURL = wszURL;
					CString strRTSP = strURL.Mid(0,4);
					if (strRTSP!=_T("rtsp")&&strRTSP!=_T("RTSP"))
					{
						strURL = _T("rtsp://")+strURL;
					}

					__WCharToMByte(strURL, szURL, sizeof(szURL)/sizeof(szURL[0]));
					strTemp = _T("网络音视频流采集");
				}

				int nRet = m_pManager->StartCapture( eType,  nCamId, nAudioId, pCapWnd->GetSafeHwnd(), szURL, nWidth, nHeight, nFps,nBitrate, szDataType, nASampleRate , nAChannels );
				if (nRet>0)
				{
					strTemp +=_T("成功!"); 
					m_pManager->LogErr(strTemp);
				} 
				else
				{
					strTemp +=_T("失败!"); 
					m_pManager->LogErr(strTemp);
					return;
				}

				//推送
				//获取服务器流地址信息
				ServerURLInfo URLInfo;
				memset(&URLInfo, 0, sizeof(ServerURLInfo));
				if (m_pMainDlg)
				{
					m_pMainDlg->	GetPushServerInfo(&URLInfo);
				}

				bool bPushRtmp = false;
				//流名称格式化
				FormatStreamName(URLInfo.sdpName);
				nRet = m_pManager->StartPush(URLInfo.pushServerAddr, URLInfo.pushServerPort,URLInfo.sdpName, URLInfo.nPushBufferLenth, bPushRtmp);
				CString strMsg = _T("");
				CString strIp;
				CString strName;
				strIp = URLInfo.pushServerAddr;
				strName = URLInfo.sdpName;
				if (nRet>=0)
				{
					strMsg.Format(_T("推送EasyDarwin服务器URL:rtsp://%s:%d/%s 成功!"), strIp , URLInfo.pushServerPort, strName);
					m_pManager->LogErr(strMsg);
					m_btnStart.SetWindowText(TEXT("Stop"));
					if (bPushRtmp)
					{
						strMsg.Format(_T("连接RTMP服务器成功,推送RTMP服务器URL:rtmp://%s:1935/live/%s 成功!"), strIp , strName);
						m_pManager->LogErr(strMsg);
					}
				} 
				else
				{
					strMsg.Format(_T("推送EasyDarwin服务器URL:rtsp://%s:%d/%s 失败!"), strIp, URLInfo.pushServerPort,strName);
					m_pManager->LogErr(strMsg);
					if (bPushRtmp)
					{
						if (nRet == -1)
							strMsg.Format(_T("连接RTMP服务器失败!"), strIp , strName);
						else
							strMsg.Format(_T("推送RTMP服务器URL:rtmp://%s:1935/live/%s 失败!"), strIp , strName);
						m_pManager->LogErr(strMsg);
					}
				}
			}
			else
			{
				m_pManager->LogErr(_T("停止推送!"));
				m_pManager->StopPush();

				m_pManager->StopCapture();
				m_btnStart.SetWindowText(TEXT("Start"));
				m_pManager->LogErr(_T("本地预览停止"));

				pCapWnd->Invalidate();	
			}
		} 
		else //直播
		{
			//RTSP
			CWnd* pPlayWnd = GetDlgVideo();
			BOOL bInPlay = m_pManager->IsInPlaying();
			if (!bInPlay)
			{
				char szIp[128] = {0,};
				wchar_t wszIp[128] = {0,};

				if (NULL != m_pEdtRtspStream)	
					m_pEdtRtspStream->GetWindowTextW(wszIp, sizeof(wszIp));
				if (wcslen(wszIp) < 1)		
					return;
				__WCharToMByte(wszIp, szIp, sizeof(szIp)/sizeof(szIp[0]));

				int nRet = m_pManager->StartPlay(szIp, pPlayWnd->GetSafeHwnd());
				m_btnStart.SetWindowText(TEXT("Stop"));
				CString strMsg = _T("");
				if (nRet>0)
				{
					strMsg.Format(_T("直播预览URL:%s 成功!"), wszIp);
				} 
				else
				{
					strMsg.Format(_T("直播预览URL:%s 失败!"), wszIp);
				}
				m_pManager->LogErr(strMsg);
			}
			else
			{
				m_pManager->StopPlay();
				m_btnStart.SetWindowText(TEXT("Start"));
				pPlayWnd->Invalidate();	
				m_pManager->LogErr(_T("停止直播"));
			}
		}
	}
}
Example #3
0
void CSettingDlg::OnBnClickedOk()
{
	int nWidth = 640;
	int nHeight = 480;
	int nFps = 25;
	int nBitrate = 2048;
	int nSampleRate = 44100;
	int nChannels = 2;

	char szWidth[128] = {0,};
	wchar_t wszWidth[128] = {0,};
	char szHeight[128] = {0,};
	wchar_t wszHeight[128] = {0,};
	char szFPS[128] = {0,};
	wchar_t wszFPS[128] = {0,};
	char szBitrate[128] = {0,};
	wchar_t wszBitrate[128] = {0,};

	char szSampleRate[128] = {0,};
	wchar_t wszSampleRate[128] = {0,};
	char szChannels[128] = {0,};
	wchar_t wszChannels[128] = {0,};

	CEdit* pEdit = NULL;
	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_VWIDTH);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszWidth, sizeof(wszWidth));
		if (wcslen(wszWidth) < 1)		
			return;
		__WCharToMByte(wszWidth, szWidth, sizeof(szWidth)/sizeof(szWidth[0]));
		nWidth = atoi(szWidth);
	}

	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_VHEIGHT);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszHeight, sizeof(wszHeight));
		if (wcslen(wszHeight) < 1)		
			return;
		__WCharToMByte(wszHeight, szHeight, sizeof(szHeight)/sizeof(szHeight[0]));
		nHeight = atoi(szHeight);
	}
	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_FPS);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszFPS, sizeof(wszFPS));
		if (wcslen(wszFPS) < 1)		
			return;
		__WCharToMByte(wszFPS, szFPS, sizeof(szFPS)/sizeof(szFPS[0]));
		nFps = atoi(szFPS);
	}
	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_BITRATE);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszBitrate, sizeof(wszBitrate));
		if (wcslen(wszBitrate) < 1)		
			return;
		__WCharToMByte(wszBitrate, szBitrate, sizeof(szBitrate)/sizeof(szBitrate[0]));
		nBitrate = atoi(szBitrate);
	}

	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_ASAMPLERATE);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszSampleRate, sizeof(wszSampleRate));
		if (wcslen(wszSampleRate) < 1)		
			return;
		__WCharToMByte(wszSampleRate, szSampleRate, sizeof(szSampleRate)/sizeof(szSampleRate[0]));
		nSampleRate = atoi(szSampleRate);	
	}

	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_ACHANNELS);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszChannels, sizeof(wszChannels));
		if (wcslen(wszChannels) < 1)		
			return;
		__WCharToMByte(wszChannels, szChannels, sizeof(szChannels)/sizeof(szChannels[0]));
		nChannels = atoi(szChannels);	
	}

	m_sParamInfo.nVWidth = nWidth;
	m_sParamInfo.nVHeight = nHeight;
	m_sParamInfo.nFps = nFps;
	m_sParamInfo.nBitrate = nBitrate;
	m_sParamInfo.nASampleRate = nSampleRate;
	m_sParamInfo.nAChannels = nChannels;

	CComboBox* pCombo = (CComboBox*) GetDlgItem ( IDC_COMBO_COLORFORMAT );
	if (pCombo)
	{
		int nSel = pCombo->GetCurSel();
		if (nSel == 0)
		{
			strcpy_s(m_sParamInfo.strColorFormat , "YUY2");
		} 
		else
		{
			strcpy_s(m_sParamInfo.strColorFormat , "RGB24");
		}
	}
	OnOK();
}
Example #4
0
void CEasyClientDlg::OnBnClickedBtnPlay()
{
	if (m_pManager)
	{
		CWnd* pPlayWnd = easyVideoPanelObj.pDlgRemotePanel->GetDlgVideo();
		CEdit* pIP = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_IP);
		CEdit* pPort = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_PORT);
		CEdit* pName = (CEdit*)GetDlgItem(IDC_EDIT_PUSH_NAME);
		CWnd* pCapWnd = easyVideoPanelObj.pDlgLocalPanel->GetDlgVideoHwnd();
		BOOL bInPlay = m_pManager->IsInPlaying();
		CButton* pBtnStartPlay= (CButton*)GetDlgItem(IDC_BTN_PLAY) ;
		if (!bInPlay)
		{
			char szIp[128] = {0,};
			char szPort[128] = {0,};
			char szName[128] = {0,};
			wchar_t wszIp[128] = {0,};
			wchar_t wszPort[128] = {0,};
			wchar_t wszName[128] = {0,};
			if (NULL != pIP)	
				pIP->GetWindowTextW(wszIp, sizeof(wszIp));
			if (wcslen(wszIp) < 1)		
				return;
			__WCharToMByte(wszIp, szIp, sizeof(szIp)/sizeof(szIp[0]));

			if (NULL != pPort)	
				pPort->GetWindowTextW(wszPort, sizeof(wszPort));
			if (wcslen(wszPort) < 1)		
				return;
			__WCharToMByte(wszPort, szPort, sizeof(szPort)/sizeof(szPort[0]));
			int nPort = atoi(szPort);

			if (NULL != pName)	
				pName->GetWindowTextW(wszName, sizeof(wszName));
			if (wcslen(wszName) < 1)		
				return;
			__WCharToMByte(wszName, szName, sizeof(szName)/sizeof(szName[0]));

			char szURL[128]= {0,};
			sprintf(szURL, "rtsp://%s:%d/%s", szIp,  nPort, szName );
			int nRet = m_pManager->StartPlay(szURL, pPlayWnd->GetSafeHwnd());
			if (NULL != pBtnStartPlay)		pBtnStartPlay->SetWindowText(TEXT("Stop"));
			CString strMsg = _T("");
			if (nRet>0)
			{
				strMsg.Format(_T("Ö±²¥Ô¤ÀÀURL£ºrtsp://%s:%d/%s ³É¹¦£¡"), wszIp, nPort, wszName);
			} 
			else
			{
				strMsg.Format(_T("Ö±²¥Ô¤ÀÀURL£ºrtsp://%s:%d/%s ʧ°Ü£¡"), wszIp, nPort, wszName);

			}
			m_pManager->LogErr(strMsg);
		}
		else
		{
			m_pManager->StopPlay();
			if (NULL != pBtnStartPlay)		pBtnStartPlay->SetWindowText(TEXT("Ö±²¥Ô¤ÀÀ"));
			pPlayWnd->Invalidate();	
			m_pManager->LogErr(_T("Í£Ö¹Ö±²¥"));
		}
	}
}
Example #5
0
void CEasyClientDlg::OnBnClickedBtnPush()
{
	if (m_pManager)
	{
		BOOL bInPush = m_pManager->IsInPushing();
		CEdit* pIP = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_IP);
		CEdit* pPort = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_PORT);
		CEdit* pName = (CEdit*)GetDlgItem(IDC_EDIT_PUSH_NAME);
		
		CButton* pBtnStartPush = (CButton*)GetDlgItem(IDC_BTN_PUSH) ;
		if (!bInPush)
		{
			char szIp[128] = {0,};
			char szPort[128] = {0,};
			char szName[128] = {0,};
			wchar_t wszIp[128] = {0,};
			wchar_t wszPort[128] = {0,};
			wchar_t wszName[128] = {0,};
			if (NULL != pIP)	
				pIP->GetWindowTextW(wszIp, sizeof(wszIp));
			if (wcslen(wszIp) < 1)		
				return;
			__WCharToMByte(wszIp, szIp, sizeof(szIp)/sizeof(szIp[0]));

			if (NULL != pPort)	
				pPort->GetWindowTextW(wszPort, sizeof(wszPort));
			if (wcslen(wszPort) < 1)		
				return;
			__WCharToMByte(wszPort, szPort, sizeof(szPort)/sizeof(szPort[0]));
			int nPort = atoi(szPort);

			if (NULL != pName)	
				pName->GetWindowTextW(wszName, sizeof(wszName));
			if (wcslen(wszName) < 1)		
				return;
			__WCharToMByte(wszName, szName, sizeof(szName)/sizeof(szName[0]));
			
			int nRet = m_pManager->StartPush(szIp , nPort,  szName);
			CString strMsg = _T("");
			if (nRet>=0)
			{
				strMsg.Format(_T("ÍÆËÍEasyDarwin·þÎñÆ÷URL£ºrtsp://%s:%d/%s ³É¹¦£¡"), wszIp, nPort, wszName);
				if (NULL != pBtnStartPush)		pBtnStartPush->SetWindowText(TEXT("Stop"));
			} 
			else
			{
				strMsg.Format(_T("ÍÆËÍEasyDarwin·þÎñÆ÷URL£ºrtsp://%s:%d/%s ʧ°Ü£¡"), wszIp, nPort, wszName);

			}
			m_pManager->LogErr(strMsg);
	
		}
		else
		{
			m_pManager->LogErr(_T("Í£Ö¹ÍÆËÍ£¡"));
			m_pManager->StopPush();
			if (NULL != pBtnStartPush)		pBtnStartPush->SetWindowText(TEXT("ÍÆËÍ->"));
		}
	}

}
Example #6
0
void CEasyClientDlg::OnBnClickedBtnCapture()
{
	if (m_pManager)
	{
		CWnd* pCapWnd = easyVideoPanelObj.pDlgLocalPanel->GetDlgVideoHwnd();
		BOOL bInCap = m_pManager->IsInCapture();
		CButton* pBtnStartCapture = (CButton*)GetDlgItem(IDC_BTN_CAPTURE) ;
		if (!bInCap)
		{
			CComboBox* pComboxMediaSource = (CComboBox*)GetDlgItem(IDC_COMBO_SOURCE);
			CComboBox* pVideoCombo = (CComboBox*)GetDlgItem(IDC_COMBO_CAMERA) ;
			CEdit* pEdtRtspSource = (CEdit*)GetDlgItem(IDC_EDIT_SREAM_URL);

			SOURCE_TYPE eType = (SOURCE_TYPE)pComboxMediaSource->GetCurSel();
			int nCamId = 0;
			char szURL[128] = {0,};
			CString strTemp = _T("");
			if (eType == SOURCE_LOCAL_CAMERA)
			{
				nCamId = pVideoCombo->GetCurSel();
				strTemp = _T("±¾µØÒôÊÓƵ²É¼¯");
			} 
			else
			{
				//Start
				wchar_t wszURL[128] = {0,};
				if (NULL != pEdtRtspSource)
					pEdtRtspSource->GetWindowTextW(wszURL, sizeof(wszURL));
				if (wcslen(wszURL) < 1)		return;

				CString strURL = wszURL;
				CString strRTSP = strURL.Mid(0,4);
				if (strRTSP!=_T("rtsp")&&strRTSP!=_T("RTSP"))
				{
					strURL = _T("rtsp://")+strURL;
				}
				
				__WCharToMByte(strURL, szURL, sizeof(szURL)/sizeof(szURL[0]));
				strTemp = _T("ÍøÂçÒôÊÓƵÁ÷²É¼¯");

			}
			int nRet = m_pManager->StartCapture( eType,  nCamId, pCapWnd->GetSafeHwnd(), szURL);
			if (nRet>0)
			{
				strTemp +=_T("³É¹¦£¡"); 
			} 
			else
			{
				strTemp +=_T("ʧ°Ü£¡"); 
			}
			m_pManager->LogErr(strTemp);
			if (NULL != pBtnStartCapture)		pBtnStartCapture->SetWindowText(TEXT("Stop"));

		}
		else
		{
			m_pManager->StopCapture();
			if (NULL != pBtnStartCapture)		pBtnStartCapture->SetWindowText(TEXT("±¾µØÔ¤ÀÀ"));
			m_pManager->LogErr(_T("±¾µØÔ¤ÀÀÍ£Ö¹"));

			pCapWnd->Invalidate();	
		}
	}
}