record_device.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 #include "record_sensor.h"
13 
14 namespace librealsense
15 {
17  public extendable_interface,
18  public info_container
19  {
20  public:
21  static const uint64_t MAX_CACHED_DATA_SIZE = 1920 * 1080 * 4 * 30; // ~1 sec of HD video @ 30 FPS
22 
23  record_device(std::shared_ptr<device_interface> device, std::shared_ptr<device_serializer::writer> serializer);
24  virtual ~record_device();
25 
26  std::shared_ptr<context> get_context() const override;
27 
28  sensor_interface& get_sensor(size_t i) override;
29  size_t get_sensors_count() 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  const sensor_interface& get_sensor(size_t i) const override;
33  void hardware_reset() override;
34 
35 
36  bool extend_to(rs2_extension extension_type, void** ext) override;
37  virtual std::shared_ptr<matcher> create_matcher(const frame_holder& frame) const override;
38 
39  void pause_recording();
40  void resume_recording();
41  const std::string& get_filename() const;
43  std::pair<uint32_t, rs2_extrinsics> get_extrinsics(const stream_interface& stream) const override;
44  bool is_valid() const override;
45 
46  std::vector<tagged_profile> get_profiles_tags() const override { return m_device->get_profiles_tags(); };
47  void tag_profiles(stream_profiles profiles) const override { m_device->tag_profiles(profiles); }
48  bool compress_while_record() const override { return true; }
49  bool contradicts(const stream_profile_interface* a, const std::vector<stream_profile>& others) const override { return m_device->contradicts(a, others); }
50 
51  private:
52  template <typename T> void write_device_extension_changes(const T& ext);
53  template <rs2_extension E, typename P> bool extend_to_aux(std::shared_ptr<P> p, void** ext);
54 
55  void write_header();
57  void write_data(size_t sensor_index, frame_holder f, std::function<void(std::string const&)> on_error);
58  void write_sensor_extension_snapshot(size_t sensor_index, rs2_extension ext, std::shared_ptr<extension_snapshot> snapshot, std::function<void(std::string const&)> on_error);
59  void write_notification(size_t sensor_index, const notification& n);
60  std::vector<std::shared_ptr<record_sensor>> create_record_sensors(std::shared_ptr<device_interface> m_device);
61  template <typename T> device_serializer::snapshot_collection get_extensions_snapshots(T* extendable);
62  template <typename T, typename Ext> void try_add_snapshot(T* extendable, device_serializer::snapshot_collection& snapshots);
63  std::shared_ptr<device_interface> m_device;
64  std::vector<std::shared_ptr<record_sensor>> m_sensors;
65 
67  std::shared_ptr<device_serializer::writer> m_ros_writer;
68 
69  std::chrono::high_resolution_clock::time_point m_capture_time_base;
70  std::chrono::high_resolution_clock::duration m_record_pause_time;
71  std::chrono::high_resolution_clock::time_point m_time_of_pause;
72 
73  std::mutex m_mutex;
75  std::once_flag m_first_frame_flag;
80  std::once_flag m_first_call_flag;
81  void initialize_recording();
82  void stop_gracefully(to_string error_msg);
83  };
84 
86 }
std::shared_ptr< device_serializer::writer > m_ros_writer
Definition: record_device.h:67
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 contradicts(const stream_profile_interface *a, const std::vector< stream_profile > &others) const override
Definition: record_device.h:49
GLfloat GLfloat p
Definition: glext.h:12687
sensor_interface & get_sensor(size_t i) override
bool compress_while_record() const override
Definition: record_device.h:48
device_serializer::snapshot_collection get_extensions_snapshots(T *extendable)
void write_data(size_t sensor_index, frame_holder f, std::function< void(std::string const &)> on_error)
std::chrono::high_resolution_clock::time_point m_capture_time_base
Definition: record_device.h:69
std::shared_ptr< device_interface > m_device
Definition: record_device.h:63
GLsizei const GLchar *const * string
virtual std::shared_ptr< matcher > create_matcher(const frame_holder &frame) const override
platform::backend_device_group get_device_data() const override
GLdouble n
Definition: glext.h:1966
void try_add_snapshot(T *extendable, device_serializer::snapshot_collection &snapshots)
std::chrono::nanoseconds get_capture_time() const
GLboolean GLboolean GLboolean GLboolean a
def info(name, value, persistent=False)
Definition: test.py:301
std::once_flag m_first_frame_flag
Definition: record_device.h:75
bool extend_to(rs2_extension extension_type, void **ext) override
bool is_valid() const override
std::shared_ptr< context > get_context() const override
GLdouble f
void tag_profiles(stream_profiles profiles) const override
Definition: record_device.h:47
bool extend_to_aux(std::shared_ptr< P > p, void **ext)
size_t get_sensors_count() const override
std::once_flag m_first_call_flag
Definition: record_device.h:80
std::vector< tagged_profile > get_profiles_tags() const override
Definition: record_device.h:46
void write_sensor_extension_snapshot(size_t sensor_index, rs2_extension ext, std::shared_ptr< extension_snapshot > snapshot, std::function< void(std::string const &)> on_error)
lazy< std::shared_ptr< dispatcher > > m_write_thread
Definition: record_device.h:66
unsigned __int64 uint64_t
Definition: stdint.h:90
bool supports_info(rs2_camera_info info) const override
std::vector< std::shared_ptr< record_sensor > > create_record_sensors(std::shared_ptr< device_interface > m_device)
std::vector< std::shared_ptr< stream_profile_interface >> stream_profiles
Definition: streaming.h:165
std::chrono::duration< uint64_t, std::nano > nanoseconds
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition: rs_types.h:166
record_device(std::shared_ptr< device_interface > device, std::shared_ptr< device_serializer::writer > serializer)
std::chrono::high_resolution_clock::duration m_record_pause_time
Definition: record_device.h:70
void write_notification(size_t sensor_index, const notification &n)
std::vector< std::shared_ptr< record_sensor > > m_sensors
Definition: record_device.h:64
std::pair< uint32_t, rs2_extrinsics > get_extrinsics(const stream_interface &stream) const override
int i
std::chrono::high_resolution_clock::time_point m_time_of_pause
Definition: record_device.h:71
void stop_gracefully(to_string error_msg)
const std::string & get_filename() const
void write_device_extension_changes(const T &ext)
MAP_EXTENSION(RS2_EXTENSION_POINTS, librealsense::points)
const std::string & get_info(rs2_camera_info info) const override
static const uint64_t MAX_CACHED_DATA_SIZE
Definition: record_device.h:21


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