17 #include <unordered_set> 29 typedef std::function<void(std::vector<platform::stream_profile>)>
on_open;
31 class sensor_base :
public std::enable_shared_from_this<sensor_base>,
88 std::shared_ptr<stream_profile_interface> target)
const;
108 std::vector<native_pixel_format> _pixel_formats;
119 virtual void reset() = 0;
125 explicit hid_sensor(std::shared_ptr<platform::hid_device> hid_device,
126 std::unique_ptr<frame_timestamp_reader> hid_iio_timestamp_reader,
127 std::unique_ptr<frame_timestamp_reader> custom_hid_timestamp_reader,
128 std::map<
rs2_stream, std::map<unsigned, unsigned>> fps_and_sampling_frequency_per_rs2_stream,
129 std::vector<std::pair<std::string, stream_profile>> sensor_name_and_hid_profiles,
136 void close()
override;
140 void stop()
override;
142 std::vector<uint8_t> get_custom_report_data(
const std::string& custom_sensor_name,
143 const std::string& report_name,
150 const std::map<rs2_stream, uint32_t> stream_and_fourcc = {{
RS2_STREAM_GYRO,
'GYRO'},
154 const std::vector<std::pair<std::string, stream_profile>> _sensor_name_and_hid_profiles;
155 std::map<rs2_stream, std::map<uint32_t, uint32_t>> _fps_and_sampling_frequency_per_rs2_stream;
156 std::shared_ptr<platform::hid_device> _hid_device;
157 std::mutex _configure_lock;
158 std::map<std::string, stream_profile> _configured_profiles;
159 std::vector<bool> _is_configured_stream;
160 std::vector<platform::hid_sensor> _hid_sensors;
161 std::map<std::string, request_mapping> _hid_mapping;
162 std::unique_ptr<frame_timestamp_reader> _hid_iio_timestamp_reader;
163 std::unique_ptr<frame_timestamp_reader> _custom_hid_timestamp_reader;
169 uint32_t stream_to_fourcc(
rs2_stream stream)
const;
171 uint32_t fps_to_sampling_frequency(
rs2_stream stream, uint32_t fps)
const;
178 explicit uvc_sensor(std::string
name, std::shared_ptr<platform::uvc_device> uvc_device,
179 std::unique_ptr<frame_timestamp_reader> timestamp_reader,
device* dev);
184 void set_roi_method(std::shared_ptr<region_of_interest_method> roi_method)
override;
188 void close()
override;
196 -> decltype(action(*static_cast<platform::uvc_device*>(
nullptr)))
198 power on(std::dynamic_pointer_cast<uvc_sensor>(shared_from_this()));
199 return action(*_device);
207 void stop()
override;
218 void acquire_power();
220 void release_power();
222 void reset_streaming();
226 explicit power(std::weak_ptr<uvc_sensor> owner)
229 auto strong =
_owner.lock();
232 strong->acquire_power();
238 if (
auto strong =
_owner.lock())
242 strong->release_power();
248 std::weak_ptr<uvc_sensor>
_owner;
251 std::shared_ptr<platform::uvc_device> _device;
252 std::atomic<int> _user_count;
253 std::mutex _power_lock;
254 std::mutex _configure_lock;
255 std::vector<platform::extension_unit> _xus;
256 std::unique_ptr<power> _power;
257 std::unique_ptr<frame_timestamp_reader> _timestamp_reader;
258 std::shared_ptr<region_of_interest_method> _roi_method =
nullptr;
std::shared_ptr< notifications_processor > get_notifications_processor()
rs2_camera_info
Read-only strings that can be queried from the device. Not all information attributes are available o...
Definition: rs_sensor.h:22
bool is_streaming() const override
Definition: sensor.h:54
auto invoke_powered(T action) -> decltype(action(*static_cast< platform::uvc_device *>(nullptr)))
Definition: sensor.h:195
frame_source _source
Definition: sensor.h:101
notifications_callback_ptr get_notifications_callback() const override
void register_on_before_frame_callback(on_before_frame_callback callback)
Definition: sensor.h:68
void register_metadata(rs2_frame_metadata_value metadata, std::shared_ptr< md_attribute_parser_base > metadata_parser) const
std::atomic< bool > _is_opened
Definition: sensor.h:95
const device_interface & get_device() override
std::vector< request_mapping > resolve_requests(stream_profiles requests)
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
std::function< void(std::vector< platform::stream_profile >)> on_open
Definition: sensor.h:29
std::function< void(rs2_stream, frame_interface *, callback_invocation_holder)> on_before_frame_callback
Definition: sensor.h:26
std::shared_ptr< rs2_frame_callback > frame_callback_ptr
Definition: types.h:872
virtual void start(frame_callback_ptr callback)=0
std::vector< platform::stream_profile > get_configuration() const
Definition: sensor.h:190
bool supports_info(rs2_camera_info info) const override
sensor_base(std::string name, device *device)
Definition: rs_sensor.h:46
Definition: rs_sensor.h:44
Definition: streaming.h:131
on_open _on_open
Definition: sensor.h:98
void set_active_streams(const stream_profiles &requests)
virtual stream_profiles init_stream_profiles()=0
device * _owner
Definition: sensor.h:102
void raise_on_before_streaming_changes(bool streaming)
std::shared_ptr< rs2_notifications_callback > notifications_callback_ptr
Definition: types.h:874
platform::usb_spec get_usb_specification() const
Definition: sensor.h:209
virtual stream_profiles get_active_streams() const override
std::shared_ptr< notifications_processor > _notifications_processor
Definition: sensor.h:96
std::vector< platform::stream_profile > _uvc_profiles
Definition: sensor.h:103
virtual void open(const stream_profiles &requests)=0
on_before_frame_callback _on_before_frame_callback
Definition: sensor.h:97
std::vector< platform::stream_profile > _internal_config
Definition: sensor.h:92
virtual frame_callback_ptr get_frames_callback() const override
virtual ~frame_timestamp_reader()
Definition: sensor.h:114
std::vector< std::shared_ptr< stream_profile_interface >> stream_profiles
Definition: streaming.h:104
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:37
Definition: rs_sensor.h:45
void unregister_before_start_callback(int token) override
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition: rs_types.h:93
void remove_pixel_format(native_pixel_format pf)
std::shared_ptr< metadata_parser_map > _metadata_parsers
Definition: sensor.h:99
void register_on_open(on_open callback)
Definition: sensor.h:63
const std::string & get_info(rs2_camera_info info) const override
std::string get_device_path() const
Definition: sensor.h:210
Definition: streaming.h:106
void register_pixel_format(native_pixel_format pf)
int register_before_streaming_changes_callback(std::function< void(bool)> callback) override
void register_notifications_callback(notifications_callback_ptr callback) override
virtual ~sensor_base()
Definition: sensor.h:59
std::atomic< bool > _is_streaming
Definition: sensor.h:94
void assign_stream(const std::shared_ptr< stream_interface > &stream, std::shared_ptr< stream_profile_interface > target) const
bool try_get_pf(const platform::stream_profile &p, native_pixel_format &result) const
rs2_frame_metadata_value
Per-Frame-Metadata are set of read-only properties that might be exposed for each individual frame...
Definition: rs_frame.h:28
virtual void set_frames_callback(frame_callback_ptr callback) override
stream_profiles get_stream_profiles() const override
Definition: sensor.h:40
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
Definition: rs_frame.h:19