2011-03-30 09:37:42 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-03-30 09:37:42 +04:00
|
|
|
#include "nsError.h"
|
2012-11-19 19:11:21 +04:00
|
|
|
#include "AbstractMediaDecoder.h"
|
2012-11-14 23:46:40 +04:00
|
|
|
#include "WaveReader.h"
|
|
|
|
#include "MediaDecoderStateMachine.h"
|
2011-03-30 09:37:42 +04:00
|
|
|
#include "VideoUtils.h"
|
2013-09-06 00:25:17 +04:00
|
|
|
#include "nsISeekableStream.h"
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2013-07-30 18:25:31 +04:00
|
|
|
#include <stdint.h>
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2012-10-06 15:33:11 +04:00
|
|
|
#include "mozilla/CheckedInt.h"
|
2013-09-06 10:31:50 +04:00
|
|
|
#include "mozilla/Endian.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2012-01-11 12:23:07 +04:00
|
|
|
|
2015-05-31 07:18:12 +03:00
|
|
|
using namespace mozilla::media;
|
|
|
|
|
2012-11-14 23:45:33 +04:00
|
|
|
namespace mozilla {
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
// Un-comment to enable logging of seek bisections.
|
|
|
|
//#define SEEK_LOGGING
|
|
|
|
|
2012-11-14 23:46:40 +04:00
|
|
|
extern PRLogModuleInfo* gMediaDecoderLog;
|
2015-05-21 23:22:04 +03:00
|
|
|
#define LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
2011-03-30 09:37:42 +04:00
|
|
|
#ifdef SEEK_LOGGING
|
2015-05-21 23:22:04 +03:00
|
|
|
#define SEEK_LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
2011-03-30 09:37:42 +04:00
|
|
|
#else
|
|
|
|
#define SEEK_LOG(type, msg)
|
|
|
|
#endif
|
|
|
|
|
2012-10-06 15:33:11 +04:00
|
|
|
struct waveIdToName {
|
|
|
|
uint32_t id;
|
|
|
|
nsCString name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-30 09:37:42 +04:00
|
|
|
// Magic values that identify RIFF chunks we're interested in.
|
2012-08-22 19:56:38 +04:00
|
|
|
static const uint32_t RIFF_CHUNK_MAGIC = 0x52494646;
|
|
|
|
static const uint32_t WAVE_CHUNK_MAGIC = 0x57415645;
|
|
|
|
static const uint32_t FRMT_CHUNK_MAGIC = 0x666d7420;
|
|
|
|
static const uint32_t DATA_CHUNK_MAGIC = 0x64617461;
|
2012-10-06 15:33:11 +04:00
|
|
|
static const uint32_t LIST_CHUNK_MAGIC = 0x4c495354;
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2012-10-06 15:33:11 +04:00
|
|
|
// Size of chunk header. 4 byte chunk header type and 4 byte size field.
|
|
|
|
static const uint16_t CHUNK_HEADER_SIZE = 8;
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
// Size of RIFF header. RIFF chunk and 4 byte RIFF type.
|
2012-10-06 15:33:11 +04:00
|
|
|
static const uint16_t RIFF_INITIAL_SIZE = CHUNK_HEADER_SIZE + 4;
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
// Size of required part of format chunk. Actual format chunks may be
|
|
|
|
// extended (for non-PCM encodings), but we skip any extended data.
|
2012-08-22 19:56:38 +04:00
|
|
|
static const uint16_t WAVE_FORMAT_CHUNK_SIZE = 16;
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
// PCM encoding type from format chunk. Linear PCM is the only encoding
|
2012-11-14 23:46:40 +04:00
|
|
|
// supported by AudioStream.
|
2012-08-22 19:56:38 +04:00
|
|
|
static const uint16_t WAVE_FORMAT_ENCODING_PCM = 1;
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2013-08-29 13:43:44 +04:00
|
|
|
// We reject files with more than this number of channels if we're decoding for
|
|
|
|
// playback.
|
2012-08-22 19:56:38 +04:00
|
|
|
static const uint8_t MAX_CHANNELS = 2;
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
namespace {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2011-03-30 09:37:42 +04:00
|
|
|
ReadUint32BE(const char** aBuffer)
|
|
|
|
{
|
2013-09-06 10:31:50 +04:00
|
|
|
uint32_t result = BigEndian::readUint32(*aBuffer);
|
2012-08-22 19:56:38 +04:00
|
|
|
*aBuffer += sizeof(uint32_t);
|
2011-03-30 09:37:42 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2011-03-30 09:37:42 +04:00
|
|
|
ReadUint32LE(const char** aBuffer)
|
|
|
|
{
|
2013-09-06 10:31:50 +04:00
|
|
|
uint32_t result = LittleEndian::readUint32(*aBuffer);
|
2012-08-22 19:56:38 +04:00
|
|
|
*aBuffer += sizeof(uint32_t);
|
2011-03-30 09:37:42 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t
|
2011-03-30 09:37:42 +04:00
|
|
|
ReadUint16LE(const char** aBuffer)
|
|
|
|
{
|
2013-09-06 10:31:50 +04:00
|
|
|
uint16_t result = LittleEndian::readUint16(*aBuffer);
|
2012-08-22 19:56:38 +04:00
|
|
|
*aBuffer += sizeof(uint16_t);
|
2011-03-30 09:37:42 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int16_t
|
2011-03-30 09:37:42 +04:00
|
|
|
ReadInt16LE(const char** aBuffer)
|
|
|
|
{
|
2013-09-06 10:31:50 +04:00
|
|
|
uint16_t result = LittleEndian::readInt16(*aBuffer);
|
|
|
|
*aBuffer += sizeof(int16_t);
|
|
|
|
return result;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t
|
2011-03-30 09:37:42 +04:00
|
|
|
ReadUint8(const char** aBuffer)
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t result = uint8_t((*aBuffer)[0]);
|
|
|
|
*aBuffer += sizeof(uint8_t);
|
2011-03-30 09:37:42 +04:00
|
|
|
return result;
|
|
|
|
}
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2012-11-19 19:11:21 +04:00
|
|
|
WaveReader::WaveReader(AbstractMediaDecoder* aDecoder)
|
2012-11-14 23:46:40 +04:00
|
|
|
: MediaDecoderReader(aDecoder)
|
2015-08-13 04:15:48 +03:00
|
|
|
, mResource(aDecoder->GetResource())
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2012-11-14 23:46:40 +04:00
|
|
|
MOZ_COUNT_CTOR(WaveReader);
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2012-11-14 23:46:40 +04:00
|
|
|
WaveReader::~WaveReader()
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2012-11-14 23:46:40 +04:00
|
|
|
MOZ_COUNT_DTOR(WaveReader);
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2015-10-19 05:51:48 +03:00
|
|
|
nsresult
|
|
|
|
WaveReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-03-18 01:22:44 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2012-10-06 15:33:11 +04:00
|
|
|
bool loaded = LoadRIFFChunk();
|
2011-03-30 09:37:42 +04:00
|
|
|
if (!loaded) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2013-09-06 10:31:50 +04:00
|
|
|
nsAutoPtr<dom::HTMLMediaElement::MetadataTags> tags;
|
2012-10-06 15:33:11 +04:00
|
|
|
|
|
|
|
bool loadAllChunks = LoadAllChunks(tags);
|
|
|
|
if (!loadAllChunks) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2013-09-27 09:22:38 +04:00
|
|
|
mInfo.mAudio.mRate = mSampleRate;
|
|
|
|
mInfo.mAudio.mChannels = mChannels;
|
2015-05-31 07:18:12 +03:00
|
|
|
mInfo.mMetadataDuration.emplace(TimeUnit::FromSeconds(BytesToTime(GetDataLength())));
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
*aInfo = mInfo;
|
|
|
|
|
2012-10-06 15:33:11 +04:00
|
|
|
*aTags = tags.forget();
|
2012-07-31 04:14:29 +04:00
|
|
|
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-06-23 14:08:34 +04:00
|
|
|
bool
|
|
|
|
WaveReader::IsMediaSeekable()
|
|
|
|
{
|
|
|
|
// not used
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-25 14:09:40 +04:00
|
|
|
template <typename T> T UnsignedByteToAudioSample(uint8_t aValue);
|
|
|
|
template <typename T> T SignedShortToAudioSample(int16_t aValue);
|
|
|
|
|
|
|
|
template <> inline float
|
|
|
|
UnsignedByteToAudioSample<float>(uint8_t aValue)
|
|
|
|
{
|
|
|
|
return aValue * (2.0f / UINT8_MAX) - 1.0f;
|
|
|
|
}
|
|
|
|
template <> inline int16_t
|
|
|
|
UnsignedByteToAudioSample<int16_t>(uint8_t aValue)
|
|
|
|
{
|
|
|
|
return int16_t(aValue * UINT16_MAX / UINT8_MAX + INT16_MIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <> inline float
|
|
|
|
SignedShortToAudioSample<float>(int16_t aValue)
|
|
|
|
{
|
|
|
|
return AudioSampleToFloat(aValue);
|
|
|
|
}
|
|
|
|
template <> inline int16_t
|
|
|
|
SignedShortToAudioSample<int16_t>(int16_t aValue)
|
|
|
|
{
|
|
|
|
return aValue;
|
|
|
|
}
|
|
|
|
|
2012-11-14 23:46:40 +04:00
|
|
|
bool WaveReader::DecodeAudioData()
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-03-18 01:22:44 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t pos = GetPosition() - mWavePCMOffset;
|
|
|
|
int64_t len = GetDataLength();
|
|
|
|
int64_t remaining = len - pos;
|
2011-03-30 09:37:42 +04:00
|
|
|
NS_ASSERTION(remaining >= 0, "Current wave position is greater than wave file length");
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static const int64_t BLOCK_SIZE = 4096;
|
2013-01-15 16:22:03 +04:00
|
|
|
int64_t readSize = std::min(BLOCK_SIZE, remaining);
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t frames = readSize / mFrameSize;
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2013-08-08 18:30:00 +04:00
|
|
|
static_assert(uint64_t(BLOCK_SIZE) < UINT_MAX /
|
|
|
|
sizeof(AudioDataValue) / MAX_CHANNELS,
|
|
|
|
"bufferSize calculation could overflow.");
|
2011-09-27 07:31:18 +04:00
|
|
|
const size_t bufferSize = static_cast<size_t>(frames * mChannels);
|
2011-08-16 09:19:51 +04:00
|
|
|
nsAutoArrayPtr<AudioDataValue> sampleBuffer(new AudioDataValue[bufferSize]);
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2013-08-08 18:30:00 +04:00
|
|
|
static_assert(uint64_t(BLOCK_SIZE) < UINT_MAX / sizeof(char),
|
|
|
|
"BLOCK_SIZE too large for enumerator.");
|
2011-03-30 09:37:42 +04:00
|
|
|
nsAutoArrayPtr<char> dataBuffer(new char[static_cast<size_t>(readSize)]);
|
|
|
|
|
|
|
|
if (!ReadAll(dataBuffer, readSize)) {
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// convert data to samples
|
|
|
|
const char* d = dataBuffer.get();
|
2011-08-16 09:19:51 +04:00
|
|
|
AudioDataValue* s = sampleBuffer.get();
|
2011-09-27 07:31:18 +04:00
|
|
|
for (int i = 0; i < frames; ++i) {
|
2011-03-30 09:37:42 +04:00
|
|
|
for (unsigned int j = 0; j < mChannels; ++j) {
|
2012-10-25 14:09:39 +04:00
|
|
|
if (mSampleFormat == FORMAT_U8) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t v = ReadUint8(&d);
|
2012-10-25 14:09:40 +04:00
|
|
|
*s++ = UnsignedByteToAudioSample<AudioDataValue>(v);
|
|
|
|
} else if (mSampleFormat == FORMAT_S16) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int16_t v = ReadInt16LE(&d);
|
2012-10-25 14:09:40 +04:00
|
|
|
*s++ = SignedShortToAudioSample<AudioDataValue>(v);
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:12:23 +04:00
|
|
|
double posTime = BytesToTime(pos);
|
|
|
|
double readSizeTime = BytesToTime(readSize);
|
2012-01-11 12:23:07 +04:00
|
|
|
NS_ASSERTION(posTime <= INT64_MAX / USECS_PER_S, "posTime overflow");
|
|
|
|
NS_ASSERTION(readSizeTime <= INT64_MAX / USECS_PER_S, "readSizeTime overflow");
|
2012-09-28 10:57:33 +04:00
|
|
|
NS_ASSERTION(frames < INT32_MAX, "frames overflow");
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2011-08-16 09:19:51 +04:00
|
|
|
mAudioQueue.Push(new AudioData(pos,
|
2012-08-22 19:56:38 +04:00
|
|
|
static_cast<int64_t>(posTime * USECS_PER_S),
|
|
|
|
static_cast<int64_t>(readSizeTime * USECS_PER_S),
|
|
|
|
static_cast<int32_t>(frames),
|
2011-04-14 02:12:23 +04:00
|
|
|
sampleBuffer.forget(),
|
2014-08-11 09:27:00 +04:00
|
|
|
mChannels,
|
|
|
|
mSampleRate));
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2011-09-30 03:34:37 +04:00
|
|
|
return true;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2012-11-14 23:46:40 +04:00
|
|
|
bool WaveReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t aTimeThreshold)
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-03-18 01:22:44 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MediaDecoderReader::SeekPromise>
|
2015-01-16 21:57:59 +03:00
|
|
|
WaveReader::Seek(int64_t aTarget, int64_t aEndTime)
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-03-18 01:22:44 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
2015-06-04 01:25:57 +03:00
|
|
|
LOG(LogLevel::Debug, ("%p About to seek to %lld", mDecoder, aTarget));
|
2014-12-16 12:52:57 +03:00
|
|
|
|
2011-03-30 09:37:42 +04:00
|
|
|
if (NS_FAILED(ResetDecode())) {
|
2014-12-16 12:52:57 +03:00
|
|
|
return SeekPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
2011-04-14 02:12:23 +04:00
|
|
|
double d = BytesToTime(GetDataLength());
|
2014-10-13 02:53:42 +04:00
|
|
|
NS_ASSERTION(d < INT64_MAX / USECS_PER_S, "Duration overflow");
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t duration = static_cast<int64_t>(d * USECS_PER_S);
|
2013-01-15 16:22:03 +04:00
|
|
|
double seekTime = std::min(aTarget, duration) / static_cast<double>(USECS_PER_S);
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t position = RoundDownToFrame(static_cast<int64_t>(TimeToBytes(seekTime)));
|
2012-01-11 12:23:07 +04:00
|
|
|
NS_ASSERTION(INT64_MAX - mWavePCMOffset > position, "Integer overflow during wave seek");
|
2011-03-30 09:37:42 +04:00
|
|
|
position += mWavePCMOffset;
|
2015-08-13 04:15:48 +03:00
|
|
|
nsresult res = mResource.Seek(nsISeekableStream::NS_SEEK_SET, position);
|
2014-12-16 12:52:57 +03:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return SeekPromise::CreateAndReject(res, __func__);
|
|
|
|
} else {
|
2015-01-12 00:57:14 +03:00
|
|
|
return SeekPromise::CreateAndResolve(aTarget, __func__);
|
2014-12-16 12:52:57 +03:00
|
|
|
}
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2015-05-18 09:15:47 +03:00
|
|
|
media::TimeIntervals WaveReader::GetBuffered()
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-06-18 00:22:10 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
2013-09-27 09:22:38 +04:00
|
|
|
if (!mInfo.HasAudio()) {
|
2015-05-18 09:15:47 +03:00
|
|
|
return media::TimeIntervals();
|
2012-06-06 09:58:07 +04:00
|
|
|
}
|
2015-05-18 09:15:47 +03:00
|
|
|
media::TimeIntervals buffered;
|
2014-11-12 07:50:21 +03:00
|
|
|
AutoPinned<MediaResource> resource(mDecoder->GetResource());
|
|
|
|
int64_t startOffset = resource->GetNextCachedData(mWavePCMOffset);
|
2011-03-30 09:37:42 +04:00
|
|
|
while (startOffset >= 0) {
|
2014-11-12 07:50:21 +03:00
|
|
|
int64_t endOffset = resource->GetCachedDataEnd(startOffset);
|
2011-03-30 09:37:42 +04:00
|
|
|
// Bytes [startOffset..endOffset] are cached.
|
|
|
|
NS_ASSERTION(startOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
|
|
|
|
NS_ASSERTION(endOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
|
|
|
|
|
2011-04-14 02:12:23 +04:00
|
|
|
// We need to round the buffered ranges' times to microseconds so that they
|
2014-10-13 02:53:42 +04:00
|
|
|
// have the same precision as the currentTime and duration attribute on
|
2011-04-14 02:12:23 +04:00
|
|
|
// the media element.
|
2015-05-18 09:15:47 +03:00
|
|
|
buffered += media::TimeInterval(
|
|
|
|
media::TimeUnit::FromSeconds(BytesToTime(startOffset - mWavePCMOffset)),
|
|
|
|
media::TimeUnit::FromSeconds(BytesToTime(endOffset - mWavePCMOffset)));
|
2014-11-12 07:50:21 +03:00
|
|
|
startOffset = resource->GetNextCachedData(endOffset);
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
2015-05-18 09:15:47 +03:00
|
|
|
return buffered;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-11-14 23:46:40 +04:00
|
|
|
WaveReader::ReadAll(char* aBuf, int64_t aSize, int64_t* aBytesRead)
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
2011-03-30 09:37:42 +04:00
|
|
|
if (aBytesRead) {
|
|
|
|
*aBytesRead = 0;
|
|
|
|
}
|
2015-08-13 04:15:54 +03:00
|
|
|
uint32_t read = 0;
|
|
|
|
if (NS_FAILED(mResource.Read(aBuf, uint32_t(aSize), &read))) {
|
|
|
|
NS_WARNING("Resource read failed");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!read) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (aBytesRead) {
|
|
|
|
*aBytesRead = read;
|
|
|
|
}
|
2011-09-30 03:34:37 +04:00
|
|
|
return true;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-11-14 23:46:40 +04:00
|
|
|
WaveReader::LoadRIFFChunk()
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
2011-03-30 09:37:42 +04:00
|
|
|
char riffHeader[RIFF_INITIAL_SIZE];
|
|
|
|
const char* p = riffHeader;
|
|
|
|
|
2015-08-13 04:15:48 +03:00
|
|
|
MOZ_ASSERT(mResource.Tell() == 0,
|
2015-02-10 01:34:50 +03:00
|
|
|
"LoadRIFFChunk called when resource in invalid state");
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
if (!ReadAll(riffHeader, sizeof(riffHeader))) {
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2013-08-08 18:30:00 +04:00
|
|
|
static_assert(sizeof(uint32_t) * 3 <= RIFF_INITIAL_SIZE,
|
2013-08-08 18:30:00 +04:00
|
|
|
"Reads would overflow riffHeader buffer.");
|
2011-03-30 09:37:42 +04:00
|
|
|
if (ReadUint32BE(&p) != RIFF_CHUNK_MAGIC) {
|
2012-02-15 08:35:01 +04:00
|
|
|
NS_WARNING("resource data not in RIFF format");
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Skip over RIFF size field.
|
2013-08-08 18:30:00 +04:00
|
|
|
p += sizeof(uint32_t);
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
if (ReadUint32BE(&p) != WAVE_CHUNK_MAGIC) {
|
|
|
|
NS_WARNING("Expected WAVE chunk");
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2011-09-30 03:34:37 +04:00
|
|
|
return true;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-10-06 15:33:11 +04:00
|
|
|
WaveReader::LoadFormatChunk(uint32_t aChunkSize)
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
2012-10-06 15:33:11 +04:00
|
|
|
uint32_t rate, channels, frameSize, sampleFormat;
|
2011-03-30 09:37:42 +04:00
|
|
|
char waveFormat[WAVE_FORMAT_CHUNK_SIZE];
|
|
|
|
const char* p = waveFormat;
|
|
|
|
|
|
|
|
// RIFF chunks are always word (two byte) aligned.
|
2015-08-13 04:15:48 +03:00
|
|
|
MOZ_ASSERT(mResource.Tell() % 2 == 0,
|
2015-02-10 01:34:50 +03:00
|
|
|
"LoadFormatChunk called with unaligned resource");
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
if (!ReadAll(waveFormat, sizeof(waveFormat))) {
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2013-08-08 18:30:00 +04:00
|
|
|
static_assert(sizeof(uint16_t) +
|
|
|
|
sizeof(uint16_t) +
|
|
|
|
sizeof(uint32_t) +
|
|
|
|
4 +
|
|
|
|
sizeof(uint16_t) +
|
|
|
|
sizeof(uint16_t) <= sizeof(waveFormat),
|
|
|
|
"Reads would overflow waveFormat buffer.");
|
2011-03-30 09:37:42 +04:00
|
|
|
if (ReadUint16LE(&p) != WAVE_FORMAT_ENCODING_PCM) {
|
|
|
|
NS_WARNING("WAVE is not uncompressed PCM, compressed encodings are not supported");
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
channels = ReadUint16LE(&p);
|
|
|
|
rate = ReadUint32LE(&p);
|
|
|
|
|
|
|
|
// Skip over average bytes per second field.
|
|
|
|
p += 4;
|
|
|
|
|
2011-09-27 07:31:18 +04:00
|
|
|
frameSize = ReadUint16LE(&p);
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
sampleFormat = ReadUint16LE(&p);
|
|
|
|
|
|
|
|
// PCM encoded WAVEs are not expected to have an extended "format" chunk,
|
|
|
|
// but I have found WAVEs that have a extended "format" chunk with an
|
|
|
|
// extension size of 0 bytes. Be polite and handle this rather than
|
|
|
|
// considering the file invalid. This code skips any extension of the
|
|
|
|
// "format" chunk.
|
2012-10-06 15:33:11 +04:00
|
|
|
if (aChunkSize > WAVE_FORMAT_CHUNK_SIZE) {
|
2011-03-30 09:37:42 +04:00
|
|
|
char extLength[2];
|
|
|
|
const char* p = extLength;
|
|
|
|
|
|
|
|
if (!ReadAll(extLength, sizeof(extLength))) {
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2013-08-08 18:30:00 +04:00
|
|
|
static_assert(sizeof(uint16_t) <= sizeof(extLength),
|
|
|
|
"Reads would overflow extLength buffer.");
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t extra = ReadUint16LE(&p);
|
2012-10-06 15:33:11 +04:00
|
|
|
if (aChunkSize - (WAVE_FORMAT_CHUNK_SIZE + 2) != extra) {
|
2011-03-30 09:37:42 +04:00
|
|
|
NS_WARNING("Invalid extended format chunk size");
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
extra += extra % 2;
|
|
|
|
|
|
|
|
if (extra > 0) {
|
2013-08-08 18:30:00 +04:00
|
|
|
static_assert(UINT16_MAX + (UINT16_MAX % 2) < UINT_MAX / sizeof(char),
|
|
|
|
"chunkExtension array too large for iterator.");
|
2011-03-30 09:37:42 +04:00
|
|
|
nsAutoArrayPtr<char> chunkExtension(new char[extra]);
|
|
|
|
if (!ReadAll(chunkExtension.get(), extra)) {
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RIFF chunks are always word (two byte) aligned.
|
2015-08-13 04:15:48 +03:00
|
|
|
MOZ_ASSERT(mResource.Tell() % 2 == 0,
|
2015-02-10 01:34:50 +03:00
|
|
|
"LoadFormatChunk left resource unaligned");
|
2011-03-30 09:37:42 +04:00
|
|
|
|
|
|
|
// Make sure metadata is fairly sane. The rate check is fairly arbitrary,
|
|
|
|
// but the channels check is intentionally limited to mono or stereo
|
2013-08-29 13:43:44 +04:00
|
|
|
// when the media is intended for direct playback because that's what the
|
|
|
|
// audio backend currently supports.
|
2014-02-01 01:50:45 +04:00
|
|
|
unsigned int actualFrameSize = (sampleFormat == 8 ? 1 : 2) * channels;
|
2011-03-30 09:37:42 +04:00
|
|
|
if (rate < 100 || rate > 96000 ||
|
2013-08-29 13:43:44 +04:00
|
|
|
(((channels < 1 || channels > MAX_CHANNELS) ||
|
|
|
|
(frameSize != 1 && frameSize != 2 && frameSize != 4)) &&
|
|
|
|
!mIgnoreAudioOutputFormat) ||
|
|
|
|
(sampleFormat != 8 && sampleFormat != 16) ||
|
2012-08-28 10:21:58 +04:00
|
|
|
frameSize != actualFrameSize) {
|
2011-03-30 09:37:42 +04:00
|
|
|
NS_WARNING("Invalid WAVE metadata");
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mSampleRate = rate;
|
|
|
|
mChannels = channels;
|
2011-09-27 07:31:18 +04:00
|
|
|
mFrameSize = frameSize;
|
2011-03-30 09:37:42 +04:00
|
|
|
if (sampleFormat == 8) {
|
2012-10-25 14:09:39 +04:00
|
|
|
mSampleFormat = FORMAT_U8;
|
2011-03-30 09:37:42 +04:00
|
|
|
} else {
|
2012-10-25 14:09:39 +04:00
|
|
|
mSampleFormat = FORMAT_S16;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
2011-09-30 03:34:37 +04:00
|
|
|
return true;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-10-06 15:33:11 +04:00
|
|
|
WaveReader::FindDataOffset(uint32_t aChunkSize)
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
2011-03-30 09:37:42 +04:00
|
|
|
// RIFF chunks are always word (two byte) aligned.
|
2015-08-13 04:15:48 +03:00
|
|
|
MOZ_ASSERT(mResource.Tell() % 2 == 0,
|
2015-02-10 01:34:50 +03:00
|
|
|
"FindDataOffset called with unaligned resource");
|
2011-03-30 09:37:42 +04:00
|
|
|
|
2015-08-13 04:15:48 +03:00
|
|
|
int64_t offset = mResource.Tell();
|
2012-09-28 10:57:33 +04:00
|
|
|
if (offset <= 0 || offset > UINT32_MAX) {
|
2011-03-30 09:37:42 +04:00
|
|
|
NS_WARNING("PCM data offset out of range");
|
2011-09-30 03:34:37 +04:00
|
|
|
return false;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2012-10-06 15:33:11 +04:00
|
|
|
mWaveLength = aChunkSize;
|
2012-08-22 19:56:38 +04:00
|
|
|
mWavePCMOffset = uint32_t(offset);
|
2011-09-30 03:34:37 +04:00
|
|
|
return true;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2011-04-14 02:12:23 +04:00
|
|
|
double
|
2012-11-14 23:46:40 +04:00
|
|
|
WaveReader::BytesToTime(int64_t aBytes) const
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aBytes >= 0, "Must be >= 0");
|
2011-09-27 07:31:18 +04:00
|
|
|
return float(aBytes) / mSampleRate / mFrameSize;
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t
|
2012-11-14 23:46:40 +04:00
|
|
|
WaveReader::TimeToBytes(double aTime) const
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aTime >= 0.0f, "Must be >= 0");
|
2012-08-22 19:56:38 +04:00
|
|
|
return RoundDownToFrame(int64_t(aTime * mSampleRate * mFrameSize));
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t
|
2012-11-14 23:46:40 +04:00
|
|
|
WaveReader::RoundDownToFrame(int64_t aBytes) const
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aBytes >= 0, "Must be >= 0");
|
2011-09-27 07:31:18 +04:00
|
|
|
return aBytes - (aBytes % mFrameSize);
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t
|
2012-11-14 23:46:40 +04:00
|
|
|
WaveReader::GetDataLength()
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t length = mWaveLength;
|
2011-03-30 09:37:42 +04:00
|
|
|
// If the decoder has a valid content length, and it's shorter than the
|
|
|
|
// expected length of the PCM data, calculate the playback duration from
|
|
|
|
// the content length rather than the expected PCM data length.
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t streamLength = mDecoder->GetResource()->GetLength();
|
2011-03-30 09:37:42 +04:00
|
|
|
if (streamLength >= 0) {
|
2013-01-15 16:22:03 +04:00
|
|
|
int64_t dataLength = std::max<int64_t>(0, streamLength - mWavePCMOffset);
|
|
|
|
length = std::min(dataLength, length);
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t
|
2012-11-14 23:46:40 +04:00
|
|
|
WaveReader::GetPosition()
|
2011-03-30 09:37:42 +04:00
|
|
|
{
|
2015-08-13 04:15:48 +03:00
|
|
|
return mResource.Tell();
|
2011-03-30 09:37:42 +04:00
|
|
|
}
|
2012-11-14 23:45:33 +04:00
|
|
|
|
2012-10-06 15:33:11 +04:00
|
|
|
bool
|
|
|
|
WaveReader::LoadListChunk(uint32_t aChunkSize,
|
2013-09-06 10:31:50 +04:00
|
|
|
nsAutoPtr<dom::HTMLMediaElement::MetadataTags> &aTags)
|
2012-10-06 15:33:11 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
2012-10-06 15:33:11 +04:00
|
|
|
// List chunks are always word (two byte) aligned.
|
2015-08-13 04:15:48 +03:00
|
|
|
MOZ_ASSERT(mResource.Tell() % 2 == 0,
|
2015-02-10 01:34:50 +03:00
|
|
|
"LoadListChunk called with unaligned resource");
|
2012-10-06 15:33:11 +04:00
|
|
|
|
|
|
|
static const unsigned int MAX_CHUNK_SIZE = 1 << 16;
|
2013-08-08 18:30:00 +04:00
|
|
|
static_assert(uint64_t(MAX_CHUNK_SIZE) < UINT_MAX / sizeof(char),
|
2013-08-08 18:30:00 +04:00
|
|
|
"MAX_CHUNK_SIZE too large for enumerator.");
|
2012-10-06 15:33:11 +04:00
|
|
|
|
2014-10-15 04:56:09 +04:00
|
|
|
if (aChunkSize > MAX_CHUNK_SIZE || aChunkSize < 4) {
|
2012-10-06 15:33:11 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoArrayPtr<char> chunk(new char[aChunkSize]);
|
|
|
|
if (!ReadAll(chunk.get(), aChunkSize)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const uint32_t INFO_LIST_MAGIC = 0x494e464f;
|
2014-10-15 04:56:09 +04:00
|
|
|
const char* p = chunk.get();
|
2012-10-06 15:33:11 +04:00
|
|
|
if (ReadUint32BE(&p) != INFO_LIST_MAGIC) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const waveIdToName ID_TO_NAME[] = {
|
|
|
|
{ 0x49415254, NS_LITERAL_CSTRING("artist") }, // IART
|
|
|
|
{ 0x49434d54, NS_LITERAL_CSTRING("comments") }, // ICMT
|
|
|
|
{ 0x49474e52, NS_LITERAL_CSTRING("genre") }, // IGNR
|
|
|
|
{ 0x494e414d, NS_LITERAL_CSTRING("name") }, // INAM
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* const end = chunk.get() + aChunkSize;
|
|
|
|
|
2013-09-06 10:31:50 +04:00
|
|
|
aTags = new dom::HTMLMediaElement::MetadataTags;
|
2012-10-06 15:33:11 +04:00
|
|
|
|
|
|
|
while (p + 8 < end) {
|
|
|
|
uint32_t id = ReadUint32BE(&p);
|
|
|
|
// Uppercase tag id, inspired by GStreamer's Wave parser.
|
|
|
|
id &= 0xDFDFDFDF;
|
|
|
|
|
|
|
|
uint32_t length = ReadUint32LE(&p);
|
|
|
|
|
|
|
|
// Subchunk shall not exceed parent chunk.
|
2014-05-16 09:09:28 +04:00
|
|
|
if (uint32_t(end - p) < length) {
|
2012-10-06 15:33:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-06-11 04:10:09 +04:00
|
|
|
// Wrap the string, adjusting length to account for optional
|
|
|
|
// null termination in the chunk.
|
2012-10-06 15:33:11 +04:00
|
|
|
nsCString val(p, length);
|
2013-06-11 04:10:09 +04:00
|
|
|
if (length > 0 && val[length - 1] == '\0') {
|
2012-10-06 15:33:11 +04:00
|
|
|
val.SetLength(length - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Chunks in List::INFO are always word (two byte) aligned. So round up if
|
|
|
|
// necessary.
|
|
|
|
length += length % 2;
|
|
|
|
p += length;
|
|
|
|
|
|
|
|
if (!IsUTF8(val)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < mozilla::ArrayLength(ID_TO_NAME); ++i) {
|
|
|
|
if (id == ID_TO_NAME[i].id) {
|
|
|
|
aTags->Put(ID_TO_NAME[i].name, val);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-09-06 10:31:50 +04:00
|
|
|
WaveReader::LoadAllChunks(nsAutoPtr<dom::HTMLMediaElement::MetadataTags> &aTags)
|
2012-10-06 15:33:11 +04:00
|
|
|
{
|
2015-09-30 01:55:20 +03:00
|
|
|
MOZ_ASSERT(OnTaskQueue());
|
|
|
|
|
2012-10-06 15:33:11 +04:00
|
|
|
// Chunks are always word (two byte) aligned.
|
2015-08-13 04:15:48 +03:00
|
|
|
MOZ_ASSERT(mResource.Tell() % 2 == 0,
|
2015-02-10 01:34:50 +03:00
|
|
|
"LoadAllChunks called with unaligned resource");
|
2012-10-06 15:33:11 +04:00
|
|
|
|
|
|
|
bool loadFormatChunk = false;
|
|
|
|
bool findDataOffset = false;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
static const unsigned int CHUNK_HEADER_SIZE = 8;
|
|
|
|
char chunkHeader[CHUNK_HEADER_SIZE];
|
|
|
|
const char* p = chunkHeader;
|
|
|
|
|
|
|
|
if (!ReadAll(chunkHeader, sizeof(chunkHeader))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-08 18:30:00 +04:00
|
|
|
static_assert(sizeof(uint32_t) * 2 <= CHUNK_HEADER_SIZE,
|
|
|
|
"Reads would overflow chunkHeader buffer.");
|
2012-10-06 15:33:11 +04:00
|
|
|
|
|
|
|
uint32_t magic = ReadUint32BE(&p);
|
|
|
|
uint32_t chunkSize = ReadUint32LE(&p);
|
|
|
|
int64_t chunkStart = GetPosition();
|
|
|
|
|
|
|
|
switch (magic) {
|
|
|
|
case FRMT_CHUNK_MAGIC:
|
|
|
|
loadFormatChunk = LoadFormatChunk(chunkSize);
|
|
|
|
if (!loadFormatChunk) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIST_CHUNK_MAGIC:
|
|
|
|
if (!aTags) {
|
|
|
|
LoadListChunk(chunkSize, aTags);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DATA_CHUNK_MAGIC:
|
|
|
|
findDataOffset = FindDataOffset(chunkSize);
|
|
|
|
return loadFormatChunk && findDataOffset;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// RIFF chunks are two-byte aligned, so round up if necessary.
|
|
|
|
chunkSize += chunkSize % 2;
|
|
|
|
|
|
|
|
// Move forward to next chunk
|
|
|
|
CheckedInt64 forward = CheckedInt64(chunkStart) + chunkSize - GetPosition();
|
|
|
|
|
|
|
|
if (!forward.isValid() || forward.value() < 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const int64_t MAX_CHUNK_SIZE = 1 << 16;
|
2013-08-08 18:30:00 +04:00
|
|
|
static_assert(uint64_t(MAX_CHUNK_SIZE) < UINT_MAX / sizeof(char),
|
|
|
|
"MAX_CHUNK_SIZE too large for enumerator.");
|
2012-10-06 15:33:11 +04:00
|
|
|
nsAutoArrayPtr<char> chunk(new char[MAX_CHUNK_SIZE]);
|
|
|
|
while (forward.value() > 0) {
|
2013-01-15 16:22:03 +04:00
|
|
|
int64_t size = std::min(forward.value(), MAX_CHUNK_SIZE);
|
2012-10-06 15:33:11 +04:00
|
|
|
if (!ReadAll(chunk.get(), size)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
forward -= size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-14 23:45:33 +04:00
|
|
|
} // namespace mozilla
|