Skip to content

Commit

Permalink
EHN: Enable the video message in the messagefactory
Browse files Browse the repository at this point in the history
  • Loading branch information
leochan2009 committed Dec 22, 2017
1 parent c501689 commit 244276a
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 111 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ OPTION(OpenIGTLink_USE_OpenHEVC "Link the OpenHEVC tree." OFF)

#-----------------------------------------------------------------------------
# Configure WebSocket
OPTION(USE_WEBSOCKET "Build the Websocket." OFF)
OPTION(OpenIGTLink_USE_WEBSOCKET "Build the Websocket." OFF)

#-----------------------------------------------------------------------------
# OpenIGTLink build configuration options.
Expand Down Expand Up @@ -165,8 +165,10 @@ IF(CMAKE_USE_PTHREADS)
ENDIF()

SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "0")
IF (OpenIGTLink_USE_H264 OR OpenIGTLink_USE_VP9 OR OpenIGTLink_USE_X265 OR OpenIGTLink_USE_OpenHEVC)
SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "1")
IF(${OpenIGTLink_PROTOCOL_VERSION} GREATER "2")
IF (OpenIGTLink_USE_H264 OR OpenIGTLink_USE_VP9 OR OpenIGTLink_USE_X265 OR OpenIGTLink_USE_OpenHEVC)
SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "1")
ENDIF()
ENDIF()
#-----------------------------------------------------------------------------
# Run superbuild script instead of library script
Expand Down
16 changes: 9 additions & 7 deletions Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ if (${OpenIGTLink_PROTOCOL_VERSION} GREATER 1)
)
endif (${OpenIGTLink_PROTOCOL_VERSION} GREATER 1)


IF(OpenIGTLink_USE_H264 OR OpenIGTLink_USE_VP9 OR (OpenIGTLink_USE_X265 AND OpenIGTLink_USE_OpenHEVC) AND (${OpenIGTLink_PROTOCOL_VERSION} GREATER 2))
SET(EXAMPLE_DIRS
${EXAMPLE_DIRS}
VideoStreaming
)
IF(${OpenIGTLink_PROTOCOL_VERSION} GREATER 2)
IF(OpenIGTLink_USE_H264 OR OpenIGTLink_USE_VP9 OR (OpenIGTLink_USE_X265 AND OpenIGTLink_USE_OpenHEVC))
SET(EXAMPLE_DIRS
${EXAMPLE_DIRS}
VideoStreaming
)
ENDIF()
ENDIF()

IF(USE_WEBSOCKET)

IF(OpenIGTLink_USE_WEBSOCKET)
SET(EXAMPLE_DIRS
${EXAMPLE_DIRS}
WebSocket
Expand Down
2 changes: 1 addition & 1 deletion OpenIGTLinkConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SET(OpenIGTLink_USE_VP9 @OpenIGTLink_USE_VP9@)
SET(OpenIGTLink_USE_X265 @OpenIGTLink_USE_X265@)
SET(OpenIGTLink_USE_OpenHEVC @OpenIGTLink_USE_OpenHEVC@)
SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "@OpenIGTLink_ENABLE_VIDEOSTREAMING@")
SET(USE_WEBSOCKET @USE_WEBSOCKET@)
SET(OpenIGTLink_USE_WEBSOCKET @OpenIGTLink_USE_WEBSOCKET@)

# Path to CableSwig configuration used by OpenIGTLink.
SET(OpenIGTLink_CableSwig_DIR "@OpenIGTLink_CableSwig_DIR_CONFIG@")
Expand Down
6 changes: 3 additions & 3 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,14 @@ IF(${OpenIGTLink_PROTOCOL_VERSION} GREATER "2")
ENDIF()

IF (NOT (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 3.04))
IF(OpenIGTLink_USE_H264 OR OpenIGTLink_USE_VP9 OR OpenIGTLink_USE_X265 OR OpenIGTLink_USE_OpenHEVC)
IF(OpenIGTLink_ENABLE_VIDEOSTREAMING)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/VideoStreaming/VideoStreaming.cmake)
ENDIF()

#-----------------------------------------------------------------------------
# Configure WebSocket
# Create the link to the WebSocket libraries
IF(USE_WEBSOCKET)
IF(OpenIGTLink_USE_WEBSOCKET)
FIND_PACKAGE(WebSocket REQUIRED)
LIST(APPEND LINK_LIBS WebSocket)

Expand Down Expand Up @@ -257,7 +257,7 @@ IF (NOT (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 3.04))
IF(OpenIGTLink_USE_OpenHEVC AND (NOT OpenHEVC_FOUND))
add_dependencies(OpenIGTLink OpenHEVC)
ENDIF()
IF(USE_WEBSOCKET)
IF(OpenIGTLink_USE_WEBSOCKET)
add_dependencies(OpenIGTLink WebSocket)
ENDIF()
ELSE()
Expand Down
175 changes: 86 additions & 89 deletions Source/VideoStreaming/VideoStreaming.cmake
Original file line number Diff line number Diff line change
@@ -1,139 +1,136 @@
# Add support for OpenIGTLink version 3
IF(${OpenIGTLink_PROTOCOL_VERSION} GREATER "2")
LIST(APPEND OpenIGTLink_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/Source/VideoStreaming)
LIST(APPEND OpenIGTLink_SOURCES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtl_video.c
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtl_videometa.c
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVideoMessage.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VideoStreamIGTLinkServer.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VideoStreamIGTLinkReceiver.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlCodecCommonClasses.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVideoMetaMessage.cxx
)
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/Source/VideoStreaming
)
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtl_video.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtl_videometa.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVideoMessage.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VideoStreamIGTLinkServer.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VideoStreamIGTLinkReceiver.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlCodecCommonClasses.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVideoMetaMessage.h
)
IF(OpenIGTLink_USE_H264)
INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_openh264.cmake)
IF(EXISTS ${OpenH264_LIBRARY_DIR})
LIST(APPEND OpenIGTLink_SOURCES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H264Decoder.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H264Encoder.cxx
)
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H264Decoder.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H264Encoder.h
)
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
${OpenH264_INCLUDE_DIR}
)
ELSE()
MESSAGE("H264_LIBRARY no found. You could specify OpenH264_INCLUDE_DIR or OpenH264_LIBRARY_DIR")
ENDIF()
ENDIF()
IF(OpenIGTLink_USE_VP9)
INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_VP9.cmake)
IF(EXISTS ${VP9_LIBRARY_DIR})
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
${VP9_INCLUDE_DIR}
)
LIST(APPEND OpenIGTLink_SOURCES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VP9Decoder.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VP9Encoder.cxx
LIST(APPEND OpenIGTLink_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/Source/VideoStreaming)
LIST(APPEND OpenIGTLink_SOURCES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtl_video.c
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtl_videometa.c
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVideoMessage.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VideoStreamIGTLinkServer.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VideoStreamIGTLinkReceiver.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlCodecCommonClasses.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVideoMetaMessage.cxx
)
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/Source/VideoStreaming
)
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtl_video.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtl_videometa.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVideoMessage.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VideoStreamIGTLinkServer.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VideoStreamIGTLinkReceiver.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlCodecCommonClasses.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVideoMetaMessage.h
)
IF(OpenIGTLink_USE_H264)
INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_openh264.cmake)
IF(EXISTS ${OpenH264_LIBRARY_DIR})
LIST(APPEND OpenIGTLink_SOURCES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H264Decoder.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H264Encoder.cxx
)
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VP9Decoder.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VP9Encoder.h
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H264Decoder.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H264Encoder.h
)
IF(NOT ${VP9_LIBRARY_DIR} EQUAL "")
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
"${VP9_LIBRARY_DIR}" )
LINK_DIRECTORIES("${VP9_LIBRARY_DIR}/lib")
ENDIF()
ELSE()
MESSAGE("VP9_INCLUDE_DIR or VP9_LIBRARY_DIR no found")
ENDIF()
ENDIF()

IF(OpenIGTLink_USE_X265)
INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_X265.cmake)
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
${X265_INCLUDE_DIR}
${X265_LIBRARY_DIR}
)
LIST(APPEND OpenIGTLink_SOURCES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H265Encoder.cxx
)
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H265Encoder.h
${OpenH264_INCLUDE_DIR}
)
ELSE()
MESSAGE("H264_LIBRARY no found. You could specify OpenH264_INCLUDE_DIR or OpenH264_LIBRARY_DIR")
ENDIF()

IF(OpenIGTLink_USE_OpenHEVC)
INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_openHEVC.cmake)
ENDIF()
IF(OpenIGTLink_USE_VP9)
INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_VP9.cmake)
IF(EXISTS ${VP9_LIBRARY_DIR})
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
${OpenHEVC_INCLUDE_DIR}
${VP9_INCLUDE_DIR}
)
LIST(APPEND OpenIGTLink_SOURCES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H265Decoder.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VP9Decoder.cxx
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VP9Encoder.cxx
)
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H265Decoder.h
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VP9Decoder.h
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/VP9Encoder.h
)
IF(NOT ${VP9_LIBRARY_DIR} EQUAL "")
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
"${VP9_LIBRARY_DIR}" )
LINK_DIRECTORIES("${VP9_LIBRARY_DIR}/lib")
ENDIF()
ELSE()
MESSAGE("VP9_INCLUDE_DIR or VP9_LIBRARY_DIR no found")
ENDIF()
ENDIF()

IF(OpenIGTLink_USE_X265)
INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_X265.cmake)
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
${X265_INCLUDE_DIR}
${X265_LIBRARY_DIR}
)
LIST(APPEND OpenIGTLink_SOURCES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H265Encoder.cxx
)
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H265Encoder.h
)
ENDIF()

IF(OpenIGTLink_USE_OpenHEVC)
INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_openHEVC.cmake)
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
${OpenHEVC_INCLUDE_DIR}
)
LIST(APPEND OpenIGTLink_SOURCES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H265Decoder.cxx
)
LIST(APPEND OpenIGTLink_INCLUDE_FILES
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/H265Decoder.h
)
ENDIF()

IF(WIN32) # for Windows
IF((${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" ) AND OpenIGTLink_USE_H264)
IF(OpenIGTLink_USE_H264)
LIST(APPEND LINK_LIBS
${OpenH264_LIBRARY_DIR}/openh264.lib
)
ENDIF()
IF((${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" ) AND OpenIGTLink_USE_VP9)
IF(OpenIGTLink_USE_VP9)
#To do, library name depends on the compiler setting, could be vpxmt.lib and vpxmtd also. Make sure the setting matches.
LIST(APPEND LINK_LIBS
VP9_lib
)
ENDIF()
IF((${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" ) AND OpenIGTLink_USE_X265)
IF(OpenIGTLink_USE_X265)
#To do, library name depends on the compiler setting, could be vpxmt.lib and vpxmtd also. Make sure the setting matches.
SET(LINK_X265_LIBRARY optimized ${X265_LIBRARY_DIR}\\Release\\x265-static.lib debug ${X265_LIBRARY_DIR}\\Debug\\x265-static.lib)
LIST(APPEND LINK_LIBS
${LINK_X265_LIBRARY}
)
ENDIF()
IF((${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" ) AND OpenIGTLink_USE_OpenHEVC)
IF(OpenIGTLink_USE_OpenHEVC)
#To do, library name depends on the compiler setting, could be vpxmt.lib and vpxmtd also. Make sure the setting matches.
LIST(APPEND LINK_LIBS
${OpenHEVC_LIBRARY}
)
ENDIF()
ELSE() # for POSIX-compatible OSs
IF((${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" ) AND OpenIGTLink_USE_H264)
IF(OpenIGTLink_USE_H264)
LIST(APPEND LINK_LIBS
${OpenH264_LIBRARY_DIR}/libopenh264.a
)
ENDIF()
IF((${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" ) AND OpenIGTLink_USE_VP9)
IF(OpenIGTLink_USE_VP9)
LIST(APPEND LINK_LIBS
${VP9_LIBRARY_DIR}/libvpx.a
)
ENDIF()
IF((${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" ) AND OpenIGTLink_USE_X265)
IF(OpenIGTLink_USE_X265)
LIST(APPEND LINK_LIBS
${X265_LIBRARY_DIR}/libx265.a
)
ENDIF()
IF((${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" ) AND OpenIGTLink_USE_OpenHEVC)
IF(OpenIGTLink_USE_OpenHEVC)
LIST(APPEND LINK_LIBS
${OpenHEVC_LIBRARY}
)
Expand Down
8 changes: 8 additions & 0 deletions Source/igtlMessageFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ PURPOSE. See the above copyright notices for more information.
#include "igtlCommandMessage.h"
#endif // OpenIGTLink_PROTOCOL_VERSION >= 3

#if OpenIGTLink_ENABLE_VIDEOSTREAMING
#include "igtlVideoMessage.h"
#endif

#include "igtl_header.h"

#include <algorithm>
Expand Down Expand Up @@ -87,6 +91,10 @@ MessageFactory::MessageFactory()
this->AddMessageType("COMMAND", (PointerToMessageBaseNew)&igtl::CommandMessage::New);
this->AddMessageType("RTS_COMMAND", (PointerToMessageBaseNew)&igtl::RTSCommandMessage::New);
#endif

#if OpenIGTLink_ENABLE_VIDEOSTREAMING
this->AddMessageType("VIDEO", (PointerToMessageBaseNew)&igtl::VideoMessage::New);
#endif
}


Expand Down
4 changes: 0 additions & 4 deletions Source/igtlMessageHandlerMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@
return this->m_Message->GetMessageType(); \
} \
virtual const char* GetMessageType() \
{ \
return this->m_Message->GetType(); \
} \
virtual const char* GetMessageType() \
{ \
return this->m_Message->GetDeviceType(); \
} \
Expand Down
4 changes: 2 additions & 2 deletions SuperBuild/Superbuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ IF(OpenIGTLink_USE_OpenHEVC)
ENDIF()
ENDIF()

IF(USE_WEBSOCKET)
IF(OpenIGTLink_USE_WEBSOCKET)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/External_WebSocket.cmake)
LIST(APPEND OpenIGTLink_DEPENDENCIES websocket)
ENDIF()
Expand All @@ -58,7 +58,7 @@ ExternalProject_Add( OpenIGTLink-lib
-DOpenIGTLink_USE_VP9:BOOL=${OpenIGTLink_USE_VP9}
-DOpenIGTLink_USE_X265:BOOL=${OpenIGTLink_USE_X265}
-DOpenIGTLink_USE_OpenHEVC:BOOL=${OpenIGTLink_USE_OpenHEVC}
-DUSE_WEBSOCKET:BOOL=${USE_WEBSOCKET}
-DOpenIGTLink_USE_WEBSOCKET:BOOL=${OpenIGTLink_USE_WEBSOCKET}
-DBUILD_EXAMPLES:BOOL=${BUILD_EXAMPLES}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
Expand Down
2 changes: 1 addition & 1 deletion UseOpenIGTLink.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ INCLUDE_DIRECTORIES(BEFORE ${OpenIGTLink_INCLUDE_DIRS})
# Load the OpenIGTLink targets
include(${OpenIGTLink_LIBRARY_TARGETS_FILE})

IF(USE_WEBSOCKET)
IF(OpenIGTLink_USE_WEBSOCKET)
SET(CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/websocketpp")
find_package(WebSocket REQUIRED)
ENDIF()
2 changes: 1 addition & 1 deletion igtlConfigure.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#cmakedefine OpenIGTLink_USE_VP9
#cmakedefine OpenIGTLink_USE_X265
#cmakedefine OpenIGTLink_USE_OpenHEVC
#cmakedefine USE_WEBSOCKET
#cmakedefine OpenIGTLink_USE_WEBSOCKET
#define OpenIGTLink_ENABLE_VIDEOSTREAMING @OpenIGTLink_ENABLE_VIDEOSTREAMING@

#define OpenIGTLink_PROTOCOL_VERSION_1 1
Expand Down

0 comments on commit 244276a

Please sign in to comment.