Loading media/libmediametrics/MediaAnalyticsItem.cpp +89 −6 Original line number Diff line number Diff line Loading @@ -120,6 +120,8 @@ MediaAnalyticsItem *MediaAnalyticsItem::dup() { // key as part of constructor dst->mPid = this->mPid; dst->mUid = this->mUid; dst->mPkgName = this->mPkgName; dst->mPkgVersionCode = this->mPkgVersionCode; dst->mSessionID = this->mSessionID; dst->mTimestamp = this->mTimestamp; dst->mFinalized = this->mFinalized; Loading Loading @@ -201,6 +203,24 @@ uid_t MediaAnalyticsItem::getUid() const { return mUid; } MediaAnalyticsItem &MediaAnalyticsItem::setPkgName(AString pkgName) { mPkgName = pkgName; return *this; } AString MediaAnalyticsItem::getPkgName() const { return mPkgName; } MediaAnalyticsItem &MediaAnalyticsItem::setPkgVersionCode(int32_t pkgVersionCode) { mPkgVersionCode = pkgVersionCode; return *this; } int32_t MediaAnalyticsItem::getPkgVersionCode() const { return mPkgVersionCode; } // this key is for the overall record -- "codec", "player", "drm", etc MediaAnalyticsItem &MediaAnalyticsItem::setKey(MediaAnalyticsItem::Key key) { mKey = key; Loading Loading @@ -263,11 +283,29 @@ MediaAnalyticsItem::Prop *MediaAnalyticsItem::allocateProp(const char *name) { i = mPropCount++; prop = &mProps[i]; prop->setName(name, len); prop->mType = kTypeNone; // make caller set type info } return prop; } // used within the summarizers; return whether property existed bool MediaAnalyticsItem::removeProp(const char *name) { size_t len = strlen(name); size_t i = findPropIndex(name, len); if (i < mPropCount) { Prop *prop = &mProps[i]; clearProp(prop); if (i != mPropCount-1) { // in the middle, bring last one down to fill gap mProps[i] = mProps[mPropCount-1]; } mPropCount--; return true; } return false; } // set the values void MediaAnalyticsItem::setInt32(MediaAnalyticsItem::Attr name, int32_t value) { Prop *prop = allocateProp(name); Loading Loading @@ -568,6 +606,10 @@ int32_t MediaAnalyticsItem::readFromParcel(const Parcel& data) { // into 'this' object // .. we make a copy of the string to put away. mKey = data.readCString(); mPid = data.readInt32(); mUid = data.readInt32(); mPkgName = data.readCString(); mPkgVersionCode = data.readInt32(); mSessionID = data.readInt64(); mFinalized = data.readInt32(); mTimestamp = data.readInt64(); Loading Loading @@ -611,6 +653,10 @@ int32_t MediaAnalyticsItem::writeToParcel(Parcel *data) { data->writeCString(mKey.c_str()); data->writeInt32(mPid); data->writeInt32(mUid); data->writeCString(mPkgName.c_str()); data->writeInt32(mPkgVersionCode); data->writeInt64(mSessionID); data->writeInt32(mFinalized); data->writeInt64(mTimestamp); Loading Loading @@ -651,21 +697,54 @@ int32_t MediaAnalyticsItem::writeToParcel(Parcel *data) { AString MediaAnalyticsItem::toString() { return toString(-1); } AString MediaAnalyticsItem::toString(int version) { // v0 : released with 'o' // v1 : bug fix (missing pid/finalized separator), // adds apk name, apk version code AString result = "("; if (version <= PROTO_FIRST) { // default to original v0 format, until proper parsers are in place version = PROTO_V0; } else if (version > PROTO_LAST) { version = PROTO_LAST; } AString result; char buffer[512]; if (version == PROTO_V0) { result = "("; } else { snprintf(buffer, sizeof(buffer), "[%d:", version); result.append(buffer); } // same order as we spill into the parcel, although not required // key+session are our primary matching criteria //RBE ALOGD("mKey.c_str"); result.append(mKey.c_str()); //RBE ALOGD("post-mKey.c_str"); result.append(":"); snprintf(buffer, sizeof(buffer), "%" PRId64 ":", mSessionID); result.append(buffer); // we need these internally, but don't want to upload them snprintf(buffer, sizeof(buffer), "%d:%d", mUid, mPid); snprintf(buffer, sizeof(buffer), "%d:", mUid); result.append(buffer); if (version >= PROTO_V1) { result.append(mPkgName); snprintf(buffer, sizeof(buffer), ":%d:", mPkgVersionCode); result.append(buffer); } // in 'o' (v1) , the separator between pid and finalized was omitted if (version <= PROTO_V0) { snprintf(buffer, sizeof(buffer), "%d", mPid); } else { snprintf(buffer, sizeof(buffer), "%d:", mPid); } result.append(buffer); snprintf(buffer, sizeof(buffer), "%d:", mFinalized); Loading Loading @@ -713,7 +792,11 @@ AString MediaAnalyticsItem::toString() { result.append(buffer); } if (version == PROTO_V0) { result.append(")"); } else { result.append("]"); } return result; } Loading media/libmediametrics/include/MediaAnalyticsItem.h +18 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,14 @@ class MediaAnalyticsItem { typedef const char *Attr; enum { PROTO_V0 = 0, PROTO_FIRST = PROTO_V0, PROTO_V1 = 1, PROTO_LAST = PROTO_V1, }; public: // access functions for the class Loading Loading @@ -161,11 +169,18 @@ class MediaAnalyticsItem { MediaAnalyticsItem &setUid(uid_t); uid_t getUid() const; MediaAnalyticsItem &setPkgName(AString); AString getPkgName() const; MediaAnalyticsItem &setPkgVersionCode(int32_t); int32_t getPkgVersionCode() const; // our serialization code for binder calls int32_t writeToParcel(Parcel *); int32_t readFromParcel(const Parcel&); AString toString(); AString toString(int version); // are we collecting analytics data static bool isEnabled(); Loading @@ -188,6 +203,8 @@ class MediaAnalyticsItem { // to help validate that A doesn't mess with B's records pid_t mPid; uid_t mUid; AString mPkgName; int32_t mPkgVersionCode; // let's reuse a binder connection static sp<IMediaAnalyticsService> sAnalyticsService; Loading Loading @@ -228,6 +245,7 @@ class MediaAnalyticsItem { size_t findPropIndex(const char *name, size_t len); Prop *findProp(const char *name); Prop *allocateProp(const char *name); bool removeProp(const char *name); size_t mPropCount; size_t mPropSize; Loading media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ NuPlayerDriver::NuPlayerDriver(pid_t pid) mPlayer(new NuPlayer(pid, mMediaClock)), mPlayerFlags(0), mAnalyticsItem(NULL), mClientUid(-1), mAtEOS(false), mLooping(false), mAutoLoop(false) { Loading Loading @@ -111,6 +112,10 @@ status_t NuPlayerDriver::initCheck() { status_t NuPlayerDriver::setUID(uid_t uid) { mPlayer->setUID(uid); mClientUid = uid; if (mAnalyticsItem) { mAnalyticsItem->setUid(mClientUid); } return OK; } Loading Loading @@ -603,6 +608,7 @@ void NuPlayerDriver::logMetrics(const char *where) { mAnalyticsItem = new MediaAnalyticsItem("nuplayer"); if (mAnalyticsItem) { mAnalyticsItem->generateSessionID(); mAnalyticsItem->setUid(mClientUid); } } else { ALOGV("did not have anything to record"); Loading media/libmediaplayerservice/nuplayer/NuPlayerDriver.h +2 −0 Original line number Diff line number Diff line Loading @@ -134,11 +134,13 @@ private: uint32_t mPlayerFlags; MediaAnalyticsItem *mAnalyticsItem; uid_t mClientUid; bool mAtEOS; bool mLooping; bool mAutoLoop; void updateMetrics(const char *where); void logMetrics(const char *where); Loading media/libstagefright/MPEG4Extractor.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -5224,6 +5224,7 @@ MPEG4Extractor::Track *MPEG4Extractor::findTrackByMimePrefix( void MPEG4Extractor::populateMetrics() { ALOGV("MPEG4Extractor::populateMetrics"); // write into mAnalyticsItem } static bool LegacySniffMPEG4( Loading Loading
media/libmediametrics/MediaAnalyticsItem.cpp +89 −6 Original line number Diff line number Diff line Loading @@ -120,6 +120,8 @@ MediaAnalyticsItem *MediaAnalyticsItem::dup() { // key as part of constructor dst->mPid = this->mPid; dst->mUid = this->mUid; dst->mPkgName = this->mPkgName; dst->mPkgVersionCode = this->mPkgVersionCode; dst->mSessionID = this->mSessionID; dst->mTimestamp = this->mTimestamp; dst->mFinalized = this->mFinalized; Loading Loading @@ -201,6 +203,24 @@ uid_t MediaAnalyticsItem::getUid() const { return mUid; } MediaAnalyticsItem &MediaAnalyticsItem::setPkgName(AString pkgName) { mPkgName = pkgName; return *this; } AString MediaAnalyticsItem::getPkgName() const { return mPkgName; } MediaAnalyticsItem &MediaAnalyticsItem::setPkgVersionCode(int32_t pkgVersionCode) { mPkgVersionCode = pkgVersionCode; return *this; } int32_t MediaAnalyticsItem::getPkgVersionCode() const { return mPkgVersionCode; } // this key is for the overall record -- "codec", "player", "drm", etc MediaAnalyticsItem &MediaAnalyticsItem::setKey(MediaAnalyticsItem::Key key) { mKey = key; Loading Loading @@ -263,11 +283,29 @@ MediaAnalyticsItem::Prop *MediaAnalyticsItem::allocateProp(const char *name) { i = mPropCount++; prop = &mProps[i]; prop->setName(name, len); prop->mType = kTypeNone; // make caller set type info } return prop; } // used within the summarizers; return whether property existed bool MediaAnalyticsItem::removeProp(const char *name) { size_t len = strlen(name); size_t i = findPropIndex(name, len); if (i < mPropCount) { Prop *prop = &mProps[i]; clearProp(prop); if (i != mPropCount-1) { // in the middle, bring last one down to fill gap mProps[i] = mProps[mPropCount-1]; } mPropCount--; return true; } return false; } // set the values void MediaAnalyticsItem::setInt32(MediaAnalyticsItem::Attr name, int32_t value) { Prop *prop = allocateProp(name); Loading Loading @@ -568,6 +606,10 @@ int32_t MediaAnalyticsItem::readFromParcel(const Parcel& data) { // into 'this' object // .. we make a copy of the string to put away. mKey = data.readCString(); mPid = data.readInt32(); mUid = data.readInt32(); mPkgName = data.readCString(); mPkgVersionCode = data.readInt32(); mSessionID = data.readInt64(); mFinalized = data.readInt32(); mTimestamp = data.readInt64(); Loading Loading @@ -611,6 +653,10 @@ int32_t MediaAnalyticsItem::writeToParcel(Parcel *data) { data->writeCString(mKey.c_str()); data->writeInt32(mPid); data->writeInt32(mUid); data->writeCString(mPkgName.c_str()); data->writeInt32(mPkgVersionCode); data->writeInt64(mSessionID); data->writeInt32(mFinalized); data->writeInt64(mTimestamp); Loading Loading @@ -651,21 +697,54 @@ int32_t MediaAnalyticsItem::writeToParcel(Parcel *data) { AString MediaAnalyticsItem::toString() { return toString(-1); } AString MediaAnalyticsItem::toString(int version) { // v0 : released with 'o' // v1 : bug fix (missing pid/finalized separator), // adds apk name, apk version code AString result = "("; if (version <= PROTO_FIRST) { // default to original v0 format, until proper parsers are in place version = PROTO_V0; } else if (version > PROTO_LAST) { version = PROTO_LAST; } AString result; char buffer[512]; if (version == PROTO_V0) { result = "("; } else { snprintf(buffer, sizeof(buffer), "[%d:", version); result.append(buffer); } // same order as we spill into the parcel, although not required // key+session are our primary matching criteria //RBE ALOGD("mKey.c_str"); result.append(mKey.c_str()); //RBE ALOGD("post-mKey.c_str"); result.append(":"); snprintf(buffer, sizeof(buffer), "%" PRId64 ":", mSessionID); result.append(buffer); // we need these internally, but don't want to upload them snprintf(buffer, sizeof(buffer), "%d:%d", mUid, mPid); snprintf(buffer, sizeof(buffer), "%d:", mUid); result.append(buffer); if (version >= PROTO_V1) { result.append(mPkgName); snprintf(buffer, sizeof(buffer), ":%d:", mPkgVersionCode); result.append(buffer); } // in 'o' (v1) , the separator between pid and finalized was omitted if (version <= PROTO_V0) { snprintf(buffer, sizeof(buffer), "%d", mPid); } else { snprintf(buffer, sizeof(buffer), "%d:", mPid); } result.append(buffer); snprintf(buffer, sizeof(buffer), "%d:", mFinalized); Loading Loading @@ -713,7 +792,11 @@ AString MediaAnalyticsItem::toString() { result.append(buffer); } if (version == PROTO_V0) { result.append(")"); } else { result.append("]"); } return result; } Loading
media/libmediametrics/include/MediaAnalyticsItem.h +18 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,14 @@ class MediaAnalyticsItem { typedef const char *Attr; enum { PROTO_V0 = 0, PROTO_FIRST = PROTO_V0, PROTO_V1 = 1, PROTO_LAST = PROTO_V1, }; public: // access functions for the class Loading Loading @@ -161,11 +169,18 @@ class MediaAnalyticsItem { MediaAnalyticsItem &setUid(uid_t); uid_t getUid() const; MediaAnalyticsItem &setPkgName(AString); AString getPkgName() const; MediaAnalyticsItem &setPkgVersionCode(int32_t); int32_t getPkgVersionCode() const; // our serialization code for binder calls int32_t writeToParcel(Parcel *); int32_t readFromParcel(const Parcel&); AString toString(); AString toString(int version); // are we collecting analytics data static bool isEnabled(); Loading @@ -188,6 +203,8 @@ class MediaAnalyticsItem { // to help validate that A doesn't mess with B's records pid_t mPid; uid_t mUid; AString mPkgName; int32_t mPkgVersionCode; // let's reuse a binder connection static sp<IMediaAnalyticsService> sAnalyticsService; Loading Loading @@ -228,6 +245,7 @@ class MediaAnalyticsItem { size_t findPropIndex(const char *name, size_t len); Prop *findProp(const char *name); Prop *allocateProp(const char *name); bool removeProp(const char *name); size_t mPropCount; size_t mPropSize; Loading
media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ NuPlayerDriver::NuPlayerDriver(pid_t pid) mPlayer(new NuPlayer(pid, mMediaClock)), mPlayerFlags(0), mAnalyticsItem(NULL), mClientUid(-1), mAtEOS(false), mLooping(false), mAutoLoop(false) { Loading Loading @@ -111,6 +112,10 @@ status_t NuPlayerDriver::initCheck() { status_t NuPlayerDriver::setUID(uid_t uid) { mPlayer->setUID(uid); mClientUid = uid; if (mAnalyticsItem) { mAnalyticsItem->setUid(mClientUid); } return OK; } Loading Loading @@ -603,6 +608,7 @@ void NuPlayerDriver::logMetrics(const char *where) { mAnalyticsItem = new MediaAnalyticsItem("nuplayer"); if (mAnalyticsItem) { mAnalyticsItem->generateSessionID(); mAnalyticsItem->setUid(mClientUid); } } else { ALOGV("did not have anything to record"); Loading
media/libmediaplayerservice/nuplayer/NuPlayerDriver.h +2 −0 Original line number Diff line number Diff line Loading @@ -134,11 +134,13 @@ private: uint32_t mPlayerFlags; MediaAnalyticsItem *mAnalyticsItem; uid_t mClientUid; bool mAtEOS; bool mLooping; bool mAutoLoop; void updateMetrics(const char *where); void logMetrics(const char *where); Loading
media/libstagefright/MPEG4Extractor.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -5224,6 +5224,7 @@ MPEG4Extractor::Track *MPEG4Extractor::findTrackByMimePrefix( void MPEG4Extractor::populateMetrics() { ALOGV("MPEG4Extractor::populateMetrics"); // write into mAnalyticsItem } static bool LegacySniffMPEG4( Loading