From eaeabd18351ca839519f317bfbc445a53eccccfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E8=BE=B9=E4=B8=80=E6=9C=B5=E4=BA=91?= Date: Wed, 26 Jun 2024 15:14:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?rtt=E6=95=B0=E6=8D=AE=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=BB=8Elag=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloudphone/src/main/cpp/CasController.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloudphone/src/main/cpp/CasController.cpp b/cloudphone/src/main/cpp/CasController.cpp index 77b03e4..6962ada 100644 --- a/cloudphone/src/main/cpp/CasController.cpp +++ b/cloudphone/src/main/cpp/CasController.cpp @@ -1345,10 +1345,10 @@ std::string CasController::GetVideoRecvStats() { #if MTRANS_ENABLED if (m_mtrans != nullptr && m_isMTransValid) { - int rtt = m_mtrans->GetRtt(); + uint64_t lag = GetLag() / 1000; stream << "网络时延 : "; - if (rtt != -1) { - stream << rtt << "ms"; + if (lag != 0) { + stream << lag << "ms"; } stream << std::endl; -- Gitee From 62b4a6fca0577386c28bb506422c291fcc87578d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E8=BE=B9=E4=B8=80=E6=9C=B5=E4=BA=91?= Date: Thu, 27 Jun 2024 16:17:05 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=A2=9E=E5=8A=A0=E5=9F=BA=E7=AB=99=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 1 + .../ui/activity/CasCloudPhoneActivity.java | 79 ++++++++++++++++++- .../res/layout/cas_activity_fullscreen.xml | 5 +- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3d7b485..528d3d2 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 f4445ed..3494f9c 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 7caa7c2..408ab84 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" /> Date: Thu, 27 Jun 2024 17:18:51 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=8F=90=E9=AB=98=E5=B8=A7=E7=8E=87?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=9A=84=E5=87=86=E7=A1=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloudphone/src/main/cpp/CasController.cpp | 18 +++++++++++++----- cloudphone/src/main/cpp/CasController.h | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cloudphone/src/main/cpp/CasController.cpp b/cloudphone/src/main/cpp/CasController.cpp index 6962ada..cb49b2c 100644 --- a/cloudphone/src/main/cpp/CasController.cpp +++ b/cloudphone/src/main/cpp/CasController.cpp @@ -1367,7 +1367,7 @@ std::string CasController::GetVideoRecvStats() { } } #endif - stream << "帧率 : " << m_currentFPS << "fps" << std::endl; + stream << "帧率 : " << GetCurrentFPS() << "fps" << std::endl; statsString = stream.str(); return statsString; @@ -1378,12 +1378,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 3aa6a97..d50843c 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 -- Gitee From 99e370998c51fb0485762fe9c0800d8e2da11e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E8=BE=B9=E4=B8=80=E6=9C=B5=E4=BA=91?= Date: Thu, 27 Jun 2024 19:56:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E4=BA=8E?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E4=B8=A2=E5=B8=A7=E7=9A=84=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/layout/cas_activity_fullscreen.xml | 2 +- cloudphone/src/main/cpp/CasController.cpp | 1 + .../cpp/cas_decoder/CasDecodeController.cpp | 1 + .../src/main/cpp/cas_decoder/CasVideoUtil.cpp | 23 +++++++++++++++++++ .../src/main/cpp/cas_decoder/CasVideoUtil.h | 15 ++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/cas_activity_fullscreen.xml b/app/src/main/res/layout/cas_activity_fullscreen.xml index 408ab84..f170d41 100644 --- a/app/src/main/res/layout/cas_activity_fullscreen.xml +++ b/app/src/main/res/layout/cas_activity_fullscreen.xml @@ -29,7 +29,7 @@ GetCurrentDropFPS() << "fps" << std::endl; statsString = stream.str(); return statsString; diff --git a/cloudphone/src/main/cpp/cas_decoder/CasDecodeController.cpp b/cloudphone/src/main/cpp/cas_decoder/CasDecodeController.cpp index bc877bb..2741009 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 dd4c27c..f56b7ea 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 7784afe..f31d48a 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 -- Gitee