Merge "MediaPlayer2: remove libnetd_client dependency."

gugelfrei
TreeHugger Robot 6 years ago committed by Android (Google) Code Review
commit eb0769ba1a

@ -29,6 +29,7 @@ cc_library_shared {
"libmediametrics",
"libmediautils",
"libmemunreachable",
"libnetd_client",
"libpowermanager",
"libstagefright",
"libstagefright_foundation",

@ -114,30 +114,4 @@ void HTTPBase::setBandwidthHistorySize(size_t numHistoryItems) {
mMaxBandwidthHistoryItems = numHistoryItems;
}
// static
void HTTPBase::RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag) {
int res = qtaguid_tagSocket(sockfd, kTag, uid);
if (res != 0) {
ALOGE("Failed tagging socket %d for uid %d (My UID=%d)", sockfd, uid, geteuid());
}
}
// static
void HTTPBase::UnRegisterSocketUserTag(int sockfd) {
int res = qtaguid_untagSocket(sockfd);
if (res != 0) {
ALOGE("Failed untagging socket %d (My UID=%d)", sockfd, geteuid());
}
}
// static
void HTTPBase::RegisterSocketUserMark(int sockfd, uid_t uid) {
setNetworkForUser(uid, sockfd);
}
// static
void HTTPBase::UnRegisterSocketUserMark(int sockfd) {
RegisterSocketUserMark(sockfd, geteuid());
}
} // namespace android

@ -51,12 +51,6 @@ struct HTTPBase : public DataSource {
virtual void setBandwidthHistorySize(size_t numHistoryItems);
static void RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag);
static void UnRegisterSocketUserTag(int sockfd);
static void RegisterSocketUserMark(int sockfd, uid_t uid);
static void UnRegisterSocketUserMark(int sockfd);
virtual String8 toString() {
return mName;
}

@ -19,6 +19,7 @@
#include <utils/Log.h>
#include "ARTSPConnection.h"
#include "NetworkUtils.h"
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
@ -59,8 +60,8 @@ ARTSPConnection::~ARTSPConnection() {
if (mSocket >= 0) {
ALOGE("Connection is still open, closing the socket.");
if (mUIDValid) {
HTTPBase::UnRegisterSocketUserTag(mSocket);
HTTPBase::UnRegisterSocketUserMark(mSocket);
NetworkUtils::UnRegisterSocketUserTag(mSocket);
NetworkUtils::UnRegisterSocketUserMark(mSocket);
}
close(mSocket);
mSocket = -1;
@ -214,8 +215,8 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) {
if (mState != DISCONNECTED) {
if (mUIDValid) {
HTTPBase::UnRegisterSocketUserTag(mSocket);
HTTPBase::UnRegisterSocketUserMark(mSocket);
NetworkUtils::UnRegisterSocketUserTag(mSocket);
NetworkUtils::UnRegisterSocketUserMark(mSocket);
}
close(mSocket);
mSocket = -1;
@ -266,9 +267,9 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) {
mSocket = socket(AF_INET, SOCK_STREAM, 0);
if (mUIDValid) {
HTTPBase::RegisterSocketUserTag(mSocket, mUID,
NetworkUtils::RegisterSocketUserTag(mSocket, mUID,
(uint32_t)*(uint32_t*) "RTSP");
HTTPBase::RegisterSocketUserMark(mSocket, mUID);
NetworkUtils::RegisterSocketUserMark(mSocket, mUID);
}
MakeSocketBlocking(mSocket, false);
@ -297,8 +298,8 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) {
mState = DISCONNECTED;
if (mUIDValid) {
HTTPBase::UnRegisterSocketUserTag(mSocket);
HTTPBase::UnRegisterSocketUserMark(mSocket);
NetworkUtils::UnRegisterSocketUserTag(mSocket);
NetworkUtils::UnRegisterSocketUserMark(mSocket);
}
close(mSocket);
mSocket = -1;
@ -315,8 +316,8 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) {
void ARTSPConnection::performDisconnect() {
if (mUIDValid) {
HTTPBase::UnRegisterSocketUserTag(mSocket);
HTTPBase::UnRegisterSocketUserMark(mSocket);
NetworkUtils::UnRegisterSocketUserTag(mSocket);
NetworkUtils::UnRegisterSocketUserMark(mSocket);
}
close(mSocket);
mSocket = -1;
@ -389,8 +390,8 @@ void ARTSPConnection::onCompleteConnection(const sp<AMessage> &msg) {
mState = DISCONNECTED;
if (mUIDValid) {
HTTPBase::UnRegisterSocketUserTag(mSocket);
HTTPBase::UnRegisterSocketUserMark(mSocket);
NetworkUtils::UnRegisterSocketUserTag(mSocket);
NetworkUtils::UnRegisterSocketUserMark(mSocket);
}
close(mSocket);
mSocket = -1;

@ -1,5 +1,5 @@
cc_library_static {
name: "libstagefright_rtsp",
cc_defaults {
name: "libstagefright_rtsp_defaults",
srcs: [
"AAMRAssembler.cpp",
@ -52,6 +52,21 @@ cc_library_static {
},
}
cc_library_static {
name: "libstagefright_rtsp",
srcs: ["NetworkUtils.cpp"],
header_libs: ["libnetd_client_headers"],
defaults: ["libstagefright_rtsp_defaults"],
}
cc_library_static {
name: "libstagefright_rtsp_player2",
srcs: ["NetworkUtilsForAppProc.cpp"],
defaults: ["libstagefright_rtsp_defaults"],
}
//###############################################################################
cc_test {

@ -31,6 +31,7 @@
#include "ARTPConnection.h"
#include "ARTSPConnection.h"
#include "ASessionDescription.h"
#include "NetworkUtils.h"
#include <ctype.h>
#include <cutils/properties.h>
@ -757,10 +758,10 @@ struct MyHandler : public AHandler {
if (!track->mUsingInterleavedTCP) {
// Clear the tag
if (mUIDValid) {
HTTPBase::UnRegisterSocketUserTag(track->mRTPSocket);
HTTPBase::UnRegisterSocketUserMark(track->mRTPSocket);
HTTPBase::UnRegisterSocketUserTag(track->mRTCPSocket);
HTTPBase::UnRegisterSocketUserMark(track->mRTCPSocket);
NetworkUtils::UnRegisterSocketUserTag(track->mRTPSocket);
NetworkUtils::UnRegisterSocketUserMark(track->mRTPSocket);
NetworkUtils::UnRegisterSocketUserTag(track->mRTCPSocket);
NetworkUtils::UnRegisterSocketUserMark(track->mRTCPSocket);
}
close(track->mRTPSocket);
@ -886,10 +887,10 @@ struct MyHandler : public AHandler {
// Clear the tag
if (mUIDValid) {
HTTPBase::UnRegisterSocketUserTag(info->mRTPSocket);
HTTPBase::UnRegisterSocketUserMark(info->mRTPSocket);
HTTPBase::UnRegisterSocketUserTag(info->mRTCPSocket);
HTTPBase::UnRegisterSocketUserMark(info->mRTCPSocket);
NetworkUtils::UnRegisterSocketUserTag(info->mRTPSocket);
NetworkUtils::UnRegisterSocketUserMark(info->mRTPSocket);
NetworkUtils::UnRegisterSocketUserTag(info->mRTCPSocket);
NetworkUtils::UnRegisterSocketUserMark(info->mRTCPSocket);
}
close(info->mRTPSocket);
@ -1665,12 +1666,12 @@ private:
&info->mRTPSocket, &info->mRTCPSocket, &rtpPort);
if (mUIDValid) {
HTTPBase::RegisterSocketUserTag(info->mRTPSocket, mUID,
(uint32_t)*(uint32_t*) "RTP_");
HTTPBase::RegisterSocketUserTag(info->mRTCPSocket, mUID,
(uint32_t)*(uint32_t*) "RTP_");
HTTPBase::RegisterSocketUserMark(info->mRTPSocket, mUID);
HTTPBase::RegisterSocketUserMark(info->mRTCPSocket, mUID);
NetworkUtils::RegisterSocketUserTag(info->mRTPSocket, mUID,
(uint32_t)*(uint32_t*) "RTP_");
NetworkUtils::RegisterSocketUserTag(info->mRTCPSocket, mUID,
(uint32_t)*(uint32_t*) "RTP_");
NetworkUtils::RegisterSocketUserMark(info->mRTPSocket, mUID);
NetworkUtils::RegisterSocketUserMark(info->mRTCPSocket, mUID);
}
request.append("Transport: RTP/AVP/UDP;unicast;client_port=");

@ -0,0 +1,53 @@
/*
* Copyright (C) 2018 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 "NetworkUtils"
#include <utils/Log.h>
#include "NetworkUtils.h"
#include <cutils/qtaguid.h>
#include <NetdClient.h>
namespace android {
// static
void NetworkUtils::RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag) {
int res = qtaguid_tagSocket(sockfd, kTag, uid);
if (res != 0) {
ALOGE("Failed tagging socket %d for uid %d (My UID=%d)", sockfd, uid, geteuid());
}
}
// static
void NetworkUtils::UnRegisterSocketUserTag(int sockfd) {
int res = qtaguid_untagSocket(sockfd);
if (res != 0) {
ALOGE("Failed untagging socket %d (My UID=%d)", sockfd, geteuid());
}
}
// static
void NetworkUtils::RegisterSocketUserMark(int sockfd, uid_t uid) {
setNetworkForUser(uid, sockfd);
}
// static
void NetworkUtils::UnRegisterSocketUserMark(int sockfd) {
RegisterSocketUserMark(sockfd, geteuid());
}
} // namespace android

@ -0,0 +1,32 @@
/*
* Copyright (C) 2018 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.
*/
#ifndef NETWORK_UTILS_H_
#define NETWORK_UTILS_H_
namespace android {
struct NetworkUtils {
static void RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag);
static void UnRegisterSocketUserTag(int sockfd);
static void RegisterSocketUserMark(int sockfd, uid_t uid);
static void UnRegisterSocketUserMark(int sockfd);
};
} // namespace android
#endif // NETWORK_UTILS_H_

@ -0,0 +1,46 @@
/*
* Copyright (C) 2018 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 "NetworkUtils"
#include <utils/Log.h>
#include "NetworkUtils.h"
// NetworkUtils implementation for application process.
namespace android {
// static
void NetworkUtils::RegisterSocketUserTag(int, uid_t, uint32_t) {
// No op. Framework already handles the data usage billing for applications.
}
// static
void NetworkUtils::UnRegisterSocketUserTag(int) {
// No op.
}
// static
void NetworkUtils::RegisterSocketUserMark(int, uid_t) {
// No op. Framework already handles the data usage billing for applications.
}
// static
void NetworkUtils::UnRegisterSocketUserMark(int) {
// No op.
}
} // namespace android
Loading…
Cancel
Save