Fixing Release compilation errors

Review URL: http://webrtc-codereview.appspot.com/267026

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1000 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
kjellander@webrtc.org
2011-11-23 12:20:35 +00:00
parent 89ab652250
commit 543c3eaa46
38 changed files with 221 additions and 171 deletions

View File

@@ -42,7 +42,7 @@ int readframe(WebRtc_Word16 *data, FILE *inp, int length) {
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
char inname[80], outname[40], bitname[40]; char inname[80], outname[40], bitname[40];
FILE *inp, *outp, *bitp; FILE *inp, *outp, *bitp = NULL;
int framecnt, endfile; int framecnt, endfile;
WebRtc_Word16 framelength = 80; WebRtc_Word16 framelength = 80;

View File

@@ -56,7 +56,7 @@ int main(int argc, char* argv[])
/* Runtime statistics */ /* Runtime statistics */
double starttime; double starttime;
double runtime; double runtime = 0;
double length_file; double length_file;
WebRtc_Word16 stream_len = 0; WebRtc_Word16 stream_len = 0;

View File

@@ -101,13 +101,13 @@ int main(int argc, char* argv[])
WebRtc_Word16 CodingMode; WebRtc_Word16 CodingMode;
WebRtc_Word16 bottleneck; WebRtc_Word16 bottleneck;
WebRtc_Word16 framesize = 30; /* ms */ WebRtc_Word16 framesize = 30; /* ms */
int cur_framesmpls, err, lostPackets = 0; int cur_framesmpls, err = 0, lostPackets = 0;
/* Runtime statistics */ /* Runtime statistics */
double starttime, runtime, length_file; double starttime, runtime, length_file;
WebRtc_Word16 stream_len = 0; WebRtc_Word16 stream_len = 0;
WebRtc_Word16 framecnt, declen; WebRtc_Word16 framecnt, declen = 0;
WebRtc_Word16 shortdata[FRAMESAMPLES_10ms]; WebRtc_Word16 shortdata[FRAMESAMPLES_10ms];
WebRtc_Word16 decoded[MAX_FRAMESAMPLES]; WebRtc_Word16 decoded[MAX_FRAMESAMPLES];
WebRtc_UWord16 streamdata[500]; WebRtc_UWord16 streamdata[500];
@@ -119,7 +119,7 @@ int main(int argc, char* argv[])
WebRtc_Word32 payloadRate = 0; WebRtc_Word32 payloadRate = 0;
int setControlBWE = 0; int setControlBWE = 0;
int readLoss; int readLoss;
FILE *plFile; FILE *plFile = NULL;
char version_number[20]; char version_number[20];
char tmpBit[5] = ".bit"; char tmpBit[5] = ".bit";
@@ -396,7 +396,9 @@ int main(int argc, char* argv[])
if (fscanf(f_bn, "%d", &aux_var) == EOF) { if (fscanf(f_bn, "%d", &aux_var) == EOF) {
/* Set pointer to beginning of file */ /* Set pointer to beginning of file */
fseek(f_bn, 0L, SEEK_SET); fseek(f_bn, 0L, SEEK_SET);
fscanf(f_bn, "%d", &aux_var); if (fscanf(f_bn, "%d", &aux_var) == EOF) {
exit(0);
}
} }
bottleneck = (WebRtc_Word16)aux_var; bottleneck = (WebRtc_Word16)aux_var;
/* Bottleneck is a cosine function /* Bottleneck is a cosine function
@@ -640,7 +642,9 @@ int main(int argc, char* argv[])
if (fscanf(f_bn, "%d", &aux_var) == EOF) { if (fscanf(f_bn, "%d", &aux_var) == EOF) {
/* Set pointer to beginning of file */ /* Set pointer to beginning of file */
fseek(f_bn, 0L, SEEK_SET); fseek(f_bn, 0L, SEEK_SET);
fscanf(f_bn, "%d", &aux_var); if (fscanf(f_bn, "%d", &aux_var) == EOF) {
exit(0);
}
} }
bottleneck = (WebRtc_Word16)aux_var; bottleneck = (WebRtc_Word16)aux_var;
if (CodingMode == 1) { if (CodingMode == 1) {
@@ -675,10 +679,11 @@ int main(int argc, char* argv[])
if (fp_gns != NULL) { if (fp_gns != NULL) {
if (fscanf(fp_gns, "%d", &cur_delay) == EOF) { if (fscanf(fp_gns, "%d", &cur_delay) == EOF) {
fseek(fp_gns, 0L, SEEK_SET); fseek(fp_gns, 0L, SEEK_SET);
fscanf(fp_gns, "%d", &cur_delay); if (fscanf(fp_gns, "%d", &cur_delay) == EOF) {
exit(0);
}
} }
} }
/* simulate packet handling through NetEq and the modem */ /* simulate packet handling through NetEq and the modem */
if (!(testNum == 3 && framecnt == 0)) { if (!(testNum == 3 && framecnt == 0)) {

View File

@@ -58,7 +58,7 @@ int main(int argc, char* argv[])
double starttime, runtime, length_file; double starttime, runtime, length_file;
WebRtc_Word16 stream_len = 0; WebRtc_Word16 stream_len = 0;
WebRtc_Word16 declen, lostFrame = 0, declenTC; WebRtc_Word16 declen, lostFrame = 0, declenTC = 0;
WebRtc_Word16 shortdata[SWBFRAMESAMPLES_10ms]; WebRtc_Word16 shortdata[SWBFRAMESAMPLES_10ms];
WebRtc_Word16 vaddata[SWBFRAMESAMPLES_10ms*3]; WebRtc_Word16 vaddata[SWBFRAMESAMPLES_10ms*3];
@@ -97,9 +97,9 @@ int main(int argc, char* argv[])
bool doTransCoding = false; bool doTransCoding = false;
WebRtc_Word32 rateTransCoding = 0; WebRtc_Word32 rateTransCoding = 0;
WebRtc_UWord16 streamDataTransCoding[600]; WebRtc_UWord16 streamDataTransCoding[600];
WebRtc_Word16 streamLenTransCoding; WebRtc_Word16 streamLenTransCoding = 0;
FILE* transCodingFile; FILE* transCodingFile = NULL;
FILE* transcodingBitstream; FILE* transcodingBitstream = NULL;
WebRtc_UWord32 numTransCodingBytes = 0; WebRtc_UWord32 numTransCodingBytes = 0;
/* only one structure used for ISAC encoder */ /* only one structure used for ISAC encoder */
@@ -368,7 +368,9 @@ int main(int argc, char* argv[])
{ {
/* Set pointer to beginning of file */ /* Set pointer to beginning of file */
fseek(f_bn, 0L, SEEK_SET); fseek(f_bn, 0L, SEEK_SET);
fscanf(f_bn, "%d", &bottleneck); if (fscanf(f_bn, "%d", &bottleneck) == EOF) {
exit(0);
}
} }
/* Bottleneck is a cosine function /* Bottleneck is a cosine function
@@ -744,7 +746,9 @@ int main(int argc, char* argv[])
{ {
/* Set pointer to beginning of file */ /* Set pointer to beginning of file */
fseek(f_bn, 0L, SEEK_SET); fseek(f_bn, 0L, SEEK_SET);
fscanf(f_bn, "%d", &bottleneck); if (fscanf(f_bn, "%d", &bottleneck) == EOF) {
exit(0);
}
} }
if(CodingMode == 1) if(CodingMode == 1)
{ {

View File

@@ -108,7 +108,7 @@ int main(int argc, char* argv[])
WebRtc_UWord16 payload[600]; WebRtc_UWord16 payload[600];
WebRtc_UWord16 payloadRCU[600]; WebRtc_UWord16 payloadRCU[600];
WebRtc_UWord16 packetLossPercent = 0; WebRtc_UWord16 packetLossPercent = 0;
WebRtc_Word16 rcuStreamLen; WebRtc_Word16 rcuStreamLen = 0;
int onlyEncode; int onlyEncode;
int onlyDecode; int onlyDecode;

View File

@@ -100,6 +100,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'audio_coding_module', 'audio_coding_module',
'<(webrtc_root)/../testing/gtest.gyp:gtest',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
], ],
'sources': [ 'sources': [

View File

@@ -9,20 +9,21 @@
*/ */
#include <cctype> #include <cctype>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream> #include <iostream>
#include <ostream> #include <ostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "APITest.h" #include "APITest.h"
#include "thread_wrapper.h" #include "common_types.h"
#include "engine_configurations.h"
#include "event_wrapper.h" #include "event_wrapper.h"
#include "gtest/gtest.h"
#include "thread_wrapper.h"
#include "tick_util.h" #include "tick_util.h"
#include "trace.h" #include "trace.h"
#include "utility.h" #include "utility.h"
#include "common_types.h"
#include "engine_configurations.h"
#define TEST_DURATION_SEC 600 #define TEST_DURATION_SEC 600
@@ -310,7 +311,7 @@ APITest::SetUp()
char print[11]; char print[11];
printf("\nRandom Test (y/n)?"); printf("\nRandom Test (y/n)?");
fgets(print, 10, stdin); EXPECT_TRUE(fgets(print, 10, stdin) != NULL);
print[10] = '\0'; print[10] = '\0';
if(strstr(print, "y") != NULL) if(strstr(print, "y") != NULL)
{ {
@@ -327,11 +328,11 @@ APITest::SetUp()
Trace::SetTraceFile("ACMAPITest.txt", true); Trace::SetTraceFile("ACMAPITest.txt", true);
_randomTest = false; _randomTest = false;
printf("\nPrint Tests (y/n)? "); printf("\nPrint Tests (y/n)? ");
fgets(print, 10, stdin); EXPECT_TRUE(fgets(print, 10, stdin) != NULL);
print[10] = '\0'; print[10] = '\0';
if(strstr(print, "y") == NULL) if(strstr(print, "y") == NULL)
{ {
freopen("APITest_log.txt", "w", stdout); EXPECT_TRUE(freopen("APITest_log.txt", "w", stdout) != 0);
_verbose = false; _verbose = false;
} }
} }
@@ -1139,8 +1140,8 @@ void
APITest::TestPlayout(char receiveSide) APITest::TestPlayout(char receiveSide)
{ {
AudioCodingModule* receiveACM; AudioCodingModule* receiveACM;
AudioPlayoutMode* playoutMode; AudioPlayoutMode* playoutMode = NULL;
ACMBackgroundNoiseMode* bgnMode; ACMBackgroundNoiseMode* bgnMode = NULL;
switch(receiveSide) switch(receiveSide)
{ {
case 'A': case 'A':

View File

@@ -9,10 +9,12 @@
*/ */
#include "EncodeDecodeTest.h" #include "EncodeDecodeTest.h"
#include "common_types.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "common_types.h"
#include "gtest/gtest.h"
#include "trace.h" #include "trace.h"
#include "utility.h" #include "utility.h"
@@ -63,7 +65,7 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream)
printf("\nValid output frequencies:\n"); printf("\nValid output frequencies:\n");
printf("8000\n16000\n32000\n-1, which means output freq equal to received signal freq"); printf("8000\n16000\n32000\n-1, which means output freq equal to received signal freq");
printf("\n\nChoose output sampling frequency: "); printf("\n\nChoose output sampling frequency: ");
scanf("%d", &playSampFreq); ASSERT_GT(scanf("%d", &playSampFreq), 0);
char fileName[] = "./src/modules/audio_coding/main/test/outFile.pcm"; char fileName[] = "./src/modules/audio_coding/main/test/outFile.pcm";
_pcmFile.Open(fileName, 32000, "wb+"); _pcmFile.Open(fileName, 32000, "wb+");
} }

View File

@@ -9,8 +9,6 @@
*/ */
#include "EncodeToFileTest.h" #include "EncodeToFileTest.h"
#include "audio_coding_module.h"
#include "common_types.h"
#ifdef WIN32 #ifdef WIN32
# include <Winsock2.h> # include <Winsock2.h>
@@ -18,11 +16,14 @@
# include <arpa/inet.h> # include <arpa/inet.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "audio_coding_module.h"
#include "common_types.h"
#include "gtest/gtest.h"
TestPacketization::TestPacketization(RTPStream *rtpStream, WebRtc_UWord16 frequency) TestPacketization::TestPacketization(RTPStream *rtpStream, WebRtc_UWord16 frequency)
: :
_frequency(frequency), _frequency(frequency),
@@ -90,8 +91,7 @@ void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream)
printf("%d %s\n", n, sendCodec.plname); printf("%d %s\n", n, sendCodec.plname);
} }
printf("Choose your codec:"); printf("Choose your codec:");
ASSERT_GT(scanf("%d", &codecNo), 0);
scanf("%d", &codecNo);
char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm"; char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb"); _pcmFile.Open(fileName, 32000, "rb");
} }

View File

@@ -1,3 +1,4 @@
/* /*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* *
@@ -8,12 +9,13 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "PCMFile.h"
#include <cctype> #include <cctype>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "gtest/gtest.h"
#include "PCMFile.h"
#include "module_common_types.h" #include "module_common_types.h"
#define MAX_FILE_NAME_LENGTH_BYTE 500 #define MAX_FILE_NAME_LENGTH_BYTE 500
@@ -54,7 +56,7 @@ PCMFile::ChooseFile(
WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE]; WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE];
//strcpy(_fileName, "in.pcm"); //strcpy(_fileName, "in.pcm");
//printf("\n\nPlease enter the input file: "); //printf("\n\nPlease enter the input file: ");
fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin); EXPECT_TRUE(fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin) != NULL);
tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0'; tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0';
WebRtc_Word16 n = 0; WebRtc_Word16 n = 0;
@@ -106,7 +108,7 @@ PCMFile::ChooseFile(
WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE]; WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE];
//strcpy(_fileName, "in.pcm"); //strcpy(_fileName, "in.pcm");
//printf("\n\nPlease enter the input file: "); //printf("\n\nPlease enter the input file: ");
fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin); EXPECT_TRUE(fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin) != NULL);
tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0'; tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0';
WebRtc_Word16 n = 0; WebRtc_Word16 n = 0;
@@ -147,7 +149,7 @@ PCMFile::ChooseFile(
strncpy(fileName, tmpName, len+1); strncpy(fileName, tmpName, len+1);
} }
printf("Enter the sampling frequency (in Hz) of the above file [%u]: ", *frequencyHz); printf("Enter the sampling frequency (in Hz) of the above file [%u]: ", *frequencyHz);
fgets(tmpName, 10, stdin); EXPECT_TRUE(fgets(tmpName, 10, stdin) != NULL);
WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName); WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName);
if(tmpFreq > 0) if(tmpFreq > 0)
{ {

View File

@@ -9,8 +9,7 @@
*/ */
#include "RTPFile.h" #include "RTPFile.h"
#include "rw_lock_wrapper.h"
#include "engine_configurations.h"
#include <stdlib.h> #include <stdlib.h>
#ifdef WIN32 #ifdef WIN32
@@ -20,6 +19,9 @@
#endif #endif
#include "audio_coding_module.h" #include "audio_coding_module.h"
#include "engine_configurations.h"
#include "gtest/gtest.h"
#include "rw_lock_wrapper.h"
void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const WebRtc_UWord8* rtpHeader) void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const WebRtc_UWord8* rtpHeader)
{ {
@@ -186,16 +188,16 @@ void RTPFile::ReadHeader()
WebRtc_UWord32 start_sec, start_usec, source; WebRtc_UWord32 start_sec, start_usec, source;
WebRtc_UWord16 port, padding; WebRtc_UWord16 port, padding;
char fileHeader[40]; char fileHeader[40];
fgets(fileHeader, 40, _rtpFile); EXPECT_TRUE(fgets(fileHeader, 40, _rtpFile) != 0);
fread(&start_sec, 4, 1, _rtpFile); EXPECT_GT(fread(&start_sec, 4, 1, _rtpFile), 0u);
start_sec=ntohl(start_sec); start_sec=ntohl(start_sec);
fread(&start_usec, 4, 1, _rtpFile); EXPECT_GT(fread(&start_usec, 4, 1, _rtpFile), 0u);
start_usec=ntohl(start_usec); start_usec=ntohl(start_usec);
fread(&source, 4, 1, _rtpFile); EXPECT_GT(fread(&source, 4, 1, _rtpFile), 0u);
source=ntohl(source); source=ntohl(source);
fread(&port, 2, 1, _rtpFile); EXPECT_GT(fread(&port, 2, 1, _rtpFile), 0u);
port=ntohs(port); port=ntohs(port);
fread(&padding, 2, 1, _rtpFile); EXPECT_GT(fread(&padding, 2, 1, _rtpFile), 0u);
padding=ntohs(padding); padding=ntohs(padding);
} }
@@ -237,19 +239,19 @@ WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo,
WebRtc_UWord16 lengthBytes; WebRtc_UWord16 lengthBytes;
WebRtc_UWord16 plen; WebRtc_UWord16 plen;
WebRtc_UWord8 rtpHeader[12]; WebRtc_UWord8 rtpHeader[12];
fread(&lengthBytes, 2, 1, _rtpFile); EXPECT_GT(fread(&lengthBytes, 2, 1, _rtpFile), 0u);
if (feof(_rtpFile)) if (feof(_rtpFile))
{ {
_rtpEOF = true; _rtpEOF = true;
return 0; return 0;
} }
fread(&plen, 2, 1, _rtpFile); EXPECT_GT(fread(&plen, 2, 1, _rtpFile), 0u);
if (feof(_rtpFile)) if (feof(_rtpFile))
{ {
_rtpEOF = true; _rtpEOF = true;
return 0; return 0;
} }
fread(offset, 4, 1, _rtpFile); EXPECT_GT(fread(offset, 4, 1, _rtpFile), 0u);
if (feof(_rtpFile)) if (feof(_rtpFile))
{ {
_rtpEOF = true; _rtpEOF = true;
@@ -263,7 +265,7 @@ WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo,
throw "Unable to read RTP file"; throw "Unable to read RTP file";
exit(1); exit(1);
} }
fread(rtpHeader, 12, 1, _rtpFile); EXPECT_GT(fread(rtpHeader, 12, 1, _rtpFile), 0u);
if (feof(_rtpFile)) if (feof(_rtpFile))
{ {
_rtpEOF = true; _rtpEOF = true;
@@ -287,7 +289,7 @@ WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo,
exit(1); exit(1);
} }
lengthBytes -= 20; lengthBytes -= 20;
fread(payloadData, 1, lengthBytes, _rtpFile); EXPECT_GT(fread(payloadData, 1, lengthBytes, _rtpFile), 0u);
if (feof(_rtpFile)) if (feof(_rtpFile))
{ {
_rtpEOF = true; _rtpEOF = true;

View File

@@ -8,6 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "TwoWayCommunication.h"
#include <cctype> #include <cctype>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -16,12 +18,12 @@
#include <Windows.h> #include <Windows.h>
#endif #endif
#include "TwoWayCommunication.h"
#include "engine_configurations.h"
#include "PCMFile.h"
#include "utility.h"
#include "trace.h"
#include "common_types.h" #include "common_types.h"
#include "engine_configurations.h"
#include "gtest/gtest.h"
#include "PCMFile.h"
#include "trace.h"
#include "utility.h"
using namespace webrtc; using namespace webrtc;
@@ -79,11 +81,11 @@ TwoWayCommunication::ChooseCodec(WebRtc_UWord8* codecID_A, WebRtc_UWord8* codecI
} }
printf("\nChoose a send codec for side A [0]: "); printf("\nChoose a send codec for side A [0]: ");
char myStr[15] = ""; char myStr[15] = "";
fgets(myStr, 10, stdin); EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
*codecID_A = (WebRtc_UWord8)atoi(myStr); *codecID_A = (WebRtc_UWord8)atoi(myStr);
printf("\nChoose a send codec for side B [0]: "); printf("\nChoose a send codec for side B [0]: ");
fgets(myStr, 10, stdin); EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
*codecID_B = (WebRtc_UWord8)atoi(myStr); *codecID_B = (WebRtc_UWord8)atoi(myStr);
AudioCodingModule::Destroy(tmpACM); AudioCodingModule::Destroy(tmpACM);
@@ -97,7 +99,7 @@ TwoWayCommunication::ChooseFile(char* fileName, WebRtc_Word16 maxLen, WebRtc_UWo
WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE]; WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE];
//strcpy(_fileName, "in.pcm"); //strcpy(_fileName, "in.pcm");
//printf("\n\nPlease enter the input file: "); //printf("\n\nPlease enter the input file: ");
fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin); EXPECT_TRUE(fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin) != NULL);
tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0'; tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0';
WebRtc_Word16 n = 0; WebRtc_Word16 n = 0;
@@ -138,7 +140,7 @@ TwoWayCommunication::ChooseFile(char* fileName, WebRtc_Word16 maxLen, WebRtc_UWo
strncpy(fileName, tmpName, len+1); strncpy(fileName, tmpName, len+1);
} }
printf("Enter the sampling frequency (in Hz) of the above file [%u]: ", *frequencyHz); printf("Enter the sampling frequency (in Hz) of the above file [%u]: ", *frequencyHz);
fgets(tmpName, 6, stdin); EXPECT_TRUE(fgets(tmpName, 6, stdin) != NULL);
WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName); WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName);
if(tmpFreq > 0) if(tmpFreq > 0)
{ {

View File

@@ -298,7 +298,7 @@ ISACTest::Perform()
testNr++; testNr++;
EncodeDecode(testNr, wbISACConfig, swbISACConfig); EncodeDecode(testNr, wbISACConfig, swbISACConfig);
int dummy; int user_input;
if((_testMode == 0) || (_testMode == 1)) if((_testMode == 0) || (_testMode == 1))
{ {
swbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)200; swbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)200;
@@ -307,11 +307,11 @@ ISACTest::Perform()
else else
{ {
printf("Enter the max payload-size for side A: "); printf("Enter the max payload-size for side A: ");
scanf("%d", &dummy); CHECK_ERROR(scanf("%d", &user_input));
swbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)dummy; swbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)user_input;
printf("Enter the max payload-size for side B: "); printf("Enter the max payload-size for side B: ");
scanf("%d", &dummy); CHECK_ERROR(scanf("%d", &user_input));
wbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)dummy; wbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)user_input;
} }
testNr++; testNr++;
EncodeDecode(testNr, wbISACConfig, swbISACConfig); EncodeDecode(testNr, wbISACConfig, swbISACConfig);
@@ -329,11 +329,11 @@ ISACTest::Perform()
else else
{ {
printf("Enter the max rate for side A: "); printf("Enter the max rate for side A: ");
scanf("%d", &dummy); CHECK_ERROR(scanf("%d", &user_input));
swbISACConfig.maxRateBitPerSec = (WebRtc_UWord32)dummy; swbISACConfig.maxRateBitPerSec = (WebRtc_UWord32)user_input;
printf("Enter the max rate for side B: "); printf("Enter the max rate for side B: ");
scanf("%d", &dummy); CHECK_ERROR(scanf("%d", &user_input));
wbISACConfig.maxRateBitPerSec = (WebRtc_UWord32)dummy; wbISACConfig.maxRateBitPerSec = (WebRtc_UWord32)user_input;
} }
testNr++; testNr++;

View File

@@ -9,14 +9,14 @@
*/ */
#include "utility.h" #include "utility.h"
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "audio_coding_module.h" #include "audio_coding_module.h"
#include "common_types.h" #include "common_types.h"
#include "gtest/gtest.h"
#define NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE 13 #define NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE 13
@@ -128,7 +128,7 @@ ChooseCodec(
do do
{ {
printf("\nChoose a codec [0]: "); printf("\nChoose a codec [0]: ");
fgets(myStr, 10, stdin); EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
codecID = atoi(myStr); codecID = atoi(myStr);
if((codecID < 0) || (codecID >= noCodec)) if((codecID < 0) || (codecID >= noCodec))
{ {

View File

@@ -177,6 +177,9 @@
{ {
'target_name': 'RTPjitter', 'target_name': 'RTPjitter',
'type': 'executable', 'type': 'executable',
'dependencies': [
'<(webrtc_root)/../testing/gtest.gyp:gtest',
],
'sources': [ 'sources': [
'test/RTPjitter.cc', 'test/RTPjitter.cc',
], ],
@@ -186,6 +189,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'NetEqTestTools', 'NetEqTestTools',
'<(webrtc_root)/../testing/gtest.gyp:gtest',
], ],
'sources': [ 'sources': [
'test/RTPanalyze.cc', 'test/RTPanalyze.cc',
@@ -196,6 +200,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'NetEqTestTools', 'NetEqTestTools',
'<(webrtc_root)/../testing/gtest.gyp:gtest',
], ],
'sources': [ 'sources': [
'test/RTPchange.cc', 'test/RTPchange.cc',
@@ -206,6 +211,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'NetEqTestTools', 'NetEqTestTools',
'<(webrtc_root)/../testing/gtest.gyp:gtest',
], ],
'sources': [ 'sources': [
'test/RTPtimeshift.cc', 'test/RTPtimeshift.cc',
@@ -216,6 +222,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'NetEqTestTools', 'NetEqTestTools',
'<(webrtc_root)/../testing/gtest.gyp:gtest',
], ],
'sources': [ 'sources': [
'test/RTPcat.cc', 'test/RTPcat.cc',
@@ -232,6 +239,7 @@
'iLBC', 'iLBC',
'iSAC', 'iSAC',
'CNG', 'CNG',
'<(webrtc_root)/../testing/gtest.gyp:gtest',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'include_dirs': [ 'include_dirs': [

View File

@@ -21,6 +21,8 @@
#include <cstdlib> #include <cstdlib>
#include "gtest/gtest.h"
#define HDR_SIZE 8 // rtpplay packet header size in bytes #define HDR_SIZE 8 // rtpplay packet header size in bytes
@@ -145,7 +147,9 @@ int NETEQTEST_RTPpacket::skipFileHeader(FILE *fp)
const int kFirstLineLength = 40; const int kFirstLineLength = 40;
char firstline[kFirstLineLength]; char firstline[kFirstLineLength];
fgets(firstline, kFirstLineLength, fp); if (fgets(firstline, kFirstLineLength, fp) == NULL) {
return -1;
}
if (strncmp(firstline, "#!rtpplay", 9) == 0) { if (strncmp(firstline, "#!rtpplay", 9) == 0) {
if (strncmp(firstline, "#!rtpplay1.0", 12) != 0) { if (strncmp(firstline, "#!rtpplay1.0", 12) != 0) {
return -1; return -1;

View File

@@ -19,8 +19,6 @@
/* Misc. definitions */ /* Misc. definitions */
/*********************/ /*********************/
#define FIRSTLINELEN 40
enum {kRedPayloadType = 127}; enum {kRedPayloadType = 127};
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@@ -44,12 +42,8 @@ int main(int argc, char* argv[])
// print file header // print file header
fprintf(outFile, "SeqNo TimeStamp SendTime Size PT M\n"); fprintf(outFile, "SeqNo TimeStamp SendTime Size PT M\n");
// read file header // read file header
char firstline[FIRSTLINELEN]; NETEQTEST_RTPpacket::skipFileHeader(inFile);
fgets(firstline, FIRSTLINELEN, inFile);
fread(firstline, 4+4+4+2+2, 1, inFile); // start_sec + start_usec + source + port + padding
NETEQTEST_RTPpacket packet; NETEQTEST_RTPpacket packet;
while (packet.readFromFile(inFile) >= 0) while (packet.readFromFile(inFile) >= 0)

View File

@@ -13,6 +13,7 @@
#include <vector> #include <vector>
#include "NETEQTEST_RTPpacket.h" #include "NETEQTEST_RTPpacket.h"
#include "gtest/gtest.h"
/*********************/ /*********************/
/* Misc. definitions */ /* Misc. definitions */
@@ -42,16 +43,18 @@ int main(int argc, char* argv[])
// read file header and write directly to output file // read file header and write directly to output file
char firstline[FIRSTLINELEN]; char firstline[FIRSTLINELEN];
fgets(firstline, FIRSTLINELEN, inFile); const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
fputs(firstline, outFile); EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, inFile) != NULL);
fread(firstline, 4 + 4 + 4 + 2 + 2, 1, inFile); // start_sec + start_usec + source + port + padding EXPECT_GT(fputs(firstline, outFile), 0);
fwrite(firstline, 4 + 4 + 4 + 2 + 2, 1, outFile); EXPECT_EQ(kRtpDumpHeaderSize, fread(firstline, 1, kRtpDumpHeaderSize,
inFile));
EXPECT_EQ(kRtpDumpHeaderSize, fwrite(firstline, 1, kRtpDumpHeaderSize,
outFile));
// close input file and re-open it later (easier to write the loop below) // close input file and re-open it later (easier to write the loop below)
fclose(inFile); fclose(inFile);
for (int i = 1; i < argc - 1; i++) { for (int i = 1; i < argc - 1; i++) {
inFile = fopen(argv[i], "rb"); inFile = fopen(argv[i], "rb");
if (!inFile) { if (!inFile) {
printf("Cannot open input file %s\n", argv[i]); printf("Cannot open input file %s\n", argv[i]);
@@ -60,28 +63,18 @@ int main(int argc, char* argv[])
printf("Input RTP file: %s\n", argv[i]); printf("Input RTP file: %s\n", argv[i]);
// skip file header // skip file header
fgets(firstline, FIRSTLINELEN, inFile); NETEQTEST_RTPpacket::skipFileHeader(inFile);
fread(firstline, 4 + 4 + 4 + 2 + 2, 1, inFile); // start_sec + start_usec + source + port + padding
NETEQTEST_RTPpacket packet; NETEQTEST_RTPpacket packet;
int packLen = packet.readFromFile(inFile); int packLen = packet.readFromFile(inFile);
if (packLen < 0) { if (packLen < 0) {
exit(1); exit(1);
} }
while (packLen >= 0) { while (packLen >= 0) {
packet.writeToFile(outFile); packet.writeToFile(outFile);
packLen = packet.readFromFile(inFile); packLen = packet.readFromFile(inFile);
} }
fclose(inFile); fclose(inFile);
} }
fclose(outFile); fclose(outFile);
return 0; return 0;
} }

View File

@@ -13,7 +13,7 @@
#include <vector> #include <vector>
#include "NETEQTEST_RTPpacket.h" #include "NETEQTEST_RTPpacket.h"
#include "gtest/gtest.h"
/*********************/ /*********************/
/* Misc. definitions */ /* Misc. definitions */
@@ -56,8 +56,11 @@ int main(int argc, char* argv[])
// read all statistics and insert into map // read all statistics and insert into map
// read first line // read first line
char tempStr[100]; char tempStr[100];
fgets(tempStr, 100, statFile); if (fgets(tempStr, 100, statFile) == NULL)
{
printf("Failed to read timing file %s\n", argv[2]);
return (-1);
}
// define map // define map
std::map<std::pair<WebRtc_UWord16, WebRtc_UWord32>, WebRtc_UWord32> std::map<std::pair<WebRtc_UWord16, WebRtc_UWord32>, WebRtc_UWord32>
packetStats; packetStats;
@@ -77,10 +80,24 @@ int main(int argc, char* argv[])
// read file header and write directly to output file // read file header and write directly to output file
char firstline[FIRSTLINELEN]; char firstline[FIRSTLINELEN];
fgets(firstline, FIRSTLINELEN, inFile); if (fgets(firstline, FIRSTLINELEN, inFile) == NULL)
{
printf("Failed to read first line of input file %s\n", argv[1]);
return (-1);
}
fputs(firstline, outFile); fputs(firstline, outFile);
fread(firstline, 4+4+4+2+2, 1, inFile); // start_sec + start_usec + source + port + padding // start_sec + start_usec + source + port + padding
fwrite(firstline, 4+4+4+2+2, 1, outFile); const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
if (fread(firstline, 1, kRtpDumpHeaderSize, inFile) != kRtpDumpHeaderSize)
{
printf("Failed to read RTP dump header from input file %s\n", argv[1]);
return (-1);
}
if (fwrite(firstline, 1, kRtpDumpHeaderSize, outFile) != kRtpDumpHeaderSize)
{
printf("Failed to write RTP dump header to output file %s\n", argv[3]);
return (-1);
}
std::vector<NETEQTEST_RTPpacket *> packetVec; std::vector<NETEQTEST_RTPpacket *> packetVec;

View File

@@ -277,7 +277,7 @@ int main(int argc, char* argv[])
bool dtmfSent = false; bool dtmfSent = false;
#endif #endif
bool usingStereo = false; bool usingStereo = false;
int stereoMode; int stereoMode = 0;
int numChannels = 1; int numChannels = 1;
/* check number of parameters */ /* check number of parameters */
@@ -1609,7 +1609,7 @@ int NetEQTest_free_coders(enum WebRtcNetEQDecoder coder, int numChannels) {
int NetEQTest_encode(int coder, WebRtc_Word16 *indata, int frameLen, unsigned char * encoded,int sampleRate , int NetEQTest_encode(int coder, WebRtc_Word16 *indata, int frameLen, unsigned char * encoded,int sampleRate ,
int * vad, int useVAD, int bitrate, int numChannels){ int * vad, int useVAD, int bitrate, int numChannels){
short cdlen; short cdlen = 0;
WebRtc_Word16 *tempdata; WebRtc_Word16 *tempdata;
static int first_cng=1; static int first_cng=1;
WebRtc_Word16 tempLen; WebRtc_Word16 tempLen;

View File

@@ -22,6 +22,8 @@
#include <search.h> #include <search.h>
#include <float.h> #include <float.h>
#include "gtest/gtest.h"
/*********************/ /*********************/
/* Misc. definitions */ /* Misc. definitions */
/*********************/ /*********************/
@@ -68,7 +70,8 @@ int main(int argc, char* argv[])
unsigned int dat_len, rtp_len, Npack, k; unsigned int dat_len, rtp_len, Npack, k;
arr_time *time_vec; arr_time *time_vec;
char firstline[FIRSTLINELEN]; char firstline[FIRSTLINELEN];
unsigned char *rtp_vec, **packet_ptr, *temp_packet; unsigned char *rtp_vec = NULL, **packet_ptr, *temp_packet;
const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
WebRtc_UWord16 len; WebRtc_UWord16 len;
WebRtc_UWord32 *offset; WebRtc_UWord32 *offset;
@@ -126,10 +129,12 @@ int main(int argc, char* argv[])
} }
// read file header and write directly to output file // read file header and write directly to output file
fgets(firstline, FIRSTLINELEN, in_file); EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, in_file) != NULL);
fputs(firstline, out_file); EXPECT_GT(fputs(firstline, out_file), 0);
fread(firstline, 4+4+4+2+2, 1, in_file); // start_sec + start_usec + source + port + padding EXPECT_EQ(kRtpDumpHeaderSize, fread(firstline, 1, kRtpDumpHeaderSize,
fwrite(firstline, 4+4+4+2+2, 1, out_file); in_file));
EXPECT_EQ(kRtpDumpHeaderSize, fwrite(firstline, 1, kRtpDumpHeaderSize,
out_file));
// read all RTP packets into vector // read all RTP packets into vector
rtp_len=0; rtp_len=0;

View File

@@ -13,7 +13,7 @@
#include <vector> #include <vector>
#include "NETEQTEST_RTPpacket.h" #include "NETEQTEST_RTPpacket.h"
#include "gtest/gtest.h"
/*********************/ /*********************/
/* Misc. definitions */ /* Misc. definitions */
@@ -47,12 +47,14 @@ int main(int argc, char* argv[])
printf("Output RTP file: %s\n\n",argv[2]); printf("Output RTP file: %s\n\n",argv[2]);
// read file header and write directly to output file // read file header and write directly to output file
const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
char firstline[FIRSTLINELEN]; char firstline[FIRSTLINELEN];
fgets(firstline, FIRSTLINELEN, inFile); EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, inFile) != NULL);
fputs(firstline, outFile); EXPECT_GT(fputs(firstline, outFile), 0);
fread(firstline, 4+4+4+2+2, 1, inFile); // start_sec + start_usec + source + port + padding EXPECT_EQ(kRtpDumpHeaderSize,
fwrite(firstline, 4+4+4+2+2, 1, outFile); fread(firstline, 1, kRtpDumpHeaderSize, inFile));
EXPECT_EQ(kRtpDumpHeaderSize,
fwrite(firstline, 1, kRtpDumpHeaderSize, outFile));
NETEQTEST_RTPpacket packet; NETEQTEST_RTPpacket packet;
int packLen = packet.readFromFile(inFile); int packLen = packet.readFromFile(inFile);
if (packLen < 0) if (packLen < 0)

View File

@@ -776,7 +776,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection()
{ {
TEST_LOG("Would you like to try kWindowsCoreAudio instead " TEST_LOG("Would you like to try kWindowsCoreAudio instead "
"[requires Win Vista or Win 7] (Y/N)?\n: "); "[requires Win Vista or Win 7] (Y/N)?\n: ");
scanf(" %c", &ch); TEST(scanf(" %c", &ch) > 0);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@@ -785,7 +785,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection()
} else if (audioLayer == AudioDeviceModule::kWindowsCoreAudio) } else if (audioLayer == AudioDeviceModule::kWindowsCoreAudio)
{ {
TEST_LOG("Would you like to try kWindowsWaveAudio instead (Y/N)?\n: "); TEST_LOG("Would you like to try kWindowsWaveAudio instead (Y/N)?\n: ");
scanf(" %c", &ch); TEST(scanf(" %c", &ch) > 0);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@@ -1695,7 +1695,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneVolume()
RecordedMicrophoneVolumeFile); RecordedMicrophoneVolumeFile);
char ch; char ch;
bool fileRecording(false); bool fileRecording(false);
scanf(" %c", &ch); TEST(scanf(" %c", &ch) > 0);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@@ -1834,7 +1834,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneMute()
RecordedMicrophoneMuteFile); RecordedMicrophoneMuteFile);
char ch; char ch;
bool fileRecording(false); bool fileRecording(false);
scanf(" %c", &ch); TEST(scanf(" %c", &ch) > 0);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@@ -1970,7 +1970,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneBoost()
RecordedMicrophoneBoostFile); RecordedMicrophoneBoostFile);
char ch; char ch;
bool fileRecording(false); bool fileRecording(false);
scanf(" %c", &ch); TEST(scanf(" %c", &ch) > 0);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@@ -2107,7 +2107,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneAGC()
RecordedMicrophoneAGCFile); RecordedMicrophoneAGCFile);
char ch; char ch;
bool fileRecording(false); bool fileRecording(false);
scanf(" %c", &ch); TEST(scanf(" %c", &ch) > 0);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@@ -2567,11 +2567,8 @@ WebRtc_Word32 FuncTestManager::SelectRecordingDevice()
TEST_LOG(" (%d) Device %d (%s)\n", i, i, name); TEST_LOG(" (%d) Device %d (%s)\n", i, i, name);
} }
TEST_LOG("\n: "); TEST_LOG("\n: ");
int sel(0); int sel(0);
TEST(scanf("%u", &sel) > 0);
scanf("%u", &sel);
if (sel < (nDevices)) if (sel < (nDevices))
{ {
TEST((ret = _audioDevice->SetRecordingDevice(sel)) == 0); TEST((ret = _audioDevice->SetRecordingDevice(sel)) == 0);
@@ -2634,13 +2631,9 @@ WebRtc_Word32 FuncTestManager::SelectPlayoutDevice()
TEST_LOG(" (%d) Device %d (%s)\n", i, i, name); TEST_LOG(" (%d) Device %d (%s)\n", i, i, name);
} }
TEST_LOG("\n: "); TEST_LOG("\n: ");
int sel(0); int sel(0);
TEST(scanf("%u", &sel) > 0);
scanf("%u", &sel);
WebRtc_Word32 ret(0); WebRtc_Word32 ret(0);
if (sel < (nDevices)) if (sel < (nDevices))
{ {
TEST((ret = _audioDevice->SetPlayoutDevice(sel)) == 0); TEST((ret = _audioDevice->SetPlayoutDevice(sel)) == 0);

View File

@@ -9,12 +9,15 @@
*/ */
#include "normal_async_test.h" #include "normal_async_test.h"
#include "typedefs.h"
#include <sstream> #include <sstream>
#include <assert.h> #include <assert.h>
#include <queue> #include <queue>
#include <string.h> #include <string.h>
#include "gtest/gtest.h"
#include "tick_util.h" #include "tick_util.h"
#include "typedefs.h"
using namespace webrtc; using namespace webrtc;
@@ -391,7 +394,7 @@ bool
NormalAsyncTest::Encode() NormalAsyncTest::Encode()
{ {
_lengthEncFrame = 0; _lengthEncFrame = 0;
fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile); EXPECT_GT(fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile), 0u);
_inputVideoBuffer.CopyBuffer(_lengthSourceFrame, _sourceBuffer); _inputVideoBuffer.CopyBuffer(_lengthSourceFrame, _sourceBuffer);
_inputVideoBuffer.SetTimeStamp((unsigned int) _inputVideoBuffer.SetTimeStamp((unsigned int)
(_encFrameCnt * 9e4 / _inst.maxFramerate)); (_encFrameCnt * 9e4 / _inst.maxFramerate));
@@ -448,6 +451,7 @@ NormalAsyncTest::Encode()
webrtc::CodecSpecificInfo* codecSpecificInfo = CreateEncoderSpecificInfo(); webrtc::CodecSpecificInfo* codecSpecificInfo = CreateEncoderSpecificInfo();
int ret = _encoder->Encode(rawImage, codecSpecificInfo, &frameType); int ret = _encoder->Encode(rawImage, codecSpecificInfo, &frameType);
EXPECT_EQ(ret, WEBRTC_VIDEO_CODEC_OK);
if (codecSpecificInfo != NULL) if (codecSpecificInfo != NULL)
{ {
delete codecSpecificInfo; delete codecSpecificInfo;

View File

@@ -9,10 +9,13 @@
*/ */
#include "normal_test.h" #include "normal_test.h"
#include <time.h> #include <time.h>
#include <sstream> #include <sstream>
#include <string.h> #include <string.h>
#include "gtest/gtest.h"
NormalTest::NormalTest() NormalTest::NormalTest()
: :
Test("Normal Test 1", "A test of normal execution of the codec"), Test("Normal Test 1", "A test of normal execution of the codec"),
@@ -169,7 +172,7 @@ bool
NormalTest::Encode() NormalTest::Encode()
{ {
_lengthEncFrame = 0; _lengthEncFrame = 0;
fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile); EXPECT_GT(fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile), 0u);
if (feof(_sourceFile) != 0) if (feof(_sourceFile) != 0)
{ {
return true; return true;

View File

@@ -9,9 +9,12 @@
*/ */
#include "performance_test.h" #include "performance_test.h"
#include "tick_util.h"
#include <assert.h> #include <assert.h>
#include "gtest/gtest.h"
#include "tick_util.h"
using namespace webrtc; using namespace webrtc;
#define NUM_FRAMES 300 #define NUM_FRAMES 300
@@ -129,7 +132,8 @@ PerformanceTest::Perform()
// Read a new frame from file // Read a new frame from file
WriteLockScoped imageLock(*_rawImageLock); WriteLockScoped imageLock(*_rawImageLock);
_lengthEncFrame = 0; _lengthEncFrame = 0;
fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile); EXPECT_GT(fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile),
0u);
if (feof(_sourceFile) != 0) if (feof(_sourceFile) != 0)
{ {
rewind(_sourceFile); rewind(_sourceFile);
@@ -269,6 +273,7 @@ bool PerformanceTest::Encode()
} }
webrtc::CodecSpecificInfo* codecSpecificInfo = CreateEncoderSpecificInfo(); webrtc::CodecSpecificInfo* codecSpecificInfo = CreateEncoderSpecificInfo();
int ret = _encoder->Encode(rawImage, codecSpecificInfo, &frameType); int ret = _encoder->Encode(rawImage, codecSpecificInfo, &frameType);
EXPECT_EQ(ret, WEBRTC_VIDEO_CODEC_OK);
if (codecSpecificInfo != NULL) if (codecSpecificInfo != NULL)
{ {
delete codecSpecificInfo; delete codecSpecificInfo;

View File

@@ -16,6 +16,7 @@
'type': '<(library)', 'type': '<(library)',
'dependencies': [ 'dependencies': [
'<(webrtc_root)/../testing/gtest.gyp:gtest',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/common_video/common_video.gyp:webrtc_vplib', '<(webrtc_root)/common_video/common_video.gyp:webrtc_vplib',
], ],

View File

@@ -11,6 +11,7 @@
'target_name': 'video_coding_test', 'target_name': 'video_coding_test',
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'<(webrtc_root)/../testing/gtest.gyp:gtest',
'<(webrtc_root)/../test/test.gyp:test_support', '<(webrtc_root)/../test/test.gyp:test_support',
'webrtc_video_coding', 'webrtc_video_coding',
'rtp_rtcp', 'rtp_rtcp',

View File

@@ -121,7 +121,7 @@ CodecDataBaseTest::Perform(CmdArgs& args)
VideoFrame sourceFrame; VideoFrame sourceFrame;
sourceFrame.VerifyAndAllocate(_lengthSourceFrame); sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame]; WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame];
fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height); sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width); sourceFrame.SetWidth(_width);
@@ -324,7 +324,7 @@ CodecDataBaseTest::Perform(CmdArgs& args)
for (j=0; j < int(300/VideoCodingModule::NumberOfCodecs()); j++)// assuming 300 frames, NumberOfCodecs <= 10 for (j=0; j < int(300/VideoCodingModule::NumberOfCodecs()); j++)// assuming 300 frames, NumberOfCodecs <= 10
{ {
frameCnt++; frameCnt++;
fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
// building source frame // building source frame
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height); sourceFrame.SetHeight(_height);

View File

@@ -143,7 +143,7 @@ GenericCodecTest::Perform(CmdArgs& args)
_vcm->RegisterReceiveCodec(&receiveCodec, 1); _vcm->RegisterReceiveCodec(&receiveCodec, 1);
} }
WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame]; WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame];
fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
// building source frame // building source frame
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height); sourceFrame.SetHeight(_height);
@@ -191,7 +191,7 @@ GenericCodecTest::Perform(CmdArgs& args)
//encoding 1 second of video //encoding 1 second of video
for (i = 0; i < _frameRate; i++) for (i = 0; i < _frameRate; i++)
{ {
fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height); sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width); sourceFrame.SetWidth(_width);
@@ -265,7 +265,7 @@ GenericCodecTest::Perform(CmdArgs& args)
sourceFrame.VerifyAndAllocate(_lengthSourceFrame); sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
const float bitRate[] = {100, 400, 600, 1000, 2000, 3000}; const float bitRate[] = {100, 400, 600, 1000, 2000, 3000};
const float nBitrates = sizeof(bitRate)/sizeof(*bitRate); const float nBitrates = sizeof(bitRate)/sizeof(*bitRate);
float _bitRate; float _bitRate = 0;
int _frameCnt = 0; int _frameCnt = 0;
WebRtc_Word64 startTime, currentTime, oneSecTime; WebRtc_Word64 startTime, currentTime, oneSecTime;
float totalBytesOneSec;//, totalBytesTenSec; float totalBytesOneSec;//, totalBytesTenSec;
@@ -377,7 +377,7 @@ GenericCodecTest::Perform(CmdArgs& args)
encodeComplete = false; encodeComplete = false;
while (encodeComplete == false) while (encodeComplete == false)
{ {
fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
_frameCnt++; _frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height); sourceFrame.SetHeight(_height);
@@ -467,7 +467,7 @@ GenericCodecTest::Perform(CmdArgs& args)
rewind(_sourceFile); rewind(_sourceFile);
while (!feof(_sourceFile)) while (!feof(_sourceFile))
{ {
fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height); sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width); sourceFrame.SetWidth(_width);

View File

@@ -102,7 +102,7 @@ int JitterBufferTest(CmdArgs& args)
packet.seqNum = seqNum; packet.seqNum = seqNum;
packet.payloadType = 126; packet.payloadType = 126;
seqNum++; seqNum++;
fb->InsertPacket(packet, VCMTickTime::MillisecondTimestamp()); fb->InsertPacket(packet, VCMTickTime::MillisecondTimestamp(), false, 0);
TEST(frameList.Insert(fb) == 0); TEST(frameList.Insert(fb) == 0);
} }
VCMFrameListItem* item = NULL; VCMFrameListItem* item = NULL;
@@ -1907,8 +1907,8 @@ int JitterBufferTest(CmdArgs& args)
seqNum = 65485; seqNum = 65485;
timeStampStart = timeStamp + 33*90; timeStampStart = timeStamp + 33*90;
WebRtc_UWord32 timeStampFirstKey = 0; WebRtc_UWord32 timeStampFirstKey = 0;
VCMEncodedFrame* ptrLastDeltaFrame; VCMEncodedFrame* ptrLastDeltaFrame = NULL;
VCMEncodedFrame* ptrFirstKeyFrame; VCMEncodedFrame* ptrFirstKeyFrame = NULL;
// insert MAX_NUMBER_OF_FRAMES frames // insert MAX_NUMBER_OF_FRAMES frames
do do
{ {

View File

@@ -128,7 +128,7 @@ MediaOptTest::Setup(int testType, CmdArgs& args)
_fpinp = fopen("dat_inp","rb"); _fpinp = fopen("dat_inp","rb");
_fpout = fopen("test_runs/dat_out","ab"); _fpout = fopen("test_runs/dat_out","ab");
_fpout2 = fopen("test_runs/dat_out2","ab"); _fpout2 = fopen("test_runs/dat_out2","ab");
fscanf(_fpinp,"%f %f %d \n",&rateTest,&lossTest,&numRuns); TEST(fscanf(_fpinp,"%f %f %d \n",&rateTest,&lossTest,&numRuns) > 0);
_bitRate = rateTest; _bitRate = rateTest;
_lossRate = lossTest; _lossRate = lossTest;
_testNum = 0; _testNum = 0;
@@ -311,7 +311,7 @@ MediaOptTest::Perform()
while (feof(_sourceFile)== 0) while (feof(_sourceFile)== 0)
{ {
fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
_frameCnt++; _frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);

View File

@@ -55,7 +55,7 @@ MainSenderThread(void* obj)
} }
if (feof(state->_sourceFile) == 0) if (feof(state->_sourceFile) == 0)
{ {
fread(tmpBuffer, 1, lengthSourceFrame,state->_sourceFile); TEST(fread(tmpBuffer, 1, lengthSourceFrame,state->_sourceFile) > 0);
state->_frameCnt++; state->_frameCnt++;
sourceFrame.CopyFrame(lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(height); sourceFrame.SetHeight(height);

View File

@@ -279,7 +279,7 @@ NormalTest::Perform(CmdArgs& args)
#if !(defined(TICK_TIME_DEBUG) || defined(EVENT_DEBUG)) #if !(defined(TICK_TIME_DEBUG) || defined(EVENT_DEBUG))
WebRtc_Word64 processStartTime = VCMTickTime::MillisecondTimestamp(); WebRtc_Word64 processStartTime = VCMTickTime::MillisecondTimestamp();
#endif #endif
fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
_frameCnt++; _frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height); sourceFrame.SetHeight(_height);

View File

@@ -236,7 +236,7 @@ QualityModesTest::Perform()
while (feof(_sourceFile)== 0) while (feof(_sourceFile)== 0)
{ {
fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
_frameCnt++; _frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_nativeHeight); sourceFrame.SetHeight(_nativeHeight);

View File

@@ -9,9 +9,6 @@
*/ */
#include "rtp_player.h" #include "rtp_player.h"
#include "../source/internal_defines.h"
#include "rtp_rtcp.h"
#include "tick_time.h"
#include <cstdlib> #include <cstdlib>
#ifdef WIN32 #ifdef WIN32
@@ -21,6 +18,11 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include "../source/internal_defines.h"
#include "gtest/gtest.h"
#include "rtp_rtcp.h"
#include "tick_time.h"
using namespace webrtc; using namespace webrtc;
RawRtpPacket::RawRtpPacket(WebRtc_UWord8* data, WebRtc_UWord16 len) RawRtpPacket::RawRtpPacket(WebRtc_UWord8* data, WebRtc_UWord16 len)
@@ -231,7 +233,7 @@ WebRtc_Word32 RTPPlayer::ReadHeader()
{ {
return -1; return -1;
} }
fgets(firstline, FIRSTLINELEN, _rtpFile); EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, _rtpFile) != NULL);
if(strncmp(firstline,"#!rtpplay",9) == 0) { if(strncmp(firstline,"#!rtpplay",9) == 0) {
if(strncmp(firstline,"#!rtpplay1.0",12) != 0){ if(strncmp(firstline,"#!rtpplay1.0",12) != 0){
printf("ERROR: wrong rtpplay version, must be 1.0\n"); printf("ERROR: wrong rtpplay version, must be 1.0\n");
@@ -255,15 +257,15 @@ WebRtc_Word32 RTPPlayer::ReadHeader()
WebRtc_UWord16 port; WebRtc_UWord16 port;
WebRtc_UWord16 padding; WebRtc_UWord16 padding;
fread(&start_sec, 4, 1, _rtpFile); EXPECT_GT(fread(&start_sec, 4, 1, _rtpFile), 0u);
start_sec=ntohl(start_sec); start_sec=ntohl(start_sec);
fread(&start_usec, 4, 1, _rtpFile); EXPECT_GT(fread(&start_usec, 4, 1, _rtpFile), 0u);
start_usec=ntohl(start_usec); start_usec=ntohl(start_usec);
fread(&source, 4, 1, _rtpFile); EXPECT_GT(fread(&source, 4, 1, _rtpFile), 0u);
source=ntohl(source); source=ntohl(source);
fread(&port, 2, 1, _rtpFile); EXPECT_GT(fread(&port, 2, 1, _rtpFile), 0u);
port=ntohs(port); port=ntohs(port);
fread(&padding, 2, 1, _rtpFile); EXPECT_GT(fread(&padding, 2, 1, _rtpFile), 0u);
padding=ntohs(padding); padding=ntohs(padding);
return 0; return 0;
} }

View File

@@ -298,7 +298,7 @@ TEST_F(VideoProcessingModuleTest, Resampler)
// Reading test frame // Reading test frame
VideoFrame sourceFrame; VideoFrame sourceFrame;
ASSERT_EQ(0, sourceFrame.VerifyAndAllocate(lengthSourceFrame)); ASSERT_EQ(0, sourceFrame.VerifyAndAllocate(lengthSourceFrame));
fread(sourceFrame.Buffer(), 1, lengthSourceFrame, _sourceFile); EXPECT_GT(fread(sourceFrame.Buffer(), 1, lengthSourceFrame, _sourceFile), 0u);
ASSERT_EQ(0, sourceFrame.SetLength(lengthSourceFrame)); ASSERT_EQ(0, sourceFrame.SetLength(lengthSourceFrame));
sourceFrame.SetHeight(height); sourceFrame.SetHeight(height);
sourceFrame.SetWidth(width); sourceFrame.SetWidth(width);

View File

@@ -17,8 +17,7 @@
'dependencies': [ 'dependencies': [
'src/common_audio/common_audio.gyp:*', 'src/common_audio/common_audio.gyp:*',
'src/common_video/common_video.gyp:*', 'src/common_video/common_video.gyp:*',
# TODO(andrew): enable when Linux-Release errors are fixed. 'src/modules/modules.gyp:*',
#'src/modules/modules.gyp:*',
'src/system_wrappers/source/system_wrappers.gyp:*', 'src/system_wrappers/source/system_wrappers.gyp:*',
'src/video_engine/video_engine.gyp:*', 'src/video_engine/video_engine.gyp:*',
'src/voice_engine/voice_engine.gyp:*', 'src/voice_engine/voice_engine.gyp:*',