Backed out changeset 191741878690 (bug 908503)

This commit is contained in:
Anthony Jones 2014-05-12 10:11:04 +12:00
parent 0775db81b3
commit ec6e39e9ce
88 changed files with 287 additions and 2842 deletions

View File

@ -158,8 +158,12 @@ private:
class BlankAudioDataCreator {
public:
BlankAudioDataCreator(uint32_t aChannelCount, uint32_t aSampleRate)
: mFrameSum(0), mChannelCount(aChannelCount), mSampleRate(aSampleRate)
BlankAudioDataCreator(uint32_t aChannelCount,
uint32_t aSampleRate,
uint16_t aBitsPerSample)
: mFrameSum(0)
, mChannelCount(aChannelCount)
, mSampleRate(aSampleRate)
{
}
@ -215,8 +219,9 @@ public:
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE {
BlankVideoDataCreator* decoder = new BlankVideoDataCreator(
aConfig.display_width, aConfig.display_height, aImageContainer);
BlankVideoDataCreator* decoder = new BlankVideoDataCreator(aConfig.visible_rect().width(),
aConfig.visible_rect().height(),
aImageContainer);
return new BlankMediaDataDecoder<BlankVideoDataCreator>(decoder,
aVideoTaskQueue,
aCallback);
@ -226,8 +231,10 @@ public:
virtual MediaDataDecoder* CreateAACDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE {
BlankAudioDataCreator* decoder = new BlankAudioDataCreator(
aConfig.channel_count, aConfig.samples_per_second);
BlankAudioDataCreator* decoder =
new BlankAudioDataCreator(ChannelLayoutToChannelCount(aConfig.channel_layout()),
aConfig.samples_per_second(),
aConfig.bits_per_channel());
return new BlankMediaDataDecoder<BlankAudioDataCreator>(decoder,
aAudioTaskQueue,
aCallback);

View File

@ -6,6 +6,8 @@
#include "MP4Reader.h"
#include "MediaResource.h"
#include "mp4_demuxer/mp4_demuxer.h"
#include "mp4_demuxer/Streams.h"
#include "nsSize.h"
#include "VideoUtils.h"
#include "mozilla/dom/HTMLMediaElement.h"
@ -51,13 +53,14 @@ public:
MOZ_COUNT_DTOR(MP4Stream);
}
virtual bool ReadAt(int64_t aOffset, void* aBuffer, size_t aCount,
size_t* aBytesRead) MOZ_OVERRIDE
{
virtual bool ReadAt(int64_t aOffset,
uint8_t* aBuffer,
uint32_t aCount,
uint32_t* aBytesRead) MOZ_OVERRIDE {
uint32_t sum = 0;
do {
uint32_t offset = aOffset + sum;
char* buffer = reinterpret_cast<char*>(aBuffer) + sum;
char* buffer = reinterpret_cast<char*>(aBuffer + sum);
uint32_t toRead = aCount - sum;
uint32_t bytesRead = 0;
nsresult rv = mResource->ReadAt(offset, buffer, toRead, &bytesRead);
@ -70,12 +73,8 @@ public:
return true;
}
virtual bool Length(int64_t* aSize) MOZ_OVERRIDE
{
if (mResource->GetLength() < 0)
return false;
*aSize = mResource->GetLength();
return true;
virtual int64_t Length() const MOZ_OVERRIDE {
return mResource->GetLength();
}
private:
@ -121,8 +120,6 @@ MP4Reader::Shutdown()
mVideo.mTaskQueue->Shutdown();
mVideo.mTaskQueue = nullptr;
}
// Dispose of the queued sample before shutting down the demuxer
mQueuedVideoSample = nullptr;
}
void
@ -156,7 +153,8 @@ MP4Reader::Init(MediaDecoderReader* aCloneDonor)
{
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
PlatformDecoderModule::Init();
mDemuxer = new MP4Demuxer(new MP4Stream(mDecoder->GetResource()));
mMP4Stream = new MP4Stream(mDecoder->GetResource());
mDemuxer = new MP4Demuxer(mMP4Stream);
InitLayersBackendType();
@ -178,17 +176,19 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
bool ok = mDemuxer->Init();
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
mInfo.mAudio.mHasAudio = mAudio.mActive = mDemuxer->HasValidAudio();
const AudioDecoderConfig& audio = mDemuxer->AudioConfig();
mInfo.mAudio.mHasAudio = mAudio.mActive = mDemuxer->HasAudio() &&
audio.IsValidConfig();
// If we have audio, we *only* allow AAC to be decoded.
if (mInfo.mAudio.mHasAudio && strcmp(audio.mime_type, "audio/mp4a-latm")) {
if (HasAudio() && audio.codec() != kCodecAAC) {
return NS_ERROR_FAILURE;
}
mInfo.mVideo.mHasVideo = mVideo.mActive = mDemuxer->HasValidVideo();
const VideoDecoderConfig& video = mDemuxer->VideoConfig();
mInfo.mVideo.mHasVideo = mVideo.mActive = mDemuxer->HasVideo() &&
video.IsValidConfig();
// If we have video, we *only* allow H.264 to be decoded.
if (mInfo.mVideo.mHasVideo && strcmp(video.mime_type, "video/avc")) {
if (HasVideo() && video.codec() != kCodecH264) {
return NS_ERROR_FAILURE;
}
@ -196,8 +196,8 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
NS_ENSURE_TRUE(mPlatform, NS_ERROR_FAILURE);
if (HasAudio()) {
mInfo.mAudio.mRate = audio.samples_per_second;
mInfo.mAudio.mChannels = audio.channel_count;
mInfo.mAudio.mRate = audio.samples_per_second();
mInfo.mAudio.mChannels = ChannelLayoutToChannelCount(audio.channel_layout());
mAudio.mCallback = new DecoderCallback(this, kAudio);
mAudio.mDecoder = mPlatform->CreateAACDecoder(audio,
mAudio.mTaskQueue,
@ -208,8 +208,8 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
}
if (HasVideo()) {
mInfo.mVideo.mDisplay =
nsIntSize(video.display_width, video.display_height);
IntSize sz = video.natural_size();
mInfo.mVideo.mDisplay = nsIntSize(sz.width(), sz.height());
mVideo.mCallback = new DecoderCallback(this, kVideo);
mVideo.mDecoder = mPlatform->CreateH264Decoder(video,
mLayersBackendType,
@ -229,7 +229,7 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
}
// We can seek if we get a duration *and* the reader reports that it's
// seekable.
if (!mDecoder->GetResource()->IsTransportSeekable() || !mDemuxer->CanSeek()) {
if (!mDemuxer->CanSeek()) {
mDecoder->SetMediaSeekable(false);
}
@ -258,6 +258,12 @@ MP4Reader::GetDecoderData(TrackType aTrack)
return (aTrack == kAudio) ? mAudio : mVideo;
}
MP4SampleQueue&
MP4Reader::SampleQueue(TrackType aTrack)
{
return GetDecoderData(aTrack).mDemuxedSamples;
}
MediaDataDecoder*
MP4Reader::Decoder(TrackType aTrack)
{
@ -267,19 +273,26 @@ MP4Reader::Decoder(TrackType aTrack)
MP4Sample*
MP4Reader::PopSample(TrackType aTrack)
{
switch (aTrack) {
case kAudio:
return mDemuxer->DemuxAudioSample();
case kVideo:
if (mQueuedVideoSample)
return mQueuedVideoSample.forget();
return mDemuxer->DemuxVideoSample();
default:
// Unfortunately the demuxer outputs in the order samples appear in the
// media, not on a per stream basis. We cache the samples we get from
// streams other than the one we want.
MP4SampleQueue& sampleQueue = SampleQueue(aTrack);
while (sampleQueue.empty()) {
nsAutoPtr<MP4Sample> sample;
bool eos = false;
bool ok = mDemuxer->Demux(&sample, &eos);
if (!ok || eos) {
MOZ_ASSERT(!sample);
return nullptr;
}
MOZ_ASSERT(sample);
MP4Sample* s = sample.forget();
SampleQueue(s->type).push_back(s);
}
MOZ_ASSERT(!sampleQueue.empty());
MP4Sample* sample = sampleQueue.front();
sampleQueue.pop_front();
return sample;
}
// How async decoding works:
@ -471,7 +484,7 @@ MP4Reader::SkipVideoDemuxToNextKeyFrame(int64_t aTimeThreshold, uint32_t& parsed
compressed->composition_timestamp < aTimeThreshold) {
continue;
}
mQueuedVideoSample = compressed;
mVideo.mDemuxedSamples.push_front(compressed.forget());
break;
}
@ -518,24 +531,10 @@ MP4Reader::Seek(int64_t aTime,
int64_t aEndTime,
int64_t aCurrentTime)
{
if (!mDecoder->GetResource()->IsTransportSeekable() || !mDemuxer->CanSeek()) {
if (!mDemuxer->CanSeek()) {
return NS_ERROR_FAILURE;
}
Flush(kVideo);
Flush(kAudio);
ResetDecode();
mQueuedVideoSample = nullptr;
if (mDemuxer->HasValidVideo()) {
mDemuxer->SeekVideo(aTime);
mQueuedVideoSample = PopSample(kVideo);
}
if (mDemuxer->HasValidAudio()) {
mDemuxer->SeekAudio(
mQueuedVideoSample ? mQueuedVideoSample->composition_timestamp : aTime);
}
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
} // namespace mozilla

View File

@ -11,6 +11,7 @@
#include "nsAutoPtr.h"
#include "PlatformDecoderModule.h"
#include "mp4_demuxer/mp4_demuxer.h"
#include "mp4_demuxer/box_definitions.h"
#include "MediaTaskQueue.h"
#include <deque>
@ -70,6 +71,7 @@ private:
void Flush(mp4_demuxer::TrackType aTrack);
nsAutoPtr<mp4_demuxer::MP4Demuxer> mDemuxer;
nsAutoPtr<MP4Stream> mMP4Stream;
nsAutoPtr<PlatformDecoderModule> mPlatform;
class DecoderCallback : public MediaDataDecoderCallback {
@ -110,6 +112,9 @@ private:
// The platform decoder.
RefPtr<MediaDataDecoder> mDecoder;
// Queue of input extracted by the demuxer, but not yet sent to the
// platform decoder.
MP4SampleQueue mDemuxedSamples;
// TaskQueue on which decoder can choose to decode.
// Only non-null up until the decoder is created.
RefPtr<MediaTaskQueue> mTaskQueue;
@ -129,9 +134,6 @@ private:
};
DecoderData mAudio;
DecoderData mVideo;
// Queued frame extracted by the demuxer, but not yet sent to the platform
// decoder.
nsAutoPtr<mp4_demuxer::MP4Sample> mQueuedVideoSample;
// The last number of decoded output frames that we've reported to
// MediaDecoder::NotifyDecoded(). We diff the number of output video

View File

@ -73,9 +73,10 @@ FFmpegAACDecoder::DecodePacket(MP4Sample* aSample)
AVPacket packet;
av_init_packet(&packet);
packet.data = aSample->data;
packet.size = aSample->size;
packet.data = &(*aSample->data)[0];
packet.size = aSample->data->size();
packet.pos = aSample->byte_offset;
packet.dts = aSample->decode_timestamp;
int decoded;
int bytesConsumed =
@ -87,7 +88,7 @@ FFmpegAACDecoder::DecodePacket(MP4Sample* aSample)
return;
}
NS_ASSERTION(bytesConsumed == (int)aSample->size,
NS_ASSERTION(bytesConsumed == (int)aSample->data->size(),
"Only one audio packet should be received at a time.");
uint32_t numChannels = mCodecContext.channels;
@ -95,9 +96,9 @@ FFmpegAACDecoder::DecodePacket(MP4Sample* aSample)
nsAutoArrayPtr<AudioDataValue> audio(
CopyAndPackAudio(frame.get(), numChannels, frame->nb_samples));
nsAutoPtr<AudioData> data(
new AudioData(packet.pos, aSample->composition_timestamp, aSample->duration,
frame->nb_samples, audio.forget(), numChannels));
nsAutoPtr<AudioData> data(new AudioData(packet.pos, aSample->decode_timestamp,
aSample->duration, frame->nb_samples,
audio.forget(), numChannels));
mCallback->Output(data.forget());

View File

@ -8,7 +8,6 @@
#define __FFmpegAACDecoder_h__
#include "FFmpegDataDecoder.h"
#include "mp4_demuxer/DecoderData.h"
namespace mozilla
{

View File

@ -20,7 +20,7 @@ bool FFmpegDataDecoder::sFFmpegInitDone = false;
FFmpegDataDecoder::FFmpegDataDecoder(MediaTaskQueue* aTaskQueue,
AVCodecID aCodecID)
: mExtraDataSize(0), mTaskQueue(aTaskQueue), mCodecID(aCodecID)
: mTaskQueue(aTaskQueue), mCodecID(aCodecID)
{
MOZ_COUNT_CTOR(FFmpegDataDecoder);
}
@ -87,11 +87,6 @@ FFmpegDataDecoder::Init()
// FFmpeg will call back to this to negotiate a video pixel format.
mCodecContext.get_format = ChoosePixelFormat;
if (mExtraData) {
mCodecContext.extradata = mExtraData;
mCodecContext.extradata_size = mExtraDataSize;
}
AVDictionary* opts = nullptr;
if (avcodec_open2(&mCodecContext, codec, &opts) < 0) {
NS_WARNING("Couldn't initialise ffmpeg decoder");

View File

@ -7,6 +7,8 @@
#ifndef __FFmpegDataDecoder_h__
#define __FFmpegDataDecoder_h__
#include "mp4_demuxer/mp4_demuxer.h"
#include "FFmpegDecoderModule.h"
#include "FFmpegRuntimeLinker.h"
#include "FFmpegCompat.h"
@ -29,8 +31,6 @@ public:
virtual nsresult Shutdown() MOZ_OVERRIDE;
protected:
nsAutoArrayPtr<uint8_t> mExtraData;
size_t mExtraDataSize;
MediaTaskQueue* mTaskQueue;
AVCodecContext mCodecContext;

View File

@ -29,15 +29,11 @@ FFmpegH264Decoder::FFmpegH264Decoder(
const mp4_demuxer::VideoDecoderConfig &aConfig,
ImageContainer* aImageContainer)
: FFmpegDataDecoder(aTaskQueue, AV_CODEC_ID_H264)
, mConfig(aConfig)
, mCallback(aCallback)
, mImageContainer(aImageContainer)
{
MOZ_COUNT_CTOR(FFmpegH264Decoder);
mExtraDataSize = aConfig.extra_data_size;
mExtraData = new uint8_t[mExtraDataSize + FF_INPUT_BUFFER_PADDING_SIZE];
memset(mExtraData, 0, mExtraDataSize + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(mExtraData, aConfig.extra_data, mExtraDataSize);
}
nsresult
@ -57,8 +53,9 @@ FFmpegH264Decoder::DecodeFrame(mp4_demuxer::MP4Sample* aSample)
AVPacket packet;
av_init_packet(&packet);
packet.data = aSample->data;
packet.size = aSample->size;
packet.data = &(*aSample->data)[0];
packet.size = aSample->data->size();
packet.dts = aSample->decode_timestamp;
packet.pts = aSample->composition_timestamp;
packet.flags = aSample->is_sync_point ? AV_PKT_FLAG_KEY : 0;
packet.pos = aSample->byte_offset;
@ -241,7 +238,11 @@ FFmpegH264Decoder::Drain()
for (int32_t i = 0; i <= mCodecContext.max_b_frames; i++) {
// An empty frame tells FFmpeg to decode the next delayed frame it has in
// its queue, if it has any.
nsAutoPtr<MP4Sample> empty(new MP4Sample());
nsAutoPtr<MP4Sample> empty(new MP4Sample(0 /* dts */, 0 /* cts */,
0 /* duration */, 0 /* offset */,
new std::vector<uint8_t>(),
mp4_demuxer::kVideo, nullptr,
false));
nsresult rv = Input(empty.forget());
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -46,6 +46,7 @@ private:
static int AllocateBufferCb(AVCodecContext* aCodecContext, AVFrame* aFrame);
mp4_demuxer::VideoDecoderConfig mConfig;
MediaDataDecoderCallback* mCallback;
nsRefPtr<ImageContainer> mImageContainer;

View File

@ -10,43 +10,42 @@ EXPORTS += [
'PlatformDecoderModule.h',
]
#EXPORTS.mp4_demuxer += [
# 'demuxer/aac.h',
# 'demuxer/audio_decoder_config.h',
# 'demuxer/avc.h',
# 'demuxer/basictypes.h',
# 'demuxer/bit_reader.h',
# 'demuxer/box_definitions.h',
# 'demuxer/box_reader.h',
# 'demuxer/cenc.h',
# 'demuxer/channel_layout.h',
# 'demuxer/decrypt_config.h',
# 'demuxer/es_descriptor.h',
# 'demuxer/fourccs.h',
# 'demuxer/mp4_demuxer.h',
# 'demuxer/Streams.h',
# 'demuxer/track_run_iterator.h',
# 'demuxer/video_decoder_config.h',
# 'demuxer/video_util.h',
#]
EXPORTS.mp4_demuxer += [
'demuxer/aac.h',
'demuxer/audio_decoder_config.h',
'demuxer/avc.h',
'demuxer/basictypes.h',
'demuxer/bit_reader.h',
'demuxer/box_definitions.h',
'demuxer/box_reader.h',
'demuxer/cenc.h',
'demuxer/channel_layout.h',
'demuxer/decrypt_config.h',
'demuxer/es_descriptor.h',
'demuxer/fourccs.h',
'demuxer/mp4_demuxer.h',
'demuxer/Streams.h',
'demuxer/track_run_iterator.h',
'demuxer/video_decoder_config.h',
'demuxer/video_util.h',
]
#UNIFIED_SOURCES += [
SOURCES += [
UNIFIED_SOURCES += [
'BlankDecoderModule.cpp',
# 'demuxer/aac.cc',
# 'demuxer/audio_decoder_config.cc',
# 'demuxer/avc.cc',
# 'demuxer/bit_reader.cc',
# 'demuxer/box_definitions.cc',
# 'demuxer/box_reader.cc',
# 'demuxer/cenc.cc',
# 'demuxer/channel_layout.cc',
# 'demuxer/decrypt_config.cc',
# 'demuxer/es_descriptor.cc',
# 'demuxer/mp4_demuxer.cc',
# 'demuxer/track_run_iterator.cc',
# 'demuxer/video_decoder_config.cc',
# 'demuxer/video_util.cc',
'demuxer/aac.cc',
'demuxer/audio_decoder_config.cc',
'demuxer/avc.cc',
'demuxer/bit_reader.cc',
'demuxer/box_definitions.cc',
'demuxer/box_reader.cc',
'demuxer/cenc.cc',
'demuxer/channel_layout.cc',
'demuxer/decrypt_config.cc',
'demuxer/es_descriptor.cc',
'demuxer/mp4_demuxer.cc',
'demuxer/track_run_iterator.cc',
'demuxer/video_decoder_config.cc',
'demuxer/video_util.cc',
'MP4Decoder.cpp',
'MP4Reader.cpp',
'PlatformDecoderModule.cpp',

View File

@ -65,19 +65,18 @@ AACAudioSpecificConfigToUserData(const uint8_t* aAudioSpecConfig,
aOutUserData.AppendElements(aAudioSpecConfig, aConfigLength);
}
WMFAudioOutputSource::WMFAudioOutputSource(
const mp4_demuxer::AudioDecoderConfig& aConfig)
: mAudioChannels(aConfig.channel_count)
, mAudioBytesPerSample(aConfig.bytes_per_sample)
, mAudioRate(aConfig.samples_per_second)
WMFAudioOutputSource::WMFAudioOutputSource(const mp4_demuxer::AudioDecoderConfig& aConfig)
: mAudioChannels(ChannelLayoutToChannelCount(aConfig.channel_layout()))
, mAudioBytesPerSample(aConfig.bits_per_channel() / 8)
, mAudioRate(aConfig.samples_per_second())
, mAudioFrameOffset(0)
, mAudioFrameSum(0)
, mMustRecaptureAudioPosition(true)
{
MOZ_COUNT_CTOR(WMFAudioOutputSource);
AACAudioSpecificConfigToUserData(
reinterpret_cast<const uint8_t*>(aConfig.extra_data),
aConfig.extra_data_size, mUserData);
AACAudioSpecificConfigToUserData(aConfig.extra_data(),
aConfig.extra_data_size(),
mUserData);
}
WMFAudioOutputSource::~WMFAudioOutputSource()

View File

@ -11,6 +11,7 @@
#include "WMFAudioOutputSource.h"
#include "mozilla/Preferences.h"
#include "mozilla/DebugOnly.h"
#include "mp4_demuxer/audio_decoder_config.h"
#include "WMFMediaDataDecoder.h"
namespace mozilla {

View File

@ -67,8 +67,8 @@ WMFMediaDataDecoder::Input(mp4_demuxer::MP4Sample* aSample)
void
WMFMediaDataDecoder::ProcessDecode(mp4_demuxer::MP4Sample* aSample)
{
const uint8_t* data = reinterpret_cast<const uint8_t*>(aSample->data);
uint32_t length = aSample->size;
const uint8_t* data = &aSample->data->front();
uint32_t length = aSample->data->size();
HRESULT hr = mDecoder->Input(data, length, aSample->composition_timestamp);
if (FAILED(hr)) {
NS_WARNING("WMFAudioDecoder failed to input data");

View File

@ -1,57 +0,0 @@
frameworks/av/include/media/stagefright/foundation/AAtomizer.h
frameworks/av/include/media/stagefright/foundation/ABase.h
frameworks/av/include/media/stagefright/foundation/ABitReader.h
frameworks/av/include/media/stagefright/foundation/ABuffer.h
frameworks/av/include/media/stagefright/foundation/ADebug.h
frameworks/av/include/media/stagefright/foundation/AHandler.h
frameworks/av/include/media/stagefright/foundation/AString.h
frameworks/av/include/media/stagefright/foundation/hexdump.h
frameworks/av/include/media/stagefright/MediaBufferGroup.h
frameworks/av/include/media/stagefright/MediaDefs.h
frameworks/av/include/media/stagefright/MediaErrors.h
frameworks/av/include/media/stagefright/MediaExtractor.h
frameworks/av/include/media/stagefright/MediaSource.h
frameworks/av/include/media/stagefright/MetaData.h
frameworks/av/include/media/stagefright/MetaData.h
frameworks/av/media/libstagefright/include/ESDS.h
frameworks/av/media/libstagefright/include/ID3.h
frameworks/av/media/libstagefright/include/MPEG4Extractor.h
frameworks/av/media/libstagefright/include/SampleTable.h
frameworks/av/media/libstagefright/include/SampleTable.h
system/core/debuggerd/backtrace.h
system/core/include/android/log.h
system/core/include/corkscrew/backtrace.h
system/core/include/corkscrew/map_info.h
system/core/include/corkscrew/ptrace.h
system/core/include/corkscrew/symbol_table.h
system/core/include/cutils/jstring.h
system/core/include/cutils/log.h
system/core/include/cutils/sched_policy.h
system/core/include/log/event_tag_map.h
system/core/include/log/logd.h
system/core/include/log/logger.h
system/core/include/log/logprint.h
system/core/include/log/uio.h
system/core/include/system/graphics.h
system/core/include/sysutils/List.h
system/core/include/utils/Atomic.h
system/core/include/utils/CallStack.h
system/core/include/utils/Condition.h
system/core/include/utils/Debug.h
system/core/include/utils/Errors.h
system/core/include/utils/KeyedVector.h
system/core/include/utils/List.h
system/core/include/utils/Log.h
system/core/include/utils/Mutex.h
system/core/include/utils/RWLock.h
system/core/include/utils/SortedVector.h
system/core/include/utils/String16.h
system/core/include/utils/String8.h
system/core/include/utils/Timers.h
system/core/include/utils/Vector.h
system/core/include/utils/VectorImpl.h
system/core/libpixelflinger/codeflinger/tinyutils/Errors.h
system/core/libpixelflinger/codeflinger/tinyutils/KeyedVector.h
system/core/libpixelflinger/codeflinger/tinyutils/SortedVector.h
system/core/libpixelflinger/codeflinger/tinyutils/Vector.h
system/core/libpixelflinger/codeflinger/tinyutils/VectorImpl.h

View File

@ -1,62 +0,0 @@
/* 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/. */
#include "mp4_demuxer/Adts.h"
#include "mp4_demuxer/DecoderData.h"
#include "media/stagefright/MediaBuffer.h"
namespace mp4_demuxer
{
int8_t
Adts::GetFrequencyIndex(uint16_t aSamplesPerSecond)
{
static const int freq_lookup[] = { 96000, 88200, 64000, 48000, 44100,
32000, 24000, 22050, 16000, 12000,
11025, 8000, 7350, 0 };
int8_t i = 0;
while (aSamplesPerSecond < freq_lookup[i]) {
i++;
}
if (!freq_lookup[i]) {
return -1;
}
return i;
}
bool
Adts::ConvertEsdsToAdts(uint16_t aChannelCount, int8_t aFrequencyIndex,
int8_t aProfile, MP4Sample* aSample)
{
static const int kADTSHeaderSize = 7;
size_t newSize = aSample->size + kADTSHeaderSize;
// ADTS header uses 13 bits for packet size.
if (newSize > aSample->mMediaBuffer->size() || newSize >= (1 << 13) ||
aChannelCount < 0 || aChannelCount > 15 || aFrequencyIndex < 0 ||
aProfile < 1 || aProfile > 4)
return false;
// Create a new buffer that is big enough to hold the ADTS header
aSample->adts_buffer = new uint8_t[newSize];
memcpy(aSample->adts_buffer + kADTSHeaderSize, aSample->data, aSample->size);
aSample->data = aSample->adts_buffer;
aSample->size = newSize;
aSample->data[0] = 0xff;
aSample->data[1] = 0xf1;
aSample->data[2] =
((aProfile - 1) << 6) + (aFrequencyIndex << 2) + (aChannelCount >> 2);
aSample->data[3] = ((aChannelCount & 0x3) << 6) + (newSize >> 11);
aSample->data[4] = (newSize & 0x7ff) >> 3;
aSample->data[5] = ((newSize & 7) << 5) + 0x1f;
aSample->data[6] = 0xfc;
return true;
}
}

View File

@ -1,107 +0,0 @@
/* 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/. */
#include "mp4_demuxer/Adts.h"
#include "mp4_demuxer/DecoderData.h"
#include "media/stagefright/MetaData.h"
#include "media/stagefright/MediaBuffer.h"
using namespace android;
namespace mp4_demuxer
{
static int32_t
FindInt32(sp<MetaData>& mMetaData, uint32_t mKey)
{
int32_t value;
if (!mMetaData->findInt32(mKey, &value))
return 0;
return value;
}
static int64_t
FindInt64(sp<MetaData>& mMetaData, uint32_t mKey)
{
int64_t value;
if (!mMetaData->findInt64(mKey, &value))
return 0;
return value;
}
void
AudioDecoderConfig::Update(sp<MetaData>& aMetaData, const char* aMimeType)
{
// aMimeType points to a string from MediaDefs.cpp so we don't need to copy it
mime_type = aMimeType;
duration = FindInt64(aMetaData, kKeyDuration);
channel_count = FindInt32(aMetaData, kKeyChannelCount);
bytes_per_sample = FindInt32(aMetaData, kKeySampleSize);
samples_per_second = FindInt32(aMetaData, kKeySampleRate);
frequency_index = Adts::GetFrequencyIndex(samples_per_second);
aac_profile = FindInt32(aMetaData, kKeyAACProfile);
uint32_t type;
aMetaData->findData(kKeyAVCC, &type, &extra_data, &extra_data_size);
}
bool
AudioDecoderConfig::IsValid()
{
return duration > 0 && channel_count > 0 && samples_per_second > 0;
}
void
VideoDecoderConfig::Update(sp<MetaData>& aMetaData, const char* aMimeType)
{
// aMimeType points to a string from MediaDefs.cpp so we don't need to copy it
mime_type = aMimeType;
duration = FindInt64(aMetaData, kKeyDuration);
display_width = FindInt32(aMetaData, kKeyDisplayWidth);
display_height = FindInt32(aMetaData, kKeyDisplayHeight);
// Copy the extra data so we don't have to hang onto MetaData.
const void* meta_extra_data;
uint32_t type;
aMetaData->findData(kKeyAVCC, &type, &meta_extra_data, &extra_data_size);
extra_data = new uint8_t[extra_data_size];
memcpy(extra_data, meta_extra_data, extra_data_size);
}
bool
VideoDecoderConfig::IsValid()
{
return display_width > 0 && display_height > 0 && duration > 0;
}
MP4Sample::MP4Sample()
: mMediaBuffer(nullptr)
, composition_timestamp(0)
, duration(0)
, byte_offset(0)
, is_sync_point(0)
, data(nullptr)
, size(0)
{
}
MP4Sample::~MP4Sample()
{
if (mMediaBuffer) {
mMediaBuffer->release();
}
}
void
MP4Sample::Update()
{
sp<MetaData> m = mMediaBuffer->meta_data();
composition_timestamp = FindInt64(m, kKeyTime);
duration = FindInt64(m, kKeyDuration);
byte_offset = FindInt64(m, kKey64BitFileOffset);
is_sync_point = FindInt32(m, kKeyIsSyncFrame);
data = reinterpret_cast<uint8_t*>(mMediaBuffer->data());
size = mMediaBuffer->range_length();
}
}

View File

@ -1,24 +0,0 @@
/* 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/. */
#ifndef ADTS_H_
#define ADTS_H_
#include <stdint.h>
namespace mp4_demuxer
{
class MP4Sample;
class Adts
{
public:
static int8_t GetFrequencyIndex(uint16_t aSamplesPerSecond);
static bool ConvertEsdsToAdts(uint16_t aChannelCount, int8_t aFrequencyIndex,
int8_t aProfile, MP4Sample* aSample);
};
}
#endif

View File

@ -1,106 +0,0 @@
/* 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/. */
#ifndef DECODER_DATA_H_
#define DECODER_DATA_H_
#include "mozilla/Types.h"
#include "nsAutoPtr.h"
namespace android
{
template <typename T> class sp;
class MetaData;
class MediaBuffer;
}
namespace mp4_demuxer
{
class MP4Demuxer;
class Adts;
class AudioDecoderConfig
{
public:
AudioDecoderConfig()
: mime_type(nullptr)
, duration(0)
, channel_count(0)
, bytes_per_sample(0)
, samples_per_second(0)
, extra_data(nullptr)
, extra_data_size(0)
, aac_profile(0)
{
}
const char* mime_type;
int64_t duration;
uint32_t channel_count;
uint32_t bytes_per_sample;
uint32_t samples_per_second;
int8_t frequency_index;
// Decoder specific extra data which in the case of H.264 is the AVCC config
// for decoders which require AVCC format as opposed to Annex B format.
const void* extra_data;
size_t extra_data_size;
void Update(android::sp<android::MetaData>& aMetaData, const char* aMimeType);
bool IsValid();
private:
friend class MP4Demuxer;
int8_t aac_profile;
};
class VideoDecoderConfig
{
public:
VideoDecoderConfig()
: mime_type(nullptr)
, duration(0)
, display_width(0)
, display_height(0)
, extra_data(nullptr)
, extra_data_size(0)
{
}
const char* mime_type;
int64_t duration;
int32_t display_width;
int32_t display_height;
nsAutoPtr<uint8_t> extra_data;
size_t extra_data_size;
void Update(android::sp<android::MetaData>& aMetaData, const char* aMimeType);
bool IsValid();
};
class MP4Sample
{
public:
MP4Sample();
~MP4Sample();
void Update();
android::MediaBuffer* mMediaBuffer;
int64_t composition_timestamp;
int64_t duration;
int64_t byte_offset;
bool is_sync_point;
uint8_t* data;
size_t size;
private:
friend class Adts;
nsAutoPtr<uint8_t> adts_buffer;
};
}
#endif

View File

@ -1,63 +0,0 @@
/* 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/. */
#ifndef MP4_DEMUXER_H_
#define MP4_DEMUXER_H_
#include "nsAutoPtr.h"
#include "mozilla/gfx/Rect.h"
#include "mp4_demuxer/DecoderData.h"
namespace mp4_demuxer
{
struct StageFrightPrivate;
typedef int64_t Microseconds;
class Stream
{
public:
virtual bool ReadAt(int64_t offset, void* data, size_t size,
size_t* bytes_read) = 0;
virtual bool Length(int64_t* size) = 0;
virtual ~Stream() {}
};
enum TrackType { kVideo = 1, kAudio };
class MP4Demuxer
{
public:
MP4Demuxer(Stream* aSource);
~MP4Demuxer();
bool Init();
Microseconds Duration();
bool CanSeek();
bool HasValidAudio();
bool HasValidVideo();
void SeekAudio(Microseconds aTime);
void SeekVideo(Microseconds aTime);
// DemuxAudioSample and DemuxVideoSample functions return nullptr on end of
// stream or error.
MP4Sample* DemuxAudioSample();
MP4Sample* DemuxVideoSample();
const AudioDecoderConfig& AudioConfig() { return mAudioConfig; }
const VideoDecoderConfig& VideoConfig() { return mVideoConfig; }
private:
AudioDecoderConfig mAudioConfig;
VideoDecoderConfig mVideoConfig;
nsAutoPtr<StageFrightPrivate> mPrivate;
};
}
#endif

View File

@ -1,192 +0,0 @@
/* 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/. */
#include "include/MPEG4Extractor.h"
#include "media/stagefright/DataSource.h"
#include "media/stagefright/MediaSource.h"
#include "media/stagefright/MetaData.h"
#include "mp4_demuxer/Adts.h"
#include "mp4_demuxer/mp4_demuxer.h"
#include <stdint.h>
using namespace android;
namespace mp4_demuxer
{
struct StageFrightPrivate
{
sp<MPEG4Extractor> mExtractor;
sp<MediaSource> mAudio;
MediaSource::ReadOptions mAudioOptions;
sp<MediaSource> mVideo;
MediaSource::ReadOptions mVideoOptions;
};
class DataSourceAdapter : public DataSource
{
public:
DataSourceAdapter(Stream* aSource) : mSource(aSource) {}
~DataSourceAdapter() {}
virtual status_t initCheck() const { return NO_ERROR; }
virtual ssize_t readAt(off64_t offset, void* data, size_t size)
{
MOZ_ASSERT(((ssize_t)size) >= 0);
size_t bytesRead;
if (!mSource->ReadAt(offset, data, size, &bytesRead))
return ERROR_IO;
if (bytesRead == 0)
return ERROR_END_OF_STREAM;
MOZ_ASSERT(((ssize_t)bytesRead) >= 0);
return bytesRead;
}
virtual status_t getSize(off64_t* size)
{
if (!mSource->Length(size))
return ERROR_UNSUPPORTED;
return NO_ERROR;
}
virtual uint32_t flags() { return kWantsPrefetching | kIsHTTPBasedSource; }
virtual status_t reconnectAtOffset(off64_t offset) { return NO_ERROR; }
private:
nsAutoPtr<Stream> mSource;
};
MP4Demuxer::MP4Demuxer(Stream* source) : mPrivate(new StageFrightPrivate())
{
mPrivate->mExtractor = new MPEG4Extractor(new DataSourceAdapter(source));
}
MP4Demuxer::~MP4Demuxer()
{
if (mPrivate->mAudio.get()) {
mPrivate->mAudio->stop();
}
if (mPrivate->mVideo.get()) {
mPrivate->mVideo->stop();
}
}
bool
MP4Demuxer::Init()
{
sp<MediaExtractor> e = mPrivate->mExtractor;
for (size_t i = 0; i < e->countTracks(); i++) {
sp<MetaData> metaData = e->getTrackMetaData(i);
const char* mimeType;
if (!metaData->findCString(kKeyMIMEType, &mimeType))
continue;
if (!mPrivate->mAudio.get() && !strncmp(mimeType, "audio/", 6)) {
mPrivate->mAudio = e->getTrack(i);
mPrivate->mAudio->start();
mAudioConfig.Update(metaData, mimeType);
} else if (!mPrivate->mVideo.get() && !strncmp(mimeType, "video/", 6)) {
mPrivate->mVideo = e->getTrack(i);
mPrivate->mVideo->start();
mVideoConfig.Update(metaData, mimeType);
}
}
return mPrivate->mAudio.get() || mPrivate->mVideo.get();
}
bool
MP4Demuxer::HasValidAudio()
{
return mPrivate->mAudio.get() && mAudioConfig.IsValid();
}
bool
MP4Demuxer::HasValidVideo()
{
return mPrivate->mVideo.get() && mVideoConfig.IsValid();
}
Microseconds
MP4Demuxer::Duration()
{
return std::max(mVideoConfig.duration, mAudioConfig.duration);
}
bool
MP4Demuxer::CanSeek()
{
return mPrivate->mExtractor->flags() & MediaExtractor::CAN_SEEK;
}
void
MP4Demuxer::SeekAudio(Microseconds aTime)
{
mPrivate->mAudioOptions.setSeekTo(
aTime, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
}
void
MP4Demuxer::SeekVideo(Microseconds aTime)
{
mPrivate->mVideoOptions.setSeekTo(
aTime, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
}
MP4Sample*
MP4Demuxer::DemuxAudioSample()
{
nsAutoPtr<MP4Sample> sample(new MP4Sample());
status_t status =
mPrivate->mAudio->read(&sample->mMediaBuffer, &mPrivate->mAudioOptions);
mPrivate->mAudioOptions.clearSeekTo();
if (status < 0) {
return nullptr;
}
sample->Update();
if (!Adts::ConvertEsdsToAdts(mAudioConfig.channel_count,
mAudioConfig.frequency_index,
mAudioConfig.aac_profile, sample)) {
return nullptr;
}
return sample.forget();
}
MP4Sample*
MP4Demuxer::DemuxVideoSample()
{
nsAutoPtr<MP4Sample> sample(new MP4Sample());
status_t status =
mPrivate->mVideo->read(&sample->mMediaBuffer, &mPrivate->mVideoOptions);
mPrivate->mVideoOptions.clearSeekTo();
if (status < 0) {
return nullptr;
}
sample->Update();
// The stagefright demuxer outputs Annex B format but decoders such as ffmpeg
// want AVCC format so we clobber the 00 00 00 01 with the nalsize.
if (sample->size < sizeof(uint32_t)) {
return nullptr;
}
*reinterpret_cast<uint32_t*>(sample->data) =
htonl(sample->size - sizeof(uint32_t));
return sample.forget();
}
}

View File

@ -1,52 +0,0 @@
#!/bin/bash -e
set -o pipefail
abort () {
errcode=$?
echo "Error: That didn't work..."
exit $errcode
}
trap abort ERR
cd `dirname "$0"`
SITE=https://android.googlesource.com/platform
for TAGFILE in `find patches -name \*.tag`
do
REPO=${TAGFILE:8:-4}
DEST=android/${REPO}
if [[ ! -e ${DEST} ]]
then
mkdir -p `dirname ${DEST}`
echo Cloning from ${SITE}/${REPO}
git clone ${SITE}/${REPO} ${DEST}
fi
rm -fR ${REPO}
TAG=`cat $TAGFILE`
(cd $DEST && git reset --hard 2>&1 && git checkout ${TAG} 2>&1) > /dev/null
done
FILES=`python files.py`
HEADERS=`cat additional_headers`
for FILE in $FILES $HEADERS frameworks/av/media/libstagefright/include/AMRExtractor.h
do
echo Copying ${FILE}
mkdir -p `dirname ${FILE}`
cp android/${FILE} ${FILE}
done
for PATCH in `find patches -name \*.patch`
do
REPO=${PATCH:8:-6}
echo Patching repo ${REPO}
for FILE in `grep -- '--- a/' ${PATCH} | colrm 1 6`
do
if [[ ! -e ${FILE} ]]
then
echo Copying ${REPO}/${FILE}
mkdir -p `dirname ${REPO}/${FILE}`
cp android/${REPO}/${FILE} ${REPO}/${FILE}
fi
done
(cd ${REPO} && patch -p1 || true) < $PATCH
done

View File

@ -1,29 +0,0 @@
#!/usr/bin/python
import os
import sys
DEFINES={}
CONFIG={}
CXXFLAGS=[]
CONFIG['_MSC_VER'] = 0
CONFIG['OS_TARGET'] = 0
class Exports(object):
def __init__(self):
self.mp4_demuxer=[]
EXPORTS=Exports()
SOURCES=[]
UNIFIED_SOURCES=[]
LOCAL_INCLUDES=[]
try:
execfile('moz.build')
except:
sys.exit(1)
for f in SOURCES+UNIFIED_SOURCES:
if not f.startswith('binding/'):
print f

View File

@ -21,10 +21,16 @@
#include <sys/types.h>
#include <media/stagefright/MediaErrors.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/List.h>
#include <utils/RefBase.h>
#include <utils/threads.h>
#include <drm/DrmManagerClient.h>
namespace android {
struct AMessage;
class String8;
class DataSource : public RefBase {
@ -36,6 +42,10 @@ public:
kIsHTTPBasedSource = 8,
};
static sp<DataSource> CreateFromURI(
const char *uri,
const KeyedVector<String8, String8> *headers = NULL);
DataSource() {}
virtual status_t initCheck() const = 0;
@ -59,7 +69,6 @@ public:
return ERROR_UNSUPPORTED;
}
#if 0
////////////////////////////////////////////////////////////////////////////
bool sniff(String8 *mimeType, float *confidence, sp<AMessage> *meta);
@ -83,7 +92,6 @@ public:
virtual String8 getUri() {
return String8();
}
#endif
virtual String8 getMIMEType() const;
@ -91,6 +99,9 @@ protected:
virtual ~DataSource() {}
private:
static Mutex gSnifferMutex;
static List<SnifferFunc> gSniffers;
DataSource(const DataSource &);
DataSource &operator=(const DataSource &);
};

View File

@ -22,47 +22,49 @@
namespace android {
#define MEDIA_ERROR_BASE (-1000)
enum {
MEDIA_ERROR_BASE = -1000,
#define ERROR_ALREADY_CONNECTED (MEDIA_ERROR_BASE)
#define ERROR_NOT_CONNECTED (MEDIA_ERROR_BASE - 1)
#define ERROR_UNKNOWN_HOST (MEDIA_ERROR_BASE - 2)
#define ERROR_CANNOT_CONNECT (MEDIA_ERROR_BASE - 3)
#define ERROR_IO (MEDIA_ERROR_BASE - 4)
#define ERROR_CONNECTION_LOST (MEDIA_ERROR_BASE - 5)
#define ERROR_MALFORMED (MEDIA_ERROR_BASE - 7)
#define ERROR_OUT_OF_RANGE (MEDIA_ERROR_BASE - 8)
#define ERROR_BUFFER_TOO_SMALL (MEDIA_ERROR_BASE - 9)
#define ERROR_UNSUPPORTED (MEDIA_ERROR_BASE - 10)
#define ERROR_END_OF_STREAM (MEDIA_ERROR_BASE - 11)
ERROR_ALREADY_CONNECTED = MEDIA_ERROR_BASE,
ERROR_NOT_CONNECTED = MEDIA_ERROR_BASE - 1,
ERROR_UNKNOWN_HOST = MEDIA_ERROR_BASE - 2,
ERROR_CANNOT_CONNECT = MEDIA_ERROR_BASE - 3,
ERROR_IO = MEDIA_ERROR_BASE - 4,
ERROR_CONNECTION_LOST = MEDIA_ERROR_BASE - 5,
ERROR_MALFORMED = MEDIA_ERROR_BASE - 7,
ERROR_OUT_OF_RANGE = MEDIA_ERROR_BASE - 8,
ERROR_BUFFER_TOO_SMALL = MEDIA_ERROR_BASE - 9,
ERROR_UNSUPPORTED = MEDIA_ERROR_BASE - 10,
ERROR_END_OF_STREAM = MEDIA_ERROR_BASE - 11,
// Not technically an error.
#define INFO_FORMAT_CHANGED (MEDIA_ERROR_BASE - 12)
#define INFO_DISCONTINUITY (MEDIA_ERROR_BASE - 13)
#define INFO_OUTPUT_BUFFERS_CHANGED (MEDIA_ERROR_BASE - 14)
// Not technically an error.
INFO_FORMAT_CHANGED = MEDIA_ERROR_BASE - 12,
INFO_DISCONTINUITY = MEDIA_ERROR_BASE - 13,
INFO_OUTPUT_BUFFERS_CHANGED = MEDIA_ERROR_BASE - 14,
// The following constant values should be in sync with
// drm/drm_framework_common.h
#define DRM_ERROR_BASE (-2000)
// The following constant values should be in sync with
// drm/drm_framework_common.h
DRM_ERROR_BASE = -2000,
#define ERROR_DRM_UNKNOWN (DRM_ERROR_BASE)
#define ERROR_DRM_NO_LICENSE (DRM_ERROR_BASE - 1)
#define ERROR_DRM_LICENSE_EXPIRED (DRM_ERROR_BASE - 2)
#define ERROR_DRM_SESSION_NOT_OPENED (DRM_ERROR_BASE - 3)
#define ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED (DRM_ERROR_BASE - 4)
#define ERROR_DRM_DECRYPT (DRM_ERROR_BASE - 5)
#define ERROR_DRM_CANNOT_HANDLE (DRM_ERROR_BASE - 6)
#define ERROR_DRM_TAMPER_DETECTED (DRM_ERROR_BASE - 7)
#define ERROR_DRM_NOT_PROVISIONED (DRM_ERROR_BASE - 8)
#define ERROR_DRM_DEVICE_REVOKED (DRM_ERROR_BASE - 9)
#define ERROR_DRM_RESOURCE_BUSY (DRM_ERROR_BASE - 10)
ERROR_DRM_UNKNOWN = DRM_ERROR_BASE,
ERROR_DRM_NO_LICENSE = DRM_ERROR_BASE - 1,
ERROR_DRM_LICENSE_EXPIRED = DRM_ERROR_BASE - 2,
ERROR_DRM_SESSION_NOT_OPENED = DRM_ERROR_BASE - 3,
ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED = DRM_ERROR_BASE - 4,
ERROR_DRM_DECRYPT = DRM_ERROR_BASE - 5,
ERROR_DRM_CANNOT_HANDLE = DRM_ERROR_BASE - 6,
ERROR_DRM_TAMPER_DETECTED = DRM_ERROR_BASE - 7,
ERROR_DRM_NOT_PROVISIONED = DRM_ERROR_BASE - 8,
ERROR_DRM_DEVICE_REVOKED = DRM_ERROR_BASE - 9,
ERROR_DRM_RESOURCE_BUSY = DRM_ERROR_BASE - 10,
#define ERROR_DRM_VENDOR_MAX (DRM_ERROR_BASE - 500)
#define ERROR_DRM_VENDOR_MIN (DRM_ERROR_BASE - 999)
ERROR_DRM_VENDOR_MAX = DRM_ERROR_BASE - 500,
ERROR_DRM_VENDOR_MIN = DRM_ERROR_BASE - 999,
// Heartbeat Error Codes
#define HEARTBEAT_ERROR_BASE (-3000)
#define ERROR_HEARTBEAT_TERMINATE_REQUESTED (HEARTBEAT_ERROR_BASE)
// Heartbeat Error Codes
HEARTBEAT_ERROR_BASE = -3000,
ERROR_HEARTBEAT_TERMINATE_REQUESTED = HEARTBEAT_ERROR_BASE,
};
} // namespace android

View File

@ -42,7 +42,7 @@ public:
// Return container specific meta-data. The default implementation
// returns an empty metadata object.
virtual sp<MetaData> getMetaData() = 0;
virtual sp<MetaData> getMetaData();
enum Flags {
CAN_SEEK_BACKWARD = 1, // the "seek 10secs back button"
@ -53,7 +53,7 @@ public:
// If subclasses do _not_ override this, the default is
// CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK | CAN_PAUSE
virtual uint32_t flags() const = 0;
virtual uint32_t flags() const;
// for DRM
void setDrmFlag(bool flag) {

View File

@ -48,7 +48,6 @@ enum {
kKeyChannelCount = '#chn', // int32_t
kKeyChannelMask = 'chnm', // int32_t
kKeySampleRate = 'srte', // int32_t (audio sampling rate Hz)
kKeySampleSize = 'ssiz', // int32_t (sample size in bytes)
kKeyFrameRate = 'frmR', // int32_t (video frame rate fps)
kKeyBitRate = 'brte', // int32_t (bps)
kKeyESDS = 'esds', // raw data

View File

@ -28,7 +28,7 @@
namespace android {
#define FOURCC(c1, c2, c3, c4) \
((uint32_t) c1 << 24 | c2 << 16 | c3 << 8 | c4)
(c1 << 24 | c2 << 16 | c3 << 8 | c4)
uint16_t U16_AT(const uint8_t *ptr);
uint32_t U32_AT(const uint8_t *ptr);
@ -50,6 +50,15 @@ void convertMessageToMetaData(
AString MakeUserAgent();
// Convert a MIME type to a AudioSystem::audio_format
status_t mapMimeToAudioFormat(audio_format_t& format, const char* mime);
// Send information from MetaData to the HAL via AudioSink
status_t sendMetaDataToHal(sp<MediaPlayerBase::AudioSink>& sink, const sp<MetaData>& meta);
// Check whether the stream defined by meta can be offloaded to hardware
bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo, bool isStreaming);
} // namespace android
#endif // UTILS_H_

View File

@ -20,10 +20,28 @@
#include "include/chromium_http_stub.h"
#endif
#include "include/AACExtractor.h"
#include "include/DRMExtractor.h"
#include "include/FLACExtractor.h"
#include "include/HTTPBase.h"
#include "include/MP3Extractor.h"
#include "include/MPEG2PSExtractor.h"
#include "include/MPEG2TSExtractor.h"
#include "include/MPEG4Extractor.h"
#include "include/NuCachedSource2.h"
#include "include/OggExtractor.h"
#include "include/WAVExtractor.h"
#include "include/WVMExtractor.h"
#include "matroska/MatroskaExtractor.h"
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/FileSource.h>
#include <media/stagefright/MediaErrors.h>
#include <utils/String8.h>
#include <cutils/properties.h>
namespace android {
@ -87,8 +105,6 @@ status_t DataSource::getSize(off64_t *size) {
////////////////////////////////////////////////////////////////////////////////
#if 0
Mutex DataSource::gSnifferMutex;
List<DataSource::SnifferFunc> DataSource::gSniffers;
@ -210,8 +226,6 @@ sp<DataSource> DataSource::CreateFromURI(
return source;
}
#endif
String8 DataSource::getMIMEType() const {
return String8("application/octet-stream");
}

View File

@ -15,7 +15,6 @@
*/
//#define LOG_NDEBUG 0
#undef LOG_TAG
#define LOG_TAG "ESDS"
#include <utils/Log.h>
@ -226,4 +225,3 @@ status_t ESDS::parseDecoderConfigDescriptor(size_t offset, size_t size) {
} // namespace android
#undef LOG_TAG

View File

@ -15,7 +15,6 @@
*/
//#define LOG_NDEBUG 0
#undef LOG_TAG
#define LOG_TAG "MPEG4Extractor"
#include <utils/Log.h>
@ -1249,7 +1248,6 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
ALOGV("*** coding='%s' %d channels, size %d, rate %d\n",
chunk, num_channels, sample_size, sample_rate);
mLastTrack->meta->setInt32(kKeyChannelCount, num_channels);
mLastTrack->meta->setInt32(kKeySampleSize, sample_size);
mLastTrack->meta->setInt32(kKeySampleRate, sample_rate);
off64_t stop_offset = *offset + chunk_size;
@ -2280,10 +2278,6 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
objectType = 32 + br.getBits(6);
}
if (objectType >= 1 && objectType <= 4) {
mLastTrack->meta->setInt32(kKeyAACProfile, objectType);
}
uint32_t freqIndex = br.getBits(4);
int32_t sampleRate = 0;
@ -3160,7 +3154,6 @@ status_t MPEG4Source::read(
CHECK(mBuffer != NULL);
mBuffer->set_range(0, size);
mBuffer->meta_data()->clear();
mBuffer->meta_data()->setInt64(kKey64BitFileOffset, offset);
mBuffer->meta_data()->setInt64(
kKeyTime, ((int64_t)cts * 1000000) / mTimescale);
@ -3283,7 +3276,6 @@ status_t MPEG4Source::read(
}
mBuffer->meta_data()->clear();
mBuffer->meta_data()->setInt64(kKey64BitFileOffset, offset);
mBuffer->meta_data()->setInt64(
kKeyTime, ((int64_t)cts * 1000000) / mTimescale);
@ -3634,7 +3626,6 @@ static bool isCompatibleBrand(uint32_t fourcc) {
return false;
}
#if 0
// Attempt to actually parse the 'ftyp' atom and determine if a suitable
// compatible brand is present.
// Also try to identify where this file's metadata ends
@ -3765,8 +3756,5 @@ bool SniffMPEG4(
return false;
}
#endif
} // namespace android
#undef LOG_TAG

View File

@ -14,7 +14,6 @@
* limitations under the License.
*/
#undef LOG_TAG
#define LOG_TAG "MediaBufferGroup"
#include <utils/Log.h>
@ -85,5 +84,3 @@ void MediaBufferGroup::signalBufferReturned(MediaBuffer *) {
}
} // namespace android
#undef LOG_TAG

View File

@ -15,7 +15,6 @@
*/
//#define LOG_NDEBUG 0
#undef LOG_TAG
#define LOG_TAG "MetaData"
#include <utils/Log.h>
@ -353,4 +352,3 @@ void MetaData::dumpToLog() const {
} // namespace android
#undef LOG_TAG

View File

@ -14,7 +14,6 @@
* limitations under the License.
*/
#undef LOG_TAG
#define LOG_TAG "SampleIterator"
//#define LOG_NDEBUG 0
#include <utils/Log.h>
@ -315,4 +314,3 @@ status_t SampleIterator::findSampleTime(
} // namespace android
#undef LOG_TAG

View File

@ -14,7 +14,6 @@
* limitations under the License.
*/
#undef LOG_TAG
#define LOG_TAG "SampleTable"
//#define LOG_NDEBUG 0
#include <utils/Log.h>
@ -830,4 +829,3 @@ uint32_t SampleTable::getCompositionTimeOffset(uint32_t sampleIndex) {
} // namespace android
#undef LOG_TAG

View File

@ -15,7 +15,6 @@
*/
//#define LOG_NDEBUG 0
#undef LOG_TAG
#define LOG_TAG "Utils"
#include <utils/Log.h>
@ -69,7 +68,6 @@ uint64_t hton64(uint64_t x) {
return ((uint64_t)htonl(x & 0xffffffff) << 32) | htonl(x >> 32);
}
#if 0
status_t convertMetaDataToMessage(
const sp<MetaData> &meta, sp<AMessage> *format) {
format->clear();
@ -605,8 +603,5 @@ bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo, bool isStreaming)
return AudioSystem::isOffloadSupported(info);
}
#endif
} // namespace android
#undef LOG_TAG

View File

@ -16,7 +16,6 @@
#include "ABitReader.h"
#include <log/log.h>
#include <media/stagefright/foundation/ADebug.h>
namespace android {

View File

@ -325,13 +325,7 @@ AString StringPrintf(const char *format, ...) {
va_start(ap, format);
char *buffer;
#ifdef _MSC_VER
int n = vsnprintf(NULL, 0, format, ap);
buffer = new char[n+1];
vsnprintf(buffer, n+1, format, ap);
#else
vasprintf(&buffer, format, ap);
#endif
va_end(ap);

View File

@ -15,7 +15,6 @@
*/
//#define LOG_NDEBUG 0
#undef LOG_TAG
#define LOG_TAG "hexdump"
#include <utils/Log.h>
@ -93,4 +92,3 @@ void hexdump(const void *_data, size_t size, size_t indent, AString *appendTo) {
} // namespace android
#undef LOG_TAG

View File

@ -15,7 +15,6 @@
*/
//#define LOG_NDEBUG 0
#undef LOG_TAG
#define LOG_TAG "ID3"
#include <utils/Log.h>
@ -899,5 +898,3 @@ bool ID3::parseV1(const sp<DataSource> &source) {
}
} // namespace android
#undef LOG_TAG

View File

@ -14,9 +14,6 @@
* limitations under the License.
*/
#ifndef SAMPLE_ITERATOR_H_
#define SAMPLE_ITERATOR_H_
#include <utils/Vector.h>
namespace android {
@ -76,4 +73,3 @@ private:
} // namespace android
#endif

View File

@ -1,524 +0,0 @@
diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h
index 742bc0e..2a5e2f6 100644
--- a/include/media/stagefright/DataSource.h
+++ b/include/media/stagefright/DataSource.h
@@ -21,16 +21,10 @@
#include <sys/types.h>
#include <media/stagefright/MediaErrors.h>
-#include <utils/Errors.h>
-#include <utils/KeyedVector.h>
-#include <utils/List.h>
#include <utils/RefBase.h>
-#include <utils/threads.h>
-#include <drm/DrmManagerClient.h>
namespace android {
-struct AMessage;
class String8;
class DataSource : public RefBase {
@@ -42,10 +36,6 @@ public:
kIsHTTPBasedSource = 8,
};
- static sp<DataSource> CreateFromURI(
- const char *uri,
- const KeyedVector<String8, String8> *headers = NULL);
-
DataSource() {}
virtual status_t initCheck() const = 0;
@@ -69,6 +59,7 @@ public:
return ERROR_UNSUPPORTED;
}
+#if 0
////////////////////////////////////////////////////////////////////////////
bool sniff(String8 *mimeType, float *confidence, sp<AMessage> *meta);
@@ -92,6 +83,7 @@ public:
virtual String8 getUri() {
return String8();
}
+#endif
virtual String8 getMIMEType() const;
@@ -99,9 +91,6 @@ protected:
virtual ~DataSource() {}
private:
- static Mutex gSnifferMutex;
- static List<SnifferFunc> gSniffers;
-
DataSource(const DataSource &);
DataSource &operator=(const DataSource &);
};
diff --git a/include/media/stagefright/MediaErrors.h b/include/media/stagefright/MediaErrors.h
index 686f286..786522c 100644
--- a/include/media/stagefright/MediaErrors.h
+++ b/include/media/stagefright/MediaErrors.h
@@ -22,49 +22,47 @@
namespace android {
-enum {
- MEDIA_ERROR_BASE = -1000,
+#define MEDIA_ERROR_BASE (-1000)
- ERROR_ALREADY_CONNECTED = MEDIA_ERROR_BASE,
- ERROR_NOT_CONNECTED = MEDIA_ERROR_BASE - 1,
- ERROR_UNKNOWN_HOST = MEDIA_ERROR_BASE - 2,
- ERROR_CANNOT_CONNECT = MEDIA_ERROR_BASE - 3,
- ERROR_IO = MEDIA_ERROR_BASE - 4,
- ERROR_CONNECTION_LOST = MEDIA_ERROR_BASE - 5,
- ERROR_MALFORMED = MEDIA_ERROR_BASE - 7,
- ERROR_OUT_OF_RANGE = MEDIA_ERROR_BASE - 8,
- ERROR_BUFFER_TOO_SMALL = MEDIA_ERROR_BASE - 9,
- ERROR_UNSUPPORTED = MEDIA_ERROR_BASE - 10,
- ERROR_END_OF_STREAM = MEDIA_ERROR_BASE - 11,
+#define ERROR_ALREADY_CONNECTED (MEDIA_ERROR_BASE)
+#define ERROR_NOT_CONNECTED (MEDIA_ERROR_BASE - 1)
+#define ERROR_UNKNOWN_HOST (MEDIA_ERROR_BASE - 2)
+#define ERROR_CANNOT_CONNECT (MEDIA_ERROR_BASE - 3)
+#define ERROR_IO (MEDIA_ERROR_BASE - 4)
+#define ERROR_CONNECTION_LOST (MEDIA_ERROR_BASE - 5)
+#define ERROR_MALFORMED (MEDIA_ERROR_BASE - 7)
+#define ERROR_OUT_OF_RANGE (MEDIA_ERROR_BASE - 8)
+#define ERROR_BUFFER_TOO_SMALL (MEDIA_ERROR_BASE - 9)
+#define ERROR_UNSUPPORTED (MEDIA_ERROR_BASE - 10)
+#define ERROR_END_OF_STREAM (MEDIA_ERROR_BASE - 11)
- // Not technically an error.
- INFO_FORMAT_CHANGED = MEDIA_ERROR_BASE - 12,
- INFO_DISCONTINUITY = MEDIA_ERROR_BASE - 13,
- INFO_OUTPUT_BUFFERS_CHANGED = MEDIA_ERROR_BASE - 14,
+// Not technically an error.
+#define INFO_FORMAT_CHANGED (MEDIA_ERROR_BASE - 12)
+#define INFO_DISCONTINUITY (MEDIA_ERROR_BASE - 13)
+#define INFO_OUTPUT_BUFFERS_CHANGED (MEDIA_ERROR_BASE - 14)
- // The following constant values should be in sync with
- // drm/drm_framework_common.h
- DRM_ERROR_BASE = -2000,
+// The following constant values should be in sync with
+// drm/drm_framework_common.h
+#define DRM_ERROR_BASE (-2000)
- ERROR_DRM_UNKNOWN = DRM_ERROR_BASE,
- ERROR_DRM_NO_LICENSE = DRM_ERROR_BASE - 1,
- ERROR_DRM_LICENSE_EXPIRED = DRM_ERROR_BASE - 2,
- ERROR_DRM_SESSION_NOT_OPENED = DRM_ERROR_BASE - 3,
- ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED = DRM_ERROR_BASE - 4,
- ERROR_DRM_DECRYPT = DRM_ERROR_BASE - 5,
- ERROR_DRM_CANNOT_HANDLE = DRM_ERROR_BASE - 6,
- ERROR_DRM_TAMPER_DETECTED = DRM_ERROR_BASE - 7,
- ERROR_DRM_NOT_PROVISIONED = DRM_ERROR_BASE - 8,
- ERROR_DRM_DEVICE_REVOKED = DRM_ERROR_BASE - 9,
- ERROR_DRM_RESOURCE_BUSY = DRM_ERROR_BASE - 10,
+#define ERROR_DRM_UNKNOWN (DRM_ERROR_BASE)
+#define ERROR_DRM_NO_LICENSE (DRM_ERROR_BASE - 1)
+#define ERROR_DRM_LICENSE_EXPIRED (DRM_ERROR_BASE - 2)
+#define ERROR_DRM_SESSION_NOT_OPENED (DRM_ERROR_BASE - 3)
+#define ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED (DRM_ERROR_BASE - 4)
+#define ERROR_DRM_DECRYPT (DRM_ERROR_BASE - 5)
+#define ERROR_DRM_CANNOT_HANDLE (DRM_ERROR_BASE - 6)
+#define ERROR_DRM_TAMPER_DETECTED (DRM_ERROR_BASE - 7)
+#define ERROR_DRM_NOT_PROVISIONED (DRM_ERROR_BASE - 8)
+#define ERROR_DRM_DEVICE_REVOKED (DRM_ERROR_BASE - 9)
+#define ERROR_DRM_RESOURCE_BUSY (DRM_ERROR_BASE - 10)
- ERROR_DRM_VENDOR_MAX = DRM_ERROR_BASE - 500,
- ERROR_DRM_VENDOR_MIN = DRM_ERROR_BASE - 999,
+#define ERROR_DRM_VENDOR_MAX (DRM_ERROR_BASE - 500)
+#define ERROR_DRM_VENDOR_MIN (DRM_ERROR_BASE - 999)
- // Heartbeat Error Codes
- HEARTBEAT_ERROR_BASE = -3000,
- ERROR_HEARTBEAT_TERMINATE_REQUESTED = HEARTBEAT_ERROR_BASE,
-};
+// Heartbeat Error Codes
+#define HEARTBEAT_ERROR_BASE (-3000)
+#define ERROR_HEARTBEAT_TERMINATE_REQUESTED (HEARTBEAT_ERROR_BASE)
} // namespace android
diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h
index 3076a96..53072e8 100644
--- a/include/media/stagefright/MediaExtractor.h
+++ b/include/media/stagefright/MediaExtractor.h
@@ -42,7 +42,7 @@ public:
// Return container specific meta-data. The default implementation
// returns an empty metadata object.
- virtual sp<MetaData> getMetaData();
+ virtual sp<MetaData> getMetaData() = 0;
enum Flags {
CAN_SEEK_BACKWARD = 1, // the "seek 10secs back button"
@@ -53,7 +53,7 @@ public:
// If subclasses do _not_ override this, the default is
// CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK | CAN_PAUSE
- virtual uint32_t flags() const;
+ virtual uint32_t flags() const = 0;
// for DRM
void setDrmFlag(bool flag) {
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
index de3fc36..bebbda6 100644
--- a/include/media/stagefright/MetaData.h
+++ b/include/media/stagefright/MetaData.h
@@ -48,6 +48,7 @@ enum {
kKeyChannelCount = '#chn', // int32_t
kKeyChannelMask = 'chnm', // int32_t
kKeySampleRate = 'srte', // int32_t (audio sampling rate Hz)
+ kKeySampleSize = 'ssiz', // int32_t (sample size in bytes)
kKeyFrameRate = 'frmR', // int32_t (video frame rate fps)
kKeyBitRate = 'brte', // int32_t (bps)
kKeyESDS = 'esds', // raw data
diff --git a/include/media/stagefright/Utils.h b/include/media/stagefright/Utils.h
index c24f612..a580fec 100644
--- a/include/media/stagefright/Utils.h
+++ b/include/media/stagefright/Utils.h
@@ -28,7 +28,7 @@
namespace android {
#define FOURCC(c1, c2, c3, c4) \
- (c1 << 24 | c2 << 16 | c3 << 8 | c4)
+ ((uint32_t) c1 << 24 | c2 << 16 | c3 << 8 | c4)
uint16_t U16_AT(const uint8_t *ptr);
uint32_t U32_AT(const uint8_t *ptr);
@@ -50,15 +50,6 @@ void convertMessageToMetaData(
AString MakeUserAgent();
-// Convert a MIME type to a AudioSystem::audio_format
-status_t mapMimeToAudioFormat(audio_format_t& format, const char* mime);
-
-// Send information from MetaData to the HAL via AudioSink
-status_t sendMetaDataToHal(sp<MediaPlayerBase::AudioSink>& sink, const sp<MetaData>& meta);
-
-// Check whether the stream defined by meta can be offloaded to hardware
-bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo, bool isStreaming);
-
} // namespace android
#endif // UTILS_H_
diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp
index fc6fd9c..172bb53 100644
--- a/media/libstagefright/DataSource.cpp
+++ b/media/libstagefright/DataSource.cpp
@@ -20,28 +20,10 @@
#include "include/chromium_http_stub.h"
#endif
-#include "include/AACExtractor.h"
-#include "include/DRMExtractor.h"
-#include "include/FLACExtractor.h"
-#include "include/HTTPBase.h"
-#include "include/MP3Extractor.h"
-#include "include/MPEG2PSExtractor.h"
-#include "include/MPEG2TSExtractor.h"
#include "include/MPEG4Extractor.h"
-#include "include/NuCachedSource2.h"
-#include "include/OggExtractor.h"
-#include "include/WAVExtractor.h"
-#include "include/WVMExtractor.h"
-#include "matroska/MatroskaExtractor.h"
-
-#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/DataSource.h>
-#include <media/stagefright/FileSource.h>
#include <media/stagefright/MediaErrors.h>
-#include <utils/String8.h>
-
-#include <cutils/properties.h>
namespace android {
@@ -105,6 +87,8 @@ status_t DataSource::getSize(off64_t *size) {
////////////////////////////////////////////////////////////////////////////////
+#if 0
+
Mutex DataSource::gSnifferMutex;
List<DataSource::SnifferFunc> DataSource::gSniffers;
@@ -226,6 +210,8 @@ sp<DataSource> DataSource::CreateFromURI(
return source;
}
+#endif
+
String8 DataSource::getMIMEType() const {
return String8("application/octet-stream");
}
diff --git a/media/libstagefright/ESDS.cpp b/media/libstagefright/ESDS.cpp
index 4a0c35c..0366960 100644
--- a/media/libstagefright/ESDS.cpp
+++ b/media/libstagefright/ESDS.cpp
@@ -15,6 +15,7 @@
*/
//#define LOG_NDEBUG 0
+#undef LOG_TAG
#define LOG_TAG "ESDS"
#include <utils/Log.h>
@@ -225,3 +226,4 @@ status_t ESDS::parseDecoderConfigDescriptor(size_t offset, size_t size) {
} // namespace android
+#undef LOG_TAG
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index ad985ee..17a90cb 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -15,6 +15,7 @@
*/
//#define LOG_NDEBUG 0
+#undef LOG_TAG
#define LOG_TAG "MPEG4Extractor"
#include <utils/Log.h>
@@ -1248,6 +1249,7 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
ALOGV("*** coding='%s' %d channels, size %d, rate %d\n",
chunk, num_channels, sample_size, sample_rate);
mLastTrack->meta->setInt32(kKeyChannelCount, num_channels);
+ mLastTrack->meta->setInt32(kKeySampleSize, sample_size);
mLastTrack->meta->setInt32(kKeySampleRate, sample_rate);
off64_t stop_offset = *offset + chunk_size;
@@ -2278,6 +2280,10 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
objectType = 32 + br.getBits(6);
}
+ if (objectType >= 1 && objectType <= 4) {
+ mLastTrack->meta->setInt32(kKeyAACProfile, objectType);
+ }
+
uint32_t freqIndex = br.getBits(4);
int32_t sampleRate = 0;
@@ -3154,6 +3160,7 @@ status_t MPEG4Source::read(
CHECK(mBuffer != NULL);
mBuffer->set_range(0, size);
mBuffer->meta_data()->clear();
+ mBuffer->meta_data()->setInt64(kKey64BitFileOffset, offset);
mBuffer->meta_data()->setInt64(
kKeyTime, ((int64_t)cts * 1000000) / mTimescale);
@@ -3276,6 +3283,7 @@ status_t MPEG4Source::read(
}
mBuffer->meta_data()->clear();
+ mBuffer->meta_data()->setInt64(kKey64BitFileOffset, offset);
mBuffer->meta_data()->setInt64(
kKeyTime, ((int64_t)cts * 1000000) / mTimescale);
@@ -3626,6 +3634,7 @@ static bool isCompatibleBrand(uint32_t fourcc) {
return false;
}
+#if 0
// Attempt to actually parse the 'ftyp' atom and determine if a suitable
// compatible brand is present.
// Also try to identify where this file's metadata ends
@@ -3756,5 +3765,8 @@ bool SniffMPEG4(
return false;
}
+#endif
} // namespace android
+
+#undef LOG_TAG
diff --git a/media/libstagefright/MediaBufferGroup.cpp b/media/libstagefright/MediaBufferGroup.cpp
index 80aae51..1ae12cf 100644
--- a/media/libstagefright/MediaBufferGroup.cpp
+++ b/media/libstagefright/MediaBufferGroup.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#undef LOG_TAG
#define LOG_TAG "MediaBufferGroup"
#include <utils/Log.h>
@@ -84,3 +85,5 @@ void MediaBufferGroup::signalBufferReturned(MediaBuffer *) {
}
} // namespace android
+
+#undef LOG_TAG
diff --git a/media/libstagefright/MetaData.cpp b/media/libstagefright/MetaData.cpp
index ae6ae2d..050dbac 100644
--- a/media/libstagefright/MetaData.cpp
+++ b/media/libstagefright/MetaData.cpp
@@ -15,6 +15,7 @@
*/
//#define LOG_NDEBUG 0
+#undef LOG_TAG
#define LOG_TAG "MetaData"
#include <utils/Log.h>
@@ -352,3 +353,4 @@ void MetaData::dumpToLog() const {
} // namespace android
+#undef LOG_TAG
diff --git a/media/libstagefright/SampleIterator.cpp b/media/libstagefright/SampleIterator.cpp
index eae721b..58dbdc3 100644
--- a/media/libstagefright/SampleIterator.cpp
+++ b/media/libstagefright/SampleIterator.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#undef LOG_TAG
#define LOG_TAG "SampleIterator"
//#define LOG_NDEBUG 0
#include <utils/Log.h>
@@ -314,3 +315,4 @@ status_t SampleIterator::findSampleTime(
} // namespace android
+#undef LOG_TAG
diff --git a/media/libstagefright/SampleTable.cpp b/media/libstagefright/SampleTable.cpp
index d9858d7..8e637fb 100644
--- a/media/libstagefright/SampleTable.cpp
+++ b/media/libstagefright/SampleTable.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#undef LOG_TAG
#define LOG_TAG "SampleTable"
//#define LOG_NDEBUG 0
#include <utils/Log.h>
@@ -829,3 +830,4 @@ uint32_t SampleTable::getCompositionTimeOffset(uint32_t sampleIndex) {
} // namespace android
+#undef LOG_TAG
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp
index 4db8e80..bdbb000 100644
--- a/media/libstagefright/Utils.cpp
+++ b/media/libstagefright/Utils.cpp
@@ -15,6 +15,7 @@
*/
//#define LOG_NDEBUG 0
+#undef LOG_TAG
#define LOG_TAG "Utils"
#include <utils/Log.h>
@@ -68,6 +69,7 @@ uint64_t hton64(uint64_t x) {
return ((uint64_t)htonl(x & 0xffffffff) << 32) | htonl(x >> 32);
}
+#if 0
status_t convertMetaDataToMessage(
const sp<MetaData> &meta, sp<AMessage> *format) {
format->clear();
@@ -603,5 +605,8 @@ bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo, bool isStreaming)
return AudioSystem::isOffloadSupported(info);
}
+#endif
+
} // namespace android
+#undef LOG_TAG
diff --git a/media/libstagefright/foundation/ABitReader.cpp b/media/libstagefright/foundation/ABitReader.cpp
index 5499c32..59330ab 100644
--- a/media/libstagefright/foundation/ABitReader.cpp
+++ b/media/libstagefright/foundation/ABitReader.cpp
@@ -16,6 +16,7 @@
#include "ABitReader.h"
+#include <log/log.h>
#include <media/stagefright/foundation/ADebug.h>
namespace android {
diff --git a/media/libstagefright/foundation/AString.cpp b/media/libstagefright/foundation/AString.cpp
index dee786d..7f68fd3 100644
--- a/media/libstagefright/foundation/AString.cpp
+++ b/media/libstagefright/foundation/AString.cpp
@@ -325,7 +325,13 @@ AString StringPrintf(const char *format, ...) {
va_start(ap, format);
char *buffer;
+#ifdef _MSC_VER
+ int n = vsnprintf(NULL, 0, format, ap);
+ buffer = new char[n+1];
+ vsnprintf(buffer, n+1, format, ap);
+#else
vasprintf(&buffer, format, ap);
+#endif
va_end(ap);
diff --git a/media/libstagefright/foundation/hexdump.cpp b/media/libstagefright/foundation/hexdump.cpp
index a44d832..e4f25aa 100644
--- a/media/libstagefright/foundation/hexdump.cpp
+++ b/media/libstagefright/foundation/hexdump.cpp
@@ -15,6 +15,7 @@
*/
//#define LOG_NDEBUG 0
+#undef LOG_TAG
#define LOG_TAG "hexdump"
#include <utils/Log.h>
@@ -92,3 +93,4 @@ void hexdump(const void *_data, size_t size, size_t indent, AString *appendTo) {
} // namespace android
+#undef LOG_TAG
diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp
index 34d671a..abe88a4 100644
--- a/media/libstagefright/id3/ID3.cpp
+++ b/media/libstagefright/id3/ID3.cpp
@@ -15,6 +15,7 @@
*/
//#define LOG_NDEBUG 0
+#undef LOG_TAG
#define LOG_TAG "ID3"
#include <utils/Log.h>
@@ -898,3 +899,5 @@ bool ID3::parseV1(const sp<DataSource> &source) {
}
} // namespace android
+
+#undef LOG_TAG
diff --git a/media/libstagefright/include/SampleIterator.h b/media/libstagefright/include/SampleIterator.h
index b5a043c..3775d9e 100644
--- a/media/libstagefright/include/SampleIterator.h
+++ b/media/libstagefright/include/SampleIterator.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef SAMPLE_ITERATOR_H_
+#define SAMPLE_ITERATOR_H_
+
#include <utils/Vector.h>
namespace android {
@@ -73,3 +76,4 @@ private:
} // namespace android
+#endif

View File

@ -1,797 +0,0 @@
diff --git a/include/cutils/properties.h b/include/cutils/properties.h
index 2c70165..c380d5d 100644
--- a/include/cutils/properties.h
+++ b/include/cutils/properties.h
@@ -19,7 +19,6 @@
#include <sys/cdefs.h>
#include <stddef.h>
-#include <sys/system_properties.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/log/log.h b/include/log/log.h
index 7faddea..6131f01 100644
--- a/include/log/log.h
+++ b/include/log/log.h
@@ -25,6 +25,16 @@
// supports O_APPEND. These calls have mutex-protected data structures
// and so are NOT reentrant. Do not use LOG in a signal handler.
//
+
+/*
+ * This is the local tag used for the following simplified
+ * logging macros. You can change this preprocessor definition
+ * before using the other macros to change the tag.
+ */
+#ifndef LOG_TAG
+#define LOG_TAG NULL
+#endif
+
#ifndef _LIBS_LOG_LOG_H
#define _LIBS_LOG_LOG_H
@@ -40,6 +50,10 @@
#include <log/uio.h>
#include <log/logd.h>
+#ifdef _MSC_VER
+#define __builtin_expect(X, Y) (X)
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -59,15 +73,6 @@ extern "C" {
#endif
#endif
-/*
- * This is the local tag used for the following simplified
- * logging macros. You can change this preprocessor definition
- * before using the other macros to change the tag.
- */
-#ifndef LOG_TAG
-#define LOG_TAG NULL
-#endif
-
// ---------------------------------------------------------------------
/*
@@ -498,11 +503,11 @@ typedef enum {
* The stuff in the rest of this file should not be used directly.
*/
-#define android_printLog(prio, tag, fmt...) \
- __android_log_print(prio, tag, fmt)
+#define android_printLog(prio, tag, ...) \
+ __android_log_print(prio, tag, __VA_ARGS__)
-#define android_vprintLog(prio, cond, tag, fmt...) \
- __android_log_vprint(prio, tag, fmt)
+#define android_vprintLog(prio, cond, tag, ...) \
+ __android_log_vprint(prio, tag, __VA_ARGS__)
/* XXX Macros to work around syntax errors in places where format string
* arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
@@ -519,9 +524,9 @@ typedef enum {
*/
#define __android_rest(first, ...) , ## __VA_ARGS__
-#define android_printAssert(cond, tag, fmt...) \
+#define android_printAssert(cond, tag, ...) \
__android_log_assert(cond, tag, \
- __android_second(0, ## fmt, NULL) __android_rest(fmt))
+ __android_second(0, ## __VA_ARGS__, NULL) __android_rest(__VA_ARGS__))
#define android_writeLog(prio, tag, text) \
__android_log_write(prio, tag, text)
diff --git a/include/log/logprint.h b/include/log/logprint.h
index 481c96e..9b57e0e 100644
--- a/include/log/logprint.h
+++ b/include/log/logprint.h
@@ -20,7 +20,6 @@
#include <log/log.h>
#include <log/logger.h>
#include <log/event_tag_map.h>
-#include <pthread.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/utils/Condition.h b/include/utils/Condition.h
index e63ba7e..73fe3fc 100644
--- a/include/utils/Condition.h
+++ b/include/utils/Condition.h
@@ -138,6 +138,18 @@ inline void Condition::broadcast() {
pthread_cond_broadcast(&mCond);
}
+#else
+
+inline Condition::Condition() {}
+inline Condition::Condition(int type) {}
+inline Condition::~Condition() {}
+inline status_t Condition::wait(Mutex& mutex) { return OK; }
+inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) {
+ return OK;
+}
+inline void Condition::signal() {}
+inline void Condition::broadcast() {}
+
#endif // HAVE_PTHREADS
// ---------------------------------------------------------------------------
diff --git a/include/utils/List.h b/include/utils/List.h
index 403cd7f..cf3d10c 100644
--- a/include/utils/List.h
+++ b/include/utils/List.h
@@ -56,9 +56,11 @@ protected:
inline void setVal(const T& val) { mVal = val; }
inline void setPrev(_Node* ptr) { mpPrev = ptr; }
inline void setNext(_Node* ptr) { mpNext = ptr; }
+#ifndef _MSC_VER
private:
friend class List;
friend class _ListIterator;
+#endif
T mVal;
_Node* mpPrev;
_Node* mpNext;
diff --git a/include/utils/Mutex.h b/include/utils/Mutex.h
index dd201c8..d381805 100644
--- a/include/utils/Mutex.h
+++ b/include/utils/Mutex.h
@@ -118,6 +118,17 @@ inline status_t Mutex::tryLock() {
return -pthread_mutex_trylock(&mMutex);
}
+#else
+
+inline Mutex::Mutex() {}
+inline Mutex::Mutex(const char* name) {}
+inline Mutex::Mutex(int type, const char* name) {}
+inline Mutex::~Mutex() {}
+inline status_t Mutex::lock() { return OK; }
+inline void Mutex::unlock() {}
+inline status_t Mutex::tryLock() { return OK; }
+inline void Mutex::_init() {}
+
#endif // HAVE_PTHREADS
// ---------------------------------------------------------------------------
diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h
index cbfe13a..a0baa2c 100644
--- a/include/utils/RefBase.h
+++ b/include/utils/RefBase.h
@@ -27,6 +27,10 @@
#include <utils/StrongPointer.h>
#include <utils/TypeHelpers.h>
+#ifdef _MSC_VER
+#define __attribute__(X)
+#endif
+
// ---------------------------------------------------------------------------
namespace android {
@@ -541,6 +545,10 @@ void move_backward_type(wp<TYPE>* d, wp<TYPE> const* s, size_t n) {
}; // namespace android
+#ifdef _MSC_VER
+#undef __attribute__
+#endif
+
// ---------------------------------------------------------------------------
#endif // ANDROID_REF_BASE_H
diff --git a/include/utils/SortedVector.h b/include/utils/SortedVector.h
index 2d3e82a..450f8f3 100644
--- a/include/utils/SortedVector.h
+++ b/include/utils/SortedVector.h
@@ -48,7 +48,6 @@ public:
virtual ~SortedVector();
/*! copy operator */
- const SortedVector<TYPE>& operator = (const SortedVector<TYPE>& rhs) const;
SortedVector<TYPE>& operator = (const SortedVector<TYPE>& rhs);
/*
@@ -168,12 +167,6 @@ SortedVector<TYPE>& SortedVector<TYPE>::operator = (const SortedVector<TYPE>& rh
}
template<class TYPE> inline
-const SortedVector<TYPE>& SortedVector<TYPE>::operator = (const SortedVector<TYPE>& rhs) const {
- SortedVectorImpl::operator = (rhs);
- return *this;
-}
-
-template<class TYPE> inline
const TYPE* SortedVector<TYPE>::array() const {
return static_cast<const TYPE *>(arrayImpl());
}
diff --git a/include/utils/String8.h b/include/utils/String8.h
index ef59470..71f7275 100644
--- a/include/utils/String8.h
+++ b/include/utils/String8.h
@@ -27,6 +27,10 @@
// ---------------------------------------------------------------------------
+#ifdef _MSC_VER
+#define __attribute__(X)
+#endif
+
namespace android {
class String16;
@@ -390,6 +394,10 @@ inline String8::operator const char*() const
} // namespace android
+#ifdef _MSC_VER
+#undef __attribute__
+#endif
+
// ---------------------------------------------------------------------------
#endif // ANDROID_STRING8_H
diff --git a/include/utils/TypeHelpers.h b/include/utils/TypeHelpers.h
index 13c9081..e63904a 100644
--- a/include/utils/TypeHelpers.h
+++ b/include/utils/TypeHelpers.h
@@ -201,7 +201,7 @@ void move_backward_type(TYPE* d, const TYPE* s, size_t n = 1) {
if ((traits<TYPE>::has_trivial_dtor && traits<TYPE>::has_trivial_copy)
|| traits<TYPE>::has_trivial_move)
{
- memmove(d,s,n*sizeof(TYPE));
+ memmove((void*)d,(void*)s,n*sizeof(TYPE));
} else {
while (n--) {
if (!traits<TYPE>::has_trivial_copy) {
diff --git a/include/utils/Unicode.h b/include/utils/Unicode.h
index c8c87c3..b76a5e2 100644
--- a/include/utils/Unicode.h
+++ b/include/utils/Unicode.h
@@ -22,9 +22,6 @@
extern "C" {
-typedef uint32_t char32_t;
-typedef uint16_t char16_t;
-
// Standard string functions on char16_t strings.
int strcmp16(const char16_t *, const char16_t *);
int strncmp16(const char16_t *s1, const char16_t *s2, size_t n);
diff --git a/include/utils/Vector.h b/include/utils/Vector.h
index ed7b725..e487b7f 100644
--- a/include/utils/Vector.h
+++ b/include/utils/Vector.h
@@ -55,10 +55,8 @@ public:
virtual ~Vector();
/*! copy operator */
- const Vector<TYPE>& operator = (const Vector<TYPE>& rhs) const;
Vector<TYPE>& operator = (const Vector<TYPE>& rhs);
- const Vector<TYPE>& operator = (const SortedVector<TYPE>& rhs) const;
Vector<TYPE>& operator = (const SortedVector<TYPE>& rhs);
/*
@@ -171,8 +169,12 @@ public:
typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs);
typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state);
- inline status_t sort(compar_t cmp);
- inline status_t sort(compar_r_t cmp, void* state);
+ inline status_t sort(compar_t cmp) {
+ return VectorImpl::sort((VectorImpl::compar_t)cmp);
+ }
+ inline status_t sort(compar_r_t cmp, void* state) {
+ return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state);
+ }
// for debugging only
inline size_t getItemSize() const { return itemSize(); }
@@ -247,24 +249,12 @@ Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) {
}
template<class TYPE> inline
-const Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const {
- VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
- return *this;
-}
-
-template<class TYPE> inline
Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) {
VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
return *this;
}
template<class TYPE> inline
-const Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) const {
- VectorImpl::operator = (rhs);
- return *this;
-}
-
-template<class TYPE> inline
const TYPE* Vector<TYPE>::array() const {
return static_cast<const TYPE *>(arrayImpl());
}
@@ -373,16 +363,6 @@ ssize_t Vector<TYPE>::removeItemsAt(size_t index, size_t count) {
return VectorImpl::removeItemsAt(index, count);
}
-template<class TYPE> inline
-status_t Vector<TYPE>::sort(Vector<TYPE>::compar_t cmp) {
- return VectorImpl::sort((VectorImpl::compar_t)cmp);
-}
-
-template<class TYPE> inline
-status_t Vector<TYPE>::sort(Vector<TYPE>::compar_r_t cmp, void* state) {
- return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state);
-}
-
// ---------------------------------------------------------------------------
template<class TYPE>
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index 5283619..a34838c 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -31,6 +31,34 @@
#include <pthread.h>
#endif
+#ifdef _MSC_VER
+#include <io.h>
+#include <process.h>
+#include <nspr/prprf.h>
+#define snprintf PR_snprintf
+
+/* We don't want to indent large blocks because it causes unnecessary merge
+ * conflicts */
+#define UNINDENTED_BLOCK_START {
+#define UNINDENTED_BLOCK_END }
+#else
+#define UNINDENTED_BLOCK_START
+#define UNINDENTED_BLOCK_END
+#endif
+
+#ifdef _MSC_VER
+#include <io.h>
+#include <process.h>
+
+/* We don't want to indent large blocks because it causes unnecessary merge
+ * conflicts */
+#define UNINDENTED_BLOCK_START {
+#define UNINDENTED_BLOCK_END }
+#else
+#define UNINDENTED_BLOCK_START
+#define UNINDENTED_BLOCK_END
+#endif
+
#define kMaxTagLen 16 /* from the long-dead utils/Log.cpp */
#define kTagSetSize 16 /* arbitrary */
@@ -191,6 +219,7 @@ static void configureInitialState(const char* pathName, LogState* logState)
/*
* This is based on the the long-dead utils/Log.cpp code.
*/
+ UNINDENTED_BLOCK_START
const char* tags = getenv("ANDROID_LOG_TAGS");
TRACE("Found ANDROID_LOG_TAGS='%s'\n", tags);
if (tags != NULL) {
@@ -264,11 +293,12 @@ static void configureInitialState(const char* pathName, LogState* logState)
}
}
}
-
+ UNINDENTED_BLOCK_END
/*
* Taken from the long-dead utils/Log.cpp
*/
+ UNINDENTED_BLOCK_START
const char* fstr = getenv("ANDROID_PRINTF_LOG");
LogFormat format;
if (fstr == NULL) {
@@ -293,6 +323,7 @@ static void configureInitialState(const char* pathName, LogState* logState)
}
logState->outputFormat = format;
+ UNINDENTED_BLOCK_END
}
/*
@@ -321,7 +352,7 @@ static const char* getPriorityString(int priority)
*/
static ssize_t fake_writev(int fd, const struct iovec *iov, int iovcnt) {
int result = 0;
- struct iovec* end = iov + iovcnt;
+ const struct iovec* end = iov + iovcnt;
for (; iov < end; iov++) {
int w = write(fd, iov->iov_base, iov->iov_len);
if (w != iov->iov_len) {
@@ -354,7 +385,11 @@ static void showLog(LogState *state,
char prefixBuf[128], suffixBuf[128];
char priChar;
time_t when;
+#ifdef _MSC_VER
+ int pid, tid;
+#else
pid_t pid, tid;
+#endif
TRACE("LOG %d: %s %s", logPrio, tag, msg);
@@ -382,6 +417,7 @@ static void showLog(LogState *state,
/*
* Construct a buffer containing the log header and log message.
*/
+ UNINDENTED_BLOCK_START
size_t prefixLen, suffixLen;
switch (state->outputFormat) {
@@ -431,6 +467,7 @@ static void showLog(LogState *state,
/*
* Figure out how many lines there will be.
*/
+ UNINDENTED_BLOCK_START
const char* end = msg + strlen(msg);
size_t numLines = 0;
const char* p = msg;
@@ -443,7 +480,8 @@ static void showLog(LogState *state,
* Create an array of iovecs large enough to write all of
* the lines with a prefix and a suffix.
*/
- const size_t INLINE_VECS = 6;
+ UNINDENTED_BLOCK_START
+ #define INLINE_VECS 6
const size_t MAX_LINES = ((size_t)~0)/(3*sizeof(struct iovec*));
struct iovec stackVec[INLINE_VECS];
struct iovec* vec = stackVec;
@@ -467,6 +505,7 @@ static void showLog(LogState *state,
* Fill in the iovec pointers.
*/
p = msg;
+ UNINDENTED_BLOCK_START
struct iovec* v = vec;
int totalLen = 0;
while (numLines > 0 && p < end) {
@@ -476,6 +515,7 @@ static void showLog(LogState *state,
totalLen += prefixLen;
v++;
}
+ UNINDENTED_BLOCK_START
const char* start = p;
while (p < end && *p != '\n') p++;
if ((p-start) > 0) {
@@ -492,6 +532,7 @@ static void showLog(LogState *state,
v++;
}
numLines -= 1;
+ UNINDENTED_BLOCK_END
}
/*
@@ -529,6 +570,10 @@ static void showLog(LogState *state,
/* if we allocated storage for the iovecs, free it */
if (vec != stackVec)
free(vec);
+ UNINDENTED_BLOCK_END
+ UNINDENTED_BLOCK_END
+ UNINDENTED_BLOCK_END
+ UNINDENTED_BLOCK_END
}
@@ -567,6 +612,7 @@ static ssize_t logWritev(int fd, const struct iovec* vector, int count)
}
/* pull out the three fields */
+ UNINDENTED_BLOCK_START
int logPrio = *(const char*)vector[0].iov_base;
const char* tag = (const char*) vector[1].iov_base;
const char* msg = (const char*) vector[2].iov_base;
@@ -590,6 +636,7 @@ static ssize_t logWritev(int fd, const struct iovec* vector, int count)
} else {
//TRACE("+++ NOLOG(%d): %s %s", logPrio, tag, msg);
}
+ UNINDENTED_BLOCK_END
bail:
unlock();
@@ -683,3 +730,6 @@ ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count)
/* Assume that open() was called first. */
return redirectWritev(fd, vector, count);
}
+
+#undef UNINDENTED_BLOCK_START
+#undef UNINDENTED_BLOCK_END
diff --git a/liblog/logd_write.c b/liblog/logd_write.c
index fff7cc4..a194a9c 100644
--- a/liblog/logd_write.c
+++ b/liblog/logd_write.c
@@ -33,7 +33,19 @@
#define LOG_BUF_SIZE 1024
+#ifdef _MSC_VER
+#include <nspr/prprf.h>
+#define snprintf PR_snprintf
+#define __builtin_trap abort
+static int W_OK = 0;
+static int access(char* c, int i) { return -1; }
+#endif
+
#if FAKE_LOG_DEVICE
+int fakeLogOpen(const char *pathName, int flags);
+ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count);
+int fakeLogClose(int fd);
+
// This will be defined when building for the host.
#define log_open(pathname, flags) fakeLogOpen(pathname, flags)
#define log_writev(filedes, vector, count) fakeLogWritev(filedes, vector, count)
@@ -258,7 +270,11 @@ void __android_log_assert(const char *cond, const char *tag,
__android_log_write(ANDROID_LOG_FATAL, tag, buf);
+#ifdef _MSC_VER
+ abort();
+#else
__builtin_trap(); /* trap so we have a chance to debug the situation */
+#endif
}
int __android_log_bwrite(int32_t tag, const void *payload, size_t len)
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 508c825..6b229df 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -29,6 +29,35 @@
#include <log/logd.h>
#include <log/logprint.h>
+#ifdef _MSC_VER
+#include <nspr/prprf.h>
+#define snprintf PR_snprintf
+#define inline
+/* We don't want to indent large blocks because it causes unnecessary merge
+ * conflicts */
+#define UNINDENTED_BLOCK_START {
+#define UNINDENTED_BLOCK_END }
+
+static char *
+strsep(char **stringp, const char *delim)
+{
+ char* res = *stringp;
+ while (**stringp) {
+ const char *c;
+ for (c = delim; *c; c++) {
+ if (**stringp == *c) {
+ **stringp++ = 0;
+ return res;
+ }
+ }
+ }
+ return res;
+}
+#else
+#define UNINDENTED_BLOCK_START
+#define UNINDENTED_BLOCK_END
+#endif
+
typedef struct FilterInfo_t {
char *mTag;
android_LogPriority mPri;
@@ -268,6 +297,7 @@ int android_log_addFilterRule(AndroidLogFormat *p_format,
pri = ANDROID_LOG_VERBOSE;
}
+ UNINDENTED_BLOCK_START
char *tagName;
// Presently HAVE_STRNDUP is never defined, so the second case is always taken
@@ -280,11 +310,14 @@ int android_log_addFilterRule(AndroidLogFormat *p_format,
tagName[tagNameLength] = '\0';
#endif /*HAVE_STRNDUP*/
+ UNINDENTED_BLOCK_START
FilterInfo *p_fi = filterinfo_new(tagName, pri);
free(tagName);
p_fi->p_next = p_format->filters;
p_format->filters = p_fi;
+ UNINDENTED_BLOCK_END
+ UNINDENTED_BLOCK_END
}
return 0;
@@ -373,6 +406,7 @@ int android_log_processLogBuffer(struct logger_entry *buf,
return -1;
}
+ UNINDENTED_BLOCK_START
int msgStart = -1;
int msgEnd = -1;
@@ -404,6 +438,7 @@ int android_log_processLogBuffer(struct logger_entry *buf,
entry->messageLen = msgEnd - msgStart;
return 0;
+ UNINDENTED_BLOCK_END
}
/*
@@ -621,11 +656,7 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf,
eventData += 4;
inCount -= 4;
- if (map != NULL) {
- entry->tag = android_lookupEventTag(map, tagIndex);
- } else {
- entry->tag = NULL;
- }
+ entry->tag = NULL;
/*
* If we don't have a map, or didn't find the tag number in the map,
@@ -644,6 +675,7 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf,
/*
* Format the event log data into the buffer.
*/
+ UNINDENTED_BLOCK_START
char* outBuf = messageBuf;
size_t outRemaining = messageBufLen-1; /* leave one for nul byte */
int result;
@@ -687,6 +719,7 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf,
entry->message = messageBuf;
return 0;
+ UNINDENTED_BLOCK_END
}
/**
@@ -737,6 +770,7 @@ char *android_log_formatLogLine (
/*
* Construct a buffer containing the log header and log message.
*/
+ UNINDENTED_BLOCK_START
size_t prefixLen, suffixLen;
switch (p_format->format) {
@@ -807,6 +841,7 @@ char *android_log_formatLogLine (
/* the following code is tragically unreadable */
+ UNINDENTED_BLOCK_START
size_t numLines;
size_t i;
char *p;
@@ -882,6 +917,8 @@ char *android_log_formatLogLine (
}
return ret;
+ UNINDENTED_BLOCK_END
+ UNINDENTED_BLOCK_END
}
/**
@@ -1014,3 +1051,6 @@ void logprint_run_tests()
fprintf(stderr, "tests complete\n");
#endif
}
+
+#undef UNINDENTED_BLOCK_START
+#undef UNINDENTED_BLOCK_END
diff --git a/libutils/RefBase.cpp b/libutils/RefBase.cpp
index f398a82..be0306f 100644
--- a/libutils/RefBase.cpp
+++ b/libutils/RefBase.cpp
@@ -20,7 +20,14 @@
#include <utils/RefBase.h>
#include <utils/Atomic.h>
+#ifdef _MSC_VER
+class CallStack {
+public:
+ CallStack(int x) {}
+};
+#else
#include <utils/CallStack.h>
+#endif
#include <utils/Log.h>
#include <utils/threads.h>
@@ -40,7 +47,7 @@
#define DEBUG_REFS_ENABLED_BY_DEFAULT 0
// whether callstack are collected (significantly slows things down)
-#define DEBUG_REFS_CALLSTACK_ENABLED 1
+#define DEBUG_REFS_CALLSTACK_ENABLED 0
// folder where stack traces are saved when DEBUG_REFS is enabled
// this folder needs to exist and be writable
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index e852d77..255dd23 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -138,17 +138,8 @@ static char* allocFromUTF32(const char32_t* in, size_t len)
// ---------------------------------------------------------------------------
String8::String8()
- : mString(getEmptyString())
-{
-}
-
-String8::String8(StaticLinkage)
: mString(0)
{
- // this constructor is used when we can't rely on the static-initializers
- // having run. In this case we always allocate an empty string. It's less
- // efficient than using getEmptyString(), but we assume it's uncommon.
-
char* data = static_cast<char*>(
SharedBuffer::alloc(sizeof(char))->data());
data[0] = 0;
@@ -324,16 +315,27 @@ status_t String8::appendFormat(const char* fmt, ...)
status_t String8::appendFormatV(const char* fmt, va_list args)
{
int result = NO_ERROR;
+#ifndef _MSC_VER
+ va_list o;
+ va_copy(o, args);
+#endif
int n = vsnprintf(NULL, 0, fmt, args);
if (n != 0) {
size_t oldLength = length();
char* buf = lockBuffer(oldLength + n);
if (buf) {
+#ifdef _MSC_VER
vsnprintf(buf + oldLength, n + 1, fmt, args);
+#else
+ vsnprintf(buf + oldLength, n + 1, fmt, o);
+#endif
} else {
result = NO_MEMORY;
}
}
+#ifndef _MSC_VER
+ va_end(o);
+#endif
return result;
}
diff --git a/libutils/Unicode.cpp b/libutils/Unicode.cpp
index a66e3bb..b8aae5e 100644
--- a/libutils/Unicode.cpp
+++ b/libutils/Unicode.cpp
@@ -576,8 +576,8 @@ void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) {
char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen) {
const uint8_t* const u8end = src + srcLen;
const uint8_t* u8cur = src;
- const uint16_t* const u16end = dst + dstLen;
- char16_t* u16cur = dst;
+ const uint16_t* const u16end = (const uint16_t* const) dst + dstLen;
+ uint16_t* u16cur = (uint16_t*) dst;
while (u8cur < u8end && u16cur < u16end) {
size_t u8len = utf8_codepoint_len(*u8cur);
@@ -593,14 +593,14 @@ char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size
*u16cur++ = (char16_t) ((codepoint >> 10) + 0xD800);
if (u16cur >= u16end) {
// Ooops... not enough room for this surrogate pair.
- return u16cur-1;
+ return (char16_t*) u16cur-1;
}
*u16cur++ = (char16_t) ((codepoint & 0x3FF) + 0xDC00);
}
u8cur += u8len;
}
- return u16cur;
+ return (char16_t*) u16cur;
}
}

View File

@ -1,10 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef BYTESWAP_H_
#define BYTESWAP_H_
#include <libkern/OSByteOrder.h>
#define bswap_16 OSSwapInt16
#endif

View File

@ -1 +0,0 @@
#include "android/log.h"

View File

@ -1,96 +0,0 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBS_UTILS_CONDITION_H
#define _LIBS_UTILS_CONDITION_H
#include <stdint.h>
#include <sys/types.h>
#include <time.h>
#include <utils/Errors.h>
#include <utils/Mutex.h>
#include <utils/Timers.h>
// ---------------------------------------------------------------------------
namespace android {
// ---------------------------------------------------------------------------
/*
* Condition variable class. The implementation is system-dependent.
*
* Condition variables are paired up with mutexes. Lock the mutex,
* call wait(), then either re-wait() if things aren't quite what you want,
* or unlock the mutex and continue. All threads calling wait() must
* use the same mutex for a given Condition.
*/
class Condition {
public:
enum {
PRIVATE = 0,
SHARED = 1
};
enum WakeUpType {
WAKE_UP_ONE = 0,
WAKE_UP_ALL = 1
};
Condition();
Condition(int type);
~Condition();
// Wait on the condition variable. Lock the mutex before calling.
status_t wait(Mutex& mutex);
// same with relative timeout
status_t waitRelative(Mutex& mutex, nsecs_t reltime);
// Signal the condition variable, allowing one thread to continue.
void signal();
// Signal the condition variable, allowing one or all threads to continue.
void signal(WakeUpType type) {
if (type == WAKE_UP_ONE) {
signal();
} else {
broadcast();
}
}
// Signal the condition variable, allowing all threads to continue.
void broadcast();
};
// ---------------------------------------------------------------------------
inline Condition::Condition() {
}
inline Condition::Condition(int type) {
}
inline Condition::~Condition() {
}
inline status_t Condition::wait(Mutex& mutex) {
return OK;
}
inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) {
return OK;
}
inline void Condition::signal() {
}
inline void Condition::broadcast() {
}
// ---------------------------------------------------------------------------
}; // namespace android
// ---------------------------------------------------------------------------
#endif // _LIBS_UTILS_CONDITON_H

View File

@ -1,117 +0,0 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBS_UTILS_MUTEX_H
#define _LIBS_UTILS_MUTEX_H
#include <stdint.h>
#include <sys/types.h>
#include <time.h>
#include <utils/Errors.h>
#ifdef _MSC_VER
#define __attribute__(X)
#endif
// ---------------------------------------------------------------------------
namespace android {
// ---------------------------------------------------------------------------
class Condition;
/*
* Simple mutex class. The implementation is system-dependent.
*
* The mutex must be unlocked by the thread that locked it. They are not
* recursive, i.e. the same thread can't lock it multiple times.
*/
class Mutex {
public:
enum {
PRIVATE = 0,
SHARED = 1
};
Mutex();
Mutex(const char* name);
Mutex(int type, const char* name = NULL);
~Mutex();
// lock or unlock the mutex
status_t lock();
void unlock();
// lock if possible; returns 0 on success, error otherwise
status_t tryLock();
// Manages the mutex automatically. It'll be locked when Autolock is
// constructed and released when Autolock goes out of scope.
class Autolock {
public:
inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); }
inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); }
inline ~Autolock() { mLock.unlock(); }
private:
Mutex& mLock;
};
private:
friend class Condition;
// A mutex cannot be copied
Mutex(const Mutex&);
Mutex& operator = (const Mutex&);
};
// ---------------------------------------------------------------------------
inline Mutex::Mutex() {
}
inline Mutex::Mutex(__attribute__((unused)) const char* name) {
}
inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) {
}
inline Mutex::~Mutex() {
}
inline status_t Mutex::lock() {
return OK;
}
inline void Mutex::unlock() {
}
inline status_t Mutex::tryLock() {
return OK;
}
// ---------------------------------------------------------------------------
/*
* Automatic mutex. Declare one of these at the top of a function.
* When the function returns, it will go out of scope, and release the
* mutex.
*/
typedef Mutex::Autolock AutoMutex;
// ---------------------------------------------------------------------------
}; // namespace android
// ---------------------------------------------------------------------------
#ifdef _MSC_VER
#undef __attribute__
#endif
#endif // _LIBS_UTILS_MUTEX_H

View File

@ -1,4 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#include "android/log.h"

View File

@ -1,9 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef INET_H_
#define INET_H_
#include <netinet/in.h>
#endif

View File

@ -1,10 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef BYTESWAP_H_
#define BYTESWAP_H_
#include <stdlib.h>
#define bswap_16 _byteswap_ushort
#endif

View File

@ -1,39 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef IN_H_
#define IN_H_
#include <stdint.h>
#if defined(_M_IX86)
static uint32_t
ntohl(uint32_t x)
{
return x << 24 | (x << 8 & 0xff0000) | (x >> 8 & 0xff00) | x >> 24;
}
static uint16_t
ntohs(uint16_t x)
{
return x << 8 | x >> 8;
}
static uint32_t
htonl(uint32_t x)
{
return x << 24 | (x << 8 & 0xff0000) | (x >> 8 & 0xff00) | x >> 24;
}
static uint16_t
htons(uint16_t x)
{
return x << 8 | x >> 8;
}
#else
#error Unsupported architecture
#endif
#endif

View File

@ -1 +0,0 @@
// Intentionally left blank

View File

@ -1 +0,0 @@
// Intentionally left blank

View File

@ -1 +0,0 @@
// Intentionally left blank

View File

@ -1,9 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef TIME_H_
#define TIME_H_
#include <time.h>
#endif

View File

@ -1 +0,0 @@
// Intentionally left blank

View File

@ -1,51 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef ATOMIC_H_
#define ATOMIC_H_
#include <stdint.h>
// This implements the atomic primatives without any atomicity guarantees. This
// makes the totally unsafe. However we're only using the demuxer in a single
// thread.
static inline int32_t
android_atomic_dec(volatile int32_t* aValue)
{
return (*aValue)--;
}
static inline int32_t
android_atomic_inc(volatile int32_t* aValue)
{
return (*aValue)++;
}
static inline int32_t
android_atomic_or(int32_t aModifier, volatile int32_t* aValue)
{
int32_t ret = *aValue;
*aValue |= aModifier;
return ret;
}
static inline int32_t
android_atomic_add(int32_t aModifier, volatile int32_t* aValue)
{
int32_t ret = *aValue;
*aValue += aModifier;
return ret;
}
static inline int32_t
android_atomic_cmpxchg(int32_t aOld, int32_t aNew, volatile int32_t* aValue)
{
if (*aValue == aOld)
{
return *aValue = aNew;
}
return aOld;
}
#endif

View File

@ -1,16 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef A_MESSAGE_H_
#define A_MESSAGE_H_
namespace android {
struct AMessage : public RefBase {
public:
void post() {}
};
}
#endif

View File

@ -1,10 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef ATOMICS_H_
#define ATOMICS_H_
#define __atomic_dec android_atomic_dec
#define __atomic_inc android_atomic_inc
#endif

View File

@ -1,14 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef GRAPHIC_BUFFER_H_
#define GRAPHIC_BUFFER_H_
namespace android {
class GraphicBuffer : public RefBase {
};
}
#endif

View File

@ -1,5 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#include <utils/Condition.h>
#include <utils/Mutex.h>

View File

@ -19,6 +19,7 @@
#include <sys/cdefs.h>
#include <stddef.h>
#include <sys/system_properties.h>
#ifdef __cplusplus
extern "C" {

View File

@ -25,16 +25,6 @@
// supports O_APPEND. These calls have mutex-protected data structures
// and so are NOT reentrant. Do not use LOG in a signal handler.
//
/*
* This is the local tag used for the following simplified
* logging macros. You can change this preprocessor definition
* before using the other macros to change the tag.
*/
#ifndef LOG_TAG
#define LOG_TAG NULL
#endif
#ifndef _LIBS_LOG_LOG_H
#define _LIBS_LOG_LOG_H
@ -50,10 +40,6 @@
#include <log/uio.h>
#include <log/logd.h>
#ifdef _MSC_VER
#define __builtin_expect(X, Y) (X)
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -73,6 +59,15 @@ extern "C" {
#endif
#endif
/*
* This is the local tag used for the following simplified
* logging macros. You can change this preprocessor definition
* before using the other macros to change the tag.
*/
#ifndef LOG_TAG
#define LOG_TAG NULL
#endif
// ---------------------------------------------------------------------
/*
@ -503,11 +498,11 @@ typedef enum {
* The stuff in the rest of this file should not be used directly.
*/
#define android_printLog(prio, tag, ...) \
__android_log_print(prio, tag, __VA_ARGS__)
#define android_printLog(prio, tag, fmt...) \
__android_log_print(prio, tag, fmt)
#define android_vprintLog(prio, cond, tag, ...) \
__android_log_vprint(prio, tag, __VA_ARGS__)
#define android_vprintLog(prio, cond, tag, fmt...) \
__android_log_vprint(prio, tag, fmt)
/* XXX Macros to work around syntax errors in places where format string
* arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
@ -524,9 +519,9 @@ typedef enum {
*/
#define __android_rest(first, ...) , ## __VA_ARGS__
#define android_printAssert(cond, tag, ...) \
#define android_printAssert(cond, tag, fmt...) \
__android_log_assert(cond, tag, \
__android_second(0, ## __VA_ARGS__, NULL) __android_rest(__VA_ARGS__))
__android_second(0, ## fmt, NULL) __android_rest(fmt))
#define android_writeLog(prio, tag, text) \
__android_log_write(prio, tag, text)

View File

@ -20,6 +20,7 @@
#include <log/log.h>
#include <log/logger.h>
#include <log/event_tag_map.h>
#include <pthread.h>
#ifdef __cplusplus
extern "C" {

View File

@ -138,18 +138,6 @@ inline void Condition::broadcast() {
pthread_cond_broadcast(&mCond);
}
#else
inline Condition::Condition() {}
inline Condition::Condition(int type) {}
inline Condition::~Condition() {}
inline status_t Condition::wait(Mutex& mutex) { return OK; }
inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) {
return OK;
}
inline void Condition::signal() {}
inline void Condition::broadcast() {}
#endif // HAVE_PTHREADS
// ---------------------------------------------------------------------------

View File

@ -56,11 +56,9 @@ protected:
inline void setVal(const T& val) { mVal = val; }
inline void setPrev(_Node* ptr) { mpPrev = ptr; }
inline void setNext(_Node* ptr) { mpNext = ptr; }
#ifndef _MSC_VER
private:
friend class List;
friend class _ListIterator;
#endif
T mVal;
_Node* mpPrev;
_Node* mpNext;

View File

@ -118,17 +118,6 @@ inline status_t Mutex::tryLock() {
return -pthread_mutex_trylock(&mMutex);
}
#else
inline Mutex::Mutex() {}
inline Mutex::Mutex(const char* name) {}
inline Mutex::Mutex(int type, const char* name) {}
inline Mutex::~Mutex() {}
inline status_t Mutex::lock() { return OK; }
inline void Mutex::unlock() {}
inline status_t Mutex::tryLock() { return OK; }
inline void Mutex::_init() {}
#endif // HAVE_PTHREADS
// ---------------------------------------------------------------------------

View File

@ -27,10 +27,6 @@
#include <utils/StrongPointer.h>
#include <utils/TypeHelpers.h>
#ifdef _MSC_VER
#define __attribute__(X)
#endif
// ---------------------------------------------------------------------------
namespace android {
@ -545,10 +541,6 @@ void move_backward_type(wp<TYPE>* d, wp<TYPE> const* s, size_t n) {
}; // namespace android
#ifdef _MSC_VER
#undef __attribute__
#endif
// ---------------------------------------------------------------------------
#endif // ANDROID_REF_BASE_H

View File

@ -48,6 +48,7 @@ public:
virtual ~SortedVector();
/*! copy operator */
const SortedVector<TYPE>& operator = (const SortedVector<TYPE>& rhs) const;
SortedVector<TYPE>& operator = (const SortedVector<TYPE>& rhs);
/*
@ -166,6 +167,12 @@ SortedVector<TYPE>& SortedVector<TYPE>::operator = (const SortedVector<TYPE>& rh
return *this;
}
template<class TYPE> inline
const SortedVector<TYPE>& SortedVector<TYPE>::operator = (const SortedVector<TYPE>& rhs) const {
SortedVectorImpl::operator = (rhs);
return *this;
}
template<class TYPE> inline
const TYPE* SortedVector<TYPE>::array() const {
return static_cast<const TYPE *>(arrayImpl());

View File

@ -27,10 +27,6 @@
// ---------------------------------------------------------------------------
#ifdef _MSC_VER
#define __attribute__(X)
#endif
namespace android {
class String16;
@ -394,10 +390,6 @@ inline String8::operator const char*() const
} // namespace android
#ifdef _MSC_VER
#undef __attribute__
#endif
// ---------------------------------------------------------------------------
#endif // ANDROID_STRING8_H

View File

@ -201,7 +201,7 @@ void move_backward_type(TYPE* d, const TYPE* s, size_t n = 1) {
if ((traits<TYPE>::has_trivial_dtor && traits<TYPE>::has_trivial_copy)
|| traits<TYPE>::has_trivial_move)
{
memmove((void*)d,(void*)s,n*sizeof(TYPE));
memmove(d,s,n*sizeof(TYPE));
} else {
while (n--) {
if (!traits<TYPE>::has_trivial_copy) {

View File

@ -22,6 +22,9 @@
extern "C" {
typedef uint32_t char32_t;
typedef uint16_t char16_t;
// Standard string functions on char16_t strings.
int strcmp16(const char16_t *, const char16_t *);
int strncmp16(const char16_t *s1, const char16_t *s2, size_t n);

View File

@ -55,8 +55,10 @@ public:
virtual ~Vector();
/*! copy operator */
const Vector<TYPE>& operator = (const Vector<TYPE>& rhs) const;
Vector<TYPE>& operator = (const Vector<TYPE>& rhs);
const Vector<TYPE>& operator = (const SortedVector<TYPE>& rhs) const;
Vector<TYPE>& operator = (const SortedVector<TYPE>& rhs);
/*
@ -169,12 +171,8 @@ public:
typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs);
typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state);
inline status_t sort(compar_t cmp) {
return VectorImpl::sort((VectorImpl::compar_t)cmp);
}
inline status_t sort(compar_r_t cmp, void* state) {
return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state);
}
inline status_t sort(compar_t cmp);
inline status_t sort(compar_r_t cmp, void* state);
// for debugging only
inline size_t getItemSize() const { return itemSize(); }
@ -248,12 +246,24 @@ Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) {
return *this;
}
template<class TYPE> inline
const Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const {
VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
return *this;
}
template<class TYPE> inline
Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) {
VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
return *this;
}
template<class TYPE> inline
const Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) const {
VectorImpl::operator = (rhs);
return *this;
}
template<class TYPE> inline
const TYPE* Vector<TYPE>::array() const {
return static_cast<const TYPE *>(arrayImpl());
@ -363,6 +373,16 @@ ssize_t Vector<TYPE>::removeItemsAt(size_t index, size_t count) {
return VectorImpl::removeItemsAt(index, count);
}
template<class TYPE> inline
status_t Vector<TYPE>::sort(Vector<TYPE>::compar_t cmp) {
return VectorImpl::sort((VectorImpl::compar_t)cmp);
}
template<class TYPE> inline
status_t Vector<TYPE>::sort(Vector<TYPE>::compar_r_t cmp, void* state) {
return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state);
}
// ---------------------------------------------------------------------------
template<class TYPE>

View File

@ -31,34 +31,6 @@
#include <pthread.h>
#endif
#ifdef _MSC_VER
#include <io.h>
#include <process.h>
#include <nspr/prprf.h>
#define snprintf PR_snprintf
/* We don't want to indent large blocks because it causes unnecessary merge
* conflicts */
#define UNINDENTED_BLOCK_START {
#define UNINDENTED_BLOCK_END }
#else
#define UNINDENTED_BLOCK_START
#define UNINDENTED_BLOCK_END
#endif
#ifdef _MSC_VER
#include <io.h>
#include <process.h>
/* We don't want to indent large blocks because it causes unnecessary merge
* conflicts */
#define UNINDENTED_BLOCK_START {
#define UNINDENTED_BLOCK_END }
#else
#define UNINDENTED_BLOCK_START
#define UNINDENTED_BLOCK_END
#endif
#define kMaxTagLen 16 /* from the long-dead utils/Log.cpp */
#define kTagSetSize 16 /* arbitrary */
@ -219,7 +191,6 @@ static void configureInitialState(const char* pathName, LogState* logState)
/*
* This is based on the the long-dead utils/Log.cpp code.
*/
UNINDENTED_BLOCK_START
const char* tags = getenv("ANDROID_LOG_TAGS");
TRACE("Found ANDROID_LOG_TAGS='%s'\n", tags);
if (tags != NULL) {
@ -293,12 +264,11 @@ static void configureInitialState(const char* pathName, LogState* logState)
}
}
}
UNINDENTED_BLOCK_END
/*
* Taken from the long-dead utils/Log.cpp
*/
UNINDENTED_BLOCK_START
const char* fstr = getenv("ANDROID_PRINTF_LOG");
LogFormat format;
if (fstr == NULL) {
@ -323,7 +293,6 @@ static void configureInitialState(const char* pathName, LogState* logState)
}
logState->outputFormat = format;
UNINDENTED_BLOCK_END
}
/*
@ -352,7 +321,7 @@ static const char* getPriorityString(int priority)
*/
static ssize_t fake_writev(int fd, const struct iovec *iov, int iovcnt) {
int result = 0;
const struct iovec* end = iov + iovcnt;
struct iovec* end = iov + iovcnt;
for (; iov < end; iov++) {
int w = write(fd, iov->iov_base, iov->iov_len);
if (w != iov->iov_len) {
@ -385,11 +354,7 @@ static void showLog(LogState *state,
char prefixBuf[128], suffixBuf[128];
char priChar;
time_t when;
#ifdef _MSC_VER
int pid, tid;
#else
pid_t pid, tid;
#endif
TRACE("LOG %d: %s %s", logPrio, tag, msg);
@ -417,7 +382,6 @@ static void showLog(LogState *state,
/*
* Construct a buffer containing the log header and log message.
*/
UNINDENTED_BLOCK_START
size_t prefixLen, suffixLen;
switch (state->outputFormat) {
@ -467,7 +431,6 @@ static void showLog(LogState *state,
/*
* Figure out how many lines there will be.
*/
UNINDENTED_BLOCK_START
const char* end = msg + strlen(msg);
size_t numLines = 0;
const char* p = msg;
@ -480,8 +443,7 @@ static void showLog(LogState *state,
* Create an array of iovecs large enough to write all of
* the lines with a prefix and a suffix.
*/
UNINDENTED_BLOCK_START
#define INLINE_VECS 6
const size_t INLINE_VECS = 6;
const size_t MAX_LINES = ((size_t)~0)/(3*sizeof(struct iovec*));
struct iovec stackVec[INLINE_VECS];
struct iovec* vec = stackVec;
@ -505,7 +467,6 @@ static void showLog(LogState *state,
* Fill in the iovec pointers.
*/
p = msg;
UNINDENTED_BLOCK_START
struct iovec* v = vec;
int totalLen = 0;
while (numLines > 0 && p < end) {
@ -515,7 +476,6 @@ static void showLog(LogState *state,
totalLen += prefixLen;
v++;
}
UNINDENTED_BLOCK_START
const char* start = p;
while (p < end && *p != '\n') p++;
if ((p-start) > 0) {
@ -532,7 +492,6 @@ static void showLog(LogState *state,
v++;
}
numLines -= 1;
UNINDENTED_BLOCK_END
}
/*
@ -570,10 +529,6 @@ static void showLog(LogState *state,
/* if we allocated storage for the iovecs, free it */
if (vec != stackVec)
free(vec);
UNINDENTED_BLOCK_END
UNINDENTED_BLOCK_END
UNINDENTED_BLOCK_END
UNINDENTED_BLOCK_END
}
@ -612,7 +567,6 @@ static ssize_t logWritev(int fd, const struct iovec* vector, int count)
}
/* pull out the three fields */
UNINDENTED_BLOCK_START
int logPrio = *(const char*)vector[0].iov_base;
const char* tag = (const char*) vector[1].iov_base;
const char* msg = (const char*) vector[2].iov_base;
@ -636,7 +590,6 @@ static ssize_t logWritev(int fd, const struct iovec* vector, int count)
} else {
//TRACE("+++ NOLOG(%d): %s %s", logPrio, tag, msg);
}
UNINDENTED_BLOCK_END
bail:
unlock();
@ -730,6 +683,3 @@ ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count)
/* Assume that open() was called first. */
return redirectWritev(fd, vector, count);
}
#undef UNINDENTED_BLOCK_START
#undef UNINDENTED_BLOCK_END

View File

@ -33,19 +33,7 @@
#define LOG_BUF_SIZE 1024
#ifdef _MSC_VER
#include <nspr/prprf.h>
#define snprintf PR_snprintf
#define __builtin_trap abort
static int W_OK = 0;
static int access(char* c, int i) { return -1; }
#endif
#if FAKE_LOG_DEVICE
int fakeLogOpen(const char *pathName, int flags);
ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count);
int fakeLogClose(int fd);
// This will be defined when building for the host.
#define log_open(pathname, flags) fakeLogOpen(pathname, flags)
#define log_writev(filedes, vector, count) fakeLogWritev(filedes, vector, count)
@ -270,11 +258,7 @@ void __android_log_assert(const char *cond, const char *tag,
__android_log_write(ANDROID_LOG_FATAL, tag, buf);
#ifdef _MSC_VER
abort();
#else
__builtin_trap(); /* trap so we have a chance to debug the situation */
#endif
}
int __android_log_bwrite(int32_t tag, const void *payload, size_t len)

View File

@ -29,35 +29,6 @@
#include <log/logd.h>
#include <log/logprint.h>
#ifdef _MSC_VER
#include <nspr/prprf.h>
#define snprintf PR_snprintf
#define inline
/* We don't want to indent large blocks because it causes unnecessary merge
* conflicts */
#define UNINDENTED_BLOCK_START {
#define UNINDENTED_BLOCK_END }
static char *
strsep(char **stringp, const char *delim)
{
char* res = *stringp;
while (**stringp) {
const char *c;
for (c = delim; *c; c++) {
if (**stringp == *c) {
**stringp++ = 0;
return res;
}
}
}
return res;
}
#else
#define UNINDENTED_BLOCK_START
#define UNINDENTED_BLOCK_END
#endif
typedef struct FilterInfo_t {
char *mTag;
android_LogPriority mPri;
@ -297,7 +268,6 @@ int android_log_addFilterRule(AndroidLogFormat *p_format,
pri = ANDROID_LOG_VERBOSE;
}
UNINDENTED_BLOCK_START
char *tagName;
// Presently HAVE_STRNDUP is never defined, so the second case is always taken
@ -310,14 +280,11 @@ int android_log_addFilterRule(AndroidLogFormat *p_format,
tagName[tagNameLength] = '\0';
#endif /*HAVE_STRNDUP*/
UNINDENTED_BLOCK_START
FilterInfo *p_fi = filterinfo_new(tagName, pri);
free(tagName);
p_fi->p_next = p_format->filters;
p_format->filters = p_fi;
UNINDENTED_BLOCK_END
UNINDENTED_BLOCK_END
}
return 0;
@ -406,7 +373,6 @@ int android_log_processLogBuffer(struct logger_entry *buf,
return -1;
}
UNINDENTED_BLOCK_START
int msgStart = -1;
int msgEnd = -1;
@ -438,7 +404,6 @@ int android_log_processLogBuffer(struct logger_entry *buf,
entry->messageLen = msgEnd - msgStart;
return 0;
UNINDENTED_BLOCK_END
}
/*
@ -656,7 +621,11 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf,
eventData += 4;
inCount -= 4;
entry->tag = NULL;
if (map != NULL) {
entry->tag = android_lookupEventTag(map, tagIndex);
} else {
entry->tag = NULL;
}
/*
* If we don't have a map, or didn't find the tag number in the map,
@ -675,7 +644,6 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf,
/*
* Format the event log data into the buffer.
*/
UNINDENTED_BLOCK_START
char* outBuf = messageBuf;
size_t outRemaining = messageBufLen-1; /* leave one for nul byte */
int result;
@ -719,7 +687,6 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf,
entry->message = messageBuf;
return 0;
UNINDENTED_BLOCK_END
}
/**
@ -770,7 +737,6 @@ char *android_log_formatLogLine (
/*
* Construct a buffer containing the log header and log message.
*/
UNINDENTED_BLOCK_START
size_t prefixLen, suffixLen;
switch (p_format->format) {
@ -841,7 +807,6 @@ char *android_log_formatLogLine (
/* the following code is tragically unreadable */
UNINDENTED_BLOCK_START
size_t numLines;
size_t i;
char *p;
@ -917,8 +882,6 @@ char *android_log_formatLogLine (
}
return ret;
UNINDENTED_BLOCK_END
UNINDENTED_BLOCK_END
}
/**
@ -1051,6 +1014,3 @@ void logprint_run_tests()
fprintf(stderr, "tests complete\n");
#endif
}
#undef UNINDENTED_BLOCK_START
#undef UNINDENTED_BLOCK_END

View File

@ -20,14 +20,7 @@
#include <utils/RefBase.h>
#include <utils/Atomic.h>
#ifdef _MSC_VER
class CallStack {
public:
CallStack(int x) {}
};
#else
#include <utils/CallStack.h>
#endif
#include <utils/Log.h>
#include <utils/threads.h>
@ -47,7 +40,7 @@ public:
#define DEBUG_REFS_ENABLED_BY_DEFAULT 0
// whether callstack are collected (significantly slows things down)
#define DEBUG_REFS_CALLSTACK_ENABLED 0
#define DEBUG_REFS_CALLSTACK_ENABLED 1
// folder where stack traces are saved when DEBUG_REFS is enabled
// this folder needs to exist and be writable

View File

@ -138,8 +138,17 @@ static char* allocFromUTF32(const char32_t* in, size_t len)
// ---------------------------------------------------------------------------
String8::String8()
: mString(getEmptyString())
{
}
String8::String8(StaticLinkage)
: mString(0)
{
// this constructor is used when we can't rely on the static-initializers
// having run. In this case we always allocate an empty string. It's less
// efficient than using getEmptyString(), but we assume it's uncommon.
char* data = static_cast<char*>(
SharedBuffer::alloc(sizeof(char))->data());
data[0] = 0;
@ -315,27 +324,16 @@ status_t String8::appendFormat(const char* fmt, ...)
status_t String8::appendFormatV(const char* fmt, va_list args)
{
int result = NO_ERROR;
#ifndef _MSC_VER
va_list o;
va_copy(o, args);
#endif
int n = vsnprintf(NULL, 0, fmt, args);
if (n != 0) {
size_t oldLength = length();
char* buf = lockBuffer(oldLength + n);
if (buf) {
#ifdef _MSC_VER
vsnprintf(buf + oldLength, n + 1, fmt, args);
#else
vsnprintf(buf + oldLength, n + 1, fmt, o);
#endif
} else {
result = NO_MEMORY;
}
}
#ifndef _MSC_VER
va_end(o);
#endif
return result;
}

View File

@ -576,8 +576,8 @@ void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) {
char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen) {
const uint8_t* const u8end = src + srcLen;
const uint8_t* u8cur = src;
const uint16_t* const u16end = (const uint16_t* const) dst + dstLen;
uint16_t* u16cur = (uint16_t*) dst;
const uint16_t* const u16end = dst + dstLen;
char16_t* u16cur = dst;
while (u8cur < u8end && u16cur < u16end) {
size_t u8len = utf8_codepoint_len(*u8cur);
@ -593,14 +593,14 @@ char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size
*u16cur++ = (char16_t) ((codepoint >> 10) + 0xD800);
if (u16cur >= u16end) {
// Ooops... not enough room for this surrogate pair.
return (char16_t*) u16cur-1;
return u16cur-1;
}
*u16cur++ = (char16_t) ((codepoint & 0x3FF) + 0xDC00);
}
u8cur += u8len;
}
return (char16_t*) u16cur;
return u16cur;
}
}

View File

@ -1,13 +0,0 @@
#!/bin/bash -e
cd `dirname "$0"`
rm -fR patches
for DIR in `find android/ -name .git`
do
DIR=`dirname ${DIR}`
DST=patches/${DIR:8}
echo ${DST}
mkdir -p `dirname ${DST}`
cp -a ${DIR:8} `dirname ${DIR}`
(cd ${DIR} && git diff) > ${DST}.patch
(cd ${DIR} && git rev-parse HEAD) > ${DST}.tag
done