From 0ea11c1768005b0b496d01ac9b5e9d3790131317 Mon Sep 17 00:00:00 2001 From: "pbos@webrtc.org" Date: Tue, 9 Apr 2013 13:31:37 +0000 Subject: [PATCH] WebRtc_Word32 -> int32_t in media_file/ BUG=314 Review URL: https://webrtc-codereview.appspot.com/1304005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3796 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/media_file/interface/media_file.h | 88 ++-- .../media_file/interface/media_file_defines.h | 12 +- webrtc/modules/media_file/source/avi_file.cc | 330 +++++++------- webrtc/modules/media_file/source/avi_file.h | 251 +++++----- .../media_file/source/media_file_impl.cc | 183 ++++---- .../media_file/source/media_file_impl.h | 139 +++--- .../media_file/source/media_file_utility.cc | 431 +++++++++--------- .../media_file/source/media_file_utility.h | 194 ++++---- 8 files changed, 805 insertions(+), 823 deletions(-) diff --git a/webrtc/modules/media_file/interface/media_file.h b/webrtc/modules/media_file/interface/media_file.h index ea10d82d0f..78dcf92736 100644 --- a/webrtc/modules/media_file/interface/media_file.h +++ b/webrtc/modules/media_file/interface/media_file.h @@ -23,11 +23,11 @@ class MediaFile : public Module public: // Factory method. Constructor disabled. id is the identifier for the // MediaFile instance. - static MediaFile* CreateMediaFile(const WebRtc_Word32 id); + static MediaFile* CreateMediaFile(const int32_t id); static void DestroyMediaFile(MediaFile* module); // Set the MediaFile instance identifier. - virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id) = 0; + virtual int32_t ChangeUniqueId(const int32_t id) = 0; // Put 10-60ms of audio data from file into the audioBuffer depending on // codec frame size. dataLengthInBytes is both an input and output @@ -37,17 +37,17 @@ public: // Note: This API only play mono audio but can be used on file containing // audio with more channels (in which case the audio will be converted to // mono). - virtual WebRtc_Word32 PlayoutAudioData( - WebRtc_Word8* audioBuffer, - WebRtc_UWord32& dataLengthInBytes) = 0; + virtual int32_t PlayoutAudioData( + int8_t* audioBuffer, + uint32_t& dataLengthInBytes) = 0; // Put one video frame into videoBuffer. dataLengthInBytes is both an input // and output parameter. As input parameter it indicates the size of // videoBuffer. As output parameter it indicates the number of bytes written // to videoBuffer. - virtual WebRtc_Word32 PlayoutAVIVideoData( - WebRtc_Word8* videoBuffer, - WebRtc_UWord32& dataLengthInBytes) = 0; + virtual int32_t PlayoutAVIVideoData( + int8_t* videoBuffer, + uint32_t& dataLengthInBytes) = 0; // Put 10-60ms, depending on codec frame size, of audio data from file into // audioBufferLeft and audioBufferRight. The buffers contain the left and @@ -58,10 +58,10 @@ public: // written to both audio buffers. // Note: This API can only be successfully called for WAV files with stereo // audio. - virtual WebRtc_Word32 PlayoutStereoData( - WebRtc_Word8* audioBufferLeft, - WebRtc_Word8* audioBufferRight, - WebRtc_UWord32& dataLengthInBytes) = 0; + virtual int32_t PlayoutStereoData( + int8_t* audioBufferLeft, + int8_t* audioBufferRight, + uint32_t& dataLengthInBytes) = 0; // Open the file specified by fileName (relative path is allowed) for // reading. FileCallback::PlayNotification(..) will be called after @@ -76,21 +76,21 @@ public: // stopPointMs ms. // Note: codecInst.channels should be set to 2 for stereo (and 1 for // mono). Stereo audio is only supported for WAV files. - virtual WebRtc_Word32 StartPlayingAudioFile( + virtual int32_t StartPlayingAudioFile( const char* fileName, - const WebRtc_UWord32 notificationTimeMs = 0, + const uint32_t notificationTimeMs = 0, const bool loop = false, const FileFormats format = kFileFormatPcm16kHzFile, const CodecInst* codecInst = NULL, - const WebRtc_UWord32 startPointMs = 0, - const WebRtc_UWord32 stopPointMs = 0) = 0; + const uint32_t startPointMs = 0, + const uint32_t stopPointMs = 0) = 0; // Open the file specified by fileName for reading (relative path is // allowed). If loop is true the file will be played until StopPlaying() is // called. When end of file is reached the file is read from the start. // format specifies the type of file fileName refers to. Only video will be // read if videoOnly is true. - virtual WebRtc_Word32 StartPlayingVideoFile(const char* fileName, + virtual int32_t StartPlayingVideoFile(const char* fileName, const bool loop, bool videoOnly, const FileFormats format) = 0; @@ -106,32 +106,32 @@ public: // stopPointMs ms. // Note: codecInst.channels should be set to 2 for stereo (and 1 for // mono). Stereo audio is only supported for WAV files. - virtual WebRtc_Word32 StartPlayingAudioStream( + virtual int32_t StartPlayingAudioStream( InStream& stream, - const WebRtc_UWord32 notificationTimeMs = 0, + const uint32_t notificationTimeMs = 0, const FileFormats format = kFileFormatPcm16kHzFile, const CodecInst* codecInst = NULL, - const WebRtc_UWord32 startPointMs = 0, - const WebRtc_UWord32 stopPointMs = 0) = 0; + const uint32_t startPointMs = 0, + const uint32_t stopPointMs = 0) = 0; // Stop playing from file or stream. - virtual WebRtc_Word32 StopPlaying() = 0; + virtual int32_t StopPlaying() = 0; // Return true if playing. virtual bool IsPlaying() = 0; // Set durationMs to the number of ms that has been played from file. - virtual WebRtc_Word32 PlayoutPositionMs( - WebRtc_UWord32& durationMs) const = 0; + virtual int32_t PlayoutPositionMs( + uint32_t& durationMs) const = 0; // Write one audio frame, i.e. the bufferLength first bytes of audioBuffer, // to file. The audio frame size is determined by the codecInst.pacsize // parameter of the last sucessfull StartRecordingAudioFile(..) call. // Note: bufferLength must be exactly one frame. - virtual WebRtc_Word32 IncomingAudioData( - const WebRtc_Word8* audioBuffer, - const WebRtc_UWord32 bufferLength) = 0; + virtual int32_t IncomingAudioData( + const int8_t* audioBuffer, + const uint32_t bufferLength) = 0; // Write one video frame, i.e. the bufferLength first bytes of videoBuffer, // to file. @@ -139,9 +139,9 @@ public: // same as what was specified by videoCodecInst for the last successfull // StartRecordingVideoFile(..) call. The videoBuffer must contain exactly // one video frame. - virtual WebRtc_Word32 IncomingAVIVideoData( - const WebRtc_Word8* videoBuffer, - const WebRtc_UWord32 bufferLength) = 0; + virtual int32_t IncomingAVIVideoData( + const int8_t* videoBuffer, + const uint32_t bufferLength) = 0; // Open/creates file specified by fileName for writing (relative path is // allowed). FileCallback::RecordNotification(..) will be called after @@ -153,19 +153,19 @@ public: // greater than zero. // Note: codecInst.channels should be set to 2 for stereo (and 1 for // mono). Stereo is only supported for WAV files. - virtual WebRtc_Word32 StartRecordingAudioFile( + virtual int32_t StartRecordingAudioFile( const char* fileName, const FileFormats format, const CodecInst& codecInst, - const WebRtc_UWord32 notificationTimeMs = 0, - const WebRtc_UWord32 maxSizeBytes = 0) = 0; + const uint32_t notificationTimeMs = 0, + const uint32_t maxSizeBytes = 0) = 0; // Open/create the file specified by fileName for writing audio/video data // (relative path is allowed). format specifies the type of file fileName // should be. codecInst specifies the encoding of the audio data. // videoCodecInst specifies the encoding of the video data. Only video data // will be recorded if videoOnly is true. - virtual WebRtc_Word32 StartRecordingVideoFile( + virtual int32_t StartRecordingVideoFile( const char* fileName, const FileFormats format, const CodecInst& codecInst, @@ -180,44 +180,44 @@ public: // codecInst specifies the encoding of the audio data. // Note: codecInst.channels should be set to 2 for stereo (and 1 for // mono). Stereo is only supported for WAV files. - virtual WebRtc_Word32 StartRecordingAudioStream( + virtual int32_t StartRecordingAudioStream( OutStream& stream, const FileFormats format, const CodecInst& codecInst, - const WebRtc_UWord32 notificationTimeMs = 0) = 0; + const uint32_t notificationTimeMs = 0) = 0; // Stop recording to file or stream. - virtual WebRtc_Word32 StopRecording() = 0; + virtual int32_t StopRecording() = 0; // Return true if recording. virtual bool IsRecording() = 0; // Set durationMs to the number of ms that has been recorded to file. - virtual WebRtc_Word32 RecordDurationMs(WebRtc_UWord32& durationMs) = 0; + virtual int32_t RecordDurationMs(uint32_t& durationMs) = 0; // Return true if recording or playing is stereo. virtual bool IsStereo() = 0; // Register callback to receive media file related notifications. Disables // callbacks if callback is NULL. - virtual WebRtc_Word32 SetModuleFileCallback(FileCallback* callback) = 0; + virtual int32_t SetModuleFileCallback(FileCallback* callback) = 0; // Set durationMs to the size of the file (in ms) specified by fileName. // format specifies the type of file fileName refers to. freqInHz specifies // the sampling frequency of the file. - virtual WebRtc_Word32 FileDurationMs( + virtual int32_t FileDurationMs( const char* fileName, - WebRtc_UWord32& durationMs, + uint32_t& durationMs, const FileFormats format, - const WebRtc_UWord32 freqInHz = 16000) = 0; + const uint32_t freqInHz = 16000) = 0; // Update codecInst according to the current audio codec being used for // reading or writing. - virtual WebRtc_Word32 codec_info(CodecInst& codecInst) const = 0; + virtual int32_t codec_info(CodecInst& codecInst) const = 0; // Update videoCodecInst according to the current video codec being used for // reading or writing. - virtual WebRtc_Word32 VideoCodecInst(VideoCodec& videoCodecInst) const = 0; + virtual int32_t VideoCodecInst(VideoCodec& videoCodecInst) const = 0; protected: MediaFile() {} diff --git a/webrtc/modules/media_file/interface/media_file_defines.h b/webrtc/modules/media_file/interface/media_file_defines.h index 38af562b95..d3093019f2 100644 --- a/webrtc/modules/media_file/interface/media_file_defines.h +++ b/webrtc/modules/media_file/interface/media_file_defines.h @@ -25,24 +25,24 @@ public: // This function is called by MediaFile when a file has been playing for // durationMs ms. id is the identifier for the MediaFile instance calling // the callback. - virtual void PlayNotification(const WebRtc_Word32 id, - const WebRtc_UWord32 durationMs) = 0; + virtual void PlayNotification(const int32_t id, + const uint32_t durationMs) = 0; // This function is called by MediaFile when a file has been recording for // durationMs ms. id is the identifier for the MediaFile instance calling // the callback. - virtual void RecordNotification(const WebRtc_Word32 id, - const WebRtc_UWord32 durationMs) = 0; + virtual void RecordNotification(const int32_t id, + const uint32_t durationMs) = 0; // This function is called by MediaFile when a file has been stopped // playing. id is the identifier for the MediaFile instance calling the // callback. - virtual void PlayFileEnded(const WebRtc_Word32 id) = 0; + virtual void PlayFileEnded(const int32_t id) = 0; // This function is called by MediaFile when a file has been stopped // recording. id is the identifier for the MediaFile instance calling the // callback. - virtual void RecordFileEnded(const WebRtc_Word32 id) = 0; + virtual void RecordFileEnded(const int32_t id) = 0; protected: FileCallback() {} diff --git a/webrtc/modules/media_file/source/avi_file.cc b/webrtc/modules/media_file/source/avi_file.cc index 3b6d778fc8..b3830731df 100644 --- a/webrtc/modules/media_file/source/avi_file.cc +++ b/webrtc/modules/media_file/source/avi_file.cc @@ -44,11 +44,11 @@ namespace webrtc { namespace { -static const WebRtc_UWord32 kAvifHasindex = 0x00000010; -static const WebRtc_UWord32 kAvifMustuseindex = 0x00000020; -static const WebRtc_UWord32 kAvifIsinterleaved = 0x00000100; -static const WebRtc_UWord32 kAvifTrustcktype = 0x00000800; -static const WebRtc_UWord32 kAvifWascapturefile = 0x00010000; +static const uint32_t kAvifHasindex = 0x00000010; +static const uint32_t kAvifMustuseindex = 0x00000020; +static const uint32_t kAvifIsinterleaved = 0x00000100; +static const uint32_t kAvifTrustcktype = 0x00000800; +static const uint32_t kAvifWascapturefile = 0x00010000; template T MinValue(T a, T b) @@ -126,10 +126,10 @@ WAVEFORMATEX::WAVEFORMATEX() { } -AviFile::AVIINDEXENTRY::AVIINDEXENTRY(WebRtc_UWord32 inckid, - WebRtc_UWord32 indwFlags, - WebRtc_UWord32 indwChunkOffset, - WebRtc_UWord32 indwChunkLength) +AviFile::AVIINDEXENTRY::AVIINDEXENTRY(uint32_t inckid, + uint32_t indwFlags, + uint32_t indwChunkOffset, + uint32_t indwChunkLength) : ckid(inckid), dwFlags(indwFlags), dwChunkOffset(indwChunkOffset), @@ -193,8 +193,7 @@ AviFile::~AviFile() delete _crit; } -WebRtc_Word32 AviFile::Open(AVIStreamType streamType, const char* fileName, - bool loop) +int32_t AviFile::Open(AVIStreamType streamType, const char* fileName, bool loop) { WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, -1, "OpenAVIFile(%s)", fileName); @@ -235,7 +234,7 @@ WebRtc_Word32 AviFile::Open(AVIStreamType streamType, const char* fileName, } // ReadRIFF verifies that the file is AVI and figures out the file length. - WebRtc_Word32 err = ReadRIFF(); + int32_t err = ReadRIFF(); if (err) { if (_aviFile) @@ -269,7 +268,7 @@ WebRtc_Word32 AviFile::Open(AVIStreamType streamType, const char* fileName, return 0; } -WebRtc_Word32 AviFile::Close() +int32_t AviFile::Close() { _crit->Enter(); switch (_aviMode) @@ -294,19 +293,18 @@ WebRtc_Word32 AviFile::Close() return 0; } -WebRtc_UWord32 AviFile::MakeFourCc(WebRtc_UWord8 ch0, WebRtc_UWord8 ch1, - WebRtc_UWord8 ch2, WebRtc_UWord8 ch3) +uint32_t AviFile::MakeFourCc(uint8_t ch0, uint8_t ch1, uint8_t ch2, uint8_t ch3) { - return ((WebRtc_UWord32)(WebRtc_UWord8)(ch0) | - ((WebRtc_UWord32)(WebRtc_UWord8)(ch1) << 8) | - ((WebRtc_UWord32)(WebRtc_UWord8)(ch2) << 16) | - ((WebRtc_UWord32)(WebRtc_UWord8)(ch3) << 24 )); + return ((uint32_t)(uint8_t)(ch0) | + ((uint32_t)(uint8_t)(ch1) << 8) | + ((uint32_t)(uint8_t)(ch2) << 16) | + ((uint32_t)(uint8_t)(ch3) << 24 )); } -WebRtc_Word32 AviFile::GetVideoStreamInfo(AVISTREAMHEADER& videoStreamHeader, - BITMAPINFOHEADER& bitmapInfo, - char* codecConfigParameters, - WebRtc_Word32& configLength) +int32_t AviFile::GetVideoStreamInfo(AVISTREAMHEADER& videoStreamHeader, + BITMAPINFOHEADER& bitmapInfo, + char* codecConfigParameters, + int32_t& configLength) { _crit->Enter(); if (!_reading && !_created) @@ -332,7 +330,7 @@ WebRtc_Word32 AviFile::GetVideoStreamInfo(AVISTREAMHEADER& videoStreamHeader, return 0; } -WebRtc_Word32 AviFile::GetDuration(WebRtc_Word32& durationMs) +int32_t AviFile::GetDuration(int32_t& durationMs) { _crit->Enter(); if (_videoStreamHeader.dwRate==0 || _videoStreamHeader.dwScale==0) @@ -347,7 +345,7 @@ WebRtc_Word32 AviFile::GetDuration(WebRtc_Word32& durationMs) return 0; } -WebRtc_Word32 AviFile::GetAudioStreamInfo(WAVEFORMATEX& waveHeader) +int32_t AviFile::GetAudioStreamInfo(WAVEFORMATEX& waveHeader) { _crit->Enter(); if (_aviMode != Read) @@ -365,8 +363,7 @@ WebRtc_Word32 AviFile::GetAudioStreamInfo(WAVEFORMATEX& waveHeader) return 0; } -WebRtc_Word32 AviFile::WriteAudio(const WebRtc_UWord8* data, - WebRtc_Word32 length) +int32_t AviFile::WriteAudio(const uint8_t* data, int32_t length) { _crit->Enter(); size_t newBytesWritten = _bytesWritten; @@ -388,7 +385,7 @@ WebRtc_Word32 AviFile::WriteAudio(const WebRtc_UWord8* data, } // Start of chunk. - const WebRtc_UWord32 chunkOffset = ftell(_aviFile) - _moviListOffset; + const uint32_t chunkOffset = ftell(_aviFile) - _moviListOffset; _bytesWritten += PutLE32(_audioStreamDataChunkPrefix); // Size is unknown at this point. Update later. _bytesWritten += PutLE32(0); @@ -413,11 +410,10 @@ WebRtc_Word32 AviFile::WriteAudio(const WebRtc_UWord8* data, ++_audioFrames; newBytesWritten = _bytesWritten - newBytesWritten; _crit->Leave(); - return static_cast(newBytesWritten); + return static_cast(newBytesWritten); } -WebRtc_Word32 AviFile::WriteVideo(const WebRtc_UWord8* data, - WebRtc_Word32 length) +int32_t AviFile::WriteVideo(const uint8_t* data, int32_t length) { _crit->Enter(); size_t newBytesWritten = _bytesWritten; @@ -438,7 +434,7 @@ WebRtc_Word32 AviFile::WriteVideo(const WebRtc_UWord8* data, } // Start of chunk. - const WebRtc_UWord32 chunkOffset = ftell(_aviFile) - _moviListOffset; + const uint32_t chunkOffset = ftell(_aviFile) - _moviListOffset; _bytesWritten += PutLE32(_videoStreamDataChunkPrefix); // Size is unknown at this point. Update later. _bytesWritten += PutLE32(0); @@ -457,15 +453,15 @@ WebRtc_Word32 AviFile::WriteVideo(const WebRtc_UWord8* data, } //End chunk! AddChunkToIndexList(_videoStreamDataChunkPrefix, 0, // No flags. - chunkOffset, static_cast(chunkSize)); + chunkOffset, static_cast(chunkSize)); ++_videoFrames; newBytesWritten = _bytesWritten - newBytesWritten; _crit->Leave(); - return static_cast(newBytesWritten); + return static_cast(newBytesWritten); } -WebRtc_Word32 AviFile::PrepareDataChunkHeaders() +int32_t AviFile::PrepareDataChunkHeaders() { // 00 video stream, 01 audio stream. // db uncompresses video, dc compressed video, wb WAV audio @@ -489,10 +485,8 @@ WebRtc_Word32 AviFile::PrepareDataChunkHeaders() return 0; } -WebRtc_Word32 AviFile::ReadMoviSubChunk(WebRtc_UWord8* data, - WebRtc_Word32& length, - WebRtc_UWord32 tag1, - WebRtc_UWord32 tag2) +int32_t AviFile::ReadMoviSubChunk(uint8_t* data, int32_t& length, uint32_t tag1, + uint32_t tag2) { if (!_reading) { @@ -502,7 +496,7 @@ WebRtc_Word32 AviFile::ReadMoviSubChunk(WebRtc_UWord8* data, return -1; } - WebRtc_UWord32 size; + uint32_t size; bool isEOFReached = false; // Try to read one data chunk header while (true) @@ -511,11 +505,11 @@ WebRtc_Word32 AviFile::ReadMoviSubChunk(WebRtc_UWord8* data, // _loop set to true? Seems like this while-loop would never exit! // tag = db uncompresses video, dc compressed video or wb WAV audio. - WebRtc_UWord32 tag; + uint32_t tag; _bytesRead += GetLE32(tag); _bytesRead += GetLE32(size); - const WebRtc_Word32 eof = feof(_aviFile); + const int32_t eof = feof(_aviFile); if (!eof) { if (tag == tag1) @@ -531,8 +525,8 @@ WebRtc_Word32 AviFile::ReadMoviSubChunk(WebRtc_UWord8* data, // Jump to next chunk. The size is in bytes but chunks are aligned // on 2 byte boundaries. - const WebRtc_UWord32 seekSize = (size % 2) ? size + 1 : size; - const WebRtc_Word32 err = fseek(_aviFile, seekSize, SEEK_CUR); + const uint32_t seekSize = (size % 2) ? size + 1 : size; + const int32_t err = fseek(_aviFile, seekSize, SEEK_CUR); if (err) { @@ -572,14 +566,14 @@ WebRtc_Word32 AviFile::ReadMoviSubChunk(WebRtc_UWord8* data, _bytesRead += size; } - if (static_cast(size) > length) + if (static_cast(size) > length) { WEBRTC_TRACE(kTraceDebug, kTraceVideo, -1, "AviFile::ReadMoviSubChunk(): AVI read buffer too small!"); // Jump to next chunk. The size is in bytes but chunks are aligned // on 2 byte boundaries. - const WebRtc_UWord32 seekSize = (size % 2) ? size + 1 : size; + const uint32_t seekSize = (size % 2) ? size + 1 : size; fseek(_aviFile, seekSize, SEEK_CUR); _bytesRead += seekSize; length = 0; @@ -590,7 +584,7 @@ WebRtc_Word32 AviFile::ReadMoviSubChunk(WebRtc_UWord8* data, // The size is in bytes but chunks are aligned on 2 byte boundaries. if (size % 2) { - WebRtc_UWord8 dummy_byte; + uint8_t dummy_byte; _bytesRead += GetByte(dummy_byte); } length = size; @@ -598,7 +592,7 @@ WebRtc_Word32 AviFile::ReadMoviSubChunk(WebRtc_UWord8* data, return 0; } -WebRtc_Word32 AviFile::ReadAudio(WebRtc_UWord8* data, WebRtc_Word32& length) +int32_t AviFile::ReadAudio(uint8_t* data, int32_t& length) { _crit->Enter(); WEBRTC_TRACE(kTraceDebug, kTraceVideo, -1, "AviFile::ReadAudio()"); @@ -616,7 +610,7 @@ WebRtc_Word32 AviFile::ReadAudio(WebRtc_UWord8* data, WebRtc_Word32& length) return -1; } - const WebRtc_Word32 ret = ReadMoviSubChunk( + const int32_t ret = ReadMoviSubChunk( data, length, StreamAndTwoCharCodeToTag(_audioStream.streamNumber, "wb")); @@ -625,7 +619,7 @@ WebRtc_Word32 AviFile::ReadAudio(WebRtc_UWord8* data, WebRtc_Word32& length) return ret; } -WebRtc_Word32 AviFile::ReadVideo(WebRtc_UWord8* data, WebRtc_Word32& length) +int32_t AviFile::ReadVideo(uint8_t* data, int32_t& length) { WEBRTC_TRACE(kTraceDebug, kTraceVideo, -1, "AviFile::ReadVideo()"); @@ -644,7 +638,7 @@ WebRtc_Word32 AviFile::ReadVideo(WebRtc_UWord8* data, WebRtc_Word32& length) return -1; } - const WebRtc_Word32 ret = ReadMoviSubChunk( + const int32_t ret = ReadMoviSubChunk( data, length, StreamAndTwoCharCodeToTag(_videoStream.streamNumber, "dc"), @@ -653,7 +647,7 @@ WebRtc_Word32 AviFile::ReadVideo(WebRtc_UWord8* data, WebRtc_Word32& length) return ret; } -WebRtc_Word32 AviFile::Create(const char* fileName) +int32_t AviFile::Create(const char* fileName) { _crit->Enter(); if (_aviMode != Write) @@ -709,11 +703,11 @@ WebRtc_Word32 AviFile::Create(const char* fileName) return 0; } -WebRtc_Word32 AviFile::CreateVideoStream( +int32_t AviFile::CreateVideoStream( const AVISTREAMHEADER& videoStreamHeader, const BITMAPINFOHEADER& bitMapInfoHeader, - const WebRtc_UWord8* codecConfigParams, - WebRtc_Word32 codecConfigParamsLength) + const uint8_t* codecConfigParams, + int32_t codecConfigParamsLength) { _crit->Enter(); if (_aviMode == Read) @@ -742,7 +736,7 @@ WebRtc_Word32 AviFile::CreateVideoStream( _videoCodecConfigParams = 0; } - _videoCodecConfigParams = new WebRtc_UWord8[codecConfigParamsLength]; + _videoCodecConfigParams = new uint8_t[codecConfigParamsLength]; _videoCodecConfigParamsLength = codecConfigParamsLength; memcpy(_videoCodecConfigParams, codecConfigParams, @@ -752,7 +746,7 @@ WebRtc_Word32 AviFile::CreateVideoStream( return 0; } -WebRtc_Word32 AviFile::CreateAudioStream( +int32_t AviFile::CreateAudioStream( const AVISTREAMHEADER& audioStreamHeader, const WAVEFORMATEX& waveFormatHeader) { @@ -778,33 +772,33 @@ WebRtc_Word32 AviFile::CreateAudioStream( return 0; } -WebRtc_Word32 AviFile::WriteRIFF() +int32_t AviFile::WriteRIFF() { - const WebRtc_UWord32 riffTag = MakeFourCc('R', 'I', 'F', 'F'); + const uint32_t riffTag = MakeFourCc('R', 'I', 'F', 'F'); _bytesWritten += PutLE32(riffTag); // Size is unknown at this point. Update later. _bytesWritten += PutLE32(0); _riffSizeMark = _bytesWritten; - const WebRtc_UWord32 aviTag = MakeFourCc('A', 'V', 'I', ' '); + const uint32_t aviTag = MakeFourCc('A', 'V', 'I', ' '); _bytesWritten += PutLE32(aviTag); return 0; } -WebRtc_Word32 AviFile::WriteHeaders() +int32_t AviFile::WriteHeaders() { // Main AVI header list. - const WebRtc_UWord32 listTag = MakeFourCc('L', 'I', 'S', 'T'); + const uint32_t listTag = MakeFourCc('L', 'I', 'S', 'T'); _bytesWritten += PutLE32(listTag); // Size is unknown at this point. Update later. _bytesWritten += PutLE32(0); const size_t listhdrlSizeMark = _bytesWritten; - const WebRtc_UWord32 hdrlTag = MakeFourCc('h', 'd', 'r', 'l'); + const uint32_t hdrlTag = MakeFourCc('h', 'd', 'r', 'l'); _bytesWritten += PutLE32(hdrlTag); WriteAVIMainHeader(); @@ -814,13 +808,13 @@ WebRtc_Word32 AviFile::WriteHeaders() static_cast(listhdrlSizeMark)); // Junk chunk to align on 2048 boundry (CD-ROM sector boundary). - const WebRtc_UWord32 junkTag = MakeFourCc('J', 'U', 'N', 'K'); + const uint32_t junkTag = MakeFourCc('J', 'U', 'N', 'K'); _bytesWritten += PutLE32(junkTag); // Size is unknown at this point. Update later. _bytesWritten += PutLE32(0); const size_t junkSizeMark = _bytesWritten; - const WebRtc_UWord32 junkBufferSize = + const uint32_t junkBufferSize = 0x800 // 2048 byte alignment - 12 // RIFF SIZE 'AVI ' - 8 // LIST SIZE @@ -829,7 +823,7 @@ WebRtc_Word32 AviFile::WriteHeaders() - 12; // LIST SIZE 'MOVI' // TODO (hellner): why not just fseek here? - WebRtc_UWord8* junkBuffer = new WebRtc_UWord8[junkBufferSize]; + uint8_t* junkBuffer = new uint8_t[junkBufferSize]; memset(junkBuffer, 0, junkBufferSize); _bytesWritten += PutBuffer(junkBuffer, junkBufferSize); delete [] junkBuffer; @@ -840,21 +834,21 @@ WebRtc_Word32 AviFile::WriteHeaders() return 0; } -WebRtc_Word32 AviFile::WriteAVIMainHeader() +int32_t AviFile::WriteAVIMainHeader() { - const WebRtc_UWord32 avihTag = MakeFourCc('a', 'v', 'i', 'h'); + const uint32_t avihTag = MakeFourCc('a', 'v', 'i', 'h'); _bytesWritten += PutLE32(avihTag); - _bytesWritten += PutLE32(14 * sizeof(WebRtc_UWord32)); + _bytesWritten += PutLE32(14 * sizeof(uint32_t)); - const WebRtc_UWord32 scale = _videoStreamHeader.dwScale ? + const uint32_t scale = _videoStreamHeader.dwScale ? _videoStreamHeader.dwScale : 1; - const WebRtc_UWord32 microSecPerFrame = 1000000 / + const uint32_t microSecPerFrame = 1000000 / (_videoStreamHeader.dwRate / scale); _bytesWritten += PutLE32(microSecPerFrame); _bytesWritten += PutLE32(0); _bytesWritten += PutLE32(0); - WebRtc_UWord32 numStreams = 0; + uint32_t numStreams = 0; if (_writeVideoStream) { ++numStreams; @@ -905,7 +899,7 @@ WebRtc_Word32 AviFile::WriteAVIMainHeader() return 0; } -WebRtc_Word32 AviFile::WriteAVIStreamHeaders() +int32_t AviFile::WriteAVIStreamHeaders() { if (_writeVideoStream) { @@ -918,16 +912,16 @@ WebRtc_Word32 AviFile::WriteAVIStreamHeaders() return 0; } -WebRtc_Word32 AviFile::WriteAVIVideoStreamHeaders() +int32_t AviFile::WriteAVIVideoStreamHeaders() { - const WebRtc_UWord32 listTag = MakeFourCc('L', 'I', 'S', 'T'); + const uint32_t listTag = MakeFourCc('L', 'I', 'S', 'T'); _bytesWritten += PutLE32(listTag); // Size is unknown at this point. Update later. _bytesWritten += PutLE32(0); const size_t liststrlSizeMark = _bytesWritten; - const WebRtc_UWord32 hdrlTag = MakeFourCc('s', 't', 'r', 'l'); + const uint32_t hdrlTag = MakeFourCc('s', 't', 'r', 'l'); _bytesWritten += PutLE32(hdrlTag); WriteAVIVideoStreamHeaderChunks(); @@ -937,10 +931,10 @@ WebRtc_Word32 AviFile::WriteAVIVideoStreamHeaders() return 0; } -WebRtc_Word32 AviFile::WriteAVIVideoStreamHeaderChunks() +int32_t AviFile::WriteAVIVideoStreamHeaderChunks() { // Start of strh - const WebRtc_UWord32 strhTag = MakeFourCc('s', 't', 'r', 'h'); + const uint32_t strhTag = MakeFourCc('s', 't', 'r', 'h'); _bytesWritten += PutLE32(strhTag); // Size is unknown at this point. Update later. @@ -972,7 +966,7 @@ WebRtc_Word32 AviFile::WriteAVIVideoStreamHeaderChunks() // End of strh // Start of strf - const WebRtc_UWord32 strfTag = MakeFourCc('s', 't', 'r', 'f'); + const uint32_t strfTag = MakeFourCc('s', 't', 'r', 'f'); _bytesWritten += PutLE32(strfTag); // Size is unknown at this point. Update later. @@ -1010,7 +1004,7 @@ WebRtc_Word32 AviFile::WriteAVIVideoStreamHeaderChunks() && !isMpegFile) { // Write strd, unless it's an MPEG file - const WebRtc_UWord32 strdTag = MakeFourCc('s', 't', 'r', 'd'); + const uint32_t strdTag = MakeFourCc('s', 't', 'r', 'd'); _bytesWritten += PutLE32(strdTag); // Size is unknown at this point. Update later. @@ -1025,7 +1019,7 @@ WebRtc_Word32 AviFile::WriteAVIVideoStreamHeaderChunks() } // Start of strn - const WebRtc_UWord32 strnTag = MakeFourCc('s', 't', 'r', 'n'); + const uint32_t strnTag = MakeFourCc('s', 't', 'r', 'n'); _bytesWritten += PutLE32(strnTag); // Size is unknown at this point. Update later. @@ -1040,17 +1034,17 @@ WebRtc_Word32 AviFile::WriteAVIVideoStreamHeaderChunks() return 0; } -WebRtc_Word32 AviFile::WriteAVIAudioStreamHeaders() +int32_t AviFile::WriteAVIAudioStreamHeaders() { // Start of LIST - WebRtc_UWord32 listTag = MakeFourCc('L', 'I', 'S', 'T'); + uint32_t listTag = MakeFourCc('L', 'I', 'S', 'T'); _bytesWritten += PutLE32(listTag); // Size is unknown at this point. Update later. _bytesWritten += PutLE32(0); const size_t liststrlSizeMark = _bytesWritten; - WebRtc_UWord32 hdrlTag = MakeFourCc('s', 't', 'r', 'l'); + uint32_t hdrlTag = MakeFourCc('s', 't', 'r', 'l'); _bytesWritten += PutLE32(hdrlTag); WriteAVIAudioStreamHeaderChunks(); @@ -1060,10 +1054,10 @@ WebRtc_Word32 AviFile::WriteAVIAudioStreamHeaders() return 0; } -WebRtc_Word32 AviFile::WriteAVIAudioStreamHeaderChunks() +int32_t AviFile::WriteAVIAudioStreamHeaderChunks() { // Start of strh - const WebRtc_UWord32 strhTag = MakeFourCc('s', 't', 'r', 'h'); + const uint32_t strhTag = MakeFourCc('s', 't', 'r', 'h'); _bytesWritten += PutLE32(strhTag); // Size is unknown at this point. Update later. @@ -1095,7 +1089,7 @@ WebRtc_Word32 AviFile::WriteAVIAudioStreamHeaderChunks() // End of strh // Start of strf - const WebRtc_UWord32 strfTag = MakeFourCc('s', 't', 'r', 'f'); + const uint32_t strfTag = MakeFourCc('s', 't', 'r', 'f'); _bytesWritten += PutLE32(strfTag); // Size is unknown at this point. Update later. @@ -1116,7 +1110,7 @@ WebRtc_Word32 AviFile::WriteAVIAudioStreamHeaderChunks() // Audio doesn't have strd. // Start of strn - const WebRtc_UWord32 strnTag = MakeFourCc('s', 't', 'r', 'n'); + const uint32_t strnTag = MakeFourCc('s', 't', 'r', 'n'); _bytesWritten += PutLE32(strnTag); // Size is unknown at this point. Update later. @@ -1131,51 +1125,51 @@ WebRtc_Word32 AviFile::WriteAVIAudioStreamHeaderChunks() return 0; } -WebRtc_Word32 AviFile::WriteMoviStart() +int32_t AviFile::WriteMoviStart() { // Create template movi list. Fill out size when known (i.e. when closing // file). - const WebRtc_UWord32 listTag = MakeFourCc('L', 'I', 'S', 'T'); + const uint32_t listTag = MakeFourCc('L', 'I', 'S', 'T'); _bytesWritten += PutLE32(listTag); _bytesWritten += PutLE32(0); //Size! Change later! _moviSizeMark = _bytesWritten; _moviListOffset = ftell(_aviFile); - const WebRtc_UWord32 moviTag = MakeFourCc('m', 'o', 'v', 'i'); + const uint32_t moviTag = MakeFourCc('m', 'o', 'v', 'i'); _bytesWritten += PutLE32(moviTag); return 0; } -size_t AviFile::PutByte(WebRtc_UWord8 byte) +size_t AviFile::PutByte(uint8_t byte) { - return fwrite(&byte, sizeof(WebRtc_UWord8), sizeof(WebRtc_UWord8), + return fwrite(&byte, sizeof(uint8_t), sizeof(uint8_t), _aviFile); } -size_t AviFile::PutLE16(WebRtc_UWord16 word) +size_t AviFile::PutLE16(uint16_t word) { - return fwrite(&word, sizeof(WebRtc_UWord8), sizeof(WebRtc_UWord16), + return fwrite(&word, sizeof(uint8_t), sizeof(uint16_t), _aviFile); } -size_t AviFile::PutLE32(WebRtc_UWord32 word) +size_t AviFile::PutLE32(uint32_t word) { - return fwrite(&word, sizeof(WebRtc_UWord8), sizeof(WebRtc_UWord32), + return fwrite(&word, sizeof(uint8_t), sizeof(uint32_t), _aviFile); } -size_t AviFile::PutBuffer(const WebRtc_UWord8* str, size_t size) +size_t AviFile::PutBuffer(const uint8_t* str, size_t size) { - return fwrite(str, sizeof(WebRtc_UWord8), size, + return fwrite(str, sizeof(uint8_t), size, _aviFile); } size_t AviFile::PutBufferZ(const char* str) { // Include NULL charachter, hence the + 1 - return PutBuffer(reinterpret_cast(str), + return PutBuffer(reinterpret_cast(str), strlen(str) + 1); } @@ -1202,7 +1196,7 @@ long AviFile::PutLE32LengthFromCurrent(long startPos) return len; } -void AviFile::PutLE32AtPos(long pos, WebRtc_UWord32 word) +void AviFile::PutLE32AtPos(long pos, uint32_t word) { const long currPos = ftell(_aviFile); if (currPos < 0) { @@ -1321,31 +1315,31 @@ void AviFile::ResetComplexMembers() memset(&_audioStream, 0, sizeof(AVIStream)); } -size_t AviFile::GetByte(WebRtc_UWord8& word) +size_t AviFile::GetByte(uint8_t& word) { - return fread(&word, sizeof(WebRtc_UWord8), sizeof(WebRtc_UWord8), _aviFile); + return fread(&word, sizeof(uint8_t), sizeof(uint8_t), _aviFile); } -size_t AviFile::GetLE16(WebRtc_UWord16& word) +size_t AviFile::GetLE16(uint16_t& word) { - return fread(&word, sizeof(WebRtc_UWord8), sizeof(WebRtc_UWord16), + return fread(&word, sizeof(uint8_t), sizeof(uint16_t), _aviFile); } -size_t AviFile::GetLE32(WebRtc_UWord32& word) +size_t AviFile::GetLE32(uint32_t& word) { - return fread(&word, sizeof(WebRtc_UWord8), sizeof(WebRtc_UWord32), + return fread(&word, sizeof(uint8_t), sizeof(uint32_t), _aviFile); } -size_t AviFile::GetBuffer(WebRtc_UWord8* str, size_t size) +size_t AviFile::GetBuffer(uint8_t* str, size_t size) { - return fread(str, sizeof(WebRtc_UWord8), size, _aviFile); + return fread(str, sizeof(uint8_t), size, _aviFile); } -WebRtc_Word32 AviFile::ReadRIFF() +int32_t AviFile::ReadRIFF() { - WebRtc_UWord32 tag; + uint32_t tag; _bytesRead = GetLE32(tag); if (tag != MakeFourCc('R', 'I', 'F', 'F')) { @@ -1353,7 +1347,7 @@ WebRtc_Word32 AviFile::ReadRIFF() return -1; } - WebRtc_UWord32 size; + uint32_t size; _bytesRead += GetLE32(size); _aviLength = size; @@ -1367,11 +1361,11 @@ WebRtc_Word32 AviFile::ReadRIFF() return 0; } -WebRtc_Word32 AviFile::ReadHeaders() +int32_t AviFile::ReadHeaders() { - WebRtc_UWord32 tag; + uint32_t tag; _bytesRead += GetLE32(tag); - WebRtc_UWord32 size; + uint32_t size; _bytesRead += GetLE32(size); if (tag != MakeFourCc('L', 'I', 'S', 'T')) @@ -1379,14 +1373,14 @@ WebRtc_Word32 AviFile::ReadHeaders() return -1; } - WebRtc_UWord32 listTag; + uint32_t listTag; _bytesRead += GetLE32(listTag); if (listTag != MakeFourCc('h', 'd', 'r', 'l')) { return -1; } - WebRtc_Word32 err = ReadAVIMainHeader(); + int32_t err = ReadAVIMainHeader(); if (err) { return -1; @@ -1395,7 +1389,7 @@ WebRtc_Word32 AviFile::ReadHeaders() return 0; } -WebRtc_Word32 AviFile::ReadAVIMainHeader() +int32_t AviFile::ReadAVIMainHeader() { _bytesRead += GetLE32(_aviHeader.fcc); _bytesRead += GetLE32(_aviHeader.cb); @@ -1429,28 +1423,28 @@ WebRtc_Word32 AviFile::ReadAVIMainHeader() unsigned int streamsRead = 0; while (_aviHeader.dwStreams > streamsRead) { - WebRtc_UWord32 strltag; + uint32_t strltag; _bytesRead += GetLE32(strltag); - WebRtc_UWord32 strlsize; + uint32_t strlsize; _bytesRead += GetLE32(strlsize); const long endSeekPos = ftell(_aviFile) + - static_cast(strlsize); + static_cast(strlsize); if (strltag != MakeFourCc('L', 'I', 'S', 'T')) { return -1; } - WebRtc_UWord32 listTag; + uint32_t listTag; _bytesRead += GetLE32(listTag); if (listTag != MakeFourCc('s', 't', 'r', 'l')) { return -1; } - WebRtc_UWord32 chunktag; + uint32_t chunktag; _bytesRead += GetLE32(chunktag); - WebRtc_UWord32 chunksize; + uint32_t chunksize; _bytesRead += GetLE32(chunksize); if (chunktag != MakeFourCc('s', 't', 'r', 'h')) @@ -1476,16 +1470,16 @@ WebRtc_Word32 AviFile::ReadAVIMainHeader() _bytesRead += GetLE32(tmpStreamHeader.dwQuality); _bytesRead += GetLE32(tmpStreamHeader.dwSampleSize); - WebRtc_UWord16 left; + uint16_t left; _bytesRead += GetLE16(left); tmpStreamHeader.rcFrame.left = left; - WebRtc_UWord16 top; + uint16_t top; _bytesRead += GetLE16(top); tmpStreamHeader.rcFrame.top = top; - WebRtc_UWord16 right; + uint16_t right; _bytesRead += GetLE16(right); tmpStreamHeader.rcFrame.right = right; - WebRtc_UWord16 bottom; + uint16_t bottom; _bytesRead += GetLE16(bottom); tmpStreamHeader.rcFrame.bottom = bottom; @@ -1493,7 +1487,7 @@ WebRtc_Word32 AviFile::ReadAVIMainHeader() && (tmpStreamHeader.fccType == MakeFourCc('v', 'i', 'd', 's'))) { _videoStreamHeader = tmpStreamHeader; //Bitwise copy is OK! - const WebRtc_Word32 err = ReadAVIVideoStreamHeader(endSeekPos); + const int32_t err = ReadAVIVideoStreamHeader(endSeekPos); if (err) { return -1; @@ -1507,7 +1501,7 @@ WebRtc_Word32 AviFile::ReadAVIMainHeader() } else if(!readAudioStreamHeader && (tmpStreamHeader.fccType == MakeFourCc('a', 'u', 'd', 's'))) { _audioStreamHeader = tmpStreamHeader; - const WebRtc_Word32 err = ReadAVIAudioStreamHeader(endSeekPos); + const int32_t err = ReadAVIAudioStreamHeader(endSeekPos); if (err) { return -1; @@ -1528,9 +1522,9 @@ WebRtc_Word32 AviFile::ReadAVIMainHeader() return -1; } - WebRtc_UWord32 tag; + uint32_t tag; _bytesRead += GetLE32(tag); - WebRtc_UWord32 size; + uint32_t size; _bytesRead += GetLE32(size); if (tag == MakeFourCc('J', 'U', 'N', 'K')) @@ -1544,7 +1538,7 @@ WebRtc_Word32 AviFile::ReadAVIMainHeader() { return -1; } - WebRtc_UWord32 listTag; + uint32_t listTag; _bytesRead += GetLE32(listTag); if (listTag != MakeFourCc('m', 'o', 'v', 'i')) { @@ -1554,11 +1548,11 @@ WebRtc_Word32 AviFile::ReadAVIMainHeader() return 0; } -WebRtc_Word32 AviFile::ReadAVIVideoStreamHeader(WebRtc_Word32 endpos) +int32_t AviFile::ReadAVIVideoStreamHeader(int32_t endpos) { - WebRtc_UWord32 chunktag; + uint32_t chunktag; _bytesRead += GetLE32(chunktag); - WebRtc_UWord32 chunksize; + uint32_t chunksize; _bytesRead += GetLE32(chunksize); if (chunktag != MakeFourCc('s', 't', 'r', 'f')) @@ -1580,12 +1574,12 @@ WebRtc_Word32 AviFile::ReadAVIVideoStreamHeader(WebRtc_Word32 endpos) if (chunksize > _videoFormatHeader.biSize) { - const WebRtc_UWord32 size = chunksize - _videoFormatHeader.biSize; - const WebRtc_UWord32 readSize = MinValue(size, CODEC_CONFIG_LENGTH); + const uint32_t size = chunksize - _videoFormatHeader.biSize; + const uint32_t readSize = MinValue(size, CODEC_CONFIG_LENGTH); _bytesRead += GetBuffer( - reinterpret_cast(_videoConfigParameters), readSize); + reinterpret_cast(_videoConfigParameters), readSize); _videoConfigLength = readSize; - WebRtc_Word32 skipSize = chunksize - _videoFormatHeader.biSize - + int32_t skipSize = chunksize - _videoFormatHeader.biSize - readSize; if (skipSize > 0) { @@ -1596,23 +1590,22 @@ WebRtc_Word32 AviFile::ReadAVIVideoStreamHeader(WebRtc_Word32 endpos) while (static_cast(_bytesRead) < endpos) { - WebRtc_UWord32 chunktag; + uint32_t chunktag; _bytesRead += GetLE32(chunktag); - WebRtc_UWord32 chunksize; + uint32_t chunksize; _bytesRead += GetLE32(chunksize); if (chunktag == MakeFourCc('s', 't', 'r', 'n')) { - const WebRtc_UWord32 size = MinValue(chunksize, STREAM_NAME_LENGTH); + const uint32_t size = MinValue(chunksize, STREAM_NAME_LENGTH); _bytesRead += GetBuffer( - reinterpret_cast(_videoStreamName), size); + reinterpret_cast(_videoStreamName), size); } else if (chunktag == MakeFourCc('s', 't', 'r', 'd')) { - const WebRtc_UWord32 size = MinValue(chunksize, - CODEC_CONFIG_LENGTH); + const uint32_t size = MinValue(chunksize, CODEC_CONFIG_LENGTH); _bytesRead += GetBuffer( - reinterpret_cast(_videoConfigParameters), size); + reinterpret_cast(_videoConfigParameters), size); _videoConfigLength = size; } else @@ -1632,11 +1625,11 @@ WebRtc_Word32 AviFile::ReadAVIVideoStreamHeader(WebRtc_Word32 endpos) return 0; } -WebRtc_Word32 AviFile::ReadAVIAudioStreamHeader(WebRtc_Word32 endpos) +int32_t AviFile::ReadAVIAudioStreamHeader(int32_t endpos) { - WebRtc_UWord32 chunktag; + uint32_t chunktag; _bytesRead += GetLE32(chunktag); - WebRtc_UWord32 chunksize; + uint32_t chunksize; _bytesRead += GetLE32(chunksize); if (chunktag != MakeFourCc('s', 't', 'r', 'f')) @@ -1655,33 +1648,32 @@ WebRtc_Word32 AviFile::ReadAVIAudioStreamHeader(WebRtc_Word32 endpos) _bytesRead += GetLE16(_audioFormatHeader.cbSize); } - const WebRtc_UWord32 diffRead = chunksize - (_bytesRead - startRead); + const uint32_t diffRead = chunksize - (_bytesRead - startRead); if (diffRead > 0) { - const WebRtc_UWord32 size = MinValue(diffRead, CODEC_CONFIG_LENGTH); + const uint32_t size = MinValue(diffRead, CODEC_CONFIG_LENGTH); _bytesRead += GetBuffer( - reinterpret_cast(_audioConfigParameters), size); + reinterpret_cast(_audioConfigParameters), size); } while (static_cast(_bytesRead) < endpos) { - WebRtc_UWord32 chunktag; + uint32_t chunktag; _bytesRead += GetLE32(chunktag); - WebRtc_UWord32 chunksize; + uint32_t chunksize; _bytesRead += GetLE32(chunksize); if (chunktag == MakeFourCc('s', 't', 'r', 'n')) { - const WebRtc_UWord32 size = MinValue(chunksize, STREAM_NAME_LENGTH); + const uint32_t size = MinValue(chunksize, STREAM_NAME_LENGTH); _bytesRead += GetBuffer( - reinterpret_cast(_audioStreamName), size); + reinterpret_cast(_audioStreamName), size); } else if (chunktag == MakeFourCc('s', 't', 'r', 'd')) { - const WebRtc_UWord32 size = MinValue(chunksize, - CODEC_CONFIG_LENGTH); + const uint32_t size = MinValue(chunksize, CODEC_CONFIG_LENGTH); _bytesRead += GetBuffer( - reinterpret_cast(_audioConfigParameters), size); + reinterpret_cast(_audioConfigParameters), size); } else { @@ -1699,11 +1691,11 @@ WebRtc_Word32 AviFile::ReadAVIAudioStreamHeader(WebRtc_Word32 endpos) return 0; } -WebRtc_UWord32 AviFile::StreamAndTwoCharCodeToTag(WebRtc_Word32 streamNum, - const char* twoCharCode) +uint32_t AviFile::StreamAndTwoCharCodeToTag(int32_t streamNum, + const char* twoCharCode) { - WebRtc_UWord8 a = '0'; - WebRtc_UWord8 b; + uint8_t a = '0'; + uint8_t b; switch (streamNum) { case 1: @@ -1737,10 +1729,10 @@ void AviFile::ClearIndexList() } } -void AviFile::AddChunkToIndexList(WebRtc_UWord32 inChunkId, - WebRtc_UWord32 inFlags, - WebRtc_UWord32 inOffset, - WebRtc_UWord32 inSize) +void AviFile::AddChunkToIndexList(uint32_t inChunkId, + uint32_t inFlags, + uint32_t inOffset, + uint32_t inSize) { _indexList->PushBack(new AVIINDEXENTRY(inChunkId, inFlags, inOffset, inSize)); @@ -1748,7 +1740,7 @@ void AviFile::AddChunkToIndexList(WebRtc_UWord32 inChunkId, void AviFile::WriteIndex() { - const WebRtc_UWord32 idxTag = MakeFourCc('i', 'd', 'x', '1'); + const uint32_t idxTag = MakeFourCc('i', 'd', 'x', '1'); _bytesWritten += PutLE32(idxTag); // Size is unknown at this point. Update later. diff --git a/webrtc/modules/media_file/source/avi_file.h b/webrtc/modules/media_file/source/avi_file.h index fe7069258e..83a51fc790 100644 --- a/webrtc/modules/media_file/source/avi_file.h +++ b/webrtc/modules/media_file/source/avi_file.h @@ -24,56 +24,56 @@ class ListWrapper; struct AVISTREAMHEADER { AVISTREAMHEADER(); - WebRtc_UWord32 fcc; - WebRtc_UWord32 cb; - WebRtc_UWord32 fccType; - WebRtc_UWord32 fccHandler; - WebRtc_UWord32 dwFlags; - WebRtc_UWord16 wPriority; - WebRtc_UWord16 wLanguage; - WebRtc_UWord32 dwInitialFrames; - WebRtc_UWord32 dwScale; - WebRtc_UWord32 dwRate; - WebRtc_UWord32 dwStart; - WebRtc_UWord32 dwLength; - WebRtc_UWord32 dwSuggestedBufferSize; - WebRtc_UWord32 dwQuality; - WebRtc_UWord32 dwSampleSize; + uint32_t fcc; + uint32_t cb; + uint32_t fccType; + uint32_t fccHandler; + uint32_t dwFlags; + uint16_t wPriority; + uint16_t wLanguage; + uint32_t dwInitialFrames; + uint32_t dwScale; + uint32_t dwRate; + uint32_t dwStart; + uint32_t dwLength; + uint32_t dwSuggestedBufferSize; + uint32_t dwQuality; + uint32_t dwSampleSize; struct { - WebRtc_Word16 left; - WebRtc_Word16 top; - WebRtc_Word16 right; - WebRtc_Word16 bottom; + int16_t left; + int16_t top; + int16_t right; + int16_t bottom; } rcFrame; }; struct BITMAPINFOHEADER { BITMAPINFOHEADER(); - WebRtc_UWord32 biSize; - WebRtc_UWord32 biWidth; - WebRtc_UWord32 biHeight; - WebRtc_UWord16 biPlanes; - WebRtc_UWord16 biBitCount; - WebRtc_UWord32 biCompression; - WebRtc_UWord32 biSizeImage; - WebRtc_UWord32 biXPelsPerMeter; - WebRtc_UWord32 biYPelsPerMeter; - WebRtc_UWord32 biClrUsed; - WebRtc_UWord32 biClrImportant; + uint32_t biSize; + uint32_t biWidth; + uint32_t biHeight; + uint16_t biPlanes; + uint16_t biBitCount; + uint32_t biCompression; + uint32_t biSizeImage; + uint32_t biXPelsPerMeter; + uint32_t biYPelsPerMeter; + uint32_t biClrUsed; + uint32_t biClrImportant; }; struct WAVEFORMATEX { WAVEFORMATEX(); - WebRtc_UWord16 wFormatTag; - WebRtc_UWord16 nChannels; - WebRtc_UWord32 nSamplesPerSec; - WebRtc_UWord32 nAvgBytesPerSec; - WebRtc_UWord16 nBlockAlign; - WebRtc_UWord16 wBitsPerSample; - WebRtc_UWord16 cbSize; + uint16_t wFormatTag; + uint16_t nChannels; + uint32_t nSamplesPerSec; + uint32_t nAvgBytesPerSec; + uint16_t nBlockAlign; + uint16_t wBitsPerSample; + uint16_t cbSize; }; class AviFile @@ -92,37 +92,37 @@ public: AviFile(); ~AviFile(); - WebRtc_Word32 Open(AVIStreamType streamType, const char* fileName, - bool loop = false); + int32_t Open(AVIStreamType streamType, const char* fileName, + bool loop = false); - WebRtc_Word32 CreateVideoStream(const AVISTREAMHEADER& videoStreamHeader, - const BITMAPINFOHEADER& bitMapInfoHeader, - const WebRtc_UWord8* codecConfigParams, - WebRtc_Word32 codecConfigParamsLength); + int32_t CreateVideoStream(const AVISTREAMHEADER& videoStreamHeader, + const BITMAPINFOHEADER& bitMapInfoHeader, + const uint8_t* codecConfigParams, + int32_t codecConfigParamsLength); - WebRtc_Word32 CreateAudioStream(const AVISTREAMHEADER& audioStreamHeader, - const WAVEFORMATEX& waveFormatHeader); - WebRtc_Word32 Create(const char* fileName); + int32_t CreateAudioStream(const AVISTREAMHEADER& audioStreamHeader, + const WAVEFORMATEX& waveFormatHeader); + int32_t Create(const char* fileName); - WebRtc_Word32 WriteAudio(const WebRtc_UWord8* data, WebRtc_Word32 length); - WebRtc_Word32 WriteVideo(const WebRtc_UWord8* data, WebRtc_Word32 length); + int32_t WriteAudio(const uint8_t* data, int32_t length); + int32_t WriteVideo(const uint8_t* data, int32_t length); - WebRtc_Word32 GetVideoStreamInfo(AVISTREAMHEADER& videoStreamHeader, - BITMAPINFOHEADER& bitmapInfo, - char* codecConfigParameters, - WebRtc_Word32& configLength); + int32_t GetVideoStreamInfo(AVISTREAMHEADER& videoStreamHeader, + BITMAPINFOHEADER& bitmapInfo, + char* codecConfigParameters, + int32_t& configLength); - WebRtc_Word32 GetDuration(WebRtc_Word32& durationMs); + int32_t GetDuration(int32_t& durationMs); - WebRtc_Word32 GetAudioStreamInfo(WAVEFORMATEX& waveHeader); + int32_t GetAudioStreamInfo(WAVEFORMATEX& waveHeader); - WebRtc_Word32 ReadAudio(WebRtc_UWord8* data, WebRtc_Word32& length); - WebRtc_Word32 ReadVideo(WebRtc_UWord8* data, WebRtc_Word32& length); + int32_t ReadAudio(uint8_t* data, int32_t& length); + int32_t ReadVideo(uint8_t* data, int32_t& length); - WebRtc_Word32 Close(); + int32_t Close(); - static WebRtc_UWord32 MakeFourCc(WebRtc_UWord8 ch0, WebRtc_UWord8 ch1, - WebRtc_UWord8 ch2, WebRtc_UWord8 ch3); + static uint32_t MakeFourCc(uint8_t ch0, uint8_t ch1, uint8_t ch2, + uint8_t ch3); private: enum AVIFileMode @@ -134,44 +134,43 @@ private: struct AVIINDEXENTRY { - AVIINDEXENTRY(WebRtc_UWord32 inckid, WebRtc_UWord32 indwFlags, - WebRtc_UWord32 indwChunkOffset, - WebRtc_UWord32 indwChunkLength); - WebRtc_UWord32 ckid; - WebRtc_UWord32 dwFlags; - WebRtc_UWord32 dwChunkOffset; - WebRtc_UWord32 dwChunkLength; + AVIINDEXENTRY(uint32_t inckid, uint32_t indwFlags, + uint32_t indwChunkOffset, + uint32_t indwChunkLength); + uint32_t ckid; + uint32_t dwFlags; + uint32_t dwChunkOffset; + uint32_t dwChunkLength; }; - WebRtc_Word32 PrepareDataChunkHeaders(); + int32_t PrepareDataChunkHeaders(); - WebRtc_Word32 ReadMoviSubChunk(WebRtc_UWord8* data, WebRtc_Word32& length, - WebRtc_UWord32 tag1, - WebRtc_UWord32 tag2 = 0); + int32_t ReadMoviSubChunk(uint8_t* data, int32_t& length, uint32_t tag1, + uint32_t tag2 = 0); - WebRtc_Word32 WriteRIFF(); - WebRtc_Word32 WriteHeaders(); - WebRtc_Word32 WriteAVIMainHeader(); - WebRtc_Word32 WriteAVIStreamHeaders(); - WebRtc_Word32 WriteAVIVideoStreamHeaders(); - WebRtc_Word32 WriteAVIVideoStreamHeaderChunks(); - WebRtc_Word32 WriteAVIAudioStreamHeaders(); - WebRtc_Word32 WriteAVIAudioStreamHeaderChunks(); + int32_t WriteRIFF(); + int32_t WriteHeaders(); + int32_t WriteAVIMainHeader(); + int32_t WriteAVIStreamHeaders(); + int32_t WriteAVIVideoStreamHeaders(); + int32_t WriteAVIVideoStreamHeaderChunks(); + int32_t WriteAVIAudioStreamHeaders(); + int32_t WriteAVIAudioStreamHeaderChunks(); - WebRtc_Word32 WriteMoviStart(); + int32_t WriteMoviStart(); - size_t PutByte(WebRtc_UWord8 byte); - size_t PutLE16(WebRtc_UWord16 word); - size_t PutLE32(WebRtc_UWord32 word); - size_t PutBuffer(const WebRtc_UWord8* str, size_t size); + size_t PutByte(uint8_t byte); + size_t PutLE16(uint16_t word); + size_t PutLE32(uint32_t word); + size_t PutBuffer(const uint8_t* str, size_t size); size_t PutBufferZ(const char* str); long PutLE32LengthFromCurrent(long startPos); - void PutLE32AtPos(long pos, WebRtc_UWord32 word); + void PutLE32AtPos(long pos, uint32_t word); - size_t GetByte(WebRtc_UWord8& word); - size_t GetLE16(WebRtc_UWord16& word); - size_t GetLE32(WebRtc_UWord32& word); - size_t GetBuffer(WebRtc_UWord8* str, size_t size); + size_t GetByte(uint8_t& word); + size_t GetLE16(uint16_t& word); + size_t GetLE32(uint32_t& word); + size_t GetBuffer(uint8_t* str, size_t size); void CloseRead(); void CloseWrite(); @@ -179,18 +178,18 @@ private: void ResetMembers(); void ResetComplexMembers(); - WebRtc_Word32 ReadRIFF(); - WebRtc_Word32 ReadHeaders(); - WebRtc_Word32 ReadAVIMainHeader(); - WebRtc_Word32 ReadAVIVideoStreamHeader(WebRtc_Word32 endpos); - WebRtc_Word32 ReadAVIAudioStreamHeader(WebRtc_Word32 endpos); + int32_t ReadRIFF(); + int32_t ReadHeaders(); + int32_t ReadAVIMainHeader(); + int32_t ReadAVIVideoStreamHeader(int32_t endpos); + int32_t ReadAVIAudioStreamHeader(int32_t endpos); - WebRtc_UWord32 StreamAndTwoCharCodeToTag(WebRtc_Word32 streamNum, - const char* twoCharCode); + uint32_t StreamAndTwoCharCodeToTag(int32_t streamNum, + const char* twoCharCode); void ClearIndexList(); - void AddChunkToIndexList(WebRtc_UWord32 inChunkId, WebRtc_UWord32 inFlags, - WebRtc_UWord32 inOffset, WebRtc_UWord32 inSize); + void AddChunkToIndexList(uint32_t inChunkId, uint32_t inFlags, + uint32_t inOffset, uint32_t inSize); void WriteIndex(); @@ -198,19 +197,19 @@ private: struct AVIMAINHEADER { AVIMAINHEADER(); - WebRtc_UWord32 fcc; - WebRtc_UWord32 cb; - WebRtc_UWord32 dwMicroSecPerFrame; - WebRtc_UWord32 dwMaxBytesPerSec; - WebRtc_UWord32 dwPaddingGranularity; - WebRtc_UWord32 dwFlags; - WebRtc_UWord32 dwTotalFrames; - WebRtc_UWord32 dwInitialFrames; - WebRtc_UWord32 dwStreams; - WebRtc_UWord32 dwSuggestedBufferSize; - WebRtc_UWord32 dwWidth; - WebRtc_UWord32 dwHeight; - WebRtc_UWord32 dwReserved[4]; + uint32_t fcc; + uint32_t cb; + uint32_t dwMicroSecPerFrame; + uint32_t dwMaxBytesPerSec; + uint32_t dwPaddingGranularity; + uint32_t dwFlags; + uint32_t dwTotalFrames; + uint32_t dwInitialFrames; + uint32_t dwStreams; + uint32_t dwSuggestedBufferSize; + uint32_t dwWidth; + uint32_t dwHeight; + uint32_t dwReserved[4]; }; struct AVIStream @@ -227,23 +226,23 @@ private: BITMAPINFOHEADER _videoFormatHeader; WAVEFORMATEX _audioFormatHeader; - WebRtc_Word8 _videoConfigParameters[CODEC_CONFIG_LENGTH]; - WebRtc_Word32 _videoConfigLength; - WebRtc_Word8 _videoStreamName[STREAM_NAME_LENGTH]; - WebRtc_Word8 _audioConfigParameters[CODEC_CONFIG_LENGTH]; - WebRtc_Word8 _audioStreamName[STREAM_NAME_LENGTH]; + int8_t _videoConfigParameters[CODEC_CONFIG_LENGTH]; + int32_t _videoConfigLength; + int8_t _videoStreamName[STREAM_NAME_LENGTH]; + int8_t _audioConfigParameters[CODEC_CONFIG_LENGTH]; + int8_t _audioStreamName[STREAM_NAME_LENGTH]; AVIStream _videoStream; AVIStream _audioStream; - WebRtc_Word32 _nrStreams; - WebRtc_Word32 _aviLength; - WebRtc_Word32 _dataLength; + int32_t _nrStreams; + int32_t _aviLength; + int32_t _dataLength; size_t _bytesRead; size_t _dataStartByte; - WebRtc_Word32 _framesRead; - WebRtc_Word32 _videoFrames; - WebRtc_Word32 _audioFrames; + int32_t _framesRead; + int32_t _videoFrames; + int32_t _audioFrames; bool _reading; AVIStreamType _openedAs; @@ -257,17 +256,17 @@ private: size_t _totNumFramesMark; size_t _videoStreamLengthMark; size_t _audioStreamLengthMark; - WebRtc_Word32 _moviListOffset; + int32_t _moviListOffset; bool _writeAudioStream; bool _writeVideoStream; AVIFileMode _aviMode; - WebRtc_UWord8* _videoCodecConfigParams; - WebRtc_Word32 _videoCodecConfigParamsLength; + uint8_t* _videoCodecConfigParams; + int32_t _videoCodecConfigParamsLength; - WebRtc_UWord32 _videoStreamDataChunkPrefix; - WebRtc_UWord32 _audioStreamDataChunkPrefix; + uint32_t _videoStreamDataChunkPrefix; + uint32_t _audioStreamDataChunkPrefix; bool _created; ListWrapper* _indexList; // Elements are of type AVIINDEXENTRY. diff --git a/webrtc/modules/media_file/source/media_file_impl.cc b/webrtc/modules/media_file/source/media_file_impl.cc index 206c8d87f2..fa66677f23 100644 --- a/webrtc/modules/media_file/source/media_file_impl.cc +++ b/webrtc/modules/media_file/source/media_file_impl.cc @@ -25,7 +25,7 @@ #endif namespace webrtc { -MediaFile* MediaFile::CreateMediaFile(const WebRtc_Word32 id) +MediaFile* MediaFile::CreateMediaFile(const int32_t id) { return new MediaFileImpl(id); } @@ -35,7 +35,7 @@ void MediaFile::DestroyMediaFile(MediaFile* module) delete static_cast(module); } -MediaFileImpl::MediaFileImpl(const WebRtc_Word32 id) +MediaFileImpl::MediaFileImpl(const int32_t id) : _id(id), _crit(CriticalSectionWrapper::CreateCriticalSection()), _callbackCrit(CriticalSectionWrapper::CreateCriticalSection()), @@ -92,13 +92,13 @@ MediaFileImpl::~MediaFileImpl() delete _callbackCrit; } -WebRtc_Word32 MediaFileImpl::ChangeUniqueId(const WebRtc_Word32 id) +int32_t MediaFileImpl::ChangeUniqueId(const int32_t id) { _id = id; return 0; } -WebRtc_Word32 MediaFileImpl::TimeUntilNextProcess() +int32_t MediaFileImpl::TimeUntilNextProcess() { WEBRTC_TRACE( kTraceWarning, @@ -108,35 +108,34 @@ WebRtc_Word32 MediaFileImpl::TimeUntilNextProcess() return -1; } -WebRtc_Word32 MediaFileImpl::Process() +int32_t MediaFileImpl::Process() { WEBRTC_TRACE(kTraceWarning, kTraceFile, _id, "Process: This method is not used by MediaFile class."); return -1; } -WebRtc_Word32 MediaFileImpl::PlayoutAVIVideoData( - WebRtc_Word8* buffer, - WebRtc_UWord32& dataLengthInBytes) +int32_t MediaFileImpl::PlayoutAVIVideoData( + int8_t* buffer, + uint32_t& dataLengthInBytes) { return PlayoutData( buffer, dataLengthInBytes, true); } -WebRtc_Word32 MediaFileImpl::PlayoutAudioData(WebRtc_Word8* buffer, - WebRtc_UWord32& dataLengthInBytes) +int32_t MediaFileImpl::PlayoutAudioData(int8_t* buffer, + uint32_t& dataLengthInBytes) { return PlayoutData( buffer, dataLengthInBytes, false); } -WebRtc_Word32 MediaFileImpl::PlayoutData(WebRtc_Word8* buffer, - WebRtc_UWord32& dataLengthInBytes, - bool video) +int32_t MediaFileImpl::PlayoutData(int8_t* buffer, uint32_t& dataLengthInBytes, + bool video) { WEBRTC_TRACE(kTraceStream, kTraceFile, _id, "MediaFileImpl::PlayoutData(buffer= 0x%x, bufLen= %ld)", buffer, dataLengthInBytes); - const WebRtc_UWord32 bufferLengthInBytes = dataLengthInBytes; + const uint32_t bufferLengthInBytes = dataLengthInBytes; dataLengthInBytes = 0; if(buffer == NULL || bufferLengthInBytes == 0) @@ -146,7 +145,7 @@ WebRtc_Word32 MediaFileImpl::PlayoutData(WebRtc_Word8* buffer, return -1; } - WebRtc_Word32 bytesRead = 0; + int32_t bytesRead = 0; { CriticalSectionScoped lock(_crit); @@ -225,17 +224,17 @@ WebRtc_Word32 MediaFileImpl::PlayoutData(WebRtc_Word8* buffer, if( bytesRead > 0) { - dataLengthInBytes =(WebRtc_UWord32) bytesRead; + dataLengthInBytes =(uint32_t) bytesRead; } } HandlePlayCallbacks(bytesRead); return 0; } -void MediaFileImpl::HandlePlayCallbacks(WebRtc_Word32 bytesRead) +void MediaFileImpl::HandlePlayCallbacks(int32_t bytesRead) { bool playEnded = false; - WebRtc_UWord32 callbackNotifyMs = 0; + uint32_t callbackNotifyMs = 0; if(bytesRead > 0) { @@ -272,10 +271,10 @@ void MediaFileImpl::HandlePlayCallbacks(WebRtc_Word32 bytesRead) } } -WebRtc_Word32 MediaFileImpl::PlayoutStereoData( - WebRtc_Word8* bufferLeft, - WebRtc_Word8* bufferRight, - WebRtc_UWord32& dataLengthInBytes) +int32_t MediaFileImpl::PlayoutStereoData( + int8_t* bufferLeft, + int8_t* bufferRight, + uint32_t& dataLengthInBytes) { WEBRTC_TRACE(kTraceStream, kTraceFile, _id, "MediaFileImpl::PlayoutStereoData(Left = 0x%x, Right = 0x%x,\ @@ -284,7 +283,7 @@ WebRtc_Word32 MediaFileImpl::PlayoutStereoData( bufferRight, dataLengthInBytes); - const WebRtc_UWord32 bufferLengthInBytes = dataLengthInBytes; + const uint32_t bufferLengthInBytes = dataLengthInBytes; dataLengthInBytes = 0; if(bufferLeft == NULL || bufferRight == NULL || bufferLengthInBytes == 0) @@ -295,7 +294,7 @@ WebRtc_Word32 MediaFileImpl::PlayoutStereoData( } bool playEnded = false; - WebRtc_UWord32 callbackNotifyMs = 0; + uint32_t callbackNotifyMs = 0; { CriticalSectionScoped lock(_crit); @@ -318,7 +317,7 @@ WebRtc_Word32 MediaFileImpl::PlayoutStereoData( } // Stereo playout only supported for WAV files. - WebRtc_Word32 bytesRead = 0; + int32_t bytesRead = 0; switch(_fileFormat) { case kFileFormatWavFile: @@ -373,14 +372,14 @@ WebRtc_Word32 MediaFileImpl::PlayoutStereoData( return 0; } -WebRtc_Word32 MediaFileImpl::StartPlayingAudioFile( +int32_t MediaFileImpl::StartPlayingAudioFile( const char* fileName, - const WebRtc_UWord32 notificationTimeMs, + const uint32_t notificationTimeMs, const bool loop, const FileFormats format, const CodecInst* codecInst, - const WebRtc_UWord32 startPointMs, - const WebRtc_UWord32 stopPointMs) + const uint32_t startPointMs, + const uint32_t stopPointMs) { const bool videoOnly = false; return StartPlayingFile(fileName, notificationTimeMs, loop, videoOnly, @@ -388,28 +387,28 @@ WebRtc_Word32 MediaFileImpl::StartPlayingAudioFile( } -WebRtc_Word32 MediaFileImpl::StartPlayingVideoFile(const char* fileName, - const bool loop, - bool videoOnly, - const FileFormats format) +int32_t MediaFileImpl::StartPlayingVideoFile(const char* fileName, + const bool loop, + bool videoOnly, + const FileFormats format) { - const WebRtc_UWord32 notificationTimeMs = 0; - const WebRtc_UWord32 startPointMs = 0; - const WebRtc_UWord32 stopPointMs = 0; + const uint32_t notificationTimeMs = 0; + const uint32_t startPointMs = 0; + const uint32_t stopPointMs = 0; return StartPlayingFile(fileName, notificationTimeMs, loop, videoOnly, format, 0, startPointMs, stopPointMs); } -WebRtc_Word32 MediaFileImpl::StartPlayingFile( +int32_t MediaFileImpl::StartPlayingFile( const char* fileName, - const WebRtc_UWord32 notificationTimeMs, + const uint32_t notificationTimeMs, const bool loop, bool videoOnly, const FileFormats format, const CodecInst* codecInst, - const WebRtc_UWord32 startPointMs, - const WebRtc_UWord32 stopPointMs) + const uint32_t startPointMs, + const uint32_t stopPointMs) { if(!ValidFileName(fileName)) @@ -478,27 +477,27 @@ WebRtc_Word32 MediaFileImpl::StartPlayingFile( return 0; } -WebRtc_Word32 MediaFileImpl::StartPlayingAudioStream( +int32_t MediaFileImpl::StartPlayingAudioStream( InStream& stream, - const WebRtc_UWord32 notificationTimeMs, + const uint32_t notificationTimeMs, const FileFormats format, const CodecInst* codecInst, - const WebRtc_UWord32 startPointMs, - const WebRtc_UWord32 stopPointMs) + const uint32_t startPointMs, + const uint32_t stopPointMs) { return StartPlayingStream(stream, 0, false, notificationTimeMs, format, codecInst, startPointMs, stopPointMs); } -WebRtc_Word32 MediaFileImpl::StartPlayingStream( +int32_t MediaFileImpl::StartPlayingStream( InStream& stream, const char* filename, bool loop, - const WebRtc_UWord32 notificationTimeMs, + const uint32_t notificationTimeMs, const FileFormats format, const CodecInst* codecInst, - const WebRtc_UWord32 startPointMs, - const WebRtc_UWord32 stopPointMs, + const uint32_t startPointMs, + const uint32_t stopPointMs, bool videoOnly) { if(!ValidFileFormat(format,codecInst)) @@ -655,7 +654,7 @@ WebRtc_Word32 MediaFileImpl::StartPlayingStream( return 0; } -WebRtc_Word32 MediaFileImpl::StopPlaying() +int32_t MediaFileImpl::StopPlaying() { CriticalSectionScoped lock(_crit); @@ -697,23 +696,23 @@ bool MediaFileImpl::IsPlaying() return _playingActive; } -WebRtc_Word32 MediaFileImpl::IncomingAudioData( - const WebRtc_Word8* buffer, - const WebRtc_UWord32 bufferLengthInBytes) +int32_t MediaFileImpl::IncomingAudioData( + const int8_t* buffer, + const uint32_t bufferLengthInBytes) { return IncomingAudioVideoData( buffer, bufferLengthInBytes, false); } -WebRtc_Word32 MediaFileImpl::IncomingAVIVideoData( - const WebRtc_Word8* buffer, - const WebRtc_UWord32 bufferLengthInBytes) +int32_t MediaFileImpl::IncomingAVIVideoData( + const int8_t* buffer, + const uint32_t bufferLengthInBytes) { return IncomingAudioVideoData( buffer, bufferLengthInBytes, true); } -WebRtc_Word32 MediaFileImpl::IncomingAudioVideoData( - const WebRtc_Word8* buffer, - const WebRtc_UWord32 bufferLengthInBytes, +int32_t MediaFileImpl::IncomingAudioVideoData( + const int8_t* buffer, + const uint32_t bufferLengthInBytes, const bool video) { WEBRTC_TRACE(kTraceStream, kTraceFile, _id, @@ -728,7 +727,7 @@ WebRtc_Word32 MediaFileImpl::IncomingAudioVideoData( } bool recordingEnded = false; - WebRtc_UWord32 callbackNotifyMs = 0; + uint32_t callbackNotifyMs = 0; { CriticalSectionScoped lock(_crit); @@ -746,8 +745,8 @@ WebRtc_Word32 MediaFileImpl::IncomingAudioVideoData( return -1; } - WebRtc_Word32 bytesWritten = 0; - WebRtc_UWord32 samplesWritten = codec_info_.pacsize; + int32_t bytesWritten = 0; + uint32_t samplesWritten = codec_info_.pacsize; if(_ptrFileUtilityObj) { switch(_fileFormat) @@ -763,7 +762,7 @@ WebRtc_Word32 MediaFileImpl::IncomingAudioVideoData( // Sample size is 2 bytes. if(bytesWritten > 0) { - samplesWritten = bytesWritten/sizeof(WebRtc_Word16); + samplesWritten = bytesWritten/sizeof(int16_t); } break; case kFileFormatCompressedFile: @@ -779,7 +778,7 @@ WebRtc_Word32 MediaFileImpl::IncomingAudioVideoData( "L16", 4) == 0) { // Sample size is 2 bytes. - samplesWritten = bytesWritten/sizeof(WebRtc_Word16); + samplesWritten = bytesWritten/sizeof(int16_t); } break; case kFileFormatPreencodedFile: @@ -831,7 +830,7 @@ WebRtc_Word32 MediaFileImpl::IncomingAudioVideoData( callbackNotifyMs = _recordDurationMs; } } - if(bytesWritten < (WebRtc_Word32)bufferLengthInBytes) + if(bytesWritten < (int32_t)bufferLengthInBytes) { WEBRTC_TRACE(kTraceWarning, kTraceFile, _id, "Failed to write all requested bytes!"); @@ -857,12 +856,12 @@ WebRtc_Word32 MediaFileImpl::IncomingAudioVideoData( return 0; } -WebRtc_Word32 MediaFileImpl::StartRecordingAudioFile( +int32_t MediaFileImpl::StartRecordingAudioFile( const char* fileName, const FileFormats format, const CodecInst& codecInst, - const WebRtc_UWord32 notificationTimeMs, - const WebRtc_UWord32 maxSizeBytes) + const uint32_t notificationTimeMs, + const uint32_t maxSizeBytes) { VideoCodec dummyCodecInst; return StartRecordingFile(fileName, format, codecInst, dummyCodecInst, @@ -870,27 +869,27 @@ WebRtc_Word32 MediaFileImpl::StartRecordingAudioFile( } -WebRtc_Word32 MediaFileImpl::StartRecordingVideoFile( +int32_t MediaFileImpl::StartRecordingVideoFile( const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, bool videoOnly) { - const WebRtc_UWord32 notificationTimeMs = 0; - const WebRtc_UWord32 maxSizeBytes = 0; + const uint32_t notificationTimeMs = 0; + const uint32_t maxSizeBytes = 0; return StartRecordingFile(fileName, format, codecInst, videoCodecInst, notificationTimeMs, maxSizeBytes, videoOnly); } -WebRtc_Word32 MediaFileImpl::StartRecordingFile( +int32_t MediaFileImpl::StartRecordingFile( const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, - const WebRtc_UWord32 notificationTimeMs, - const WebRtc_UWord32 maxSizeBytes, + const uint32_t notificationTimeMs, + const uint32_t maxSizeBytes, bool videoOnly) { @@ -948,24 +947,24 @@ WebRtc_Word32 MediaFileImpl::StartRecordingFile( return 0; } -WebRtc_Word32 MediaFileImpl::StartRecordingAudioStream( +int32_t MediaFileImpl::StartRecordingAudioStream( OutStream& stream, const FileFormats format, const CodecInst& codecInst, - const WebRtc_UWord32 notificationTimeMs) + const uint32_t notificationTimeMs) { VideoCodec dummyCodecInst; return StartRecordingStream(stream, 0, format, codecInst, dummyCodecInst, notificationTimeMs); } -WebRtc_Word32 MediaFileImpl::StartRecordingStream( +int32_t MediaFileImpl::StartRecordingStream( OutStream& stream, const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, - const WebRtc_UWord32 notificationTimeMs, + const uint32_t notificationTimeMs, bool videoOnly) { @@ -1128,7 +1127,7 @@ WebRtc_Word32 MediaFileImpl::StartRecordingStream( return 0; } -WebRtc_Word32 MediaFileImpl::StopRecording() +int32_t MediaFileImpl::StopRecording() { CriticalSectionScoped lock(_crit); @@ -1185,7 +1184,7 @@ bool MediaFileImpl::IsRecording() return _recordingActive; } -WebRtc_Word32 MediaFileImpl::RecordDurationMs(WebRtc_UWord32& durationMs) +int32_t MediaFileImpl::RecordDurationMs(uint32_t& durationMs) { CriticalSectionScoped lock(_crit); @@ -1205,7 +1204,7 @@ bool MediaFileImpl::IsStereo() return _isStereo; } -WebRtc_Word32 MediaFileImpl::SetModuleFileCallback(FileCallback* callback) +int32_t MediaFileImpl::SetModuleFileCallback(FileCallback* callback) { CriticalSectionScoped lock(_callbackCrit); @@ -1214,10 +1213,10 @@ WebRtc_Word32 MediaFileImpl::SetModuleFileCallback(FileCallback* callback) return 0; } -WebRtc_Word32 MediaFileImpl::FileDurationMs(const char* fileName, - WebRtc_UWord32& durationMs, - const FileFormats format, - const WebRtc_UWord32 freqInHz) +int32_t MediaFileImpl::FileDurationMs(const char* fileName, + uint32_t& durationMs, + const FileFormats format, + const uint32_t freqInHz) { if(!ValidFileName(fileName)) @@ -1237,8 +1236,8 @@ WebRtc_Word32 MediaFileImpl::FileDurationMs(const char* fileName, return -1; } - const WebRtc_Word32 duration = utilityObj->FileDurationMs(fileName, format, - freqInHz); + const int32_t duration = utilityObj->FileDurationMs(fileName, format, + freqInHz); delete utilityObj; if(duration == -1) { @@ -1250,7 +1249,7 @@ WebRtc_Word32 MediaFileImpl::FileDurationMs(const char* fileName, return 0; } -WebRtc_Word32 MediaFileImpl::PlayoutPositionMs(WebRtc_UWord32& positionMs) const +int32_t MediaFileImpl::PlayoutPositionMs(uint32_t& positionMs) const { CriticalSectionScoped lock(_crit); if(!_playingActive) @@ -1262,7 +1261,7 @@ WebRtc_Word32 MediaFileImpl::PlayoutPositionMs(WebRtc_UWord32& positionMs) const return 0; } -WebRtc_Word32 MediaFileImpl::codec_info(CodecInst& codecInst) const +int32_t MediaFileImpl::codec_info(CodecInst& codecInst) const { CriticalSectionScoped lock(_crit); if(!_playingActive && !_recordingActive) @@ -1282,7 +1281,7 @@ WebRtc_Word32 MediaFileImpl::codec_info(CodecInst& codecInst) const return 0; } -WebRtc_Word32 MediaFileImpl::VideoCodecInst(VideoCodec& codecInst) const +int32_t MediaFileImpl::VideoCodecInst(VideoCodec& codecInst) const { CriticalSectionScoped lock(_crit); if(!_playingActive && !_recordingActive) @@ -1337,8 +1336,8 @@ bool MediaFileImpl::ValidFileName(const char* fileName) } -bool MediaFileImpl::ValidFilePositions(const WebRtc_UWord32 startPointMs, - const WebRtc_UWord32 stopPointMs) +bool MediaFileImpl::ValidFilePositions(const uint32_t startPointMs, + const uint32_t stopPointMs) { if(startPointMs == 0 && stopPointMs == 0) // Default values { @@ -1359,7 +1358,7 @@ bool MediaFileImpl::ValidFilePositions(const WebRtc_UWord32 startPointMs, return true; } -bool MediaFileImpl::ValidFrequency(const WebRtc_UWord32 frequency) +bool MediaFileImpl::ValidFrequency(const uint32_t frequency) { if((frequency == 8000) || (frequency == 16000)|| (frequency == 32000)) { diff --git a/webrtc/modules/media_file/source/media_file_impl.h b/webrtc/modules/media_file/source/media_file_impl.h index 182367858b..c7390306e8 100644 --- a/webrtc/modules/media_file/source/media_file_impl.h +++ b/webrtc/modules/media_file/source/media_file_impl.h @@ -22,76 +22,71 @@ class MediaFileImpl : public MediaFile { public: - MediaFileImpl(const WebRtc_Word32 id); + MediaFileImpl(const int32_t id); ~MediaFileImpl(); - WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); - WebRtc_Word32 Process(); - WebRtc_Word32 TimeUntilNextProcess(); + int32_t ChangeUniqueId(const int32_t id); + int32_t Process(); + int32_t TimeUntilNextProcess(); // MediaFile functions - WebRtc_Word32 PlayoutAudioData(WebRtc_Word8* audioBuffer, - WebRtc_UWord32& dataLengthInBytes); - WebRtc_Word32 PlayoutAVIVideoData(WebRtc_Word8* videoBuffer, - WebRtc_UWord32& dataLengthInBytes); - WebRtc_Word32 PlayoutStereoData(WebRtc_Word8* audioBufferLeft, - WebRtc_Word8* audioBufferRight, - WebRtc_UWord32& dataLengthInBytes); - virtual WebRtc_Word32 StartPlayingAudioFile( + int32_t PlayoutAudioData(int8_t* audioBuffer, uint32_t& dataLengthInBytes); + int32_t PlayoutAVIVideoData(int8_t* videoBuffer, + uint32_t& dataLengthInBytes); + int32_t PlayoutStereoData(int8_t* audioBufferLeft, int8_t* audioBufferRight, + uint32_t& dataLengthInBytes); + virtual int32_t StartPlayingAudioFile( const char* fileName, - const WebRtc_UWord32 notificationTimeMs = 0, + const uint32_t notificationTimeMs = 0, const bool loop = false, const FileFormats format = kFileFormatPcm16kHzFile, const CodecInst* codecInst = NULL, - const WebRtc_UWord32 startPointMs = 0, - const WebRtc_UWord32 stopPointMs = 0); - WebRtc_Word32 StartPlayingVideoFile(const char* fileName, - const bool loop, - bool videoOnly, - const FileFormats format); - WebRtc_Word32 StartPlayingAudioStream( - InStream& stream, - const WebRtc_UWord32 notificationTimeMs = 0, - const FileFormats format = kFileFormatPcm16kHzFile, - const CodecInst* codecInst = NULL, - const WebRtc_UWord32 startPointMs = 0, - const WebRtc_UWord32 stopPointMs = 0); - WebRtc_Word32 StopPlaying(); + const uint32_t startPointMs = 0, + const uint32_t stopPointMs = 0); + int32_t StartPlayingVideoFile(const char* fileName, const bool loop, + bool videoOnly, const FileFormats format); + int32_t StartPlayingAudioStream(InStream& stream, + const uint32_t notificationTimeMs = 0, + const FileFormats format = kFileFormatPcm16kHzFile, + const CodecInst* codecInst = NULL, + const uint32_t startPointMs = 0, + const uint32_t stopPointMs = 0); + int32_t StopPlaying(); bool IsPlaying(); - WebRtc_Word32 PlayoutPositionMs(WebRtc_UWord32& positionMs) const; - WebRtc_Word32 IncomingAudioData(const WebRtc_Word8* audioBuffer, - const WebRtc_UWord32 bufferLength); - WebRtc_Word32 IncomingAVIVideoData(const WebRtc_Word8* audioBuffer, - const WebRtc_UWord32 bufferLength); - WebRtc_Word32 StartRecordingAudioFile( + int32_t PlayoutPositionMs(uint32_t& positionMs) const; + int32_t IncomingAudioData(const int8_t* audioBuffer, + const uint32_t bufferLength); + int32_t IncomingAVIVideoData(const int8_t* audioBuffer, + const uint32_t bufferLength); + int32_t StartRecordingAudioFile( const char* fileName, const FileFormats format, const CodecInst& codecInst, - const WebRtc_UWord32 notificationTimeMs = 0, - const WebRtc_UWord32 maxSizeBytes = 0); - WebRtc_Word32 StartRecordingVideoFile( + const uint32_t notificationTimeMs = 0, + const uint32_t maxSizeBytes = 0); + int32_t StartRecordingVideoFile( const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, bool videoOnly = false); - WebRtc_Word32 StartRecordingAudioStream( + int32_t StartRecordingAudioStream( OutStream& stream, const FileFormats format, const CodecInst& codecInst, - const WebRtc_UWord32 notificationTimeMs = 0); - WebRtc_Word32 StopRecording(); + const uint32_t notificationTimeMs = 0); + int32_t StopRecording(); bool IsRecording(); - WebRtc_Word32 RecordDurationMs(WebRtc_UWord32& durationMs); + int32_t RecordDurationMs(uint32_t& durationMs); bool IsStereo(); - WebRtc_Word32 SetModuleFileCallback(FileCallback* callback); - WebRtc_Word32 FileDurationMs( + int32_t SetModuleFileCallback(FileCallback* callback); + int32_t FileDurationMs( const char* fileName, - WebRtc_UWord32& durationMs, + uint32_t& durationMs, const FileFormats format, - const WebRtc_UWord32 freqInHz = 16000); - WebRtc_Word32 codec_info(CodecInst& codecInst) const; - WebRtc_Word32 VideoCodecInst(VideoCodec& codecInst) const; + const uint32_t freqInHz = 16000); + int32_t codec_info(CodecInst& codecInst) const; + int32_t VideoCodecInst(VideoCodec& codecInst) const; private: // Returns true if the combination of format and codecInst is valid. @@ -103,8 +98,8 @@ private: static bool ValidFileName(const char* fileName); // Returns true if the combination of startPointMs and stopPointMs is valid. - static bool ValidFilePositions(const WebRtc_UWord32 startPointMs, - const WebRtc_UWord32 stopPointMs); + static bool ValidFilePositions(const uint32_t startPointMs, + const uint32_t stopPointMs); // Open the file specified by fileName for reading (relative path is // allowed). FileCallback::PlayNotification(..) will be called after @@ -118,15 +113,15 @@ private: // true. startPointMs and stopPointMs, unless zero, // specify what part of the file should be read. From startPointMs ms to // stopPointMs ms. - WebRtc_Word32 StartPlayingFile( + int32_t StartPlayingFile( const char* fileName, - const WebRtc_UWord32 notificationTimeMs = 0, + const uint32_t notificationTimeMs = 0, const bool loop = false, bool videoOnly = false, const FileFormats format = kFileFormatPcm16kHzFile, const CodecInst* codecInst = NULL, - const WebRtc_UWord32 startPointMs = 0, - const WebRtc_UWord32 stopPointMs = 0); + const uint32_t startPointMs = 0, + const uint32_t stopPointMs = 0); // Opens the file specified by fileName for reading (relative path is // allowed) if format is kFileFormatAviFile otherwise use stream for @@ -142,15 +137,15 @@ private: // specify what part of the file should be read. From startPointMs ms to // stopPointMs ms. // TODO (hellner): there is no reason why fileName should be needed here. - WebRtc_Word32 StartPlayingStream( + int32_t StartPlayingStream( InStream& stream, const char* fileName, bool loop, - const WebRtc_UWord32 notificationTimeMs = 0, + const uint32_t notificationTimeMs = 0, const FileFormats format = kFileFormatPcm16kHzFile, const CodecInst* codecInst = NULL, - const WebRtc_UWord32 startPointMs = 0, - const WebRtc_UWord32 stopPointMs = 0, + const uint32_t startPointMs = 0, + const uint32_t stopPointMs = 0, bool videoOnly = true); // Writes one frame into dataBuffer. dataLengthInBytes is both an input and @@ -158,15 +153,15 @@ private: // audioBuffer. As output parameter it indicates the number of bytes // written to audioBuffer. If video is true the data written is a video // frame otherwise it is an audio frame. - WebRtc_Word32 PlayoutData(WebRtc_Word8* dataBuffer, - WebRtc_UWord32& dataLengthInBytes, bool video); + int32_t PlayoutData(int8_t* dataBuffer, uint32_t& dataLengthInBytes, + bool video); // Write one frame, i.e. the bufferLength first bytes of audioBuffer, // to file. The frame is an audio frame if video is true otherwise it is an // audio frame. - WebRtc_Word32 IncomingAudioVideoData(const WebRtc_Word8* buffer, - const WebRtc_UWord32 bufferLength, - const bool video); + int32_t IncomingAudioVideoData(const int8_t* buffer, + const uint32_t bufferLength, + const bool video); // Open/creates file specified by fileName for writing (relative path is // allowed) if format is kFileFormatAviFile otherwise use stream for @@ -181,13 +176,13 @@ private: // only contain video frames. // Note: codecInst.channels should be set to 2 for stereo (and 1 for // mono). Stereo is only supported for WAV files. - WebRtc_Word32 StartRecordingFile( + int32_t StartRecordingFile( const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, - const WebRtc_UWord32 notificationTimeMs = 0, - const WebRtc_UWord32 maxSizeBytes = 0, + const uint32_t notificationTimeMs = 0, + const uint32_t maxSizeBytes = 0, bool videoOnly = false); // Open/creates file specified by fileName for writing (relative path is @@ -203,21 +198,21 @@ private: // Note: codecInst.channels should be set to 2 for stereo (and 1 for // mono). Stereo is only supported for WAV files. // TODO (hellner): there is no reason why fileName should be needed here. - WebRtc_Word32 StartRecordingStream( + int32_t StartRecordingStream( OutStream& stream, const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, - const WebRtc_UWord32 notificationTimeMs = 0, + const uint32_t notificationTimeMs = 0, const bool videoOnly = false); // Returns true if frequencyInHz is a supported frequency. - static bool ValidFrequency(const WebRtc_UWord32 frequencyInHz); + static bool ValidFrequency(const uint32_t frequencyInHz); - void HandlePlayCallbacks(WebRtc_Word32 bytesRead); + void HandlePlayCallbacks(int32_t bytesRead); - WebRtc_Word32 _id; + int32_t _id; CriticalSectionWrapper* _crit; CriticalSectionWrapper* _callbackCrit; @@ -228,9 +223,9 @@ private: OutStream* _ptrOutStream; FileFormats _fileFormat; - WebRtc_UWord32 _recordDurationMs; - WebRtc_UWord32 _playoutPositionMs; - WebRtc_UWord32 _notificationMs; + uint32_t _recordDurationMs; + uint32_t _playoutPositionMs; + uint32_t _notificationMs; bool _playingActive; bool _recordingActive; diff --git a/webrtc/modules/media_file/source/media_file_utility.cc b/webrtc/modules/media_file/source/media_file_utility.cc index 5616e3436f..4e23899cfa 100644 --- a/webrtc/modules/media_file/source/media_file_utility.cc +++ b/webrtc/modules/media_file/source/media_file_utility.cc @@ -43,22 +43,22 @@ enum WaveFormats // "WAVE" and ckSize is the chunk size (4 + n) struct WAVE_RIFF_header { - WebRtc_Word8 ckID[4]; - WebRtc_Word32 ckSize; - WebRtc_Word8 wave_ckID[4]; + int8_t ckID[4]; + int32_t ckSize; + int8_t wave_ckID[4]; }; // First 8 byte of the format chunk. fmt_ckID should be "fmt ". fmt_ckSize is // the chunk size (16, 18 or 40 byte) struct WAVE_CHUNK_header { - WebRtc_Word8 fmt_ckID[4]; - WebRtc_Word32 fmt_ckSize; + int8_t fmt_ckID[4]; + int32_t fmt_ckSize; }; } // unnamed namespace namespace webrtc { -ModuleFileUtility::ModuleFileUtility(const WebRtc_Word32 id) +ModuleFileUtility::ModuleFileUtility(const int32_t id) : _wavFormatObj(), _dataSize(0), _readSizeBytes(0), @@ -101,7 +101,7 @@ ModuleFileUtility::~ModuleFileUtility() } #ifdef WEBRTC_MODULE_UTILITY_VIDEO -WebRtc_Word32 ModuleFileUtility::InitAviWriting( +int32_t ModuleFileUtility::InitAviWriting( const char* filename, const CodecInst& audioCodecInst, const VideoCodec& videoCodecInst, @@ -138,7 +138,7 @@ WebRtc_Word32 ModuleFileUtility::InitAviWriting( videoStreamHeader.dwRate = videoCodecInst.maxFramerate; videoStreamHeader.dwSuggestedBufferSize = videoCodecInst.height * (videoCodecInst.width >> 1) * 3; - videoStreamHeader.dwQuality = (WebRtc_UWord32)-1; + videoStreamHeader.dwQuality = (uint32_t)-1; videoStreamHeader.dwSampleSize = 0; videoStreamHeader.rcFrame.top = 0; videoStreamHeader.rcFrame.bottom = videoCodecInst.height; @@ -183,7 +183,7 @@ WebRtc_Word32 ModuleFileUtility::InitAviWriting( { audioStreamHeader.dwSampleSize = 1; audioStreamHeader.dwRate = 8000; - audioStreamHeader.dwQuality = (WebRtc_UWord32)-1; + audioStreamHeader.dwQuality = (uint32_t)-1; audioStreamHeader.dwSuggestedBufferSize = 80; waveFormatHeader.nAvgBytesPerSec = 8000; @@ -196,7 +196,7 @@ WebRtc_Word32 ModuleFileUtility::InitAviWriting( { audioStreamHeader.dwSampleSize = 1; audioStreamHeader.dwRate = 8000; - audioStreamHeader.dwQuality = (WebRtc_UWord32)-1; + audioStreamHeader.dwQuality = (uint32_t)-1; audioStreamHeader.dwSuggestedBufferSize = 80; waveFormatHeader.nAvgBytesPerSec = 8000; @@ -209,7 +209,7 @@ WebRtc_Word32 ModuleFileUtility::InitAviWriting( { audioStreamHeader.dwSampleSize = 2; audioStreamHeader.dwRate = audioCodecInst.plfreq; - audioStreamHeader.dwQuality = (WebRtc_UWord32)-1; + audioStreamHeader.dwQuality = (uint32_t)-1; audioStreamHeader.dwSuggestedBufferSize = (audioCodecInst.plfreq/100) * 2; @@ -244,14 +244,14 @@ WebRtc_Word32 ModuleFileUtility::InitAviWriting( return 0; } -WebRtc_Word32 ModuleFileUtility::WriteAviAudioData( - const WebRtc_Word8* buffer, - WebRtc_UWord32 bufferLengthInBytes) +int32_t ModuleFileUtility::WriteAviAudioData( + const int8_t* buffer, + uint32_t bufferLengthInBytes) { if( _aviOutFile != 0) { return _aviOutFile->WriteAudio( - reinterpret_cast(buffer), + reinterpret_cast(buffer), bufferLengthInBytes); } else @@ -261,14 +261,14 @@ WebRtc_Word32 ModuleFileUtility::WriteAviAudioData( } } -WebRtc_Word32 ModuleFileUtility::WriteAviVideoData( - const WebRtc_Word8* buffer, - WebRtc_UWord32 bufferLengthInBytes) +int32_t ModuleFileUtility::WriteAviVideoData( + const int8_t* buffer, + uint32_t bufferLengthInBytes) { if( _aviOutFile != 0) { return _aviOutFile->WriteVideo( - reinterpret_cast(buffer), + reinterpret_cast(buffer), bufferLengthInBytes); } else @@ -279,7 +279,7 @@ WebRtc_Word32 ModuleFileUtility::WriteAviVideoData( } -WebRtc_Word32 ModuleFileUtility::CloseAviFile( ) +int32_t ModuleFileUtility::CloseAviFile( ) { if( _reading && _aviAudioInFile) { @@ -302,8 +302,8 @@ WebRtc_Word32 ModuleFileUtility::CloseAviFile( ) } -WebRtc_Word32 ModuleFileUtility::InitAviReading(const char* filename, - bool videoOnly, bool loop) +int32_t ModuleFileUtility::InitAviReading(const char* filename, bool videoOnly, + bool loop) { _reading = false; delete _aviVideoInFile; @@ -321,18 +321,18 @@ WebRtc_Word32 ModuleFileUtility::InitAviReading(const char* filename, AVISTREAMHEADER videoInStreamHeader; BITMAPINFOHEADER bitmapInfo; char codecConfigParameters[AviFile::CODEC_CONFIG_LENGTH] = {}; - WebRtc_Word32 configLength = 0; + int32_t configLength = 0; if( _aviVideoInFile->GetVideoStreamInfo(videoInStreamHeader, bitmapInfo, codecConfigParameters, configLength) != 0) { return -1; } - _videoCodec.width = static_cast( + _videoCodec.width = static_cast( videoInStreamHeader.rcFrame.right); - _videoCodec.height = static_cast( + _videoCodec.height = static_cast( videoInStreamHeader.rcFrame.bottom); - _videoCodec.maxFramerate = static_cast( + _videoCodec.maxFramerate = static_cast( videoInStreamHeader.dwRate); const size_t plnameLen = sizeof(_videoCodec.plName) / sizeof(char); @@ -380,9 +380,9 @@ WebRtc_Word32 ModuleFileUtility::InitAviReading(const char* filename, return 0; } -WebRtc_Word32 ModuleFileUtility::ReadAviAudioData( - WebRtc_Word8* outBuffer, - const WebRtc_UWord32 bufferLengthInBytes) +int32_t ModuleFileUtility::ReadAviAudioData( + int8_t* outBuffer, + const uint32_t bufferLengthInBytes) { if(_aviAudioInFile == 0) { @@ -390,9 +390,9 @@ WebRtc_Word32 ModuleFileUtility::ReadAviAudioData( return -1; } - WebRtc_Word32 length = bufferLengthInBytes; + int32_t length = bufferLengthInBytes; if(_aviAudioInFile->ReadAudio( - reinterpret_cast(outBuffer), + reinterpret_cast(outBuffer), length) != 0) { return -1; @@ -403,9 +403,9 @@ WebRtc_Word32 ModuleFileUtility::ReadAviAudioData( } } -WebRtc_Word32 ModuleFileUtility::ReadAviVideoData( - WebRtc_Word8* outBuffer, - const WebRtc_UWord32 bufferLengthInBytes) +int32_t ModuleFileUtility::ReadAviVideoData( + int8_t* outBuffer, + const uint32_t bufferLengthInBytes) { if(_aviVideoInFile == 0) { @@ -413,9 +413,9 @@ WebRtc_Word32 ModuleFileUtility::ReadAviVideoData( return -1; } - WebRtc_Word32 length = bufferLengthInBytes; + int32_t length = bufferLengthInBytes; if( _aviVideoInFile->ReadVideo( - reinterpret_cast(outBuffer), + reinterpret_cast(outBuffer), length) != 0) { return -1; @@ -424,7 +424,7 @@ WebRtc_Word32 ModuleFileUtility::ReadAviVideoData( } } -WebRtc_Word32 ModuleFileUtility::VideoCodecInst(VideoCodec& codecInst) +int32_t ModuleFileUtility::VideoCodecInst(VideoCodec& codecInst) { WEBRTC_TRACE(kTraceStream, kTraceFile, _id, "ModuleFileUtility::CodecInst(codecInst= 0x%x)", &codecInst); @@ -440,17 +440,17 @@ WebRtc_Word32 ModuleFileUtility::VideoCodecInst(VideoCodec& codecInst) } #endif -WebRtc_Word32 ModuleFileUtility::ReadWavHeader(InStream& wav) +int32_t ModuleFileUtility::ReadWavHeader(InStream& wav) { WAVE_RIFF_header RIFFheaderObj; WAVE_CHUNK_header CHUNKheaderObj; // TODO (hellner): tmpStr and tmpStr2 seems unnecessary here. char tmpStr[6] = "FOUR"; unsigned char tmpStr2[4]; - WebRtc_Word32 i, len; + int32_t i, len; bool dataFound = false; bool fmtFound = false; - WebRtc_Word8 dummyRead; + int8_t dummyRead; _dataSize = 0; @@ -491,10 +491,10 @@ WebRtc_Word32 ModuleFileUtility::ReadWavHeader(InStream& wav) // in a subroutine. memcpy(tmpStr2, &CHUNKheaderObj.fmt_ckSize, 4); CHUNKheaderObj.fmt_ckSize = - (WebRtc_Word32) ((WebRtc_UWord32) tmpStr2[0] + - (((WebRtc_UWord32)tmpStr2[1])<<8) + - (((WebRtc_UWord32)tmpStr2[2])<<16) + - (((WebRtc_UWord32)tmpStr2[3])<<24)); + (int32_t) ((uint32_t) tmpStr2[0] + + (((uint32_t)tmpStr2[1])<<8) + + (((uint32_t)tmpStr2[2])<<16) + + (((uint32_t)tmpStr2[3])<<24)); memcpy(tmpStr, CHUNKheaderObj.fmt_ckID, 4); @@ -506,36 +506,36 @@ WebRtc_Word32 ModuleFileUtility::ReadWavHeader(InStream& wav) memcpy(tmpStr2, &_wavFormatObj.formatTag, 2); _wavFormatObj.formatTag = - (WaveFormats) ((WebRtc_UWord32)tmpStr2[0] + - (((WebRtc_UWord32)tmpStr2[1])<<8)); + (WaveFormats) ((uint32_t)tmpStr2[0] + + (((uint32_t)tmpStr2[1])<<8)); memcpy(tmpStr2, &_wavFormatObj.nChannels, 2); _wavFormatObj.nChannels = - (WebRtc_Word16) ((WebRtc_UWord32)tmpStr2[0] + - (((WebRtc_UWord32)tmpStr2[1])<<8)); + (int16_t) ((uint32_t)tmpStr2[0] + + (((uint32_t)tmpStr2[1])<<8)); memcpy(tmpStr2, &_wavFormatObj.nSamplesPerSec, 4); _wavFormatObj.nSamplesPerSec = - (WebRtc_Word32) ((WebRtc_UWord32)tmpStr2[0] + - (((WebRtc_UWord32)tmpStr2[1])<<8) + - (((WebRtc_UWord32)tmpStr2[2])<<16) + - (((WebRtc_UWord32)tmpStr2[3])<<24)); + (int32_t) ((uint32_t)tmpStr2[0] + + (((uint32_t)tmpStr2[1])<<8) + + (((uint32_t)tmpStr2[2])<<16) + + (((uint32_t)tmpStr2[3])<<24)); memcpy(tmpStr2, &_wavFormatObj.nAvgBytesPerSec, 4); _wavFormatObj.nAvgBytesPerSec = - (WebRtc_Word32) ((WebRtc_UWord32)tmpStr2[0] + - (((WebRtc_UWord32)tmpStr2[1])<<8) + - (((WebRtc_UWord32)tmpStr2[2])<<16) + - (((WebRtc_UWord32)tmpStr2[3])<<24)); + (int32_t) ((uint32_t)tmpStr2[0] + + (((uint32_t)tmpStr2[1])<<8) + + (((uint32_t)tmpStr2[2])<<16) + + (((uint32_t)tmpStr2[3])<<24)); memcpy(tmpStr2, &_wavFormatObj.nBlockAlign, 2); _wavFormatObj.nBlockAlign = - (WebRtc_Word16) ((WebRtc_UWord32)tmpStr2[0] + - (((WebRtc_UWord32)tmpStr2[1])<<8)); + (int16_t) ((uint32_t)tmpStr2[0] + + (((uint32_t)tmpStr2[1])<<8)); memcpy(tmpStr2, &_wavFormatObj.nBitsPerSample, 2); _wavFormatObj.nBitsPerSample = - (WebRtc_Word16) ((WebRtc_UWord32)tmpStr2[0] + - (((WebRtc_UWord32)tmpStr2[1])<<8)); + (int16_t) ((uint32_t)tmpStr2[0] + + (((uint32_t)tmpStr2[1])<<8)); for (i = 0; i < (CHUNKheaderObj.fmt_ckSize - - (WebRtc_Word32)sizeof(WAVE_FMTINFO_header)); + (int32_t)sizeof(WAVE_FMTINFO_header)); i++) { len = wav.Read(&dummyRead, 1); @@ -572,10 +572,10 @@ WebRtc_Word32 ModuleFileUtility::ReadWavHeader(InStream& wav) memcpy(tmpStr2, &CHUNKheaderObj.fmt_ckSize, 4); CHUNKheaderObj.fmt_ckSize = - (WebRtc_Word32) ((WebRtc_UWord32)tmpStr2[0] + - (((WebRtc_UWord32)tmpStr2[1])<<8) + - (((WebRtc_UWord32)tmpStr2[2])<<16) + - (((WebRtc_UWord32)tmpStr2[3])<<24)); + (int32_t) ((uint32_t)tmpStr2[0] + + (((uint32_t)tmpStr2[1])<<8) + + (((uint32_t)tmpStr2[2])<<16) + + (((uint32_t)tmpStr2[3])<<24)); memcpy(tmpStr, CHUNKheaderObj.fmt_ckID, 4); } @@ -637,10 +637,10 @@ WebRtc_Word32 ModuleFileUtility::ReadWavHeader(InStream& wav) return 0; } -WebRtc_Word32 ModuleFileUtility::InitWavCodec(WebRtc_UWord32 samplesPerSec, - WebRtc_UWord32 channels, - WebRtc_UWord32 bitsPerSample, - WebRtc_UWord32 formatTag) +int32_t ModuleFileUtility::InitWavCodec(uint32_t samplesPerSec, + uint32_t channels, + uint32_t bitsPerSample, + uint32_t formatTag) { codec_info_.pltype = -1; codec_info_.plfreq = samplesPerSec; @@ -725,9 +725,9 @@ WebRtc_Word32 ModuleFileUtility::InitWavCodec(WebRtc_UWord32 samplesPerSec, return 0; } -WebRtc_Word32 ModuleFileUtility::InitWavReading(InStream& wav, - const WebRtc_UWord32 start, - const WebRtc_UWord32 stop) +int32_t ModuleFileUtility::InitWavReading(InStream& wav, + const uint32_t start, + const uint32_t stop) { _reading = false; @@ -744,8 +744,8 @@ WebRtc_Word32 ModuleFileUtility::InitWavReading(InStream& wav, if(start > 0) { - WebRtc_UWord8 dummy[WAV_MAX_BUFFER_SIZE]; - WebRtc_Word32 readLength; + uint8_t dummy[WAV_MAX_BUFFER_SIZE]; + int32_t readLength; if(_readSizeBytes <= WAV_MAX_BUFFER_SIZE) { while (_playoutPositionMs < start) @@ -784,10 +784,10 @@ WebRtc_Word32 ModuleFileUtility::InitWavReading(InStream& wav, return 0; } -WebRtc_Word32 ModuleFileUtility::ReadWavDataAsMono( +int32_t ModuleFileUtility::ReadWavDataAsMono( InStream& wav, - WebRtc_Word8* outData, - const WebRtc_UWord32 bufferSize) + int8_t* outData, + const uint32_t bufferSize) { WEBRTC_TRACE( kTraceStream, @@ -800,9 +800,9 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsMono( bufferSize); // The number of bytes that should be read from file. - const WebRtc_UWord32 totalBytesNeeded = _readSizeBytes; + const uint32_t totalBytesNeeded = _readSizeBytes; // The number of bytes that will be written to outData. - const WebRtc_UWord32 bytesRequested = (codec_info_.channels == 2) ? + const uint32_t bytesRequested = (codec_info_.channels == 2) ? totalBytesNeeded >> 1 : totalBytesNeeded; if(bufferSize < bytesRequested) { @@ -824,9 +824,9 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsMono( return -1; } - WebRtc_Word32 bytesRead = ReadWavData( + int32_t bytesRead = ReadWavData( wav, - (codec_info_.channels == 2) ? _tempData : (WebRtc_UWord8*)outData, + (codec_info_.channels == 2) ? _tempData : (uint8_t*)outData, totalBytesNeeded); if(bytesRead == 0) { @@ -841,7 +841,7 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsMono( // Output data is should be mono. if(codec_info_.channels == 2) { - for (WebRtc_UWord32 i = 0; i < bytesRequested / _bytesPerSample; i++) + for (uint32_t i = 0; i < bytesRequested / _bytesPerSample; i++) { // Sample value is the average of left and right buffer rounded to // closest integer value. Note samples can be either 1 or 2 byte. @@ -852,7 +852,7 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsMono( } else { - WebRtc_Word16* sampleData = (WebRtc_Word16*) _tempData; + int16_t* sampleData = (int16_t*) _tempData; sampleData[i] = ((sampleData[2 * i] + sampleData[(2 * i) + 1] + 1) >> 1); } @@ -862,11 +862,11 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsMono( return bytesRequested; } -WebRtc_Word32 ModuleFileUtility::ReadWavDataAsStereo( +int32_t ModuleFileUtility::ReadWavDataAsStereo( InStream& wav, - WebRtc_Word8* outDataLeft, - WebRtc_Word8* outDataRight, - const WebRtc_UWord32 bufferSize) + int8_t* outDataLeft, + int8_t* outDataRight, + const uint32_t bufferSize) { WEBRTC_TRACE( kTraceStream, @@ -903,10 +903,10 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsStereo( } // The number of bytes that should be read from file. - const WebRtc_UWord32 totalBytesNeeded = _readSizeBytes; + const uint32_t totalBytesNeeded = _readSizeBytes; // The number of bytes that will be written to the left and the right // buffers. - const WebRtc_UWord32 bytesRequested = totalBytesNeeded >> 1; + const uint32_t bytesRequested = totalBytesNeeded >> 1; if(bufferSize < bytesRequested) { WEBRTC_TRACE(kTraceError, kTraceFile, _id, @@ -915,7 +915,7 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsStereo( return -1; } - WebRtc_Word32 bytesRead = ReadWavData(wav, _tempData, totalBytesNeeded); + int32_t bytesRead = ReadWavData(wav, _tempData, totalBytesNeeded); if(bytesRead <= 0) { WEBRTC_TRACE(kTraceError, kTraceFile, _id, @@ -927,7 +927,7 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsStereo( // either 1 or 2 bytes if(_bytesPerSample == 1) { - for (WebRtc_UWord32 i = 0; i < bytesRequested; i++) + for (uint32_t i = 0; i < bytesRequested; i++) { outDataLeft[i] = _tempData[2 * i]; outDataRight[i] = _tempData[(2 * i) + 1]; @@ -935,14 +935,14 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsStereo( } else if(_bytesPerSample == 2) { - WebRtc_Word16* sampleData = reinterpret_cast(_tempData); - WebRtc_Word16* outLeft = reinterpret_cast(outDataLeft); - WebRtc_Word16* outRight = reinterpret_cast( + int16_t* sampleData = reinterpret_cast(_tempData); + int16_t* outLeft = reinterpret_cast(outDataLeft); + int16_t* outRight = reinterpret_cast( outDataRight); // Bytes requested to samples requested. - WebRtc_UWord32 sampleCount = bytesRequested >> 1; - for (WebRtc_UWord32 i = 0; i < sampleCount; i++) + uint32_t sampleCount = bytesRequested >> 1; + for (uint32_t i = 0; i < sampleCount; i++) { outLeft[i] = sampleData[2 * i]; outRight[i] = sampleData[(2 * i) + 1]; @@ -957,10 +957,10 @@ WebRtc_Word32 ModuleFileUtility::ReadWavDataAsStereo( return bytesRequested; } -WebRtc_Word32 ModuleFileUtility::ReadWavData( +int32_t ModuleFileUtility::ReadWavData( InStream& wav, - WebRtc_UWord8* buffer, - const WebRtc_UWord32 dataLengthInBytes) + uint8_t* buffer, + const uint32_t dataLengthInBytes) { WEBRTC_TRACE( kTraceStream, @@ -982,7 +982,7 @@ WebRtc_Word32 ModuleFileUtility::ReadWavData( // Make sure that a read won't return too few samples. // TODO (hellner): why not read the remaining bytes needed from the start // of the file? - if((_dataSize - _readPos) < (WebRtc_Word32)dataLengthInBytes) + if((_dataSize - _readPos) < (int32_t)dataLengthInBytes) { // Rewind() being -1 may be due to the file not supposed to be looped. if(wav.Rewind() == -1) @@ -997,7 +997,7 @@ WebRtc_Word32 ModuleFileUtility::ReadWavData( } } - WebRtc_Word32 bytesRead = wav.Read(buffer, dataLengthInBytes); + int32_t bytesRead = wav.Read(buffer, dataLengthInBytes); if(bytesRead < 0) { _reading = false; @@ -1007,7 +1007,7 @@ WebRtc_Word32 ModuleFileUtility::ReadWavData( // This should never happen due to earlier sanity checks. // TODO (hellner): change to an assert and fail here since this should // never happen... - if(bytesRead < (WebRtc_Word32)dataLengthInBytes) + if(bytesRead < (int32_t)dataLengthInBytes) { if((wav.Rewind() == -1) || (InitWavReading(wav, _startPointInMs, _stopPointInMs) == -1)) @@ -1018,7 +1018,7 @@ WebRtc_Word32 ModuleFileUtility::ReadWavData( else { bytesRead = wav.Read(buffer, dataLengthInBytes); - if(bytesRead < (WebRtc_Word32)dataLengthInBytes) + if(bytesRead < (int32_t)dataLengthInBytes) { _reading = false; return -1; @@ -1043,8 +1043,8 @@ WebRtc_Word32 ModuleFileUtility::ReadWavData( return bytesRead; } -WebRtc_Word32 ModuleFileUtility::InitWavWriting(OutStream& wav, - const CodecInst& codecInst) +int32_t ModuleFileUtility::InitWavWriting(OutStream& wav, + const CodecInst& codecInst) { if(set_codec_info(codecInst) != 0) @@ -1054,7 +1054,7 @@ WebRtc_Word32 ModuleFileUtility::InitWavWriting(OutStream& wav, return -1; } _writing = false; - WebRtc_UWord32 channels = (codecInst.channels == 0) ? + uint32_t channels = (codecInst.channels == 0) ? 1 : codecInst.channels; if(STR_CASE_CMP(codecInst.plname, "PCMU") == 0) @@ -1094,9 +1094,9 @@ WebRtc_Word32 ModuleFileUtility::InitWavWriting(OutStream& wav, return 0; } -WebRtc_Word32 ModuleFileUtility::WriteWavData(OutStream& out, - const WebRtc_Word8* buffer, - const WebRtc_UWord32 dataLength) +int32_t ModuleFileUtility::WriteWavData(OutStream& out, + const int8_t* buffer, + const uint32_t dataLength) { WEBRTC_TRACE( kTraceStream, @@ -1123,39 +1123,39 @@ WebRtc_Word32 ModuleFileUtility::WriteWavData(OutStream& out, } -WebRtc_Word32 ModuleFileUtility::WriteWavHeader( +int32_t ModuleFileUtility::WriteWavHeader( OutStream& wav, - const WebRtc_UWord32 freq, - const WebRtc_UWord32 bytesPerSample, - const WebRtc_UWord32 channels, - const WebRtc_UWord32 format, - const WebRtc_UWord32 lengthInBytes) + const uint32_t freq, + const uint32_t bytesPerSample, + const uint32_t channels, + const uint32_t format, + const uint32_t lengthInBytes) { // Frame size in bytes for 10 ms of audio. // TODO (hellner): 44.1 kHz has 440 samples frame size. Doesn't seem to // be taken into consideration here! - WebRtc_Word32 frameSize = (freq / 100) * bytesPerSample * channels; + int32_t frameSize = (freq / 100) * bytesPerSample * channels; // Calculate the number of full frames that the wave file contain. - const WebRtc_Word32 dataLengthInBytes = frameSize * + const int32_t dataLengthInBytes = frameSize * (lengthInBytes / frameSize); - WebRtc_Word8 tmpStr[4]; - WebRtc_Word8 tmpChar; - WebRtc_UWord32 tmpLong; + int8_t tmpStr[4]; + int8_t tmpChar; + uint32_t tmpLong; memcpy(tmpStr, "RIFF", 4); wav.Write(tmpStr, 4); tmpLong = dataLengthInBytes + 36; - tmpChar = (WebRtc_Word8)(tmpLong); + tmpChar = (int8_t)(tmpLong); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 8); + tmpChar = (int8_t)(tmpLong >> 8); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 16); + tmpChar = (int8_t)(tmpLong >> 16); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 24); + tmpChar = (int8_t)(tmpLong >> 24); wav.Write(&tmpChar, 1); memcpy(tmpStr, "WAVE", 4); @@ -1173,44 +1173,44 @@ WebRtc_Word32 ModuleFileUtility::WriteWavHeader( tmpChar = 0; wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(format); + tmpChar = (int8_t)(format); wav.Write(&tmpChar, 1); tmpChar = 0; wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(channels); + tmpChar = (int8_t)(channels); wav.Write(&tmpChar, 1); tmpChar = 0; wav.Write(&tmpChar, 1); tmpLong = freq; - tmpChar = (WebRtc_Word8)(tmpLong); + tmpChar = (int8_t)(tmpLong); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 8); + tmpChar = (int8_t)(tmpLong >> 8); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 16); + tmpChar = (int8_t)(tmpLong >> 16); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 24); + tmpChar = (int8_t)(tmpLong >> 24); wav.Write(&tmpChar, 1); // nAverageBytesPerSec = Sample rate * Bytes per sample * Channels tmpLong = bytesPerSample * freq * channels; - tmpChar = (WebRtc_Word8)(tmpLong); + tmpChar = (int8_t)(tmpLong); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 8); + tmpChar = (int8_t)(tmpLong >> 8); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 16); + tmpChar = (int8_t)(tmpLong >> 16); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 24); + tmpChar = (int8_t)(tmpLong >> 24); wav.Write(&tmpChar, 1); // nBlockAlign = Bytes per sample * Channels - tmpChar = (WebRtc_Word8)(bytesPerSample * channels); + tmpChar = (int8_t)(bytesPerSample * channels); wav.Write(&tmpChar, 1); tmpChar = 0; wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(bytesPerSample*8); + tmpChar = (int8_t)(bytesPerSample*8); wav.Write(&tmpChar, 1); tmpChar = 0; wav.Write(&tmpChar, 1); @@ -1219,26 +1219,26 @@ WebRtc_Word32 ModuleFileUtility::WriteWavHeader( wav.Write(tmpStr, 4); tmpLong = dataLengthInBytes; - tmpChar = (WebRtc_Word8)(tmpLong); + tmpChar = (int8_t)(tmpLong); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 8); + tmpChar = (int8_t)(tmpLong >> 8); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 16); + tmpChar = (int8_t)(tmpLong >> 16); wav.Write(&tmpChar, 1); - tmpChar = (WebRtc_Word8)(tmpLong >> 24); + tmpChar = (int8_t)(tmpLong >> 24); wav.Write(&tmpChar, 1); return 0; } -WebRtc_Word32 ModuleFileUtility::UpdateWavHeader(OutStream& wav) +int32_t ModuleFileUtility::UpdateWavHeader(OutStream& wav) { - WebRtc_Word32 res = -1; + int32_t res = -1; if(wav.Rewind() == -1) { return -1; } - WebRtc_UWord32 channels = (codec_info_.channels == 0) ? + uint32_t channels = (codec_info_.channels == 0) ? 1 : codec_info_.channels; if(STR_CASE_CMP(codec_info_.plname, "L16") == 0) @@ -1260,11 +1260,11 @@ WebRtc_Word32 ModuleFileUtility::UpdateWavHeader(OutStream& wav) } -WebRtc_Word32 ModuleFileUtility::InitPreEncodedReading(InStream& in, - const CodecInst& cinst) +int32_t ModuleFileUtility::InitPreEncodedReading(InStream& in, + const CodecInst& cinst) { - WebRtc_UWord8 preEncodedID; + uint8_t preEncodedID; in.Read(&preEncodedID, 1); MediaFileUtility_CodecType codecType = @@ -1287,10 +1287,10 @@ WebRtc_Word32 ModuleFileUtility::InitPreEncodedReading(InStream& in, return 0; } -WebRtc_Word32 ModuleFileUtility::ReadPreEncodedData( +int32_t ModuleFileUtility::ReadPreEncodedData( InStream& in, - WebRtc_Word8* outData, - const WebRtc_UWord32 bufferSize) + int8_t* outData, + const uint32_t bufferSize) { WEBRTC_TRACE( kTraceStream, @@ -1307,10 +1307,10 @@ WebRtc_Word32 ModuleFileUtility::ReadPreEncodedData( WEBRTC_TRACE(kTraceError, kTraceFile, _id, "output buffer NULL"); } - WebRtc_UWord32 frameLen; - WebRtc_UWord8 buf[64]; + uint32_t frameLen; + uint8_t buf[64]; // Each frame has a two byte header containing the frame length. - WebRtc_Word32 res = in.Read(buf, 2); + int32_t res = in.Read(buf, 2); if(res != 2) { if(!in.Rewind()) @@ -1338,7 +1338,7 @@ WebRtc_Word32 ModuleFileUtility::ReadPreEncodedData( return in.Read(outData, frameLen); } -WebRtc_Word32 ModuleFileUtility::InitPreEncodedWriting( +int32_t ModuleFileUtility::InitPreEncodedWriting( OutStream& out, const CodecInst& codecInst) { @@ -1354,10 +1354,10 @@ WebRtc_Word32 ModuleFileUtility::InitPreEncodedWriting( return 0; } -WebRtc_Word32 ModuleFileUtility::WritePreEncodedData( +int32_t ModuleFileUtility::WritePreEncodedData( OutStream& out, - const WebRtc_Word8* buffer, - const WebRtc_UWord32 dataLength) + const int8_t* buffer, + const uint32_t dataLength) { WEBRTC_TRACE( kTraceStream, @@ -1374,10 +1374,10 @@ WebRtc_Word32 ModuleFileUtility::WritePreEncodedData( WEBRTC_TRACE(kTraceError, kTraceFile, _id,"buffer NULL"); } - WebRtc_Word32 bytesWritten = 0; + int32_t bytesWritten = 0; // The first two bytes is the size of the frame. - WebRtc_Word16 lengthBuf; - lengthBuf = (WebRtc_Word16)dataLength; + int16_t lengthBuf; + lengthBuf = (int16_t)dataLength; if(!out.Write(&lengthBuf, 2)) { return -1; @@ -1392,10 +1392,10 @@ WebRtc_Word32 ModuleFileUtility::WritePreEncodedData( return bytesWritten; } -WebRtc_Word32 ModuleFileUtility::InitCompressedReading( +int32_t ModuleFileUtility::InitCompressedReading( InStream& in, - const WebRtc_UWord32 start, - const WebRtc_UWord32 stop) + const uint32_t start, + const uint32_t stop) { WEBRTC_TRACE( kTraceDebug, @@ -1409,7 +1409,7 @@ WebRtc_Word32 ModuleFileUtility::InitCompressedReading( #if defined(WEBRTC_CODEC_AMR) || defined(WEBRTC_CODEC_AMRWB) || \ defined(WEBRTC_CODEC_ILBC) - WebRtc_Word16 read_len = 0; + int16_t read_len = 0; #endif _codecId = kCodecNoCodec; _playoutPositionMs = 0; @@ -1419,14 +1419,14 @@ WebRtc_Word32 ModuleFileUtility::InitCompressedReading( _stopPointInMs = stop; #ifdef WEBRTC_CODEC_AMR - WebRtc_Word32 AMRmode2bytes[9]={12,13,15,17,19,20,26,31,5}; + int32_t AMRmode2bytes[9]={12,13,15,17,19,20,26,31,5}; #endif #ifdef WEBRTC_CODEC_AMRWB - WebRtc_Word32 AMRWBmode2bytes[10]={17,23,32,36,40,46,50,58,60,6}; + int32_t AMRWBmode2bytes[10]={17,23,32,36,40,46,50,58,60,6}; #endif // Read the codec name - WebRtc_Word32 cnt = 0; + int32_t cnt = 0; char buf[64]; do { @@ -1451,7 +1451,7 @@ WebRtc_Word32 ModuleFileUtility::InitCompressedReading( codec_info_.plfreq = 8000; codec_info_.channels = 1; - WebRtc_Word16 mode = 0; + int16_t mode = 0; if(_startPointInMs > 0) { while (_playoutPositionMs <= _startPointInMs) @@ -1495,7 +1495,7 @@ WebRtc_Word32 ModuleFileUtility::InitCompressedReading( codec_info_.plfreq = 16000; codec_info_.channels = 1; - WebRtc_Word16 mode = 0; + int16_t mode = 0; if(_startPointInMs > 0) { while (_playoutPositionMs <= _startPointInMs) @@ -1591,9 +1591,9 @@ WebRtc_Word32 ModuleFileUtility::InitCompressedReading( return 0; } -WebRtc_Word32 ModuleFileUtility::ReadCompressedData(InStream& in, - WebRtc_Word8* outData, - WebRtc_UWord32 bufferSize) +int32_t ModuleFileUtility::ReadCompressedData(InStream& in, + int8_t* outData, + uint32_t bufferSize) { WEBRTC_TRACE( kTraceStream, @@ -1606,12 +1606,12 @@ WebRtc_Word32 ModuleFileUtility::ReadCompressedData(InStream& in, bufferSize); #ifdef WEBRTC_CODEC_AMR - WebRtc_UWord32 AMRmode2bytes[9]={12,13,15,17,19,20,26,31,5}; + uint32_t AMRmode2bytes[9]={12,13,15,17,19,20,26,31,5}; #endif #ifdef WEBRTC_CODEC_AMRWB - WebRtc_UWord32 AMRWBmode2bytes[10]={17,23,32,36,40,46,50,58,60,6}; + uint32_t AMRWBmode2bytes[10]={17,23,32,36,40,46,50,58,60,6}; #endif - WebRtc_UWord32 bytesRead = 0; + uint32_t bytesRead = 0; if(! _reading) { @@ -1622,7 +1622,7 @@ WebRtc_Word32 ModuleFileUtility::ReadCompressedData(InStream& in, #ifdef WEBRTC_CODEC_AMR if(_codecId == kCodecAmr) { - WebRtc_Word32 res = in.Read(outData, 1); + int32_t res = in.Read(outData, 1); if(res != 1) { if(!in.Rewind()) @@ -1641,7 +1641,7 @@ WebRtc_Word32 ModuleFileUtility::ReadCompressedData(InStream& in, return -1; } } - const WebRtc_Word16 mode = (outData[0]>>3)&0xF; + const int16_t mode = (outData[0]>>3)&0xF; if((mode < 0) || (mode > 8)) { @@ -1680,7 +1680,7 @@ WebRtc_Word32 ModuleFileUtility::ReadCompressedData(InStream& in, #ifdef WEBRTC_CODEC_AMRWB if(_codecId == kCodecAmrWb) { - WebRtc_Word32 res = in.Read(outData, 1); + int32_t res = in.Read(outData, 1); if(res != 1) { if(!in.Rewind()) @@ -1699,7 +1699,7 @@ WebRtc_Word32 ModuleFileUtility::ReadCompressedData(InStream& in, return -1; } } - WebRtc_Word16 mode = (outData[0]>>3)&0xF; + int16_t mode = (outData[0]>>3)&0xF; if((mode < 0) || (mode > 8)) { @@ -1736,7 +1736,7 @@ WebRtc_Word32 ModuleFileUtility::ReadCompressedData(InStream& in, if((_codecId == kCodecIlbc20Ms) || (_codecId == kCodecIlbc30Ms)) { - WebRtc_UWord32 byteSize = 0; + uint32_t byteSize = 0; if(_codecId == kCodecIlbc30Ms) { byteSize = 50; @@ -1798,7 +1798,7 @@ WebRtc_Word32 ModuleFileUtility::ReadCompressedData(InStream& in, return bytesRead; } -WebRtc_Word32 ModuleFileUtility::InitCompressedWriting( +int32_t ModuleFileUtility::InitCompressedWriting( OutStream& out, const CodecInst& codecInst) { @@ -1865,10 +1865,10 @@ WebRtc_Word32 ModuleFileUtility::InitCompressedWriting( return -1; } -WebRtc_Word32 ModuleFileUtility::WriteCompressedData( +int32_t ModuleFileUtility::WriteCompressedData( OutStream& out, - const WebRtc_Word8* buffer, - const WebRtc_UWord32 dataLength) + const int8_t* buffer, + const uint32_t dataLength) { WEBRTC_TRACE( kTraceStream, @@ -1892,10 +1892,10 @@ WebRtc_Word32 ModuleFileUtility::WriteCompressedData( return dataLength; } -WebRtc_Word32 ModuleFileUtility::InitPCMReading(InStream& pcm, - const WebRtc_UWord32 start, - const WebRtc_UWord32 stop, - WebRtc_UWord32 freq) +int32_t ModuleFileUtility::InitPCMReading(InStream& pcm, + const uint32_t start, + const uint32_t stop, + uint32_t freq) { WEBRTC_TRACE( kTraceInfo, @@ -1908,8 +1908,8 @@ WebRtc_Word32 ModuleFileUtility::InitPCMReading(InStream& pcm, stop, freq); - WebRtc_Word8 dummy[320]; - WebRtc_Word32 read_len; + int8_t dummy[320]; + int32_t read_len; _playoutPositionMs = 0; _startPointInMs = start; @@ -1968,9 +1968,9 @@ WebRtc_Word32 ModuleFileUtility::InitPCMReading(InStream& pcm, return 0; } -WebRtc_Word32 ModuleFileUtility::ReadPCMData(InStream& pcm, - WebRtc_Word8* outData, - WebRtc_UWord32 bufferSize) +int32_t ModuleFileUtility::ReadPCMData(InStream& pcm, + int8_t* outData, + uint32_t bufferSize) { WEBRTC_TRACE( kTraceStream, @@ -1987,7 +1987,7 @@ WebRtc_Word32 ModuleFileUtility::ReadPCMData(InStream& pcm, } // Readsize for 10ms of audio data (2 bytes per sample). - WebRtc_UWord32 bytesRequested = 2 * codec_info_.plfreq / 100; + uint32_t bytesRequested = 2 * codec_info_.plfreq / 100; if(bufferSize < bytesRequested) { WEBRTC_TRACE(kTraceError, kTraceFile, _id, @@ -1996,7 +1996,7 @@ WebRtc_Word32 ModuleFileUtility::ReadPCMData(InStream& pcm, return -1; } - WebRtc_UWord32 bytesRead = pcm.Read(outData, bytesRequested); + uint32_t bytesRead = pcm.Read(outData, bytesRequested); if(bytesRead < bytesRequested) { if(pcm.Rewind() == -1) @@ -2012,8 +2012,8 @@ WebRtc_Word32 ModuleFileUtility::ReadPCMData(InStream& pcm, } else { - WebRtc_Word32 rest = bytesRequested - bytesRead; - WebRtc_Word32 len = pcm.Read(&(outData[bytesRead]), rest); + int32_t rest = bytesRequested - bytesRead; + int32_t len = pcm.Read(&(outData[bytesRead]), rest); if(len == rest) { bytesRead += len; @@ -2053,8 +2053,7 @@ WebRtc_Word32 ModuleFileUtility::ReadPCMData(InStream& pcm, return bytesRead; } -WebRtc_Word32 ModuleFileUtility::InitPCMWriting(OutStream& out, - WebRtc_UWord32 freq) +int32_t ModuleFileUtility::InitPCMWriting(OutStream& out, uint32_t freq) { if(freq == 8000) @@ -2103,9 +2102,9 @@ WebRtc_Word32 ModuleFileUtility::InitPCMWriting(OutStream& out, return 0; } -WebRtc_Word32 ModuleFileUtility::WritePCMData(OutStream& out, - const WebRtc_Word8* buffer, - const WebRtc_UWord32 dataLength) +int32_t ModuleFileUtility::WritePCMData(OutStream& out, + const int8_t* buffer, + const uint32_t dataLength) { WEBRTC_TRACE( kTraceStream, @@ -2130,7 +2129,7 @@ WebRtc_Word32 ModuleFileUtility::WritePCMData(OutStream& out, return dataLength; } -WebRtc_Word32 ModuleFileUtility::codec_info(CodecInst& codecInst) +int32_t ModuleFileUtility::codec_info(CodecInst& codecInst) { WEBRTC_TRACE(kTraceStream, kTraceFile, _id, "ModuleFileUtility::codec_info(codecInst= 0x%x)", &codecInst); @@ -2145,7 +2144,7 @@ WebRtc_Word32 ModuleFileUtility::codec_info(CodecInst& codecInst) return 0; } -WebRtc_Word32 ModuleFileUtility::set_codec_info(const CodecInst& codecInst) +int32_t ModuleFileUtility::set_codec_info(const CodecInst& codecInst) { _codecId = kCodecNoCodec; @@ -2310,9 +2309,9 @@ WebRtc_Word32 ModuleFileUtility::set_codec_info(const CodecInst& codecInst) return 0; } -WebRtc_Word32 ModuleFileUtility::FileDurationMs(const char* fileName, - const FileFormats fileFormat, - const WebRtc_UWord32 freqInHz) +int32_t ModuleFileUtility::FileDurationMs(const char* fileName, + const FileFormats fileFormat, + const uint32_t freqInHz) { if(fileName == NULL) @@ -2321,7 +2320,7 @@ WebRtc_Word32 ModuleFileUtility::FileDurationMs(const char* fileName, return -1; } - WebRtc_Word32 time_in_ms = -1; + int32_t time_in_ms = -1; struct stat file_size; if(stat(fileName,&file_size) == -1) { @@ -2361,21 +2360,21 @@ WebRtc_Word32 ModuleFileUtility::FileDurationMs(const char* fileName, case kFileFormatPcm16kHzFile: { // 16 samples per ms. 2 bytes per sample. - WebRtc_Word32 denominator = 16*2; + int32_t denominator = 16*2; time_in_ms = (file_size.st_size)/denominator; break; } case kFileFormatPcm8kHzFile: { // 8 samples per ms. 2 bytes per sample. - WebRtc_Word32 denominator = 8*2; + int32_t denominator = 8*2; time_in_ms = (file_size.st_size)/denominator; break; } case kFileFormatCompressedFile: { - WebRtc_Word32 cnt = 0; - WebRtc_Word32 read_len = 0; + int32_t cnt = 0; + int32_t read_len = 0; char buf[64]; do { @@ -2397,14 +2396,14 @@ WebRtc_Word32 ModuleFileUtility::FileDurationMs(const char* fileName, #ifdef WEBRTC_CODEC_AMR if(!strcmp("#!AMR\n", buf)) { - WebRtc_UWord8 dummy; + uint8_t dummy; read_len = inStreamObj->Read(&dummy, 1); if(read_len != 1) { return -1; } - WebRtc_Word16 AMRMode = (dummy>>3)&0xF; + int16_t AMRMode = (dummy>>3)&0xF; // TODO (hellner): use tables instead of hardcoding like this! // Additionally, this calculation does not @@ -2459,7 +2458,7 @@ WebRtc_Word32 ModuleFileUtility::FileDurationMs(const char* fileName, #ifdef WEBRTC_CODEC_AMRWB if(!strcmp("#!AMRWB\n", buf)) { - WebRtc_UWord8 dummy; + uint8_t dummy; read_len = inStreamObj->Read(&dummy, 1); if(read_len != 1) { @@ -2467,7 +2466,7 @@ WebRtc_Word32 ModuleFileUtility::FileDurationMs(const char* fileName, } // TODO (hellner): use tables instead of hardcoding like this! - WebRtc_Word16 AMRWBMode = (dummy>>3)&0xF; + int16_t AMRWBMode = (dummy>>3)&0xF; switch(AMRWBMode) { // Mode 0: 6.6 kbit/sec -> 132 bits per 20 ms frame. @@ -2546,7 +2545,7 @@ WebRtc_Word32 ModuleFileUtility::FileDurationMs(const char* fileName, return time_in_ms; } -WebRtc_UWord32 ModuleFileUtility::PlayoutPositionMs() +uint32_t ModuleFileUtility::PlayoutPositionMs() { WEBRTC_TRACE(kTraceStream, kTraceFile, _id, "ModuleFileUtility::PlayoutPosition()"); diff --git a/webrtc/modules/media_file/source/media_file_utility.h b/webrtc/modules/media_file/source/media_file_utility.h index d3eaef1e9e..049f25f5f6 100644 --- a/webrtc/modules/media_file/source/media_file_utility.h +++ b/webrtc/modules/media_file/source/media_file_utility.h @@ -26,7 +26,7 @@ class ModuleFileUtility { public: - ModuleFileUtility(const WebRtc_Word32 id); + ModuleFileUtility(const int32_t id); ~ModuleFileUtility(); #ifdef WEBRTC_MODULE_UTILITY_VIDEO @@ -34,8 +34,7 @@ public: // allowed). If loop is true the file will be played until StopPlaying() is // called. When end of file is reached the file is read from the start. // Only video will be read if videoOnly is true. - WebRtc_Word32 InitAviReading(const char* fileName, bool videoOnly, - bool loop); + int32_t InitAviReading(const char* fileName, bool videoOnly, bool loop); // Put 10-60ms of audio data from file into the outBuffer depending on // codec frame size. bufferLengthInBytes indicates the size of outBuffer. @@ -43,31 +42,31 @@ public: // Note: This API only play mono audio but can be used on file containing // audio with more channels (in which case the audio will be coverted to // mono). - WebRtc_Word32 ReadAviAudioData(WebRtc_Word8* outBuffer, - const WebRtc_UWord32 bufferLengthInBytes); + int32_t ReadAviAudioData(int8_t* outBuffer, + const uint32_t bufferLengthInBytes); // Put one video frame into outBuffer. bufferLengthInBytes indicates the // size of outBuffer. // The return value is the number of bytes written to videoBuffer. - WebRtc_Word32 ReadAviVideoData(WebRtc_Word8* videoBuffer, - const WebRtc_UWord32 bufferLengthInBytes); + int32_t ReadAviVideoData(int8_t* videoBuffer, + const uint32_t bufferLengthInBytes); // Open/create the file specified by fileName for writing audio/video data // (relative path is allowed). codecInst specifies the encoding of the audio // data. videoCodecInst specifies the encoding of the video data. Only video // data will be recorded if videoOnly is true. - WebRtc_Word32 InitAviWriting(const char* filename, - const CodecInst& codecInst, - const VideoCodec& videoCodecInst, - const bool videoOnly); + int32_t InitAviWriting(const char* filename, + const CodecInst& codecInst, + const VideoCodec& videoCodecInst, + const bool videoOnly); // Write one audio frame, i.e. the bufferLengthinBytes first bytes of // audioBuffer, to file. The audio frame size is determined by the // codecInst.pacsize parameter of the last sucessfull // InitAviWriting(..) call. // Note: bufferLength must be exactly one frame. - WebRtc_Word32 WriteAviAudioData(const WebRtc_Word8* audioBuffer, - WebRtc_UWord32 bufferLengthInBytes); + int32_t WriteAviAudioData(const int8_t* audioBuffer, + uint32_t bufferLengthInBytes); // Write one video frame, i.e. the bufferLength first bytes of videoBuffer, @@ -76,21 +75,21 @@ public: // same as what was specified by videoCodecInst for the last successfull // InitAviWriting(..) call. The videoBuffer must contain exactly // one video frame. - WebRtc_Word32 WriteAviVideoData(const WebRtc_Word8* videoBuffer, - WebRtc_UWord32 bufferLengthInBytes); + int32_t WriteAviVideoData(const int8_t* videoBuffer, + uint32_t bufferLengthInBytes); // Stop recording to file or stream. - WebRtc_Word32 CloseAviFile(); + int32_t CloseAviFile(); - WebRtc_Word32 VideoCodecInst(VideoCodec& codecInst); + int32_t VideoCodecInst(VideoCodec& codecInst); #endif // #ifdef WEBRTC_MODULE_UTILITY_VIDEO // Prepare for playing audio from stream. // startPointMs and stopPointMs, unless zero, specify what part of the file // should be read. From startPointMs ms to stopPointMs ms. - WebRtc_Word32 InitWavReading(InStream& stream, - const WebRtc_UWord32 startPointMs = 0, - const WebRtc_UWord32 stopPointMs = 0); + int32_t InitWavReading(InStream& stream, + const uint32_t startPointMs = 0, + const uint32_t stopPointMs = 0); // Put 10-60ms of audio data from stream into the audioBuffer depending on // codec frame size. dataLengthInBytes indicates the size of audioBuffer. @@ -98,8 +97,8 @@ public: // Note: This API only play mono audio but can be used on file containing // audio with more channels (in which case the audio will be converted to // mono). - WebRtc_Word32 ReadWavDataAsMono(InStream& stream, WebRtc_Word8* audioBuffer, - const WebRtc_UWord32 dataLengthInBytes); + int32_t ReadWavDataAsMono(InStream& stream, int8_t* audioBuffer, + const uint32_t dataLengthInBytes); // Put 10-60ms, depending on codec frame size, of audio data from file into // audioBufferLeft and audioBufferRight. The buffers contain the left and @@ -109,141 +108,140 @@ public: // The return value is the number of bytes read for each buffer. // Note: This API can only be successfully called for WAV files with stereo // audio. - WebRtc_Word32 ReadWavDataAsStereo(InStream& wav, - WebRtc_Word8* audioBufferLeft, - WebRtc_Word8* audioBufferRight, - const WebRtc_UWord32 bufferLength); + int32_t ReadWavDataAsStereo(InStream& wav, + int8_t* audioBufferLeft, + int8_t* audioBufferRight, + const uint32_t bufferLength); // Prepare for recording audio to stream. // codecInst specifies the encoding of the audio data. // Note: codecInst.channels should be set to 2 for stereo (and 1 for // mono). Stereo is only supported for WAV files. - WebRtc_Word32 InitWavWriting(OutStream& stream, const CodecInst& codecInst); + int32_t InitWavWriting(OutStream& stream, const CodecInst& codecInst); // Write one audio frame, i.e. the bufferLength first bytes of audioBuffer, // to file. The audio frame size is determined by the codecInst.pacsize // parameter of the last sucessfull StartRecordingAudioFile(..) call. // The return value is the number of bytes written to audioBuffer. - WebRtc_Word32 WriteWavData(OutStream& stream, - const WebRtc_Word8* audioBuffer, - const WebRtc_UWord32 bufferLength); + int32_t WriteWavData(OutStream& stream, + const int8_t* audioBuffer, + const uint32_t bufferLength); // Finalizes the WAV header so that it is correct if nothing more will be // written to stream. // Note: this API must be called before closing stream to ensure that the // WAVE header is updated with the file size. Don't call this API // if more samples are to be written to stream. - WebRtc_Word32 UpdateWavHeader(OutStream& stream); + int32_t UpdateWavHeader(OutStream& stream); // Prepare for playing audio from stream. // startPointMs and stopPointMs, unless zero, specify what part of the file // should be read. From startPointMs ms to stopPointMs ms. // freqInHz is the PCM sampling frequency. // NOTE, allowed frequencies are 8000, 16000 and 32000 (Hz) - WebRtc_Word32 InitPCMReading(InStream& stream, - const WebRtc_UWord32 startPointMs = 0, - const WebRtc_UWord32 stopPointMs = 0, - const WebRtc_UWord32 freqInHz = 16000); + int32_t InitPCMReading(InStream& stream, + const uint32_t startPointMs = 0, + const uint32_t stopPointMs = 0, + const uint32_t freqInHz = 16000); // Put 10-60ms of audio data from stream into the audioBuffer depending on // codec frame size. dataLengthInBytes indicates the size of audioBuffer. // The return value is the number of bytes written to audioBuffer. - WebRtc_Word32 ReadPCMData(InStream& stream, WebRtc_Word8* audioBuffer, - const WebRtc_UWord32 dataLengthInBytes); + int32_t ReadPCMData(InStream& stream, int8_t* audioBuffer, + const uint32_t dataLengthInBytes); // Prepare for recording audio to stream. // freqInHz is the PCM sampling frequency. // NOTE, allowed frequencies are 8000, 16000 and 32000 (Hz) - WebRtc_Word32 InitPCMWriting(OutStream& stream, - const WebRtc_UWord32 freqInHz = 16000); + int32_t InitPCMWriting(OutStream& stream, const uint32_t freqInHz = 16000); // Write one 10ms audio frame, i.e. the bufferLength first bytes of // audioBuffer, to file. The audio frame size is determined by the freqInHz // parameter of the last sucessfull InitPCMWriting(..) call. // The return value is the number of bytes written to audioBuffer. - WebRtc_Word32 WritePCMData(OutStream& stream, - const WebRtc_Word8* audioBuffer, - WebRtc_UWord32 bufferLength); + int32_t WritePCMData(OutStream& stream, + const int8_t* audioBuffer, + uint32_t bufferLength); // Prepare for playing audio from stream. // startPointMs and stopPointMs, unless zero, specify what part of the file // should be read. From startPointMs ms to stopPointMs ms. - WebRtc_Word32 InitCompressedReading(InStream& stream, - const WebRtc_UWord32 startPointMs = 0, - const WebRtc_UWord32 stopPointMs = 0); + int32_t InitCompressedReading(InStream& stream, + const uint32_t startPointMs = 0, + const uint32_t stopPointMs = 0); // Put 10-60ms of audio data from stream into the audioBuffer depending on // codec frame size. dataLengthInBytes indicates the size of audioBuffer. // The return value is the number of bytes written to audioBuffer. - WebRtc_Word32 ReadCompressedData(InStream& stream, - WebRtc_Word8* audioBuffer, - const WebRtc_UWord32 dataLengthInBytes); + int32_t ReadCompressedData(InStream& stream, + int8_t* audioBuffer, + const uint32_t dataLengthInBytes); // Prepare for recording audio to stream. // codecInst specifies the encoding of the audio data. - WebRtc_Word32 InitCompressedWriting(OutStream& stream, - const CodecInst& codecInst); + int32_t InitCompressedWriting(OutStream& stream, + const CodecInst& codecInst); // Write one audio frame, i.e. the bufferLength first bytes of audioBuffer, // to file. The audio frame size is determined by the codecInst.pacsize // parameter of the last sucessfull InitCompressedWriting(..) call. // The return value is the number of bytes written to stream. // Note: bufferLength must be exactly one frame. - WebRtc_Word32 WriteCompressedData(OutStream& stream, - const WebRtc_Word8* audioBuffer, - const WebRtc_UWord32 bufferLength); + int32_t WriteCompressedData(OutStream& stream, + const int8_t* audioBuffer, + const uint32_t bufferLength); // Prepare for playing audio from stream. // codecInst specifies the encoding of the audio data. - WebRtc_Word32 InitPreEncodedReading(InStream& stream, - const CodecInst& codecInst); + int32_t InitPreEncodedReading(InStream& stream, + const CodecInst& codecInst); // Put 10-60ms of audio data from stream into the audioBuffer depending on // codec frame size. dataLengthInBytes indicates the size of audioBuffer. // The return value is the number of bytes written to audioBuffer. - WebRtc_Word32 ReadPreEncodedData(InStream& stream, - WebRtc_Word8* audioBuffer, - const WebRtc_UWord32 dataLengthInBytes); + int32_t ReadPreEncodedData(InStream& stream, + int8_t* audioBuffer, + const uint32_t dataLengthInBytes); // Prepare for recording audio to stream. // codecInst specifies the encoding of the audio data. - WebRtc_Word32 InitPreEncodedWriting(OutStream& stream, - const CodecInst& codecInst); + int32_t InitPreEncodedWriting(OutStream& stream, + const CodecInst& codecInst); // Write one audio frame, i.e. the bufferLength first bytes of audioBuffer, // to stream. The audio frame size is determined by the codecInst.pacsize // parameter of the last sucessfull InitPreEncodedWriting(..) call. // The return value is the number of bytes written to stream. // Note: bufferLength must be exactly one frame. - WebRtc_Word32 WritePreEncodedData(OutStream& stream, - const WebRtc_Word8* inData, - const WebRtc_UWord32 dataLengthInBytes); + int32_t WritePreEncodedData(OutStream& stream, + const int8_t* inData, + const uint32_t dataLengthInBytes); // Set durationMs to the size of the file (in ms) specified by fileName. // freqInHz specifies the sampling frequency of the file. - WebRtc_Word32 FileDurationMs(const char* fileName, - const FileFormats fileFormat, - const WebRtc_UWord32 freqInHz = 16000); + int32_t FileDurationMs(const char* fileName, + const FileFormats fileFormat, + const uint32_t freqInHz = 16000); // Return the number of ms that have been played so far. - WebRtc_UWord32 PlayoutPositionMs(); + uint32_t PlayoutPositionMs(); // Update codecInst according to the current audio codec being used for // reading or writing. - WebRtc_Word32 codec_info(CodecInst& codecInst); + int32_t codec_info(CodecInst& codecInst); private: // Biggest WAV frame supported is 10 ms at 48kHz of 2 channel, 16 bit audio. enum{WAV_MAX_BUFFER_SIZE = 480*2*2}; - WebRtc_Word32 InitWavCodec(WebRtc_UWord32 samplesPerSec, - WebRtc_UWord32 channels, - WebRtc_UWord32 bitsPerSample, - WebRtc_UWord32 formatTag); + int32_t InitWavCodec(uint32_t samplesPerSec, + uint32_t channels, + uint32_t bitsPerSample, + uint32_t formatTag); // Parse the WAV header in stream. - WebRtc_Word32 ReadWavHeader(InStream& stream); + int32_t ReadWavHeader(InStream& stream); // Update the WAV header. freqInHz, bytesPerSample, channels, format, // lengthInBytes specify characterists of the audio data. @@ -251,30 +249,30 @@ private: // bytes. channels is the number of channels, e.g. 1 is mono and 2 is // stereo. format is the encode format (e.g. PCMU, PCMA, PCM etc). // lengthInBytes is the number of bytes the audio samples are using up. - WebRtc_Word32 WriteWavHeader(OutStream& stream, - const WebRtc_UWord32 freqInHz, - const WebRtc_UWord32 bytesPerSample, - const WebRtc_UWord32 channels, - const WebRtc_UWord32 format, - const WebRtc_UWord32 lengthInBytes); + int32_t WriteWavHeader(OutStream& stream, + const uint32_t freqInHz, + const uint32_t bytesPerSample, + const uint32_t channels, + const uint32_t format, + const uint32_t lengthInBytes); // Put dataLengthInBytes of audio data from stream into the audioBuffer. // The return value is the number of bytes written to audioBuffer. - WebRtc_Word32 ReadWavData(InStream& stream, WebRtc_UWord8* audioBuffer, - const WebRtc_UWord32 dataLengthInBytes); + int32_t ReadWavData(InStream& stream, uint8_t* audioBuffer, + const uint32_t dataLengthInBytes); // Update the current audio codec being used for reading or writing // according to codecInst. - WebRtc_Word32 set_codec_info(const CodecInst& codecInst); + int32_t set_codec_info(const CodecInst& codecInst); struct WAVE_FMTINFO_header { - WebRtc_Word16 formatTag; - WebRtc_Word16 nChannels; - WebRtc_Word32 nSamplesPerSec; - WebRtc_Word32 nAvgBytesPerSec; - WebRtc_Word16 nBlockAlign; - WebRtc_Word16 nBitsPerSample; + int16_t formatTag; + int16_t nChannels; + int32_t nSamplesPerSec; + int32_t nAvgBytesPerSec; + int16_t nBlockAlign; + int16_t nBitsPerSample; }; // Identifiers for preencoded files. enum MediaFileUtility_CodecType @@ -312,31 +310,31 @@ private: // TODO (hellner): why store multiple formats. Just store either codec_info_ // or _wavFormatObj and supply conversion functions. WAVE_FMTINFO_header _wavFormatObj; - WebRtc_Word32 _dataSize; // Chunk size if reading a WAV file + int32_t _dataSize; // Chunk size if reading a WAV file // Number of bytes to read. I.e. frame size in bytes. May be multiple // chunks if reading WAV. - WebRtc_Word32 _readSizeBytes; + int32_t _readSizeBytes; - WebRtc_Word32 _id; + int32_t _id; - WebRtc_UWord32 _stopPointInMs; - WebRtc_UWord32 _startPointInMs; - WebRtc_UWord32 _playoutPositionMs; - WebRtc_UWord32 _bytesWritten; + uint32_t _stopPointInMs; + uint32_t _startPointInMs; + uint32_t _playoutPositionMs; + uint32_t _bytesWritten; CodecInst codec_info_; MediaFileUtility_CodecType _codecId; // The amount of bytes, on average, used for one audio sample. - WebRtc_Word32 _bytesPerSample; - WebRtc_Word32 _readPos; + int32_t _bytesPerSample; + int32_t _readPos; // Only reading or writing can be enabled, not both. bool _reading; bool _writing; // Scratch buffer used for turning stereo audio to mono. - WebRtc_UWord8 _tempData[WAV_MAX_BUFFER_SIZE]; + uint8_t _tempData[WAV_MAX_BUFFER_SIZE]; #ifdef WEBRTC_MODULE_UTILITY_VIDEO AviFile* _aviAudioInFile;