Fix videos app bandwidth accounting for streaming over 4G
Attribute traffic on socket descriptors to UID of videos app Multi-repository commit, see also changes in frameworks/base/media. Includes Widevine library version 4.5.0.6153 Change-Id: I5ddf1b7b758edc82d48a788fc30616d90cab4bd0 related-to-bug: 5434244
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -133,6 +133,11 @@ class WVSession;
|
||||
//
|
||||
|
||||
typedef void (*WVDecryptCallback)(WVEsSelector esType, void* input, void* output, size_t length, int key);
|
||||
|
||||
// Provide info on socket open/close operations for bandwidth attribution
|
||||
// status: {0=open, 1=close}
|
||||
typedef void (*WVSocketInfoCallback)(int fd, int status, void *context);
|
||||
|
||||
struct WVCallbacks {
|
||||
void (*pushData)(unsigned short port, void *buffer, size_t length);
|
||||
void (*response)(WVSession *session, const std::string &response);
|
||||
@@ -144,6 +149,9 @@ struct WVCallbacks {
|
||||
|
||||
int (*getKeyboxPath)(char* path, size_t size);
|
||||
WVDecryptCallback decrypt;
|
||||
|
||||
// publish info about descriptors used for streaming for accounting purposes
|
||||
WVSocketInfoCallback socketInfo;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -425,16 +433,16 @@ WV_CheckBandwidth(const std::string &url, unsigned long *bandwidth, const WVProx
|
||||
//This form is deprecated and may be removed in a future release
|
||||
CLIENT_API WVStatus
|
||||
WV_Setup(WVSession *&session, const std::string &url,
|
||||
const std::string &transport, WVCredentials &credentials,
|
||||
WVOutputFormat outputFormat = WV_OutputFormat_PS,
|
||||
unsigned long bufferSize = 10 * 1024 * 1024);
|
||||
const std::string &transport, WVCredentials &credentials,
|
||||
WVOutputFormat outputFormat = WV_OutputFormat_PS,
|
||||
unsigned long bufferSize = 10 * 1024 * 1024, void *context = NULL);
|
||||
|
||||
// Setup using a proxy
|
||||
CLIENT_API WVStatus
|
||||
WV_Setup(WVSession *&session, const std::string &url,
|
||||
const std::string &transport, WVCredentials &credentials,
|
||||
WVProxySettings &proxy, WVOutputFormat outputFormat = WV_OutputFormat_PS,
|
||||
unsigned long bufferSize = 10 * 1024 * 1024);
|
||||
const std::string &transport, WVCredentials &credentials,
|
||||
WVProxySettings &proxy, WVOutputFormat outputFormat = WV_OutputFormat_PS,
|
||||
unsigned long bufferSize = 10 * 1024 * 1024, void *context = NULL);
|
||||
|
||||
//
|
||||
// An alternate form of WV_Setup that receives data from a file source instead of accessing
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -4,6 +4,7 @@
|
||||
|
||||
#define LOG_TAG "WVMExtractorImpl"
|
||||
#include <utils/Log.h>
|
||||
#include <cutils/qtaguid.h>
|
||||
|
||||
#include "WVMExtractorImpl.h"
|
||||
#include "WVMMediaSource.h"
|
||||
@@ -26,7 +27,6 @@ using namespace android;
|
||||
static sp<DecryptHandle> sDecryptHandle;
|
||||
static DrmManagerClient *sDrmManagerClient;
|
||||
|
||||
|
||||
static void _cb1(char *data, unsigned long size)
|
||||
{
|
||||
DrmBuffer buf(data, size);
|
||||
@@ -96,7 +96,8 @@ WVMExtractorImpl::WVMExtractorImpl(sp<DataSource> dataSource)
|
||||
mUseAdaptiveStreaming(false),
|
||||
mIsLiveStream(false),
|
||||
mSession(NULL),
|
||||
mSetupStatus(OK)
|
||||
mSetupStatus(OK),
|
||||
mUIDIsSet(false)
|
||||
{
|
||||
dataSource->getDrmInfo(sDecryptHandle, &sDrmManagerClient);
|
||||
|
||||
@@ -131,13 +132,15 @@ void WVMExtractorImpl::Initialize()
|
||||
|
||||
#ifdef REQUIRE_SECURE_BUFFERS
|
||||
if (!mIsLiveStream) {
|
||||
WVCallbacks callbacks = {NULL, NULL, NULL, NULL, NULL, NULL, WVMMediaSource::DecryptCallback};
|
||||
WVCallbacks callbacks = {NULL, NULL, NULL, NULL, NULL, NULL, WVMMediaSource::DecryptCallback, SocketInfoCallback};
|
||||
result = WV_Initialize(&callbacks);
|
||||
} else {
|
||||
result = WV_Initialize(NULL);
|
||||
WVCallbacks callbacks = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, SocketInfoCallback};
|
||||
result = WV_Initialize(&callbacks);
|
||||
}
|
||||
#else
|
||||
result = WV_Initialize(NULL);
|
||||
WVCallbacks callbacks = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, SocketInfoCallback};
|
||||
result = WV_Initialize(&callbacks);
|
||||
#endif
|
||||
|
||||
if (result != WV_Status_OK) {
|
||||
@@ -151,7 +154,7 @@ void WVMExtractorImpl::Initialize()
|
||||
// Use the URI - streaming case, only for widevine:// protocol
|
||||
result = WV_Setup(mSession, mDataSource->getUri().string(),
|
||||
"RAW/RAW/RAW;destination=getdata", credentials,
|
||||
WV_OutputFormat_ES, kStreamCacheSize);
|
||||
WV_OutputFormat_ES, kStreamCacheSize, this);
|
||||
} else {
|
||||
// No URI supplied or not adaptive, pull data from the stagefright data source.
|
||||
mFileSource = new WVMFileSource(mDataSource);
|
||||
@@ -184,6 +187,32 @@ void WVMExtractorImpl::cleanup()
|
||||
}
|
||||
}
|
||||
|
||||
void WVMExtractorImpl::SocketInfoCallback(int fd, int closing, void *context)
|
||||
{
|
||||
//ALOGD("WVMExtractorImpl::SocketInfoCallback(%d, %d, %p)", fd, closing, context);
|
||||
|
||||
WVMExtractorImpl *obj = (WVMExtractorImpl *)context;
|
||||
|
||||
if (!obj || !obj->mUIDIsSet) {
|
||||
ALOGW("SocketInfoCallback - UID not set!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!closing) {
|
||||
uint32_t kTag = *(uint32_t *)"WVEX";
|
||||
int res = qtaguid_tagSocket(fd, kTag, obj->mUID);
|
||||
if (res != 0) {
|
||||
ALOGE("Failed tagging socket %d for uid %d (My UID=%d)", fd, obj->mUID, geteuid());
|
||||
}
|
||||
} else {
|
||||
int res = qtaguid_untagSocket(fd);
|
||||
if (res != 0) {
|
||||
ALOGE("Failed untagging socket %d (My UID=%d)", fd, geteuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Configure metadata for video and audio sources
|
||||
//
|
||||
@@ -475,5 +504,12 @@ bool WVMExtractorImpl::getAdaptiveStreamingMode() const
|
||||
return mUseAdaptiveStreaming;
|
||||
}
|
||||
|
||||
void WVMExtractorImpl::setUID(uid_t uid)
|
||||
{
|
||||
//ALOGD("WVMExtractorImpl::setUID(%d)", (uint32_t)uid);
|
||||
mUID = uid;
|
||||
mUIDIsSet = true;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@ public:
|
||||
virtual void setAdaptiveStreamingMode(bool adaptive);
|
||||
bool getAdaptiveStreamingMode() const;
|
||||
|
||||
virtual void setUID(uid_t uid);
|
||||
|
||||
static void SocketInfoCallback(int fd, int op, void *context);
|
||||
static void cleanup();
|
||||
|
||||
protected:
|
||||
@@ -63,6 +66,9 @@ private:
|
||||
|
||||
status_t mSetupStatus;
|
||||
|
||||
bool mUIDIsSet;
|
||||
uid_t mUID;
|
||||
|
||||
status_t readMetaData();
|
||||
|
||||
const static size_t kStreamCacheSize = 10 * 1024 * 1024;
|
||||
|
||||
Reference in New Issue
Block a user