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;
107 std::vector<native_pixel_format> _pixel_formats;
118 virtual void reset() = 0;
124 explicit hid_sensor(std::shared_ptr<platform::hid_device> hid_device,
125 std::unique_ptr<frame_timestamp_reader> hid_iio_timestamp_reader,
126 std::unique_ptr<frame_timestamp_reader> custom_hid_timestamp_reader,
127 std::map<
rs2_stream, std::map<unsigned, unsigned>> fps_and_sampling_frequency_per_rs2_stream,
128 std::vector<std::pair<std::string, stream_profile>> sensor_name_and_hid_profiles,
135 void close()
override;
139 void stop()
override;
142 const std::string& report_name,
149 const std::map<rs2_stream, uint32_t> stream_and_fourcc = {{
RS2_STREAM_GYRO,
'GYRO'},
153 const std::vector<std::pair<std::string, stream_profile>> _sensor_name_and_hid_profiles;
154 std::map<rs2_stream, std::map<uint32_t, uint32_t>> _fps_and_sampling_frequency_per_rs2_stream;
155 std::shared_ptr<platform::hid_device> _hid_device;
156 std::mutex _configure_lock;
157 std::map<std::string, stream_profile> _configured_profiles;
158 std::vector<bool> _is_configured_stream;
159 std::vector<platform::hid_sensor> _hid_sensors;
160 std::map<std::string, request_mapping> _hid_mapping;
161 std::unique_ptr<frame_timestamp_reader> _hid_iio_timestamp_reader;
162 std::unique_ptr<frame_timestamp_reader> _custom_hid_timestamp_reader;
177 explicit uvc_sensor(std::string
name, std::shared_ptr<platform::uvc_device> uvc_device,
178 std::unique_ptr<frame_timestamp_reader> timestamp_reader,
device* dev);
183 void set_roi_method(std::shared_ptr<region_of_interest_method> roi_method)
override;
187 void close()
override;
195 -> decltype(action(*static_cast<platform::uvc_device*>(
nullptr)))
197 power on(std::dynamic_pointer_cast<uvc_sensor>(shared_from_this()));
198 return action(*_device);
206 void stop()
override;
214 void acquire_power();
216 void release_power();
218 void reset_streaming();
222 explicit power(std::weak_ptr<uvc_sensor> owner)
225 auto strong =
_owner.lock();
228 strong->acquire_power();
234 auto strong =
_owner.lock();
235 if (strong) strong->release_power();
238 std::weak_ptr<uvc_sensor>
_owner;
241 std::shared_ptr<platform::uvc_device> _device;
242 std::atomic<int> _user_count;
243 std::mutex _power_lock;
244 std::mutex _configure_lock;
245 std::vector<platform::extension_unit> _xus;
246 std::unique_ptr<power> _power;
247 std::unique_ptr<frame_timestamp_reader> _timestamp_reader;
248 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:194
frame_source _source
Definition: sensor.h:101
notifications_callback_ptr get_notifications_callback() const override
virtual double get_frame_timestamp(const request_mapping &mode, const platform::frame_object &fo)=0
void register_xu(platform::extension_unit xu)
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)
stream_profiles init_stream_profiles() override
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
hid_sensor(std::shared_ptr< platform::hid_device > hid_device, std::unique_ptr< frame_timestamp_reader > hid_iio_timestamp_reader, std::unique_ptr< frame_timestamp_reader > custom_hid_timestamp_reader, std::map< rs2_stream, std::map< unsigned, unsigned >> fps_and_sampling_frequency_per_rs2_stream, std::vector< std::pair< std::string, stream_profile >> sensor_name_and_hid_profiles, device *dev)
uvc_sensor(std::string name, std::shared_ptr< platform::uvc_device > uvc_device, std::unique_ptr< frame_timestamp_reader > timestamp_reader, device *dev)
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:822
void start(frame_callback_ptr callback) override
std::vector< platform::stream_profile > get_configuration() const
Definition: sensor.h:189
bool supports_info(rs2_camera_info info) const override
void register_pu(rs2_option id)
sensor_base(std::string name, device *device)
Definition: rs_sensor.h:45
void open(const stream_profiles &requests) override
Definition: rs_sensor.h:43
Definition: streaming.h:131
on_open _on_open
Definition: sensor.h:98
void open(const stream_profiles &requests) override
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:824
virtual stream_profiles get_active_streams() const override
std::shared_ptr< notifications_processor > _notifications_processor
Definition: sensor.h:96
void try_register_pu(rs2_option id)
on_before_frame_callback _on_before_frame_callback
Definition: sensor.h:97
std::vector< uint8_t > get_custom_report_data(const std::string &custom_sensor_name, const std::string &report_name, platform::custom_sensor_report_field report_field) const
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:113
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:36
region_of_interest_method & get_roi_method() const override
Definition: rs_sensor.h:44
void unregister_before_start_callback(int token) override
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition: rs_types.h:93
rs2_extension stream_to_frame_types(rs2_stream stream) const
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::vector< std::shared_ptr< stream_profile_interface > > stream_profiles
Definition: streaming.h:104
Definition: streaming.h:106
virtual rs2_timestamp_domain get_frame_timestamp_domain(const request_mapping &mode, const platform::frame_object &fo) const =0
void register_pixel_format(native_pixel_format pf)
int register_before_streaming_changes_callback(std::function< void(bool)> callback) override
void start(frame_callback_ptr callback) override
void register_notifications_callback(notifications_callback_ptr callback) override
virtual ~sensor_base()
Definition: sensor.h:59
stream_profiles init_stream_profiles() override
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
void set_roi_method(std::shared_ptr< region_of_interest_method > roi_method) override
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
virtual unsigned long long get_frame_counter(const request_mapping &mode, const platform::frame_object &fo) const =0
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