Skip to content

Commit

Permalink
Merge pull request IntelRealSense#34 from IntelRealSense/michalpr_tmp…
Browse files Browse the repository at this point in the history
…branch

fixes
  • Loading branch information
michalprager authored Jan 14, 2020
2 parents 45d99a7 + e5ec0f1 commit 817b41d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 60 deletions.
20 changes: 10 additions & 10 deletions examples/rtsp-client-app/myClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<rs2_video_stream> 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";
Expand Down
97 changes: 47 additions & 50 deletions src/ethernet/camOERtspClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ std::vector<rs2_video_stream> 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()) {
Expand Down Expand Up @@ -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<int, MediaSubsession*>(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<std::mutex> lck(command_mtx);
cammand_done = true;
// TODO: update width and height in subsession?
((camOERTSPClient*)rtspClient)->subsessionMap.insert(std::pair<int, MediaSubsession*>(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<std::mutex> lck(command_mtx);
cammand_done = true;
}
cv.notify_one();

// An unrecoverable error occurred with this stream.
// TODO:
//shutdownStream(rtspClient);
Expand Down

0 comments on commit 817b41d

Please sign in to comment.