diff --git a/src/ethernet/CMakeLists.txt b/src/ethernet/CMakeLists.txt index 29ca0be584..e48da84cf5 100644 --- a/src/ethernet/CMakeLists.txt +++ b/src/ethernet/CMakeLists.txt @@ -57,6 +57,10 @@ target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES} ) +if(COMPRESSION) + add_definitions(-DCOMPRESSION) +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..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,13 +170,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 COMPRESSION 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 COMPRESSION } +#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..974cd7c1a6 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(COMPRESSION) + add_definitions(-DCOMPRESSION) +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..aa0f30185a 100644 --- a/tools/rs-server/RsSource.cpp +++ b/tools/rs-server/RsSource.cpp @@ -103,7 +103,9 @@ void RsDeviceSource::doGetNextFrame() void RsDeviceSource::deliverRSFrame() { */ +#ifdef COMPRESSION 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 COMPRESSION } +#endif // After delivering the data, inform the reader that it is now available: FramedSource::afterGetting(this); }