Skip to content

Commit

Permalink
Merge pull request IntelRealSense#32 from IntelRealSense/scpungin_LRS…
Browse files Browse the repository at this point in the history
…_integration

fix CAMOE-99 bug: server is stopped after minute
  • Loading branch information
nhershko authored Jan 13, 2020
2 parents 0812779 + d7a5892 commit f0454ba
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 73 deletions.
88 changes: 22 additions & 66 deletions tools/rs-server/RsRTSPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,72 +74,28 @@ ::RsRTSPClientSession(RTSPServer& ourServer, u_int32_t sessionId)

RsRTSPServer::RsRTSPClientSession::~RsRTSPClientSession(){}


void RsRTSPServer::RsRTSPClientSession
::handleCmd_withinSession(RTSPServer::RTSPClientConnection* ourClientConnection,
char const* cmdName,
char const* urlPreSuffix, char const* urlSuffix,
char const* fullRequestStr) {
// This will either be:
// - a non-aggregated operation, if "urlPreSuffix" is the session (stream)
// name and "urlSuffix" is the subsession (track) name, or
// - an aggregated operation, if "urlSuffix" is the session (stream) name,
// or "urlPreSuffix" is the session (stream) name, and "urlSuffix" is empty,
// or "urlPreSuffix" and "urlSuffix" are both nonempty, but when concatenated, (with "/") form the session (stream) name.
// Begin by figuring out which of these it is:
ServerMediaSubsession* subsession;

if (fOurServerMediaSession == NULL) { // There wasn't a previous SETUP!
((RsRTSPClientConnection*)ourClientConnection)->handleCmd_notSupported();
return;
} else if (urlSuffix[0] != '\0' && strcmp(fOurServerMediaSession->streamName(), urlPreSuffix) == 0) {
// Non-aggregated operation.
// Look up the media subsession whose track id is "urlSuffix":
ServerMediaSubsessionIterator iter(*fOurServerMediaSession);
while ((subsession = iter.next()) != NULL) {
if (strcmp(subsession->trackId(), urlSuffix) == 0) break; // success
}
if (subsession == NULL) { // no such track!
((RsRTSPClientConnection*)ourClientConnection)->handleCmd_notFound();
return;
}
} else if (strcmp(fOurServerMediaSession->streamName(), urlSuffix) == 0 ||
(urlSuffix[0] == '\0' && strcmp(fOurServerMediaSession->streamName(), urlPreSuffix) == 0)) {
// Aggregated operation
subsession = NULL;
} else if (urlPreSuffix[0] != '\0' && urlSuffix[0] != '\0') {
// Aggregated operation, if <urlPreSuffix>/<urlSuffix> is the session (stream) name:
unsigned const urlPreSuffixLen = strlen(urlPreSuffix);
if (strncmp(fOurServerMediaSession->streamName(), urlPreSuffix, urlPreSuffixLen) == 0 &&
fOurServerMediaSession->streamName()[urlPreSuffixLen] == '/' &&
strcmp(&(fOurServerMediaSession->streamName())[urlPreSuffixLen+1], urlSuffix) == 0) {
subsession = NULL;
} else {
((RsRTSPClientConnection*)ourClientConnection)->handleCmd_notFound();
return;
}
} else { // the request doesn't match a known stream and/or track at all!
((RsRTSPClientConnection*)ourClientConnection)->handleCmd_notFound();
return;
}

if (strcmp(cmdName, "TEARDOWN") == 0) {
envir() << "TEARDOWN \n";
handleCmd_TEARDOWN(ourClientConnection, subsession);
} else if (strcmp(cmdName, "PLAY") == 0) {
envir() << "PLAY \n";
openRsCamera();
handleCmd_PLAY(ourClientConnection, subsession, fullRequestStr);
} else if (strcmp(cmdName, "PAUSE") == 0) {
envir() << "PAUSE \n";
handleCmd_PAUSE(ourClientConnection, subsession);
closeRsCamera();
} else if (strcmp(cmdName, "GET_PARAMETER") == 0) {
handleCmd_GET_PARAMETER(ourClientConnection, subsession, fullRequestStr);
} else if (strcmp(cmdName, "SET_PARAMETER") == 0) {
handleCmd_SET_PARAMETER(ourClientConnection, subsession, fullRequestStr);
}
}
void RsRTSPServer::RsRTSPClientSession::handleCmd_TEARDOWN(RTSPClientConnection* ourClientConnection,
ServerMediaSubsession* subsession)
{
envir() << "TEARDOWN \n";
RTSPServer::RTSPClientSession::handleCmd_TEARDOWN(ourClientConnection,subsession);
}

void RsRTSPServer::RsRTSPClientSession::handleCmd_PLAY(RTSPClientConnection* ourClientConnection,
ServerMediaSubsession* subsession, char const* fullRequestStr)
{
envir() << "PLAY \n";
openRsCamera();
RTSPServer::RTSPClientSession::handleCmd_PLAY(ourClientConnection,subsession,fullRequestStr);
}

void RsRTSPServer::RsRTSPClientSession::handleCmd_PAUSE(RTSPClientConnection* ourClientConnection,
ServerMediaSubsession* subsession)
{
envir() << "PAUSE \n";
RTSPServer::RTSPClientSession::handleCmd_PAUSE(ourClientConnection,subsession);
closeRsCamera();
}

int RsRTSPServer::RsRTSPClientSession::openRsCamera()
{
Expand Down
12 changes: 7 additions & 5 deletions tools/rs-server/RsRTSPServer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RsRTSPServer: public RTSPServer {
public:
static RsRTSPServer* createNew(UsageEnvironment& env, Port ourPort = 554,
UserAuthenticationDatabase* authDatabase = NULL,
unsigned reclamationSeconds = 65);
unsigned reclamationSeconds = 0);

protected:
RsRTSPServer(UsageEnvironment& env,
Expand Down Expand Up @@ -61,10 +61,12 @@ public:
friend class RsRTSPServer;
friend class RsRTSPClientConnection;

virtual void handleCmd_withinSession(RTSPClientConnection* ourClientConnection,
char const* cmdName,
char const* urlPreSuffix, char const* urlSuffix,
char const* fullRequestStr);
virtual void handleCmd_TEARDOWN(RTSPClientConnection* ourClientConnection,
ServerMediaSubsession* subsession);
virtual void handleCmd_PLAY(RTSPClientConnection* ourClientConnection,
ServerMediaSubsession* subsession, char const* fullRequestStr);
virtual void handleCmd_PAUSE(RTSPClientConnection* ourClientConnection,
ServerMediaSubsession* subsession);

int openRsCamera();
int closeRsCamera();
Expand Down
2 changes: 0 additions & 2 deletions tools/rs-server/RsSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ int RsSensor::start(std::unordered_map<long long int, rs2::frame_queue> &stream_
{
auto callback = [&](const rs2::frame &frame) {
long long int profile_key = getStreamProfileKey(frame.get_profile());
std::cout<<"queue size is "<< stream_profiles_queues.size() <<"\n";
//check if profile exists in map:

if (stream_profiles_queues.find(profile_key) != stream_profiles_queues.end())
{
std::cout<<",\n";
//push frame to its queue
stream_profiles_queues[profile_key].enqueue(frame);
}
Expand Down
2 changes: 2 additions & 0 deletions tools/rs-server/rs-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ int main(int argc, char **argv)
for (auto stream_profile:sensor.getStreamProfiles())
{
rs2::video_stream_profile stream=stream_profile.second;
//if ( stream.format() == RS2_FORMAT_Z16 || stream.format() == RS2_FORMAT_Y16 || stream.format() == RS2_FORMAT_RAW16 || stream.format() == RS2_FORMAT_YUYV)

if (sensorIndex==0 && stream.width()==640 && stream.height() == 480 && stream.format()== RS2_FORMAT_Z16 && stream.fps() == 30)
{
//depth_queues[index] = rs2::frame_queue(CAPACITY, true);
Expand Down

0 comments on commit f0454ba

Please sign in to comment.