diff options
Diffstat (limited to 'media/libstagefright')
41 files changed, 404 insertions, 134 deletions
diff --git a/media/libstagefright/AACWriter.cpp b/media/libstagefright/AACWriter.cpp index a6f7cfb..c9bcaba 100644 --- a/media/libstagefright/AACWriter.cpp +++ b/media/libstagefright/AACWriter.cpp @@ -171,7 +171,7 @@ status_t AACWriter::reset() { void *dummy; pthread_join(mThread, &dummy); - status_t err = (status_t) dummy; + status_t err = static_cast<status_t>(reinterpret_cast<uintptr_t>(dummy)); { status_t status = mSource->stop(); if (err == OK && @@ -200,7 +200,7 @@ bool AACWriter::exceedsFileDurationLimit() { // static void *AACWriter::ThreadWrapper(void *me) { - return (void *) static_cast<AACWriter *>(me)->threadFunc(); + return (void *)(uintptr_t)static_cast<AACWriter *>(me)->threadFunc(); } /* diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 3ad3ca7..6e36bbf 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -3442,7 +3442,7 @@ void ACodec::BaseState::onOutputBufferDrained(const sp<AMessage> &msg) { int32_t render; if (mCodec->mNativeWindow != NULL && msg->findInt32("render", &render) && render != 0 - && (info->mData == NULL || info->mData->size() != 0)) { + && info->mData != NULL && info->mData->size() != 0) { // The client wants this buffer to be rendered. status_t err; diff --git a/media/libstagefright/AMRWriter.cpp b/media/libstagefright/AMRWriter.cpp index 8d5eec8..3fe247a 100644 --- a/media/libstagefright/AMRWriter.cpp +++ b/media/libstagefright/AMRWriter.cpp @@ -162,7 +162,7 @@ status_t AMRWriter::reset() { void *dummy; pthread_join(mThread, &dummy); - status_t err = (status_t) dummy; + status_t err = static_cast<status_t>(reinterpret_cast<uintptr_t>(dummy)); { status_t status = mSource->stop(); if (err == OK && @@ -191,7 +191,7 @@ bool AMRWriter::exceedsFileDurationLimit() { // static void *AMRWriter::ThreadWrapper(void *me) { - return (void *) static_cast<AMRWriter *>(me)->threadFunc(); + return (void *)(uintptr_t) static_cast<AMRWriter *>(me)->threadFunc(); } status_t AMRWriter::threadFunc() { diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp index d7223d9..f0d1a14 100644 --- a/media/libstagefright/AudioSource.cpp +++ b/media/libstagefright/AudioSource.cpp @@ -308,7 +308,7 @@ status_t AudioSource::dataCallback(const AudioRecord::Buffer& audioBuffer) { if (numLostBytes > 0) { // Loss of audio frames should happen rarely; thus the LOGW should // not cause a logging spam - ALOGW("Lost audio record data: %d bytes", numLostBytes); + ALOGW("Lost audio record data: %zu bytes", numLostBytes); } while (numLostBytes > 0) { diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 130207d..29c007a 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -19,6 +19,7 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "AwesomePlayer" #define ATRACE_TAG ATRACE_TAG_VIDEO +#include <inttypes.h> #include <utils/Log.h> #include <utils/Trace.h> @@ -725,7 +726,7 @@ void AwesomePlayer::onBufferingUpdate() { if ((mFlags & PLAYING) && !eos && (cachedDataRemaining < kLowWaterMarkBytes)) { - ALOGI("cache is running low (< %d) , pausing.", + ALOGI("cache is running low (< %zu) , pausing.", kLowWaterMarkBytes); modifyFlags(CACHE_UNDERRUN, SET); pause_l(); @@ -734,12 +735,12 @@ void AwesomePlayer::onBufferingUpdate() { notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START); } else if (eos || cachedDataRemaining > kHighWaterMarkBytes) { if (mFlags & CACHE_UNDERRUN) { - ALOGI("cache has filled up (> %d), resuming.", + ALOGI("cache has filled up (> %zu), resuming.", kHighWaterMarkBytes); modifyFlags(CACHE_UNDERRUN, CLEAR); play_l(); } else if (mFlags & PREPARING) { - ALOGV("cache has filled up (> %d), prepare is done", + ALOGV("cache has filled up (> %zu), prepare is done", kHighWaterMarkBytes); finishAsyncPrepare_l(); } @@ -2096,7 +2097,10 @@ void AwesomePlayer::onCheckAudioStatus() { mSeekNotificationSent = true; } - mSeeking = NO_SEEK; + if (mVideoSource == NULL) { + // For video the mSeeking flag is always reset in finishSeekIfNecessary + mSeeking = NO_SEEK; + } notifyIfMediaStarted_l(); } @@ -2292,8 +2296,8 @@ status_t AwesomePlayer::finishSetDataSource_l() { sniffedMIME = tmp.string(); if (meta == NULL - || !meta->findInt64( - "meta-data-size", &metaDataSize)) { + || !meta->findInt64("meta-data-size", + reinterpret_cast<int64_t*>(&metaDataSize))) { metaDataSize = kHighWaterMarkBytes; } @@ -2580,12 +2584,12 @@ status_t AwesomePlayer::getTrackInfo(Parcel *reply) const { status_t AwesomePlayer::selectAudioTrack_l( const sp<MediaSource>& source, size_t trackIndex) { - ALOGI("selectAudioTrack_l: trackIndex=%d, mFlags=0x%x", trackIndex, mFlags); + ALOGI("selectAudioTrack_l: trackIndex=%zu, mFlags=0x%x", trackIndex, mFlags); { Mutex::Autolock autoLock(mStatsLock); if ((ssize_t)trackIndex == mActiveAudioTrackIndex) { - ALOGI("Track %d is active. Does nothing.", trackIndex); + ALOGI("Track %zu is active. Does nothing.", trackIndex); return OK; } //mStats.mFlags = mFlags; @@ -2658,7 +2662,7 @@ status_t AwesomePlayer::selectTrack(size_t trackIndex, bool select) { trackCount += mTextDriver->countExternalTracks(); } if (trackIndex >= trackCount) { - ALOGE("Track index (%d) is out of range [0, %d)", trackIndex, trackCount); + ALOGE("Track index (%zu) is out of range [0, %zu)", trackIndex, trackCount); return ERROR_OUT_OF_RANGE; } @@ -2670,14 +2674,14 @@ status_t AwesomePlayer::selectTrack(size_t trackIndex, bool select) { isAudioTrack = !strncasecmp(mime, "audio/", 6); if (!isAudioTrack && strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) != 0) { - ALOGE("Track %d is not either audio or timed text", trackIndex); + ALOGE("Track %zu is not either audio or timed text", trackIndex); return ERROR_UNSUPPORTED; } } if (isAudioTrack) { if (!select) { - ALOGE("Deselect an audio track (%d) is not supported", trackIndex); + ALOGE("Deselect an audio track (%zu) is not supported", trackIndex); return ERROR_UNSUPPORTED; } return selectAudioTrack_l(mExtractor->getTrack(trackIndex), trackIndex); @@ -2815,7 +2819,7 @@ status_t AwesomePlayer::dump(int fd, const Vector<String16> &args) const { fprintf(out, ", flags(0x%08x)", mStats.mFlags); if (mStats.mBitrate >= 0) { - fprintf(out, ", bitrate(%lld bps)", mStats.mBitrate); + fprintf(out, ", bitrate(%" PRId64 " bps)", mStats.mBitrate); } fprintf(out, "\n"); @@ -2823,7 +2827,7 @@ status_t AwesomePlayer::dump(int fd, const Vector<String16> &args) const { for (size_t i = 0; i < mStats.mTracks.size(); ++i) { const TrackStat &stat = mStats.mTracks.itemAt(i); - fprintf(out, " Track %d\n", i + 1); + fprintf(out, " Track %zu\n", i + 1); fprintf(out, " MIME(%s)", stat.mMIME.string()); if (!stat.mDecoderName.isEmpty()) { @@ -2835,8 +2839,8 @@ status_t AwesomePlayer::dump(int fd, const Vector<String16> &args) const { if ((ssize_t)i == mStats.mVideoTrackIndex) { fprintf(out, " videoDimensions(%d x %d), " - "numVideoFramesDecoded(%lld), " - "numVideoFramesDropped(%lld)\n", + "numVideoFramesDecoded(%" PRId64 "), " + "numVideoFramesDropped(%" PRId64 ")\n", mStats.mVideoWidth, mStats.mVideoHeight, mStats.mNumVideoFramesDecoded, diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index 4926c1d..6a33ce6 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -38,6 +38,9 @@ #include <media/stagefright/MetaData.h> #include <utils/String8.h> +#include <byteswap.h> +#include "include/ID3.h" + namespace android { class MPEG4Source : public MediaSource { @@ -257,7 +260,7 @@ static void hexdump(const void *_data, size_t size) { const uint8_t *data = (const uint8_t *)_data; size_t offset = 0; while (offset < size) { - printf("0x%04x ", offset); + printf("0x%04zx ", offset); size_t n = size - offset; if (n > 16) { @@ -680,8 +683,9 @@ status_t MPEG4Extractor::parseDrmSINF(off64_t *offset, off64_t data_offset) { } sinf->len = dataLen - 3; sinf->IPMPData = new char[sinf->len]; + data_offset += 2; - if (mDataSource->readAt(data_offset + 2, sinf->IPMPData, sinf->len) < sinf->len) { + if (mDataSource->readAt(data_offset, sinf->IPMPData, sinf->len) < sinf->len) { return ERROR_IO; } data_offset += sinf->len; @@ -1635,7 +1639,7 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { case FOURCC('d', 'a', 't', 'a'): { if (mPath.size() == 6 && underMetaDataPath(mPath)) { - status_t err = parseMetaData(data_offset, chunk_data_size); + status_t err = parseITunesMetaData(data_offset, chunk_data_size); if (err != OK) { return err; @@ -1767,6 +1771,35 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { break; } + case FOURCC('t', 'i', 't', 'l'): + case FOURCC('p', 'e', 'r', 'f'): + case FOURCC('a', 'u', 't', 'h'): + case FOURCC('g', 'n', 'r', 'e'): + case FOURCC('a', 'l', 'b', 'm'): + case FOURCC('y', 'r', 'r', 'c'): + { + status_t err = parse3GPPMetaData(data_offset, chunk_data_size, depth); + + if (err != OK) { + return err; + } + + *offset += chunk_size; + break; + } + + case FOURCC('I', 'D', '3', '2'): + { + if (chunk_data_size < 6) { + return ERROR_MALFORMED; + } + + parseID3v2MetaData(data_offset + 6); + + *offset += chunk_size; + break; + } + case FOURCC('-', '-', '-', '-'): { mLastCommentMean.clear(); @@ -2001,7 +2034,7 @@ status_t MPEG4Extractor::parseTrackHeader( return OK; } -status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) { +status_t MPEG4Extractor::parseITunesMetaData(off64_t offset, size_t size) { if (size < 4) { return ERROR_MALFORMED; } @@ -2147,7 +2180,7 @@ status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) { break; } - if (size >= 8 && metadataKey) { + if (size >= 8 && metadataKey && !mFileMetaData->hasData(metadataKey)) { if (metadataKey == kKeyAlbumArt) { mFileMetaData->setData( kKeyAlbumArt, MetaData::TYPE_NONE, @@ -2188,6 +2221,170 @@ status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) { return OK; } +status_t MPEG4Extractor::parse3GPPMetaData(off64_t offset, size_t size, int depth) { + if (size < 4) { + return ERROR_MALFORMED; + } + + uint8_t *buffer = new uint8_t[size]; + if (mDataSource->readAt( + offset, buffer, size) != (ssize_t)size) { + delete[] buffer; + buffer = NULL; + + return ERROR_IO; + } + + uint32_t metadataKey = 0; + switch (mPath[depth]) { + case FOURCC('t', 'i', 't', 'l'): + { + metadataKey = kKeyTitle; + break; + } + case FOURCC('p', 'e', 'r', 'f'): + { + metadataKey = kKeyArtist; + break; + } + case FOURCC('a', 'u', 't', 'h'): + { + metadataKey = kKeyWriter; + break; + } + case FOURCC('g', 'n', 'r', 'e'): + { + metadataKey = kKeyGenre; + break; + } + case FOURCC('a', 'l', 'b', 'm'): + { + if (buffer[size - 1] != '\0') { + char tmp[4]; + sprintf(tmp, "%u", buffer[size - 1]); + + mFileMetaData->setCString(kKeyCDTrackNumber, tmp); + } + + metadataKey = kKeyAlbum; + break; + } + case FOURCC('y', 'r', 'r', 'c'): + { + char tmp[5]; + uint16_t year = U16_AT(&buffer[4]); + + if (year < 10000) { + sprintf(tmp, "%u", year); + + mFileMetaData->setCString(kKeyYear, tmp); + } + break; + } + + default: + break; + } + + if (metadataKey > 0) { + bool isUTF8 = true; // Common case + char16_t *framedata = NULL; + int len16 = 0; // Number of UTF-16 characters + + // smallest possible valid UTF-16 string w BOM: 0xfe 0xff 0x00 0x00 + if (size - 6 >= 4) { + len16 = ((size - 6) / 2) - 1; // don't include 0x0000 terminator + framedata = (char16_t *)(buffer + 6); + if (0xfffe == *framedata) { + // endianness marker (BOM) doesn't match host endianness + for (int i = 0; i < len16; i++) { + framedata[i] = bswap_16(framedata[i]); + } + // BOM is now swapped to 0xfeff, we will execute next block too + } + + if (0xfeff == *framedata) { + // Remove the BOM + framedata++; + len16--; + isUTF8 = false; + } + // else normal non-zero-length UTF-8 string + // we can't handle UTF-16 without BOM as there is no other + // indication of encoding. + } + + if (isUTF8) { + mFileMetaData->setCString(metadataKey, (const char *)buffer + 6); + } else { + // Convert from UTF-16 string to UTF-8 string. + String8 tmpUTF8str(framedata, len16); + mFileMetaData->setCString(metadataKey, tmpUTF8str.string()); + } + } + + delete[] buffer; + buffer = NULL; + + return OK; +} + +void MPEG4Extractor::parseID3v2MetaData(off64_t offset) { + ID3 id3(mDataSource, true /* ignorev1 */, offset); + + if (id3.isValid()) { + struct Map { + int key; + const char *tag1; + const char *tag2; + }; + static const Map kMap[] = { + { kKeyAlbum, "TALB", "TAL" }, + { kKeyArtist, "TPE1", "TP1" }, + { kKeyAlbumArtist, "TPE2", "TP2" }, + { kKeyComposer, "TCOM", "TCM" }, + { kKeyGenre, "TCON", "TCO" }, + { kKeyTitle, "TIT2", "TT2" }, + { kKeyYear, "TYE", "TYER" }, + { kKeyAuthor, "TXT", "TEXT" }, + { kKeyCDTrackNumber, "TRK", "TRCK" }, + { kKeyDiscNumber, "TPA", "TPOS" }, + { kKeyCompilation, "TCP", "TCMP" }, + }; + static const size_t kNumMapEntries = sizeof(kMap) / sizeof(kMap[0]); + + for (size_t i = 0; i < kNumMapEntries; ++i) { + if (!mFileMetaData->hasData(kMap[i].key)) { + ID3::Iterator *it = new ID3::Iterator(id3, kMap[i].tag1); + if (it->done()) { + delete it; + it = new ID3::Iterator(id3, kMap[i].tag2); + } + + if (it->done()) { + delete it; + continue; + } + + String8 s; + it->getString(&s); + delete it; + + mFileMetaData->setCString(kMap[i].key, s); + } + } + + size_t dataSize; + String8 mime; + const void *data = id3.getAlbumArt(&dataSize, &mime); + + if (data) { + mFileMetaData->setData(kKeyAlbumArt, MetaData::TYPE_NONE, data, dataSize); + mFileMetaData->setCString(kKeyAlbumArtMIME, mime.string()); + } + } +} + sp<MediaSource> MPEG4Extractor::getTrack(size_t index) { status_t err; if ((err = readMetaData()) != OK) { diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index 42885dd..2f1f449 100644 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -16,6 +16,7 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "MPEG4Writer" +#include <inttypes.h> #include <utils/Log.h> #include <arpa/inet.h> @@ -419,7 +420,7 @@ status_t MPEG4Writer::Track::dump( result.append(buffer); snprintf(buffer, SIZE, " frames encoded : %d\n", mStszTableEntries->count()); result.append(buffer); - snprintf(buffer, SIZE, " duration encoded : %lld us\n", mTrackDurationUs); + snprintf(buffer, SIZE, " duration encoded : %" PRId64 " us\n", mTrackDurationUs); result.append(buffer); ::write(fd, result.string(), result.size()); return OK; @@ -1406,7 +1407,7 @@ void MPEG4Writer::Track::addOneSttsTableEntry( size_t sampleCount, int32_t duration) { if (duration == 0) { - ALOGW("0-duration samples found: %d", sampleCount); + ALOGW("0-duration samples found: %zu", sampleCount); } mSttsTableEntries->add(htonl(sampleCount)); mSttsTableEntries->add(htonl(duration)); @@ -1586,7 +1587,7 @@ void MPEG4Writer::writeAllChunks() { sendSessionSummary(); mChunkInfos.clear(); - ALOGD("%d chunks are written in the last batch", outstandingChunks); + ALOGD("%zu chunks are written in the last batch", outstandingChunks); } bool MPEG4Writer::findChunkToWrite(Chunk *chunk) { @@ -1776,7 +1777,7 @@ status_t MPEG4Writer::Track::stop() { void *dummy; pthread_join(mThread, &dummy); - status_t err = (status_t) dummy; + status_t err = static_cast<status_t>(reinterpret_cast<uintptr_t>(dummy)); ALOGD("Stopping %s track source", mIsAudio? "Audio": "Video"); { @@ -1799,7 +1800,7 @@ void *MPEG4Writer::Track::ThreadWrapper(void *me) { Track *track = static_cast<Track *>(me); status_t err = track->threadEntry(); - return (void *) err; + return (void *)(uintptr_t)err; } static void getNalUnitType(uint8_t byte, uint8_t* type) { @@ -1871,7 +1872,7 @@ status_t MPEG4Writer::Track::copyAVCCodecSpecificData( // 2 bytes for each of the parameter set length field // plus the 7 bytes for the header if (size < 4 + 7) { - ALOGE("Codec specific data length too short: %d", size); + ALOGE("Codec specific data length too short: %zu", size); return ERROR_MALFORMED; } @@ -1940,7 +1941,7 @@ status_t MPEG4Writer::Track::parseAVCCodecSpecificData( } if (nSeqParamSets > 0x1F) { - ALOGE("Too many seq parameter sets (%d) found", nSeqParamSets); + ALOGE("Too many seq parameter sets (%zu) found", nSeqParamSets); return ERROR_MALFORMED; } } @@ -1953,7 +1954,7 @@ status_t MPEG4Writer::Track::parseAVCCodecSpecificData( return ERROR_MALFORMED; } if (nPicParamSets > 0xFF) { - ALOGE("Too many pic parameter sets (%d) found", nPicParamSets); + ALOGE("Too many pic parameter sets (%zd) found", nPicParamSets); return ERROR_MALFORMED; } } @@ -1983,7 +1984,7 @@ status_t MPEG4Writer::Track::makeAVCCodecSpecificData( } if (size < 4) { - ALOGE("Codec specific data length too short: %d", size); + ALOGE("Codec specific data length too short: %zu", size); return ERROR_MALFORMED; } diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index c36dd7c..c4c47b3 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -746,6 +746,10 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { CHECK(msg->findInt32("width", &width)); CHECK(msg->findInt32("height", &height)); + int32_t cropLeft, cropTop, cropRight, cropBottom; + CHECK(msg->findRect("crop", + &cropLeft, &cropTop, &cropRight, &cropBottom)); + int32_t colorFormat; CHECK(msg->findInt32( "color-format", &colorFormat)); @@ -753,6 +757,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { sp<MetaData> meta = new MetaData; meta->setInt32(kKeyWidth, width); meta->setInt32(kKeyHeight, height); + meta->setRect(kKeyCropRect, + cropLeft, cropTop, cropRight, cropBottom); meta->setInt32(kKeyColorFormat, colorFormat); mSoftRenderer = @@ -1674,7 +1680,7 @@ status_t MediaCodec::onReleaseOutputBuffer(const sp<AMessage> &msg) { return -EACCES; } - if (render && (info->mData == NULL || info->mData->size() != 0)) { + if (render && info->mData != NULL && info->mData->size() != 0) { info->mNotify->setInt32("render", true); if (mSoftRenderer != NULL) { diff --git a/media/libstagefright/MetaData.cpp b/media/libstagefright/MetaData.cpp index 7b60afc..74234a6 100644 --- a/media/libstagefright/MetaData.cpp +++ b/media/libstagefright/MetaData.cpp @@ -16,6 +16,7 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "MetaData" +#include <inttypes.h> #include <utils/Log.h> #include <stdlib.h> @@ -221,6 +222,16 @@ bool MetaData::findData(uint32_t key, uint32_t *type, return true; } +bool MetaData::hasData(uint32_t key) const { + ssize_t i = mItems.indexOfKey(key); + + if (i < 0) { + return false; + } + + return true; +} + MetaData::typed_data::typed_data() : mType(0), mSize(0) { @@ -297,7 +308,7 @@ String8 MetaData::typed_data::asString() const { const void *data = storage(); switch(mType) { case TYPE_NONE: - out = String8::format("no type, size %d)", mSize); + out = String8::format("no type, size %zu)", mSize); break; case TYPE_C_STRING: out = String8::format("(char*) %s", (const char *)data); @@ -306,7 +317,7 @@ String8 MetaData::typed_data::asString() const { out = String8::format("(int32_t) %d", *(int32_t *)data); break; case TYPE_INT64: - out = String8::format("(int64_t) %lld", *(int64_t *)data); + out = String8::format("(int64_t) %" PRId64, *(int64_t *)data); break; case TYPE_FLOAT: out = String8::format("(float) %f", *(float *)data); @@ -323,7 +334,7 @@ String8 MetaData::typed_data::asString() const { } default: - out = String8::format("(unknown type %d, size %d)", mType, mSize); + out = String8::format("(unknown type %d, size %zu)", mType, mSize); if (mSize <= 48) { // if it's less than three lines of hex data, dump it AString foo; hexdump(data, mSize, 0, &foo); diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp index 19af4fb..fcd9a85 100644 --- a/media/libstagefright/StagefrightMetadataRetriever.cpp +++ b/media/libstagefright/StagefrightMetadataRetriever.cpp @@ -16,6 +16,7 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "StagefrightMetadataRetriever" +#include <inttypes.h> #include <utils/Log.h> #include "include/StagefrightMetadataRetriever.h" @@ -488,7 +489,7 @@ void StagefrightMetadataRetriever::parseMetaData() { size_t numTracks = mExtractor->countTracks(); char tmp[32]; - sprintf(tmp, "%d", numTracks); + sprintf(tmp, "%zu", numTracks); mMetaData.add(METADATA_KEY_NUM_TRACKS, String8(tmp)); @@ -545,7 +546,7 @@ void StagefrightMetadataRetriever::parseMetaData() { } // The duration value is a string representing the duration in ms. - sprintf(tmp, "%lld", (maxDurationUs + 500) / 1000); + sprintf(tmp, "%" PRId64, (maxDurationUs + 500) / 1000); mMetaData.add(METADATA_KEY_DURATION, String8(tmp)); if (hasAudio) { @@ -573,7 +574,7 @@ void StagefrightMetadataRetriever::parseMetaData() { if (mSource->getSize(&sourceSize) == OK) { int64_t avgBitRate = (int64_t)(sourceSize * 8E6 / maxDurationUs); - sprintf(tmp, "%lld", avgBitRate); + sprintf(tmp, "%" PRId64, avgBitRate); mMetaData.add(METADATA_KEY_BITRATE, String8(tmp)); } } diff --git a/media/libstagefright/TimedEventQueue.cpp b/media/libstagefright/TimedEventQueue.cpp index dedd186..0afac69 100644 --- a/media/libstagefright/TimedEventQueue.cpp +++ b/media/libstagefright/TimedEventQueue.cpp @@ -318,7 +318,7 @@ sp<TimedEventQueue::Event> TimedEventQueue::removeEventFromQueue_l( void TimedEventQueue::acquireWakeLock_l() { - if (mWakeLockCount++ == 0) { + if (mWakeLockCount == 0) { CHECK(mWakeLockToken == 0); if (mPowerManager == 0) { // use checkService() to avoid blocking if power service is not up yet @@ -341,21 +341,23 @@ void TimedEventQueue::acquireWakeLock_l() IPCThreadState::self()->restoreCallingIdentity(token); if (status == NO_ERROR) { mWakeLockToken = binder; + mWakeLockCount++; } } + } else { + mWakeLockCount++; } } void TimedEventQueue::releaseWakeLock_l(bool force) { + if (mWakeLockCount == 0) { + return; + } if (force) { - if (mWakeLockCount == 0) { - return; - } // Force wakelock release below by setting reference count to 1. mWakeLockCount = 1; } - CHECK(mWakeLockCount != 0); if (--mWakeLockCount == 0) { CHECK(mWakeLockToken != 0); if (mPowerManager != 0) { diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp index 5ae80cc..bc48272 100644 --- a/media/libstagefright/WVMExtractor.cpp +++ b/media/libstagefright/WVMExtractor.cpp @@ -76,7 +76,7 @@ static void init_routine() { gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW); if (gVendorLibHandle == NULL) { - ALOGE("Failed to open libwvm.so"); + ALOGE("Failed to open libwvm.so: %s", dlerror()); } } diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp index 1d66120..1d398fb 100644 --- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp +++ b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp @@ -593,6 +593,17 @@ OMX_ERRORTYPE SoftAVCEncoder::internalSetParameter( mVideoHeight = def->format.video.nFrameHeight; mVideoFrameRate = def->format.video.xFramerate >> 16; mVideoColorFormat = def->format.video.eColorFormat; + + OMX_PARAM_PORTDEFINITIONTYPE *portDef = + &editPortInfo(0)->mDef; + portDef->format.video.nFrameWidth = mVideoWidth; + portDef->format.video.nFrameHeight = mVideoHeight; + portDef->format.video.xFramerate = def->format.video.xFramerate; + portDef->format.video.eColorFormat = + (OMX_COLOR_FORMATTYPE) mVideoColorFormat; + portDef = &editPortInfo(1)->mDef; + portDef->format.video.nFrameWidth = mVideoWidth; + portDef->format.video.nFrameHeight = mVideoHeight; } else { mVideoBitRate = def->format.video.nBitrate; } @@ -871,7 +882,13 @@ void SoftAVCEncoder::onQueueFilled(OMX_U32 portIndex) { CHECK(encoderStatus == AVCENC_SUCCESS || encoderStatus == AVCENC_NEW_IDR); dataLength = outHeader->nAllocLen; // Reset the output buffer length if (inHeader->nFilledLen > 0) { + if (outHeader->nAllocLen >= 4) { + memcpy(outPtr, "\x00\x00\x00\x01", 4); + outPtr += 4; + dataLength -= 4; + } encoderStatus = PVAVCEncodeNAL(mHandle, outPtr, &dataLength, &type); + dataLength = outPtr + dataLength - outHeader->pBuffer; if (encoderStatus == AVCENC_SUCCESS) { CHECK(NULL == PVAVCEncGetOverrunBuffer(mHandle)); } else if (encoderStatus == AVCENC_PICTURE_READY) { diff --git a/media/libstagefright/codecs/avc/enc/src/bitstream_io.cpp b/media/libstagefright/codecs/avc/enc/src/bitstream_io.cpp index 0e3037f..d71c327 100644 --- a/media/libstagefright/codecs/avc/enc/src/bitstream_io.cpp +++ b/media/libstagefright/codecs/avc/enc/src/bitstream_io.cpp @@ -103,6 +103,15 @@ AVCEnc_Status AVCBitstreamSaveWord(AVCEncBitstream *stream) { num_bits -= 8; byte = (current_word >> num_bits) & 0xFF; + if (stream->count_zeros == 2) + { /* for num_bits = 32, this can add 2 more bytes extra for EPBS */ + if (byte <= 3) + { + *write_pnt++ = 0x3; + stream->write_pos++; + stream->count_zeros = 0; + } + } if (byte != 0) { *write_pnt++ = byte; @@ -114,12 +123,6 @@ AVCEnc_Status AVCBitstreamSaveWord(AVCEncBitstream *stream) stream->count_zeros++; *write_pnt++ = byte; stream->write_pos++; - if (stream->count_zeros == 2) - { /* for num_bits = 32, this can add 2 more bytes extra for EPBS */ - *write_pnt++ = 0x3; - stream->write_pos++; - stream->count_zeros = 0; - } } } diff --git a/media/libstagefright/codecs/common/Config.mk b/media/libstagefright/codecs/common/Config.mk index a6d4286..a843cef 100644 --- a/media/libstagefright/codecs/common/Config.mk +++ b/media/libstagefright/codecs/common/Config.mk @@ -14,8 +14,10 @@ VOTT := pc endif # Do we also need to check on ARCH_ARM_HAVE_ARMV7A? - probably not -ifeq ($(ARCH_ARM_HAVE_NEON),true) -VOTT := v7 +ifeq ($(TARGET_ARCH),arm) + ifeq ($(ARCH_ARM_HAVE_NEON),true) + VOTT := v7 + endif endif VOTEST := 0 diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/get_pred_adv_b_add.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/get_pred_adv_b_add.cpp index e23f23d..fe9e7dc 100644 --- a/media/libstagefright/codecs/m4v_h263/dec/src/get_pred_adv_b_add.cpp +++ b/media/libstagefright/codecs/m4v_h263/dec/src/get_pred_adv_b_add.cpp @@ -96,7 +96,7 @@ int GetPredAdvancedBy0x0( offset = width - B_SIZE; /* offset for prev */ offset2 = (pred_width_rnd >> 1) - 4; /* offset for pred_block */ - tmp = (uint32)prev & 0x3; + tmp = (uintptr_t)prev & 0x3; pred_block -= offset2; /* preset */ if (tmp == 0) /* word-aligned */ @@ -203,7 +203,7 @@ int GetPredAdvancedBy0x1( /* Branch based on pixel location (half-pel or full-pel) for x and y */ pred_block -= offset2; /* preset */ - tmp = (uint32)prev & 3; + tmp = (uintptr_t)prev & 3; mask = 254; mask |= (mask << 8); mask |= (mask << 16); /* 0xFEFEFEFE */ @@ -532,7 +532,7 @@ int GetPredAdvancedBy1x0( /* Branch based on pixel location (half-pel or full-pel) for x and y */ pred_block -= offset2; /* preset */ - tmp = (uint32)prev & 3; + tmp = (uintptr_t)prev & 3; mask = 254; mask |= (mask << 8); mask |= (mask << 16); /* 0xFEFEFEFE */ @@ -884,7 +884,7 @@ int GetPredAdvancedBy1x1( mask |= (mask << 8); mask |= (mask << 16); /* 0x3f3f3f3f */ - tmp = (uint32)prev & 3; + tmp = (uintptr_t)prev & 3; pred_block -= 4; /* preset */ diff --git a/media/libstagefright/codecs/m4v_h263/enc/src/dct.cpp b/media/libstagefright/codecs/m4v_h263/enc/src/dct.cpp index fa50eeb..fa4ae23 100644 --- a/media/libstagefright/codecs/m4v_h263/enc/src/dct.cpp +++ b/media/libstagefright/codecs/m4v_h263/enc/src/dct.cpp @@ -250,7 +250,7 @@ extern "C" out[40] = k4 ; /* row 5 */ out++; } - while ((UInt)out < (UInt)dst) ; + while ((uintptr_t)out < (uintptr_t)dst) ; return ; } @@ -455,7 +455,7 @@ extern "C" out[8] = k5 ; /* row 1 */ out++; } - while ((UInt)out < (UInt)dst) ; + while ((uintptr_t)out < (uintptr_t)dst) ; return ; } @@ -635,7 +635,7 @@ extern "C" out[8] = k5 ; /* row 1 */ out++; } - while ((UInt)out < (UInt)dst) ; + while ((uintptr_t)out < (uintptr_t)dst) ; return ; } @@ -846,7 +846,7 @@ extern "C" out[40] = k4 ; /* row 5 */ out++; } - while ((UInt)out < (UInt)dst) ; + while ((uintptr_t)out < (uintptr_t)dst) ; return ; } @@ -1033,7 +1033,7 @@ extern "C" out[8] = k5 ; /* row 1 */ out++; } - while ((UInt)out < (UInt)dst) ; + while ((uintptr_t)out < (uintptr_t)dst) ; return ; } @@ -1195,7 +1195,7 @@ extern "C" out[8] = k5 ; /* row 1 */ out++; } - while ((UInt)out < (UInt)dst) ; + while ((uintptr_t)out < (uintptr_t)dst) ; return ; } diff --git a/media/libstagefright/codecs/m4v_h263/enc/src/fastcodemb.cpp b/media/libstagefright/codecs/m4v_h263/enc/src/fastcodemb.cpp index 6fd41c3..0ad39a6 100644 --- a/media/libstagefright/codecs/m4v_h263/enc/src/fastcodemb.cpp +++ b/media/libstagefright/codecs/m4v_h263/enc/src/fastcodemb.cpp @@ -572,7 +572,7 @@ Int Sad8x8(UChar *cur, UChar *prev, Int width) cur2 = cur2 & (mask << 8); /* mask first and third bytes */ sum2 = sum2 + ((UInt)cur2 >> 8); } - while ((UInt)curInt < (UInt)end); + while ((uintptr_t)curInt < (uintptr_t)end); cur1 = sum4 - (sum2 << 8); /* get even-sum */ cur1 = cur1 + sum2; /* add 16 bit even-sum and odd-sum*/ @@ -611,7 +611,7 @@ Int getBlockSum(UChar *cur, Int width) load2 = load2 & (mask << 8); /* even bytes */ sum2 += ((UInt)load2 >> 8); /* sum even bytes, 16 bit */ } - while ((UInt)curInt < (UInt)end); + while ((uintptr_t)curInt < (uintptr_t)end); load1 = sum4 - (sum2 << 8); /* get even-sum */ load1 = load1 + sum2; /* add 16 bit even-sum and odd-sum*/ load1 = load1 + (load1 << 16); /* add upper and lower 16 bit sum */ diff --git a/media/libstagefright/codecs/m4v_h263/enc/src/motion_comp.cpp b/media/libstagefright/codecs/m4v_h263/enc/src/motion_comp.cpp index b81d278..06e8926 100644 --- a/media/libstagefright/codecs/m4v_h263/enc/src/motion_comp.cpp +++ b/media/libstagefright/codecs/m4v_h263/enc/src/motion_comp.cpp @@ -1959,7 +1959,7 @@ void PutSkippedBlock(UChar *rec, UChar *prev, Int lx) dst += offset; src += offset; } - while ((UInt)src < (UInt)end); + while ((uintptr_t)src < (uintptr_t)end); return ; } diff --git a/media/libstagefright/codecs/m4v_h263/enc/src/sad_inline.h b/media/libstagefright/codecs/m4v_h263/enc/src/sad_inline.h index ba77dfd..b865f23 100644 --- a/media/libstagefright/codecs/m4v_h263/enc/src/sad_inline.h +++ b/media/libstagefright/codecs/m4v_h263/enc/src/sad_inline.h @@ -85,7 +85,7 @@ extern "C" x9 = 0x80808080; /* const. */ - x8 = (uint32)ref & 0x3; + x8 = (uintptr_t)ref & 0x3; if (x8 == 3) goto SadMBOffset3; if (x8 == 2) diff --git a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp index 8375cac..5efe022 100644 --- a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp +++ b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp @@ -677,6 +677,9 @@ OMX_ERRORTYPE SoftVPXEncoder::internalSetPortParams( def->format.video.nFrameHeight = mHeight; def->format.video.xFramerate = port->format.video.xFramerate; def->format.video.eColorFormat = mColorFormat; + def = &editPortInfo(kOutputPortIndex)->mDef; + def->format.video.nFrameWidth = mWidth; + def->format.video.nFrameHeight = mHeight; return OMX_ErrorNone; } else if (port->nPortIndex == kOutputPortIndex) { diff --git a/media/libstagefright/codecs/on2/h264dec/Android.mk b/media/libstagefright/codecs/on2/h264dec/Android.mk index 655b2ab..bf03ad9 100644 --- a/media/libstagefright/codecs/on2/h264dec/Android.mk +++ b/media/libstagefright/codecs/on2/h264dec/Android.mk @@ -84,8 +84,8 @@ MY_OMXDL_ASM_SRC := \ ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_DequantTransformResidualFromPairAndAdd_s.S \ ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_TransformDequantChromaDCFromPair_s.S \ - -ifeq ($(ARCH_ARM_HAVE_NEON),true) +ifeq ($(TARGET_ARCH),arm) + ifeq ($(ARCH_ARM_HAVE_NEON),true) LOCAL_ARM_NEON := true # LOCAL_CFLAGS := -std=c99 -D._NEON -D._OMXDL LOCAL_CFLAGS := -DH264DEC_NEON -DH264DEC_OMXDL @@ -94,6 +94,7 @@ ifeq ($(ARCH_ARM_HAVE_NEON),true) LOCAL_C_INCLUDES += $(LOCAL_PATH)/./omxdl/arm_neon/api \ $(LOCAL_PATH)/./omxdl/arm_neon/vc/api \ $(LOCAL_PATH)/./omxdl/arm_neon/vc/m4p10/api + endif endif LOCAL_SHARED_LIBRARIES := \ diff --git a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_intra_prediction.c b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_intra_prediction.c index 15eabfb..52c85e5 100755 --- a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_intra_prediction.c +++ b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_intra_prediction.c @@ -1110,7 +1110,7 @@ void Intra16x16PlanePrediction(u8 *data, u8 *above, u8 *left) /* Variables */ - u32 i, j; + i32 i, j; i32 a, b, c; i32 tmp; @@ -1123,20 +1123,20 @@ void Intra16x16PlanePrediction(u8 *data, u8 *above, u8 *left) a = 16 * (above[15] + left[15]); for (i = 0, b = 0; i < 8; i++) - b += ((i32)i + 1) * (above[8+i] - above[6-i]); + b += (i + 1) * (above[8+i] - above[6-i]); b = (5 * b + 32) >> 6; for (i = 0, c = 0; i < 7; i++) - c += ((i32)i + 1) * (left[8+i] - left[6-i]); + c += (i + 1) * (left[8+i] - left[6-i]); /* p[-1,-1] has to be accessed through above pointer */ - c += ((i32)i + 1) * (left[8+i] - above[-1]); + c += (i + 1) * (left[8+i] - above[-1]); c = (5 * c + 32) >> 6; for (i = 0; i < 16; i++) { for (j = 0; j < 16; j++) { - tmp = (a + b * ((i32)j - 7) + c * ((i32)i - 7) + 16) >> 5; + tmp = (a + b * (j - 7) + c * (i - 7) + 16) >> 5; data[i*16+j] = (u8)CLIP1(tmp); } } diff --git a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_util.h b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_util.h index cb3adda..216ad04 100755 --- a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_util.h +++ b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_util.h @@ -42,6 +42,7 @@ #include <stdio.h> #endif +#include <stdint.h> #include "basetype.h" #include "h264bsd_stream.h" #include "h264bsd_image.h" @@ -150,7 +151,7 @@ } #define ALIGN(ptr, bytePos) \ - (ptr + ( ((bytePos - (int)ptr) & (bytePos - 1)) / sizeof(*ptr) )) + (ptr + ( ((bytePos - (uintptr_t)ptr) & (bytePos - 1)) / sizeof(*ptr) )) extern const u32 h264bsdQpC[52]; diff --git a/media/libstagefright/foundation/ANetworkSession.cpp b/media/libstagefright/foundation/ANetworkSession.cpp index e629588..4cd51d0 100644 --- a/media/libstagefright/foundation/ANetworkSession.cpp +++ b/media/libstagefright/foundation/ANetworkSession.cpp @@ -579,7 +579,7 @@ status_t ANetworkSession::Session::writeMore() { if (err == -EAGAIN) { if (!mOutFragments.empty()) { - ALOGI("%d datagrams remain queued.", mOutFragments.size()); + ALOGI("%zu datagrams remain queued.", mOutFragments.size()); } err = OK; } diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index e53e35a..61c54c1 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -492,7 +492,7 @@ void LiveSession::onConnect(const sp<AMessage> &msg) { mPlaylist = fetchPlaylist(url.c_str(), NULL /* curPlaylistHash */, &dummy); if (mPlaylist == NULL) { - ALOGE("unable to fetch master playlist '%s'.", url.c_str()); + ALOGE("unable to fetch master playlist <URL suppressed>."); postPrepared(ERROR_IO); return; @@ -769,9 +769,6 @@ sp<M3UParser> LiveSession::fetchPlaylist( // playlist unchanged *unchanged = true; - ALOGV("Playlist unchanged, refresh state is now %d", - (int)mRefreshState); - return NULL; } diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp index f211bc8..7b06a2f 100644 --- a/media/libstagefright/httplive/M3UParser.cpp +++ b/media/libstagefright/httplive/M3UParser.cpp @@ -626,7 +626,7 @@ status_t M3UParser::parseMetaDataDuration( if (meta->get() == NULL) { *meta = new AMessage; } - (*meta)->setInt64(key, (int64_t)x * 1E6); + (*meta)->setInt64(key, (int64_t)(x * 1E6)); return OK; } @@ -798,8 +798,7 @@ status_t M3UParser::parseCipherInfo( if (MakeURL(baseURI.c_str(), val.c_str(), &absURI)) { val = absURI; } else { - ALOGE("failed to make absolute url for '%s'.", - val.c_str()); + ALOGE("failed to make absolute url for <URL suppressed>."); } } diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp index 34d671a..1ec4a40 100644 --- a/media/libstagefright/id3/ID3.cpp +++ b/media/libstagefright/id3/ID3.cpp @@ -56,14 +56,14 @@ private: DISALLOW_EVIL_CONSTRUCTORS(MemorySource); }; -ID3::ID3(const sp<DataSource> &source, bool ignoreV1) +ID3::ID3(const sp<DataSource> &source, bool ignoreV1, off64_t offset) : mIsValid(false), mData(NULL), mSize(0), mFirstFrameOffset(0), mVersion(ID3_UNKNOWN), mRawSize(0) { - mIsValid = parseV2(source); + mIsValid = parseV2(source, offset); if (!mIsValid && !ignoreV1) { mIsValid = parseV1(source); @@ -79,7 +79,7 @@ ID3::ID3(const uint8_t *data, size_t size, bool ignoreV1) mRawSize(0) { sp<MemorySource> source = new MemorySource(data, size); - mIsValid = parseV2(source); + mIsValid = parseV2(source, 0); if (!mIsValid && !ignoreV1) { mIsValid = parseV1(source); @@ -115,7 +115,7 @@ bool ID3::ParseSyncsafeInteger(const uint8_t encoded[4], size_t *x) { return true; } -bool ID3::parseV2(const sp<DataSource> &source) { +bool ID3::parseV2(const sp<DataSource> &source, off64_t offset) { struct id3_header { char id[3]; uint8_t version_major; @@ -126,7 +126,7 @@ struct id3_header { id3_header header; if (source->readAt( - 0, &header, sizeof(header)) != (ssize_t)sizeof(header)) { + offset, &header, sizeof(header)) != (ssize_t)sizeof(header)) { return false; } @@ -185,7 +185,7 @@ struct id3_header { mSize = size; mRawSize = mSize + sizeof(header); - if (source->readAt(sizeof(header), mData, mSize) != (ssize_t)mSize) { + if (source->readAt(offset + sizeof(header), mData, mSize) != (ssize_t)mSize) { free(mData); mData = NULL; diff --git a/media/libstagefright/id3/testid3.cpp b/media/libstagefright/id3/testid3.cpp index bc4572c..b2f4188 100644 --- a/media/libstagefright/id3/testid3.cpp +++ b/media/libstagefright/id3/testid3.cpp @@ -33,7 +33,7 @@ static void hexdump(const void *_data, size_t size) { const uint8_t *data = (const uint8_t *)_data; size_t offset = 0; while (offset < size) { - printf("0x%04x ", offset); + printf("0x%04zx ", offset); size_t n = size - offset; if (n > 16) { @@ -101,7 +101,7 @@ void scanFile(const char *path) { const void *data = tag.getAlbumArt(&dataSize, &mime); if (data) { - printf("found album art: size=%d mime='%s'\n", dataSize, + printf("found album art: size=%zu mime='%s'\n", dataSize, mime.string()); hexdump(data, dataSize > 128 ? 128 : dataSize); diff --git a/media/libstagefright/include/ID3.h b/media/libstagefright/include/ID3.h index cca83ab..e83f3ef 100644 --- a/media/libstagefright/include/ID3.h +++ b/media/libstagefright/include/ID3.h @@ -35,7 +35,7 @@ struct ID3 { ID3_V2_4, }; - ID3(const sp<DataSource> &source, bool ignoreV1 = false); + ID3(const sp<DataSource> &source, bool ignoreV1 = false, off64_t offset = 0); ID3(const uint8_t *data, size_t size, bool ignoreV1 = false); ~ID3(); @@ -86,7 +86,7 @@ private: size_t mRawSize; bool parseV1(const sp<DataSource> &source); - bool parseV2(const sp<DataSource> &source); + bool parseV2(const sp<DataSource> &source, off64_t offset); void removeUnsynchronization(); bool removeUnsynchronizationV2_4(bool iTunesHack); diff --git a/media/libstagefright/include/MPEG4Extractor.h b/media/libstagefright/include/MPEG4Extractor.h index bbec1c4..7b4bc6d 100644 --- a/media/libstagefright/include/MPEG4Extractor.h +++ b/media/libstagefright/include/MPEG4Extractor.h @@ -95,7 +95,9 @@ private: status_t readMetaData(); status_t parseChunk(off64_t *offset, int depth); - status_t parseMetaData(off64_t offset, size_t size); + status_t parseITunesMetaData(off64_t offset, size_t size); + status_t parse3GPPMetaData(off64_t offset, size_t size, int depth); + void parseID3v2MetaData(off64_t offset); status_t updateAudioTrackInfoFromESDS_MPEG4Audio( const void *esds_data, size_t esds_size); diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp index 8f9c9c8..e0ff0d1 100644 --- a/media/libstagefright/mpeg2ts/ESQueue.cpp +++ b/media/libstagefright/mpeg2ts/ESQueue.cpp @@ -604,7 +604,9 @@ sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitH264() { dstOffset += pos.nalSize + 4; } +#if !LOG_NDEBUG ALOGV("accessUnit contains nal types %s", out.c_str()); +#endif const NALPosition &pos = nals.itemAt(nals.size() - 1); size_t nextScan = pos.nalOffset + pos.nalSize; diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp index 84a0e10..274f2eb 100644 --- a/media/libstagefright/omx/OMX.cpp +++ b/media/libstagefright/omx/OMX.cpp @@ -479,7 +479,7 @@ OMX_ERRORTYPE OMX::OnFillBufferDone( OMX::node_id OMX::makeNodeID(OMXNodeInstance *instance) { // mLock is already held. - node_id node = (node_id)++mNodeCounter; + node_id node = (node_id)(uintptr_t)++mNodeCounter; mNodeIDToInstance.add(node, instance); return node; diff --git a/media/libstagefright/omx/tests/Android.mk b/media/libstagefright/omx/tests/Android.mk index 1061c39..e368134 100644 --- a/media/libstagefright/omx/tests/Android.mk +++ b/media/libstagefright/omx/tests/Android.mk @@ -15,4 +15,6 @@ LOCAL_MODULE := omx_tests LOCAL_MODULE_TAGS := tests +LOCAL_32_BIT_ONLY := true + include $(BUILD_EXECUTABLE) diff --git a/media/libstagefright/omx/tests/OMXHarness.cpp b/media/libstagefright/omx/tests/OMXHarness.cpp index 4bee808..44e4f9d 100644 --- a/media/libstagefright/omx/tests/OMXHarness.cpp +++ b/media/libstagefright/omx/tests/OMXHarness.cpp @@ -16,6 +16,7 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "OMXHarness" +#include <inttypes.h> #include <utils/Log.h> #include "OMXHarness.h" @@ -711,11 +712,11 @@ status_t Harness::testSeek( int64_t bufferTimeUs; CHECK(buffer->meta_data()->findInt64(kKeyTime, &bufferTimeUs)); if (!CloseEnough(bufferTimeUs, actualSeekTimeUs)) { - printf("\n * Attempted seeking to %lld us (%.2f secs)", + printf("\n * Attempted seeking to %" PRId64 " us (%.2f secs)", requestedSeekTimeUs, requestedSeekTimeUs / 1E6); - printf("\n * Nearest keyframe is at %lld us (%.2f secs)", + printf("\n * Nearest keyframe is at %" PRId64 " us (%.2f secs)", actualSeekTimeUs, actualSeekTimeUs / 1E6); - printf("\n * Returned buffer was at %lld us (%.2f secs)\n\n", + printf("\n * Returned buffer was at %" PRId64 " us (%.2f secs)\n\n", bufferTimeUs, bufferTimeUs / 1E6); buffer->release(); diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp index 5116550..492bd4a 100644 --- a/media/libstagefright/rtsp/ARTSPConnection.cpp +++ b/media/libstagefright/rtsp/ARTSPConnection.cpp @@ -239,7 +239,7 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) { // right here, since we currently have no way of asking the user // for this information. - ALOGE("Malformed rtsp url %s", url.c_str()); + ALOGE("Malformed rtsp url <URL suppressed>"); reply->setInt32("result", ERROR_MALFORMED); reply->post(); @@ -489,7 +489,6 @@ void ARTSPConnection::onReceiveResponse() { FD_SET(mSocket, &rs); int res = select(mSocket + 1, &rs, NULL, NULL, &tv); - CHECK_GE(res, 0); if (res == 1) { MakeSocketBlocking(mSocket, true); diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h index f4b5846..e7580c2 100644 --- a/media/libstagefright/rtsp/MyHandler.h +++ b/media/libstagefright/rtsp/MyHandler.h @@ -149,7 +149,7 @@ struct MyHandler : public AHandler { mSessionURL.append(StringPrintf("%u", port)); mSessionURL.append(path); - ALOGI("rewritten session url: '%s'", mSessionURL.c_str()); + ALOGV("rewritten session url: '%s'", mSessionURL.c_str()); } mSessionHost = host; @@ -478,21 +478,32 @@ struct MyHandler : public AHandler { sp<ARTSPResponse> response = static_cast<ARTSPResponse *>(obj.get()); - if (response->mStatusCode == 302) { + if (response->mStatusCode == 301 || response->mStatusCode == 302) { ssize_t i = response->mHeaders.indexOfKey("location"); CHECK_GE(i, 0); - mSessionURL = response->mHeaders.valueAt(i); - - AString request; - request = "DESCRIBE "; - request.append(mSessionURL); - request.append(" RTSP/1.0\r\n"); - request.append("Accept: application/sdp\r\n"); - request.append("\r\n"); + mOriginalSessionURL = response->mHeaders.valueAt(i); + mSessionURL = mOriginalSessionURL; + + // Strip any authentication info from the session url, we don't + // want to transmit user/pass in cleartext. + AString host, path, user, pass; + unsigned port; + if (ARTSPConnection::ParseURL( + mSessionURL.c_str(), &host, &port, &path, &user, &pass) + && user.size() > 0) { + mSessionURL.clear(); + mSessionURL.append("rtsp://"); + mSessionURL.append(host); + mSessionURL.append(":"); + mSessionURL.append(StringPrintf("%u", port)); + mSessionURL.append(path); + + ALOGI("rewritten session url: '%s'", mSessionURL.c_str()); + } - sp<AMessage> reply = new AMessage('desc', id()); - mConn->sendRequest(request.c_str(), reply); + sp<AMessage> reply = new AMessage('conn', id()); + mConn->connect(mOriginalSessionURL.c_str(), reply); break; } @@ -686,23 +697,27 @@ struct MyHandler : public AHandler { i = response->mHeaders.indexOfKey("transport"); CHECK_GE(i, 0); - if (!track->mUsingInterleavedTCP) { - AString transport = response->mHeaders.valueAt(i); - - // We are going to continue even if we were - // unable to poke a hole into the firewall... - pokeAHole( - track->mRTPSocket, - track->mRTCPSocket, - transport); - } + if (track->mRTPSocket != -1 && track->mRTCPSocket != -1) { + if (!track->mUsingInterleavedTCP) { + AString transport = response->mHeaders.valueAt(i); - mRTPConn->addStream( - track->mRTPSocket, track->mRTCPSocket, - mSessionDesc, index, - notify, track->mUsingInterleavedTCP); + // We are going to continue even if we were + // unable to poke a hole into the firewall... + pokeAHole( + track->mRTPSocket, + track->mRTCPSocket, + transport); + } + + mRTPConn->addStream( + track->mRTPSocket, track->mRTCPSocket, + mSessionDesc, index, + notify, track->mUsingInterleavedTCP); - mSetupTracksSuccessful = true; + mSetupTracksSuccessful = true; + } else { + result = BAD_VALUE; + } } } @@ -726,7 +741,7 @@ struct MyHandler : public AHandler { } ++index; - if (index < mSessionDesc->countTracks()) { + if (result == OK && index < mSessionDesc->countTracks()) { setupTrack(index); } else if (mSetupTracksSuccessful) { ++mKeepAliveGeneration; @@ -1559,6 +1574,8 @@ private: info->mUsingInterleavedTCP = false; info->mFirstSeqNumInSegment = 0; info->mNewSegment = true; + info->mRTPSocket = -1; + info->mRTCPSocket = -1; info->mRTPAnchor = 0; info->mNTPAnchorUs = -1; info->mNormalPlayTimeRTP = 0; diff --git a/media/libstagefright/rtsp/SDPLoader.cpp b/media/libstagefright/rtsp/SDPLoader.cpp index ed3fa7e..3c7d82a 100644 --- a/media/libstagefright/rtsp/SDPLoader.cpp +++ b/media/libstagefright/rtsp/SDPLoader.cpp @@ -95,7 +95,7 @@ void SDPLoader::onLoad(const sp<AMessage> &msg) { msg->findPointer("headers", (void **)&headers); if (!(mFlags & kFlagIncognito)) { - ALOGI("onLoad '%s'", url.c_str()); + ALOGV("onLoad '%s'", url.c_str()); } else { ALOGI("onLoad <URL suppressed>"); } diff --git a/media/libstagefright/tests/Android.mk b/media/libstagefright/tests/Android.mk index 06ce16b..903af49 100644 --- a/media/libstagefright/tests/Android.mk +++ b/media/libstagefright/tests/Android.mk @@ -41,6 +41,8 @@ LOCAL_C_INCLUDES := \ frameworks/av/media/libstagefright/include \ $(TOP)/frameworks/native/include/media/openmax \ +LOCAL_32_BIT_ONLY := true + include $(BUILD_EXECUTABLE) endif diff --git a/media/libstagefright/tests/DummyRecorder.cpp b/media/libstagefright/tests/DummyRecorder.cpp index ac37b28..8f17088 100644 --- a/media/libstagefright/tests/DummyRecorder.cpp +++ b/media/libstagefright/tests/DummyRecorder.cpp @@ -61,7 +61,7 @@ status_t DummyRecorder::stop() { mSource->stop(); void *dummy; pthread_join(mThread, &dummy); - status_t err = (status_t) dummy; + status_t err = static_cast<status_t>(reinterpret_cast<uintptr_t>(dummy)); ALOGV("Ending the reading thread"); return err; diff --git a/media/libstagefright/wifi-display/source/TSPacketizer.cpp b/media/libstagefright/wifi-display/source/TSPacketizer.cpp index eeb3700..50d317a 100644 --- a/media/libstagefright/wifi-display/source/TSPacketizer.cpp +++ b/media/libstagefright/wifi-display/source/TSPacketizer.cpp @@ -565,7 +565,7 @@ status_t TSPacketizer::packetize( } } - // size_t numPaddingBytes = sizeAvailableForPayload - numBytesOfPayload; + size_t numPaddingBytes = sizeAvailableForPayload - numBytesOfPayload; ALOGV("packet 1 contains %zd padding bytes and %zd bytes of payload", numPaddingBytes, numBytesOfPayload); |