ip_device.hh
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include "RsRtspClient.h"
7 #include "ip_sensor.hh"
8 #include "rs_rtp_callback.hh"
9 
10 #include "option.h"
11 #include "software-device.h"
13 #include <librealsense2/rs.hpp>
14 
15 #include <list>
16 
17 #define MAX_ACTIVE_STREAMS 4
18 
19 #define NUM_OF_SENSORS 2
20 
21 #define POLLING_SW_DEVICE_STATE_INTERVAL 100
22 
23 #define DEFAULT_PROFILE_FPS 15
24 
25 #define DEFAULT_PROFILE_WIDTH 424
26 
27 #define DEFAULT_PROFILE_HIGHT 240
28 
29 #define DEFAULT_PROFILE_COLOR_FORMAT RS2_FORMAT_RGB8
30 
31 class ip_device
32 {
33 
34 public:
36  ~ip_device();
37 
39 
40 private:
42 
43  //TODO: get smart ptr
45 
47  unsigned int ip_port;
48 
49  //todo: consider wrapp all maps to single container
50  std::map<long long int, std::shared_ptr<rs_rtp_stream>> streams_collection;
51 
52  std::map<long long int, std::thread> inject_frames_thread;
53 
54  std::map<long long int, rs_rtp_callback*> rtp_callbacks;
55 
57 
58  bool init_device_data(rs2::software_device sw_device);
59 
60  void polling_state_loop();
61 
62  void inject_frames_loop(std::shared_ptr<rs_rtp_stream> rtp_stream);
63 
64  void stop_sensor_streams(int sensor_id);
65 
66  void update_sensor_state(int sensor_index, std::vector<rs2::stream_profile> updated_streams, bool recover);
67  void update_option_value(int sensor_index, rs2_option opt, float val);
68 
69  void set_option_value(int sensor_index, rs2_option opt, float val);
70  void get_option_value(int sensor_index, rs2_option opt, float& val);
71 
72  std::vector<rs2_video_stream> query_streams(int sensor_id);
73 
74  std::vector<IpDeviceControlData> get_controls(int sensor_id);
75 
76  void recover_rtsp_client(int sensor_index);
77 
78  // default device stream index per type + sensor_index
79  // streams will be loaded at runtime so here the place holder
80  std::map<std::pair<rs2_stream,int>,int> default_streams =
81  {
82  { std::make_pair(rs2_stream::RS2_STREAM_COLOR,0),-1},
83  { std::make_pair(rs2_stream::RS2_STREAM_DEPTH,0),-1}
84  };
85 };
bool is_device_alive
Definition: ip_device.hh:41
void get_option_value(int sensor_index, rs2_option opt, float &val)
Definition: ip_device.cpp:293
unsigned int ip_port
Definition: ip_device.hh:47
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
std::map< long long int, std::shared_ptr< rs_rtp_stream > > streams_collection
Definition: ip_device.hh:50
std::thread sw_device_status_check
Definition: ip_device.hh:56
void update_option_value(int sensor_index, rs2_option opt, float val)
Definition: ip_device.cpp:272
GLsizei const GLchar *const * string
void update_sensor_state(int sensor_index, std::vector< rs2::stream_profile > updated_streams, bool recover)
Definition: ip_device.cpp:314
GLuint GLfloat * val
void polling_state_loop()
Definition: ip_device.cpp:216
std::vector< IpDeviceControlData > get_controls(int sensor_id)
Definition: ip_device.cpp:102
#define NUM_OF_SENSORS
Definition: ip_device.hh:19
std::map< long long int, rs_rtp_callback * > rtp_callbacks
Definition: ip_device.hh:54
bool init_device_data(rs2::software_device sw_device)
Definition: ip_device.cpp:111
void inject_frames_loop(std::shared_ptr< rs_rtp_stream > rtp_stream)
Definition: ip_device.cpp:357
std::vector< rs2_video_stream > query_streams(int sensor_id)
Definition: ip_device.cpp:87
ip_device(rs2::software_device sw_device, std::string ip_address)
Definition: ip_device.cpp:69
void set_option_value(int sensor_index, rs2_option opt, float val)
Definition: ip_device.cpp:285
void recover_rtsp_client(int sensor_index)
Definition: ip_device.cpp:23
std::map< long long int, std::thread > inject_frames_thread
Definition: ip_device.hh:52
std::map< std::pair< rs2_stream, int >, int > default_streams
Definition: ip_device.hh:80
std::string ip_address
Definition: ip_device.hh:46
void stop_sensor_streams(int sensor_id)
Definition: ip_device.cpp:57
ip_sensor * remote_sensors[NUM_OF_SENSORS]
Definition: ip_device.hh:38
MemoryPool * memory_pool
Definition: ip_device.hh:44


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:17