From ece4044054ae483590611911b652fe4967c7c69f Mon Sep 17 00:00:00 2001 From: mchanan Date: Sun, 22 Dec 2019 15:45:28 +0200 Subject: [PATCH 1/2] add compresstion flag -DCOMPRESS_FRAMES=ON --- src/ethernet/CMakeLists.txt | 4 ++++ src/ethernet/ethernet-device.cpp | 4 ++++ tools/rs-server/CMakeLists.txt | 4 ++++ tools/rs-server/RsSource.cpp | 15 ++++++--------- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/ethernet/CMakeLists.txt b/src/ethernet/CMakeLists.txt index 29ca0be584..d098dc48d9 100644 --- a/src/ethernet/CMakeLists.txt +++ b/src/ethernet/CMakeLists.txt @@ -57,6 +57,10 @@ target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES} ) +if(COMPRESS_FRAMES) + add_definitions(-DCOMPRESS_FRAMES) +endif() + target_include_directories(${PROJECT_NAME} PUBLIC "rtsp_client/*.h") target_include_directories(${PROJECT_NAME} PUBLIC ${LIVE}/groupsock/include ${LIVE}/liveMedia/include ${LIVE}/UsageEnvironment/include ${LIVE}/BasicUsageEnvironment/include inc) diff --git a/src/ethernet/ethernet-device.cpp b/src/ethernet/ethernet-device.cpp index 1755357123..05efd051e2 100644 --- a/src/ethernet/ethernet-device.cpp +++ b/src/ethernet/ethernet-device.cpp @@ -168,13 +168,17 @@ void rs2::ethernet_device::pull_from_queue(int stream_index) //const std::lock_guard lock(mtx); Frame* frame = frame_queues[stream_index].front(); frame_queues[stream_index].pop(); +#ifdef COMPRESS_FRAMES if (stream_index == 0) { // depth idecomress->decompressFrame((unsigned char *)frame->m_buffer, frame->m_size, (unsigned char*)(last_frame[stream_index].pixels)); } else { // other -> color +#endif memcpy(last_frame[stream_index].pixels, frame->m_buffer, frame->m_size); +#ifdef COMPRESS_FRAMES } +#endif // delete frame; last_frame[stream_index].timestamp = frame->m_timestamp.tv_sec; last_frame[stream_index].frame_number++; diff --git a/tools/rs-server/CMakeLists.txt b/tools/rs-server/CMakeLists.txt index 21eb10f35e..0e63ff29fb 100644 --- a/tools/rs-server/CMakeLists.txt +++ b/tools/rs-server/CMakeLists.txt @@ -47,6 +47,10 @@ find_package(ZLIB REQUIRED) target_link_libraries(rs-server ${DEPENDENCIES} realsense2 ${ZLIB_LIBRARIES}) +if(COMPRESS_FRAMES) + add_definitions(-DCOMPRESS_FRAMES) +endif() + set_target_properties (rs-server PROPERTIES FOLDER Tools ) diff --git a/tools/rs-server/RsSource.cpp b/tools/rs-server/RsSource.cpp index c03cc7341f..2b002f84d4 100644 --- a/tools/rs-server/RsSource.cpp +++ b/tools/rs-server/RsSource.cpp @@ -103,7 +103,9 @@ void RsDeviceSource::doGetNextFrame() void RsDeviceSource::deliverRSFrame() { */ +#ifdef COMPRESS_FRAMES IcompressFrame* iCompress = compressFrameFactory::create(zipMethod::gzip); +#endif if (!isCurrentlyAwaitingData()) { envir() << "isCurrentlyAwaitingData returned false"<compressFrame(fbuf, fFrameSize, compressedBuf); - envir() << "Compression income " << fFrameSize << ", outcome " << newSize << "\n"; - // memmove(fTo, compressedBuf, fFrameSize); - memmove(fTo, compressedBuf, newSize + sizeof(unsigned int)); -#else iCompress->compressFrame(fbuf, fFrameSize, fTo); -#endif } else { +#endif memmove(fTo, fbuf, 640*480*2); +#ifdef COMPRESS_FRAMES } +#endif // After delivering the data, inform the reader that it is now available: FramedSource::afterGetting(this); } From c3579d193726a1bd7b72678d8d3e97fef7008180 Mon Sep 17 00:00:00 2001 From: mchanan Date: Mon, 23 Dec 2019 12:01:19 +0200 Subject: [PATCH 2/2] change flag name --- src/ethernet/CMakeLists.txt | 4 ++-- src/ethernet/ethernet-device.cpp | 6 ++++-- tools/rs-server/CMakeLists.txt | 4 ++-- tools/rs-server/RsSource.cpp | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ethernet/CMakeLists.txt b/src/ethernet/CMakeLists.txt index d098dc48d9..e48da84cf5 100644 --- a/src/ethernet/CMakeLists.txt +++ b/src/ethernet/CMakeLists.txt @@ -57,8 +57,8 @@ target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES} ) -if(COMPRESS_FRAMES) - add_definitions(-DCOMPRESS_FRAMES) +if(COMPRESSION) + add_definitions(-DCOMPRESSION) endif() target_include_directories(${PROJECT_NAME} PUBLIC "rtsp_client/*.h") diff --git a/src/ethernet/ethernet-device.cpp b/src/ethernet/ethernet-device.cpp index 05efd051e2..3d1e9d256f 100644 --- a/src/ethernet/ethernet-device.cpp +++ b/src/ethernet/ethernet-device.cpp @@ -34,7 +34,9 @@ void sig_handler(int signo) rs2::ethernet_device::ethernet_device() { dev = rs2_create_software_device(NULL); +#ifdef COMPRESSION idecomress = decompressFrameFactory::create(zipMethod::gzip); +#endif } rs2::ethernet_device::ethernet_device(std::string url) : ethernet_device() @@ -168,7 +170,7 @@ void rs2::ethernet_device::pull_from_queue(int stream_index) //const std::lock_guard lock(mtx); Frame* frame = frame_queues[stream_index].front(); frame_queues[stream_index].pop(); -#ifdef COMPRESS_FRAMES +#ifdef COMPRESSION if (stream_index == 0) { // depth idecomress->decompressFrame((unsigned char *)frame->m_buffer, frame->m_size, (unsigned char*)(last_frame[stream_index].pixels)); @@ -176,7 +178,7 @@ void rs2::ethernet_device::pull_from_queue(int stream_index) // other -> color #endif memcpy(last_frame[stream_index].pixels, frame->m_buffer, frame->m_size); -#ifdef COMPRESS_FRAMES +#ifdef COMPRESSION } #endif // delete frame; diff --git a/tools/rs-server/CMakeLists.txt b/tools/rs-server/CMakeLists.txt index 0e63ff29fb..974cd7c1a6 100644 --- a/tools/rs-server/CMakeLists.txt +++ b/tools/rs-server/CMakeLists.txt @@ -47,8 +47,8 @@ find_package(ZLIB REQUIRED) target_link_libraries(rs-server ${DEPENDENCIES} realsense2 ${ZLIB_LIBRARIES}) -if(COMPRESS_FRAMES) - add_definitions(-DCOMPRESS_FRAMES) +if(COMPRESSION) + add_definitions(-DCOMPRESSION) endif() set_target_properties (rs-server PROPERTIES diff --git a/tools/rs-server/RsSource.cpp b/tools/rs-server/RsSource.cpp index 2b002f84d4..aa0f30185a 100644 --- a/tools/rs-server/RsSource.cpp +++ b/tools/rs-server/RsSource.cpp @@ -103,7 +103,7 @@ void RsDeviceSource::doGetNextFrame() void RsDeviceSource::deliverRSFrame() { */ -#ifdef COMPRESS_FRAMES +#ifdef COMPRESSION IcompressFrame* iCompress = compressFrameFactory::create(zipMethod::gzip); #endif if (!isCurrentlyAwaitingData()) @@ -129,14 +129,14 @@ void RsDeviceSource::deliverRSFrame() gettimeofday(&fPresentationTime, NULL); // If you have a more accurate time - e.g., from an encoder - then use that instead. //// memmove(fTo, frame.get_data(), fFrameSize); //// unsigned char b[640*480*2]; -#ifdef COMPRESS_FRAMES +#ifdef COMPRESSION if(fParams.sensorID == 0) { iCompress->compressFrame(fbuf, fFrameSize, fTo); } else { #endif memmove(fTo, fbuf, 640*480*2); -#ifdef COMPRESS_FRAMES +#ifdef COMPRESSION } #endif // After delivering the data, inform the reader that it is now available: