diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3d7b485b9bd1a13e131853c8cbb7d93dfd38b5b6..528d3d2fbcd95b833023259ea5e64d9d41321f10 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,6 +4,7 @@
+
diff --git a/app/src/main/java/com/huawei/cloudapp/ui/activity/CasCloudPhoneActivity.java b/app/src/main/java/com/huawei/cloudapp/ui/activity/CasCloudPhoneActivity.java
index f4445eddb9e7a2652e22956a78aa53d65ae4e3d0..3494f9cef125fc7841019b22804c034c45072f41 100644
--- a/app/src/main/java/com/huawei/cloudapp/ui/activity/CasCloudPhoneActivity.java
+++ b/app/src/main/java/com/huawei/cloudapp/ui/activity/CasCloudPhoneActivity.java
@@ -52,6 +52,7 @@ import static com.huawei.cloudphone.api.CloudPhoneParas.DEV_TYPE_MICROPHONE;
import static com.huawei.cloudphone.api.CloudPhoneParas.DevType.DEV_PHONE;
import static com.huawei.cloudphone.utils.CasConstantsUtil.CLIENT_MODE;
+import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ClipData;
@@ -67,6 +68,16 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.telephony.CellSignalStrength;
+import android.telephony.CellSignalStrengthCdma;
+import android.telephony.CellSignalStrengthGsm;
+import android.telephony.CellSignalStrengthLte;
+import android.telephony.CellSignalStrengthNr;
+import android.telephony.CellSignalStrengthTdscdma;
+import android.telephony.CellSignalStrengthWcdma;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
@@ -341,7 +352,12 @@ public class CasCloudPhoneActivity extends FragmentActivity implements IHandleDa
if (mStatisticsTextView.getVisibility() != View.VISIBLE) {
return;
}
- mStatisticsTextView.setText(mCloudPhone.getVideoStatisticInfo());
+
+ String str = "网络数据>>\n";
+ str += mCloudPhone.getVideoStatisticInfo();
+ str += "\n";
+ str += getTowerInfo();
+ mStatisticsTextView.setText(str);
}
/**
@@ -634,6 +650,67 @@ public class CasCloudPhoneActivity extends FragmentActivity implements IHandleDa
return false;
}
+ private String getTowerInfo() {
+ int rssi = -1;
+ int subscriberId;
+ StringBuilder tower = new StringBuilder("基站数据>>");
+
+ SubscriptionManager subscriptionManager = (SubscriptionManager) this.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+ if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+ ActivityCompat.requestPermissions(this, new String[]{ Manifest.permission.READ_PHONE_STATE }, 101);
+ tower.append("\n未授权");
+ return tower.toString();
+ }
+ TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
+ List subInfos = subscriptionManager.getActiveSubscriptionInfoList();
+ if (subInfos.isEmpty()) {
+ tower.append("\n无sim卡");
+ return tower.toString();
+ }
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
+ tower.append("\n当前手机版本过低,无法获取数据");
+ return tower.toString();
+ }
+ subscriberId = SubscriptionManager.getActiveDataSubscriptionId();
+ for (SubscriptionInfo subInfo:subInfos) {
+ if (subscriberId != subInfo.getSubscriptionId()) {
+ continue;
+ }
+ TelephonyManager tm2 = tm.createForSubscriptionId(subInfo.getSubscriptionId());
+
+ tower.append("\nmcc : ").append(subInfo.getMccString());
+ tower.append("\nmnc : ").append(subInfo.getMncString());
+ String dataType = "";
+
+ List cellSignalStrengths = tm2.getSignalStrength().getCellSignalStrengths();
+ for (CellSignalStrength cellSignalStrength:cellSignalStrengths) {
+ if (cellSignalStrength instanceof CellSignalStrengthCdma) {
+ dataType = "CDMA";
+ rssi = ((CellSignalStrengthCdma) cellSignalStrength).getCdmaDbm();
+ } else if (cellSignalStrength instanceof CellSignalStrengthGsm) {
+ dataType = "GSM";
+ rssi = ((CellSignalStrengthGsm) cellSignalStrength).getDbm();
+ } else if (cellSignalStrength instanceof CellSignalStrengthLte) {
+ dataType = "LTE";
+ rssi = ((CellSignalStrengthLte) cellSignalStrength).getDbm();
+ } else if (cellSignalStrength instanceof CellSignalStrengthNr) {
+ dataType = "NR";
+ rssi = ((CellSignalStrengthNr) cellSignalStrength).getDbm();
+ } else if (cellSignalStrength instanceof CellSignalStrengthTdscdma) {
+ dataType = "TDSCDMA";
+ rssi = ((CellSignalStrengthTdscdma) cellSignalStrength).getDbm();
+ } else if (cellSignalStrength instanceof CellSignalStrengthWcdma) {
+ dataType = "WCDMA";
+ rssi = ((CellSignalStrengthWcdma) cellSignalStrength).getDbm();
+ }
+ }
+ tower.append("\nnetType : ").append(dataType);
+ tower.append("\nrssi : ").append(rssi);
+ tower.append("\noperator : ").append(subInfo.getDisplayName());
+ }
+ return tower.toString();
+ }
+
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK && bIsStart)) {
diff --git a/app/src/main/res/layout/cas_activity_fullscreen.xml b/app/src/main/res/layout/cas_activity_fullscreen.xml
index 7caa7c27b64efb9f9b635b98ed5b655334e37fdf..f170d41be6a4fe2a3aa44692e9c778a827ba4cd1 100644
--- a/app/src/main/res/layout/cas_activity_fullscreen.xml
+++ b/app/src/main/res/layout/cas_activity_fullscreen.xml
@@ -24,13 +24,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="165dp"
- android:layout_gravity="end"
- android:text="网络时延" />
+ android:layout_gravity="start" />
GetRtt();
+ uint64_t lag = GetLag() / 1000;
stream << "网络时延 : ";
- if (rtt != -1) {
- stream << rtt << "ms";
+ if (lag != 0) {
+ stream << lag << "ms";
}
stream << std::endl;
@@ -1367,7 +1367,8 @@ std::string CasController::GetVideoRecvStats() {
}
}
#endif
- stream << "帧率 : " << m_currentFPS << "fps" << std::endl;
+ stream << "帧率 : " << GetCurrentFPS() << "fps" << std::endl;
+ stream << "策略丢帧 : " << CasVideoUtil::GetInstance()->GetCurrentDropFPS() << "fps" << std::endl;
statsString = stream.str();
return statsString;
@@ -1378,12 +1379,20 @@ void CasController::CalculateFPS() {
m_videoDataCount++;
- if (m_lastTimeGotVideoData == 0) {
- m_lastTimeGotVideoData = currentTime;
+ if (m_lastTimeRefreshFPS == 0) {
+ m_lastTimeRefreshFPS = currentTime;
}
- if (currentTime - m_lastTimeGotVideoData > DURATION_USEC) {
+ if (currentTime - m_lastTimeRefreshFPS > DURATION_USEC) {
m_currentFPS = m_videoDataCount;
m_videoDataCount = 0;
- m_lastTimeGotVideoData = currentTime;
+ m_lastTimeRefreshFPS = currentTime;
}
+}
+
+int CasController::GetCurrentFPS() const {
+ uint64_t currentTime = CasVideoUtil::GetInstance()->GetNow();
+ if (currentTime - m_lastTimeRefreshFPS > 2 * DURATION_USEC) {
+ return 0;
+ }
+ return m_currentFPS;
}
\ No newline at end of file
diff --git a/cloudphone/src/main/cpp/CasController.h b/cloudphone/src/main/cpp/CasController.h
index 3aa6a97e2a5fb7bccb0e78d7b3135b6ed57a62c0..d50843c76f54c25ba5258f7f919f22ddea16251b 100644
--- a/cloudphone/src/main/cpp/CasController.h
+++ b/cloudphone/src/main/cpp/CasController.h
@@ -133,6 +133,7 @@ private:
std::string CalcMaxDisconnectDuration(std::string backgroundTimeout);
void CalculateFPS();
+ int GetCurrentFPS() const;
void *(*cmdCallBack)(int type, std::string msg) = nullptr;
@@ -185,7 +186,7 @@ private:
bool m_isMTransValid = false;
int m_videoDataCount = 0;
int m_currentFPS = 0;
- uint64_t m_lastTimeGotVideoData = 0;
+ uint64_t m_lastTimeRefreshFPS = 0;
};
#endif // CLOUDAPPSDK_CASCONTROLLRT_H
\ No newline at end of file
diff --git a/cloudphone/src/main/cpp/cas_decoder/CasDecodeController.cpp b/cloudphone/src/main/cpp/cas_decoder/CasDecodeController.cpp
index bc877bb6f5b46dd110b8509756cdf2dcea0e7e86..27410092a390a1aaa17d85429178b3a4da075790 100644
--- a/cloudphone/src/main/cpp/cas_decoder/CasDecodeController.cpp
+++ b/cloudphone/src/main/cpp/cas_decoder/CasDecodeController.cpp
@@ -117,6 +117,7 @@ void FrameCallback(long frameTime, void* data)
// 是否丢帧
if (isDiscard) {
g_controller->m_DiscardFrameNum++;
+ CasVideoUtil::GetInstance()->DropOneFrame();
INFO("FrameCallback start discard, frameBuffer=%lu, index=%u, last index=%lu, m_DiscardFrameNum=%lu, m_InputFrameNum=%lu, m_DisplayFrameNum=%lu",
frameBuffer, updatePatternIdx, g_controller->m_UpdatePatternIdx, g_controller->m_DiscardFrameNum, g_controller->m_InputFrameNum, g_controller->m_DisplayFrameNum);
}
diff --git a/cloudphone/src/main/cpp/cas_decoder/CasVideoUtil.cpp b/cloudphone/src/main/cpp/cas_decoder/CasVideoUtil.cpp
index dd4c27cd731d2183d74307d7bae13d54866a110f..f56b7ead3e24673c5b135d8ee1b6d229f82294b0 100644
--- a/cloudphone/src/main/cpp/cas_decoder/CasVideoUtil.cpp
+++ b/cloudphone/src/main/cpp/cas_decoder/CasVideoUtil.cpp
@@ -153,4 +153,27 @@ void CasVideoUtil::Release() noexcept
delete m_frameQueue;
m_frameQueue = nullptr;
}
+}
+
+void CasVideoUtil::DropOneFrame() {
+ uint64_t currentTime = GetNow();
+
+ m_VideoDropCount++;
+
+ if (m_lastTimeRefreshDropFPS == 0) {
+ m_lastTimeRefreshDropFPS = currentTime;
+ }
+ if (currentTime - m_lastTimeRefreshDropFPS > DURATION_USEC) {
+ m_VideoDropFPS = m_VideoDropCount;
+ m_VideoDropCount = 0;
+ m_lastTimeRefreshDropFPS = currentTime;
+ }
+}
+
+int CasVideoUtil::GetCurrentDropFPS() {
+ uint64_t currentTime = GetNow();
+ if (currentTime - m_lastTimeRefreshDropFPS > 2 * DURATION_USEC) {
+ return 0;
+ }
+ return m_VideoDropFPS;
}
\ No newline at end of file
diff --git a/cloudphone/src/main/cpp/cas_decoder/CasVideoUtil.h b/cloudphone/src/main/cpp/cas_decoder/CasVideoUtil.h
index 7784afe82ea89d5e2f29615a92425bb7b1989c7b..f31d48a4c65a71173e16e086f363638e86427321 100644
--- a/cloudphone/src/main/cpp/cas_decoder/CasVideoUtil.h
+++ b/cloudphone/src/main/cpp/cas_decoder/CasVideoUtil.h
@@ -60,6 +60,18 @@ public:
*/
uint32_t GetFps();
+ /*
+ * @fn DropOneFrame
+ * @brief count when drop one frame
+ */
+ void DropOneFrame();
+
+ /*
+ * @fn GetCurrentDropFPS
+ * @brief get drop FPS
+ */
+ int GetCurrentDropFPS();
+
private:
/*
* @brief: construct
@@ -81,5 +93,8 @@ private:
static CasVideoUtil *g_instance;
static std::mutex g_instanceLock;
CasItemQueue *m_frameQueue = nullptr;
+ int m_VideoDropCount = 0;
+ int m_VideoDropFPS = 0;
+ uint64_t m_lastTimeRefreshDropFPS = 0;
};
#endif // CLOUDAPPSDK_CASVIDEOUTIL_H
\ No newline at end of file