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