6 #include <liveMedia.hh> 7 #include <GroupsockHelper.hh> 21 using namespace TCLAP;
27 UsageEnvironment*
env;
34 void main(
int argc,
char** argv)
42 SwitchArg arg_enable_compression(
"c",
"enable-compression",
"Enable video compression");
43 ValueArg<std::string> arg_address(
"i",
"interface-address",
"Address of the interface to bind on",
false,
"",
"string");
46 cmd.
add(arg_enable_compression);
50 cmd.
parse(argc, argv);
53 if (arg_enable_compression.
isSet())
58 if (arg_address.
isSet())
60 ReceivingInterfaceAddr = inet_addr(arg_address.
getValue().c_str());
71 scheduler = BasicTaskScheduler::createNew();
74 rsDevice = std::make_shared<RsDevice>(env);
77 if(rtspServer ==
NULL)
79 *env <<
"Failed to create RTSP server: " << env->getResultMsg() <<
"\n";
83 sensors = rsDevice.get()->getSensors();
96 for(
auto stream_profile :
sensor.getStreamProfiles())
106 if(stream.
fps() == 6)
108 if((stream.
width() == 1280 && stream.
height() == 720) || (stream.
width() == 640 && stream.
height() == 480))
112 supported_stream_profiles.push_back(stream);
116 else if(stream.
fps() == 15 || stream.
fps() == 30)
118 if((stream.
width() == 1280 && stream.
height() == 720) || (stream.
width() == 640 && stream.
height() == 480))
121 supported_stream_profiles.push_back(stream);
125 else if(stream.
fps() == 60)
127 if((stream.
width() == 640 && stream.
height() == 480))
130 supported_stream_profiles.push_back(stream);
134 else if(stream.
fps() == 10)
139 supported_stream_profiles.push_back(stream);
146 if(stream.
fps() == 6 || stream.
fps() == 15 || stream.
fps() == 30)
148 if(stream.
width() == 848 && stream.
height() == 480)
151 supported_stream_profiles.push_back(stream);
155 if(stream.
fps() == 30 || stream.
fps() == 60)
157 if(stream.
width() == 640 && stream.
height() == 360)
160 supported_stream_profiles.push_back(stream);
167 if(stream.
fps() == 6 || stream.
fps() == 15 || stream.
fps() == 30 || stream.
fps() == 60)
169 if(stream.
width() == 424 && stream.
height() == 240)
172 supported_stream_profiles.push_back(stream);
179 if(stream.
fps() == 6 || stream.
fps() == 15 || stream.
fps() == 30 || stream.
fps() == 60 || stream.
fps() == 90)
181 if(stream.
width() == 480 && stream.
height() == 270)
184 supported_stream_profiles.push_back(stream);
190 *env <<
"Ignoring stream: format: " << stream.
format() <<
" width: " << stream.
width() <<
" height: " << stream.
height() <<
" fps: " << stream.
fps() <<
"\n";
193 calculate_extrinsics();
195 rtspServer->addServerMediaSession(sms);
196 char* url = rtspServer->rtspURL(sms);
197 *env <<
"Play this stream using the URL \"" << url <<
"\"\n";
200 rtspServer->setSupportedOptions(
sensor.getSensorName(),
sensor.getSupportedOptions());
205 env->taskScheduler().doEventLoop();
210 for(
auto stream_profile_from : supported_stream_profiles)
212 for(
auto stream_profile_to : supported_stream_profiles)
217 rsDevice.get()->minimal_extrinsics_map[std::make_pair(from_sensor_key, to_sensor_key)] = stream_profile_from.get_extrinsics_to(stream_profile_to);
224 Medium::close(rtspServer);
244 int main(
int argc,
char** argv)
const int MAX_MESSAGE_SIZE
void sigint_handler(int sig)
static server & instance()
#define START_EASYLOGGINGPP(argc, argv)
const std::string RGB_SENSOR_NAME("RGB Camera")
RsRTSPServer * rtspServer
std::shared_ptr< RsDevice > rsDevice
static int getPhysicalSensorUniqueKey(rs2_stream stream_type, int sensors_index)
std::vector< rs2::video_stream_profile > supported_stream_profiles
rs2::device selected_device
const std::string STEREO_SENSOR_NAME("Stereo Module")
TaskScheduler * scheduler
void calculate_extrinsics()
static const textual_icon exit
rs2_format format() const
void parse(int argc, const char *const *argv)
#define RS2_API_VERSION_STR
static bool & getIsEnabled()
static RsRTSPServer * createNew(UsageEnvironment &t_env, std::shared_ptr< RsDevice > t_device, Port t_ourPort=554, UserAuthenticationDatabase *t_authDatabase=NULL, unsigned t_reclamationSeconds=20)
static RSUsageEnvironment * createNew(TaskScheduler &taskScheduler)
std::vector< RsSensor > sensors
void main(int argc, char **argv)