diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj
index 767d89e79e13776c18d8164bef135613f13a164e..f8fe80329562bfbded5525bfdacdfc174bce7abe 100644
--- a/Workspace_msvc/decoder.vcxproj
+++ b/Workspace_msvc/decoder.vcxproj
@@ -14,7 +14,7 @@
decoder
{E3DCBC31-7FC9-D127-E000-529F8460D5FD}
decoder
- 10.0.17763.0
+ 10.0.19041.0
@@ -68,7 +68,7 @@
Disabled
- ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories)
+ ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;.\%(AdditionalIncludeDirectories)
_CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions)
EnableFastChecks
@@ -113,7 +113,7 @@
Neither
false
false
- ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories)
+ ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;.\%(AdditionalIncludeDirectories)
_CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions)
true
@@ -161,7 +161,7 @@
{869a305e-d99e-4c3a-bdb3-aa57abcce619}
-
+
{2fa8f384-0775-f3b7-f8c3-85209222fc70}
false
@@ -175,4 +175,4 @@
-
+
\ No newline at end of file
diff --git a/Workspace_msvc/encoder.vcxproj b/Workspace_msvc/encoder.vcxproj
index 122e3e4e09e73ab0f184cd5261d8b344475b97f9..03e4e7af1c4c67159a849ca9ad471daf258ddd2d 100644
--- a/Workspace_msvc/encoder.vcxproj
+++ b/Workspace_msvc/encoder.vcxproj
@@ -14,7 +14,7 @@
encoder
{B3FC9DFC-7268-8660-7C0D-B60BAF02C554}
encoder
- 10.0.17763.0
+ 10.0.19041.0
@@ -177,4 +177,4 @@
-
+
\ No newline at end of file
diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj
index 170ff20545a4ac5c7d610daac49ba963ad4d88b4..e44bc448a45bbba3790f8821a62d1b1863c25965 100644
--- a/Workspace_msvc/isar_post_rend.vcxproj
+++ b/Workspace_msvc/isar_post_rend.vcxproj
@@ -14,7 +14,7 @@
isar_post_rend
{12374ADC-0E5C-4FDD-B903-71D572413831}
isar_post_rend
- 10.0.17763.0
+ 10.0.19041.0
diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj
index 82a59ab688b85492ac1d01c135d04acf5f862733..949a27def04474859c2a3bcc15d798634600c94e 100644
--- a/Workspace_msvc/lib_com.vcxproj
+++ b/Workspace_msvc/lib_com.vcxproj
@@ -13,7 +13,7 @@
{39EC200D-7795-4FF8-B214-B24EDA5526AE}
common
- 10.0.17763.0
+ 10.0.19041.0
@@ -344,4 +344,4 @@
-
+
\ No newline at end of file
diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters
index 3fbbb7bc58487f8e7a82723afd2e11ff344f323e..bc88593d98e4ed7335b2a7537ab7687e6192ec8b 100644
--- a/Workspace_msvc/lib_com.vcxproj.filters
+++ b/Workspace_msvc/lib_com.vcxproj.filters
@@ -184,9 +184,6 @@
common_all_c
-
- common_all_c
-
common_all_c
diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj
index e52c492f7643344e7910f2eb05488e99e4ade582..0f66f33956b5204b839c27224eb0072aae85b004 100644
--- a/Workspace_msvc/lib_debug.vcxproj
+++ b/Workspace_msvc/lib_debug.vcxproj
@@ -13,7 +13,7 @@
{54509728-928B-44D9-A118-A6F92F08B34F}
debug
- 10.0.17763.0
+ 10.0.19041.0
@@ -120,4 +120,4 @@
-
+
\ No newline at end of file
diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj
index f18efbed4952b8d816016d9ba4431a2349ccd65d..17e192f73e2552135e6cfd831ef937a6f39629ff 100644
--- a/Workspace_msvc/lib_dec.vcxproj
+++ b/Workspace_msvc/lib_dec.vcxproj
@@ -14,7 +14,7 @@
lib_dec
{E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}
evs_dec
- 10.0.17763.0
+ 10.0.19041.0
StaticLibrary
@@ -350,4 +350,4 @@
-
+
\ No newline at end of file
diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj
index 3115070740a00f7552314f7b323f3df91760eecb..56c698679a6027de0f510dca4b746a3e1e138fb6 100644
--- a/Workspace_msvc/lib_enc.vcxproj
+++ b/Workspace_msvc/lib_enc.vcxproj
@@ -14,7 +14,7 @@
lib_enc
{824DA4CF-06F0-45C9-929A-8792F0E19C3E}
evs_enc
- 10.0.17763.0
+ 10.0.19041.0
@@ -370,4 +370,4 @@
-
+
\ No newline at end of file
diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj
index 95f64b54fd3e510cb3c45c9f40f2fc733572e77f..35e4eae2ea40aeae021bdb4d8cbf44476843662c 100644
--- a/Workspace_msvc/lib_isar.vcxproj
+++ b/Workspace_msvc/lib_isar.vcxproj
@@ -14,7 +14,7 @@
lib_isar
{869A305E-D99E-4C3A-BDB3-AA57ABCCE619}
isar
- 10.0.17763.0
+ 10.0.19041.0
@@ -182,4 +182,4 @@
-
+
\ No newline at end of file
diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj
index 22b5cddd3c55c39f43af6dfa39ec652305880ff2..1dcc70d25a182b1ee8a9d8b64c5ec89a35089829 100644
--- a/Workspace_msvc/lib_lc3plus.vcxproj
+++ b/Workspace_msvc/lib_lc3plus.vcxproj
@@ -22,7 +22,7 @@
{95030B82-70CD-4C6B-84D4-61096035BEA2}
Win32Proj
LC3_FL
- 10.0.17763.0
+ 10.0.19041.0
diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj
index ff8946cc05ad785f675a2bdac42b09dae55d0665..3c97e41c096ff484b3b211f1b245ab236208e408 100644
--- a/Workspace_msvc/lib_rend.vcxproj
+++ b/Workspace_msvc/lib_rend.vcxproj
@@ -14,7 +14,7 @@
lib_rend
{718DE063-A18B-BB72-9150-62B892E6FFA6}
evs_dec
- 10.0.17763.0
+ 10.0.19041.0
StaticLibrary
@@ -199,7 +199,7 @@
{95030B82-70CD-4C6B-84D4-61096035BEA2}
false
-
+
@@ -209,4 +209,4 @@
-
+
\ No newline at end of file
diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters
index 820a5c044354c8b35ceabc1855256052b4915b24..2494e2ee2e8a44233535a78999c15448adf0ce04 100644
--- a/Workspace_msvc/lib_rend.vcxproj.filters
+++ b/Workspace_msvc/lib_rend.vcxproj.filters
@@ -31,9 +31,6 @@
rend_c
-
- rend_c
-
rend_c
diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj
index b6b7fedfa8984c43465af1b5b317a84a2118dd67..d773da5c0393fb4d04b24d36a0c520ac699f835e 100644
--- a/Workspace_msvc/lib_util.vcxproj
+++ b/Workspace_msvc/lib_util.vcxproj
@@ -13,7 +13,7 @@
{2FA8F384-0775-F3B7-F8C3-85209222FC70}
utility
- 10.0.17763.0
+ 10.0.19041.0
@@ -123,7 +123,8 @@
-
+
+
@@ -150,7 +151,8 @@
-
+
+
@@ -160,4 +162,4 @@
-
+
\ No newline at end of file
diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj
index a88ac29a52af6e031458cd3defb30206cf0d4f29..e930db5eda7ad265c666bf3e089c159dd73425a2 100644
--- a/Workspace_msvc/renderer.vcxproj
+++ b/Workspace_msvc/renderer.vcxproj
@@ -14,7 +14,7 @@
renderer
{12B4C8A5-1E06-4E30-B443-D1F916F52B47}
renderer
- 10.0.17763.0
+ 10.0.19041.0
@@ -160,7 +160,7 @@
{869a305e-d99e-4c3a-bdb3-aa57abcce619}
-
+
{2FA8F384-0775-F3B7-F8C3-85209222FC70}
false
@@ -182,4 +182,4 @@
-
+
\ No newline at end of file
diff --git a/apps/decoder.c b/apps/decoder.c
index a4424c92c59210f10c511792c2fdba0ecdc27da1..6de0df33ba67f830c6bd5cf0d1e85b02a7c0d5b5 100644
--- a/apps/decoder.c
+++ b/apps/decoder.c
@@ -32,6 +32,7 @@
#include "lib_dec.h"
#include
+#include
#include "cmdl_tools.h"
#include "audio_file_writer.h"
#include "bitstream_reader.h"
@@ -43,11 +44,17 @@
#include "masa_file_writer.h"
#include "render_config_reader.h"
#include "rotation_file_reader.h"
+#include "common_api_types.h"
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+#include "socket_comm.h"
+#include "ivas_error_utils.h"
+#endif
#include "split_render_file_read_write.h"
#include "vector3_pair_file_reader.h"
#include "wmc_auto.h"
#include "options.h"
#include "stl.h"
+#include "cnst.h"
#define WMC_TOOL_SKIP
@@ -102,6 +109,10 @@ typedef struct
bool voipMode;
bool enableHeadRotation;
char *headrotTrajFileName;
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ bool enableHeadrotTrajSocket;
+ uint16_t socketPort;
+#endif
bool enableReferenceRotation;
char *refrotTrajFileName;
bool enableReferenceVectorTracking;
@@ -135,16 +146,22 @@ typedef struct
} DecArguments;
-
/*------------------------------------------------------------------------------------------*
* Local functions prototypes
*------------------------------------------------------------------------------------------*/
static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+static ivas_error parseQuaternionData( char *rxBuffer, IVAS_QUATERNION *pQuaternion );
+#endif
static void usage_dec( void );
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, unsigned int hSocket, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
+static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, unsigned int hSocket, IVAS_DEC_HANDLE hIvasDec );
+#else
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec );
-
+#endif
/*------------------------------------------------------------------------------------------*
* main()
@@ -177,6 +194,9 @@ int main(
IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL;
IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL;
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ uint32_t hSocket = (uint32_t) NULL;
+#endif
#ifdef WMOPS
reset_wmops();
@@ -258,7 +278,6 @@ int main(
fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" );
goto cleanup;
}
-
if ( ( error = hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) ) != IVAS_ERR_OK )
{
arg.hrtfReaderEnabled = false;
@@ -276,15 +295,39 @@ int main(
/* sanity check */
if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
{
+
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ fprintf( stderr, "\nError: Head-rotation cannot be used in this output configuration.\n\n" );
+#else
fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" );
+#endif
goto cleanup;
}
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ if ( arg.enableHeadrotTrajSocket )
+ {
+ if ( ( error = SocketComm_start( &hSocket, arg.socketPort ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError: Can't start socket communication \n\n" );
+ goto cleanup;
+ }
+ }
+ else
+ {
+ if ( ( error = RotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError: Can't open head-rotation file %s \n\n", arg.headrotTrajFileName );
+ goto cleanup;
+ }
+ }
+#else
if ( ( error = RotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError: Can't open head-rotation file %s \n\n", arg.headrotTrajFileName );
goto cleanup;
}
+#endif
}
/*------------------------------------------------------------------------------------------*
@@ -440,7 +483,7 @@ int main(
* Load renderer configuration from file
*--------------------------------------------------------------------*/
- if ( arg.renderConfigEnabled )
+ if ( arg.renderConfigEnabled )
{
IVAS_RENDER_CONFIG_DATA renderConfig;
@@ -681,11 +724,20 @@ int main(
if ( arg.voipMode )
{
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hSocket, hIvasDec );
+#else
error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec );
+#endif
}
else
{
+
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hSocket, &splitRendBits, hIvasDec, pcmBuf );
+#else
error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf );
+#endif
}
if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE )
@@ -752,6 +804,13 @@ cleanup:
Vector3PairFileReader_close( &referenceVectorReader );
RenderConfigReader_close( &renderConfigReader );
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ if ( arg.enableHeadrotTrajSocket )
+ {
+ SocketComm_close( hSocket );
+ }
+#endif
+
if ( BS_Reader_Close( &hBsReader ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError while closing file: %s\nContinuing...\n\n", arg.inputBitstreamFilename );
@@ -885,9 +944,15 @@ static bool parseCmdlIVAS_dec(
arg->enableHeadRotation = false;
arg->headrotTrajFileName = NULL;
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ arg->enableHeadrotTrajSocket = false;
+ arg->socketPort = 0;
+#endif
arg->orientation_tracking = ORIENT_TRK_NONE;
arg->enableReferenceRotation = false;
+#ifndef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
arg->headrotTrajFileName = NULL;
+#endif
arg->enableReferenceVectorTracking = false;
arg->referenceVectorTrajFileName = NULL;
arg->enableExternalOrientation = false;
@@ -1024,6 +1089,14 @@ static bool parseCmdlIVAS_dec(
}
else if ( strcmp( argv_to_upper, "-T" ) == 0 )
{
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ if ( arg->enableHeadRotation )
+ {
+ fprintf( stderr, "Error: Head rotation file and socket communication cannot be used together!\n\n" );
+ usage_dec();
+ return false;
+ }
+#endif
arg->enableHeadRotation = true;
i++;
@@ -1037,6 +1110,38 @@ static bool parseCmdlIVAS_dec(
arg->headrotTrajFileName = argv[i];
i++;
}
+
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ else if ( strcmp( argv_to_upper, "-SOCKET" ) == 0 )
+ {
+ if ( arg->enableHeadRotation )
+ {
+ fprintf( stderr, "Error: Head rotation file and socket communication cannot be used together!\n\n" );
+ usage_dec();
+ return false;
+ }
+
+ arg->enableHeadRotation = true;
+ arg->enableHeadrotTrajSocket = true;
+ i++;
+
+ if ( argc - i <= 4 || argv[i][0] == '-' )
+ {
+ fprintf( stderr, "Error: Socket port not specified!\n\n" );
+ usage_dec();
+ return false;
+ }
+
+ arg->socketPort = (int16_t) atoi( argv[i++] );
+
+ if ( arg->socketPort < SOCKET_PORT_MIN || arg->socketPort > SOCKET_PORT_MAX )
+ {
+ fprintf( stderr, "Error: Only ports in the range of %d-%d can be used!\n\n", SOCKET_PORT_MIN, SOCKET_PORT_MAX );
+ usage_dec();
+ return false;
+ }
+ }
+#endif
else if ( strcmp( argv_to_upper, "-FR" ) == 0 )
{
int32_t tmp;
@@ -1479,6 +1584,46 @@ static bool parseCmdlIVAS_dec(
return true;
}
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+/*-----------------------------------------------------------------------*
+ * parseQuaternionData()
+ *
+ * Parse Quaternion Data
+ *-----------------------------------------------------------------------*/
+
+static ivas_error parseQuaternionData(
+ char *rxBuffer, /* i : data buffer */
+ IVAS_QUATERNION *pQuaternion /* o : head-tracking data */
+)
+{
+ float w, x, y, z;
+ size_t charsConsumed;
+ const char *messageHeader = "IVAS buffer request";
+ const int32_t read_values = sscanf( rxBuffer, "%*[^:]%n: %f, %f, %f, %f", &charsConsumed, &w, &x, &y, &z );
+
+ if ( read_values == 4 && charsConsumed == strlen( messageHeader ) && strncmp( rxBuffer, messageHeader, charsConsumed ) == 0 )
+ {
+ {
+ /* Recieved values can be seen in console */
+ printf( "[rotation: w=%+.2f, x=%+.2f, y=%+.2f, z=%+.2f]\n", w, x, y, z );
+
+ //Quaternion data is in float. Convert this to fixed point in Q22 format and set the Qformat of quaternion to 22.
+ pQuaternion->w_fx = w * ONE_IN_Q22;
+ pQuaternion->x_fx = x * ONE_IN_Q22;
+ pQuaternion->y_fx = y * ONE_IN_Q22;
+ pQuaternion->z_fx = z * ONE_IN_Q22;
+ // Q-factor of IVAS quaternion?? can we set it to Q0? set to 22 later
+ pQuaternion->q_fact = 22;
+ }
+ }
+ else
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL, "Quaternion Parser: parsing error." );
+ }
+
+ return IVAS_ERR_OK;
+}
+#endif
/*---------------------------------------------------------------------*
* usage_dec()
@@ -1527,6 +1672,10 @@ static void usage_dec( void )
fprintf( stdout, " default bitstream file format is G.192\n" );
fprintf( stdout, "-hrtf File : HRTF filter File used in BINAURAL output configuration\n" );
fprintf( stdout, "-T File : Head rotation specified by external trajectory File\n" );
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ fprintf( stdout, "-socket port : Socket communication for pose input and audio output\n" );
+ fprintf( stdout, " port = 49152-65535 (range of dynamic, private or ephemeral ports\n" );
+#endif
fprintf( stdout, "-otr tracking_type : Head orientation tracking type: 'none', 'ref', 'avg', 'ref_vec' \n" );
fprintf( stdout, " or 'ref_vec_lev' (only for binaural rendering)\n" );
fprintf( stdout, "-rf File : Reference rotation specified by external trajectory File\n" );
@@ -1864,6 +2013,9 @@ static ivas_error decodeG192(
RotFileReader *externalOrientationFileReader,
RotFileReader *refRotReader,
Vector3PairFileReader *referenceVectorReader,
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ uint32_t hSocket,
+#endif
ISAR_SPLIT_REND_BITS_DATA *splitRendBits,
IVAS_DEC_HANDLE hIvasDec,
int16_t *pcmBuf )
@@ -1908,6 +2060,10 @@ static ivas_error decodeG192(
return error;
}
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ char rxBuffer[SOCKET_BUFFER_SIZE];
+#endif
+
if ( arg.renderConfigEnabled )
{
if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK )
@@ -2024,7 +2180,11 @@ static ivas_error decodeG192(
{
IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ if ( headRotReader == NULL && !arg.enableHeadrotTrajSocket )
+#else
if ( headRotReader == NULL )
+#endif
{
for ( i = 0; i < num_subframes; i++ )
{
@@ -2043,11 +2203,42 @@ static ivas_error decodeG192(
{
for ( i = 0; i < num_subframes; i++ )
{
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ if ( arg.enableHeadrotTrajSocket )
+ {
+ if ( i % num_subframes != 0 )
+ {
+ Quaternions[i] = Quaternions[0];
+ continue;
+ }
+
+ if ( ( error = SocketComm_recv( hSocket, rxBuffer ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while receiving head orientation\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+
+ if ( ( error = parseQuaternionData( rxBuffer, &Quaternions[i] ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while parsing head orientation\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+ else
+ {
+ if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) );
+ goto cleanup;
+ }
+ }
+#else
if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) );
goto cleanup;
}
+#endif
}
}
@@ -2128,6 +2319,22 @@ static ivas_error decodeG192(
{
if ( error == IVAS_ERR_END_OF_FILE )
{
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ /* Rewind the input bitstream at the end of file in case of socket communication */
+ if ( arg.enableHeadrotTrajSocket )
+ {
+ if ( ( error = BS_Reader_Rewind( hBsReader ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError: unable to rewind input bitstream file: %s \n\n", arg.inputBitstreamFilename );
+ goto cleanup;
+ }
+ if ( ( error = BS_Reader_ReadFrame_short( hBsReader, bit_stream, &num_bits, &bfi ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError: input bitstream file couldn't be read: %s \n\n", arg.inputBitstreamFilename );
+ goto cleanup;
+ }
+ }
+#endif
break;
}
fprintf( stderr, "\nError: input bitstream file couldn't be read: %s \n\n", arg.inputBitstreamFilename );
@@ -2220,6 +2427,16 @@ static ivas_error decodeG192(
{
if ( delayNumSamples < nOutSamples )
{
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ if ( arg.enableHeadrotTrajSocket )
+ {
+ if ( ( error = SocketComm_send( hSocket, (char *) &pcmBuf[delayNumSamples * nOutChannels], ( nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) * ( sizeof( *pcmBuf ) / sizeof( char ) ) ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while sending audio buffer\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+#endif
if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nOutput audio file writer error\n" );
@@ -2539,6 +2756,9 @@ static ivas_error decodeVoIP(
RotFileReader *externalOrientationFileReader,
RotFileReader *refRotReader,
Vector3PairFileReader *referenceVectorReader,
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ uint32_t hSocket,
+#endif
IVAS_DEC_HANDLE hIvasDec )
{
bool decodingFailed = true; /* Assume failure until cleanup is reached without errors */
@@ -2585,6 +2805,9 @@ static ivas_error decodeVoIP(
int16_t vec_pos_update, vec_pos_len;
int16_t nOutSamples = 0;
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ char rxBuffer[SOCKET_BUFFER_SIZE];
+#endif
vec_pos_update = 0;
if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK )
{
@@ -2748,7 +2971,11 @@ static ivas_error decodeVoIP(
{
IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ if ( headRotReader == NULL && !arg.enableHeadrotTrajSocket )
+#else
if ( headRotReader == NULL )
+#endif
{
for ( i = 0; i < num_subframes; i++ )
{
@@ -2767,11 +2994,43 @@ static ivas_error decodeVoIP(
{
for ( i = 0; i < num_subframes; i++ )
{
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ if ( arg.enableHeadrotTrajSocket )
+ {
+ if ( i % num_subframes != 0 )
+ {
+ Quaternions[i] = Quaternions[0];
+ continue;
+ }
+
+ if ( ( error = SocketComm_recv( hSocket, rxBuffer ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while receiving head orientation\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+
+ if ( ( error = parseQuaternionData( rxBuffer, &Quaternions[i] ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while parsing head orientation\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+ else
+ {
+ if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ),
+ RotationFileReader_getFilePath( headRotReader ) );
+ goto cleanup;
+ }
+ }
+#else
if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) );
goto cleanup;
}
+#endif
}
}
@@ -2923,6 +3182,16 @@ static ivas_error decodeVoIP(
{
if ( delayNumSamples < nOutSamples )
{
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ if ( arg.enableHeadrotTrajSocket )
+ {
+ if ( ( error = SocketComm_send( hSocket, (char *) &pcmBuf[delayNumSamples * nOutChannels], ( nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) * ( sizeof( *pcmBuf ) / sizeof( char ) ) ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while sending audio buffer\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+#endif
if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nOutput audio file writer error\n" );
diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h
index cc3e4cd12ac3bf89137aaee13adf383222781622..909d9faaee4868cac8ee2b8c42f0f39021d0f810 100644
--- a/lib_com/ivas_error.h
+++ b/lib_com/ivas_error.h
@@ -126,6 +126,17 @@ typedef enum
IVAS_ERR_NO_FILE_OPEN,
IVAS_ERR_SAMPLING_RATE_UNKNOWN,
+
+#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
+ /*----------------------------------------*
+ * socket errors (lib_util only) *
+ *----------------------------------------*/
+ IVAS_ERR_SOCKET_RECEIVE_FAILED,
+ IVAS_ERR_SOCKET_SEND_FAILED,
+ IVAS_ERR_SOCKET_TIMEOUT,
+#endif
+
+
/*----------------------------------------*
* renderer (lib_rend only) *
*----------------------------------------*/
diff --git a/lib_com/options.h b/lib_com/options.h
index 9765329e56ad40a1bfa16352294d7a7878e48c36..5ccf9516dfa680ee9fa342c77e3c292e2e1e36eb 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -41,7 +41,7 @@
/* ################### Start DEBUGGING switches ######################## */
-/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */
+#define DEBUGGING /* Allows debugging message to be printed out during runtime */
#ifdef DEBUGGING
/*#define DBG_BITSTREAM_ANALYSIS*/ /* Write bitstream with annotations to a text file */
#define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */
@@ -71,6 +71,10 @@
#define BASOP_NOGLOB_DECLARE_LOCAL
#endif
+#ifdef _MSC_VER
+#define SOCKET_INTERFACE_FOR_POSE_AND_AUDIO /* Philips: Socket interface for head rotation - Windows only*/
+#endif
+
/* Note: each compile switch (FIX_1101_...) is independent from the other ones */
#define FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 2166 */
diff --git a/lib_util/bitstream_reader.c b/lib_util/bitstream_reader.c
index 2bd6f46aa6014e8e37f1c77bd051d49eabb47da4..576ffbeded7e8e89848fbc04f2bcb56622ee2614 100644
--- a/lib_util/bitstream_reader.c
+++ b/lib_util/bitstream_reader.c
@@ -263,6 +263,22 @@ cleanup:
return error;
}
+#if defined( SOCKET_INTERFACE_FOR_POSE_AND_AUDIO ) || defined( DEBUGGING )
+ivas_error BS_Reader_Rewind( BS_READER_HANDLE hBsReader )
+{
+ if ( hBsReader == NULL )
+ {
+ return IVAS_ERR_UNEXPECTED_NULL_POINTER;
+ }
+
+ if ( hBsReader->rewind == NULL )
+ {
+ return IVAS_ERR_NOT_IMPLEMENTED;
+ }
+
+ return hBsReader->rewind( hBsReader->hFormatReader );
+}
+#endif
ivas_error BS_Reader_ReadFrame_short( BS_READER_HANDLE hBsReader, uint16_t *serial, int16_t *num_bits, int16_t *bfi )
{
diff --git a/lib_util/bitstream_reader.h b/lib_util/bitstream_reader.h
index fb6f9f9b9dac7304cd1bf029cdf2c2822991f62c..9f8c2303e13f5c9c6d9d523625ef5b036c68f1bd 100644
--- a/lib_util/bitstream_reader.h
+++ b/lib_util/bitstream_reader.h
@@ -58,6 +58,9 @@ typedef struct BS_Reader *BS_READER_HANDLE;
ivas_error BS_Reader_Open_filename( BS_READER_HANDLE *phBsReader, const char *filename, BS_READER_FORMAT format );
+#if defined( SOCKET_INTERFACE_FOR_POSE_AND_AUDIO ) || defined( DEBUGGING )
+ivas_error BS_Reader_Rewind( BS_READER_HANDLE hBsReader );
+#endif
ivas_error BS_Reader_ReadFrame_short( BS_READER_HANDLE hBsReader, uint16_t *serial, int16_t *num_bits, int16_t *bfi );