Skip to content

Commit

Permalink
Merge pull request #16 from zshahaf/master
Browse files Browse the repository at this point in the history
Renaming, order and documentation
  • Loading branch information
dorodnic authored and GitHub Enterprise committed Jul 20, 2017
2 parents 49e477e + c6184df commit 6a32417
Show file tree
Hide file tree
Showing 632 changed files with 52,887 additions and 52,824 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ librealsense-log.txt
*.list
*.txt
*.cmake
!config.cmake
*.json
*.ini
*.cxx
Expand Down
8 changes: 3 additions & 5 deletions CMake/realsense.def
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ EXPORTS
rs2_create_device_from_sensor
rs2_get_depth_scale

rs2_is_sensor
rs2_is_device
rs2_is_frame
rs2_is_sensor_extendable_to
rs2_is_device_extendable_to
rs2_is_frame_extendable_to

rs2_allocate_synthetic_video_frame
rs2_synthetic_frame_ready
Expand Down Expand Up @@ -158,8 +158,6 @@ EXPORTS
rs2_is_enabled
rs2_toggle_advanced_mode

rs2_create_device_serializer
rs2_delete_device_serializer
rs2_create_record_device
rs2_create_playback_device
rs2_record_device_pause
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ set(REALSENSE_HPP
)

# Add additional include directories to allow file to include rosbag headers
include(${CMAKE_CURRENT_LIST_DIR}/third-party/realsense-file/3rd_party/config.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/third-party/realsense-file/config.cmake)
include_directories(
${ROSBAG_HEADER_DIRS}
${BOOST_INCLUDE_PATH}
Expand All @@ -272,6 +272,7 @@ if(WIN32)

source_group("Source Files\\Media" FILES
src/recording/record_device.cpp
src/recording/record_sensor.cpp
src/recording/playback_device.cpp
src/recording/playback_sensor.cpp
src/recording/ros/stream_playback.cpp
Expand Down
183 changes: 97 additions & 86 deletions include/librealsense/rs2.h

Large diffs are not rendered by default.

30 changes: 8 additions & 22 deletions include/librealsense/rs2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ namespace rs2
: frame(f)
{
rs2_error* e = nullptr;
if(!f || (rs2_is_frame(f.get(), RS2_EXTENSION_TYPE_VIDEO_FRAME, &e) == 0 && !e))
if(!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_TYPE_VIDEO_FRAME, &e) == 0 && !e))
{
frame_ref = nullptr;
}
Expand Down Expand Up @@ -460,7 +460,7 @@ namespace rs2
: frame(f), _size(0)
{
rs2_error* e = nullptr;
if(!f || (rs2_is_frame(f.get(), RS2_EXTENSION_TYPE_POINTS, &e) == 0 && !e))
if(!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_TYPE_POINTS, &e) == 0 && !e))
{
frame_ref = nullptr;
}
Expand Down Expand Up @@ -506,7 +506,7 @@ namespace rs2
: frame(f), _size(0)
{
rs2_error* e = nullptr;
if(!f || (rs2_is_frame(f.get(), RS2_EXTENSION_TYPE_COMPOSITE_FRAME, &e) == 0 && !e))
if(!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_TYPE_COMPOSITE_FRAME, &e) == 0 && !e))
{
frame_ref = nullptr;
}
Expand Down Expand Up @@ -1136,7 +1136,7 @@ namespace rs2
: sensor(s.get())
{
rs2_error* e = nullptr;
if(rs2_is_sensor(_sensor.get(), RS2_EXTENSION_TYPE_ROI, &e) == 0 && !e)
if(rs2_is_sensor_extendable_to(_sensor.get(), RS2_EXTENSION_TYPE_ROI, &e) == 0 && !e)
{
_sensor = nullptr;
}
Expand Down Expand Up @@ -1169,7 +1169,7 @@ namespace rs2
: sensor(s.get())
{
rs2_error* e = nullptr;
if (rs2_is_sensor(_sensor.get(), RS2_EXTENSION_TYPE_DEPTH_SENSOR, &e) == 0 && !e)
if (rs2_is_sensor_extendable_to(_sensor.get(), RS2_EXTENSION_TYPE_DEPTH_SENSOR, &e) == 0 && !e)
{
_sensor = nullptr;
}
Expand Down Expand Up @@ -1329,7 +1329,7 @@ namespace rs2
: device(d.get())
{
rs2_error* e = nullptr;
if(rs2_is_device(_dev.get(), RS2_EXTENSION_TYPE_DEBUG, &e) == 0 && !e)
if(rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_TYPE_DEBUG, &e) == 0 && !e)
{
_dev = nullptr;
}
Expand Down Expand Up @@ -1462,14 +1462,8 @@ namespace rs2
m_file(file)
{
rs2_error* e = nullptr;
m_serializer = std::shared_ptr<rs2_device_serializer>(
rs2_create_device_serializer(file.c_str(), &e),
rs2_delete_device_serializer);
rs2::error::handle(e);

e = nullptr;
_dev = std::shared_ptr<rs2_device>(
rs2_create_playback_device(m_serializer.get(), &e),
rs2_create_playback_device(file.c_str(), &e),
rs2_delete_device);
rs2::error::handle(e);
}
Expand All @@ -1487,7 +1481,6 @@ namespace rs2
}
private:
std::string m_file;
std::shared_ptr<rs2_device_serializer> m_serializer;
};
class recorder : public device
{
Expand All @@ -1496,14 +1489,8 @@ namespace rs2
m_file(file)
{
rs2_error* e = nullptr;
m_serializer = std::shared_ptr<rs2_device_serializer>(
rs2_create_device_serializer(file.c_str(), &e),
rs2_delete_device_serializer);
rs2::error::handle(e);

e = nullptr;
_dev = std::shared_ptr<rs2_device>(
rs2_create_record_device(device.get().get(), m_serializer.get(), &e),
rs2_create_record_device(device.get().get(), file.c_str(), &e),
rs2_delete_device);
rs2::error::handle(e);
}
Expand All @@ -1522,7 +1509,6 @@ namespace rs2
}
private:
std::string m_file;
std::shared_ptr<rs2_device_serializer> m_serializer;
};

class event_information
Expand Down
2 changes: 1 addition & 1 deletion include/librealsense/rs2_advanced_mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace rs400
: rs2::device(d.get())
{
rs2_error* e = nullptr;
if(rs2_is_device(_dev.get(), RS2_EXTENSION_TYPE_ADVANCED_MODE, &e) == 0 && !e)
if(rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_TYPE_ADVANCED_MODE, &e) == 0 && !e)
{
_dev = nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace librealsense
if (new_bpp == 0 || (new_width == 0 && new_stride == 0) || new_height == 0)
{
// If the user wants to delegate width, height and etc to original frame, it must be a video frame
if (!rs2_is_frame((rs2_frame*)original, RS2_EXTENSION_TYPE_VIDEO_FRAME, nullptr))
if (!rs2_is_frame_extendable_to((rs2_frame*)original, RS2_EXTENSION_TYPE_VIDEO_FRAME, nullptr))
{
throw std::runtime_error("If original frame is not video frame, you must specify new bpp, width/stide and height!");
}
Expand Down
2 changes: 1 addition & 1 deletion src/align.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace librealsense
std::mutex _mutex;
frame_processor_callback_ptr _callback;
synthetic_source _source_wrapper;
rs2_extension_type _output_type;
rs2_extension _output_type;
};

class pointcloud : public processing_block
Expand Down
2 changes: 1 addition & 1 deletion src/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ namespace librealsense

};

std::shared_ptr<archive_interface> make_archive(rs2_extension_type type,
std::shared_ptr<archive_interface> make_archive(rs2_extension type,
std::atomic<uint32_t>* in_max_frame_queue_size,
std::shared_ptr<platform::time_service> ts,
std::shared_ptr<metadata_parser_map> parsers)
Expand Down
2 changes: 1 addition & 1 deletion src/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ namespace librealsense

};

std::shared_ptr<archive_interface> make_archive(rs2_extension_type type,
std::shared_ptr<archive_interface> make_archive(rs2_extension type,
std::atomic<uint32_t>* in_max_frame_queue_size,
std::shared_ptr<platform::time_service> ts,
std::shared_ptr<metadata_parser_map> parsers);
Expand Down
29 changes: 14 additions & 15 deletions src/core/extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#pragma once
#include "../../include/librealsense/rs2.h" //TODO: Ziv, remove relative\file
#include "../../include/librealsense/rs2.h"
#include <memory>
#include <functional>

//Preprocessor Macro to define mapping between rs2_extension_type and their respective interface (and vice versa)
#define MAP_EXTENSION(E, T) \
template<> struct ExtensionsToTypes<E> { \
using type = T; \
}; \
template<> struct TypeToExtensionn<T> { \
static constexpr rs2_extension_type value = E; \
//Preprocessor Macro to define mapping between rs2_extension and their respective interface (and vice versa)
#define MAP_EXTENSION(E, T) \
template<> struct ExtensionsToTypes<E> { \
using type = T; \
}; \
template<> struct TypeToExtensionn<T> { \
static constexpr rs2_extension value = E; \
}

namespace librealsense
{
class extendable_interface
{
public:
virtual bool extend_to(rs2_extension_type extension_type, void** ptr) = 0;
virtual bool extend_to(rs2_extension extension_type, void** ptr) = 0;
virtual ~extendable_interface() = default;
};

/**
* Extensions' snapshot implementations are expected to derive from this class in addition to the actual extension
* Extensions' interfaces are not expected to derive from this class (//TODO Ziv, what if they do? - test that it works)
* Extensions' snapshots implementations are expected to derive from this class in addition to the actual extensions'
* interfaces. Extensions are not expected to derive from this class.
*/
//template <typename T>
class extension_snapshot //TODO: : Ziv, : public T, public std::enable_shared_from_this ?
class extension_snapshot
{
public:
virtual void update(std::shared_ptr<extension_snapshot> ext) = 0;
Expand Down Expand Up @@ -102,7 +101,7 @@ namespace librealsense
return dynamic_cast<T*>(ptr) != nullptr;
}

//Creating Helper functions to map rs2_extension_type enums to actual interface
template<rs2_extension_type> struct ExtensionsToTypes;
//Creating Helper functions to map rs2_extension enums to actual interface
template<rs2_extension> struct ExtensionsToTypes;
template<typename T> struct TypeToExtensionn;
}
12 changes: 6 additions & 6 deletions src/recording/device_snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ namespace librealsense
{
public:
snapshot_collection() {}
snapshot_collection(const std::map<rs2_extension_type, std::shared_ptr<extension_snapshot>>& snapshots) :
snapshot_collection(const std::map<rs2_extension, std::shared_ptr<extension_snapshot>>& snapshots) :
m_snapshots(snapshots)
{
}

std::shared_ptr<extension_snapshot> find(rs2_extension_type t)
std::shared_ptr<extension_snapshot> find(rs2_extension t)
{
auto snapshot_it = m_snapshots.find(t);
if(snapshot_it == std::end(m_snapshots))
Expand All @@ -27,22 +27,22 @@ namespace librealsense
}
return snapshot_it->second;
}
std::map<rs2_extension_type, std::shared_ptr<extension_snapshot>> get_snapshots() const
std::map<rs2_extension, std::shared_ptr<extension_snapshot>> get_snapshots() const
{
return m_snapshots;
}

const std::shared_ptr<extension_snapshot>& operator[](rs2_extension_type extension) const
const std::shared_ptr<extension_snapshot>& operator[](rs2_extension extension) const
{
return m_snapshots.at(extension);
}

std::shared_ptr<extension_snapshot>& operator[](rs2_extension_type extension)
std::shared_ptr<extension_snapshot>& operator[](rs2_extension extension)
{
return m_snapshots[extension];
}
private:
std::map<rs2_extension_type, std::shared_ptr<extension_snapshot>> m_snapshots;
std::map<rs2_extension, std::shared_ptr<extension_snapshot>> m_snapshots;
};
class sensor_snapshot
{
Expand Down
2 changes: 1 addition & 1 deletion src/recording/playback_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ rs2_extrinsics playback_device::get_extrinsics(size_t from, rs2_stream from_stre
//std::dynamic_pointer_cast<librealsense::info_interface>(m_device_description.get_device_extensions_snapshots().get_snapshots()[RS2_EXTENSION_TYPE_EXTRINSICS])->supports_info(info);
}

bool playback_device::extend_to(rs2_extension_type extension_type, void** ext)
bool playback_device::extend_to(rs2_extension extension_type, void** ext)
{
std::shared_ptr<extension_snapshot> e = m_device_description.get_device_extensions_snapshots().find(extension_type);
if (e == nullptr)
Expand Down
2 changes: 1 addition & 1 deletion src/recording/playback_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace librealsense
const sensor_interface& get_sensor(size_t i) const override;
void hardware_reset() override;
rs2_extrinsics get_extrinsics(size_t from,rs2_stream from_stream,size_t to,rs2_stream to_stream) const override;
bool extend_to(rs2_extension_type extension_type, void** ext) override;
bool extend_to(rs2_extension extension_type, void** ext) override;
std::shared_ptr<matcher> create_matcher(rs2_stream stream) const override;

bool set_frame_rate(double rate);
Expand Down
2 changes: 1 addition & 1 deletion src/recording/playback_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool playback_sensor::is_streaming() const
{
return m_is_started;
}
bool playback_sensor::extend_to(rs2_extension_type extension_type, void** ext)
bool playback_sensor::extend_to(rs2_extension extension_type, void** ext)
{
std::shared_ptr<extension_snapshot> e = m_sensor_description.get_sensor_extensions_snapshots().find(extension_type);
if(e == nullptr)
Expand Down
2 changes: 1 addition & 1 deletion src/recording/playback_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace librealsense
void start(frame_callback_ptr callback) override;
void stop() override;
bool is_streaming() const override;
bool extend_to(rs2_extension_type extension_type, void** ext) override;
bool extend_to(rs2_extension extension_type, void** ext) override;
const device_interface& get_device() override;
rs2_extrinsics get_extrinsics_to(rs2_stream from, const sensor_interface& other, rs2_stream to) const override;
const std::vector<platform::stream_profile>& get_curr_configurations() const override;
Expand Down
Loading

0 comments on commit 6a32417

Please sign in to comment.