WebRtc_Word32 -> int32_t in utility/
BUG=314 Review URL: https://webrtc-codereview.appspot.com/1307005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3797 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -25,7 +25,7 @@
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
FilePlayer* FilePlayer::CreateFilePlayer(WebRtc_UWord32 instanceID,
|
||||
FilePlayer* FilePlayer::CreateFilePlayer(uint32_t instanceID,
|
||||
FileFormats fileFormat)
|
||||
{
|
||||
switch(fileFormat)
|
||||
@ -57,7 +57,7 @@ void FilePlayer::DestroyFilePlayer(FilePlayer* player)
|
||||
delete player;
|
||||
}
|
||||
|
||||
FilePlayerImpl::FilePlayerImpl(const WebRtc_UWord32 instanceID,
|
||||
FilePlayerImpl::FilePlayerImpl(const uint32_t instanceID,
|
||||
const FileFormats fileFormat)
|
||||
: _instanceID(instanceID),
|
||||
_fileFormat(fileFormat),
|
||||
@ -78,7 +78,7 @@ FilePlayerImpl::~FilePlayerImpl()
|
||||
MediaFile::DestroyMediaFile(&_fileModule);
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::Frequency() const
|
||||
int32_t FilePlayerImpl::Frequency() const
|
||||
{
|
||||
if(_codec.plfreq == 0)
|
||||
{
|
||||
@ -108,13 +108,13 @@ WebRtc_Word32 FilePlayerImpl::Frequency() const
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::AudioCodec(CodecInst& audioCodec) const
|
||||
int32_t FilePlayerImpl::AudioCodec(CodecInst& audioCodec) const
|
||||
{
|
||||
audioCodec = _codec;
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
||||
int32_t FilePlayerImpl::Get10msAudioFromFile(
|
||||
int16_t* outBuffer,
|
||||
int& lengthInSamples,
|
||||
int frequencyInHz)
|
||||
@ -134,10 +134,10 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
||||
unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq;
|
||||
|
||||
// L16 is un-encoded data. Just pull 10 ms.
|
||||
WebRtc_UWord32 lengthInBytes =
|
||||
uint32_t lengthInBytes =
|
||||
sizeof(unresampledAudioFrame.data_);
|
||||
if (_fileModule.PlayoutAudioData(
|
||||
(WebRtc_Word8*)unresampledAudioFrame.data_,
|
||||
(int8_t*)unresampledAudioFrame.data_,
|
||||
lengthInBytes) == -1)
|
||||
{
|
||||
// End of file reached.
|
||||
@ -150,19 +150,19 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
||||
}
|
||||
// One sample is two bytes.
|
||||
unresampledAudioFrame.samples_per_channel_ =
|
||||
(WebRtc_UWord16)lengthInBytes >> 1;
|
||||
(uint16_t)lengthInBytes >> 1;
|
||||
|
||||
}else {
|
||||
// Decode will generate 10 ms of audio data. PlayoutAudioData(..)
|
||||
// expects a full frame. If the frame size is larger than 10 ms,
|
||||
// PlayoutAudioData(..) data should be called proportionally less often.
|
||||
WebRtc_Word16 encodedBuffer[MAX_AUDIO_BUFFER_IN_SAMPLES];
|
||||
WebRtc_UWord32 encodedLengthInBytes = 0;
|
||||
int16_t encodedBuffer[MAX_AUDIO_BUFFER_IN_SAMPLES];
|
||||
uint32_t encodedLengthInBytes = 0;
|
||||
if(++_numberOf10MsInDecoder >= _numberOf10MsPerFrame)
|
||||
{
|
||||
_numberOf10MsInDecoder = 0;
|
||||
WebRtc_UWord32 bytesFromFile = sizeof(encodedBuffer);
|
||||
if (_fileModule.PlayoutAudioData((WebRtc_Word8*)encodedBuffer,
|
||||
uint32_t bytesFromFile = sizeof(encodedBuffer);
|
||||
if (_fileModule.PlayoutAudioData((int8_t*)encodedBuffer,
|
||||
bytesFromFile) == -1)
|
||||
{
|
||||
// End of file reached.
|
||||
@ -171,7 +171,7 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
||||
encodedLengthInBytes = bytesFromFile;
|
||||
}
|
||||
if(_audioDecoder.Decode(unresampledAudioFrame,frequencyInHz,
|
||||
(WebRtc_Word8*)encodedBuffer,
|
||||
(int8_t*)encodedBuffer,
|
||||
encodedLengthInBytes) == -1)
|
||||
{
|
||||
return -1;
|
||||
@ -187,7 +187,7 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
||||
|
||||
// New sampling frequency. Update state.
|
||||
outLen = frequencyInHz / 100;
|
||||
memset(outBuffer, 0, outLen * sizeof(WebRtc_Word16));
|
||||
memset(outBuffer, 0, outLen * sizeof(int16_t));
|
||||
return 0;
|
||||
}
|
||||
_resampler.Push(unresampledAudioFrame.data_,
|
||||
@ -202,19 +202,19 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
||||
{
|
||||
for (int i = 0;i < outLen; i++)
|
||||
{
|
||||
outBuffer[i] = (WebRtc_Word16)(outBuffer[i] * _scaling);
|
||||
outBuffer[i] = (int16_t)(outBuffer[i] * _scaling);
|
||||
}
|
||||
}
|
||||
_decodedLengthInMS += 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::RegisterModuleFileCallback(FileCallback* callback)
|
||||
int32_t FilePlayerImpl::RegisterModuleFileCallback(FileCallback* callback)
|
||||
{
|
||||
return _fileModule.SetModuleFileCallback(callback);
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::SetAudioScaling(float scaleFactor)
|
||||
int32_t FilePlayerImpl::SetAudioScaling(float scaleFactor)
|
||||
{
|
||||
if((scaleFactor >= 0)&&(scaleFactor <= 2.0))
|
||||
{
|
||||
@ -226,13 +226,13 @@ WebRtc_Word32 FilePlayerImpl::SetAudioScaling(float scaleFactor)
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::StartPlayingFile(const char* fileName,
|
||||
bool loop,
|
||||
WebRtc_UWord32 startPosition,
|
||||
float volumeScaling,
|
||||
WebRtc_UWord32 notification,
|
||||
WebRtc_UWord32 stopPosition,
|
||||
const CodecInst* codecInst)
|
||||
int32_t FilePlayerImpl::StartPlayingFile(const char* fileName,
|
||||
bool loop,
|
||||
uint32_t startPosition,
|
||||
float volumeScaling,
|
||||
uint32_t notification,
|
||||
uint32_t stopPosition,
|
||||
const CodecInst* codecInst)
|
||||
{
|
||||
if (_fileFormat == kFileFormatPcm16kHzFile ||
|
||||
_fileFormat == kFileFormatPcm8kHzFile||
|
||||
@ -322,12 +322,12 @@ WebRtc_Word32 FilePlayerImpl::StartPlayingFile(const char* fileName,
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::StartPlayingFile(InStream& sourceStream,
|
||||
WebRtc_UWord32 startPosition,
|
||||
float volumeScaling,
|
||||
WebRtc_UWord32 notification,
|
||||
WebRtc_UWord32 stopPosition,
|
||||
const CodecInst* codecInst)
|
||||
int32_t FilePlayerImpl::StartPlayingFile(InStream& sourceStream,
|
||||
uint32_t startPosition,
|
||||
float volumeScaling,
|
||||
uint32_t notification,
|
||||
uint32_t stopPosition,
|
||||
const CodecInst* codecInst)
|
||||
{
|
||||
if (_fileFormat == kFileFormatPcm16kHzFile ||
|
||||
_fileFormat == kFileFormatPcm32kHzFile ||
|
||||
@ -415,7 +415,7 @@ WebRtc_Word32 FilePlayerImpl::StartPlayingFile(InStream& sourceStream,
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::StopPlayingFile()
|
||||
int32_t FilePlayerImpl::StopPlayingFile()
|
||||
{
|
||||
memset(&_codec, 0, sizeof(CodecInst));
|
||||
_numberOf10MsPerFrame = 0;
|
||||
@ -428,12 +428,12 @@ bool FilePlayerImpl::IsPlayingFile() const
|
||||
return _fileModule.IsPlaying();
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::GetPlayoutPosition(WebRtc_UWord32& durationMs)
|
||||
int32_t FilePlayerImpl::GetPlayoutPosition(uint32_t& durationMs)
|
||||
{
|
||||
return _fileModule.PlayoutPositionMs(durationMs);
|
||||
}
|
||||
|
||||
WebRtc_Word32 FilePlayerImpl::SetUpAudioDecoder()
|
||||
int32_t FilePlayerImpl::SetUpAudioDecoder()
|
||||
{
|
||||
if ((_fileModule.codec_info(_codec) == -1))
|
||||
{
|
||||
@ -462,7 +462,7 @@ WebRtc_Word32 FilePlayerImpl::SetUpAudioDecoder()
|
||||
}
|
||||
|
||||
#ifdef WEBRTC_MODULE_UTILITY_VIDEO
|
||||
VideoFilePlayerImpl::VideoFilePlayerImpl(WebRtc_UWord32 instanceID,
|
||||
VideoFilePlayerImpl::VideoFilePlayerImpl(uint32_t instanceID,
|
||||
FileFormats fileFormat)
|
||||
: FilePlayerImpl(instanceID,fileFormat),
|
||||
_videoDecoder(*new VideoCoder(instanceID)),
|
||||
@ -488,7 +488,7 @@ VideoFilePlayerImpl::~VideoFilePlayerImpl()
|
||||
delete &_encodedData;
|
||||
}
|
||||
|
||||
WebRtc_Word32 VideoFilePlayerImpl::StartPlayingVideoFile(
|
||||
int32_t VideoFilePlayerImpl::StartPlayingVideoFile(
|
||||
const char* fileName,
|
||||
bool loop,
|
||||
bool videoOnly)
|
||||
@ -525,7 +525,7 @@ WebRtc_Word32 VideoFilePlayerImpl::StartPlayingVideoFile(
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 VideoFilePlayerImpl::StopPlayingFile()
|
||||
int32_t VideoFilePlayerImpl::StopPlayingFile()
|
||||
{
|
||||
CriticalSectionScoped lock( _critSec);
|
||||
|
||||
@ -535,13 +535,13 @@ WebRtc_Word32 VideoFilePlayerImpl::StopPlayingFile()
|
||||
return FilePlayerImpl::StopPlayingFile();
|
||||
}
|
||||
|
||||
WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame,
|
||||
WebRtc_UWord32 outWidth,
|
||||
WebRtc_UWord32 outHeight)
|
||||
int32_t VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame,
|
||||
uint32_t outWidth,
|
||||
uint32_t outHeight)
|
||||
{
|
||||
CriticalSectionScoped lock( _critSec);
|
||||
|
||||
WebRtc_Word32 retVal = GetVideoFromFile(videoFrame);
|
||||
int32_t retVal = GetVideoFromFile(videoFrame);
|
||||
if(retVal != 0)
|
||||
{
|
||||
return retVal;
|
||||
@ -554,7 +554,7 @@ WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame,
|
||||
return retVal;
|
||||
}
|
||||
|
||||
WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
||||
int32_t VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
||||
{
|
||||
CriticalSectionScoped lock( _critSec);
|
||||
// No new video data read from file.
|
||||
@ -563,7 +563,7 @@ WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
||||
videoFrame.ResetSize();
|
||||
return -1;
|
||||
}
|
||||
WebRtc_Word32 retVal = 0;
|
||||
int32_t retVal = 0;
|
||||
if(strncmp(video_codec_info_.plName, "I420", 5) == 0)
|
||||
{
|
||||
int size_y = video_codec_info_.width * video_codec_info_.height;
|
||||
@ -588,7 +588,7 @@ WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
||||
retVal = _videoDecoder.Decode(videoFrame, _encodedData);
|
||||
}
|
||||
|
||||
WebRtc_Word64 renderTimeMs = TickTime::MillisecondTimestamp();
|
||||
int64_t renderTimeMs = TickTime::MillisecondTimestamp();
|
||||
videoFrame.set_render_time_ms(renderTimeMs);
|
||||
|
||||
// Indicate that the current frame in the encoded buffer is old/has
|
||||
@ -601,7 +601,7 @@ WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
WebRtc_Word32 VideoFilePlayerImpl::video_codec_info(
|
||||
int32_t VideoFilePlayerImpl::video_codec_info(
|
||||
VideoCodec& videoCodec) const
|
||||
{
|
||||
if(video_codec_info_.plName[0] == 0)
|
||||
@ -612,7 +612,7 @@ WebRtc_Word32 VideoFilePlayerImpl::video_codec_info(
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
||||
int32_t VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
||||
{
|
||||
if(_fileFormat != kFileFormatAviFile)
|
||||
{
|
||||
@ -630,9 +630,9 @@ WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
||||
if(_fileFormat == kFileFormatAviFile)
|
||||
{
|
||||
// Get next video frame
|
||||
WebRtc_UWord32 encodedBufferLengthInBytes = _encodedData.bufferSize;
|
||||
uint32_t encodedBufferLengthInBytes = _encodedData.bufferSize;
|
||||
if(_fileModule.PlayoutAVIVideoData(
|
||||
reinterpret_cast< WebRtc_Word8*>(_encodedData.payloadData),
|
||||
reinterpret_cast< int8_t*>(_encodedData.payloadData),
|
||||
encodedBufferLengthInBytes) != 0)
|
||||
{
|
||||
WEBRTC_TRACE(
|
||||
@ -659,7 +659,7 @@ WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
||||
// Frame rate is in frames per seconds. Frame length is
|
||||
// calculated as an integer division which means it may
|
||||
// be rounded down. Compensate for this every second.
|
||||
WebRtc_UWord32 rest = 1000%_frameLengthMS;
|
||||
uint32_t rest = 1000%_frameLengthMS;
|
||||
_accumulatedRenderTimeMs += rest;
|
||||
}
|
||||
_accumulatedRenderTimeMs += _frameLengthMS;
|
||||
@ -667,7 +667,7 @@ WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word64 timeToNextFrame;
|
||||
int64_t timeToNextFrame;
|
||||
if(_videoOnly)
|
||||
{
|
||||
timeToNextFrame = _accumulatedRenderTimeMs -
|
||||
@ -686,10 +686,10 @@ WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
||||
// Wraparound or audio stream has gone to far ahead of the video stream.
|
||||
return -1;
|
||||
}
|
||||
return static_cast<WebRtc_Word32>(timeToNextFrame);
|
||||
return static_cast<int32_t>(timeToNextFrame);
|
||||
}
|
||||
|
||||
WebRtc_Word32 VideoFilePlayerImpl::SetUpVideoDecoder()
|
||||
int32_t VideoFilePlayerImpl::SetUpVideoDecoder()
|
||||
{
|
||||
if (_fileModule.VideoCodecInst(video_codec_info_) != 0)
|
||||
{
|
||||
@ -702,7 +702,7 @@ WebRtc_Word32 VideoFilePlayerImpl::SetUpVideoDecoder()
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 useNumberOfCores = 1;
|
||||
int32_t useNumberOfCores = 1;
|
||||
if(_videoDecoder.SetDecodeCodec(video_codec_info_, useNumberOfCores) != 0)
|
||||
{
|
||||
WEBRTC_TRACE(
|
||||
@ -718,7 +718,7 @@ WebRtc_Word32 VideoFilePlayerImpl::SetUpVideoDecoder()
|
||||
|
||||
// Size of unencoded data (I420) should be the largest possible frame size
|
||||
// in a file.
|
||||
const WebRtc_UWord32 KReadBufferSize = 3 * video_codec_info_.width *
|
||||
const uint32_t KReadBufferSize = 3 * video_codec_info_.width *
|
||||
video_codec_info_.height / 2;
|
||||
_encodedData.VerifyAndAllocate(KReadBufferSize);
|
||||
_encodedData.encodedHeight = video_codec_info_.height;
|
||||
|
||||
Reference in New Issue
Block a user