Skip to content

Commit 269c68b

Browse files
committed
EHN: VP9 download and link for Visual studio 2013 and 2015. build of openigtlink use the other
compilers in windows platform will still succeed, but without vp9 support.
1 parent 70c9cb5 commit 269c68b

17 files changed

+170
-123
lines changed

BUILD.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ If all went OK you will have the executable and the library:
4848

4949
VideoStreaming
5050
---------------
51-
You might want to use OpenIGTLink library to perform video streaming. Currently OpenH264, H265 and VP9 are supported in the OpenIGTLink.
51+
You might want to use OpenIGTLink library to perform video streaming. Currently OpenH264, H265, VP9 and AV1 are supported in the OpenIGTLink.
5252

5353
* Prerequisites
5454

@@ -64,6 +64,7 @@ In the case of H265 build, H265 have many implementations, the encoder used in l
6464
OpenIGTLink library doesn't build H265 libraries, so the users need to download and compile the libraries by themselves.
6565
Afterwards, set the variables-"X265_INCLUDE_DIR, X265_LIBRARY_DIR, OPENHEVC_INCLUDE_DIR, OpenHEVC_LIBRARY"-correctly in cmake configuration.
6666

67+
In the case of AV1 build, the AV1 codec is cmakefied. Once the OpenIGTLink_USE_AV1 option is selected, the openigtlink libray will superbuild the codec and link automatically.
6768
* Linux / Mac OS X
6869

6970
In the case of Linux and Mac, after installing the required program in the Prerequisites section,
@@ -84,7 +85,6 @@ $ make
8485
* Windows Build
8586

8687
In the case of windows build, please refer to the following websites for H264, X265 and VP9 respectively.
87-
Make sure the build are 32 bit.
8888
Useful H264 build instructions:
8989

9090
https://github.com/cisco/openh264
@@ -94,6 +94,11 @@ Useful VP9 build instructions:
9494
https://www.webmproject.org/code/build-prerequisites/
9595
http://wiki.webmproject.org/ffmpeg/building-with-libvpx
9696

97+
OpenIGTLink provides binary library files for visual studio 12 2013 and visual studio 14 2015.
98+
The libray will be automatically downloaded during the project build when user configure OpenIGTLink library using these cmake generators:
99+
"Visual Studio 12 2013", "Visual Studio 12 2013 Win64", "Visual Studio 14 2015" and "Visual Studio 14 2015 Win64".
100+
For the rest cmake generators, the user need to provide the VP9_INCLUDE_DIR and VP9_BINARY_DIR, otherwize the video streaming feature will be deactivated.
101+
97102
Useful X265 build intructions:
98103

99104
https://bitbucket.org/multicoreware/x265/wiki/CrossCompile

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ SET(OpenIGTLink_BUILD_EXAMPLES ${BUILD_EXAMPLES})
5757
OPTION(BUILD_TESTING "Build the testing tree." ON)
5858
OPTION(USE_GTEST "Use googletest for testing" ON)
5959
SET(OpenIGTLink_BUILD_TESTING ${BUILD_TESTING})
60-
SET(OpenIGTLink_USE_GTEST "0")
61-
IF(USE_GTEST)
62-
SET(OpenIGTLink_USE_GTEST "1")
60+
#link to google test library tend to fail https://github.com/openigtlink/OpenIGTLink/issues/122
61+
IF(OpenIGTLink_BUILD_SHARED_LIBS)
62+
SET(USE_GTEST OFF)
6363
ENDIF()
6464

6565
#-----------------------------------------------------------------------------
@@ -165,10 +165,10 @@ IF(CMAKE_USE_PTHREADS)
165165
ENDIF()
166166
ENDIF()
167167

168-
SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "0")
168+
OPTION(OpenIGTLink_ENABLE_VIDEOSTREAMING "Video stream feature activated." OFF)
169169
IF(${OpenIGTLink_PROTOCOL_VERSION} GREATER "2")
170170
IF (OpenIGTLink_USE_H264 OR OpenIGTLink_USE_VP9 OR OpenIGTLink_USE_X265 OR OpenIGTLink_USE_OpenHEVC OR OpenIGTLink_USE_AV1)
171-
SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "1")
171+
SET(OpenIGTLink_ENABLE_VIDEOSTREAMING ON)
172172
ENDIF()
173173
ENDIF()
174174
#-----------------------------------------------------------------------------

Examples/VideoStreaming/VideoServer.cxx

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int Width = 256;
4949
int Height = 256;
5050
std::string testFileName(OpenIGTLink_SOURCE_ROOTDIR);
5151
int startIndex = 0;
52-
int inputFrameNum = 500;
52+
int inputFrameNum = 2000;
5353

5454
void* ThreadFunction(void* ptr);
5555

@@ -103,11 +103,41 @@ int main(int argc, char* argv[])
103103
{
104104
std::cerr << "A client is connected." << std::endl;
105105
// Create a message buffer to receive header
106-
td.interval = 30;
106+
td.interval = 100;
107107
td.glock = glock;
108108
td.socket = socket;
109109
td.stop = 0;
110110
threadID = threader->SpawnThread((igtl::ThreadFunctionType) &ThreadFunction, &td);
111+
// Create a message buffer to receive header
112+
igtl::MessageHeader::Pointer headerMsg;
113+
headerMsg = igtl::MessageHeader::New();
114+
//------------------------------------------------------------
115+
// loop
116+
for (;;)
117+
{
118+
// Initialize receive buffer
119+
headerMsg->InitPack();
120+
121+
// Receive generic header from the socket
122+
int rs = socket->Receive(headerMsg->GetPackPointer(), headerMsg->GetPackSize());
123+
if (rs == 0)
124+
{
125+
if (threadID >= 0)
126+
{
127+
td.stop = 1;
128+
threader->TerminateThread(threadID);
129+
threadID = -1;
130+
}
131+
std::cerr << "Disconnecting the client." << std::endl;
132+
td.socket = NULL; // VERY IMPORTANT. Completely remove the instance.
133+
socket->CloseSocket();
134+
break;
135+
}
136+
if (rs != headerMsg->GetPackSize())
137+
{
138+
continue;
139+
}
140+
}
111141
}
112142
}
113143

@@ -141,6 +171,7 @@ void* ThreadFunction(void * ptr)
141171
VP9StreamEncoder->SetPicWidthAndHeight(Width,Height);
142172
VP9StreamEncoder->InitializeEncoder();
143173
VP9StreamEncoder->SetLosslessLink(true);
174+
VP9StreamEncoder->SetKeyFrameDistance(50);
144175
encoder = VP9StreamEncoder;
145176
#elif defined(OpenIGTLink_USE_AV1)
146177
igtlAV1Encoder* AV1StreamEncoder = new igtlAV1Encoder();
@@ -173,6 +204,10 @@ void* ThreadFunction(void * ptr)
173204
memset(pDecodedPic->data[0], 0, Width * Height * 3 / 2);
174205
for(int i = 0; i <inputFrameNum; i++)
175206
{
207+
if(td->stop)
208+
{
209+
break;
210+
}
176211
std::string sep = "/";
177212
#if defined(_WIN32) || defined(_WIN64)
178213
sep = "\\";

OpenIGTLinkConfig.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ SET(OpenIGTLink_USE_VP9 @OpenIGTLink_USE_VP9@)
4545
SET(OpenIGTLink_USE_X265 @OpenIGTLink_USE_X265@)
4646
SET(OpenIGTLink_USE_OpenHEVC @OpenIGTLink_USE_OpenHEVC@)
4747
SET(OpenIGTLink_USE_AV1 @OpenIGTLink_USE_AV1@)
48-
SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "@OpenIGTLink_ENABLE_VIDEOSTREAMING@")
48+
SET(OpenIGTLink_ENABLE_VIDEOSTREAMING @OpenIGTLink_ENABLE_VIDEOSTREAMING@)
4949
SET(OpenIGTLink_USE_WEBSOCKET @OpenIGTLink_USE_WEBSOCKET@)
5050

5151
# Path to CableSwig configuration used by OpenIGTLink.

Source/VideoStreaming/igtlVP9Decoder.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
#include "igtl_types.h"
3131
#include "igtlVideoMessage.h"
3232
#include "igtlCodecCommonClasses.h"
33-
#include "vpx/vpx_decoder.h"
33+
#include "vpx_decoder.h"
3434
#include "vpx_config.h"
35-
#include "vpx/vp8dx.h"
36-
#include "vpx/vpx_codec.h"
37-
#include "vpx/vpx_image.h"
38-
#include "vpx/vpx_integer.h"
35+
#include "vp8dx.h"
36+
#include "vpx_codec.h"
37+
#include "vpx_image.h"
38+
#include "vpx_integer.h"
3939

4040
namespace igtl {
4141

Source/VideoStreaming/igtlVP9Encoder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include <stdlib.h>
1818
#include <string.h>
1919

20-
#include "vpx/vp8cx.h"
21-
#include "vpx/vpx_image.h"
20+
#include "vp8cx.h"
21+
#include "vpx_image.h"
2222

2323
#include "igtlCodecCommonClasses.h"
2424
#include "igtl_header.h"

Source/VideoStreaming/igtlVideoStreaming.cmake

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ IF(OpenIGTLink_USE_H264)
4040
ENDIF()
4141
IF(OpenIGTLink_USE_VP9)
4242
INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_VP9.cmake)
43-
IF(EXISTS ${VP9_LIBRARY_DIR})
43+
IF((NOT "${VP9_LIBRARY_DIR}" STREQUAL "") AND (NOT "${VP9_INCLUDE_DIR}" STREQUAL ""))
4444
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
4545
${VP9_INCLUDE_DIR}
4646
)
@@ -52,11 +52,9 @@ IF(OpenIGTLink_USE_VP9)
5252
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVP9Decoder.h
5353
${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVP9Encoder.h
5454
)
55-
IF(NOT ${VP9_LIBRARY_DIR} EQUAL "")
56-
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
57-
"${VP9_LIBRARY_DIR}" )
58-
LINK_DIRECTORIES("${VP9_LIBRARY_DIR}/lib")
59-
ENDIF()
55+
LIST(APPEND OpenIGTLink_INCLUDE_DIRS
56+
${VP9_LIBRARY_DIR} )
57+
LINK_DIRECTORIES("${VP9_LIBRARY_DIR}/lib")
6058
ELSE()
6159
MESSAGE("VP9_INCLUDE_DIR or VP9_LIBRARY_DIR no found")
6260
ENDIF()
@@ -113,8 +111,14 @@ IF(WIN32) # for Windows
113111
ENDIF()
114112
IF(OpenIGTLink_USE_VP9)
115113
#To do, library name depends on the compiler setting, could be vpxmt.lib and vpxmtd also. Make sure the setting matches.
114+
#SET(VP9_lib optimized ${VP9_LIBRARY_DIR}\\Release\\vpxmd.lib debug ${VP9_LIBRARY_DIR}\\Debug\\vpxmdd.lib)
115+
if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
116+
SET(VP9_lib optimized ${VP9_LIBRARY_DIR}\\x64\\Release\\vpxmd.lib debug ${VP9_LIBRARY_DIR}\\x64\\Debug\\vpxmdd.lib)
117+
else()
118+
SET(VP9_lib optimized ${VP9_LIBRARY_DIR}\\Win32\\Release\\vpxmd.lib debug ${VP9_LIBRARY_DIR}\\Win32\\Debug\\vpxmdd.lib)
119+
endif()
116120
LIST(APPEND LINK_LIBS
117-
VP9_lib
121+
${VP9_lib}
118122
)
119123
ENDIF()
120124
IF(OpenIGTLink_USE_X265)

Source/igtlGeneralSocket.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
#include "igtlWin32Header.h"
4747
#include "igtl_types.h"
4848

49+
#if defined(_WIN32) && !defined(__CYGWIN__)
50+
#else
51+
#include <sys/time.h>
52+
#endif
53+
4954
#define IP4AddressStrLen 16
5055
#define IP6AddressStrLen 46
5156

Source/igtlMessageFactory.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PURPOSE. See the above copyright notices for more information.
3636
#include "igtlCommandMessage.h"
3737
#endif // OpenIGTLink_PROTOCOL_VERSION >= 3
3838

39-
#if OpenIGTLink_ENABLE_VIDEOSTREAMING
39+
#if defined(OpenIGTLink_ENABLE_VIDEOSTREAMING)
4040
#include "igtlVideoMessage.h"
4141
#endif
4242

@@ -92,7 +92,7 @@ MessageFactory::MessageFactory()
9292
this->AddMessageType("RTS_COMMAND", (PointerToMessageBaseNew)&igtl::RTSCommandMessage::New);
9393
#endif
9494

95-
#if OpenIGTLink_ENABLE_VIDEOSTREAMING
95+
#if defined(OpenIGTLink_ENABLE_VIDEOSTREAMING)
9696
this->AddMessageType("VIDEO", (PointerToMessageBaseNew)&igtl::VideoMessage::New);
9797
#endif
9898
}

Source/igtlMessageRTPWrapper.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
#include "igtlTimeStamp.h"
3131
#include "igtlOSUtil.h"
3232

33-
#if defined(WIN32) || defined(_WIN32)
34-
#include <windows.h>
35-
#else
36-
#include <sys/time.h>
37-
#endif
3833

3934
/// This number defines the maximum number for UDP packet buffering, to avoid overflow of the buffer, the first buffered packet will be
4035
#define PacketMaximumBufferNum 1000

0 commit comments

Comments
 (0)