record_sensor.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 #include "core/roi.h"
6 #include "core/extension.h"
7 #include "core/serialization.h"
8 #include "core/streaming.h"
9 #include "archive.h"
10 #include "concurrency.h"
11 #include "sensor.h"
12 
13 namespace librealsense
14 {
16  public extendable_interface, //Allows extension for any of the given device's extensions
17  public info_container,
18  public options_container
19  {
20  public:
23  virtual ~record_sensor();
24  void init();
26  void open(const stream_profiles& requests) override;
27  void close() override;
28  option& get_option(rs2_option id) override;
29  const option& get_option(rs2_option id) const override;
30  const std::string& get_info(rs2_camera_info info) const override;
31  bool supports_info(rs2_camera_info info) const override;
32  bool supports_option(rs2_option id) const override;
35  void start(frame_callback_ptr callback) override;
36  void stop() override;
37  bool is_streaming() const override;
38  bool extend_to(rs2_extension extension_type, void** ext) override;
39  device_interface& get_device() override;
40  frame_callback_ptr get_frames_callback() const override;
41  void set_frames_callback(frame_callback_ptr callback) override;
42  stream_profiles get_active_streams() const override;
43  int register_before_streaming_changes_callback(std::function<void(bool)> callback) override;
44  void unregister_before_start_callback(int token) override;
48  void stop_with_error(const std::string& message);
49  void disable_recording();
51 
52  private /*methods*/:
53  template <typename T> void record_snapshot(rs2_extension extension_type, const recordable<T>& snapshot);
54  template <rs2_extension E, typename P> bool extend_to_aux(P* p, void** ext);
55  void record_frame(frame_holder holder);
56  void enable_sensor_hooks();
57  void disable_sensor_hooks();
58  void hook_sensor_callbacks();
63  void wrap_streams();
64 
65  private /*members*/:
66  sensor_interface& m_sensor;
67  std::set<int> m_recorded_streams_ids;
68  std::set<rs2_option> m_recording_options;
70  std::atomic_bool m_is_recording;
77  std::mutex m_mutex;
78  };
79 
81  {
82  std::function<void(rs2_notification*)> on_notification_function;
83  public:
84  notification_callback(std::function<void(rs2_notification*)> on_notification) : on_notification_function(on_notification) {}
85 
86  void on_notification(rs2_notification* _notification) override
87  {
88  on_notification_function(_notification);
89  }
90  void release() override { delete this; }
91  };
92 
94  {
95  std::function<void(frame_holder)> on_frame_function;
96  public:
97  explicit frame_holder_callback(std::function<void(frame_holder)> on_frame) : on_frame_function(on_frame) {}
98 
99  void on_frame(rs2_frame * fref) override
100  {
101  on_frame_function({ (frame_interface*)fref });
102  }
103 
104  void release() override { delete this; }
105  };
106 
107 }
stream_profiles get_active_streams() const override
private const recordable< T > & snapshot
Definition: record_sensor.h:53
GLenum GLuint GLenum GLsizei const GLchar * message
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
option & get_option(rs2_option id) override
boost_foreach_argument_dependent_lookup_hack tag
Definition: foreach_fwd.hpp:31
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
virtual processing_blocks get_recommended_processing_blocks() const override
std::shared_ptr< rs2_frame_callback > frame_callback_ptr
Definition: src/types.h:1071
frame_callback_ptr m_frame_callback
Definition: record_sensor.h:71
GLfloat GLfloat p
Definition: glext.h:12687
void start(frame_callback_ptr callback) override
void stop_with_error(const std::string &message)
std::function< void(frame_interface *)> on_frame
Definition: streaming.h:164
librealsense::notifications_callback_ptr m_user_notification_callback
Definition: record_sensor.h:69
GLsizei const GLchar *const * string
stream_profiles get_stream_profiles(int tag=profile_tag::PROFILE_TAG_ANY) const override
void on_frame(rs2_frame *fref) override
Definition: record_sensor.h:99
void record_frame(frame_holder holder)
int register_before_streaming_changes_callback(std::function< void(bool)> callback) override
void open(const stream_profiles &requests) override
def info(name, value, persistent=False)
Definition: test.py:301
device_interface & get_device() override
std::function< void(rs2_notification *)> on_notification_function
Definition: record_sensor.h:82
frame_callback_ptr m_original_callback
Definition: record_sensor.h:72
notifications_callback_ptr get_notifications_callback() const override
std::function< void(frame_holder)> on_frame_function
Definition: record_sensor.h:95
std::atomic_bool m_is_recording
Definition: record_sensor.h:70
bool supports_option(rs2_option id) const override
std::shared_ptr< rs2_notifications_callback > notifications_callback_ptr
Definition: src/types.h:1073
const std::string & get_info(rs2_camera_info info) const override
bool extend_to_aux(P *p, void **ext)
void unregister_before_start_callback(int token) override
signal< record_sensor, frame_holder > on_frame
Definition: record_sensor.h:46
def callback(frame)
Definition: t265_stereo.py:91
bool is_streaming() const override
frame_callback_ptr wrap_frame_callback(frame_callback_ptr callback)
void register_notifications_callback(notifications_callback_ptr callback) override
signal< record_sensor, rs2_extension, std::shared_ptr< extension_snapshot > > on_extension_change
Definition: record_sensor.h:47
record_sensor(device_interface &device, sensor_interface &sensor)
void on_notification(rs2_notification *_notification) override
Definition: record_sensor.h:86
signal< record_sensor, const notification & > on_notification
Definition: record_sensor.h:45
std::vector< std::shared_ptr< stream_profile_interface >> stream_profiles
Definition: streaming.h:165
frame_callback_ptr get_frames_callback() const override
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition: rs_types.h:166
void set_frames_callback(frame_callback_ptr callback) override
bool extend_to(rs2_extension extension_type, void **ext) override
frame_holder_callback(std::function< void(frame_holder)> on_frame)
Definition: record_sensor.h:97
std::set< int > m_recorded_streams_ids
Definition: record_sensor.h:67
notification_callback(std::function< void(rs2_notification *)> on_notification)
Definition: record_sensor.h:84
bool supports_info(rs2_camera_info info) const override
std::set< rs2_option > m_recording_options
Definition: record_sensor.h:68
device_interface & m_parent_device
Definition: record_sensor.h:74
struct rs2_frame rs2_frame
Definition: rs_types.h:261


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