timestamps.h
Go to the documentation of this file.
00001 #pragma once
00002 #ifndef LIBREALSENSE_TIMESTAMPS_H
00003 #define LIBREALSENSE_TIMESTAMPS_H
00004 
00005 #include "../include/librealsense/rs.h"     // Inherit all type definitions in the public API
00006 #include <deque>
00007 #include <condition_variable>
00008 #include <mutex>
00009 #include <atomic>
00010 
00011 
00012 namespace rsimpl
00013 {
00014     struct frame_interface
00015     { 
00016         virtual ~frame_interface() {}
00017         virtual double get_frame_metadata(rs_frame_metadata frame_metadata) const = 0;
00018         virtual bool supports_frame_metadata(rs_frame_metadata frame_metadata) const = 0;
00019         virtual unsigned long long get_frame_number() const = 0;
00020         virtual void set_timestamp(double new_ts) = 0;
00021         virtual void set_timestamp_domain(rs_timestamp_domain timestamp_domain) = 0;
00022         virtual rs_stream get_stream_type()const = 0;
00023     };
00024 
00025 
00026     class concurrent_queue{
00027     public:
00028         void    push_back_data(rs_timestamp_data data);
00029         bool    pop_front_data();
00030         bool    erase(rs_timestamp_data data);
00031         bool    correct(frame_interface& frame);
00032         size_t  size();
00033 
00034         private:
00035         std::deque<rs_timestamp_data> data_queue;
00036         std::mutex mtx;
00037 
00038     };
00039 
00040     class timestamp_corrector_interface{
00041     public:
00042         virtual ~timestamp_corrector_interface() {}
00043         virtual void on_timestamp(rs_timestamp_data data) = 0;
00044         virtual void correct_timestamp(frame_interface& frame, rs_stream stream) = 0;
00045         virtual void release() = 0;
00046     };
00047 
00048 
00049     class timestamp_corrector : public timestamp_corrector_interface{
00050     public:
00051         timestamp_corrector(std::atomic<uint32_t>* event_queue_size, std::atomic<uint32_t>* events_timeout);
00052         ~timestamp_corrector() override;
00053         void on_timestamp(rs_timestamp_data data) override;
00054         void correct_timestamp(frame_interface& frame, rs_stream stream) override;
00055         void release() override  {delete this;}
00056 
00057     private:
00058         void update_source_id(rs_event_source& source_id, const rs_stream stream);
00059 
00060         std::mutex mtx;
00061         concurrent_queue data_queue[RS_EVENT_SOURCE_COUNT];
00062         std::condition_variable cv;
00063         std::atomic<uint32_t>* event_queue_size;
00064         std::atomic<uint32_t>* events_timeout;
00065 
00066     };
00067 
00068 
00069 
00070 } // namespace rsimpl
00071 #endif // LIBREALSENSE_TIMESTAMPS_H


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Tue Jun 25 2019 19:54:39