һ

һ
non zero exit code 1 No Python at &#39;"C:\Users\Administrator\.espressif\tools\idf-python\3.11.2\python.exe&#39; No Python at &#39;"C:\Users\Administrator\.espressif\tools\idf-python\3.11.2\python.exe&#39; WARNING: pip is not available in the existing virtual environment, new virtual environment will be created. WARNING: Removing the existing Python environment in d:\Users\Administrator\.espressif\python_env\idf5.5_py3.11_env Creating a new Python environment in d:\Users\Administrator\.espressif\python_env\idf5.5_py3.11_env Downloading https://dl.espressif.com/dl/esp-idf/espidf.constraints.v5.5.txt Destination: d:\Users\Administrator\.espressif\espidf.constraints.v5.5.txt.tmp WARNING: Download failure: <urlopen error [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�> WARNING: Failed to download https://dl.espressif.com/dl/esp-idf/espidf.constraints.v5.5.txt to d:\Users\Administrator\.espressif\espidf.constraints.v5.5.txt.tmp Downloading https://dl.espressif.com/dl/esp-idf/espidf.constraints.v5.5.txt Destination: d:\Users\Administrator\.espressif\espidf.constraints.v5.5.txt.tmp WARNING: Download failure: <urlopen error [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�> WARNING: Failed to download https://dl.espressif.com/dl/esp-idf/espidf.constraints.v5.5.txt to d:\Users\Administrator\.espressif\espidf.constraints.v5.5.txt.tmp Downloading https://dl.espressif.com/dl/esp-idf/espidf.constraints.v5.5.txt Destination: d:\Users\Administrator\.espressif\espidf.constraints.v5.5.txt.tmp WARNING: Download failure: <urlopen error [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�> WARNING: Failed to download https://dl.espressif.com/dl/esp-idf/espidf.constraints.v5.5.txt to d:\Users\Administrator\.espressif\espidf.constraints.v5.5.txt.tmp WARNING: Failed to download, retry count has expired, using a previously downloaded version Requirement already satisfied: pip in d:\users\administrator\.espressif\python_env\idf5.5_py3.11_env\lib\site-packages (22.3.1) WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000002C566AE8790>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/pip/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000002C568626850>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/pip/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000002C568626DD0>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/pip/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000002C568624350>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/pip/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000002C568634710>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/pip/ WARNING: There was an error checking the latest version of pip. Requirement already satisfied: setuptools in d:\users\administrator\.espressif\python_env\idf5.5_py3.11_env\lib\site-packages (65.5.0) WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000232CF4E8910>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000232D0FC6E90>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000232D0FC7790>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000232D0FC7DD0>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000232D0FC75D0>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: There was an error checking the latest version of pip. Looking in indexes: https://pypi.org/simple, https://dl.espressif.com/pypi Ignoring importlib_metadata: markers &#39;python_version < "3.8"&#39; don&#39;t match your environment Requirement already satisfied: setuptools in d:\users\administrator\.espressif\python_env\idf5.5_py3.11_env\lib\site-packages (from -r d:\Users\Administrator\esp\v5.5.1\esp-idf\tools\requirements\requirements.core.txt (line 7)) (65.5.0) WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF1DB50>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FAF9A2D0>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF1E950>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF1EE10>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF1F5D0>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/setuptools/ WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF30790>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/setuptools/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF30E90>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/setuptools/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FAF9A2D0>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/setuptools/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF1F590>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/setuptools/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF1DF50>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/setuptools/ WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF34150>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/packaging/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF1F1D0>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/packaging/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF34E10>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/packaging/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF35350>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/packaging/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF35990>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /simple/packaging/ WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF36950>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/packaging/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF35D90>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/packaging/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF36D50>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/packaging/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF36F90>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/packaging/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ProxyError(&#39;Cannot connect to proxy.&#39;, NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000250FCF372D0>: Failed to establish a new connection: [WinError 10013] ��һ�ַ���Ȩ�޲������ķ�ʽ����һ�������׽��ֵij��ԡ�&#39;))&#39;: /pypi/packaging/ ERROR: Could not find a version that satisfies the requirement packaging (from versions: none) ERROR: No matching distribution found for packaging WARNING: There was an error checking the latest version of pip. Upgrading pip... Upgrading setuptools... Installing Python packages Constraint file: d:\Users\Administrator\.espressif\espidf.constraints.v5.5.txt Requirement files: - d:\Users\Administrator\esp\v5.5.1\esp-idf\tools\requirements\requirements.core.txt Traceback (most recent call last): File "d:\Users\Administrator\esp\v5.5.1\esp-idf\tools\idf_tools.py", line 3606, in <module> main(sys.argv[1:]) File "d:\Users\Administrator\esp\v5.5.1\esp-idf\tools\idf_tools.py", line 3596, in main action_func(args) File "d:\Users\Administrator\esp\v5.5.1\esp-idf\tools\idf_tools.py", line 2928, in action_install_python_env subprocess.check_call(run_args, stdout=sys.stdout, stderr=sys.stderr, env=env_copy) File "subprocess.py", line 413, in check_call subprocess.CalledProcessError: Command &#39;[&#39;d:\\Users\\Administrator\\.espressif\\python_env\\idf5.5_py3.11_env\\Scripts\\python.exe&#39;, &#39;-m&#39;, &#39;pip&#39;, &#39;install&#39;, &#39;--no-warn-script-location&#39;, &#39;-r&#39;, &#39;d:\\Users\\Administrator\\esp\\v5.5.1\\esp-idf\\tools\\requirements\\requirements.core.txt&#39;, &#39;--upgrade&#39;, &#39;--constraint&#39;, &#39;d:\\Users\\Administrator\\.espressif\\espidf.constraints.v5.5.txt&#39;, &#39;--extra-index-url&#39;, &#39;https://dl.espressif.com/pypi&#39;]&#39; returned non-zero exit status 1.
09-29
#include "sdp.h" #include "rtpcommon.h" #include "rtpclient.h" #include "rtspclient.h" #include "mbasicop.h" #include "basicutil.h" #include "tpwlog.h" #include "frame.h" #include "frame_info.h" #include "datasink.h" #include "udppacketqueue.h" #include "core_dbg.h" extern "C" { #include "rtspm_dbg.h" } extern __thread uint64_t tprtsp_time_ms; // RTPCLIENTSESSION RTPCLIENTSESSION::RTPCLIENTSESSION(int bRTPOverTCP) { if (bRTPOverTCP) { pDataClient = NULL; pControlClient = NULL; } else { pDataClient = new TPUDPCLIENT; pControlClient = new TPUDPCLIENT; } pBuffer = NULL; memset(&PacketInfo, 0, sizeof(RTPCLIENTPACKETINFO)); if (bRTPOverTCP == 0) { RTPControlFrameInit(NULL, RTP_CONTROL_TOTAL_SIZE, &ControlFrameReceived); } RTPControlFrameInit(NULL, RTP_CONTROL_TOTAL_SIZE, &ControlFrame2Send); ullLastTimeACKSent = tprtsp_time_ms; ullLastRRTime = ullLastTimeACKSent; uiFirstTS = 0; SDESFrame.ucType = 1; strncpy(SDESFrame.pcData, gpucRTSPUserAgent, strlen(gpucRTSPUserAgent)); SDESFrame.ucLength = strlen(gpucRTSPUserAgent); usLastSN = 0; bIsOverTCP = bRTPOverTCP; } RTPCLIENTSESSION::~RTPCLIENTSESSION() { RTPControlFrameDeInit(&ControlFrame2Send); if (bIsOverTCP == 0) { RTPControlFrameDeInit(&ControlFrameReceived); } if (pDataClient) { delete pDataClient; pDataClient = NULL; } if (pControlClient) { delete pControlClient; pControlClient = NULL; } } // RTPCLIENT // public APIs RTPCLIENT::RTPCLIENT(int bRTPOverTCP, int iAudioVideo) { this->bRTPOverTCP = bRTPOverTCP; if (iAudioVideo & 0x1) pSessions[RTP_SESSION_AUDIO] = new RTPCLIENTSESSION(bRTPOverTCP); else pSessions[RTP_SESSION_AUDIO] = NULL; if (iAudioVideo & 0x2) pSessions[RTP_SESSION_VIDEO] = new RTPCLIENTSESSION(bRTPOverTCP); else pSessions[RTP_SESSION_VIDEO] = NULL; } RTPCLIENT::~RTPCLIENT() { for (int i = 0; i < RTP_SESSION_NUM; i++) { if (pSessions[i]) { delete pSessions[i]; pSessions[i] = NULL; } } } int RTPCLIENT::Init(char *pcRemoteIP, int iAudioVideo, int iAudioServerDataPort, int iAudioServerControlPort, int iVideoServerDataPort, int iVideoServerControlPort) { if ((iAudioVideo & RTSP_AUDIO) == 0) { delete pSessions[RTP_SESSION_AUDIO]; pSessions[RTP_SESSION_AUDIO] = NULL; } if ((iAudioVideo & RTSP_VIDEO) == 0) { delete pSessions[RTP_SESSION_VIDEO]; pSessions[RTP_SESSION_VIDEO] = NULL; } if (pSessions[RTP_SESSION_AUDIO]) { pSessions[RTP_SESSION_AUDIO]->pDataClient->SetServerAddress(iAudioServerDataPort, pcRemoteIP); pSessions[RTP_SESSION_AUDIO]->pControlClient->SetServerAddress(iAudioServerControlPort, pcRemoteIP); } if (pSessions[RTP_SESSION_VIDEO]) { pSessions[RTP_SESSION_VIDEO]->pDataClient->SetServerAddress(iVideoServerDataPort, pcRemoteIP); pSessions[RTP_SESSION_VIDEO]->pControlClient->SetServerAddress(iVideoServerControlPort, pcRemoteIP); } return(RTP_EC_OK); } int RTPCLIENT::Init(TP_TCPCLIENT *pTCPClient, int iAudioOrVideo, int iTCPDataID, int iTCPControlID) { int iSessionID; if (iAudioOrVideo == RTSP_AUDIO) iSessionID = RTP_SESSION_AUDIO; else if (iAudioOrVideo == RTSP_VIDEO) iSessionID = RTP_SESSION_VIDEO; else return(RTP_EC_FAILIURE); pSessions[iSessionID]->iTCPDataID = iTCPDataID; pSessions[iSessionID]->iTCPControlID = iTCPControlID; this->pTCPClient = pTCPClient; return(RTP_EC_OK); } int RTPCLIENT::SetTimeout(int iTimeout) { if (bRTPOverTCP == 0) { if (pSessions[RTP_SESSION_AUDIO]) { pSessions[RTP_SESSION_AUDIO]->pDataClient->SetTimeout(iTimeout); } if (pSessions[RTP_SESSION_VIDEO]) { pSessions[RTP_SESSION_VIDEO]->pDataClient->SetTimeout(iTimeout); } } return(RTP_EC_OK); } int RTPCLIENT::SetFirstRTPInfo(int iFirstVideoRTPSN, int iFirstVideoRTPTS, int iFirstAudioRTPSN, int iFirstAudioRTPTS) { if (pSessions[RTP_SESSION_AUDIO]) { pSessions[RTP_SESSION_AUDIO]->uiFirstTS = iFirstAudioRTPTS; } if (pSessions[RTP_SESSION_VIDEO]) { pSessions[RTP_SESSION_VIDEO]->uiFirstTS = iFirstVideoRTPTS; } return(RTP_EC_OK); } int RTPCLIENT::SetAVCodec(int iAudioCodec, int iVideoCodec, SDPDECODEINFO *pSDPDecodeInfo) { if (pSessions[RTP_SESSION_AUDIO]) { pSessions[RTP_SESSION_AUDIO]->iCodec = iAudioCodec; if (iAudioCodec == ACODEC_TYPE_AAC) { memcpy(pucADTSHeader, pSDPDecodeInfo->pucAudioADTS, 7); iMPEG4GenericSizeLength = pSDPDecodeInfo->iMPEG4GenericSizeLength; iMPEG4GenericIndexLength = pSDPDecodeInfo->iMPEG4GenericIndexLength; iMPEG4GenericIndexDeltaLength = pSDPDecodeInfo->iMPEG4GenericIndexDeltaLength; } pSessions[RTP_SESSION_AUDIO]->iSampleRate = pSDPDecodeInfo->MediaInfo.iAudioSampleRate; } if (pSessions[RTP_SESSION_VIDEO]) { pSessions[RTP_SESSION_VIDEO]->iCodec = iVideoCodec; pSessions[RTP_SESSION_VIDEO]->iSampleRate = pSDPDecodeInfo->MediaInfo.iVideoSampleRate; } return(RTP_EC_OK); } int RTPCLIENT::SetAVBuffers(DataSink *pVideoBuffer, DataSink *pAudioBuffer) { if (pSessions[RTP_SESSION_VIDEO]) { pSessions[RTP_SESSION_VIDEO]->pBuffer = pVideoBuffer; } if (pSessions[RTP_SESSION_AUDIO]) { pSessions[RTP_SESSION_AUDIO]->pBuffer = pAudioBuffer; } return(RTP_EC_OK); } int RTPCLIENT::GetClientPorts(int *piAudioClientDataPort, int *piAudioClientControlPort, int *piVideoClientDataPort, int *piVideoClientControlPort) { *piVideoClientDataPort = -1; *piVideoClientControlPort = -1; *piAudioClientDataPort = -1; *piAudioClientControlPort = -1; if (pSessions[RTP_SESSION_VIDEO]) { *piVideoClientDataPort = ntohs(pSessions[RTP_SESSION_VIDEO]->pDataClient->ClientAddr.sin_port); *piVideoClientControlPort = ntohs(pSessions[RTP_SESSION_VIDEO]->pControlClient->ClientAddr.sin_port); } if (pSessions[RTP_SESSION_AUDIO]) { *piAudioClientDataPort = ntohs(pSessions[RTP_SESSION_AUDIO]->pDataClient->ClientAddr.sin_port); *piAudioClientControlPort = ntohs(pSessions[RTP_SESSION_AUDIO]->pControlClient->ClientAddr.sin_port); } return(RTP_EC_OK); } // private functions /*����UDP����Э����*/ int RTPCLIENT::Punch() { const int iSendBufferLen = 10; char pcSendBuffer[10]; if (pSessions[RTP_SESSION_AUDIO]) { pSessions[RTP_SESSION_AUDIO]->pDataClient->Send(pcSendBuffer, iSendBufferLen); pSessions[RTP_SESSION_AUDIO]->pControlClient->Send(pcSendBuffer, iSendBufferLen); } if (pSessions[RTP_SESSION_VIDEO]) { pSessions[RTP_SESSION_VIDEO]->pDataClient->Send(pcSendBuffer, iSendBufferLen); pSessions[RTP_SESSION_VIDEO]->pControlClient->Send(pcSendBuffer, iSendBufferLen); } return(RTP_EC_OK); } int RTPCLIENT::OnRxSenderReport(int iSession) { return(RTP_EC_OK); } int RTPCLIENT::OnRxReceiverReport(int iSession) { return(RTP_EC_OK); } int RTPCLIENT::OnRxSourceDescription(int iSession) { return(RTP_EC_OK); } int RTPCLIENT::OnRxGoodbye(int iSession) { return(RTP_EC_OK); } int RTPCLIENT::OnReceiveControl(int iSession) { RTPCLIENTSESSION *pSession = pSessions[iSession]; RTPCONTROLFRAME *pControlFrame = &(pSession->ControlFrameReceived); MBUFFERByteArray *pByteArray = &(pControlFrame->ByteArray); MBUFFERByteConvert2ReadBuff(pByteArray); //һ��UDP��(pByteArray)�п��ܰ������RTCP���� while (MBUFFERByteArrayLength(pByteArray) > 0) { MBUFFERByteArrayAdvance(1, pByteArray); pControlFrame->iPayloadType = MBUFFERByteArrayGetUChar(pByteArray); pControlFrame->iPayloadSize = MBUFFERByteArrayGetUShortBE(pByteArray); switch (pControlFrame->iPayloadType) { case RTP_CONTROL_TYPE_SR: OnRxSenderReport(iSession); break; case RTP_CONTROL_TYPE_RR: OnRxReceiverReport(iSession); break; case RTP_CONTROL_TYPE_SDES: OnRxSourceDescription(iSession); break; case RTP_CONTROL_TYPE_BYE: OnRxGoodbye(iSession); break; case RTP_CONTROL_TYPE_APP: break; default: return(RTP_EC_OK); } MBUFFERByteArrayAdvance(pControlFrame->iPayloadSize*4, pByteArray); } MBUFFERByteArrayReset(pByteArray); return(RTP_EC_OK); } int RTPCLIENT::WriteControl(int iSession) { RTPCLIENTSESSION *pSession = pSessions[iSession]; MBUFFERByteArray *pByteArray = &pSession->ControlFrame2Send.ByteArray; MBUFFERByteConvert2ReadBuff(pByteArray); if (bRTPOverTCP) { // over tcp ģʽ����Ҫͨ��rtsp client��socket���� pTCPClient->Send(pByteArray); } else { pSession->pControlClient->Send((char *)MBUFFERByteArrayCurBufferPos(pByteArray), MBUFFERByteArrayLength(pByteArray)); } MBUFFERByteArrayReset(&pSession->ControlFrame2Send.ByteArray); return(RTP_EC_OK); } int RTPCLIENT::SendACK(int iSession, int iSN) { RTPCLIENTSESSION *pSession = pSessions[iSession]; RTPCLIENTPACKETINFO *pPacketInfo = &pSession->PacketInfo; unsigned long long ullCurTime = tprtsp_time_ms; int iPacketsMapLength = 0; int i, iStartSN = -1; pPacketInfo->pusSN4RTPReceived[pPacketInfo->iNumRTPReceived++] = iSN; if (pPacketInfo->iNumRTPReceived >= RTP_MAX_PACKETS_4_ACK || (pPacketInfo->iNumRTPReceived > 0 && ullCurTime - pSession->ullLastTimeACKSent > RTP_PERIOD_4_ACK)) { unsigned char pucPacketsMap[RTP_MAX_PACKETS_4_ACK / 8]; memset(&(pucPacketsMap), 0, RTP_MAX_PACKETS_4_ACK / 8); pSession->ullLastTimeACKSent = ullCurTime; /* ׼��bit map */ iStartSN = -1; for (i = 0; i < pPacketInfo->iNumRTPReceived; i++) { if (iStartSN == -1 || RTPSNBefore(pPacketInfo->pusSN4RTPReceived[i], iStartSN)) iStartSN = pPacketInfo->pusSN4RTPReceived[i]; } for (i = 0; i < pPacketInfo->iNumRTPReceived; i++) { int iDiffSN = RTPSNDistance(pPacketInfo->pusSN4RTPReceived[i], iStartSN); if (iDiffSN > 0 && (iDiffSN - 1 < RTP_MAX_PACKETS_4_ACK)) /* ��֤λд���ʱ�򲻻�Խ�� */ { if (((iDiffSN - 1) / 8 + 1) > iPacketsMapLength) iPacketsMapLength = (iDiffSN - 1) / 8 + 1; unsigned char * pcLocation = pucPacketsMap + (iDiffSN - 1) / 8; *pcLocation |= 0x1 << (7 - ((iDiffSN - 1) % 8)); } } // send out ACK RTPControlBuildAPP(pSession->uiSSRC, iStartSN, (char *)pucPacketsMap, iPacketsMapLength, &(pSession->ControlFrame2Send)); WriteControl(iSession); // reset packet info memcpy(pPacketInfo->pusSN4RTPReceived, pPacketInfo->pusSN4RTPReceived + pPacketInfo->iNumLastReceived, (pPacketInfo->iNumRTPReceived - pPacketInfo->iNumLastReceived)*sizeof(unsigned short)); pPacketInfo->iNumLastReceived = pPacketInfo->iNumRTPReceived - pPacketInfo->iNumLastReceived; pPacketInfo->iNumRTPReceived = pPacketInfo->iNumLastReceived; } return RTP_EC_OK; } int RTPCLIENT::CheckValidRTPHeader(unsigned char *pcHeader) { int iRet; RTPDATAFRAME DataFrame; RTPDataFrameInit(pcHeader, RTP_HEADER_SIZE, &DataFrame); iRet = ParseRTPHeader(&DataFrame); return iRet; } int RTPCLIENT::OnReceiveData(int iSession) { RTPCLIENTSESSION *pSession = pSessions[iSession]; RTPDATAFRAME *pDataFrame = &(pSession->DataFrame); unsigned long long ullCurTime = tprtsp_time_ms; RTPDATAFRAME tmpDataFrame; // parse data from RTP packet if (bRTPOverTCP == 0) { MBUFFERByteConvert2ReadBuff(&(pDataFrame->ByteArray)); } if (RTP_EC_FAILIURE == ParseRTPHeader(pDataFrame)) { return RTP_EC_FAILIURE; } if (RTPDataGetPayloadSize(pDataFrame) <= 0) { return(RTP_EC_FAILIURE); } pSession->usLastSN = pDataFrame->iSN; //TPWLog(TPWLOG_MODULE_RTSPRTP, TPWLOG_LEVEL_DEBUG, "SN %d\n", pDataFrame->iSN); // ģ�ⶪ�� /* if (rand() % 50 == 1) { //TPWLog(TPWLOG_MODULE_RTSPRTP, TPWLOG_LEVEL_DEBUG, "?Lose packet %d\n", pDataFrame->iSN); return(RTP_EC_OK); }*/ if (pSession->uiSSRC != pDataFrame->uiSyncSource) { InitRTPSourceStat(&pSession->RTPSourceStat, pDataFrame->iSN); pSession->RTPSourceStat.uiProbation = RTP_MIN_SEQUENTIAL; } else { RTCPUpdateSeq(&pSession->RTPSourceStat, pDataFrame->iSN); /* �����հ���Ÿ���ͳ����Ϣ����RTCP RR�� */ } pSession->uiSSRC = pDataFrame->uiSyncSource; if (pSession->uiFirstTS == 0) { pSession->uiFirstTS = pDataFrame->uiTimeStamp; } if (bRTPOverTCP == 0) SendACK(iSession, pDataFrame->iSN); ParseRTPPayload(pDataFrame, pSession->iCodec); if (bRTPOverTCP == 0) { int ret; do { //��data frame����rtp���е����кŷ��뻷�϶�Ӧ��λ�� ret = pSession->frameRing.InsertDataFrame(pDataFrame, &tmpDataFrame); if (RTP_EC_DUPLICATE == ret) { //�����ظ��İ�����Ӷ��л�������ɾ������ pSession->PacketQueue.RemoveItem(&pDataFrame->ByteArray); } else if (RTP_EC_CONFLICT == ret) { pSession->PacketQueue.RemoveItem(&tmpDataFrame.ByteArray); } else { //�ӻ��ϰ����к�ȡ����һ��Ҫ�����BQ��data frame int output_ret = 0; while ((output_ret = pSession->frameRing.OutputDataFrame(&tmpDataFrame)) != 0) { if (output_ret > 0) { OutputDataFrameToBQ(iSession, &tmpDataFrame); } pSession->PacketQueue.RemoveItem(&tmpDataFrame.ByteArray); } } } while(RTP_EC_AGAIN == ret || RTP_EC_CONFLICT == ret); while(pSession->PacketQueue.SpaceAvailable() <= (RTP_PACKET_SIZE_MAX << 1)) { //��������һ��RTP�� if (pSession->frameRing.IgnoreOneFrame()) { //�ӻ��ϰ����к�ȡ����һ��Ҫ�����BQ��data frame int output_ret = 0; while ((output_ret = pSession->frameRing.OutputDataFrame(&tmpDataFrame)) != 0) { if (output_ret > 0) { OutputDataFrameToBQ(iSession, &tmpDataFrame); } pSession->PacketQueue.RemoveItem(&tmpDataFrame.ByteArray); } } else { //������ʧ��ʱ��ɾ����ͷ���� int slotIndex = pSession->PacketQueue.HeadItem()->slot; RTPDATAFRAME *pFrame = pSession->frameRing.DataFrameAt(slotIndex); RTSPM_PRINT(RTSPM_MSG_NOTICE, "delete seq %d due to buffer size\n", pFrame->iSN); pSession->PacketQueue.RemoveItem(&pFrame->ByteArray); pSession->frameRing.DropDataFrame(slotIndex); } } } else { OutputDataFrameToBQ(iSession, pDataFrame); } if (ullCurTime - pSession->ullLastRRTime >= RTP_RECEIVER_REPORT_INTERVAL) { if (bRTPOverTCP) /* tcp ģʽ��rtcp��ǰ��һ��4�ֽڵ�ͷ�����ڿͻ��˶�rtp rtcp�Ľ⸴�� */ MBUFFERByteArrayPutUIntBE(0, &(pSession->ControlFrame2Send.ByteArray)); RTPCONTROLRECEIVERREPORT Report; Report.uiSsrc = pSession->uiSSRC; //Ϊ�˼��㶪���ʣ���Ҫ֪��ÿ��Դ��������rtp����ʵ�ʽ��յ�rtp���� //ÿ��������ʱ��ʹ�ýṹRTPSOURCESTATE������صİ������Ϣ�� unsigned char ucFraction = 0;//������,����С����С���������� RTPSOURCESTAT *pRTPSourceStat = &pSession->RTPSourceStat; int iExtendedMax = pRTPSourceStat->uiCycles + pRTPSourceStat->usMaxSeq; int iExpected = iExtendedMax - pRTPSourceStat->uiBaseSeq + 1; int iLost = iExpected - pRTPSourceStat->uiReceived; //�������� int iExpectedInterval = iExpected - pRTPSourceStat->uiExpectedPrior; //�������յİ��� pRTPSourceStat->uiExpectedPrior = iExpected; int iReceivedInterval = pRTPSourceStat->uiReceived - pRTPSourceStat->uiReceivedPrior; pRTPSourceStat->uiReceivedPrior = pRTPSourceStat->uiReceived; int ilostInterval = iExpectedInterval - iReceivedInterval; //��ʧ���� if (iExpectedInterval == 0 || ilostInterval <= 0) { ucFraction = 0; } else { ucFraction = (ilostInterval << 8) / iExpectedInterval; } Report.ucFraction = ucFraction; Report.iNumPacketsLost = iLost; Report.iLastSN = iExtendedMax; Report.uiJitter = 0; Report.uiLastSR = 0; Report.uiDelayLastSR = 0; //TPWLog(TPWLOG_MODULE_RTSPRTP, TPWLOG_LEVEL_DEBUG, "rtcp rr iExpectedInterval %d, iReceivedInterval %d\n", iExpectedInterval, iReceivedInterval); RTPControlBuildRR(pSession->uiClientSSRC, 1, &Report, &pSession->ControlFrame2Send); pSession->SDESFrame.uiSrc = pSession->uiClientSSRC; RTPControlBuildSDES(&(pSession->SDESFrame), &(pSession->ControlFrame2Send)); if (bRTPOverTCP) { int iSize = MBUFFERByteArrayCurPos(&pSession->ControlFrame2Send.ByteArray); MBUFFERByteArraySeek(0, &pSession->ControlFrame2Send.ByteArray); MBUFFERByteArrayPutUChar(&#39;$&#39;, &pSession->ControlFrame2Send.ByteArray); MBUFFERByteArrayPutUChar(pSession->iTCPControlID, &pSession->ControlFrame2Send.ByteArray); MBUFFERByteArrayPutUShortBE(iSize - 4, &pSession->ControlFrame2Send.ByteArray); MBUFFERByteArraySeek(iSize, &pSession->ControlFrame2Send.ByteArray); } WriteControl(iSession); pSession->ullLastRRTime = ullCurTime; } return RTP_EC_OK; } int RTPCLIENT::SendRTCPData(int iSession) { RTPCLIENTSESSION *pSession = pSessions[iSession]; unsigned long long ullCurTime = tprtsp_time_ms; if (pSession && ullCurTime - pSession->ullLastRRTime >= RTP_RECEIVER_REPORT_INTERVAL) { if (bRTPOverTCP) /* tcp ģʽ��rtcp��ǰ��һ��4�ֽڵ�ͷ�����ڿͻ��˶�rtp rtcp�Ľ⸴�� */ MBUFFERByteArrayPutUIntBE(0, &(pSession->ControlFrame2Send.ByteArray)); RTPCONTROLRECEIVERREPORT Report; Report.uiSsrc = pSession->uiSSRC; //Ϊ�˼��㶪���ʣ���Ҫ֪��ÿ��Դ��������rtp����ʵ�ʽ��յ�rtp���� //ÿ��������ʱ��ʹ�ýṹRTPSOURCESTATE������صİ������Ϣ�� /* unsigned char ucFraction = 0;//������,����С����С���������� RTPSOURCESTAT *pRTPSourceStat = &pSession->RTPSourceStat; int iExtendedMax = pRTPSourceStat->uiCycles + pRTPSourceStat->usMaxSeq; int iExpected = iExtendedMax - pRTPSourceStat->uiBaseSeq + 1; int iLost = iExpected - pRTPSourceStat->uiReceived; //�������� int iExpectedInterval = iExpected - pRTPSourceStat->uiExpectedPrior; //�������յİ��� pRTPSourceStat->uiExpectedPrior = iExpected; int iReceivedInterval = pRTPSourceStat->uiReceived - pRTPSourceStat->uiReceivedPrior; pRTPSourceStat->uiReceivedPrior = pRTPSourceStat->uiReceived; int ilostInterval = iExpectedInterval - iReceivedInterval; //��ʧ���� if (iExpectedInterval == 0 || ilostInterval <= 0) { ucFraction = 0; } else { ucFraction = (ilostInterval << 8) / iExpectedInterval; } */ Report.ucFraction = 0; Report.iNumPacketsLost = 0; Report.iLastSN = 0; Report.uiJitter = 0; Report.uiLastSR = 0; Report.uiDelayLastSR = 0; //TPWLog(TPWLOG_MODULE_RTSPRTP, TPWLOG_LEVEL_DEBUG, "rtcp rr iExpectedInterval %d, iReceivedInterval %d\n", iExpectedInterval, iReceivedInterval); RTPControlBuildRR(pSession->uiClientSSRC, 1, &Report, &pSession->ControlFrame2Send); pSession->SDESFrame.uiSrc = pSession->uiClientSSRC; RTPControlBuildSDES(&(pSession->SDESFrame), &(pSession->ControlFrame2Send)); if (bRTPOverTCP) { int iSize = MBUFFERByteArrayCurPos(&pSession->ControlFrame2Send.ByteArray); MBUFFERByteArraySeek(0, &pSession->ControlFrame2Send.ByteArray); MBUFFERByteArrayPutUChar(&#39;$&#39;, &pSession->ControlFrame2Send.ByteArray); MBUFFERByteArrayPutUChar(pSession->iTCPControlID, &pSession->ControlFrame2Send.ByteArray); MBUFFERByteArrayPutUShortBE(iSize - 4, &pSession->ControlFrame2Send.ByteArray); MBUFFERByteArraySeek(iSize, &pSession->ControlFrame2Send.ByteArray); } WriteControl(iSession); pSession->ullLastRRTime = ullCurTime; } return RTP_EC_OK; } int RTPCLIENT::OutputDataFrameToBQ(int iSession, RTPDATAFRAME *pDataFrame) { RTPCLIENTSESSION *pSession = pSessions[iSession]; if (iSession == RTP_SESSION_AUDIO) { switch (pSession->iCodec) { case ACODEC_TYPE_AAC: pSession->pBuffer->SetRTPTS(pDataFrame->uiTimeStamp, pSession->iSampleRate); WriteAACRTP2ESBuffer((uint8_t*)RTPDataGetPayloadPtr(pDataFrame), pDataFrame->iPayloadSize, pSession->pBuffer, iMPEG4GenericSizeLength, iMPEG4GenericIndexLength, iMPEG4GenericIndexDeltaLength, pucADTSHeader); break; case ACODEC_TYPE_MP2: /* ȥ��MP2֡ͷǰ��4���ֽڵ�0 */ pSession->pBuffer->SetRTPTS(pDataFrame->uiTimeStamp, pSession->iSampleRate); pSession->pBuffer->AppendData(pSession->iCodec, 1, (uint8_t*)RTPDataGetPayloadPtr(pDataFrame) + 4, pDataFrame->iPayloadSize - 4); break; default: /* ���ڷ�aac, mp2����İ���ֱ�ӽ�payloadд��esbuffer */ pSession->pBuffer->SetRTPTS(pDataFrame->uiTimeStamp, pSession->iSampleRate); pSession->pBuffer->AppendData(pSession->iCodec, 1, (uint8_t*)RTPDataGetPayloadPtr(pDataFrame), pDataFrame->iPayloadSize); break; } } else if (iSession == RTP_SESSION_VIDEO) { pSession->pBuffer->SetRTPTS(pDataFrame->uiTimeStamp, pSession->iSampleRate); pSession->pBuffer->SetFrameRtpSN(pDataFrame->iSN); pSession->pBuffer->SetVirIFrame(pDataFrame->bVirtualIFrame); #if 0 /*!< ����RTP�� */ printf("[SN,len]-[%d,%d]:", pDataFrame->iSN,pDataFrame->iPayloadSize); for( int i =0; i<20; i++ ) { printf("%02X",pDataFrame->ByteArray.pucBuffer[i]); } printf("\n"); #endif WriteRTPPkt2ESBuffer(pSession->iCodec, pDataFrame->iStartOfPicture, pDataFrame->iEndOfPicture, (char *)RTPDataGetPayloadPtr(pDataFrame), pDataFrame->iPayloadSize, pSession->pBuffer); } return OK; } int RTPCLIENT::GetDataFrame(int iSession,char *pcData, int iLength) { RTPDataFrameInit((unsigned char *)pcData, iLength, &(pSessions[iSession]->DataFrame)); return RTP_EC_OK; } int RTPCLIENT::GetControlFrame(int iSession, char *pcData, int iLength) { RTPControlFrameInit((unsigned char *)pcData, iLength, &(pSessions[iSession]->ControlFrameReceived)); return RTP_EC_OK; } RTPCLIENTSESSION *RTPCLIENT::GetSession(unsigned int sessionIndex) { if (sessionIndex >= RTP_SESSION_NUM) { return NULL; } return pSessions[sessionIndex]; } int RTPCLIENT::Execute(int iGotFrame) { int i, iDidSomeJob = 0; // to make it work with RTP over TCP, only one job is done for every single run if (bRTPOverTCP) { if (iGotFrame & RTP_GOT_AUDIO_DATAFRAME) { OnReceiveData(RTP_SESSION_AUDIO); } else if (iGotFrame & RTP_GOT_AUDIO_CONTROLFRAME) { OnReceiveControl(RTP_SESSION_AUDIO); } else if (iGotFrame & RTP_GOT_VIDEO_DATAFRAME) { OnReceiveData(RTP_SESSION_VIDEO); } else if (iGotFrame & RTP_GOT_VIDEO_CONTROLFRAME) { OnReceiveControl(RTP_SESSION_VIDEO); } iDidSomeJob = iGotFrame; } else { for (i = 0; i < RTP_SESSION_NUM; i++) { if (pSessions[i]) { //��recv�����ݷ�����л������� if (OK != pSessions[i]->PacketQueue.WriteItemOpen(&(pSessions[i]->DataFrame.ByteArray), RTP_PACKET_SIZE_MAX)) { return RTP_EC_FAILIURE; } int iReadLength = pSessions[i]->pDataClient->Recv(&(pSessions[i]->DataFrame.ByteArray)); int writeLen = (iReadLength > 0 ? iReadLength : 0); pSessions[i]->PacketQueue.WriteItemClose(&(pSessions[i]->DataFrame.ByteArray), writeLen); if (iReadLength > 0) { if (RTP_EC_FAILIURE == OnReceiveData(i)) { pSessions[i]->PacketQueue.RemoveItem(&(pSessions[i]->DataFrame.ByteArray)); } iDidSomeJob = 1; } else if (iReadLength == TPUDP_EC_TIMEOUT) { return RTP_EC_TIMEOUT; } iReadLength = pSessions[i]->pControlClient->Recv(&(pSessions[i]->ControlFrameReceived.ByteArray)); if (iReadLength > 0) { OnReceiveControl(i); } } } } if (iDidSomeJob) return RTP_EC_DID_SOME_JOB; else return RTP_EC_OK; } int RTPCLIENT::GetVideoDataSocket() { if (!bRTPOverTCP && pSessions[RTP_SESSION_VIDEO] && pSessions[RTP_SESSION_VIDEO]->pDataClient) { return pSessions[RTP_SESSION_VIDEO]->pDataClient->sock; } return -1; } RTPEXECUTOR::RTPEXECUTOR() { int i; for (i = 0; i < RTP_MAX_CLIENTS; i++) { pRTPClients[i] = NULL; } } int RTPEXECUTOR::Execute() { int i, iNeedSleep; while (bThreadProcessing) { iNeedSleep = 1; for (i = 0; i < RTP_MAX_CLIENTS; i++) { if (pRTPClients[i]) { if (pRTPClients[i]->Execute(0) == RTP_EC_DID_SOME_JOB) iNeedSleep = 0; } } if (iNeedSleep) TPThreadMSleep(1); } return RTP_EC_OK; } int RTPEXECUTOR::RegisterClient(RTPCLIENT *pClient) { int i; // find an available slot for (i = 0; i < RTP_MAX_CLIENTS; i++) { if (pRTPClients[i] == NULL) { pRTPClients[i] = pClient; return(RTP_EC_OK); } } return(RTP_EC_FAILIURE); } int RTPEXECUTOR::UnRegisterClient(RTPCLIENT *pClient) { // find an available slot for (int i = 0; i < RTP_MAX_CLIENTS; i++) { if (pRTPClients[i] == pClient) { pRTPClients[i] = NULL; return(RTP_EC_OK); } } return(RTP_EC_FAILIURE); } RTPFRAMERING::RTPFRAMERING() { minSeqInvalid = true; minSeq = -1; //���ֵ memset(slots, 0, sizeof(slots)); } RTPDATAFRAME* RTPFRAMERING::DataFrameAt(int index) { NVRCORE_ENSURE_RET_VAL(index >= 0 && index < RTP_FRAME_RING_SIZE, NULL); NVRCORE_ENSURE_RET_VAL(slots[index].state == RTPFRAMERINGSLOT::RECVD, NULL); return &slots[index].dataFrame; } void RTPFRAMERING::DropDataFrame(int index) { NVRCORE_ENSURE_RET_VOID(index >= 0 && index < RTP_FRAME_RING_SIZE); NVRCORE_ENSURE_RET_VOID(slots[index].state == RTPFRAMERINGSLOT::RECVD); slots[index].state = RTPFRAMERINGSLOT::DELETED; } int RTPFRAMERING::InsertDataFrame(RTPDATAFRAME *pFrame, RTPDATAFRAME *pConflictFrame) { uint16_t curseq = pFrame->iSN; int16_t seqdiff = curseq - minSeq; //unsigned ����󸳸�signed������ȷ����seq�ع� int slotIndex = (curseq % RTP_FRAME_RING_SIZE); Item* pItem = NULL; //printf("insert sn: %8d minSeq: %8d\n", pFrame->iSN, minSeq); //������������ʱminSeq����Ч�ģ�ֱ���յ�һ֡����ʼRTP�����Ž�minSeq��Ϊ��Ч if (minSeqInvalid) { if (pFrame->iStartOfPicture) { minSeqInvalid = false; minSeq = curseq; } goto done; } if (seqdiff < 0) { return RTP_EC_DUPLICATE; } //��minSeq��Ӧ�İ���û�������minSeq + RTP_FRAME_RING_SIZE //��Ӧ�İ����ˣ����ټ�����minSeq��Ӧ�İ� else if (seqdiff >= RTP_FRAME_RING_SIZE) { RTSPM_PRINT(RTSPM_MSG_NOTICE, "omit seq %d due to ring size\n", minSeq); minSeq++; return RTP_EC_AGAIN; } else if (slots[slotIndex].state == RTPFRAMERINGSLOT::RECVD) { if (slots[slotIndex].dataFrame.iSN == curseq) return RTP_EC_DUPLICATE; else { //������λ������RTP��, ���뵱ǰ����ͬ, ����ɾ��, ����ΪOUTPUT *pConflictFrame = slots[slotIndex].dataFrame; slots[slotIndex].state = RTPFRAMERINGSLOT::OUTPUT; return RTP_EC_CONFLICT; } } done: pItem = (Item*)(pFrame->ByteArray.pucBuffer - sizeof(Item)); pItem->slot = slotIndex; slots[slotIndex].dataFrame = *pFrame; slots[slotIndex].state = RTPFRAMERINGSLOT::RECVD; return OK; } int RTPFRAMERING::OutputDataFrame(RTPDATAFRAME *pFrame) { int ret = 0; int slotIndex = (minSeq % RTP_FRAME_RING_SIZE); if (minSeqInvalid) goto done; while (slots[slotIndex].state == RTPFRAMERINGSLOT::DELETED) { slots[slotIndex].state = RTPFRAMERINGSLOT::EMPTY; minSeq++; slotIndex = (minSeq % RTP_FRAME_RING_SIZE); } //minSeqΪ��һ��Ҫ�����BQ��RTP�������кţ�����Ӧ��RTP���Ѿ��յ��� //��������������ΪOUTPUT if (slots[slotIndex].state == RTPFRAMERINGSLOT::RECVD) { if (slots[slotIndex].dataFrame.iSN == minSeq) { ret = 1; minSeq++; } else { ret = -1; } *pFrame = slots[slotIndex].dataFrame; slots[slotIndex].state = RTPFRAMERINGSLOT::OUTPUT; } done: return ret; } bool RTPFRAMERING::IgnoreOneFrame() { RTSPM_PRINT(RTSPM_MSG_WARNING, "omit seq %d due to buffer size\n", minSeq); minSeq++; return !minSeqInvalid; } void RTPFRAMERING::Dump() { int startIdx = minSeq % RTP_FRAME_RING_SIZE; int idx = startIdx; printf("minSeq = %d\n", minSeq); do { if (slots[idx].state == RTPFRAMERINGSLOT::EMPTY) printf("seq: %5d state: %6s\n", slots[idx].dataFrame.iSN, "empty"); else if (slots[idx].state == RTPFRAMERINGSLOT::OUTPUT) printf("seq: %5d state: %6s\n", slots[idx].dataFrame.iSN, "output"); else if (slots[idx].state == RTPFRAMERINGSLOT::RECVD) printf("seq: %5d state: %6s data: %10x - %10x, len: %8d\n", slots[idx].dataFrame.iSN, "empty", slots[idx].dataFrame.ByteArray.pucBuffer, slots[idx].dataFrame.ByteArray.pucBuffer + slots[idx].dataFrame.ByteArray.iSize, slots[idx].dataFrame.ByteArray.iSize); else printf("unknown state: %d\n", slots[idx].state); idx = (idx + 1) % RTP_FRAME_RING_SIZE; } while(idx != startIdx); }
最新发布
11-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值