Commit 34a235dc authored by multrus's avatar multrus
Browse files

[cleanup] accept USE_RTPDUMP

parent 0915f5db
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -114,7 +114,6 @@
#define FIX_2500_RENDCONF_REFACTOR                      /* Eri: Basop issue #2500: Renderer configuration range check before conversion to fixed point. Harmonize between BASOP/float */
#define FIX_BASOP_2023_TDREND_DISTATT_PRECISION         /* Eri: Basop issue 2023: Distance attenuation scaling, adding clamping of distance att input and listener position */
#define FIX_BASOP_2023_TDREND_DISTATT_PRECISION_BUGFIX  /* Eri: Bug discovered in cleanup of basop issue 2023 */
#define USE_RTPDUMP                                     /* FhG: RTPDUMP format (rtptools standard) instead of custom format */
#define FIX_FLOAT_1569_REND_RENDER_CONFIG_CHECKS        /* Nokia: float issue 1569: fix render config checks in renderer */
#define FIX_BASOP_2526_SPAR_MASA_PARAM_MAP_Q_BUG        /* Nokia: BASOP issue 2526: Fix wrong Q variable in SPAR to MASA param mapping */
#define FIX_BASOP_2524_MASA_REDUCE_META_BUG             /* Nokia: BASOP issue 2524: Fix wrong reset of W_tmp in reduce_metadata_further_fx */
+0 −52
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@

#define Q15 15

#ifdef USE_RTPDUMP
#include "rtpdump.h"

struct IVAS_RTP_FILE
@@ -49,14 +48,6 @@ struct IVAS_RTP_FILE
    uint32_t offset_ms;
};

#else  // USE_RTPDUMP

struct IVAS_RTP_FILE
{
    bool isFileWriter;
    FILE *f_rtpstream;
};
#endif // USE_RTPDUMP

static ivas_error IvasRtpFile_Open(
    const char *filePath,           /* i : path to CA config file                */
@@ -64,7 +55,6 @@ static ivas_error IvasRtpFile_Open(
    IVAS_RTP_FILE_HANDLE *phRtpFile /* o : pointer to an IVAS file reader handle */
)
{
#ifdef USE_RTPDUMP
    RTPDUMP_HANDLE f_rtpstream;
    RTPDUMP_ERROR rderr;
    if ( isFileWriter )
@@ -79,14 +69,6 @@ static ivas_error IvasRtpFile_Open(
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_FILE_OPEN, "rtpdump open error %d", rderr );
    }
#else  // USE_RTPDUMP
    const char *mode = isFileWriter ? "wb" : "rb";
    FILE *f_rtpstream = fopen( filePath, mode );
    if ( f_rtpstream == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_FILE_OPEN, "could not open: %s\n", filePath );
    }
#endif // USE_RTPDUMP

    *phRtpFile = calloc( 1, sizeof( struct IVAS_RTP_FILE ) );
    if ( *phRtpFile != NULL )
@@ -106,11 +88,7 @@ static ivas_error IvasRtpFile_Close(
    {
        if ( ( *phReader )->f_rtpstream != NULL )
        {
#ifdef USE_RTPDUMP
            RTPDUMP_Close( &( *phReader )->f_rtpstream, 1 );
#else  // USE_RTPDUMP
            fclose( ( *phReader )->f_rtpstream );
#endif // USE_RTPDUMP
            ( *phReader )->f_rtpstream = NULL;
        }
        free( *phReader );
@@ -128,7 +106,6 @@ static ivas_error IvasRtpFile_Write(
    ivas_error error = IVAS_ERR_OK;
    if ( hRtpFile->isFileWriter )
    {
#ifdef USE_RTPDUMP
        RTPDUMP_RTPPACKET pkt;
        RTPDUMP_SetDefaultRtpPacketHeader( &pkt );
        numBytes = ( numBytes > sizeof( pkt.data ) ) ? sizeof( pkt.data ) : numBytes;
@@ -137,11 +114,6 @@ static ivas_error IvasRtpFile_Write(
        pkt.payloadSize = (unsigned short) ( numBytes - pkt.headerSize );
        /* compute time offset in ms from RTP timestamp (16kHz clock) */
        error = ( RTPDUMP_WritePacket( hRtpFile->f_rtpstream, &pkt, pkt.timeStamp / 16 ) != RTPDUMP_NO_ERROR ) ? IVAS_ERR_FAILED_FILE_WRITE : IVAS_ERR_OK;
#else  // USE_RTPDUMP
        uint32_t length = (uint32_t) numBytes; /* Max packet length is < 32 bits*/
        fwrite( &length, sizeof( uint32_t ), 1, hRtpFile->f_rtpstream );
        fwrite( packet, sizeof( uint8_t ), numBytes, hRtpFile->f_rtpstream );
#endif // USE_RTPDUMP
    }
    else
    {
@@ -158,15 +130,11 @@ static ivas_error IvasRtpFile_Read(
)
{
    size_t nread = 0;
#ifndef USE_RTPDUMP
    uint32_t length = 0;
#endif // USE_RTPDUMP
    if ( hRtpFile->isFileWriter )
    {
        return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "File open for writing cannot be read" );
    }

#ifdef USE_RTPDUMP
    RTPDUMP_RTPPACKET pd;
    RTPDUMP_ERROR rderr = RTPDUMP_ReadPacket( hRtpFile->f_rtpstream, &pd, &hRtpFile->offset_ms );
    if ( rderr == RTPDUMP_READ_ENDOFFILE )
@@ -186,26 +154,6 @@ static ivas_error IvasRtpFile_Read(
    }
    memcpy( packet, pd.data, nread );
    *numBytes = nread;
#else  // USE_RTPDUMP
    nread = fread( &length, sizeof( uint32_t ), 1, hRtpFile->f_rtpstream ); /* Read Packet Length */
    if ( nread == 0 )
    {
        return IVAS_ERR_END_OF_FILE;
    }

    *numBytes = length;
    if ( ( *numBytes ) > capacity )
    {
        fprintf( stderr, "RTP packet > buffer capacity %lu bytes\n", capacity );
        return IVAS_ERR_INVALID_OUTPUT_BUFFER_SIZE;
    }

    nread = fread( packet, sizeof( uint8_t ), ( *numBytes ), hRtpFile->f_rtpstream ); /* Read Packet */
    if ( nread < ( *numBytes ) )
    {
        return IVAS_ERR_END_OF_FILE;
    }
#endif // USE_RTPDUMP

    return IVAS_ERR_OK;
}
+0 −4
Original line number Diff line number Diff line
@@ -318,11 +318,7 @@ static bool readByte( FILE *file, uint8_t *value )
static bool readLong( FILE *file, uint16_t *value )
{
    char buffer[4] = { 0 };
#ifdef USE_RTPDUMP
    if ( fread( buffer, 1, 4, file ) != 4U )
#else
    if ( fread( buffer, 1, 4, file ) != 1U )
#endif
    {
        return false;
    }
+0 −2
Original line number Diff line number Diff line
@@ -281,7 +281,6 @@ RTPDUMP_OpenForWriting( RTPDUMP_HANDLE *phRTPDUMP, const char *filename )
    return RTPDUMP_NO_ERROR;
}

#ifdef USE_RTPDUMP
RTPDUMP_ERROR
RTPDUMP_SetHeaderInfo( RTPDUMP_HANDLE hRTPDUMP,
                       uint32_t source,
@@ -352,7 +351,6 @@ RTPDUMP_GetHeaderInfo( RTPDUMP_HANDLE hRTPDUMP,

    return RTPDUMP_NO_ERROR;
}
#endif

RTPDUMP_ERROR
RTPDUMP_ReadPacket( RTPDUMP_HANDLE hRTPDUMP,
+0 −2
Original line number Diff line number Diff line
@@ -85,7 +85,6 @@ extern "C"
    RTPDUMP_ERROR
    RTPDUMP_OpenForWriting( RTPDUMP_HANDLE *phRTPDUMP, const char *filename );

#ifdef USE_RTPDUMP
    RTPDUMP_ERROR
    RTPDUMP_SetHeaderInfo( RTPDUMP_HANDLE hRTPDUMP,
                           uint32_t source,
@@ -99,7 +98,6 @@ extern "C"
                           uint16_t *port,
                           uint32_t *startSeconds,
                           uint32_t *startMicroSeconds );
#endif

    RTPDUMP_ERROR
    RTPDUMP_ReadPacket( RTPDUMP_HANDLE hRTPDUMP,