int RtspConnection::setup() { int res; if((res=sendAndVerify(RTSP_DESCRIBE))<0) return res; const std::string *contentLengthStr = GetResponseHeader("Content-Length"); if(!contentLengthStr) return CONNERR_GENERIC; int contentLength = atoi(contentLengthStr->c_str()); char *describeData = new char[contentLength+1]; if((res=read(describeData, contentLength))<0) return res; //TODO: error handling describeData[contentLength] = 0; parseDescribeData(describeData); delete []describeData; int audio = -1; int video = -1; for(size_t i = 0; i < streams.size(); i++) { if(audio==-1 && streams[i].streamType == Stream::AUDIO) audio = i; if(video==-1 && streams[i].streamType == Stream::VIDEO) video = i; } if((res=setupStream(audio))<0) return res; if((res=setupStream(video))<0) return res; return 1; }
bool CinderDSAPI::initStereo(const FrameSize &pRes, const int &pFPS, const StereoCam &pWhich) { ivec2 cSize; if (setupStream(pRes, cSize)) { if ((mLRZWidth > 0 && cSize.x != mLRZWidth) || (mLRZHeight > 0 && cSize.y != mLRZHeight)) return false; bool cModeSet = false; if (pWhich == DS_LEFT || pWhich == DS_BOTH) { mHasLeft = mDSAPI->enableLeft(true); cModeSet = mDSAPI->setLRZResolutionMode(true, cSize.x, cSize.y, pFPS, DS_LUMINANCE8); } if (pWhich == DS_RIGHT || pWhich == DS_BOTH) { mHasRight = mDSAPI->enableRight(true); cModeSet = mDSAPI->setLRZResolutionMode(true, cSize.x, cSize.y, pFPS, DS_LUMINANCE8); } switch (pWhich) { case DS_LEFT: return mHasLeft&&cModeSet; case DS_RIGHT: return mHasRight&&cModeSet; case DS_BOTH: return (mHasLeft && mHasRight) && cModeSet; } } return false; }
/** * Create a channel element for remote data exchange. * @param transport The type specific object that will be used to marshal the data. */ MQChannelElement(base::PortInterface* port, types::TypeMarshaller const& transport, const ConnPolicy& policy, bool is_sender) : MQSendRecv(transport) , read_sample(new internal::ValueDataSource<T>) , write_sample(new internal::LateConstReferenceDataSource<T>) { Logger::In in("MQChannelElement"); setupStream(read_sample, port, policy, is_sender); }
bool CinderDSAPI::initDepth(const FrameSize &pRes, const int &pFPS) { ivec2 cSize; if (setupStream(pRes, cSize)) { if(mDSAPI->enableZ(true)) { mHasDepth = mDSAPI->setLRZResolutionMode(true, cSize.x, cSize.y, pFPS, DS_LUMINANCE8); if (mHasDepth) { mLRZWidth = cSize.x; mLRZHeight = cSize.y; mDepthFrame = Channel16u(mLRZWidth, mLRZHeight); mDSAPI->getCalibIntrinsicsZ(mZIntrinsics); } } } return mHasDepth; }
bool CinderDSAPI::initRgb(const FrameSize &pRes, const int &pFPS) { ivec2 cSize; if(setupStream(pRes, cSize)) { mDSRGB = mDSAPI->accessThird(); if (mDSRGB) { if(mDSRGB->enableThird(true)) { mHasRgb = mDSRGB->setThirdResolutionMode(true, cSize.x, cSize.y, pFPS, DS_RGB8); if (mHasRgb) { mRgbWidth = cSize.x; mRgbHeight = cSize.y; mRgbFrame = Surface8u(mRgbWidth, mRgbHeight, false, SurfaceChannelOrder::RGB); mDSRGB->getCalibIntrinsicsRectThird(mRgbIntrinsics); mDSRGB->getCalibExtrinsicsZToRectThird(mZToRgb); } } } } return mHasRgb; }
/* Perform RTSP Handshake with the streaming server machine as part of the connection process */ int performRtspHandshake(IP_ADDRESS addr, PSTREAM_CONFIGURATION streamConfigPtr) { struct in_addr inaddr; // Initialize global state remoteAddr = addr; memcpy(&inaddr, &addr, sizeof(addr)); sprintf(rtspTargetUrl, "rtsp://%s", inet_ntoa(inaddr)); currentSeqNumber = 1; hasSessionId = 0; if (serverMajorVersion == 3) { rtspClientVersion = 10; } else { rtspClientVersion = 11; } { RTSP_MESSAGE response; if (!requestOptions(&response)) { Limelog("RTSP OPTIONS request failed\n"); return -1; } if (response.message.response.statusCode != 200) { Limelog("RTSP OPTIONS request failed: %d\n", response.message.response.statusCode); return -1; } freeMessage(&response); } { RTSP_MESSAGE response; if (!requestDescribe(&response)) { Limelog("RTSP DESCRIBE request failed\n"); return -1; } if (response.message.response.statusCode != 200) { Limelog("RTSP DESCRIBE request failed: %d\n", response.message.response.statusCode); return -1; } freeMessage(&response); } { RTSP_MESSAGE response; char* sessionId; if (!setupStream(&response, "streamid=audio")) { Limelog("RTSP SETUP streamid=audio request failed\n"); return -1; } if (response.message.response.statusCode != 200) { Limelog("RTSP SETUP streamid=audio request failed: %d\n", response.message.response.statusCode); return -1; } sessionId = getOptionContent(response.options, "Session"); if (sessionId == NULL) { Limelog("RTSP SETUP streamid=audio is missing session attribute"); return -1; } strcpy(sessionIdString, sessionId); hasSessionId = 1; freeMessage(&response); } { RTSP_MESSAGE response; if (!setupStream(&response, "streamid=video")) { Limelog("RTSP SETUP streamid=video request failed\n"); return -1; } if (response.message.response.statusCode != 200) { Limelog("RTSP SETUP streamid=video request failed: %d\n", response.message.response.statusCode); return -1; } freeMessage(&response); } { RTSP_MESSAGE response; if (!sendVideoAnnounce(&response, streamConfigPtr)) { Limelog("RTSP ANNOUNCE request failed\n"); return -1; } if (response.message.response.statusCode != 200) { Limelog("RTSP ANNOUNCE request failed: %d\n", response.message.response.statusCode); return -1; } freeMessage(&response); } { RTSP_MESSAGE response; if (!playStream(&response, "streamid=video")) { Limelog("RTSP PLAY streamid=video request failed\n"); return -1; } if (response.message.response.statusCode != 200) { Limelog("RTSP PLAY streamid=video failed: %d\n", response.message.response.statusCode); return -1; } freeMessage(&response); } { RTSP_MESSAGE response; if (!playStream(&response, "streamid=audio")) { Limelog("RTSP PLAY streamid=audio request failed\n"); return -1; } if (response.message.response.statusCode != 200) { Limelog("RTSP PLAY streamid=audio failed: %d\n", response.message.response.statusCode); return -1; } freeMessage(&response); } return 0; }