summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/patches
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /media/libstagefright/patches
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'media/libstagefright/patches')
-rw-r--r--media/libstagefright/patches/frameworks/av.patch1192
-rw-r--r--media/libstagefright/patches/system/core.patch1387
2 files changed, 2579 insertions, 0 deletions
diff --git a/media/libstagefright/patches/frameworks/av.patch b/media/libstagefright/patches/frameworks/av.patch
new file mode 100644
index 000000000..22fb6c580
--- /dev/null
+++ b/media/libstagefright/patches/frameworks/av.patch
@@ -0,0 +1,1192 @@
+diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h
+index 742bc0e..f6b30b0 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 {
++namespace stagefright {
+
+-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,13 +91,10 @@ protected:
+ virtual ~DataSource() {}
+
+ private:
+- static Mutex gSnifferMutex;
+- static List<SnifferFunc> gSniffers;
+-
+ DataSource(const DataSource &);
+ DataSource &operator=(const DataSource &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // DATA_SOURCE_H_
+diff --git a/include/media/stagefright/MediaBuffer.h b/include/media/stagefright/MediaBuffer.h
+index 3d79596..4172739 100644
+--- a/include/media/stagefright/MediaBuffer.h
++++ b/include/media/stagefright/MediaBuffer.h
+@@ -23,7 +23,7 @@
+ #include <utils/Errors.h>
+ #include <utils/RefBase.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct ABuffer;
+ class GraphicBuffer;
+@@ -118,6 +118,6 @@ private:
+ MediaBuffer &operator=(const MediaBuffer &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // MEDIA_BUFFER_H_
+diff --git a/include/media/stagefright/MediaBufferGroup.h b/include/media/stagefright/MediaBufferGroup.h
+index 0488292..4a51351 100644
+--- a/include/media/stagefright/MediaBufferGroup.h
++++ b/include/media/stagefright/MediaBufferGroup.h
+@@ -22,7 +22,7 @@
+ #include <utils/Errors.h>
+ #include <utils/threads.h>
+
+-namespace android {
++namespace stagefright {
+
+ class MediaBuffer;
+ class MetaData;
+@@ -53,6 +53,6 @@ private:
+ MediaBufferGroup &operator=(const MediaBufferGroup &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // MEDIA_BUFFER_GROUP_H_
+diff --git a/include/media/stagefright/MediaDefs.h b/include/media/stagefright/MediaDefs.h
+index 85693d4..9897caf 100644
+--- a/include/media/stagefright/MediaDefs.h
++++ b/include/media/stagefright/MediaDefs.h
+@@ -18,7 +18,7 @@
+
+ #define MEDIA_DEFS_H_
+
+-namespace android {
++namespace stagefright {
+
+ extern const char *MEDIA_MIMETYPE_IMAGE_JPEG;
+
+@@ -58,6 +58,6 @@ extern const char *MEDIA_MIMETYPE_CONTAINER_WVM;
+ extern const char *MEDIA_MIMETYPE_TEXT_3GPP;
+ extern const char *MEDIA_MIMETYPE_TEXT_SUBRIP;
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // MEDIA_DEFS_H_
+diff --git a/include/media/stagefright/MediaErrors.h b/include/media/stagefright/MediaErrors.h
+index 686f286..df2c1a5 100644
+--- a/include/media/stagefright/MediaErrors.h
++++ b/include/media/stagefright/MediaErrors.h
+@@ -20,52 +20,50 @@
+
+ #include <utils/Errors.h>
+
+-namespace android {
++namespace stagefright {
+
+-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
++} // namespace stagefright
+
+ #endif // MEDIA_ERRORS_H_
+diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h
+index 3076a96..96d9ee1 100644
+--- a/include/media/stagefright/MediaExtractor.h
++++ b/include/media/stagefright/MediaExtractor.h
+@@ -20,7 +20,7 @@
+
+ #include <utils/RefBase.h>
+
+-namespace android {
++namespace stagefright {
+
+ class DataSource;
+ class MediaSource;
+@@ -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) {
+@@ -77,6 +77,6 @@ private:
+ MediaExtractor &operator=(const MediaExtractor &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // MEDIA_EXTRACTOR_H_
+diff --git a/include/media/stagefright/MediaSource.h b/include/media/stagefright/MediaSource.h
+index 3818e63..9aa6669 100644
+--- a/include/media/stagefright/MediaSource.h
++++ b/include/media/stagefright/MediaSource.h
+@@ -24,7 +24,7 @@
+ #include <utils/RefBase.h>
+ #include <utils/Vector.h>
+
+-namespace android {
++namespace stagefright {
+
+ class MediaBuffer;
+ class MetaData;
+@@ -117,6 +117,6 @@ private:
+ MediaSource &operator=(const MediaSource &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // MEDIA_SOURCE_H_
+diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
+index de3fc36..30b40c8 100644
+--- a/include/media/stagefright/MetaData.h
++++ b/include/media/stagefright/MetaData.h
+@@ -26,7 +26,7 @@
+ #include <utils/KeyedVector.h>
+ #include <utils/String8.h>
+
+-namespace android {
++namespace stagefright {
+
+ // The following keys map to int32_t data unless indicated otherwise.
+ enum {
+@@ -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 bits)
+ kKeyFrameRate = 'frmR', // int32_t (video frame rate fps)
+ kKeyBitRate = 'brte', // int32_t (bps)
+ kKeyESDS = 'esds', // raw data
+@@ -266,6 +267,6 @@ private:
+ // MetaData &operator=(const MetaData &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // META_DATA_H_
+diff --git a/include/media/stagefright/Utils.h b/include/media/stagefright/Utils.h
+index c24f612..bd70252 100644
+--- a/include/media/stagefright/Utils.h
++++ b/include/media/stagefright/Utils.h
+@@ -25,10 +25,10 @@
+ #include <system/audio.h>
+ #include <media/MediaPlayerInterface.h>
+
+-namespace android {
++namespace stagefright {
+
+ #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
++} // namespace stagefright
+
+ #endif // UTILS_H_
+diff --git a/include/media/stagefright/foundation/AAtomizer.h b/include/media/stagefright/foundation/AAtomizer.h
+index 5f3a678..c20ea07 100644
+--- a/include/media/stagefright/foundation/AAtomizer.h
++++ b/include/media/stagefright/foundation/AAtomizer.h
+@@ -26,7 +26,7 @@
+ #include <utils/Vector.h>
+ #include <utils/threads.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct AAtomizer {
+ static const char *Atomize(const char *name);
+@@ -46,6 +46,6 @@ private:
+ DISALLOW_EVIL_CONSTRUCTORS(AAtomizer);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // A_ATOMIZER_H_
+diff --git a/include/media/stagefright/foundation/ABitReader.h b/include/media/stagefright/foundation/ABitReader.h
+index 5510b12..589e5fe 100644
+--- a/include/media/stagefright/foundation/ABitReader.h
++++ b/include/media/stagefright/foundation/ABitReader.h
+@@ -23,7 +23,7 @@
+ #include <sys/types.h>
+ #include <stdint.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct ABitReader {
+ ABitReader(const uint8_t *data, size_t size);
+@@ -49,6 +49,6 @@ private:
+ DISALLOW_EVIL_CONSTRUCTORS(ABitReader);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // A_BIT_READER_H_
+diff --git a/include/media/stagefright/foundation/ABuffer.h b/include/media/stagefright/foundation/ABuffer.h
+index 28f0aed..4fa908e 100644
+--- a/include/media/stagefright/foundation/ABuffer.h
++++ b/include/media/stagefright/foundation/ABuffer.h
+@@ -24,7 +24,7 @@
+ #include <media/stagefright/foundation/ABase.h>
+ #include <utils/RefBase.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct AMessage;
+
+@@ -66,6 +66,6 @@ private:
+ DISALLOW_EVIL_CONSTRUCTORS(ABuffer);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // A_BUFFER_H_
+diff --git a/include/media/stagefright/foundation/ADebug.h b/include/media/stagefright/foundation/ADebug.h
+index 450dcfe..a58d951 100644
+--- a/include/media/stagefright/foundation/ADebug.h
++++ b/include/media/stagefright/foundation/ADebug.h
+@@ -24,7 +24,7 @@
+ #include <media/stagefright/foundation/AString.h>
+ #include <utils/Log.h>
+
+-namespace android {
++namespace stagefright {
+
+ #define LITERAL_TO_STRING_INTERNAL(x) #x
+ #define LITERAL_TO_STRING(x) LITERAL_TO_STRING_INTERNAL(x)
+@@ -80,7 +80,7 @@ MAKE_COMPARATOR(GT,>)
+ __FILE__ ":" LITERAL_TO_STRING(__LINE__) \
+ " Should not be here.");
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // A_DEBUG_H_
+
+diff --git a/include/media/stagefright/foundation/AHandler.h b/include/media/stagefright/foundation/AHandler.h
+index b008b54..5a5ecc2 100644
+--- a/include/media/stagefright/foundation/AHandler.h
++++ b/include/media/stagefright/foundation/AHandler.h
+@@ -21,7 +21,7 @@
+ #include <media/stagefright/foundation/ALooper.h>
+ #include <utils/RefBase.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct AMessage;
+
+@@ -51,6 +51,6 @@ private:
+ DISALLOW_EVIL_CONSTRUCTORS(AHandler);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // A_HANDLER_H_
+diff --git a/include/media/stagefright/foundation/AString.h b/include/media/stagefright/foundation/AString.h
+index 0f8f1e1..8f97ed4 100644
+--- a/include/media/stagefright/foundation/AString.h
++++ b/include/media/stagefright/foundation/AString.h
+@@ -20,7 +20,7 @@
+
+ #include <sys/types.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct AString {
+ AString();
+@@ -89,7 +89,7 @@ private:
+
+ AString StringPrintf(const char *format, ...);
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // A_STRING_H_
+
+diff --git a/include/media/stagefright/foundation/hexdump.h b/include/media/stagefright/foundation/hexdump.h
+index 8360c5a..18172f7 100644
+--- a/include/media/stagefright/foundation/hexdump.h
++++ b/include/media/stagefright/foundation/hexdump.h
+@@ -20,7 +20,7 @@
+
+ #include <sys/types.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct AString;
+
+@@ -28,6 +28,6 @@ void hexdump(
+ const void *_data, size_t size,
+ size_t indent = 0, AString *appendTo = NULL);
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // HEXDUMP_H_
+diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp
+index fc6fd9c..c65a69e 100644
+--- a/media/libstagefright/DataSource.cpp
++++ b/media/libstagefright/DataSource.cpp
+@@ -20,30 +20,12 @@
+ #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 {
++namespace stagefright {
+
+ bool DataSource::getUInt16(off64_t offset, uint16_t *x) {
+ *x = 0;
+@@ -105,6 +87,8 @@ status_t DataSource::getSize(off64_t *size) {
+
+ ////////////////////////////////////////////////////////////////////////////////
+
++#if 0
++
+ Mutex DataSource::gSnifferMutex;
+ List<DataSource::SnifferFunc> DataSource::gSniffers;
+
+@@ -226,8 +210,10 @@ sp<DataSource> DataSource::CreateFromURI(
+ return source;
+ }
+
++#endif
++
+ String8 DataSource::getMIMEType() const {
+ return String8("application/octet-stream");
+ }
+
+-} // namespace android
++} // namespace stagefright
+diff --git a/media/libstagefright/ESDS.cpp b/media/libstagefright/ESDS.cpp
+index 4a0c35c..ccf60e3 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>
+
+@@ -22,7 +23,7 @@
+
+ #include <string.h>
+
+-namespace android {
++namespace stagefright {
+
+ ESDS::ESDS(const void *data, size_t size)
+ : mData(new uint8_t[size]),
+@@ -223,5 +224,6 @@ status_t ESDS::parseDecoderConfigDescriptor(size_t offset, size_t size) {
+ return OK;
+ }
+
+-} // namespace android
++} // namespace stagefright
+
++#undef LOG_TAG
+diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
+index ad985ee..71a0613 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>
+
+@@ -38,7 +39,7 @@
+ #include <media/stagefright/MetaData.h>
+ #include <utils/String8.h>
+
+-namespace android {
++namespace stagefright {
+
+ class MPEG4Source : public MediaSource {
+ public:
+@@ -726,6 +727,11 @@ static bool underMetaDataPath(const Vector<uint32_t> &path) {
+ static void convertTimeToDate(int64_t time_1904, String8 *s) {
+ time_t time_1970 = time_1904 - (((66 * 365 + 17) * 24) * 3600);
+
++ if (time_1970 < 0) {
++ s->clear();
++ return;
++ }
++
+ char tmp[32];
+ strftime(tmp, sizeof(tmp), "%Y%m%dT%H%M%S.000Z", gmtime(&time_1970));
+
+@@ -1248,6 +1254,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;
+@@ -1652,8 +1659,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
+
+ String8 s;
+ convertTimeToDate(creationTime, &s);
+-
+- mFileMetaData->setCString(kKeyDate, s.string());
++ if (s.length()) {
++ mFileMetaData->setCString(kKeyDate, s.string());
++ }
+
+ *offset += chunk_size;
+ break;
+@@ -2278,6 +2286,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 +3166,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 +3289,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);
+
+@@ -3360,6 +3374,18 @@ status_t MPEG4Source::fragmentedRead(
+ // move to next fragment
+ Sample lastSample = mCurrentSamples[mCurrentSamples.size() - 1];
+ off64_t nextMoof = mNextMoofOffset; // lastSample.offset + lastSample.size;
++
++ // If we're pointing to a sidx box then we skip it.
++ uint32_t hdr[2];
++ if (mDataSource->readAt(nextMoof, hdr, 8) < 8) {
++ return ERROR_END_OF_STREAM;
++ }
++ uint64_t chunk_size = ntohl(hdr[0]);
++ uint32_t chunk_type = ntohl(hdr[1]);
++ if (chunk_type == FOURCC('s', 'i', 'd', 'x')) {
++ nextMoof += chunk_size;
++ }
++
+ mCurrentMoofOffset = nextMoof;
+ mCurrentSamples.clear();
+ mCurrentSampleIndex = 0;
+@@ -3626,6 +3652,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 +3783,8 @@ bool SniffMPEG4(
+
+ return false;
+ }
++#endif
++
++} // namespace stagefright
+
+-} // namespace android
++#undef LOG_TAG
+diff --git a/media/libstagefright/MediaBuffer.cpp b/media/libstagefright/MediaBuffer.cpp
+index 11b80bf..72a7174 100644
+--- a/media/libstagefright/MediaBuffer.cpp
++++ b/media/libstagefright/MediaBuffer.cpp
+@@ -29,7 +29,7 @@
+ #include <ui/GraphicBuffer.h>
+ #include <sys/atomics.h>
+
+-namespace android {
++namespace stagefright {
+
+ MediaBuffer::MediaBuffer(void *data, size_t size)
+ : mObserver(NULL),
+@@ -200,4 +200,4 @@ MediaBuffer *MediaBuffer::clone() {
+ return buffer;
+ }
+
+-} // namespace android
++} // namespace stagefright
+diff --git a/media/libstagefright/MediaBufferGroup.cpp b/media/libstagefright/MediaBufferGroup.cpp
+index 80aae51..17dc08a 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>
+
+@@ -21,7 +22,7 @@
+ #include <media/stagefright/MediaBuffer.h>
+ #include <media/stagefright/MediaBufferGroup.h>
+
+-namespace android {
++namespace stagefright {
+
+ MediaBufferGroup::MediaBufferGroup()
+ : mFirstBuffer(NULL),
+@@ -83,4 +84,6 @@ void MediaBufferGroup::signalBufferReturned(MediaBuffer *) {
+ mCondition.signal();
+ }
+
+-} // namespace android
++} // namespace stagefright
++
++#undef LOG_TAG
+diff --git a/media/libstagefright/MediaDefs.cpp b/media/libstagefright/MediaDefs.cpp
+index b5d4e44..1f17bc0 100644
+--- a/media/libstagefright/MediaDefs.cpp
++++ b/media/libstagefright/MediaDefs.cpp
+@@ -16,7 +16,7 @@
+
+ #include <media/stagefright/MediaDefs.h>
+
+-namespace android {
++namespace stagefright {
+
+ const char *MEDIA_MIMETYPE_IMAGE_JPEG = "image/jpeg";
+
+@@ -56,4 +56,4 @@ const char *MEDIA_MIMETYPE_CONTAINER_WVM = "video/wvm";
+ const char *MEDIA_MIMETYPE_TEXT_3GPP = "text/3gpp-tt";
+ const char *MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip";
+
+-} // namespace android
++} // namespace stagefright
+diff --git a/media/libstagefright/MediaSource.cpp b/media/libstagefright/MediaSource.cpp
+index fd0e79c..faafe59 100644
+--- a/media/libstagefright/MediaSource.cpp
++++ b/media/libstagefright/MediaSource.cpp
+@@ -16,7 +16,7 @@
+
+ #include <media/stagefright/MediaSource.h>
+
+-namespace android {
++namespace stagefright {
+
+ MediaSource::MediaSource() {}
+
+@@ -61,4 +61,4 @@ int64_t MediaSource::ReadOptions::getLateBy() const {
+ return mLatenessUs;
+ }
+
+-} // namespace android
++} // namespace stagefright
+diff --git a/media/libstagefright/MetaData.cpp b/media/libstagefright/MetaData.cpp
+index ae6ae2d..c832c96 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>
+
+@@ -26,7 +27,7 @@
+ #include <media/stagefright/foundation/hexdump.h>
+ #include <media/stagefright/MetaData.h>
+
+-namespace android {
++namespace stagefright {
+
+ MetaData::MetaData() {
+ }
+@@ -350,5 +351,6 @@ void MetaData::dumpToLog() const {
+ }
+ }
+
+-} // namespace android
++} // namespace stagefright
+
++#undef LOG_TAG
+diff --git a/media/libstagefright/SampleIterator.cpp b/media/libstagefright/SampleIterator.cpp
+index eae721b..767393a 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>
+@@ -28,7 +29,7 @@
+
+ #include "include/SampleTable.h"
+
+-namespace android {
++namespace stagefright {
+
+ SampleIterator::SampleIterator(SampleTable *table)
+ : mTable(table),
+@@ -312,5 +313,6 @@ status_t SampleIterator::findSampleTime(
+ return OK;
+ }
+
+-} // namespace android
++} // namespace stagefright
+
++#undef LOG_TAG
+diff --git a/media/libstagefright/SampleTable.cpp b/media/libstagefright/SampleTable.cpp
+index d9858d7..d2099df 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>
+@@ -27,7 +28,7 @@
+ #include <media/stagefright/DataSource.h>
+ #include <media/stagefright/Utils.h>
+
+-namespace android {
++namespace stagefright {
+
+ // static
+ const uint32_t SampleTable::kChunkOffsetType32 = FOURCC('s', 't', 'c', 'o');
+@@ -827,5 +828,6 @@ uint32_t SampleTable::getCompositionTimeOffset(uint32_t sampleIndex) {
+ return mCompositionDeltaLookup->getCompositionTimeOffset(sampleIndex);
+ }
+
+-} // namespace android
++} // namespace stagefright
+
++#undef LOG_TAG
+diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp
+index 4db8e80..7b7c17a 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>
+
+@@ -33,7 +34,7 @@
+ #include <media/stagefright/Utils.h>
+ #include <media/AudioParameter.h>
+
+-namespace android {
++namespace stagefright {
+
+ uint16_t U16_AT(const uint8_t *ptr) {
+ return ptr[0] << 8 | ptr[1];
+@@ -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);
+ }
+
+-} // namespace android
++#endif
++
++} // namespace stagefright
+
++#undef LOG_TAG
+diff --git a/media/libstagefright/foundation/AAtomizer.cpp b/media/libstagefright/foundation/AAtomizer.cpp
+index b7b9e9f..4210cda 100644
+--- a/media/libstagefright/foundation/AAtomizer.cpp
++++ b/media/libstagefright/foundation/AAtomizer.cpp
+@@ -18,7 +18,7 @@
+
+ #include "AAtomizer.h"
+
+-namespace android {
++namespace stagefright {
+
+ // static
+ AAtomizer AAtomizer::gAtomizer;
+@@ -64,4 +64,4 @@ uint32_t AAtomizer::Hash(const char *s) {
+ return sum;
+ }
+
+-} // namespace android
++} // namespace stagefright
+diff --git a/media/libstagefright/foundation/ABitReader.cpp b/media/libstagefright/foundation/ABitReader.cpp
+index 5499c32..22850ef 100644
+--- a/media/libstagefright/foundation/ABitReader.cpp
++++ b/media/libstagefright/foundation/ABitReader.cpp
+@@ -16,9 +16,10 @@
+
+ #include "ABitReader.h"
+
++#include <log/log.h>
+ #include <media/stagefright/foundation/ADebug.h>
+
+-namespace android {
++namespace stagefright {
+
+ ABitReader::ABitReader(const uint8_t *data, size_t size)
+ : mData(data),
+@@ -99,4 +100,4 @@ const uint8_t *ABitReader::data() const {
+ return mData - (mNumBitsLeft + 7) / 8;
+ }
+
+-} // namespace android
++} // namespace stagefright
+diff --git a/media/libstagefright/foundation/ABuffer.cpp b/media/libstagefright/foundation/ABuffer.cpp
+index 6173db4..53f5ebc 100644
+--- a/media/libstagefright/foundation/ABuffer.cpp
++++ b/media/libstagefright/foundation/ABuffer.cpp
+@@ -20,7 +20,7 @@
+ #include "ALooper.h"
+ #include "AMessage.h"
+
+-namespace android {
++namespace stagefright {
+
+ ABuffer::ABuffer(size_t capacity)
+ : mData(malloc(capacity)),
+@@ -72,5 +72,5 @@ sp<AMessage> ABuffer::meta() {
+ return mMeta;
+ }
+
+-} // namespace android
++} // namespace stagefright
+
+diff --git a/media/libstagefright/foundation/AString.cpp b/media/libstagefright/foundation/AString.cpp
+index dee786d..d06110a 100644
+--- a/media/libstagefright/foundation/AString.cpp
++++ b/media/libstagefright/foundation/AString.cpp
+@@ -23,7 +23,7 @@
+ #include "ADebug.h"
+ #include "AString.h"
+
+-namespace android {
++namespace stagefright {
+
+ // static
+ const char *AString::kEmptyString = "";
+@@ -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);
+
+@@ -337,5 +343,5 @@ AString StringPrintf(const char *format, ...) {
+ return result;
+ }
+
+-} // namespace android
++} // namespace stagefright
+
+diff --git a/media/libstagefright/foundation/hexdump.cpp b/media/libstagefright/foundation/hexdump.cpp
+index a44d832..7b566eb 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>
+
+@@ -27,7 +28,7 @@
+ #include <stdint.h>
+ #include <stdio.h>
+
+-namespace android {
++namespace stagefright {
+
+ static void appendIndent(AString *s, int32_t indent) {
+ static const char kWhitespace[] =
+@@ -90,5 +91,6 @@ void hexdump(const void *_data, size_t size, size_t indent, AString *appendTo) {
+ }
+ }
+
+-} // namespace android
++} // namespace stagefright
+
++#undef LOG_TAG
+diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp
+index 34d671a..3aa395c 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>
+
+@@ -26,7 +27,7 @@
+ #include <utils/String8.h>
+ #include <byteswap.h>
+
+-namespace android {
++namespace stagefright {
+
+ static const size_t kMaxMetadataSize = 3 * 1024 * 1024;
+
+@@ -897,4 +898,6 @@ bool ID3::parseV1(const sp<DataSource> &source) {
+ return true;
+ }
+
+-} // namespace android
++} // namespace stagefright
++
++#undef LOG_TAG
+diff --git a/media/libstagefright/include/AMRExtractor.h b/media/libstagefright/include/AMRExtractor.h
+index 4a1c827..cdfc98e 100644
+--- a/media/libstagefright/include/AMRExtractor.h
++++ b/media/libstagefright/include/AMRExtractor.h
+@@ -21,7 +21,7 @@
+ #include <utils/Errors.h>
+ #include <media/stagefright/MediaExtractor.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct AMessage;
+ class String8;
+@@ -57,6 +57,6 @@ bool SniffAMR(
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *);
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // AMR_EXTRACTOR_H_
+diff --git a/media/libstagefright/include/ESDS.h b/media/libstagefright/include/ESDS.h
+index 2f40dae..bc4c5a6 100644
+--- a/media/libstagefright/include/ESDS.h
++++ b/media/libstagefright/include/ESDS.h
+@@ -22,7 +22,7 @@
+
+ #include <media/stagefright/MediaErrors.h>
+
+-namespace android {
++namespace stagefright {
+
+ class ESDS {
+ public:
+@@ -68,5 +68,5 @@ private:
+ ESDS &operator=(const ESDS &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+ #endif // ESDS_H_
+diff --git a/media/libstagefright/include/ID3.h b/media/libstagefright/include/ID3.h
+index cca83ab..cbb3bbf 100644
+--- a/media/libstagefright/include/ID3.h
++++ b/media/libstagefright/include/ID3.h
+@@ -20,7 +20,7 @@
+
+ #include <utils/RefBase.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct DataSource;
+ struct String8;
+@@ -96,7 +96,7 @@ private:
+ ID3 &operator=(const ID3 &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // ID3_H_
+
+diff --git a/media/libstagefright/include/MPEG4Extractor.h b/media/libstagefright/include/MPEG4Extractor.h
+index bbec1c4..98818b8 100644
+--- a/media/libstagefright/include/MPEG4Extractor.h
++++ b/media/libstagefright/include/MPEG4Extractor.h
+@@ -27,7 +27,7 @@
+ #include <utils/Vector.h>
+ #include <utils/String8.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct AMessage;
+ class DataSource;
+@@ -129,6 +129,6 @@ bool SniffMPEG4(
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *);
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // MPEG4_EXTRACTOR_H_
+diff --git a/media/libstagefright/include/SampleIterator.h b/media/libstagefright/include/SampleIterator.h
+index b5a043c..a4d52fe 100644
+--- a/media/libstagefright/include/SampleIterator.h
++++ b/media/libstagefright/include/SampleIterator.h
+@@ -14,9 +14,12 @@
+ * limitations under the License.
+ */
+
++#ifndef SAMPLE_ITERATOR_H_
++#define SAMPLE_ITERATOR_H_
++
+ #include <utils/Vector.h>
+
+-namespace android {
++namespace stagefright {
+
+ struct SampleTable;
+
+@@ -71,5 +74,6 @@ private:
+ SampleIterator &operator=(const SampleIterator &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
++#endif
+diff --git a/media/libstagefright/include/SampleTable.h b/media/libstagefright/include/SampleTable.h
+index 847dff7..2a82077 100644
+--- a/media/libstagefright/include/SampleTable.h
++++ b/media/libstagefright/include/SampleTable.h
+@@ -25,7 +25,7 @@
+ #include <utils/RefBase.h>
+ #include <utils/threads.h>
+
+-namespace android {
++namespace stagefright {
+
+ class DataSource;
+ struct SampleIterator;
+@@ -148,6 +148,6 @@ private:
+ SampleTable &operator=(const SampleTable &);
+ };
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // SAMPLE_TABLE_H_
diff --git a/media/libstagefright/patches/system/core.patch b/media/libstagefright/patches/system/core.patch
new file mode 100644
index 000000000..374afc5f3
--- /dev/null
+++ b/media/libstagefright/patches/system/core.patch
@@ -0,0 +1,1387 @@
+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/sysutils/List.h b/include/sysutils/List.h
+index 31f7b37..72a9c44 100644
+--- a/include/sysutils/List.h
++++ b/include/sysutils/List.h
+@@ -30,7 +30,7 @@
+ #include <stddef.h>
+ #include <stdint.h>
+
+-namespace android {
++namespace stagefright {
+ namespace sysutils {
+
+ /*
+@@ -329,6 +329,6 @@ List<T>& List<T>::operator=(const List<T>& right)
+ }
+
+ }; // namespace sysutils
+-}; // namespace android
++}; // namespace stagefright
+
+ #endif // _SYSUTILS_LIST_H
+diff --git a/include/utils/CallStack.h b/include/utils/CallStack.h
+index 61dc832..eb52c8b 100644
+--- a/include/utils/CallStack.h
++++ b/include/utils/CallStack.h
+@@ -25,7 +25,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ class CallStack
+ {
+@@ -68,7 +68,7 @@ private:
+ backtrace_frame_t mStack[MAX_DEPTH];
+ };
+
+-}; // namespace android
++}; // namespace stagefright
+
+
+ // ---------------------------------------------------------------------------
+diff --git a/include/utils/Condition.h b/include/utils/Condition.h
+index e63ba7e..e8e7ae9 100644
+--- a/include/utils/Condition.h
++++ b/include/utils/Condition.h
+@@ -30,7 +30,7 @@
+ #include <utils/Timers.h>
+
+ // ---------------------------------------------------------------------------
+-namespace android {
++namespace stagefright {
+ // ---------------------------------------------------------------------------
+
+ /*
+@@ -138,10 +138,22 @@ 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
+
+ // ---------------------------------------------------------------------------
+-}; // namespace android
++}; // namespace stagefright
+ // ---------------------------------------------------------------------------
+
+ #endif // _LIBS_UTILS_CONDITON_H
+diff --git a/include/utils/Debug.h b/include/utils/Debug.h
+index 08893bd..41f09eb 100644
+--- a/include/utils/Debug.h
++++ b/include/utils/Debug.h
+@@ -20,7 +20,7 @@
+ #include <stdint.h>
+ #include <sys/types.h>
+
+-namespace android {
++namespace stagefright {
+ // ---------------------------------------------------------------------------
+
+ #ifdef __cplusplus
+@@ -43,6 +43,6 @@ struct CompileTimeIfElse<false, LHS, RHS> { typedef RHS TYPE; };
+ #endif
+
+ // ---------------------------------------------------------------------------
+-}; // namespace android
++}; // namespace stagefright
+
+ #endif // ANDROID_UTILS_DEBUG_H
+diff --git a/include/utils/Errors.h b/include/utils/Errors.h
+index 0b75b19..0ceda59 100644
+--- a/include/utils/Errors.h
++++ b/include/utils/Errors.h
+@@ -20,7 +20,7 @@
+ #include <sys/types.h>
+ #include <errno.h>
+
+-namespace android {
++namespace stagefright {
+
+ // use this type to return error codes
+ #ifdef HAVE_MS_C_RUNTIME
+@@ -81,7 +81,7 @@ enum {
+ # define NO_ERROR 0L
+ #endif
+
+-}; // namespace android
++}; // namespace stagefright
+
+ // ---------------------------------------------------------------------------
+
+diff --git a/include/utils/KeyedVector.h b/include/utils/KeyedVector.h
+index c4faae0..ca4bfd6 100644
+--- a/include/utils/KeyedVector.h
++++ b/include/utils/KeyedVector.h
+@@ -29,7 +29,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ template <typename KEY, typename VALUE>
+ class KeyedVector
+@@ -217,7 +217,7 @@ const VALUE& DefaultKeyedVector<KEY,VALUE>::valueFor(const KEY& key) const {
+ return i >= 0 ? KeyedVector<KEY,VALUE>::valueAt(i) : mDefault;
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+
+ // ---------------------------------------------------------------------------
+
+diff --git a/include/utils/List.h b/include/utils/List.h
+index 403cd7f..f5c110e 100644
+--- a/include/utils/List.h
++++ b/include/utils/List.h
+@@ -30,7 +30,7 @@
+ #include <stddef.h>
+ #include <stdint.h>
+
+-namespace android {
++namespace stagefright {
+
+ /*
+ * Doubly-linked list. Instantiate with "List<MyClass> myList".
+@@ -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;
+@@ -327,6 +329,6 @@ List<T>& List<T>::operator=(const List<T>& right)
+ return *this;
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+
+ #endif // _LIBS_UTILS_LIST_H
+diff --git a/include/utils/Log.h b/include/utils/Log.h
+index 4259c86..97cc4f3 100644
+--- a/include/utils/Log.h
++++ b/include/utils/Log.h
+@@ -33,7 +33,7 @@
+
+ #ifdef __cplusplus
+
+-namespace android {
++namespace stagefright {
+
+ /*
+ * A very simple utility that yells in the log when an operation takes too long.
+@@ -62,9 +62,9 @@ private:
+ * }
+ */
+ #define ALOGD_IF_SLOW(timeoutMillis, message) \
+- android::LogIfSlow _logIfSlow(LOG_TAG, ANDROID_LOG_DEBUG, timeoutMillis, message);
++ stagefright::LogIfSlow _logIfSlow(LOG_TAG, ANDROID_LOG_DEBUG, timeoutMillis, message);
+
+-} // namespace android
++} // namespace stagefright
+
+ #endif // __cplusplus
+
+diff --git a/include/utils/Mutex.h b/include/utils/Mutex.h
+index dd201c8..b33efef 100644
+--- a/include/utils/Mutex.h
++++ b/include/utils/Mutex.h
+@@ -28,7 +28,7 @@
+ #include <utils/Errors.h>
+
+ // ---------------------------------------------------------------------------
+-namespace android {
++namespace stagefright {
+ // ---------------------------------------------------------------------------
+
+ class Condition;
+@@ -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
+
+ // ---------------------------------------------------------------------------
+@@ -131,7 +142,7 @@ inline status_t Mutex::tryLock() {
+ typedef Mutex::Autolock AutoMutex;
+
+ // ---------------------------------------------------------------------------
+-}; // namespace android
++}; // namespace stagefright
+ // ---------------------------------------------------------------------------
+
+ #endif // _LIBS_UTILS_MUTEX_H
+diff --git a/include/utils/RWLock.h b/include/utils/RWLock.h
+index 90beb5f..4c43827 100644
+--- a/include/utils/RWLock.h
++++ b/include/utils/RWLock.h
+@@ -28,7 +28,7 @@
+ #include <utils/ThreadDefs.h>
+
+ // ---------------------------------------------------------------------------
+-namespace android {
++namespace stagefright {
+ // ---------------------------------------------------------------------------
+
+ #if defined(HAVE_PTHREADS)
+@@ -120,7 +120,7 @@ inline void RWLock::unlock() {
+ #endif // HAVE_PTHREADS
+
+ // ---------------------------------------------------------------------------
+-}; // namespace android
++}; // namespace stagefright
+ // ---------------------------------------------------------------------------
+
+ #endif // _LIBS_UTILS_RWLOCK_H
+diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h
+index cbfe13a..e1f97c9 100644
+--- a/include/utils/RefBase.h
++++ b/include/utils/RefBase.h
+@@ -27,8 +27,12 @@
+ #include <utils/StrongPointer.h>
+ #include <utils/TypeHelpers.h>
+
++#ifdef _MSC_VER
++#define __attribute__(X)
++#endif
++
+ // ---------------------------------------------------------------------------
+-namespace android {
++namespace stagefright {
+
+ class TextOutput;
+ TextOutput& printWeakPointer(TextOutput& to, const void* val);
+@@ -539,7 +543,11 @@ void move_backward_type(wp<TYPE>* d, wp<TYPE> const* s, size_t n) {
+ }
+
+
+-}; // namespace android
++}; // namespace stagefright
++
++#ifdef _MSC_VER
++#undef __attribute__
++#endif
+
+ // ---------------------------------------------------------------------------
+
+diff --git a/include/utils/SharedBuffer.h b/include/utils/SharedBuffer.h
+index b670953..62d3ca4 100644
+--- a/include/utils/SharedBuffer.h
++++ b/include/utils/SharedBuffer.h
+@@ -22,7 +22,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ class SharedBuffer
+ {
+@@ -130,7 +130,7 @@ bool SharedBuffer::onlyOwner() const {
+ return (mRefs == 1);
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+
+ // ---------------------------------------------------------------------------
+
+diff --git a/include/utils/SortedVector.h b/include/utils/SortedVector.h
+index 2d3e82a..67bfea8 100644
+--- a/include/utils/SortedVector.h
++++ b/include/utils/SortedVector.h
+@@ -29,7 +29,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ template <class TYPE>
+ class SortedVector : private SortedVectorImpl
+@@ -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());
+ }
+@@ -274,7 +267,7 @@ int SortedVector<TYPE>::do_compare(const void* lhs, const void* rhs) const {
+ return compare_type( *reinterpret_cast<const TYPE*>(lhs), *reinterpret_cast<const TYPE*>(rhs) );
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+
+
+ // ---------------------------------------------------------------------------
+diff --git a/include/utils/String16.h b/include/utils/String16.h
+index d131bfc..40632d7 100644
+--- a/include/utils/String16.h
++++ b/include/utils/String16.h
+@@ -30,7 +30,7 @@ extern "C" {
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ // ---------------------------------------------------------------------------
+
+@@ -243,7 +243,7 @@ inline String16::operator const char16_t*() const
+ return mString;
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+
+ // ---------------------------------------------------------------------------
+
+diff --git a/include/utils/String8.h b/include/utils/String8.h
+index ef59470..3007f21 100644
+--- a/include/utils/String8.h
++++ b/include/utils/String8.h
+@@ -27,7 +27,11 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++#ifdef _MSC_VER
++#define __attribute__(X)
++#endif
++
++namespace stagefright {
+
+ class String16;
+ class TextOutput;
+@@ -388,7 +392,11 @@ inline String8::operator const char*() const
+ return mString;
+ }
+
+-} // namespace android
++} // namespace stagefright
++
++#ifdef _MSC_VER
++#undef __attribute__
++#endif
+
+ // ---------------------------------------------------------------------------
+
+diff --git a/include/utils/StrongPointer.h b/include/utils/StrongPointer.h
+index aba9577..db22900 100644
+--- a/include/utils/StrongPointer.h
++++ b/include/utils/StrongPointer.h
+@@ -24,7 +24,7 @@
+ #include <stdlib.h>
+
+ // ---------------------------------------------------------------------------
+-namespace android {
++namespace stagefright {
+
+ template<typename T> class wp;
+
+@@ -204,7 +204,7 @@ void sp<T>::set_pointer(T* ptr) {
+ m_ptr = ptr;
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+
+ // ---------------------------------------------------------------------------
+
+diff --git a/include/utils/TypeHelpers.h b/include/utils/TypeHelpers.h
+index 13c9081..7a19244 100644
+--- a/include/utils/TypeHelpers.h
++++ b/include/utils/TypeHelpers.h
+@@ -24,7 +24,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ /*
+ * Types traits
+@@ -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) {
+@@ -295,7 +295,7 @@ template <typename T> inline hash_t hash_type(T* const & value) {
+ return hash_type(uintptr_t(value));
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+
+ // ---------------------------------------------------------------------------
+
+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..2388d06 100644
+--- a/include/utils/Vector.h
++++ b/include/utils/Vector.h
+@@ -28,7 +28,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ template <typename TYPE>
+ class SortedVector;
+@@ -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>
+@@ -415,7 +395,7 @@ void Vector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) co
+ move_backward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+
+
+ // ---------------------------------------------------------------------------
+diff --git a/include/utils/VectorImpl.h b/include/utils/VectorImpl.h
+index 21ad71c..b83c946 100644
+--- a/include/utils/VectorImpl.h
++++ b/include/utils/VectorImpl.h
+@@ -26,7 +26,7 @@
+ // No user serviceable parts in here...
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ /*!
+ * Implementation of the guts of the vector<> class
+@@ -175,7 +175,7 @@ private:
+ ssize_t replaceAt(const void* item, size_t index);
+ };
+
+-}; // namespace android
++}; // namespace stagefright
+
+
+ // ---------------------------------------------------------------------------
+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/libpixelflinger/codeflinger/tinyutils/Errors.h b/libpixelflinger/codeflinger/tinyutils/Errors.h
+index 47ae9d7..98f2190 100644
+--- a/libpixelflinger/codeflinger/tinyutils/Errors.h
++++ b/libpixelflinger/codeflinger/tinyutils/Errors.h
+@@ -20,7 +20,7 @@
+ #include <sys/types.h>
+ #include <errno.h>
+
+-namespace android {
++namespace stagefright {
+ namespace tinyutils {
+
+ // use this type to return error codes
+@@ -41,7 +41,7 @@ enum {
+
+
+ } // namespace tinyutils
+-} // namespace android
++} // namespace stagefright
+
+ // ---------------------------------------------------------------------------
+
+diff --git a/libpixelflinger/codeflinger/tinyutils/KeyedVector.h b/libpixelflinger/codeflinger/tinyutils/KeyedVector.h
+index 9d8668b..62fc760 100644
+--- a/libpixelflinger/codeflinger/tinyutils/KeyedVector.h
++++ b/libpixelflinger/codeflinger/tinyutils/KeyedVector.h
+@@ -27,7 +27,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+ namespace tinyutils {
+
+ template <typename KEY, typename VALUE>
+@@ -196,7 +196,7 @@ const VALUE& DefaultKeyedVector<KEY,VALUE>::valueFor(const KEY& key) const {
+ }
+
+ } // namespace tinyutils
+-} // namespace android
++} // namespace stagefright
+
+ // ---------------------------------------------------------------------------
+
+diff --git a/libpixelflinger/codeflinger/tinyutils/SortedVector.h b/libpixelflinger/codeflinger/tinyutils/SortedVector.h
+index a2b7005..71026c8 100644
+--- a/libpixelflinger/codeflinger/tinyutils/SortedVector.h
++++ b/libpixelflinger/codeflinger/tinyutils/SortedVector.h
+@@ -27,7 +27,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+ namespace tinyutils {
+
+ template <class TYPE>
+@@ -276,7 +276,7 @@ int SortedVector<TYPE>::do_compare(const void* lhs, const void* rhs) const {
+ }
+
+ } // namespace tinyutils
+-} // namespace android
++} // namespace stagefright
+
+
+ // ---------------------------------------------------------------------------
+diff --git a/libpixelflinger/codeflinger/tinyutils/Vector.h b/libpixelflinger/codeflinger/tinyutils/Vector.h
+index c07a17a..3fe87a2 100644
+--- a/libpixelflinger/codeflinger/tinyutils/Vector.h
++++ b/libpixelflinger/codeflinger/tinyutils/Vector.h
+@@ -29,7 +29,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+ namespace tinyutils {
+
+ /*!
+@@ -345,7 +345,7 @@ void Vector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) co
+ }
+
+ } // namespace tinyutils
+-} // namespace android
++} // namespace stagefright
+
+
+ // ---------------------------------------------------------------------------
+diff --git a/libpixelflinger/codeflinger/tinyutils/VectorImpl.h b/libpixelflinger/codeflinger/tinyutils/VectorImpl.h
+index 56089b3..6cc55c4 100644
+--- a/libpixelflinger/codeflinger/tinyutils/VectorImpl.h
++++ b/libpixelflinger/codeflinger/tinyutils/VectorImpl.h
+@@ -25,7 +25,7 @@
+ // No user serviceable parts in here...
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+ namespace tinyutils {
+
+ /*!
+@@ -187,7 +187,7 @@ private:
+ };
+
+ } // namespace tinyutils
+-} // namespace android
++} // namespace stagefright
+
+
+ // ---------------------------------------------------------------------------
+diff --git a/libutils/RefBase.cpp b/libutils/RefBase.cpp
+index f398a82..259b0a4 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
+@@ -51,7 +58,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ #define INITIAL_STRONG_VALUE (1<<28)
+
+@@ -647,4 +654,4 @@ void RefBase::renameRefId(RefBase* ref,
+ ref->mRefs->renameWeakRefId(old_id, new_id);
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+diff --git a/libutils/SharedBuffer.cpp b/libutils/SharedBuffer.cpp
+index 3555fb7..7aefe80 100644
+--- a/libutils/SharedBuffer.cpp
++++ b/libutils/SharedBuffer.cpp
+@@ -22,7 +22,7 @@
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ SharedBuffer* SharedBuffer::alloc(size_t size)
+ {
+@@ -110,4 +110,4 @@ int32_t SharedBuffer::release(uint32_t flags) const
+ }
+
+
+-}; // namespace android
++}; // namespace stagefright
+diff --git a/libutils/Static.cpp b/libutils/Static.cpp
+index 3ed07a1..476240f 100644
+--- a/libutils/Static.cpp
++++ b/libutils/Static.cpp
+@@ -17,7 +17,7 @@
+ // All static variables go here, to control initialization and
+ // destruction order in the library.
+
+-namespace android {
++namespace stagefright {
+
+ // For String8.cpp
+ extern void initialize_string8();
+@@ -46,4 +46,4 @@ public:
+ static LibUtilsFirstStatics gFirstStatics;
+ int gDarwinCantLoadAllObjects = 1;
+
+-} // namespace android
++} // namespace stagefright
+diff --git a/libutils/String16.cpp b/libutils/String16.cpp
+index b09b728..998cb94 100644
+--- a/libutils/String16.cpp
++++ b/libutils/String16.cpp
+@@ -27,7 +27,7 @@
+ #include <ctype.h>
+
+
+-namespace android {
++namespace stagefright {
+
+ static SharedBuffer* gEmptyStringBuf = NULL;
+ static char16_t* gEmptyString = NULL;
+@@ -419,4 +419,4 @@ status_t String16::remove(size_t len, size_t begin)
+ return NO_MEMORY;
+ }
+
+-}; // namespace android
++}; // namespace stagefright
+diff --git a/libutils/String8.cpp b/libutils/String8.cpp
+index e852d77..3d4b285 100644
+--- a/libutils/String8.cpp
++++ b/libutils/String8.cpp
+@@ -25,13 +25,13 @@
+ #include <ctype.h>
+
+ /*
+- * Functions outside android is below the namespace android, since they use
++ * Functions outside android is below the namespace stagefright, since they use
+ * functions and constants in android namespace.
+ */
+
+ // ---------------------------------------------------------------------------
+
+-namespace android {
++namespace stagefright {
+
+ // Separator used by resource paths. This is not platform dependent contrary
+ // to OS_PATH_SEPARATOR.
+@@ -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;
+ }
+
+@@ -465,6 +467,8 @@ void String8::getUtf32(char32_t* dst) const
+ // ---------------------------------------------------------------------------
+ // Path functions
+
++#if 0
++
+ void String8::setPathName(const char* name)
+ {
+ setPathName(name, strlen(name));
+@@ -637,4 +641,6 @@ String8& String8::convertToResPath()
+ return *this;
+ }
+
+-}; // namespace android
++#endif
++
++}; // namespace stagefright
+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;
+ }
+
+ }
+diff --git a/libutils/VectorImpl.cpp b/libutils/VectorImpl.cpp
+index 5a79647..114fa90 100644
+--- a/libutils/VectorImpl.cpp
++++ b/libutils/VectorImpl.cpp
+@@ -29,7 +29,7 @@
+ /*****************************************************************************/
+
+
+-namespace android {
++namespace stagefright {
+
+ // ----------------------------------------------------------------------------
+
+@@ -621,5 +621,5 @@ ssize_t SortedVectorImpl::remove(const void* item)
+
+ /*****************************************************************************/
+
+-}; // namespace android
++}; // namespace stagefright
+