Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RealSense Device over Network #5999

Merged
merged 155 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
e059ba6
Integration: base for LRS network extentions.
apuzhevi Mar 9, 2020
7842d76
add new net-device includes
nhershko Mar 9, 2020
386f041
return realsense errors
nhershko Mar 10, 2020
857674f
Merge pull request #142 from IntelRealSense/server_error_handling_aft…
nhershko Mar 10, 2020
4910930
mchanan_fix_pr_check_error
mchanan Mar 10, 2020
57aa0ea
Merge pull request #143 from IntelRealSense/mchanan_fix_pr_check_error
mchanan Mar 10, 2020
a930aa6
add script to setup network queues
mchanan Mar 10, 2020
aa58fb2
Merge pull request #144 from IntelRealSense/mchanan_script_queues
mchanan Mar 10, 2020
7618f3a
get extrinsics map + add it to streams
nhershko Mar 11, 2020
2690509
release sw device ptr from active object after creation
nhershko Mar 11, 2020
6687506
add header and cleanup
nhershko Mar 11, 2020
5446e4c
remove old ip_device generator
nhershko Mar 11, 2020
7870a11
generate minimal map
nhershko Mar 11, 2020
6f2e77a
Merge pull request #145 from IntelRealSense/nhershko_net_device
nhershko Mar 11, 2020
6127ef5
Removed lz4, libjpeg-turbo and zlib from dource tree. Downloading fro…
apuzhevi Mar 12, 2020
84b1809
Linux static compilation fixed. (#147)
apuzhevi Mar 12, 2020
ee2c0d3
create map at client side
nhershko Mar 12, 2020
23c813a
Merge branch 'master' into nhershko_create_extrinsics_map
nhershko Mar 12, 2020
ea3198e
bug fix
mchanan Mar 15, 2020
81d9469
use rs_sensor for device data container
nhershko Mar 15, 2020
387f337
change to stream type
mchanan Mar 15, 2020
889fb17
Merge pull request #150 from IntelRealSense/mchanan_stream
mchanan Mar 15, 2020
adf3925
review fixes
nhershko Mar 15, 2020
9f2589b
handle NaN extrinsics
nhershko Mar 15, 2020
5c8658a
Do not download live555 if exists
apuzhevi Mar 15, 2020
0a22968
Merge branch 'master' into nhershko_create_extrinsics_map
nhershko Mar 15, 2020
658f873
Merge pull request #148 from IntelRealSense/nhershko_create_extrinsic…
nhershko Mar 15, 2020
7c9f20e
Windows compilation fixed. (#152)
apuzhevi Mar 16, 2020
b2af009
return sdp fix
nhershko Mar 16, 2020
b0f3874
Merge pull request #154 from IntelRealSense/nhershko_return_miri_sdp_fix
nhershko Mar 16, 2020
c33d23c
support controls before setup (#156)
cspungin Mar 16, 2020
fb2ab86
cspungin_fix_segmentation_fault
cspungin Mar 17, 2020
550b8d4
merge Sergey's changes
cspungin Mar 17, 2020
a9dd059
add Atomic to Cmake and remove RTSP Client recover on download
cspungin Mar 17, 2020
5682560
remove tabs
cspungin Mar 18, 2020
e136a8e
fix comment
cspungin Mar 18, 2020
ace3a73
do TEARDOWN on PLAY failure
cspungin Mar 18, 2020
222f3e5
Merge pull request #157 from IntelRealSense/cspungin_sergey_changes
cspungin Mar 18, 2020
a3cafba
increase client timeout
tbentzur Mar 18, 2020
0ba448c
Merge pull request #161 from IntelRealSense/tami_change_timout
tbentzur Mar 18, 2020
8d1de95
fix metadata + uyvy
mchanan Mar 18, 2020
356cd70
Merge pull request #163 from IntelRealSense/mchanan_bug_fix
mchanan Mar 18, 2020
7965aa8
parse option as float + delete ip_sensors + try once to start sensors…
nhershko Mar 18, 2020
e9e2e8d
throw exception at start/stop failure
nhershko Mar 19, 2020
353f5bb
Merge pull request #164 from IntelRealSense/nhershko_readonly_controls
nhershko Mar 19, 2020
40e3131
set notification on start/stop error
nhershko Mar 19, 2020
44ec262
Merge branch 'master' into nhershko_readonly_controls
nhershko Mar 19, 2020
c1358d8
change notification values
nhershko Mar 19, 2020
68b5d82
Merge pull request #165 from IntelRealSense/nhershko_readonly_controls
nhershko Mar 19, 2020
3046273
Merge branch 'master' into cspungin_segmentation_fault_fix
cspungin Mar 19, 2020
ae7e364
Merge pull request #166 from IntelRealSense/cspungin_segmentation_fau…
cspungin Mar 19, 2020
d62da87
pause stream on plat after play
cspungin Mar 20, 2020
21bc8d3
support rad only option
cspungin Mar 21, 2020
cc94e87
Merge pull request #168 from IntelRealSense/cspungin_pause_on_play_af…
cspungin Mar 22, 2020
7f16b1c
Merge branch 'master' into cspungin_read_only_option
cspungin Mar 22, 2020
3e34392
Merge pull request #167 from IntelRealSense/cspungin_read_only_option
cspungin Mar 22, 2020
69f5017
fix warnning
mchanan Mar 22, 2020
caf285c
Merge pull request #169 from IntelRealSense/mchanan_fix_warnning
mchanan Mar 22, 2020
622bc17
client warning fix
nhershko Mar 23, 2020
5c93165
Merge branch 'master' into nhershko_warning_cleanup
nhershko Mar 23, 2020
a48f6b8
Merge pull request #170 from IntelRealSense/nhershko_warning_cleanup
nhershko Mar 23, 2020
b95ba61
delete todo and comments
mchanan Mar 23, 2020
e4001bf
cleanup code
cspungin Mar 23, 2020
4c4cab8
Merge branch 'master' into mchanan_todo_and_comments
mchanan Mar 23, 2020
4dd3bc1
Merge pull request #171 from IntelRealSense/mchanan_todo_and_comments
mchanan Mar 23, 2020
5f8e20f
Merge branch 'master' into cspungin_code_cleanup
cspungin Mar 23, 2020
43c96ab
fix_compilation
cspungin Mar 23, 2020
1903bbc
Merge branch 'cspungin_code_cleanup' of https://github.com/IntelRealS…
cspungin Mar 23, 2020
afeeeca
Logging subsystem. (#160)
apuzhevi Mar 23, 2020
36a6a8d
TODOs cleanup
cspungin Mar 23, 2020
a9ef411
Merge branch 'master' into cspungin_code_cleanup
cspungin Mar 23, 2020
3118073
use new logger
cspungin Mar 23, 2020
7fb3d99
Windows compiles. Static/shared compilation check pending. (#173)
apuzhevi Mar 23, 2020
a49bd11
dont free buffer
cspungin Mar 23, 2020
0f851a3
compression fixes
mchanan Mar 23, 2020
979c680
Merge pull request #175 from IntelRealSense/cspungin_logger_fix
cspungin Mar 23, 2020
d5e5929
Merge branch 'master' into pr_fixes
mchanan Mar 23, 2020
9794706
review fixes
nhershko Mar 23, 2020
0ce89dc
Merge branch 'master' into nhershko_merge_review_fixes
nhershko Mar 23, 2020
a2d998f
Merge pull request #176 from IntelRealSense/pr_fixes
mchanan Mar 23, 2020
f831125
Merge branch 'master' into nhershko_merge_review_fixes
nhershko Mar 23, 2020
4de3a07
Merge pull request #177 from IntelRealSense/nhershko_merge_review_fixes
nhershko Mar 23, 2020
4a9d2b6
code review fixes
cspungin Mar 23, 2020
264bbf9
Merge branch 'master' into cspungin_code_cleanup
cspungin Mar 23, 2020
9434c84
Merge pull request #172 from IntelRealSense/cspungin_code_cleanup
cspungin Mar 23, 2020
4b3964d
cleanup
cspungin Mar 23, 2020
9495cd0
Merge branch 'cspungin_code_cleanup' of https://github.com/IntelRealS…
cspungin Mar 23, 2020
ae45b7a
Windows compilation fix.
apuzhevi Mar 23, 2020
dc98abe
Merge branch 'master' into cspungin_code_cleanup
cspungin Mar 23, 2020
43e1147
Windows compiles again. (#179)
apuzhevi Mar 23, 2020
c3b34f4
code review fixes
cspungin Mar 23, 2020
83a9aad
Merge branch 'cspungin_code_cleanup' of https://github.com/IntelRealS…
cspungin Mar 23, 2020
35b3474
Windows release build.
apuzhevi Mar 23, 2020
1c82112
Merge branch 'master' into cspungin_code_cleanup
cspungin Mar 23, 2020
bc81cc4
Merge branch 'master' into cspungin_code_cleanup
cspungin Mar 23, 2020
cc6c578
pick default profile per stream type
nhershko Mar 23, 2020
ad368cd
Merge pull request #178 from IntelRealSense/cspungin_code_cleanup
cspungin Mar 23, 2020
eb033c2
Merge branch 'master' into nhershko_default_profiles
nhershko Mar 23, 2020
9fc085f
CMake option name and state changed. Unused options removed. Stats re…
apuzhevi Mar 23, 2020
72c353b
Merge branch 'master' into nhershko_default_profiles
nhershko Mar 23, 2020
b758ae7
add try catch to dtor section
nhershko Mar 23, 2020
58ae051
Merge remote-tracking branch 'origin-lrsj/nhershko_default_profiles' …
nhershko Mar 23, 2020
9f013ce
(c) 2017 => (c) 2020
apuzhevi Mar 23, 2020
b829226
Merge branch 'master' into nhershko_default_profiles
nhershko Mar 23, 2020
ea34719
Uniform indentation. #pragma once everywhere.
apuzhevi Mar 24, 2020
a40564e
add default color format
nhershko Mar 24, 2020
dc1ad3f
Merge remote-tracking branch 'origin-lrsj/nhershko_default_profiles' …
nhershko Mar 24, 2020
deccbf8
merge with latest master
nhershko Mar 24, 2020
3c9e878
fix variable initialization
mchanan Mar 24, 2020
8783593
Merge pull request #181 from IntelRealSense/nhershko_default_profiles
nhershko Mar 24, 2020
c817641
Merge branch 'master' into mchanan_Variable_initialization
mchanan Mar 24, 2020
014f38a
Merge pull request #184 from IntelRealSense/mchanan_Variable_initiali…
mchanan Mar 24, 2020
c0c85c9
client todo's cleanup
nhershko Mar 24, 2020
14ac8c5
Merge branch 'master' into nhershko_todo_cleanup
nhershko Mar 24, 2020
f3af281
add error handling. ignore irelevant connection sequence number
nhershko Mar 24, 2020
df1cccd
Merge remote-tracking branch 'origin-lrsj/nhershko_todo_cleanup' into…
nhershko Mar 24, 2020
ead293c
Static binaries support. (#186)
apuzhevi Mar 24, 2020
883db6c
Merge branch 'master' into nhershko_todo_cleanup
nhershko Mar 24, 2020
dc10b30
fix server memory leak
cspungin Mar 24, 2020
f1c76e4
No log on stdout. (#189)
apuzhevi Mar 24, 2020
501f6a8
Merge branch 'master' into cspungin_fix_memorry_leak
cspungin Mar 24, 2020
5f4165b
Merge pull request #188 from IntelRealSense/cspungin_fix_memorry_leak
cspungin Mar 24, 2020
2e71d71
Using LZ4 of LRS. (#190)
apuzhevi Mar 24, 2020
16ec96f
lrs/development => lrsj/master
apuzhevi Mar 24, 2020
f700460
all non void function return value + clean non required scopes
nhershko Mar 24, 2020
e970339
Merge remote-tracking branch 'origin-lrsj/nhershko_todo_cleanup' into…
nhershko Mar 24, 2020
4b348b4
LZ4 on Windows fix.
apuzhevi Mar 25, 2020
efefc08
cleaning
nhershko Mar 25, 2020
99d2503
Merge branch 'master' into nhershko_todo_cleanup
nhershko Mar 25, 2020
fd94f77
16-bit alligment
cspungin Mar 25, 2020
0d79b54
change headers size
cspungin Mar 25, 2020
25728c2
update default resolution
nhershko Mar 25, 2020
d1377ec
Merge remote-tracking branch 'origin-lrsj/nhershko_todo_cleanup' into…
nhershko Mar 25, 2020
c68ff74
remove prints
cspungin Mar 25, 2020
b767b00
add commemt
cspungin Mar 25, 2020
ab5c06e
change bach logger configuration
cspungin Mar 25, 2020
7ea0607
Merge pull request #185 from IntelRealSense/nhershko_todo_cleanup
nhershko Mar 25, 2020
fadab66
delete objects
mchanan Mar 25, 2020
58a8671
use union
cspungin Mar 25, 2020
80dc2ed
Merge branch 'master' into cspungin_aligment
cspungin Mar 25, 2020
645de72
fix merge
cspungin Mar 25, 2020
d15a016
Log fix.
apuzhevi Mar 25, 2020
0069523
Merge branch 'master' into cspungin_aligment
apuzhevi Mar 25, 2020
7867b3c
change to nullptr
mchanan Mar 25, 2020
8a4c48f
Merge branch 'master' into mchnan_delete_objects
mchanan Mar 25, 2020
3078527
Merge pull request #191 from IntelRealSense/cspungin_aligment
cspungin Mar 25, 2020
c1396e5
Merge branch 'master' into mchnan_delete_objects
mchanan Mar 25, 2020
1055fc0
Merge pull request #193 from IntelRealSense/mchnan_delete_objects
mchanan Mar 25, 2020
192b7b3
remove_alligned_aloc
cspungin Mar 25, 2020
82ba924
Merge branch 'cspungin_aligment' of https://github.com/IntelRealSense…
cspungin Mar 25, 2020
135b6b6
remove include
cspungin Mar 25, 2020
74007ce
Merge branch 'master' into cspungin_aligment
cspungin Mar 25, 2020
bfd02ea
Merge pull request #195 from IntelRealSense/cspungin_aligment
cspungin Mar 25, 2020
c1a73df
ev_mp changes (#194)
apuzhevi Mar 26, 2020
9426f24
zlib leftovers
apuzhevi Mar 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ if(IMPORT_DEPTH_CAM_FW AND NOT INTERNET_CONNECTION)
set(IMPORT_DEPTH_CAM_FW OFF)
endif()

set(BUILD_IPDEV ON CACHE BOOL "Enable IP device support")
apuzhevi marked this conversation as resolved.
Show resolved Hide resolved
set(BUILD_IPDEV_UNITTESTS ON CACHE BOOL "Enable unittests for IP device")
apuzhevi marked this conversation as resolved.
Show resolved Hide resolved
set(BUILD_IPDEV_STATS ON CACHE BOOL "Enable statistics for IP device")
apuzhevi marked this conversation as resolved.
Show resolved Hide resolved

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake)

# include librealsense general configuration
Expand Down Expand Up @@ -83,6 +87,12 @@ if(BUILD_EXAMPLES)
add_subdirectory(tools)
endif()

if(BUILD_IPDEV)
add_subdirectory(src/ethernet)
endif()

add_subdirectory(src/compression)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider moving under src/ethernet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to make COMPRESSION factory available LRS wide?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending


if(BUILD_UNIT_TESTS)
add_subdirectory(unit-tests)
endif()
Expand Down
20 changes: 18 additions & 2 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5294,8 +5294,9 @@ namespace rs2
// draw device header
////////////////////////////////////////
const bool is_playback_device = dev.is<playback>();
bool is_ip_device = dev.supports(RS2_CAMERA_INFO_IP_ADDRESS);
auto header_h = panel_height;
if (is_playback_device) header_h += 15;
if (is_playback_device || is_ip_device) header_h += 15;

ImColor device_header_background_color = title_color;
const float left_space = 3.f;
Expand Down Expand Up @@ -5327,7 +5328,14 @@ namespace rs2
std::stringstream ss;
if(dev.supports(RS2_CAMERA_INFO_NAME))
ss << dev.get_info(RS2_CAMERA_INFO_NAME);
ImGui::Text(" %s", ss.str().c_str());
if(is_ip_device)
{
ImGui::Text(" %s", ss.str().substr(0, ss.str().find("\n IP Device")).c_str());
}
else
{
ImGui::Text(" %s", ss.str().c_str());
}
if (dev.supports(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR))
{
std::string desc = dev.get_info(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR);
Expand All @@ -5347,6 +5355,14 @@ namespace rs2
ImGui::PopStyleColor();
ImGui::PopFont();
}
if(is_ip_device)
{
ImGui::PushFont(window.get_font());
ss.str("");
ss << dev.get_info(RS2_CAMERA_INFO_IP_ADDRESS);
ImGui::Text("\tIP device\t%s", ss.str().c_str());
ImGui::PopFont();
}


//ImGui::Text(" %s", dev.get_info(RS2_CAMERA_INFO_NAME));
Expand Down
26 changes: 26 additions & 0 deletions include/librealsense2-net/rs_net.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* License: Apache 2.0. See LICENSE file in root directory.
Copyright(c) 2017 Intel Corporation. All Rights Reserved. */

/** \file rs_net.h
* \
* Exposes RealSense network device functionality for C compilers
*/

#ifndef LIBREALSENSE_RS2_NET_H
#define LIBREALSENSE_RS2_NET_H

#ifdef __cplusplus
extern "C" {
#endif

#include "librealsense2/rs.h"

/**
* create RealSense net device by ip address
apuzhevi marked this conversation as resolved.
Show resolved Hide resolved
*/
rs2_device* rs2_create_net_device(int api_version, const char* address, rs2_error** error);

#ifdef __cplusplus
}
#endif
#endif
47 changes: 47 additions & 0 deletions include/librealsense2-net/rs_net.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#ifndef LIBREALSENSE_RS2_NET_HPP
#define LIBREALSENSE_RS2_NET_HPP

#include <librealsense2/rs.hpp>
#include "rs_net.h"

#include <memory>

namespace rs2
{
class net_device : public rs2::device
{
public:
net_device(const std::string& address) : rs2::device(init(address)) { }

/**
* Add network device to existing context.
* Any future queries on the context will return this device.
* This operation cannot be undone (except for destroying the context)
*
* \param[in] ctx context to add the device to
*/
void add_to(context& ctx)
{
rs2_error* e = nullptr;
rs2_context_add_software_device(((std::shared_ptr<rs2_context>)ctx).get(), _dev.get(), &e);
error::handle(e);
}


private:
std::shared_ptr<rs2_device> init(const std::string& address)
{
rs2_error* e = nullptr;
auto dev = std::shared_ptr<rs2_device>(
rs2_create_net_device(RS2_API_VERSION, address.c_str(), &e),
rs2_delete_device);
error::handle(e);

return dev;
}
};
}
#endif // LIBREALSENSE_RS2_NET_HPP
1 change: 1 addition & 0 deletions include/librealsense2/h/rs_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ typedef enum rs2_camera_info {
RS2_CAMERA_INFO_PRODUCT_LINE , /**< Device product line D400/SR300/L500/T200 */
RS2_CAMERA_INFO_ASIC_SERIAL_NUMBER , /**< ASIC serial number */
RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID , /**< Firmware update ID */
RS2_CAMERA_INFO_IP_ADDRESS , /**< IP address for remote camera. */
RS2_CAMERA_INFO_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */
} rs2_camera_info;
const char* rs2_camera_info_to_string(rs2_camera_info info);
Expand Down
16 changes: 9 additions & 7 deletions include/librealsense2/hpp/rs_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,25 +246,27 @@ namespace rs2
};


class software_device : public device
class software_device : public device
apuzhevi marked this conversation as resolved.
Show resolved Hide resolved
{
std::shared_ptr<rs2_device> create_device_ptr()
std::shared_ptr<rs2_device> create_device_ptr(std::function<void(rs2_device*)> deleter)
{
rs2_error* e = nullptr;
std::shared_ptr<rs2_device> dev(
rs2_create_software_device(&e),
rs2_delete_device);
deleter);
error::handle(e);
return dev;
}

public:
software_device()
: device(create_device_ptr())
{}
software_device(std::function<void(rs2_device*)> deleter = &rs2_delete_device)
: device(create_device_ptr(deleter))
{
this->set_destruction_callback([]{});
}

software_device(std::string name)
: device(create_device_ptr())
: device(create_device_ptr(&rs2_delete_device))
{
update_info(RS2_CAMERA_INFO_NAME, name);
}
Expand Down
6 changes: 6 additions & 0 deletions scripts/setup_network_queues.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e
apuzhevi marked this conversation as resolved.
Show resolved Hide resolved

echo 8388608 > /proc/sys/net/core/wmem_default
echo 8388608 > /proc/sys/net/core/rmem_default

echo "Setting-up network queues successfully changed"
57 changes: 57 additions & 0 deletions src/compression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2019 Intel Corporation. All Rights Reserved.
cmake_minimum_required(VERSION 3.9.0)

project(realsense2-compression VERSION 1.0.0 LANGUAGES CXX C)
# Save the command line compile commands in the build output

set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

set(DEPENDENCIES ${DEPENDENCIES} realsense2)

file(GLOB COMPRESSION_SOURCES
"*.hh"
"*.h"
"*.cpp"
"../ipDeviceCommon/*.h"
"../ipDeviceCommon/*.cpp"
)

add_library(${PROJECT_NAME} STATIC ${COMPRESSION_SOURCES})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider not adding as a library but build into realsense2-net instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending


include_directories(${PROJECT_NAME}
../../common
../ipDeviceCommon
)

set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)

add_dependencies(realsense2-compression
lz4
libjpeg-turbo
zlib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is zlib in use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be used instead of lz4. But default - it is not.

)

include_directories(${PROJECT_NAME}
${CMAKE_BINARY_DIR}/zlib/include
${CMAKE_BINARY_DIR}/libjpeg-turbo/include
${CMAKE_BINARY_DIR}/lz4/include
)

target_link_libraries(${PROJECT_NAME}
PRIVATE ${DEPENDENCIES}
${CMAKE_BINARY_DIR}/zlib/lib/libz.a
${CMAKE_BINARY_DIR}/libjpeg-turbo/lib/libturbojpeg.a
${CMAKE_BINARY_DIR}/lz4/lib/liblz4.a
)

if(BUILD_IPDEV_STATS)
add_definitions(-DSTATISTICS)
endif()

set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "Library")

install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
64 changes: 64 additions & 0 deletions src/compression/CompressionFactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
apuzhevi marked this conversation as resolved.
Show resolved Hide resolved

#include "RvlCompression.h"
#include "GzipCompression.h"
#include "JpegCompression.h"
#include "Lz4Compression.h"
#include "CompressionFactory.h"

std::shared_ptr<ICompression> CompressionFactory::getObject(int t_width, int t_height, rs2_format t_format, rs2_stream t_streamType, int t_bpp)
{
ZipMethod zipMeth;
if (t_streamType == RS2_STREAM_COLOR || t_streamType == RS2_STREAM_INFRARED)
{
zipMeth = ZipMethod::jpeg;
}
else if (t_streamType == RS2_STREAM_DEPTH)
{
zipMeth = ZipMethod::lz;
}
if (!isCompressionSupported(t_format, t_streamType))
{
return nullptr;
}

switch (zipMeth)
{
case ZipMethod::gzip:
return std::make_shared<GzipCompression>(t_width, t_height, t_format, t_bpp);
break;
case ZipMethod::rvl:
return std::make_shared<RvlCompression>(t_width, t_height, t_format, t_bpp);
break;
case ZipMethod::jpeg:
return std::make_shared<JpegCompression>(t_width, t_height, t_format, t_bpp);
break;
case ZipMethod::lz:
return std::make_shared<Lz4Compression>(t_width, t_height, t_format, t_bpp);
break;
default:
printf("error: unknown zip method\n");
return nullptr;
}
}

bool & CompressionFactory::getIsEnabled()
{
static bool m_isEnabled;
apuzhevi marked this conversation as resolved.
Show resolved Hide resolved
return m_isEnabled;
};

bool CompressionFactory::isCompressionSupported(rs2_format t_format, rs2_stream t_streamType)
{
if (getIsEnabled() == 0)
{
return false;
}

if ((t_streamType == RS2_STREAM_COLOR || t_streamType == RS2_STREAM_INFRARED) && ( t_format != RS2_FORMAT_BGR8 && t_format != RS2_FORMAT_RGB8 && t_format != RS2_FORMAT_Y8 && t_format != RS2_FORMAT_YUYV && t_format != RS2_FORMAT_UYVY))
{
return false;
}
return true;
}
23 changes: 23 additions & 0 deletions src/compression/CompressionFactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#pragma once

#include "ICompression.h"
#define IS_COMPRESSION_ENABLED 1

typedef enum ZipMethod
{
gzip,
rvl,
jpeg,
lz,
} ZipMethod;

class CompressionFactory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since compression factory is a singleton please change the design as follows:
a. All methods are not static, enabled is class member
b. Add single static function:

static CompressionFactory& CompressionFactory::instance() {
     static CompressionFactory inst;
     return inst;
}

aka mayers singleton.
also, consider not making it singleton

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP

{
public:
static std::shared_ptr<ICompression> getObject(int t_width, int t_height, rs2_format t_format, rs2_stream t_streamType, int t_bpp);
static bool isCompressionSupported(rs2_format t_format, rs2_stream t_streamType);
static bool &getIsEnabled();
};
Loading