|
|
|
@ -31,28 +31,31 @@
|
|
|
|
|
// ALL functions returning a char * give responsibility for the allocated buffer
|
|
|
|
|
// to the caller. The caller is responsible to call free() on that pointer.
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
using namespace android::mediametrics;
|
|
|
|
|
|
|
|
|
|
// manage the overall record
|
|
|
|
|
mediametrics_handle_t mediametrics_create(mediametricskey_t key) {
|
|
|
|
|
android::mediametrics::Item *item = android::mediametrics::Item::create(key);
|
|
|
|
|
Item *item = Item::create(key);
|
|
|
|
|
return (mediametrics_handle_t) item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mediametrics_delete(mediametrics_handle_t handle) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return;
|
|
|
|
|
delete item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mediametricskey_t mediametrics_getKey(mediametrics_handle_t handle) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return NULL;
|
|
|
|
|
return strdup(item->getKey().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// nuplayer, et al use it when acting as proxies
|
|
|
|
|
void mediametrics_setUid(mediametrics_handle_t handle, uid_t uid) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->setUid(uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -61,31 +64,31 @@ void mediametrics_setUid(mediametrics_handle_t handle, uid_t uid) {
|
|
|
|
|
|
|
|
|
|
void mediametrics_setInt32(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
int32_t value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->setInt32(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mediametrics_setInt64(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
int64_t value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->setInt64(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mediametrics_setDouble(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
double value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->setDouble(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mediametrics_setRate(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
int64_t count, int64_t duration) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->setRate(attr, count, duration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mediametrics_setCString(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
const char *value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->setCString(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -94,25 +97,25 @@ void mediametrics_setCString(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
|
|
|
|
|
void mediametrics_addInt32(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
int32_t value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->addInt32(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mediametrics_addInt64(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
int64_t value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->addInt64(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mediametrics_addDouble(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
double value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->addDouble(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mediametrics_addRate(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
int64_t count, int64_t duration) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item != NULL) item->addRate(attr, count, duration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -123,28 +126,28 @@ void mediametrics_addRate(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
|
|
|
|
|
bool mediametrics_getInt32(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
int32_t * value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return false;
|
|
|
|
|
return item->getInt32(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool mediametrics_getInt64(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
int64_t * value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return false;
|
|
|
|
|
return item->getInt64(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool mediametrics_getDouble(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
double *value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return false;
|
|
|
|
|
return item->getDouble(attr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool mediametrics_getRate(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
int64_t * count, int64_t * duration, double *rate) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return false;
|
|
|
|
|
return item->getRate(attr, count, duration, rate);
|
|
|
|
|
}
|
|
|
|
@ -152,7 +155,7 @@ bool mediametrics_getRate(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
// NB: caller owns the string that comes back, is responsible for freeing it
|
|
|
|
|
bool mediametrics_getCString(mediametrics_handle_t handle, attr_t attr,
|
|
|
|
|
char **value) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return false;
|
|
|
|
|
|
|
|
|
|
return item->getCString(attr, value);
|
|
|
|
@ -164,36 +167,36 @@ void mediametrics_freeCString(char *value) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool mediametrics_selfRecord(mediametrics_handle_t handle) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return false;
|
|
|
|
|
return item->selfrecord();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mediametrics_handle_t mediametrics_dup(mediametrics_handle_t handle) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
if (item == NULL) return android::mediametrics::Item::convert(item);
|
|
|
|
|
return android::mediametrics::Item::convert(item->dup());
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return Item::convert(item);
|
|
|
|
|
return Item::convert(item->dup());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *mediametrics_readable(mediametrics_handle_t handle) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return "";
|
|
|
|
|
return item->toCString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t mediametrics_count(mediametrics_handle_t handle) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return 0;
|
|
|
|
|
return item->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool mediametrics_isEnabled() {
|
|
|
|
|
// static, so doesn't need an instance
|
|
|
|
|
return android::mediametrics::Item::isEnabled();
|
|
|
|
|
return Item::isEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool mediametrics_getAttributes(mediametrics_handle_t handle, char **buffer, size_t *length) {
|
|
|
|
|
android::mediametrics::Item *item = (android::mediametrics::Item *) handle;
|
|
|
|
|
Item *item = (Item *) handle;
|
|
|
|
|
if (item == NULL) return false;
|
|
|
|
|
return item->writeToByteString(buffer, length) == android::NO_ERROR;
|
|
|
|
|
|
|
|
|
|