@tencentcloud/sdk-mcp 1.7.7 → 1.7.9-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +7 -9
  3. package/index.js +8 -8
  4. package/knowledge/chunker.js +1 -0
  5. package/knowledge/doc-url-resolver.js +16 -9
  6. package/knowledge/embedding/build-vectors.js +92 -0
  7. package/knowledge/embedding/embed-model.js +41 -0
  8. package/knowledge/embedding/vector-augment.js +126 -0
  9. package/knowledge/embedding/vector-index.js +70 -0
  10. package/knowledge/frontmatter-meta.js +23 -0
  11. package/knowledge/path-meta.js +56 -0
  12. package/knowledge/search/exact-lookup.js +145 -16
  13. package/knowledge/search/filter-pool.js +77 -33
  14. package/knowledge/search/rank-profile.js +25 -0
  15. package/knowledge/search/requires-framework.js +4 -1
  16. package/knowledge/search/search-core.js +74 -13
  17. package/knowledge/search/search-knowledge.js +24 -34
  18. package/knowledge/search/search-pass.js +495 -169
  19. package/knowledge/search/url-row-scorer.js +24 -6
  20. package/package.json +3 -1
  21. package/resource/index/manifest.json +1 -1
  22. package/resource/index/vectors/index.json +4 -0
  23. package/resource/integration/callkit/preset/android/integration.md +0 -2
  24. package/resource/integration/callkit/preset/ios/integration.md +0 -2
  25. package/resource/integration/chat/preset/react/integration.md +9 -5
  26. package/resource/integration/chat/preset/uni-app/integration.md +4 -0
  27. package/resource/integration/chat/preset/vue/integration.md +10 -6
  28. package/resource/integration/livekit/preset/live/android/prepare-integration.md +0 -4
  29. package/resource/integration/livekit/preset/live/ios/prepare-integration.md +0 -4
  30. package/resource/integration/roomkit/preset/vue/integration.md +154 -208
  31. package/resource/knowledge/callkit/best-practice/android/video-chat-dating.md +0 -2
  32. package/resource/knowledge/callkit/core-sdk/android/answer-call.md +0 -2
  33. package/resource/knowledge/callkit/core-sdk/android/make-call.md +0 -2
  34. package/resource/knowledge/callkit/core-sdk/flutter/answer-call.md +0 -4
  35. package/resource/knowledge/callkit/core-sdk/flutter/make-call.md +0 -2
  36. package/resource/knowledge/callkit/core-sdk/flutter/offline-push.md +0 -2
  37. package/resource/knowledge/callkit/core-sdk/ios/answer-call.md +0 -2
  38. package/resource/knowledge/callkit/core-sdk/ios/make-call.md +0 -4
  39. package/resource/knowledge/callkit/core-sdk/ios/offline-push.md +0 -2
  40. package/resource/knowledge/callkit/core-sdk/uni-app/answer-call.md +0 -2
  41. package/resource/knowledge/callkit/core-sdk/uni-app/make-call.md +0 -2
  42. package/resource/knowledge/callkit/faq/ios.md +0 -2
  43. package/resource/knowledge/callkit/faq/uniapp-app.md +0 -2
  44. package/resource/knowledge/callkit/preset/miniprogram/integration.md +2 -3
  45. package/resource/knowledge/callkit/preset/miniprogram/uniapp-integration.md +0 -2
  46. package/resource/knowledge/chat/preset/ios-uikit/integration.md +0 -16
  47. package/resource/knowledge/chat/preset/react/h5/integration.md +16 -5
  48. package/resource/knowledge/chat/preset/vue/features/conversation-list.md +6 -3
  49. package/resource/knowledge/chat/preset/vue/h5/integration.md +7 -4
  50. package/resource/knowledge/iot/app/activate-service.md +95 -0
  51. package/resource/knowledge/iot/app/demo/android.md +93 -0
  52. package/resource/knowledge/iot/app/demo/ios.md +87 -0
  53. package/resource/knowledge/iot/app/demo/miniprogram.md +79 -0
  54. package/resource/knowledge/iot/app/device-binding.md +378 -0
  55. package/resource/knowledge/iot/app/device-sharing.md +414 -0
  56. package/resource/knowledge/iot/app/family-management.md +762 -0
  57. package/resource/knowledge/iot/app/integration/android.md +328 -0
  58. package/resource/knowledge/iot/app/integration/harmonyos.md +326 -0
  59. package/resource/knowledge/iot/app/integration/ios.md +351 -0
  60. package/resource/knowledge/iot/app/integration/miniprogram.md +268 -0
  61. package/resource/knowledge/iot/app/monitor-playback.md +557 -0
  62. package/resource/knowledge/iot/app/remote-control.md +139 -0
  63. package/resource/knowledge/iot/app/video-call.md +559 -0
  64. package/resource/knowledge/iot/app/wechat-call/device-call-miniprogram.md +204 -0
  65. package/resource/knowledge/iot/app/wechat-call/miniprogram-call-device.md +193 -0
  66. package/resource/knowledge/iot/client-api/app/android/txiotcallsession.md +189 -0
  67. package/resource/knowledge/iot/client-api/app/android/txiotcloudstorage.md +77 -0
  68. package/resource/knowledge/iot/client-api/app/android/txiotdevicemanager.md +175 -0
  69. package/resource/knowledge/iot/client-api/app/android/txiotengine.md +172 -0
  70. package/resource/knowledge/iot/client-api/app/android/txiotenginedef.md +163 -0
  71. package/resource/knowledge/iot/client-api/app/android/txiotfamilymanager.md +146 -0
  72. package/resource/knowledge/iot/client-api/app/android/txiotmonitorsession.md +246 -0
  73. package/resource/knowledge/iot/client-api/app/harmonyos/txiotcallsession.md +191 -0
  74. package/resource/knowledge/iot/client-api/app/harmonyos/txiotcloudstorage.md +77 -0
  75. package/resource/knowledge/iot/client-api/app/harmonyos/txiotdevicemanager.md +183 -0
  76. package/resource/knowledge/iot/client-api/app/harmonyos/txiotengine.md +186 -0
  77. package/resource/knowledge/iot/client-api/app/harmonyos/txiotenginedef.md +164 -0
  78. package/resource/knowledge/iot/client-api/app/harmonyos/txiotfamilymanager.md +150 -0
  79. package/resource/knowledge/iot/client-api/app/harmonyos/txiotmonitorsession.md +252 -0
  80. package/resource/knowledge/iot/client-api/app/ios/txiotcallsession.md +199 -0
  81. package/resource/knowledge/iot/client-api/app/ios/txiotcloudstorage.md +76 -0
  82. package/resource/knowledge/iot/client-api/app/ios/txiotdevicemanager.md +173 -0
  83. package/resource/knowledge/iot/client-api/app/ios/txiotengine.md +173 -0
  84. package/resource/knowledge/iot/client-api/app/ios/txiotenginedef.md +171 -0
  85. package/resource/knowledge/iot/client-api/app/ios/txiotfamilymanager.md +146 -0
  86. package/resource/knowledge/iot/client-api/app/ios/txiotmonitorsession.md +250 -0
  87. package/resource/knowledge/iot/client-api/app/miniprogram/txiotcallsession.md +180 -0
  88. package/resource/knowledge/iot/client-api/app/miniprogram/txiotcloudstorage.md +76 -0
  89. package/resource/knowledge/iot/client-api/app/miniprogram/txiotdevicemanager.md +281 -0
  90. package/resource/knowledge/iot/client-api/app/miniprogram/txiotengine.md +183 -0
  91. package/resource/knowledge/iot/client-api/app/miniprogram/txiotenginedef.md +152 -0
  92. package/resource/knowledge/iot/client-api/app/miniprogram/txiotfamilymanager.md +179 -0
  93. package/resource/knowledge/iot/client-api/app/miniprogram/txiotmonitorsession.md +226 -0
  94. package/resource/knowledge/iot/client-api/device/android-smart-device.md +813 -0
  95. package/resource/knowledge/iot/client-api/device/linux-rtos-device.md +2027 -0
  96. package/resource/knowledge/iot/device/activate-service.md +167 -0
  97. package/resource/knowledge/iot/device/ai-voice-chat/advanced-features/custom-agent.md +171 -0
  98. package/resource/knowledge/iot/device/ai-voice-chat/advanced-features/smart-device-control.md +721 -0
  99. package/resource/knowledge/iot/device/ai-voice-chat/integration-guide/android-smart-device.md +247 -0
  100. package/resource/knowledge/iot/device/ai-voice-chat/integration-guide/linux-rtos-device.md +368 -0
  101. package/resource/knowledge/iot/device/ai-voice-chat/overview.md +84 -0
  102. package/resource/knowledge/iot/device/cloud-storage.md +696 -0
  103. package/resource/knowledge/iot/device/data-model.md +972 -0
  104. package/resource/knowledge/iot/device/demo/android-smart-device.md +97 -0
  105. package/resource/knowledge/iot/device/demo/linux-rtos-device.md +106 -0
  106. package/resource/knowledge/iot/device/device-ota-upgrade.md +237 -0
  107. package/resource/knowledge/iot/device/dynamic-registration/android-smart-device.md +275 -0
  108. package/resource/knowledge/iot/device/dynamic-registration/linux-rtos-device.md +297 -0
  109. package/resource/knowledge/iot/device/login-and-register/android-smart-device.md +131 -0
  110. package/resource/knowledge/iot/device/login-and-register/linux-rtos-device.md +291 -0
  111. package/resource/knowledge/iot/device/monitor-pushing/android-smart-device.md +237 -0
  112. package/resource/knowledge/iot/device/monitor-pushing/linux-rtos-device.md +493 -0
  113. package/resource/knowledge/iot/device/video-call/android-smart-device.md +299 -0
  114. package/resource/knowledge/iot/device/video-call/linux-rtos-device.md +465 -0
  115. package/resource/knowledge/iot/device/wechat-call/android-smart-device.md +534 -0
  116. package/resource/knowledge/iot/device/wechat-call/linux-rtos-device.md +681 -0
  117. package/resource/knowledge/iot/kids-watch/overview.md +28 -0
  118. package/resource/knowledge/iot/security-camera/activate-service.md +74 -0
  119. package/resource/knowledge/iot/security-camera/monitor-playback/app-integration.md +302 -0
  120. package/resource/knowledge/iot/security-camera/monitor-playback/device-integration/android.md +237 -0
  121. package/resource/knowledge/iot/security-camera/monitor-playback/device-integration/linux-rtos.md +493 -0
  122. package/resource/knowledge/iot/security-camera/overview.md +31 -0
  123. package/resource/knowledge/iot/security-camera/ptz-control.md +153 -0
  124. package/resource/knowledge/iot/security-camera/recording-and-snapshot.md +182 -0
  125. package/resource/knowledge/iot/security-camera/voice-intercom.md +174 -0
  126. package/resource/knowledge/iot/smart-vision/serviceoverview.md +114 -0
  127. package/resource/knowledge/iot/voice-recorder/app-demo.md +99 -0
  128. package/resource/knowledge/iot/voice-recorder/device-demo.md +189 -0
  129. package/resource/knowledge/iot/voice-recorder/overview.md +64 -0
  130. package/resource/knowledge/livekit/core-sdk/features/android/base-beauty.md +0 -2
  131. package/resource/knowledge/livekit/core-sdk/features/android/gift.md +0 -4
  132. package/resource/knowledge/livekit/core-sdk/features/android/live-list.md +0 -2
  133. package/resource/knowledge/livekit/core-sdk/features/flutter/audio-effect.md +0 -2
  134. package/resource/knowledge/livekit/core-sdk/features/flutter/base-beauty.md +0 -2
  135. package/resource/knowledge/livekit/core-sdk/features/flutter/gift.md +0 -4
  136. package/resource/knowledge/livekit/core-sdk/features/ios/base-beauty.md +0 -2
  137. package/resource/knowledge/livekit/core-sdk/features/ios/gift.md +0 -4
  138. package/resource/knowledge/livekit/core-sdk/features/ios/live-list.md +0 -2
  139. package/resource/knowledge/livekit/core-sdk/features/uni-app/base-beauty.md +0 -2
  140. package/resource/knowledge/livekit/core-sdk/features/uni-app/gift.md +0 -4
  141. package/resource/knowledge/livekit/core-sdk/live/android/co-guest-interaction.md +0 -4
  142. package/resource/knowledge/livekit/core-sdk/live/android/host-interaction.md +0 -10
  143. package/resource/knowledge/livekit/core-sdk/live/android/integration.md +0 -2
  144. package/resource/knowledge/livekit/core-sdk/live/flutter/co-guest-interaction.md +0 -2
  145. package/resource/knowledge/livekit/core-sdk/live/flutter/host-interaction.md +0 -10
  146. package/resource/knowledge/livekit/core-sdk/live/flutter/integration.md +0 -2
  147. package/resource/knowledge/livekit/core-sdk/live/ios/co-guest-interaction.md +0 -4
  148. package/resource/knowledge/livekit/core-sdk/live/ios/host-interaction.md +0 -10
  149. package/resource/knowledge/livekit/core-sdk/live/ios/integration.md +0 -2
  150. package/resource/knowledge/livekit/core-sdk/live/uni-app/co-guest-interaction.md +0 -4
  151. package/resource/knowledge/livekit/core-sdk/live/uni-app/host-interaction.md +0 -4
  152. package/resource/knowledge/livekit/core-sdk/live/uni-app/integration.md +0 -2
  153. package/resource/knowledge/livekit/core-sdk/voice/android/co-guest-interaction.md +0 -2
  154. package/resource/knowledge/livekit/core-sdk/voice/android/host-interaction.md +0 -4
  155. package/resource/knowledge/livekit/core-sdk/voice/android/integration.md +0 -4
  156. package/resource/knowledge/livekit/core-sdk/voice/flutter/integration.md +0 -2
  157. package/resource/knowledge/livekit/core-sdk/voice/ios/co-guest-interaction.md +0 -2
  158. package/resource/knowledge/livekit/core-sdk/voice/ios/host-interaction.md +0 -4
  159. package/resource/knowledge/livekit/core-sdk/voice/ios/integration.md +0 -4
  160. package/resource/knowledge/livekit/core-sdk/voice/uni-app/co-guest-interaction.md +0 -2
  161. package/resource/knowledge/livekit/core-sdk/voice/uni-app/integration.md +0 -2
  162. package/resource/knowledge/livekit/faq/error-code.md +0 -2
  163. package/resource/knowledge/push/config/android/honor.md +16 -1
  164. package/resource/knowledge/push/config/android/huawei.md +20 -4
  165. package/resource/knowledge/push/config/android/meizu.md +19 -5
  166. package/resource/knowledge/push/config/android/vivo.md +20 -1
  167. package/resource/knowledge/push/config/donut.md +0 -2
  168. package/resource/knowledge/push/config/harmonyos.md +21 -5
  169. package/resource/knowledge/push/integration/android.md +0 -5
  170. package/resource/knowledge/push/integration/donut.md +0 -3
  171. package/resource/knowledge/push/integration/flutter.md +1 -4
  172. package/resource/knowledge/push/integration/harmonyos.md +0 -3
  173. package/resource/knowledge/push/integration/ios.md +0 -3
  174. package/resource/knowledge/push/integration/react-native.md +0 -5
  175. package/resource/knowledge/push/integration/uni-app.md +0 -3
  176. package/resource/knowledge/push/integration/unity.md +0 -3
  177. package/resource/knowledge/push/integration/unreal-engine.md +0 -3
  178. package/resource/knowledge/roomkit/core-sdk/android/call-user-to-room.md +0 -2
  179. package/resource/knowledge/roomkit/core-sdk/android/room-participant-state.md +0 -2
  180. package/resource/knowledge/roomkit/core-sdk/android/room-state.md +0 -2
  181. package/resource/knowledge/roomkit/core-sdk/android/schedule-room.md +0 -2
  182. package/resource/knowledge/roomkit/core-sdk/flutter/call-user-to-room.md +0 -2
  183. package/resource/knowledge/roomkit/core-sdk/flutter/room-participant-state.md +0 -2
  184. package/resource/knowledge/roomkit/core-sdk/flutter/room-state.md +0 -2
  185. package/resource/knowledge/roomkit/core-sdk/flutter/schedule-room.md +0 -2
  186. package/resource/knowledge/roomkit/core-sdk/ios/call-user-to-room.md +0 -2
  187. package/resource/knowledge/roomkit/core-sdk/ios/room-participant-state.md +0 -2
  188. package/resource/knowledge/roomkit/core-sdk/ios/room-state.md +0 -2
  189. package/resource/knowledge/roomkit/core-sdk/ios/schedule-room.md +0 -2
  190. package/resource/knowledge/roomkit/core-sdk/vue/room-view.md +0 -3
  191. package/resource/knowledge/roomkit/preset/uniapp-app/integration.md +18 -14
  192. package/resource/knowledge/rtcengine/web/how_to_run_web_sdk_demo.md +0 -2
  193. package/resource/knowledge/rtcengine/web/plugin/23-advanced-support-detection.md +30 -0
  194. package/resource/knowledge/rtcengine/web/plugin/24-advanced-network-quality.md +0 -2
  195. package/resource/knowledge/rtcengine/web/plugin/31-advanced-plugins-overview.md +1 -1
  196. package/resource/knowledge/rtcengine/web/plugin/35-advanced-ai-denoiser.md +1 -1
  197. package/resource/knowledge/rtcengine/web/plugin/36-advanced-virtual-background.md +4 -0
  198. package/resource/knowledge/trtc/android/TRTCCloud.md +94 -85
  199. package/resource/knowledge/trtc/android/TRTCCloudDef.md +48 -46
  200. package/resource/knowledge/trtc/android/TRTCCloudListener.md +48 -48
  201. package/resource/knowledge/trtc/android/TXAudioEffectManager.md +18 -18
  202. package/resource/knowledge/trtc/android/TXDeviceManager.md +4 -4
  203. package/resource/knowledge/trtc/android/TXLiteAVCode.md +1 -0
  204. package/resource/knowledge/trtc/c++/ITRTCCloud.md +90 -90
  205. package/resource/knowledge/trtc/c++/ITXAudioEffectManager.md +18 -18
  206. package/resource/knowledge/trtc/c++/ITXDeviceManager.md +9 -9
  207. package/resource/knowledge/trtc/c++/TRTCCloudCallback.md +47 -47
  208. package/resource/knowledge/trtc/c++/TRTCTypeDef.md +47 -45
  209. package/resource/knowledge/trtc/c++/TXLiteAVCode.md +1 -0
  210. package/resource/knowledge/trtc/ios/TRTCCloud.md +93 -93
  211. package/resource/knowledge/trtc/ios/TRTCCloudDelegate.md +50 -50
  212. package/resource/knowledge/trtc/ios/TXAudioEffectManager.md +8 -8
  213. package/resource/knowledge/trtc/ios/TXDeviceManager.md +9 -9
  214. package/resource/knowledge/trtc/ios/TXLiteAVCode.md +1 -0
  215. package/resource/knowledge/trtc/ios/TXLiveSDKTypeDef.md +48 -46
  216. package/server-config.js +8 -9
  217. package/server.js +1 -1
  218. package/tools/common/finalize_answer.js +1 -1
  219. package/tools/common/present_framework_choice.js +1 -1
  220. package/tools/common/search_trtc_knowledge.js +22 -3
  221. package/tools/definitions/search_trtc_knowledge_def.js +3 -2
  222. package/utils/preflight-route.js +19 -2
  223. package/utils/report-cls-client.js +1 -1
  224. package/utils/report-es-client.js +1 -1
@@ -0,0 +1,28 @@
1
+ ---
2
+ product: iot
3
+ framework:
4
+ - '*'
5
+ types:
6
+ - feature
7
+ retrievable_scope: always
8
+ feature_domain: kids-watch
9
+ ---
10
+
11
+ ## 场景概述
12
+
13
+ 腾讯云物联网视频通话服务基于腾讯实时音视频 TRTC,将腾讯超过20年在网络与音视频技术上的积累与物联网能力深度融合。该服务面向智能手表等低功耗、小体积、算力受限的可穿戴设备,助力厂商快速搭建高可靠、低延时、低功耗的语音与视频通话服务。
14
+
15
+ ## 方案优势
16
+
17
+ 底层复用腾讯云实时音视频(TRTC)的媒体网络与音频处理能力:应用端与设备分别就近接入 TRTC 媒体网络,在同一房间内互相推流与订阅,不依赖手机与设备之间的端到端直连。对通话这类强交互场景,这一架构选择带来的差异尤为明显。
18
+
19
+ ## 核心功能
20
+
21
+ |**功能**|**功能描述**|
22
+ |---------|---------|
23
+ |视频通话|手表与家长 App 之间可发起高清双向视频通话,在手表端确认接听后,家长可通过 App 与孩子进行高清双向视频通话。|
24
+ |语音通话|支持手表与 App 之间的实时语音通话与对讲,低功耗、低延时。|
25
+ |弱网抗丢包|自适应码率与抗丢包恢复,在电梯、地下室等弱网环境下保持通话稳定,降低卡顿率。|
26
+ |实时字幕|基于 TRTC-ASR 将通话语音实时转写为文字并回传,嘈杂环境下也能看清对方内容。|
27
+ |全球调度|全球实时传输网络跨区域高质量调度,保障海外及跨运营商场景下的通话质量。|
28
+
@@ -0,0 +1,74 @@
1
+ ---
2
+ product: iot
3
+ framework:
4
+ - '*'
5
+ types:
6
+ - feature
7
+ retrievable_scope: always
8
+ feature_domain: security-camera
9
+ ---
10
+
11
+ ## 开通音视频设备接入服务
12
+
13
+ ### 购买设备激活码
14
+
15
+ 音视频设备接入必须要有对应的音视频设备激活码额度,购买激活码成功后即表示开通了正式版。具体购买流程如下:
16
+ 1. 在购买音视频设备接入服务之前,您需要先 [注册腾讯云](https://cloud.tencent.com/document/product/378/17985) 账号,并完成 [实名认证](https://cloud.tencent.com/document/product/378/3629)。
17
+
18
+ 2. 进入 [物联网开发平台购买页](https://buy.cloud.tencent.com/iotexplorer),实例类型选择**消费实例**,服务类型选择“音视频设备接入服务”。
19
+
20
+ 3. 生效地域:国内设备选择广州区域,出海设备选择新加坡;有效期默认规格5年。
21
+
22
+ 4. 激活码数量:输入您要量产的设备数量,一个物理设备默认烧录一个激活码。
23
+
24
+ 5. 勾选我已阅读并同意《腾讯云服务协议》,单击**立即购买**。
25
+
26
+ 6. 单击立即购买后进入订单确认,音视频设备接入服务分别对应“音视频设备接入服务”和“音视频设备通信服务”。
27
+
28
+ 7. 确认后单击**去支付**进行付款,支付成功后系统将您支付订单的激活码数量累加到对应激活码规格的总可用量数。
29
+
30
+ ### 查看激活码用量
31
+
32
+ 支付完音视频设备接入服务后,用户可进入 [物联网开发平台控制台](https://console.cloud.tencent.com/iotexplorer) 的**消费实例**,选择左侧导航栏的**用量统计** > **激活码概览**页面,可查看支付成功的订单对应的音视频设备激活码用量。
33
+
34
+ ## 创建产品
35
+ 1. 登录[物联网开发平台](https://console.cloud.tencent.com/iotexplorer),进入**实例管理**页面,单击**消费实例**的卡片进入详情页。
36
+
37
+ 2. 选择消费实例左侧导航栏的**产品**,然后单击**创建产品**。
38
+
39
+ 3. 在创建产品页面中,输入“产品名称”,设备类型必须是“**音视频设备**”、认证方式为“密钥认证”、数据协议选择“物模型”。信息配置好后,单击**创建**。
40
+
41
+ > **注意:**
42
+ >
43
+ > 创建产品时若码率规格显示为“不可选”,表示您的账号未购买该规格码率。码率决定了使用该款产品的用户切换清晰度的上限。
44
+ >
45
+
46
+ ## 创建设备
47
+ 1. 选择消费实例左侧导航栏的**设备**,然后单击**新建设备**。
48
+
49
+ 2. 所属产品选择前述步骤已创建成功的产品,输入设备名称并单击**新建**。
50
+
51
+ 3. 单击创建成功的设备,进入设备详情页获取设备三元组信息。
52
+
53
+ > **注意:**
54
+ >
55
+ > 产品 ID、设备名称、设备密钥三元组信息作为后续实时监控的设备身份凭证。
56
+ >
57
+
58
+ ## 创建应用
59
+ 1. 选择消费实例左侧导航栏的**应用**,单击**新建应用**。
60
+
61
+ 2. 输入应用名称,单击**保存**创建应用。
62
+
63
+ 3. 单击创建的应用,可获取应用的 App Key 及 App Secret。
64
+
65
+ > **注意:**
66
+ >
67
+ > App Key 与 App Secret 会在后续 App SDK 开发时使用,可直接使用 Android 应用的 App Key 与 App Secret。
68
+ >
69
+
70
+ ## 应用关联产品
71
+
72
+ > **注意:**
73
+ > 若应用未关联产品,APP 在绑定产品下的设备时会提示“APP对操作该产品无权限”。
74
+ >
@@ -0,0 +1,302 @@
1
+ ---
2
+ product: iot
3
+ framework:
4
+ - '*'
5
+ types:
6
+ - feature
7
+ retrievable_scope: always
8
+ feature_domain: security-camera
9
+ ---
10
+
11
+ 本文介绍腾讯云物联网(IoT)应用端 SDK 中实时监控(`TXIoTMonitorSession`)的使用方法。完成 快速接入 并登录 SDK 后,您可以获取监控会话对象,对已绑定的设备发起实时监控,播放设备实时音视频,并监听会话状态与错误回调。您还可以进一步使用云台控制、录制与截图、语音对讲等功能,详情参见 下一步:高级功能。
12
+
13
+ ## 前提条件
14
+
15
+ 在调用本文 API 前,请确保已完成以下准备工作:
16
+ - 已开通腾讯云物联网相关服务,并在控制台完成实例、应用和设备的准备工作(可参见 开通服务)。
17
+
18
+ - 已在客户端工程中集成 IoT 应用端 SDK。
19
+
20
+ - 已通过业务后台生成登录签名,并调用 `TXIoTEngine.login` 完成登录。
21
+
22
+ - 目标设备已绑定到当前登录账户名下(。
23
+
24
+ - 使用本地麦克风/摄像头对讲前,确保已在工程中申请并获取相应系统权限。
25
+
26
+ ## 使用建议
27
+ - 调用顺序:获取监控会话对象 → 注册监听 → 尽早 startRemoteView 设置渲染视图(可在 startSession 之前调用)→ startSession → 会话建立后自动播放画面;结束时调用 stopSession 停止会话。
28
+
29
+ - 提前绑定设备:确保目标设备已绑定到当前账户,否则相关调用会返回权限类错误。
30
+
31
+ - 尽早注册监听:在 startSession 之前完成 addListener,避免错过 `onSessionEstablished` 等早期回调。
32
+
33
+ - 及时释放:不再需要监控时调用 stopSession 并 removeListener,避免资源泄漏与重复回调。
34
+
35
+ - 统一错误处理:在 `onError` 中集中处理错误码,结合错误码表给出用户可理解的提示。
36
+
37
+ ## 获取监控会话对象
38
+
39
+ 在 Android 和 iOS 上,登录成功后,均可通过 `TXIoTEngine` 单例实例调用 `getMonitorSession()` 获取监控会话对象 `TXIoTMonitorSession`,无需为每个设备单独创建。
40
+
41
+ > **警告:**
42
+ > 监控会话对象为单例,同一时刻只存在一个监控会话。若已有会话正在运行中(已调用 startSession 且尚未 stopSession),再次调用 startSession 会被直接忽略,不会打断或切换已有会话;无需也不能重复获取多个会话实例。
43
+ >
44
+
45
+ ##### **与视频通话的优先级关系:**
46
+
47
+ 实时监控的优先级低于视频通话。若设备当前正处于实时监控拉流状态,应用端对该设备发起视频通话时,视频通话会打断并抢占实时监控的拉流,监控会话会被中断(。
48
+
49
+ ## **注册**监听回调
50
+
51
+ 监控会话的状态变化与错误均通过监听接口返回。**请在调用** startSession **之前完成监听注册**,避免错过 `onSessionEstablished` 等早期回调。
52
+
53
+ |方法|说明|
54
+ |---------|---------|
55
+ |addListener|添加监控会话状态与错误监听器,回调接口定义见 监控事件回调(iOS:`addDelegate`)。|
56
+ |removeListener|移除监控会话监听器(iOS:`removeDelegate`)。|
57
+
58
+ 【Android】
59
+ ``` java
60
+ TXIoTMonitorSessionListener monitorListener = new TXIoTMonitorSessionListener() {
61
+ @Override
62
+ public void onSessionEstablished() {
63
+ // 会话建立成功,可开始播放画面
64
+ }
65
+
66
+ // 其他回调...
67
+ };
68
+
69
+ session.addListener(monitorListener);
70
+ ```
71
+
72
+ 【iOS】
73
+ ``` objectivec
74
+ @interface ViewController () <TXIoTMonitorSessionDelegate>
75
+ @end
76
+
77
+ @implementation ViewController
78
+
79
+ - (void)onSessionEstablished {
80
+ // 会话建立成功
81
+ }
82
+
83
+ - (void)onError:(NSInteger)channelId
84
+ errorCode:(TXIoTErrorCode)errorCode
85
+ errorMessage:(NSString *)errorMessage {
86
+ // 发生错误,统一处理错误码与提示
87
+ }
88
+
89
+ @end
90
+
91
+ // 注册代理
92
+ [session addDelegate:self];
93
+ // 退出时注销
94
+ // [session removeDelegate:self];
95
+ ```
96
+
97
+ ## 开始与停止监控
98
+
99
+ 通过 startSession 与目标设备建立监控会话,会话建立成功后即可播放实时画面。结束监控时调用 stopSession 释放资源。
100
+
101
+ |方法|说明|
102
+ |---------|---------|
103
+ |startSession|与目标设备建立监控会话,`deviceId`(TXIoTDeviceId)为目标设备标识。|
104
+ |stopSession|停止当前监控会话并释放资源。|
105
+
106
+ 【Android】
107
+ ``` java
108
+ TXIoTMonitorSession session = TXIoTEngine.getInstance(context).getMonitorSession();
109
+ if (session == null) {
110
+ // SDK 未登录或登录已过期,请先完成登录
111
+ return;
112
+ }
113
+ // 监听已在“监听会话状态与错误回调”一节注册,此处直接开始监控
114
+
115
+ // 构造目标设备标识
116
+ TXIoTDeviceId deviceId = new TXIoTDeviceId();
117
+ deviceId.productId = "已绑定到当前账户的 productId";
118
+ deviceId.deviceName = "已绑定到当前账户的 deviceName";
119
+
120
+ // 开始监控
121
+ session.startSession(deviceId);
122
+
123
+ // 结束时停止监控
124
+ session.stopSession();
125
+ ```
126
+
127
+ 【iOS】
128
+ ``` objectivec
129
+ TXIoTMonitorSession *session = [[TXIoTEngine getInstance] getMonitorSession];
130
+ if (session == nil) {
131
+ // SDK 未登录或登录已过期,请先完成登录
132
+ return;
133
+ }
134
+ // 监听已在“监听会话状态与错误回调”一节注册,此处直接开始监控
135
+
136
+ // 构造目标设备标识
137
+ TXIoTDeviceId *deviceId = [[TXIoTDeviceId alloc] init];
138
+ deviceId.productId = @"已绑定到当前账户的 productId";
139
+ deviceId.deviceName = @"已绑定到当前账户的 deviceName";
140
+
141
+ // 开始监控
142
+ [session startSession:deviceId];
143
+
144
+ // 结束时停止监控
145
+ [session stopSession];
146
+ ```
147
+
148
+ ## 播放设备实时画面
149
+
150
+ 通过 startRemoteView 为指定通道设置渲染视图并播放实时音视频。您可以**在调用** startSession **之前**就调用 startRemoteView 设置好渲染视图。
151
+
152
+ |方法|说明|
153
+ |---------|---------|
154
+ |startRemoteView|在指定视图播放 `channelId` 通道的实时画面,`streamType` 为码流类型(取值见「数据结构体」中的 TXIoTStreamType)。`channelId` 表示设备的视频通道,每个通道对应这个设备的一个摄像头,单通道设备使用 `0`。|
155
+ |stopRemoteView|停止播放 `channelId` 通道的实时画面。|
156
+
157
+ 【Android】
158
+ ``` java
159
+ // remoteView 为布局中的 TXCloudVideoView
160
+ TXCloudVideoView remoteView = findViewById(R.id.remote_view);
161
+
162
+ // 开始播放0号通道高清流
163
+ int channelId = 0; // channelId 表示设备的视频通道,需要与设备端的通道 Id 对齐,单通道设备使用 0
164
+ TXIoTStreamType streamType = TXIoTStreamType.HD; // 需要查看的视频清晰度,SDK 会将该信息同步给设备端
165
+ session.startRemoteView(channelId, streamType, remoteView);
166
+
167
+ // 停止播放0号通道
168
+ session.stopRemoteView(channelId);
169
+ ```
170
+
171
+ 【iOS】
172
+ ``` objectivec
173
+ // remoteView 为布局中的 UIView
174
+ UIView *remoteView = self.remoteVideoView;
175
+
176
+ // 开始播放0号通道高清流
177
+ NSInteger channelId = 0; // channelId 表示设备的视频通道,需要与设备端的通道 Id 对齐,单通道设备使用 0
178
+ TXIoTStreamType streamType = TXIoTStreamTypeHD; // 需要查看的视频清晰度,SDK 会将该信息同步给设备端
179
+ // 开始播放高清流
180
+ [session startRemoteView:channelId
181
+ streamType:streamType
182
+ view:remoteView];
183
+
184
+ // 停止播放
185
+ [session stopRemoteView:0];
186
+ ```
187
+
188
+ ## 切换视频清晰度
189
+
190
+ 查看监控期间,应用端可动态切换通道画面的清晰度(高清 HD / 流畅 SD)。切换通过 switchRemoteStream 完成,无需重新建立会话;应用端切换后,设备端会收到 `on_monitor_switch` 回调并推送对应清晰度的视频流(设备端处理逻辑见 切换清晰度)。
191
+
192
+ > **注意:**
193
+ > 不同清晰度可能对应不同的计费标准,请确保应用端实际调用的清晰度与用户购买的套餐一致,避免因清晰度与计费套餐不匹配引发计费争议。
194
+ >
195
+
196
+ ### 接口说明
197
+
198
+ |方法|说明|
199
+ |---------|---------|
200
+ |switchRemoteStream|将 `channelId` 通道的视频流切换为指定清晰度,`streamType` 取值见枚举类型 TXIoTStreamType。|
201
+
202
+ ### 调用示例
203
+
204
+ 【Android】
205
+ ``` java
206
+ // 切换为流畅流
207
+ session.switchRemoteStream(0, TXIoTMonitorSession.TXIoTStreamType.SD);
208
+ // 切换为高清流
209
+ session.switchRemoteStream(0, TXIoTMonitorSession.TXIoTStreamType.HD);
210
+ ```
211
+
212
+ 【iOS】
213
+ ``` objectivec
214
+ // 切换为流畅流
215
+ [session switchRemoteStream:0 streamType:TXIoTStreamTypeSD];
216
+ // 切换为高清流
217
+ [session switchRemoteStream:0 streamType:TXIoTStreamTypeHD];
218
+ ```
219
+
220
+ ## 音频控制
221
+
222
+ 监控过程中可静音远端音频。通过 muteRemoteAudio(单通道)与 muteAllRemoteAudio(全部通道)控制远端音频播放。
223
+
224
+ |方法|说明|
225
+ |---------|---------|
226
+ |muteRemoteAudio|`mute` 为 `true` 时静音指定通道的远端音频。|
227
+ |muteAllRemoteAudio|一键静音/恢复所有通道的远端音频。|
228
+
229
+ 【Android】
230
+ ``` java
231
+ // 远端音频控制
232
+ session.muteRemoteAudio(0, true);
233
+ session.muteAllRemoteAudio(false);
234
+
235
+ ```
236
+
237
+ 【iOS】
238
+ ``` objectivec
239
+ // 远端音频控制
240
+ [session muteRemoteAudio:0 mute:YES];
241
+ [session muteAllRemoteAudio:NO];
242
+
243
+ ```
244
+
245
+ ## 状态与回调通知
246
+
247
+ 监控会话通过监听接口(Android:`TXIoTMonitorSessionListener,`iOS:`TXIoTMonitorSessionDelegate`)回调状态与错误,回调接口如下:
248
+
249
+ |回调|触发时机|关键参数|
250
+ |---------|---------|---------|
251
+ |`onSessionEstablished`|监控会话建立成功。|无。|
252
+ |`onSessionReconnecting`|会话中断,正在重连。|无。|
253
+ |`onSessionRecovery`|会话重连成功。|无。|
254
+ |`onRemoteStreamAvailable`|远端音视频流可用状态变化。|`channelId, available`|
255
+ |`onRenderFirstFrame`|指定通道首帧已渲染。|`channelId`|
256
+ |`onPlayStateChanged`|播放状态变化。|`channelId, state`(PLAYING / LOADING / STOPPED)|
257
+ |`onError`|会话或某通道发生错误。|`channelId, errCode, errMsg`|
258
+
259
+ > **注意:**
260
+ > 会话连接中断时会触发 `onSessionReconnecting`,SDK 会自动尝试重连;重连成功触发 `onSessionRecovery`,无需业务层主动重建会话。若重连持续失败,最终会通过 `onError` 回调错误。
261
+ >
262
+
263
+ ## 错误处理
264
+
265
+ 监控会话的所有错误均通过 `onError` 回调错误码与错误信息。常见错误码如下,Android 与 iOS 命名不同,请按所用平台查看:
266
+
267
+ 完整错误码定义见 TXIoTErrorCode。
268
+
269
+ 【Android】
270
+
271
+ |错误码|说明|建议处理方式|
272
+ |---------|---------|---------|
273
+ |`ERR_INVALID_PARAMETER`|参数不合法|检查 `deviceId`、`channelId`、路径等参数是否为空或格式错误。|
274
+ |`ERR_INVALID_ACCESS_TOKEN`|登录凭证无效|重新登录 SDK 后再发起监控。|
275
+ |`ERR_RATE_LIMITED`|请求被限频|降低调用频率后重试。|
276
+ |`ERR_UNAUTHORIZED_OPERATION`|当前用户无权限|确认目标设备已绑定到当前账户(见前提条件)。|
277
+ |`ERR_DEVICE_NOT_EXIST`|设备不存在|确认 `deviceId` 是否正确、设备是否已绑定。|
278
+ |`ERR_DEVICE_OFFLINE`|设备离线|确认设备在线后重试。|
279
+ |`ERR_SPEAKER_START_FAIL`|扬声器启动失败|检查音频输出设备是否正常。|
280
+ |`ERR_DEVICE_SWITCH_TO_VOIP`|设备已切换到 VoIP 通话|结束通话或等待通话结束后再发起监控。|
281
+
282
+ 【iOS】
283
+
284
+ |错误码|数值|说明|建议处理方式|
285
+ |---------|---------|---------|---------|
286
+ |`TXIoTErrorCodeInvalidParameter`|-2|参数不合法。|检查 `deviceId`、`channelId`、路径等参数是否为空或格式错误。|
287
+ |`TXIoTErrorCodeInvalidAccessToken`|-3|登录凭证无效。|重新登录 SDK 后再发起监控。|
288
+ |`TXIoTErrorCodeRateLimited`|-4|请求被限频。|降低调用频率后重试。|
289
+ |`TXIoTErrorCodeUnauthorizedOperation`|-5|当前用户无权限。|确认目标设备已绑定到当前账户(见 前提条件)。|
290
+ |`TXIoTErrorCodeDeviceNotExist`|-1009|设备不存在。|确认 `deviceId` 是否正确、设备是否已绑定。|
291
+ |`TXIoTErrorCodeDeviceOffline`|-1010|设备离线。|确认设备在线后重试。|
292
+ |`TXIoTErrorCodeSpeakerStartFail`|-2006|扬声器启动失败。|检查音频输出设备是否正常。|
293
+ |`TXIoTErrorCodeDeviceSwitchToVoIP`|-2010|设备已切换到 VoIP 通话。|结束通话或等待通话结束后再发起监控。|
294
+
295
+ ## 下一步:高级功能
296
+
297
+ 完成基础接入后,您可以进一步接入以下高级功能,丰富实时监控的使用场景:
298
+ - 云台控制: 通过 PTZ 指令控制摄像头转动、变焦,调整监控视角。
299
+
300
+ - 录制与截图:本地录制监控画面,并抓取实时截图保存。
301
+
302
+ - 语音对讲 : 与设备端进行双向语音对讲。
@@ -0,0 +1,237 @@
1
+ ---
2
+ product: iot
3
+ framework:
4
+ - android
5
+ types:
6
+ - feature
7
+ retrievable_scope: always
8
+ feature_domain: security-camera
9
+ ---
10
+
11
+ 本文将介绍设备如何在 Android 平台实现响应 APP 发起的**监控请求**、**采集并推送音视频画面**、**切换清晰度**,帮助您快速了解实时监控的功能。
12
+
13
+ ## 前提条件
14
+
15
+ 在开始之前,请您先完成 登录与注册 文档中跑通 login 登录功能。如果您已经完成,可以跳过该操作。
16
+
17
+ > **说明:**
18
+ > 监控推流依赖摄像头与麦克风采集,请确保已在 `AndroidManifest.xml` 中声明 `android.permission.CAMERA`、`android.permission.RECORD_AUDIO` 权限,并在运行时向用户申请授权。
19
+ >
20
+
21
+ ## 接入步骤
22
+
23
+ ### 步骤 1:注册监控事件回调
24
+
25
+ 登录成功后,通过 `TXIoTMonitorSession.getInstance().addListener` 注册 TXIoTMonitorSession.Listener,实时监控相关的回调如下:
26
+
27
+ |回调|说明|
28
+ |---------|---------|
29
+ |`onMonitorBegin`|APP 发起监控查看请求时触发,携带 option(清晰度等)与 `customData`(自定义数据)。|
30
+ |`onMonitorEnd`|对端结束监控查看时触发。|
31
+ |`onMonitorSwitch`|APP 在监控查看期间切换清晰度时触发,携带切换后的 quality(可选实现。|
32
+ |`onPTZCommandReceived`|APP 下发云台控制指令时触发,携带 `command`(方向/变焦等)与 `speed`(速度),仅支持云台的设备需实现。|
33
+
34
+ ``` java
35
+ import com.tencent.liteav.iot.TXIoTMonitorSession;
36
+
37
+ TXIoTMonitorSession monitorSession = TXIoTMonitorSession.getInstance();
38
+
39
+ TXIoTMonitorSession.Listener listener = new TXIoTMonitorSession.Listener() {
40
+ @Override
41
+ public void onMonitorBegin(TXIoTMonitorSession.Option option, String customData) {
42
+ // APP 发起监控,开启摄像头/麦克风采集推流(详见步骤 2、步骤 3)
43
+ }
44
+
45
+ @Override
46
+ public void onMonitorEnd() {
47
+ // APP 结束监控,关闭采集推流(详见步骤 5)
48
+ }
49
+
50
+ @Override
51
+ public void onMonitorSwitch(TXIoTMonitorSession.VideoQuality quality) {
52
+ // APP 切换清晰度(详见步骤 4)
53
+ }
54
+
55
+ @Override
56
+ public void onPTZCommandReceived(TXIoTMonitorSession.PTZCommand command, int speed) {
57
+ // 云台控制指令(可选实现)
58
+ }
59
+ };
60
+
61
+ monitorSession.addListener(listener);
62
+ ```
63
+
64
+ ### 步骤 2:响应 onMonitorBegin,开启摄像头推流
65
+
66
+ 在 `onMonitorBegin` 回调中,**必须**调用 openCamera 开启摄像头采集并推流,只需传入 `Option` 与用于本地预览的 `TXCloudVideoView` 即可:
67
+
68
+ |接口|说明|
69
+ |---------|---------|
70
+ |`openCamera(Option option, TXCloudVideoView view)`|开启摄像头采集并推流,`option` 指定视频清晰度(可复用回调传入的 `option`);`view` 为本地预览渲染控件,若无需本地预览可传 `null,`返回 `0`(`TXIoTError.SUCCESS`)表示调用成功。|
71
+ |`closeCamera`|关闭摄像头采集与推流(。|
72
+
73
+ ``` java
74
+ private TXCloudVideoView mVideoView; // 在布局中放置 <com.tencent.rtmp.ui.TXCloudVideoView/> 并获取实例
75
+
76
+ @Override
77
+ public void onMonitorBegin(TXIoTMonitorSession.Option option, String customData) {
78
+ // 开启摄像头采集并推流,同时在 mVideoView 上本地预览
79
+ int ret = TXIoTMonitorSession.getInstance().openCamera(option, mVideoView);
80
+ if (ret != TXIoTError.SUCCESS) {
81
+ Log.e(TAG, "openCamera failed: " + ret);
82
+ }
83
+
84
+ // 若需要音频,继续开启麦克风推流(详见步骤 3)
85
+ TXIoTMonitorSession.getInstance().openMicrophone();
86
+ }
87
+ ```
88
+
89
+ ### 步骤 3:开启麦克风推流
90
+
91
+ 若监控需要音频,调用 openMicrophone 开启麦克风就可实现音频采集并推流。
92
+
93
+ |接口|说明|
94
+ |---------|---------|
95
+ |`openMicrophone()`|开启麦克风采集并推流。|
96
+ |`closeMicrophone`|关闭麦克风采集与推流(。|
97
+
98
+ > **注意:**
99
+ > 开启摄像头与麦克风前,请确保已获得 `CAMERA` 与 `RECORD_AUDIO` 运行时权限,否则采集会失败导致对端无画面或无声音。
100
+ >
101
+
102
+ ``` java
103
+ int ret = TXIoTMonitorSession.getInstance().openMicrophone();
104
+ if (ret != TXIoTError.SUCCESS) {
105
+ Log.e(TAG, "openMicrophone failed: " + ret);
106
+ }
107
+ ```
108
+
109
+ ### 步骤 4:响应 onMonitorSwitch,切换视频清晰度(可选)
110
+
111
+ APP 端在监控查看期间切换清晰度时,设备端会通过 `onMonitorSwitch` 回调收到通知,携带切换后的 `quality`,在 `onMonitorSwitch` 回调中调用 switchVideoQuality 传入新的清晰度即可完成清晰度切换。`quality` 的可选取值(`TXIoTMonitorSession.VideoQuality`)如下:
112
+
113
+ |取值|说明|
114
+ |---------|---------|
115
+ |`VideoQuality.UNKNOWN`|未知/未设置。|
116
+ |`VideoQuality.LD`|流畅(低清晰度)。|
117
+ |`VideoQuality.SD`|标清。|
118
+ |`VideoQuality.HD`|高清。|
119
+ |`VideoQuality.FHD`|超清(全高清)。|
120
+
121
+ ``` java
122
+ @Override
123
+ public void onMonitorSwitch(TXIoTMonitorSession.VideoQuality quality) {
124
+ int ret = TXIoTMonitorSession.getInstance().switchVideoQuality(quality);
125
+ if (ret != TXIoTError.SUCCESS) {
126
+ Log.e(TAG, "switchVideoQuality failed: " + ret);
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### 步骤 5:响应 onMonitorEnd,关闭采集推流
132
+
133
+ 对端结束监控查看时触发 `onMonitorEnd`,此时应关闭摄像头与麦克风,停止采集推流:
134
+ ``` java
135
+ @Override
136
+ public void onMonitorEnd() {
137
+ TXIoTMonitorSession.getInstance().closeCamera();
138
+ TXIoTMonitorSession.getInstance().closeMicrophone();
139
+ }
140
+ ```
141
+
142
+ ## 示例代码
143
+
144
+ 以下示例展示在一个 Activity 中完成监听注册与监控推流的完整流程,设备登录与初始化。
145
+ ``` java
146
+ package com.example.iotdemo;
147
+
148
+ import android.os.Bundle;
149
+ import android.util.Log;
150
+ import androidx.annotation.Nullable;
151
+ import androidx.appcompat.app.AppCompatActivity;
152
+
153
+ import com.tencent.liteav.iot.TXIoTError;
154
+ import com.tencent.liteav.iot.TXIoTMonitorSession;
155
+ import com.tencent.rtmp.ui.TXCloudVideoView;
156
+
157
+ public class MonitorActivity extends AppCompatActivity {
158
+
159
+ private static final String TAG = "MonitorActivity";
160
+
161
+ private TXIoTMonitorSession mMonitorSession;
162
+ private TXCloudVideoView mVideoView;
163
+
164
+ private final TXIoTMonitorSession.Listener mListener = new TXIoTMonitorSession.Listener() {
165
+ @Override
166
+ public void onMonitorBegin(TXIoTMonitorSession.Option option, String customData) {
167
+ Log.i(TAG, "onMonitorBegin, customData=" + customData);
168
+ // 开启摄像头采集并推流,同时本地预览
169
+ int ret = mMonitorSession.openCamera(option, mVideoView);
170
+ if (ret != TXIoTError.SUCCESS) {
171
+ Log.e(TAG, "openCamera failed: " + ret);
172
+ }
173
+ // 开启麦克风采集并推流
174
+ ret = mMonitorSession.openMicrophone();
175
+ if (ret != TXIoTError.SUCCESS) {
176
+ Log.e(TAG, "openMicrophone failed: " + ret);
177
+ }
178
+ }
179
+
180
+ @Override
181
+ public void onMonitorSwitch(TXIoTMonitorSession.VideoQuality quality) {
182
+ Log.i(TAG, "onMonitorSwitch, quality=" + quality);
183
+ int ret = mMonitorSession.switchVideoQuality(quality);
184
+ if (ret != TXIoTError.SUCCESS) {
185
+ Log.e(TAG, "switchVideoQuality failed: " + ret);
186
+ }
187
+ }
188
+
189
+ @Override
190
+ public void onMonitorEnd() {
191
+ Log.i(TAG, "onMonitorEnd");
192
+ mMonitorSession.closeCamera();
193
+ mMonitorSession.closeMicrophone();
194
+ }
195
+
196
+ @Override
197
+ public void onPTZCommandReceived(TXIoTMonitorSession.PTZCommand command, int speed) {
198
+ Log.i(TAG, "onPTZCommandReceived, command=" + command + ", speed=" + speed);
199
+ // 仅支持云台的设备需实现,驱动云台电机执行对应动作
200
+ }
201
+ };
202
+
203
+ @Override
204
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
205
+ super.onCreate(savedInstanceState);
206
+ setContentView(R.layout.activity_monitor);
207
+ mVideoView = findViewById(R.id.video_view);
208
+
209
+ // 前提:SDK 已完成初始化并登录成功(参见「登录与注册」)
210
+ mMonitorSession = TXIoTMonitorSession.getInstance();
211
+ mMonitorSession.addListener(mListener);
212
+
213
+ Log.i(TAG, "monitor session ready, waiting for monitor request from app...");
214
+ }
215
+
216
+ @Override
217
+ protected void onDestroy() {
218
+ // 释放资源
219
+ mMonitorSession.closeCamera();
220
+ mMonitorSession.closeMicrophone();
221
+ mMonitorSession.removeListener(mListener);
222
+ super.onDestroy();
223
+ }
224
+ }
225
+ ```
226
+
227
+ ## 常见问题
228
+
229
+ |现象|排查建议|
230
+ |---------|---------|
231
+ |发起监控查看后,设备端未收到 `onMonitorBegin`|确认设备已成功登录;确认已通过 `addListener` 注册监听器且未在收到回调前被 `removeListener` 移除。|
232
+ |APP 端看不到监控画面|确认已在 `onMonitorBegin` 中调用 `openCamera` 且返回 `TXIoTError.SUCCESS`;确认已获得 `CAMERA` 运行时权限;确认摄像头未被其他应用占用。|
233
+ |APP 端听不到声音|确认已调用 `openMicrophone` 且返回 `TXIoTError.SUCCESS`;确认已获得 `RECORD_AUDIO` 运行时权限。|
234
+ |切换清晰度后,设备端未收到 `onMonitorSwitch`|确认设备已成功登录且监听器已注册;确认监控会话已建立(`onMonitorBegin` 已触发)。|
235
+ |收到 `onMonitorSwitch` 回调但画面清晰度未变化|确认在回调中调用了 `switchVideoQuality` 且返回 `TXIoTError.SUCCESS`;确认传入的 `quality` 与回调携带的值一致。|
236
+ |监控结束后摄像头/麦克风仍被占用|确认在 `onMonitorEnd` 回调及页面销毁(`onDestroy`)时调用了 `closeCamera` 与 `closeMicrophone` 释放采集资源。|
237
+