diff options
author | Andreas Huber <andih@google.com> | 2010-09-21 13:13:15 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-09-21 15:12:19 -0700 |
commit | 6e4c5c499999c04c2477b987f9e64f3ff2bf1a06 (patch) | |
tree | d19a0fc9db90d33a693f0e64cc79c31f38d414c4 /media/libstagefright/rtsp | |
parent | 425587d4566c1667448bf91fa452b4def8b6cedb (diff) | |
download | frameworks_av-6e4c5c499999c04c2477b987f9e64f3ff2bf1a06.zip frameworks_av-6e4c5c499999c04c2477b987f9e64f3ff2bf1a06.tar.gz frameworks_av-6e4c5c499999c04c2477b987f9e64f3ff2bf1a06.tar.bz2 |
Remove stagefright foundation's incompatible logging interface and update callsites.
Change-Id: I45fba7d60530ea0f233ac3695a97306b6dc1795c
Diffstat (limited to 'media/libstagefright/rtsp')
-rw-r--r-- | media/libstagefright/rtsp/AAMRAssembler.cpp | 16 | ||||
-rw-r--r-- | media/libstagefright/rtsp/AAVCAssembler.cpp | 61 | ||||
-rw-r--r-- | media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp | 16 | ||||
-rw-r--r-- | media/libstagefright/rtsp/APacketSource.cpp | 15 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPConnection.cpp | 21 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPSession.cpp | 24 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPSource.cpp | 103 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPSource.h | 1 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPWriter.cpp | 26 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTSPConnection.cpp | 28 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ASessionDescription.cpp | 13 | ||||
-rw-r--r-- | media/libstagefright/rtsp/MyHandler.h | 70 | ||||
-rw-r--r-- | media/libstagefright/rtsp/UDPPusher.cpp | 12 | ||||
-rw-r--r-- | media/libstagefright/rtsp/rtp_test.cpp | 7 |
14 files changed, 179 insertions, 234 deletions
diff --git a/media/libstagefright/rtsp/AAMRAssembler.cpp b/media/libstagefright/rtsp/AAMRAssembler.cpp index 154ba31..b1f6e9a 100644 --- a/media/libstagefright/rtsp/AAMRAssembler.cpp +++ b/media/libstagefright/rtsp/AAMRAssembler.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "AAMRAssembler" +#include <utils/Log.h> + #include "AAMRAssembler.h" #include "ARTPSource.h" @@ -119,9 +123,7 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket( mNextExpectedSeqNoValid = true; mNextExpectedSeqNo = (uint32_t)buffer->int32Data(); } else if ((uint32_t)buffer->int32Data() != mNextExpectedSeqNo) { -#if VERBOSE - LOG(VERBOSE) << "Not the sequence number I expected"; -#endif + LOGV("Not the sequence number I expected"); return WRONG_SEQUENCE_NUMBER; } @@ -132,7 +134,7 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket( queue->erase(queue->begin()); ++mNextExpectedSeqNo; - LOG(VERBOSE) << "AMR packet too short."; + LOGV("AMR packet too short."); return MALFORMED_PACKET; } @@ -150,7 +152,7 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket( queue->erase(queue->begin()); ++mNextExpectedSeqNo; - LOG(VERBOSE) << "Unable to parse TOC."; + LOGV("Unable to parse TOC."); return MALFORMED_PACKET; } @@ -164,7 +166,7 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket( queue->erase(queue->begin()); ++mNextExpectedSeqNo; - LOG(VERBOSE) << "Illegal TOC entry."; + LOGV("Illegal TOC entry."); return MALFORMED_PACKET; } @@ -191,7 +193,7 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket( queue->erase(queue->begin()); ++mNextExpectedSeqNo; - LOG(VERBOSE) << "AMR packet too short."; + LOGV("AMR packet too short."); return MALFORMED_PACKET; } diff --git a/media/libstagefright/rtsp/AAVCAssembler.cpp b/media/libstagefright/rtsp/AAVCAssembler.cpp index 6b1e292..11c6ae7 100644 --- a/media/libstagefright/rtsp/AAVCAssembler.cpp +++ b/media/libstagefright/rtsp/AAVCAssembler.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "AAVCAssembler" +#include <utils/Log.h> + #include "AAVCAssembler.h" #include "ARTPSource.h" @@ -25,8 +29,6 @@ #include <stdint.h> -#define BE_VERBOSE 0 - namespace android { // static @@ -70,9 +72,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addNALUnit( mNextExpectedSeqNoValid = true; mNextExpectedSeqNo = (uint32_t)buffer->int32Data(); } else if ((uint32_t)buffer->int32Data() != mNextExpectedSeqNo) { -#if BE_VERBOSE - LOG(VERBOSE) << "Not the sequence number I expected"; -#endif + LOGV("Not the sequence number I expected"); return WRONG_SEQUENCE_NUMBER; } @@ -83,7 +83,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addNALUnit( if (size < 1 || (data[0] & 0x80)) { // Corrupt. - LOG(ERROR) << "Ignoring corrupt buffer."; + LOGV("Ignoring corrupt buffer."); queue->erase(queue->begin()); ++mNextExpectedSeqNo; @@ -107,7 +107,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addNALUnit( return success ? OK : MALFORMED_PACKET; } else { - LOG(ERROR) << "Ignoring unsupported buffer (nalType=" << nalType << ")"; + LOGV("Ignoring unsupported buffer (nalType=%d)", nalType); queue->erase(queue->begin()); ++mNextExpectedSeqNo; @@ -117,8 +117,8 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addNALUnit( } void AAVCAssembler::addSingleNALUnit(const sp<ABuffer> &buffer) { -#if BE_VERBOSE - LOG(VERBOSE) << "addSingleNALUnit of size " << buffer->size(); + LOGV("addSingleNALUnit of size %d", buffer->size()); +#if !LOG_NDEBUG hexdump(buffer->data(), buffer->size()); #endif @@ -138,7 +138,7 @@ bool AAVCAssembler::addSingleTimeAggregationPacket(const sp<ABuffer> &buffer) { size_t size = buffer->size(); if (size < 3) { - LOG(ERROR) << "Discarding too small STAP-A packet."; + LOGV("Discarding too small STAP-A packet."); return false; } @@ -148,7 +148,7 @@ bool AAVCAssembler::addSingleTimeAggregationPacket(const sp<ABuffer> &buffer) { size_t nalSize = (data[0] << 8) | data[1]; if (size < nalSize + 2) { - LOG(ERROR) << "Discarding malformed STAP-A packet."; + LOGV("Discarding malformed STAP-A packet."); return false; } @@ -164,7 +164,7 @@ bool AAVCAssembler::addSingleTimeAggregationPacket(const sp<ABuffer> &buffer) { } if (size != 0) { - LOG(WARNING) << "Unexpected padding at end of STAP-A packet."; + LOGV("Unexpected padding at end of STAP-A packet."); } return true; @@ -184,7 +184,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit( CHECK((indicator & 0x1f) == 28); if (size < 2) { - LOG(ERROR) << "Ignoring malformed FU buffer (size = " << size << ")"; + LOGV("Ignoring malformed FU buffer (size = %d)", size); queue->erase(queue->begin()); ++mNextExpectedSeqNo; @@ -194,9 +194,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit( if (!(data[1] & 0x80)) { // Start bit not set on the first buffer. -#if BE_VERBOSE - LOG(ERROR) << "Start bit not set on first buffer"; -#endif + LOGV("Start bit not set on first buffer"); queue->erase(queue->begin()); ++mNextExpectedSeqNo; @@ -214,17 +212,13 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit( if (data[1] & 0x40) { // Huh? End bit also set on the first buffer. -#if BE_VERBOSE - LOG(WARNING) << "Grrr. This isn't fragmented at all."; -#endif + LOGV("Grrr. This isn't fragmented at all."); complete = true; } else { List<sp<ABuffer> >::iterator it = ++queue->begin(); while (it != queue->end()) { -#if BE_VERBOSE - LOG(VERBOSE) << "sequence length " << totalCount; -#endif + LOGV("sequence length %d", totalCount); const sp<ABuffer> &buffer = *it; @@ -232,11 +226,8 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit( size_t size = buffer->size(); if ((uint32_t)buffer->int32Data() != expectedSeqNo) { -#if BE_VERBOSE - LOG(VERBOSE) << "sequence not complete, expected seqNo " - << expectedSeqNo << ", got " - << (uint32_t)buffer->int32Data(); -#endif + LOGV("sequence not complete, expected seqNo %d, got %d", + expectedSeqNo, (uint32_t)buffer->int32Data()); return WRONG_SEQUENCE_NUMBER; } @@ -245,7 +236,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit( || data[0] != indicator || (data[1] & 0x1f) != nalType || (data[1] & 0x80)) { - LOG(ERROR) << "Ignoring malformed FU buffer.\n"; + LOGV("Ignoring malformed FU buffer."); // Delete the whole start of the FU. @@ -296,8 +287,8 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit( for (size_t i = 0; i < totalCount; ++i) { const sp<ABuffer> &buffer = *it; -#if BE_VERBOSE - LOG(VERBOSE) << "piece #" << (i + 1) << "/" << totalCount; + LOGV("piece #%d/%d", i + 1, totalCount); +#if !LOG_NDEBUG hexdump(buffer->data(), buffer->size()); #endif @@ -311,9 +302,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit( addSingleNALUnit(unit); -#if BE_VERBOSE - LOG(VERBOSE) << "successfully assembled a NAL unit from fragments."; -#endif + LOGV("successfully assembled a NAL unit from fragments."); return OK; } @@ -321,9 +310,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit( void AAVCAssembler::submitAccessUnit() { CHECK(!mNALUnits.empty()); -#if BE_VERBOSE - LOG(VERBOSE) << "Access unit complete (" << mNALUnits.size() << " nal units)"; -#endif + LOGV("Access unit complete (%d nal units)", mNALUnits.size()); size_t totalSize = 0; for (List<sp<ABuffer> >::iterator it = mNALUnits.begin(); @@ -373,7 +360,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::assembleMore( void AAVCAssembler::packetLost() { CHECK(mNextExpectedSeqNoValid); - LOG(VERBOSE) << "packetLost (expected " << mNextExpectedSeqNo << ")"; + LOGV("packetLost (expected %d)", mNextExpectedSeqNo); ++mNextExpectedSeqNo; diff --git a/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp b/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp index f68a35b..13988cd 100644 --- a/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp +++ b/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "AMPEG4ElementaryAssembler" +#include <utils/Log.h> + #include "AMPEG4ElementaryAssembler.h" #include "ARTPSource.h" @@ -28,8 +32,6 @@ #include <ctype.h> #include <stdint.h> -#define BE_VERBOSE 0 - namespace android { static bool GetAttribute(const char *s, const char *key, AString *value) { @@ -201,9 +203,7 @@ ARTPAssembler::AssemblyStatus AMPEG4ElementaryAssembler::addPacket( mNextExpectedSeqNoValid = true; mNextExpectedSeqNo = (uint32_t)buffer->int32Data(); } else if ((uint32_t)buffer->int32Data() != mNextExpectedSeqNo) { -#if BE_VERBOSE - LOG(VERBOSE) << "Not the sequence number I expected"; -#endif + LOGV("Not the sequence number I expected"); return WRONG_SEQUENCE_NUMBER; } @@ -336,9 +336,7 @@ ARTPAssembler::AssemblyStatus AMPEG4ElementaryAssembler::addPacket( void AMPEG4ElementaryAssembler::submitAccessUnit() { CHECK(!mPackets.empty()); -#if BE_VERBOSE - LOG(VERBOSE) << "Access unit complete (" << mPackets.size() << " nal units)"; -#endif + LOGV("Access unit complete (%d nal units)", mPackets.size()); size_t totalSize = 0; for (List<sp<ABuffer> >::iterator it = mPackets.begin(); @@ -385,7 +383,7 @@ ARTPAssembler::AssemblyStatus AMPEG4ElementaryAssembler::assembleMore( void AMPEG4ElementaryAssembler::packetLost() { CHECK(mNextExpectedSeqNoValid); - LOG(VERBOSE) << "packetLost (expected " << mNextExpectedSeqNo << ")"; + LOGV("packetLost (expected %d)", mNextExpectedSeqNo); ++mNextExpectedSeqNo; diff --git a/media/libstagefright/rtsp/APacketSource.cpp b/media/libstagefright/rtsp/APacketSource.cpp index b3e86eb..78754e6 100644 --- a/media/libstagefright/rtsp/APacketSource.cpp +++ b/media/libstagefright/rtsp/APacketSource.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "APacketSource" +#include <utils/Log.h> + #include "APacketSource.h" #include "ASessionDescription.h" @@ -188,7 +192,7 @@ static sp<ABuffer> MakeAVCCodecSpecificData( if (i == 0) { FindAVCDimensions(nal, width, height); - LOG(INFO) << "dimensions " << *width << "x" << *height; + LOGI("dimensions %dx%d", *width, *height); } } @@ -412,7 +416,7 @@ static bool ExtractDimensionsFromVOLHeader( *width = video_object_layer_width; *height = video_object_layer_height; - LOG(INFO) << "VOL dimensions = " << *width << "x" << *height; + LOGI("VOL dimensions = %dx%d", *width, *height); return true; } @@ -711,7 +715,7 @@ void APacketSource::updateNormalPlayTime_l(const sp<ABuffer> &buffer) { void APacketSource::queueAccessUnit(const sp<ABuffer> &buffer) { int32_t damaged; if (buffer->meta()->findInt32("damaged", &damaged) && damaged) { - LOG(VERBOSE) << "discarding damaged AU"; + LOGV("discarding damaged AU"); return; } @@ -765,8 +769,9 @@ int64_t APacketSource::getQueueDurationUs(bool *eos) { CHECK(last->meta()->findInt64("timeUs", &lastTimeUs)); if (lastTimeUs < firstTimeUs) { - LOG(ERROR) << "Huh? Time moving backwards? " - << firstTimeUs << " > " << lastTimeUs; + LOGE("Huh? Time moving backwards? %lld > %lld", + firstTimeUs, lastTimeUs); + return 0; } diff --git a/media/libstagefright/rtsp/ARTPConnection.cpp b/media/libstagefright/rtsp/ARTPConnection.cpp index 10c9e02..ded3b24 100644 --- a/media/libstagefright/rtsp/ARTPConnection.cpp +++ b/media/libstagefright/rtsp/ARTPConnection.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "ARTPConnection" +#include <utils/Log.h> + #include "ARTPConnection.h" #include "ARTPSource.h" @@ -319,7 +323,7 @@ void ARTPConnection::onPollStreams() { } if (buffer->size() > 0) { - LOG(VERBOSE) << "Sending RR..."; + LOGV("Sending RR..."); ssize_t n = sendto( s->mRTCPSocket, buffer->data(), buffer->size(), 0, @@ -356,7 +360,7 @@ status_t ARTPConnection::receive(StreamInfo *s, bool receiveRTP) { buffer->setRange(0, nbytes); - // LOG(INFO) << "received " << buffer->size() << " bytes."; + // LOGI("received %d bytes.", buffer->size()); status_t err; if (receiveRTP) { @@ -521,9 +525,8 @@ status_t ARTPConnection::parseRTCP(StreamInfo *s, const sp<ABuffer> &buffer) { default: { - LOG(WARNING) << "Unknown RTCP packet type " - << (unsigned)data[1] - << " of size " << headerLength; + LOGW("Unknown RTCP packet type %u of size %d", + (unsigned)data[1], headerLength); break; } } @@ -567,10 +570,10 @@ status_t ARTPConnection::parseSR( uint32_t rtpTime = u32at(&data[16]); #if 0 - LOG(INFO) << StringPrintf( - "XXX timeUpdate: ssrc=0x%08x, rtpTime %u == ntpTime %.3f", - id, - rtpTime, (ntpTime >> 32) + (double)(ntpTime & 0xffffffff) / (1ll << 32)); + LOGI("XXX timeUpdate: ssrc=0x%08x, rtpTime %u == ntpTime %.3f", + id, + rtpTime, + (ntpTime >> 32) + (double)(ntpTime & 0xffffffff) / (1ll << 32)); #endif sp<ARTPSource> source = findSource(s, id); diff --git a/media/libstagefright/rtsp/ARTPSession.cpp b/media/libstagefright/rtsp/ARTPSession.cpp index 8ce93b7..39c6619 100644 --- a/media/libstagefright/rtsp/ARTPSession.cpp +++ b/media/libstagefright/rtsp/ARTPSession.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "ARTPSession" +#include <utils/Log.h> + #include "ARTPSession.h" #include <media/stagefright/foundation/ABuffer.h> @@ -51,24 +55,24 @@ status_t ARTPSession::setup(const sp<ASessionDescription> &desc) { if (!mDesc->findAttribute(i, "c=", &connection)) { // No per-stream connection information, try global fallback. if (!mDesc->findAttribute(0, "c=", &connection)) { - LOG(ERROR) << "Unable to find connection attribtue."; + LOGE("Unable to find connection attribute."); return mInitCheck; } } if (!(connection == "IN IP4 127.0.0.1")) { - LOG(ERROR) << "We only support localhost connections for now."; + LOGE("We only support localhost connections for now."); return mInitCheck; } unsigned port; if (!validateMediaFormat(i, &port) || (port & 1) != 0) { - LOG(ERROR) << "Invalid media format."; + LOGE("Invalid media format."); return mInitCheck; } sp<APacketSource> source = new APacketSource(mDesc, i); if (source->initCheck() != OK) { - LOG(ERROR) << "Unsupported format."; + LOGE("Unsupported format."); return mInitCheck; } @@ -157,9 +161,8 @@ void ARTPSession::onMessageReceived(const sp<AMessage> &msg) { printf("access unit complete size=%d\tntp-time=0x%016llx\n", accessUnit->size(), ntpTime); #else - LOG(INFO) << "access unit complete, " - << "size=" << accessUnit->size() << ", " - << "ntp-time=" << ntpTime; + LOGI("access unit complete, size=%d, ntp-time=%llu", + accessUnit->size(), ntpTime); hexdump(accessUnit->data(), accessUnit->size()); #endif #endif @@ -169,9 +172,8 @@ void ARTPSession::onMessageReceived(const sp<AMessage> &msg) { CHECK(!memcmp("\x00\x00\x00\x01", accessUnit->data(), 4)); unsigned x = accessUnit->data()[4]; - LOG(INFO) << "access unit complete: " - << StringPrintf("nalType=0x%02x, nalRefIdc=0x%02x", - x & 0x1f, (x & 0x60) >> 5); + LOGI("access unit complete: nalType=0x%02x, nalRefIdc=0x%02x", + x & 0x1f, (x & 0x60) >> 5); #endif accessUnit->meta()->setInt64("ntp-time", ntpTime); @@ -181,7 +183,7 @@ void ARTPSession::onMessageReceived(const sp<AMessage> &msg) { int32_t damaged; if (accessUnit->meta()->findInt32("damaged", &damaged) && damaged != 0) { - LOG(INFO) << "ignoring damaged AU"; + LOGI("ignoring damaged AU"); } else #endif { diff --git a/media/libstagefright/rtsp/ARTPSource.cpp b/media/libstagefright/rtsp/ARTPSource.cpp index 9656ba2..2518264 100644 --- a/media/libstagefright/rtsp/ARTPSource.cpp +++ b/media/libstagefright/rtsp/ARTPSource.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "ARTPSource" +#include <utils/Log.h> + #include "ARTPSource.h" #include "AAMRAssembler.h" @@ -27,8 +31,6 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> -#define BE_VERBOSE 0 - namespace android { static const uint32_t kSourceID = 0xdeadbeef; @@ -83,14 +85,10 @@ void ARTPSource::processRTPPacket(const sp<ABuffer> &buffer) { && mAssembler != NULL) { mAssembler->onPacketReceived(this); } - - dump(); } void ARTPSource::timeUpdate(uint32_t rtpTime, uint64_t ntpTime) { -#if BE_VERBOSE - LOG(VERBOSE) << "timeUpdate"; -#endif + LOGV("timeUpdate"); mLastNTPTime = ntpTime; mLastNTPTimeUpdateUs = ALooper::GetNowUs(); @@ -173,7 +171,7 @@ bool ARTPSource::queuePacket(const sp<ABuffer> &buffer) { } if (it != mQueue.end() && (uint32_t)(*it)->int32Data() == seqNum) { - LOG(WARNING) << "Discarding duplicate buffer"; + LOGW("Discarding duplicate buffer"); return false; } @@ -182,89 +180,6 @@ bool ARTPSource::queuePacket(const sp<ABuffer> &buffer) { return true; } -void ARTPSource::dump() const { - if ((mNumBuffersReceived % 128) != 0) { - return; - } - -#if 0 - if (mAssembler == NULL) { - char tmp[20]; - sprintf(tmp, "0x%08x", mID); - - int32_t numMissing = 0; - - if (!mQueue.empty()) { - List<sp<ABuffer> >::const_iterator it = mQueue.begin(); - uint32_t expectedSeqNum = (uint32_t)(*it)->int32Data(); - ++expectedSeqNum; - ++it; - - for (; it != mQueue.end(); ++it) { - uint32_t seqNum = (uint32_t)(*it)->int32Data(); - CHECK_GE(seqNum, expectedSeqNum); - - if (seqNum != expectedSeqNum) { - numMissing += seqNum - expectedSeqNum; - expectedSeqNum = seqNum; - } - - ++expectedSeqNum; - } - } - - LOG(VERBOSE) << "[" << tmp << "] Missing " << numMissing - << " / " << (mNumBuffersReceived + numMissing) << " packets. (" - << (100.0 * numMissing / (mNumBuffersReceived + numMissing)) - << " %%)"; - } -#endif - -#if 0 - AString out; - - out.append(tmp); - out.append(" ["); - - List<sp<ABuffer> >::const_iterator it = mQueue.begin(); - while (it != mQueue.end()) { - uint32_t start = (uint32_t)(*it)->int32Data(); - - out.append(start); - - ++it; - uint32_t expected = start + 1; - - while (it != mQueue.end()) { - uint32_t seqNum = (uint32_t)(*it)->int32Data(); - - if (seqNum != expected) { - if (expected > start + 1) { - out.append("-"); - out.append(expected - 1); - } - out.append(", "); - break; - } - - ++it; - ++expected; - } - - if (it == mQueue.end()) { - if (expected > start + 1) { - out.append("-"); - out.append(expected - 1); - } - } - } - - out.append("]"); - - LOG(VERBOSE) << out; -#endif -} - uint64_t ARTPSource::RTP2NTP(uint32_t rtpTime) const { CHECK_EQ(mNumTimes, 2u); @@ -291,7 +206,7 @@ void ARTPSource::addFIR(const sp<ABuffer> &buffer) { mLastFIRRequestUs = nowUs; if (buffer->size() + 20 > buffer->capacity()) { - LOG(WARNING) << "RTCP buffer too small to accomodate FIR."; + LOGW("RTCP buffer too small to accomodate FIR."); return; } @@ -324,12 +239,12 @@ void ARTPSource::addFIR(const sp<ABuffer> &buffer) { buffer->setRange(buffer->offset(), buffer->size() + 20); - LOG(VERBOSE) << "Added FIR request."; + LOGV("Added FIR request."); } void ARTPSource::addReceiverReport(const sp<ABuffer> &buffer) { if (buffer->size() + 32 > buffer->capacity()) { - LOG(WARNING) << "RTCP buffer too small to accomodate RR."; + LOGW("RTCP buffer too small to accomodate RR."); return; } diff --git a/media/libstagefright/rtsp/ARTPSource.h b/media/libstagefright/rtsp/ARTPSource.h index 252d6d6..e62c3f1 100644 --- a/media/libstagefright/rtsp/ARTPSource.h +++ b/media/libstagefright/rtsp/ARTPSource.h @@ -72,7 +72,6 @@ private: uint64_t RTP2NTP(uint32_t rtpTime) const; bool queuePacket(const sp<ABuffer> &buffer); - void dump() const; DISALLOW_EVIL_CONSTRUCTORS(ARTPSource); }; diff --git a/media/libstagefright/rtsp/ARTPWriter.cpp b/media/libstagefright/rtsp/ARTPWriter.cpp index ce1ee0e..155fd96 100644 --- a/media/libstagefright/rtsp/ARTPWriter.cpp +++ b/media/libstagefright/rtsp/ARTPWriter.cpp @@ -1,3 +1,23 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "ARTPWriter" +#include <utils/Log.h> + #include "ARTPWriter.h" #include <fcntl.h> @@ -249,7 +269,7 @@ void ARTPWriter::onRead(const sp<AMessage> &msg) { status_t err = mSource->read(&mediaBuf); if (err != OK) { - LOG(INFO) << "reached EOS."; + LOGI("reached EOS."); Mutex::Autolock autoLock(mLock); mFlags |= kFlagEOS; @@ -257,7 +277,7 @@ void ARTPWriter::onRead(const sp<AMessage> &msg) { } if (mediaBuf->range_length() > 0) { - LOG(VERBOSE) << "read buffer of size " << mediaBuf->range_length(); + LOGV("read buffer of size %d", mediaBuf->range_length()); if (mMode == H264) { StripStartcode(mediaBuf); @@ -500,7 +520,7 @@ void ARTPWriter::dumpSessionDesc() { sdp.append("a=fmtp:" PT_STR " octed-align\r\n"); } - LOG(INFO) << sdp; + LOGI("%s", sdp.c_str()); } void ARTPWriter::makeH264SPropParamSets(MediaBuffer *buffer) { diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp index da4a73a..5ec03b2 100644 --- a/media/libstagefright/rtsp/ARTSPConnection.cpp +++ b/media/libstagefright/rtsp/ARTSPConnection.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "ARTSPConnection" +#include <utils/Log.h> + #include "ARTSPConnection.h" #include <media/stagefright/foundation/ABuffer.h> @@ -41,7 +45,7 @@ ARTSPConnection::ARTSPConnection() ARTSPConnection::~ARTSPConnection() { if (mSocket >= 0) { - LOG(ERROR) << "Connection is still open, closing the socket."; + LOGE("Connection is still open, closing the socket."); close(mSocket); mSocket = -1; } @@ -184,7 +188,7 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) { AString host, path; unsigned port; if (!ParseURL(url.c_str(), &host, &port, &path)) { - LOG(ERROR) << "Malformed rtsp url " << url; + LOGE("Malformed rtsp url %s", url.c_str()); reply->setInt32("result", ERROR_MALFORMED); reply->post(); @@ -195,7 +199,7 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) { struct hostent *ent = gethostbyname(host.c_str()); if (ent == NULL) { - LOG(ERROR) << "Unknown host " << host; + LOGE("Unknown host %s", host.c_str()); reply->setInt32("result", -ENOENT); reply->post(); @@ -300,7 +304,7 @@ void ARTSPConnection::onCompleteConnection(const sp<AMessage> &msg) { CHECK_EQ(optionLen, (socklen_t)sizeof(err)); if (err != 0) { - LOG(ERROR) << "err = " << err << " (" << strerror(err) << ")"; + LOGE("err = %d (%s)", err, strerror(err)); reply->setInt32("result", -err); @@ -343,7 +347,7 @@ void ARTSPConnection::onSendRequest(const sp<AMessage> &msg) { request.insert(cseqHeader, i + 2); - LOG(VERBOSE) << request; + LOGV("%s", request.c_str()); size_t numBytesSent = 0; while (numBytesSent < request.size()) { @@ -353,7 +357,7 @@ void ARTSPConnection::onSendRequest(const sp<AMessage> &msg) { if (n == 0) { // Server closed the connection. - LOG(ERROR) << "Server unexpectedly closed the connection."; + LOGE("Server unexpectedly closed the connection."); reply->setInt32("result", ERROR_IO); reply->post(); @@ -363,7 +367,7 @@ void ARTSPConnection::onSendRequest(const sp<AMessage> &msg) { continue; } - LOG(ERROR) << "Error sending rtsp request."; + LOGE("Error sending rtsp request."); reply->setInt32("result", -errno); reply->post(); return; @@ -438,14 +442,14 @@ status_t ARTSPConnection::receive(void *data, size_t size) { ssize_t n = recv(mSocket, (uint8_t *)data + offset, size - offset, 0); if (n == 0) { // Server closed the connection. - LOG(ERROR) << "Server unexpectedly closed the connection."; + LOGE("Server unexpectedly closed the connection."); return ERROR_IO; } else if (n < 0) { if (errno == EINTR) { continue; } - LOG(ERROR) << "Error reading rtsp response."; + LOGE("Error reading rtsp response."); return -errno; } @@ -516,7 +520,7 @@ bool ARTSPConnection::receiveRTSPReponse() { notify->setObject("buffer", buffer); notify->post(); } else { - LOG(WARNING) << "received binary data, but no one cares."; + LOGW("received binary data, but no one cares."); } return true; @@ -525,7 +529,7 @@ bool ARTSPConnection::receiveRTSPReponse() { sp<ARTSPResponse> response = new ARTSPResponse; response->mStatusLine = statusLine; - LOG(INFO) << "status: " << response->mStatusLine; + LOGI("status: %s", response->mStatusLine.c_str()); ssize_t space1 = response->mStatusLine.find(" "); if (space1 < 0) { @@ -555,7 +559,7 @@ bool ARTSPConnection::receiveRTSPReponse() { break; } - LOG(VERBOSE) << "line: " << line; + LOGV("line: %s", line.c_str()); ssize_t colonPos = line.find(":"); if (colonPos < 0) { diff --git a/media/libstagefright/rtsp/ASessionDescription.cpp b/media/libstagefright/rtsp/ASessionDescription.cpp index 4ea7fda..0db3595 100644 --- a/media/libstagefright/rtsp/ASessionDescription.cpp +++ b/media/libstagefright/rtsp/ASessionDescription.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "ASessionDescription" +#include <utils/Log.h> + #include "ASessionDescription.h" #include <media/stagefright/foundation/ADebug.h> @@ -49,7 +53,7 @@ bool ASessionDescription::parse(const void *data, size_t size) { mFormats.push(AString("[root]")); AString desc((const char *)data, size); - LOG(INFO) << desc; + LOGI("%s", desc.c_str()); size_t i = 0; for (;;) { @@ -102,7 +106,7 @@ bool ASessionDescription::parse(const void *data, size_t size) { key.trim(); value.trim(); - LOG(VERBOSE) << "adding '" << key << "' => '" << value << "'"; + LOGV("adding '%s' => '%s'", key.c_str(), value.c_str()); mTracks.editItemAt(mTracks.size() - 1).add(key, value); break; @@ -110,7 +114,8 @@ bool ASessionDescription::parse(const void *data, size_t size) { case 'm': { - LOG(VERBOSE) << "new section '" << AString(line, 2, line.size() - 2) << "'"; + LOGV("new section '%s'", + AString(line, 2, line.size() - 2).c_str()); mTracks.push(Attribs()); mFormats.push(AString(line, 2, line.size() - 2)); @@ -129,7 +134,7 @@ bool ASessionDescription::parse(const void *data, size_t size) { key.trim(); value.trim(); - LOG(VERBOSE) << "adding '" << key << "' => '" << value << "'"; + LOGV("adding '%s' => '%s'", key.c_str(), value.c_str()); mTracks.editItemAt(mTracks.size() - 1).add(key, value); break; diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h index 526bef3..a31b2b2 100644 --- a/media/libstagefright/rtsp/MyHandler.h +++ b/media/libstagefright/rtsp/MyHandler.h @@ -18,6 +18,10 @@ #define MY_HANDLER_H_ +//#define LOG_NDEBUG 0 +#define LOG_TAG "MyHandler" +#include <utils/Log.h> + #include "APacketSource.h" #include "ARTPConnection.h" #include "ARTSPConnection.h" @@ -137,8 +141,8 @@ struct MyHandler : public AHandler { int32_t result; CHECK(msg->findInt32("result", &result)); - LOG(INFO) << "connection request completed with result " - << result << " (" << strerror(-result) << ")"; + LOGI("connection request completed with result %d (%s)", + result, strerror(-result)); if (result == OK) { AString request; @@ -173,8 +177,8 @@ struct MyHandler : public AHandler { int32_t result; CHECK(msg->findInt32("result", &result)); - LOG(INFO) << "DESCRIBE completed with result " - << result << " (" << strerror(-result) << ")"; + LOGI("DESCRIBE completed with result %d (%s)", + result, strerror(-result)); if (result == OK) { sp<RefBase> obj; @@ -251,8 +255,8 @@ struct MyHandler : public AHandler { int32_t result; CHECK(msg->findInt32("result", &result)); - LOG(INFO) << "SETUP(" << index << ") completed with result " - << result << " (" << strerror(-result) << ")"; + LOGI("SETUP(%d) completed with result %d (%s)", + index, result, strerror(-result)); if (result == OK) { CHECK(track != NULL); @@ -326,8 +330,8 @@ struct MyHandler : public AHandler { int32_t result; CHECK(msg->findInt32("result", &result)); - LOG(INFO) << "PLAY completed with result " - << result << " (" << strerror(-result) << ")"; + LOGI("PLAY completed with result %d (%s)", + result, strerror(-result)); if (result == OK) { sp<RefBase> obj; @@ -404,8 +408,8 @@ struct MyHandler : public AHandler { int32_t result; CHECK(msg->findInt32("result", &result)); - LOG(INFO) << "TEARDOWN completed with result " - << result << " (" << strerror(-result) << ")"; + LOGI("TEARDOWN completed with result %d (%s)", + result, strerror(-result)); sp<AMessage> reply = new AMessage('disc', id()); @@ -431,7 +435,7 @@ struct MyHandler : public AHandler { case 'chek': { if (mNumAccessUnitsReceived == 0) { - LOG(INFO) << "stream ended? aborting."; + LOGI("stream ended? aborting."); (new AMessage('abor', id()))->post(); break; } @@ -461,7 +465,7 @@ struct MyHandler : public AHandler { CHECK(msg->findSize("track-index", &trackIndex)); if (trackIndex >= mTracks.size()) { - LOG(ERROR) << "late packets ignored."; + LOGV("late packets ignored."); break; } @@ -469,7 +473,7 @@ struct MyHandler : public AHandler { int32_t eos; if (msg->findInt32("eos", &eos)) { - LOG(INFO) << "received BYE on track index " << trackIndex; + LOGI("received BYE on track index %d", trackIndex); #if 0 track->mPacketSource->signalEOS(ERROR_END_OF_STREAM); #endif @@ -484,14 +488,13 @@ struct MyHandler : public AHandler { uint32_t seqNum = (uint32_t)accessUnit->int32Data(); if (mSeekPending) { - LOG(INFO) << "we're seeking, dropping stale packet."; + LOGV("we're seeking, dropping stale packet."); break; } if (seqNum < track->mFirstSeqNumInSegment) { - LOG(INFO) << "dropping stale access-unit " - << "(" << seqNum << " < " - << track->mFirstSeqNumInSegment << ")"; + LOGV("dropping stale access-unit (%d < %d)", + seqNum, track->mFirstSeqNumInSegment); break; } @@ -506,10 +509,8 @@ struct MyHandler : public AHandler { if (track->mNewSegment) { track->mNewSegment = false; - LOG(VERBOSE) << "first segment unit ntpTime=" - << StringPrintf("0x%016llx", ntpTime) - << " rtpTime=" << rtpTime - << " seq=" << seqNum; + LOGV("first segment unit ntpTime=0x%016llx rtpTime=%u seq=%d", + ntpTime, rtpTime, seqNum); } if (mFirstAccessUnit) { @@ -535,7 +536,7 @@ struct MyHandler : public AHandler { int32_t damaged; if (accessUnit->meta()->findInt32("damaged", &damaged) && damaged != 0) { - LOG(INFO) << "ignoring damaged AU"; + LOGI("ignoring damaged AU"); } else #endif { @@ -608,8 +609,8 @@ struct MyHandler : public AHandler { int32_t result; CHECK(msg->findInt32("result", &result)); - LOG(INFO) << "PLAY completed with result " - << result << " (" << strerror(-result) << ")"; + LOGI("PLAY completed with result %d (%s)", + result, strerror(-result)); if (result == OK) { sp<RefBase> obj; @@ -622,12 +623,12 @@ struct MyHandler : public AHandler { } else { parsePlayResponse(response); - LOG(INFO) << "seek completed."; + LOGI("seek completed."); } } if (result != OK) { - LOG(ERROR) << "seek failed, aborting."; + LOGE("seek failed, aborting."); (new AMessage('abor', id()))->post(); } @@ -652,11 +653,10 @@ struct MyHandler : public AHandler { { if (!mReceivedFirstRTCPPacket) { if (mTryTCPInterleaving) { - LOG(WARNING) << "Never received any data, disconnecting."; + LOGW("Never received any data, disconnecting."); (new AMessage('abor', id()))->post(); } else { - LOG(WARNING) - << "Never received any data, switching transports."; + LOGW("Never received any data, switching transports."); mTryTCPInterleaving = true; @@ -700,7 +700,7 @@ struct MyHandler : public AHandler { } AString range = response->mHeaders.valueAt(i); - LOG(VERBOSE) << "Range: " << range; + LOGV("Range: %s", range.c_str()); AString val; CHECK(GetAttribute(range.c_str(), "npt", &val)); @@ -724,7 +724,7 @@ struct MyHandler : public AHandler { for (List<AString>::iterator it = streamInfos.begin(); it != streamInfos.end(); ++it) { (*it).trim(); - LOG(VERBOSE) << "streamInfo[" << n << "] = " << *it; + LOGV("streamInfo[%d] = %s", n, (*it).c_str()); CHECK(GetAttribute((*it).c_str(), "url", &val)); @@ -748,8 +748,7 @@ struct MyHandler : public AHandler { uint32_t rtpTime = strtoul(val.c_str(), &end, 10); - LOG(VERBOSE) << "track #" << n - << ": rtpTime=" << rtpTime << " <=> npt=" << npt1; + LOGV("track #%d: rtpTime=%u <=> ntp=%.2f", n, rtpTime, npt1); info->mPacketSource->setNormalPlayTimeMapping( rtpTime, (int64_t)(npt1 * 1E6)); @@ -806,8 +805,7 @@ private: new APacketSource(mSessionDesc, index); if (source->initCheck() != OK) { - LOG(WARNING) << "Unsupported format. Ignoring track #" - << index << "."; + LOGW("Unsupported format. Ignoring track #%d.", index); sp<AMessage> reply = new AMessage('setu', id()); reply->setSize("index", index); @@ -830,7 +828,7 @@ private: info->mFirstSeqNumInSegment = 0; info->mNewSegment = true; - LOG(VERBOSE) << "track #" << mTracks.size() << " URL=" << trackURL; + LOGV("track #%d URL=%s", mTracks.size(), trackURL.c_str()); AString request = "SETUP "; request.append(trackURL); diff --git a/media/libstagefright/rtsp/UDPPusher.cpp b/media/libstagefright/rtsp/UDPPusher.cpp index 28a343f..576b3ca 100644 --- a/media/libstagefright/rtsp/UDPPusher.cpp +++ b/media/libstagefright/rtsp/UDPPusher.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "UDPPusher" +#include <utils/Log.h> + #include "UDPPusher.h" #include <media/stagefright/foundation/ABuffer.h> @@ -67,7 +71,7 @@ void UDPPusher::start() { bool UDPPusher::onPush() { uint32_t length; if (fread(&length, 1, sizeof(length), mFile) < sizeof(length)) { - LOG(INFO) << "No more data to push."; + LOGI("No more data to push."); return false; } @@ -77,7 +81,7 @@ bool UDPPusher::onPush() { sp<ABuffer> buffer = new ABuffer(length); if (fread(buffer->data(), 1, length, mFile) < length) { - LOG(ERROR) << "File truncated?."; + LOGE("File truncated?."); return false; } @@ -89,7 +93,7 @@ bool UDPPusher::onPush() { uint32_t timeMs; if (fread(&timeMs, 1, sizeof(timeMs), mFile) < sizeof(timeMs)) { - LOG(INFO) << "No more data to push."; + LOGI("No more data to push."); return false; } @@ -109,7 +113,7 @@ void UDPPusher::onMessageReceived(const sp<AMessage> &msg) { case kWhatPush: { if (!onPush() && !(ntohs(mRemoteAddr.sin_port) & 1)) { - LOG(INFO) << "emulating BYE packet"; + LOGI("emulating BYE packet"); sp<ABuffer> buffer = new ABuffer(8); uint8_t *data = buffer->data(); diff --git a/media/libstagefright/rtsp/rtp_test.cpp b/media/libstagefright/rtsp/rtp_test.cpp index cec6c0c..f0cb5a5 100644 --- a/media/libstagefright/rtsp/rtp_test.cpp +++ b/media/libstagefright/rtsp/rtp_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "rtp_test" +#include <utils/Log.h> + #include <binder/ProcessState.h> #include <media/stagefright/foundation/ADebug.h> @@ -200,8 +204,7 @@ int main(int argc, char **argv) { continue; } - LOG(ERROR) << "decoder returned error " - << StringPrintf("0x%08x", err); + LOGE("decoder returned error 0x%08x", err); break; } |