diff --git a/examples/rtsp-client-app/myClient.cpp b/examples/rtsp-client-app/myClient.cpp index 3dc9d67f8a..7d1c1122a2 100644 --- a/examples/rtsp-client-app/myClient.cpp +++ b/examples/rtsp-client-app/myClient.cpp @@ -39,21 +39,21 @@ int main() } - IcamOERtsp* camOErtspInstance2 = camOERTSPClient::getRtspClient("rtsp://10.12.145.82:8554/color", "myClient"); + //IcamOERtsp* camOErtspInstance2 = camOERTSPClient::getRtspClient("rtsp://10.12.145.82:8554/color", "myClient"); //IcamOERtsp* camOErtspInstance2 = camOERTSPClient::getRtspClient("rtsp://10.12.144.35:8554/unicast", "myClient"); std::vector myProfiles2; - ((camOERTSPClient*)camOErtspInstance2)->initFunc(); - myProfiles2 = camOErtspInstance2->queryStreams(); - std::cout << "Size = " << myProfiles2.size() << "\n"; - for (int i = 0; i < myProfiles2.size(); i++) - { - std::cout << "Profile " << i << ": " << "width = " << myProfiles2[i].width << " height = " << myProfiles2[i].height << " sensor id = " << myProfiles2[i].type << " UID = " << myProfiles2[i].uid << "\n"; - } + //((camOERTSPClient*)camOErtspInstance2)->initFunc(); + // myProfiles2 = camOErtspInstance2->queryStreams(); + //std::cout << "Size = " << myProfiles2.size() << "\n"; + //for (int i = 0; i < myProfiles2.size(); i++) + //{ + // std::cout << "Profile " << i << ": " << "width = " << myProfiles2[i].width << " height = " << myProfiles2[i].height << " sensor id = " << myProfiles2[i].type << " UID = " << myProfiles2[i].uid << "\n"; + //} res = camOErtspInstance->addStream(myProfiles[0], &myFrameCallBack); std::cout << "After setup. res = " << res << "\n"; - // res = camOErtspInstance->start(); - // std::cout << "After start. res = " << res << "\n"; + //res = camOErtspInstance->start(); + //std::cout << "After start. res = " << res << "\n"; //res = camOErtspInstance2->addStream(myProfiles2[0], &myFrameCallBack); //std::cout << "After setup. res = " << res << "\n"; diff --git a/src/ethernet/camOERtspClient.cpp b/src/ethernet/camOERtspClient.cpp index f2d8378a5f..edbda8618b 100644 --- a/src/ethernet/camOERtspClient.cpp +++ b/src/ethernet/camOERtspClient.cpp @@ -67,9 +67,7 @@ std::vector camOERTSPClient::queryStreams() } int camOERTSPClient::addStream(rs2_video_stream stream, frame_call_back frameCallBack) { - //MediaSubsession* subsession = this->subsessionMap.find(stream.uid)->second; - //nhershko - hard coded to subsession per media-session - MediaSubsession* subsession = this->subsessionMap.find(0)->second; + MediaSubsession* subsession = this->subsessionMap.find(stream.uid)->second; if (subsession != NULL) { if (!subsession->initiate()) { @@ -201,61 +199,60 @@ void camOERTSPClient::continueAfterDESCRIBE(RTSPClient* rtspClient, int resultCo } - int stream_counter = 0; - scs.iter = new MediaSubsessionIterator(*scs.session); - scs.subsession = scs.iter->next(); - while (scs.subsession != NULL) { - // Get more data from the SDP string - const char* strWidthVal = scs.subsession->attrVal_str("width"); - const char* strHeightVal = scs.subsession->attrVal_str("height"); - int width = strWidthVal != NULL ? std::stoi(strWidthVal) : 0; - int height = strHeightVal != NULL ? std::stoi(strHeightVal) : 0; - rs2_video_stream videoStream; - videoStream.width = width; - videoStream.height = height; - videoStream.uid = stream_counter; - - std::string url_str = rtspClient->url(); - // Remove last "/" - url_str = url_str.substr(0, url_str.size()-1); - std::size_t stream_name_index = url_str.find_last_of("/") + 1; - std::string stream_name = url_str.substr(stream_name_index, url_str.size()); - if (stream_name.compare("depth") == 0) - { - videoStream.type = RS2_STREAM_DEPTH; - //nhershko: hard coded - videoStream.fmt = RS2_FORMAT_Z16; - } - else if((stream_name.compare("color") == 0)) - { - videoStream.type = RS2_STREAM_COLOR; - //nhershko: hard coded - videoStream.fmt = RS2_FORMAT_YUYV; - } - - //nhershko: hard coded fixes - videoStream.bpp=2; - videoStream.fps=30; + int stream_counter = 0; + scs.iter = new MediaSubsessionIterator(*scs.session); + scs.subsession = scs.iter->next(); + while (scs.subsession != NULL) { + // Get more data from the SDP string + const char* strWidthVal = scs.subsession->attrVal_str("width"); + const char* strHeightVal = scs.subsession->attrVal_str("height"); + int width = strWidthVal != NULL ? std::stoi(strWidthVal) : 0; + int height = strHeightVal != NULL ? std::stoi(strHeightVal) : 0; + rs2_video_stream videoStream; + videoStream.width = width; + videoStream.height = height; + videoStream.uid = stream_counter; + std::string url_str = rtspClient->url(); + // Remove last "/" + url_str = url_str.substr(0, url_str.size()-1); + std::size_t stream_name_index = url_str.find_last_of("/") + 1; + std::string stream_name = url_str.substr(stream_name_index, url_str.size()); + if (stream_name.compare("depth") == 0) + { + videoStream.type = RS2_STREAM_DEPTH; + //nhershko: hard coded + videoStream.fmt = RS2_FORMAT_Z16; + } + else if((stream_name.compare("color") == 0)) + { + videoStream.type = RS2_STREAM_COLOR; + //nhershko: hard coded + videoStream.fmt = RS2_FORMAT_YUYV; + } + //nhershko: hard coded fixes + videoStream.bpp=2; + videoStream.fps=30; + - // TODO: update width and height in subsession? - ((camOERTSPClient*)rtspClient)->subsessionMap.insert(std::pair(videoStream.uid, scs.subsession)); - stream_counter++; - ((camOERTSPClient*)rtspClient)->supportedProfiles.push_back(videoStream); - scs.subsession = scs.iter->next(); - // TODO: when to delete p? - } - { - std::lock_guard lck(command_mtx); - cammand_done = true; + // TODO: update width and height in subsession? + ((camOERTSPClient*)rtspClient)->subsessionMap.insert(std::pair(videoStream.uid, scs.subsession)); + stream_counter++; + ((camOERTSPClient*)rtspClient)->supportedProfiles.push_back(videoStream); + scs.subsession = scs.iter->next(); + // TODO: when to delete p? } - cv.notify_one(); - return; } while (0); + { + std::lock_guard lck(command_mtx); + cammand_done = true; + } + cv.notify_one(); + // An unrecoverable error occurred with this stream. // TODO: //shutdownStream(rtspClient);