Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
ef1690a8
Commit
ef1690a8
authored
Aug 12, 2022
by
万齐军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
全局网络处理
parent
b9e2c6ec
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
17 deletions
+96
-17
IAudioImService.kt
api/audioim/src/main/java/com/ydl/audioim/api/IAudioImService.kt
+6
-1
build.gradle
app/build.gradle
+1
-0
ComponentTestApp.java
app/src/main/java/com/ydl/component/base/ComponentTestApp.java
+7
-3
AudioHomeActivity.kt
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
+30
-4
AudioNetAPi.kt
m-audioim/src/main/java/com/ydl/audioim/http/AudioNetAPi.kt
+5
-2
AudioImServiceImp.kt
m-audioim/src/main/java/com/ydl/audioim/modular/AudioImServiceImp.kt
+44
-1
ConsultantAudioHomeActivity.kt
m-audioim/src/main/java/com/ydl/consultantim/ConsultantAudioHomeActivity.kt
+3
-6
No files found.
api/audioim/src/main/java/com/ydl/audioim/api/IAudioImService.kt
View file @
ef1690a8
...
...
@@ -33,10 +33,14 @@ interface IAudioImService : IProvider{
/**
* 拨打语音电话转axb弹窗
*/
fun
openAxbDialog
(
activity
:
Activity
?,
type
:
Int
,
phoneNumber
:
String
?)
fun
openAxbDialog
(
activity
:
Activity
?,
type
:
Int
,
phoneNumber
:
String
?)
/**
* 事件上报
*/
fun
callEventSave
(
status
:
String
,
res
:
String
,
session
:
String
?,
line
:
String
)
fun
initRtcNetQuality
()
fun
initAgoraRtc
(
context
:
Context
)
}
\ No newline at end of file
app/build.gradle
View file @
ef1690a8
...
...
@@ -213,6 +213,7 @@ dependencies {
implementation
project
(
':m-muse'
)
implementation
project
(
':m-im'
)
implementation
project
(
":api:im"
)
implementation
project
(
":api:audioim"
)
implementation
project
(
':m-dynamic'
)
implementation
project
(
':m-course'
)
implementation
project
(
":api:course"
)
...
...
app/src/main/java/com/ydl/component/base/ComponentTestApp.java
View file @
ef1690a8
...
...
@@ -4,9 +4,10 @@ import android.app.ActivityManager;
import
android.content.Context
;
import
android.os.Build
;
import
android.os.Process
;
import
androidx.multidex.MultiDex
;
import
android.webkit.WebView
;
import
androidx.multidex.MultiDex
;
import
com.facebook.drawee.backends.pipeline.Fresco
;
import
com.meituan.android.walle.WalleChannelReader
;
import
com.tencent.qcloud.tuicore.calling.trtccalling.model.TRTCCalling
;
...
...
@@ -14,6 +15,7 @@ import com.umeng.analytics.MobclickAgent;
import
com.umeng.commonsdk.UMConfigure
;
import
com.umeng.socialize.PlatformConfig
;
import
com.umeng.socialize.UMShareAPI
;
import
com.ydl.audioim.api.IAudioImService
;
import
com.ydl.component.route.PlatformTempCommonRouteImpl
;
import
com.ydl.confide.BuildConfig
;
import
com.ydl.media.audio.AudioPlayer
;
...
...
@@ -21,6 +23,7 @@ import com.ydl.media.audio.manager.MediaSessionManager;
import
com.ydl.media.audio.manager.NotifyManager
;
import
com.ydl.ydl_image.manager.YDLImageCacheManager
;
import
com.ydl.ydlcommon.base.BaseApp
;
import
com.ydl.ydlcommon.modular.ModularServiceManagerKt
;
import
com.ydl.ydlcommon.router.YdlCommonRouterManager
;
import
com.ydl.ydlcommon.utils.AppProgressUtils
;
import
com.ydl.ydlcommon.utils.Utils
;
...
...
@@ -29,7 +32,6 @@ import com.yidianling.common.tools.ToastUtil;
import
com.yidianling.consultant.preview.TestImageLoader
;
import
com.yidianling.consultant.preview.ZoomMediaLoader
;
import
com.yidianling.course.lifeCallback.CoursePlayLifecycle
;
import
com.yidianling.course.widget.AudioPlayView
;
/**
...
...
@@ -71,12 +73,14 @@ public class ComponentTestApp extends BaseApp {
registerActivityLifecycleCallbacks
(
new
CoursePlayLifecycle
());
ModularServiceManagerKt
.
findRouteService
(
IAudioImService
.
class
).
initAgoraRtc
(
this
);
Fresco
.
initialize
(
this
);
TRTCCalling
.
sharedInstance
(
this
).
setMdtCallBack
(
new
TRTCCalling
.
MdtCallBack
()
{
@Override
public
void
onReceiveNewInvitation
(
String
roomId
)
{
ToastUtil
.
toastShort
(
"电话邀请"
+
roomId
);
ToastUtil
.
toastShort
(
"电话邀请"
+
roomId
);
}
@Override
...
...
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
View file @
ef1690a8
...
...
@@ -46,6 +46,7 @@ import com.ydl.webview.NewH5Activity
import
com.ydl.webview.RefreshWebEvent
import
com.ydl.ydl_av.chat.bean.AudioMessageBean
import
com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import
com.ydl.ydl_av.voice.listener.RtcNetInterface
import
com.ydl.ydl_av.voice.manager.YDLVoiceManager
import
com.ydl.ydl_image.config.SimpleImageOpConfiger
import
com.ydl.ydl_image.manager.YDLImageCacheManager
...
...
@@ -1062,9 +1063,11 @@ class AudioHomeActivity :
* param appId 应用id
* param mRtcEventHandler 事件回调(SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/
voiceManage
=
YDLVoiceManager
(
this
,
BuildConfig
.
AGORA_APPID
,
mRtcEventHandler
)
voiceManage
?.
init
()
voiceManage
?.
getVoiceApi
()
?.
setAudioProfile
(
Constants
.
AUDIO_PROFILE_DEFAULT
,
Constants
.
AUDIO_SCENARIO_CHATROOM_GAMING
)
voiceManage
=
YDLVoiceManager
()
voiceManage
?.
attachVoiceEventHandler
(
mRtcEventHandler
)
voiceManage
?.
getVoiceApi
()
?.
setAudioProfile
(
Constants
.
AUDIO_PROFILE_DEFAULT
,
Constants
.
AUDIO_SCENARIO_CHATROOM_GAMING
)
voiceManage
?.
attachNetQualityListener
(
NetQuality
())
}
/**
...
...
@@ -1640,7 +1643,7 @@ class AudioHomeActivity :
// 声网离开房间
voiceManage
?.
getVoiceApi
()
?.
leaveChannel
()
}
voiceManage
?.
getVoiceApi
()
?.
destroy
()
//
voiceManage?.getVoiceApi()?.destroy()
voiceManage
=
null
}
...
...
@@ -1654,6 +1657,29 @@ class AudioHomeActivity :
override
fun
onBackPressed
()
{
}
inner
class
NetQuality
:
RtcNetInterface
{
override
fun
onLocalAudioStats
(
bitrate
:
Int
,
packetLossRate
:
Int
)
{
}
override
fun
onNetQuality
(
uid
:
Int
,
tx
:
Int
,
rx
:
Int
)
{
}
override
fun
onRemoteAudioFeel
(
frozenRate
:
Int
,
qoeQuality
:
Int
,
reason
:
Int
,
mos
:
Int
)
{
}
override
fun
onRemoteAudioStateChanged
(
uid
:
Int
,
state
:
Int
,
reason
:
Int
,
elapsed
:
Int
)
{
}
override
fun
onRemoteAudioStats
(
quality
:
Int
,
delay
:
Int
,
bitrate
:
Int
,
audioLossRate
:
Int
)
{
}
}
/**
* 倾诉日志
* @param session 通话业务id
...
...
m-audioim/src/main/java/com/ydl/audioim/http/AudioNetAPi.kt
View file @
ef1690a8
...
...
@@ -33,12 +33,15 @@ interface AudioNetAPi {
// @POST("auth/listen-order/callback/agora/finish")
// fun connectFinish(@Body body:RequestBody): Observable<BaseAPIResponse<Any>>
@POST
(
"counselor/device/upload"
)
fun
report
(
@Body
params
:
Map
<
String
,
Any
>):
Observable
<
BaseAPIResponse
<
String
>>
/**
* 通话警告与错误回调
*/
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
,
"Content-Type:application/json"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
,
"Content-Type:application/json"
)
@POST
(
"auth/listen-order/callback/agora"
)
fun
connectException
(
@Body
body
:
RequestBody
):
Observable
<
BaseAPIResponse
<
Any
>>
fun
connectException
(
@Body
body
:
RequestBody
):
Observable
<
BaseAPIResponse
<
Any
>>
/**
...
...
m-audioim/src/main/java/com/ydl/audioim/modular/AudioImServiceImp.kt
View file @
ef1690a8
...
...
@@ -5,9 +5,17 @@ import android.content.Context
import
android.content.Intent
import
android.net.Uri
import
com.alibaba.android.arouter.facade.annotation.Route
import
com.ydl.audioim.BuildConfig
import
com.ydl.audioim.YDLavManager
import
com.ydl.audioim.api.IAudioImService
import
com.ydl.audioim.http.AudioNetAPi
import
com.ydl.audioim.widget.AxbConfirmDialog
import
com.ydl.devicesidlib.DeviceIDHelper
import
com.ydl.ydl_av.voice.listener.RtcGlobalNet
import
com.ydl.ydl_av.voice.manager.YDLVoiceManager
import
com.ydl.ydlcommon.utils.log.XLog
import
com.ydl.ydlnet.YDLHttpUtils
import
io.reactivex.schedulers.Schedulers
/**
* Created by Ykai on 2022/7/26.
...
...
@@ -45,7 +53,7 @@ class AudioImServiceImp : IAudioImService {
override
fun
onClose
()
{
}
})
})
dialog
.
show
()
}
...
...
@@ -53,7 +61,41 @@ class AudioImServiceImp : IAudioImService {
YDLavManager
.
instances
.
callEventSave
(
status
,
res
,
session
,
line
)
}
override
fun
initRtcNetQuality
()
{
YDLVoiceManager
.
enableLastmileTest
(
true
)
YDLVoiceManager
.
attachGlobalNetListener
(
RtcGlobalNetQuality
(
30
))
}
override
fun
initAgoraRtc
(
context
:
Context
)
{
YDLVoiceManager
.
init
(
context
.
applicationContext
,
BuildConfig
.
AGORA_APPID
)
}
override
fun
init
(
context
:
Context
?)
{
}
}
internal
class
RtcGlobalNetQuality
(
private
val
threshold
:
Int
)
:
RtcGlobalNet
{
private
var
average
=
0.0
private
var
count
=
0
override
fun
onLastmileQuality
(
quality
:
Int
)
{
if
(
quality
in
1
..
6
)
{
average
=
(
average
*
count
+
quality
)
/
(
count
+
1
)
count
++
if
(
quality
>
3
)
{
XLog
.
i
(
"RtcGlobalNetQuality"
,
quality
.
toString
())
}
android
.
util
.
Log
.
i
(
"qeqe"
,
String
.
format
(
"%.2f,%d"
,
average
,
count
))
if
(
count
>=
threshold
)
{
//上报
val
req
=
hashMapOf
(
"deviceId"
to
DeviceIDHelper
.
getInstance
().
deviceId
,
"rscp"
to
average
)
YDLHttpUtils
.
obtainApi
(
AudioNetAPi
::
class
.
java
).
report
(
req
).
subscribeOn
(
Schedulers
.
io
()).
subscribe
()
average
=
0.0
count
=
0
}
}
}
}
\ No newline at end of file
m-audioim/src/main/java/com/ydl/consultantim/ConsultantAudioHomeActivity.kt
View file @
ef1690a8
...
...
@@ -21,7 +21,6 @@ import com.alibaba.android.arouter.facade.annotation.Route
import
com.alibaba.android.arouter.launcher.ARouter
import
com.google.gson.Gson
import
com.tbruyelle.rxpermissions2.RxPermissions
import
com.ydl.audioim.BuildConfig
import
com.ydl.audioim.R
import
com.ydl.audioim.YDLavManager
import
com.ydl.audioim.http.command.ConnectExceptionCommand
...
...
@@ -690,9 +689,9 @@ class ConsultantAudioHomeActivity :
* param appId 应用id
* param mRtcEventHandler 事件回调(SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/
voiceManage
=
YDLVoiceManager
(
this
,
BuildConfig
.
AGORA_APPID
,
mRtcEventHandler
)
voiceManage
?.
init
(
)
voiceManage
?.
getVoiceApi
()
?.
setAudioProfile
(
Constants
.
AUDIO_PROFILE_DEFAULT
,
Constants
.
AUDIO_SCENARIO_CHATROOM_GAMING
)
voiceManage
=
YDLVoiceManager
()
voiceManage
?.
attachVoiceEventHandler
(
mRtcEventHandler
)
voiceManage
?.
getVoiceApi
()
?.
setAudioProfile
(
Constants
.
AUDIO_PROFILE_DEFAULT
,
Constants
.
AUDIO_SCENARIO_CHATROOM_GAMING
)
}
...
...
@@ -1049,7 +1048,6 @@ class ConsultantAudioHomeActivity :
totalDisposable
?.
dispose
()
connectingStatusDisposable
?.
dispose
()
voiceManage
?.
getVoiceApi
()
?.
leaveChannel
()
voiceManage
?.
getVoiceApi
()
?.
destroy
()
voiceManage
=
null
mPlayer
?.
clear
()
sensorManager
?.
unregisterListener
(
this
)
...
...
@@ -1063,7 +1061,6 @@ class ConsultantAudioHomeActivity :
}
private
fun
voiceDestory
()
{
voiceManage
?.
getVoiceApi
()
?.
destroy
()
voiceManage
=
null
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment