Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
Loading...
Searching...
No Matches
rs_record_playback.hpp
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#ifndef LIBREALSENSE_RS2_RECORD_PLAYBACK_HPP
5#define LIBREALSENSE_RS2_RECORD_PLAYBACK_HPP
6
7#include "rs_types.hpp"
8#include "rs_device.hpp"
9
10namespace rs2
11{
12 template<class T>
14 {
15 T on_status_changed_function;
16 public:
17 explicit status_changed_callback(T on_status_changed) : on_status_changed_function(on_status_changed) {}
18
20 {
21 on_status_changed_function(status);
22 }
23
24 void release() override { delete this; }
25 };
26
27 class playback : public device
28 {
29 public:
31
37 void pause()
38 {
39 rs2_error* e = nullptr;
42 }
43
48 void resume()
49 {
50 rs2_error* e = nullptr;
53 }
54
59 std::string file_name() const
60 {
61 return m_file; //cached in construction
62 }
63
69 {
70 rs2_error* e = nullptr;
73 return pos;
74 }
75
80 std::chrono::nanoseconds get_duration() const
81 {
82 rs2_error* e = nullptr;
83 std::chrono::nanoseconds duration(rs2_playback_get_duration(_dev.get(), &e));
85 return duration;
86 }
87
92 void seek(std::chrono::nanoseconds time)
93 {
94 rs2_error* e = nullptr;
95 rs2_playback_seek(_dev.get(), time.count(), &e);
97 }
98
103 bool is_real_time() const
104 {
105 rs2_error* e = nullptr;
108 return real_time;
109 }
110
122 void set_real_time(bool real_time) const
123 {
124 rs2_error* e = nullptr;
127 }
128
133 void set_playback_speed(float speed) const
134 {
135 rs2_error* e = nullptr;
138 }
139
152 template <typename T>
159
171
176 void stop()
177 {
178 rs2_error* e = nullptr;
181 }
182 protected:
183 friend context;
184 explicit playback(std::shared_ptr<rs2_device> dev) : device(dev)
185 {
186 rs2_error* e = nullptr;
188 {
189 _dev.reset();
190 }
192
193 if(_dev)
194 {
195 e = nullptr;
196 m_file = rs2_playback_device_get_file_path(_dev.get(), &e);
198 }
199 }
200 private:
201 std::string m_file;
202 };
203 class recorder : public device
204 {
205 public:
207
213 recorder(const std::string& file, rs2::device dev)
214 {
215 rs2_error* e = nullptr;
216 _dev = std::shared_ptr<rs2_device>(
217 rs2_create_record_device(dev.get().get(), file.c_str(), &e),
220 }
221
229 {
230 rs2_error* e = nullptr;
231 _dev = std::shared_ptr<rs2_device>(
235 }
236
237
241 void pause()
242 {
243 rs2_error* e = nullptr;
246 }
247
251 void resume()
252 {
253 rs2_error* e = nullptr;
256 }
257
262 std::string filename() const
263 {
264 rs2_error* e = nullptr;
265 std::string filename = rs2_record_device_filename(_dev.get(), &e);
267 return filename;
268 }
269 protected:
270 explicit recorder(std::shared_ptr<rs2_device> dev) : device(dev)
271 {
272 rs2_error* e = nullptr;
274 {
275 _dev.reset();
276 }
278 }
279 };
280}
281#endif // LIBREALSENSE_RS2_RECORD_PLAYBACK_HPP
Definition rs_device.hpp:19
const std::shared_ptr< rs2_device > & get() const
Definition rs_device.hpp:116
std::shared_ptr< rs2_device > _dev
Definition rs_device.hpp:146
static void handle(rs2_error *e)
Definition rs_types.hpp:144
Definition rs_record_playback.hpp:28
std::chrono::nanoseconds get_duration() const
Definition rs_record_playback.hpp:80
playback(std::shared_ptr< rs2_device > dev)
Definition rs_record_playback.hpp:184
void resume()
Definition rs_record_playback.hpp:48
bool is_real_time() const
Definition rs_record_playback.hpp:103
friend context
Definition rs_record_playback.hpp:183
uint64_t get_position() const
Definition rs_record_playback.hpp:68
void set_status_changed_callback(T callback)
Definition rs_record_playback.hpp:153
playback(device d)
Definition rs_record_playback.hpp:30
void stop()
Definition rs_record_playback.hpp:176
void pause()
Definition rs_record_playback.hpp:37
void set_real_time(bool real_time) const
Definition rs_record_playback.hpp:122
void set_playback_speed(float speed) const
Definition rs_record_playback.hpp:133
void seek(std::chrono::nanoseconds time)
Definition rs_record_playback.hpp:92
std::string file_name() const
Definition rs_record_playback.hpp:59
rs2_playback_status current_status() const
Definition rs_record_playback.hpp:164
Definition rs_record_playback.hpp:204
recorder(device d)
Definition rs_record_playback.hpp:206
void pause()
Definition rs_record_playback.hpp:241
std::string filename() const
Definition rs_record_playback.hpp:262
recorder(const std::string &file, rs2::device dev, bool compression_enabled)
Definition rs_record_playback.hpp:228
recorder(const std::string &file, rs2::device dev)
Definition rs_record_playback.hpp:213
void resume()
Definition rs_record_playback.hpp:251
recorder(std::shared_ptr< rs2_device > dev)
Definition rs_record_playback.hpp:270
Definition rs_record_playback.hpp:14
status_changed_callback(T on_status_changed)
Definition rs_record_playback.hpp:17
void release() override
Definition rs_record_playback.hpp:24
void on_playback_status_changed(rs2_playback_status status) override
Definition rs_record_playback.hpp:19
Definition rs_processing_gl.hpp:13
void rs2_delete_device(rs2_device *device)
int rs2_is_device_extendable_to(const rs2_device *device, rs2_extension extension, rs2_error **error)
void rs2_playback_device_resume(const rs2_device *device, rs2_error **error)
rs2_device * rs2_create_record_device(const rs2_device *device, const char *file, rs2_error **error)
void rs2_playback_device_stop(const rs2_device *device, rs2_error **error)
void rs2_playback_device_set_playback_speed(const rs2_device *device, float speed, rs2_error **error)
unsigned long long int rs2_playback_get_position(const rs2_device *device, rs2_error **error)
rs2_playback_status
Definition rs_record_playback.h:20
const char * rs2_playback_device_get_file_path(const rs2_device *device, rs2_error **error)
void rs2_playback_seek(const rs2_device *device, long long int time, rs2_error **error)
const char * rs2_record_device_filename(const rs2_device *device, rs2_error **error)
void rs2_record_device_resume(const rs2_device *device, rs2_error **error)
int rs2_playback_device_is_real_time(const rs2_device *device, rs2_error **error)
rs2_playback_status rs2_playback_device_get_current_status(const rs2_device *device, rs2_error **error)
unsigned long long int rs2_playback_get_duration(const rs2_device *device, rs2_error **error)
void rs2_playback_device_set_status_changed_callback(const rs2_device *device, rs2_playback_status_changed_callback *callback, rs2_error **error)
void rs2_record_device_pause(const rs2_device *device, rs2_error **error)
rs2_device * rs2_create_record_device_ex(const rs2_device *device, const char *file, int compression_enabled, rs2_error **error)
void rs2_playback_device_set_real_time(const rs2_device *device, int real_time, rs2_error **error)
void rs2_playback_device_pause(const rs2_device *device, rs2_error **error)
@ RS2_EXTENSION_PLAYBACK
Definition rs_types.h:184
@ RS2_EXTENSION_RECORD
Definition rs_types.h:182
struct rs2_error rs2_error
Definition rs_types.h:259
Definition rs_types.hpp:77