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
This commit is contained in:
@@ -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() {}
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
@@ -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 <class T>
|
||||
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<WebRtc_Word32>(newBytesWritten);
|
||||
return static_cast<int32_t>(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<WebRtc_UWord32>(chunkSize));
|
||||
chunkOffset, static_cast<uint32_t>(chunkSize));
|
||||
|
||||
++_videoFrames;
|
||||
newBytesWritten = _bytesWritten - newBytesWritten;
|
||||
_crit->Leave();
|
||||
return static_cast<WebRtc_Word32>(newBytesWritten);
|
||||
return static_cast<int32_t>(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<WebRtc_Word32>(size) > length)
|
||||
if (static_cast<int32_t>(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<long>(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<const WebRtc_UWord8*>(str),
|
||||
return PutBuffer(reinterpret_cast<const uint8_t*>(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<WebRtc_Word32>(strlsize);
|
||||
static_cast<int32_t>(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<WebRtc_UWord8*>(_videoConfigParameters), readSize);
|
||||
reinterpret_cast<uint8_t*>(_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<long>(_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<WebRtc_UWord8*>(_videoStreamName), size);
|
||||
reinterpret_cast<uint8_t*>(_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<WebRtc_UWord8*>(_videoConfigParameters), size);
|
||||
reinterpret_cast<uint8_t*>(_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<WebRtc_UWord8*>(_audioConfigParameters), size);
|
||||
reinterpret_cast<uint8_t*>(_audioConfigParameters), size);
|
||||
}
|
||||
|
||||
while (static_cast<long>(_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<WebRtc_UWord8*>(_audioStreamName), size);
|
||||
reinterpret_cast<uint8_t*>(_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<WebRtc_UWord8*>(_audioConfigParameters), size);
|
||||
reinterpret_cast<uint8_t*>(_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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<MediaFileImpl*>(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))
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user