From 09e771998c73a6533f48c5a6d568c80b682aab77 Mon Sep 17 00:00:00 2001 From: "leozwang@webrtc.org" Date: Thu, 1 Mar 2012 18:35:54 +0000 Subject: [PATCH] Correct WebRtc_word8 usage in media file module BUG=http://code.google.com/p/webrtc/issues/detail?id=311&sort=-id TEST=build on all platforms Review URL: https://webrtc-codereview.appspot.com/427002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1817 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/media_file/interface/media_file.h | 12 +++++----- src/modules/media_file/source/avi_file.h | 4 ++-- .../media_file/source/media_file_impl.cc | 20 ++++++++-------- .../media_file/source/media_file_impl.h | 24 +++++++++---------- .../media_file/source/media_file_utility.cc | 14 +++++------ .../media_file/source/media_file_utility.h | 8 +++---- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/modules/media_file/interface/media_file.h b/src/modules/media_file/interface/media_file.h index bc857ad7a2..ea10d82d0f 100644 --- a/src/modules/media_file/interface/media_file.h +++ b/src/modules/media_file/interface/media_file.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -77,7 +77,7 @@ public: // 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( - const WebRtc_Word8* fileName, + const char* fileName, const WebRtc_UWord32 notificationTimeMs = 0, const bool loop = false, const FileFormats format = kFileFormatPcm16kHzFile, @@ -90,7 +90,7 @@ public: // 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 WebRtc_Word8* fileName, + virtual WebRtc_Word32 StartPlayingVideoFile(const char* fileName, const bool loop, bool videoOnly, const FileFormats format) = 0; @@ -154,7 +154,7 @@ public: // 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( - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const WebRtc_UWord32 notificationTimeMs = 0, @@ -166,7 +166,7 @@ public: // videoCodecInst specifies the encoding of the video data. Only video data // will be recorded if videoOnly is true. virtual WebRtc_Word32 StartRecordingVideoFile( - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, @@ -206,7 +206,7 @@ public: // format specifies the type of file fileName refers to. freqInHz specifies // the sampling frequency of the file. virtual WebRtc_Word32 FileDurationMs( - const WebRtc_Word8* fileName, + const char* fileName, WebRtc_UWord32& durationMs, const FileFormats format, const WebRtc_UWord32 freqInHz = 16000) = 0; diff --git a/src/modules/media_file/source/avi_file.h b/src/modules/media_file/source/avi_file.h index 73a19afd48..0111a79c3f 100644 --- a/src/modules/media_file/source/avi_file.h +++ b/src/modules/media_file/source/avi_file.h @@ -102,14 +102,14 @@ public: WebRtc_Word32 CreateAudioStream(const AVISTREAMHEADER& audioStreamHeader, const WAVEFORMATEX& waveFormatHeader); - WebRtc_Word32 Create(const WebRtc_Word8* fileName); + WebRtc_Word32 Create(const char* fileName); WebRtc_Word32 WriteAudio(const WebRtc_UWord8* data, WebRtc_Word32 length); WebRtc_Word32 WriteVideo(const WebRtc_UWord8* data, WebRtc_Word32 length); WebRtc_Word32 GetVideoStreamInfo(AVISTREAMHEADER& videoStreamHeader, BITMAPINFOHEADER& bitmapInfo, - WebRtc_Word8* codecConfigParameters, + char* codecConfigParameters, WebRtc_Word32& configLength); WebRtc_Word32 GetDuration(WebRtc_Word32& durationMs); diff --git a/src/modules/media_file/source/media_file_impl.cc b/src/modules/media_file/source/media_file_impl.cc index 6c42fa15f8..206c8d87f2 100644 --- a/src/modules/media_file/source/media_file_impl.cc +++ b/src/modules/media_file/source/media_file_impl.cc @@ -374,7 +374,7 @@ WebRtc_Word32 MediaFileImpl::PlayoutStereoData( } WebRtc_Word32 MediaFileImpl::StartPlayingAudioFile( - const WebRtc_Word8* fileName, + const char* fileName, const WebRtc_UWord32 notificationTimeMs, const bool loop, const FileFormats format, @@ -388,7 +388,7 @@ WebRtc_Word32 MediaFileImpl::StartPlayingAudioFile( } -WebRtc_Word32 MediaFileImpl::StartPlayingVideoFile(const WebRtc_Word8* fileName, +WebRtc_Word32 MediaFileImpl::StartPlayingVideoFile(const char* fileName, const bool loop, bool videoOnly, const FileFormats format) @@ -402,7 +402,7 @@ WebRtc_Word32 MediaFileImpl::StartPlayingVideoFile(const WebRtc_Word8* fileName, } WebRtc_Word32 MediaFileImpl::StartPlayingFile( - const WebRtc_Word8* fileName, + const char* fileName, const WebRtc_UWord32 notificationTimeMs, const bool loop, bool videoOnly, @@ -492,7 +492,7 @@ WebRtc_Word32 MediaFileImpl::StartPlayingAudioStream( WebRtc_Word32 MediaFileImpl::StartPlayingStream( InStream& stream, - const WebRtc_Word8* filename, + const char* filename, bool loop, const WebRtc_UWord32 notificationTimeMs, const FileFormats format, @@ -858,7 +858,7 @@ WebRtc_Word32 MediaFileImpl::IncomingAudioVideoData( } WebRtc_Word32 MediaFileImpl::StartRecordingAudioFile( - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const WebRtc_UWord32 notificationTimeMs, @@ -871,7 +871,7 @@ WebRtc_Word32 MediaFileImpl::StartRecordingAudioFile( WebRtc_Word32 MediaFileImpl::StartRecordingVideoFile( - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, @@ -885,7 +885,7 @@ WebRtc_Word32 MediaFileImpl::StartRecordingVideoFile( } WebRtc_Word32 MediaFileImpl::StartRecordingFile( - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, @@ -961,7 +961,7 @@ WebRtc_Word32 MediaFileImpl::StartRecordingAudioStream( WebRtc_Word32 MediaFileImpl::StartRecordingStream( OutStream& stream, - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, @@ -1214,7 +1214,7 @@ WebRtc_Word32 MediaFileImpl::SetModuleFileCallback(FileCallback* callback) return 0; } -WebRtc_Word32 MediaFileImpl::FileDurationMs(const WebRtc_Word8* fileName, +WebRtc_Word32 MediaFileImpl::FileDurationMs(const char* fileName, WebRtc_UWord32& durationMs, const FileFormats format, const WebRtc_UWord32 freqInHz) @@ -1326,7 +1326,7 @@ bool MediaFileImpl::ValidFileFormat(const FileFormats format, return true; } -bool MediaFileImpl::ValidFileName(const WebRtc_Word8* fileName) +bool MediaFileImpl::ValidFileName(const char* fileName) { if((fileName == NULL) ||(fileName[0] == '\0')) { diff --git a/src/modules/media_file/source/media_file_impl.h b/src/modules/media_file/source/media_file_impl.h index 06e20d0239..182367858b 100644 --- a/src/modules/media_file/source/media_file_impl.h +++ b/src/modules/media_file/source/media_file_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -38,14 +38,14 @@ public: WebRtc_Word8* audioBufferRight, WebRtc_UWord32& dataLengthInBytes); virtual WebRtc_Word32 StartPlayingAudioFile( - const WebRtc_Word8* fileName, + const char* fileName, const WebRtc_UWord32 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 WebRtc_Word8* fileName, + WebRtc_Word32 StartPlayingVideoFile(const char* fileName, const bool loop, bool videoOnly, const FileFormats format); @@ -64,13 +64,13 @@ public: WebRtc_Word32 IncomingAVIVideoData(const WebRtc_Word8* audioBuffer, const WebRtc_UWord32 bufferLength); WebRtc_Word32 StartRecordingAudioFile( - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const WebRtc_UWord32 notificationTimeMs = 0, const WebRtc_UWord32 maxSizeBytes = 0); WebRtc_Word32 StartRecordingVideoFile( - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, @@ -86,7 +86,7 @@ public: bool IsStereo(); WebRtc_Word32 SetModuleFileCallback(FileCallback* callback); WebRtc_Word32 FileDurationMs( - const WebRtc_Word8* fileName, + const char* fileName, WebRtc_UWord32& durationMs, const FileFormats format, const WebRtc_UWord32 freqInHz = 16000); @@ -100,7 +100,7 @@ private: // Returns true if the filename is valid - static bool ValidFileName(const WebRtc_Word8* fileName); + static bool ValidFileName(const char* fileName); // Returns true if the combination of startPointMs and stopPointMs is valid. static bool ValidFilePositions(const WebRtc_UWord32 startPointMs, @@ -119,7 +119,7 @@ private: // specify what part of the file should be read. From startPointMs ms to // stopPointMs ms. WebRtc_Word32 StartPlayingFile( - const WebRtc_Word8* fileName, + const char* fileName, const WebRtc_UWord32 notificationTimeMs = 0, const bool loop = false, bool videoOnly = false, @@ -144,7 +144,7 @@ private: // TODO (hellner): there is no reason why fileName should be needed here. WebRtc_Word32 StartPlayingStream( InStream& stream, - const WebRtc_Word8* fileName, + const char* fileName, bool loop, const WebRtc_UWord32 notificationTimeMs = 0, const FileFormats format = kFileFormatPcm16kHzFile, @@ -182,7 +182,7 @@ private: // Note: codecInst.channels should be set to 2 for stereo (and 1 for // mono). Stereo is only supported for WAV files. WebRtc_Word32 StartRecordingFile( - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, @@ -205,7 +205,7 @@ private: // TODO (hellner): there is no reason why fileName should be needed here. WebRtc_Word32 StartRecordingStream( OutStream& stream, - const WebRtc_Word8* fileName, + const char* fileName, const FileFormats format, const CodecInst& codecInst, const VideoCodec& videoCodecInst, @@ -237,7 +237,7 @@ private: bool _isStereo; bool _openFile; - WebRtc_Word8 _fileName[512]; + char _fileName[512]; FileCallback* _ptrCallback; }; diff --git a/src/modules/media_file/source/media_file_utility.cc b/src/modules/media_file/source/media_file_utility.cc index eeeb2092d0..da723e1d57 100644 --- a/src/modules/media_file/source/media_file_utility.cc +++ b/src/modules/media_file/source/media_file_utility.cc @@ -102,7 +102,7 @@ ModuleFileUtility::~ModuleFileUtility() #ifdef WEBRTC_MODULE_UTILITY_VIDEO WebRtc_Word32 ModuleFileUtility::InitAviWriting( - const WebRtc_Word8* filename, + const char* filename, const CodecInst& audioCodecInst, const VideoCodec& videoCodecInst, const bool videoOnly /*= false*/) @@ -302,7 +302,7 @@ WebRtc_Word32 ModuleFileUtility::CloseAviFile( ) } -WebRtc_Word32 ModuleFileUtility::InitAviReading(const WebRtc_Word8* filename, +WebRtc_Word32 ModuleFileUtility::InitAviReading(const char* filename, bool videoOnly, bool loop) { _reading = false; @@ -445,8 +445,8 @@ WebRtc_Word32 ModuleFileUtility::ReadWavHeader(InStream& wav) WAVE_RIFF_header RIFFheaderObj; WAVE_CHUNK_header CHUNKheaderObj; // TODO (hellner): tmpStr and tmpStr2 seems unnecessary here. - WebRtc_Word8 tmpStr[6] = "FOUR"; - WebRtc_UWord8 tmpStr2[4]; + char tmpStr[6] = "FOUR"; + char tmpStr2[4]; WebRtc_Word32 i, len; bool dataFound = false; bool fmtFound = false; @@ -1427,7 +1427,7 @@ WebRtc_Word32 ModuleFileUtility::InitCompressedReading( // Read the codec name WebRtc_Word32 cnt = 0; - WebRtc_Word8 buf[64]; + char buf[64]; do { in.Read(&buf[cnt++], 1); @@ -2310,7 +2310,7 @@ WebRtc_Word32 ModuleFileUtility::set_codec_info(const CodecInst& codecInst) return 0; } -WebRtc_Word32 ModuleFileUtility::FileDurationMs(const WebRtc_Word8* fileName, +WebRtc_Word32 ModuleFileUtility::FileDurationMs(const char* fileName, const FileFormats fileFormat, const WebRtc_UWord32 freqInHz) { @@ -2376,7 +2376,7 @@ WebRtc_Word32 ModuleFileUtility::FileDurationMs(const WebRtc_Word8* fileName, { WebRtc_Word32 cnt = 0; WebRtc_Word32 read_len = 0; - WebRtc_Word8 buf[64]; + char buf[64]; do { read_len = inStreamObj->Read(&buf[cnt++], 1); diff --git a/src/modules/media_file/source/media_file_utility.h b/src/modules/media_file/source/media_file_utility.h index cfe0314dec..d3eaef1e9e 100644 --- a/src/modules/media_file/source/media_file_utility.h +++ b/src/modules/media_file/source/media_file_utility.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -34,7 +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 WebRtc_Word8* fileName, bool videoOnly, + WebRtc_Word32 InitAviReading(const char* fileName, bool videoOnly, bool loop); // Put 10-60ms of audio data from file into the outBuffer depending on @@ -56,7 +56,7 @@ public: // (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 WebRtc_Word8* filename, + WebRtc_Word32 InitAviWriting(const char* filename, const CodecInst& codecInst, const VideoCodec& videoCodecInst, const bool videoOnly); @@ -221,7 +221,7 @@ public: // 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 WebRtc_Word8* fileName, + WebRtc_Word32 FileDurationMs(const char* fileName, const FileFormats fileFormat, const WebRtc_UWord32 freqInHz = 16000);