AgoraIO-Extensions / react-native-agora

React Native around the Agora RTC SDKs for Android and iOS agora
https://www.agora.io
MIT License
625 stars 227 forks source link

The app is getting killed after 10-15 minutes when using Agora in the foreground service. #693

Closed vishaledkey closed 1 year ago

vishaledkey commented 1 year ago

Describe the bug I have a ForegoundService in my react-native app, and it records the audio for 40 minutes. After 40 minutes service automatically stops. Previously I was using MediaRecorder to record audio and send that file to BE. But we were facing issues with uploading those recordings so we decided to go with Agora Streaming. So far it is working fine with iOS, but for Android, in some devices like Oneplus 6(A60000) the App is getting killed after 10-15 minutes and I couldn’t find anything meaningful in the logcat on the Android Studio. I enabled the Agora logs to see more detailed logs.

To Reproduce Steps to reproduce the behavior:

  1. Start the service and join the channel
  2. Lock the mobile screen and wait for 10-15 minutes
  3. Unlock the phone, and you'll notice the app is not alive anymore
  4. Check the log and see this line: [ADGM-UP](0x70d349b2b0): state 50, category 53, reason -1 due to invalid send bitrate 0, audio send stream size 1

Expected behavior Behavior should be consistent across all Android devices and the app should not get killed after 10 minutes when the user locks the screen.

Smartphone (please complete the following information):

Additional context Agora Logs:

[08/24/23 09:45:34:634][16227][U]:(00000000): RtcEngine::initializeInternal(this:0x718378b3f0, {"context":{"eventHandler":"0x709354d030", "areaCode":4294967295, "logConfig":{"filePath":"/data/user/0/com.edkey.quicktakes/files/20230824.log"}, "autoRegisterAgoraExtensions":1}})
[08/24/23 09:45:34:634][16227][A]:(00000001):   RtcEngine::initializeEx(this:0x718378b3f0, context:(isPassThruMode:1 maxOutputBitrateKpbs:30000, channelProfile:1, audioScenario:0, areaCode:4294967295))
[08/24/23 09:45:34:634][16227][A]:(00000002):     RtcEngine::startService(this:0x718378b3f0, context:(isPassThruMode:1, maxOutputBitrateKpbs:30000))
[08/24/23 09:45:34:634][16227][A]:(00000003):       RtcEngine::initLowLevelModules(this:0x718378b3f0, void)
[08/24/23 09:45:34:634][16227][A]:(00000004): AgoraService::initializeEx(this:0x7133507370, configEx:(engineType:0, enableAudioProcessor:1, enableAudioDevice:1, enableVideo:1, context:0x3486, bitrateConstraints:(min_bitrate_bps:0, start_bitrate_bps:300000, min_bitrate_bps:0), logDir: /data/user/0/com.edkey.quicktakes/files/20230824.log, domainLimit:0))
[08/24/23 09:45:34:900][16227][A]:(00000005):   AgoraService::setLogFilter(this:0x7133507370, filters:12)
[08/24/23 09:45:35:008][16276][E]:audio_device_generic.cc: (line 65): SetPlayoutDevice: Not supported on this platform
[08/24/23 09:45:35:009][16276][E]:audio_device_generic.cc: (line 71): SetRecordingDevice: Not supported on this platform
[08/24/23 09:45:35:038][16227][A]:(00000006): AgoraService::createAudioDeviceManager(this:0x7133507370, void)
[08/24/23 09:45:35:039][16227][A]:(00000007): AudioDeviceManagerImpl::setDefaultAudioRouting(this:0x70d34f9ed0, route:3)
[08/24/23 09:45:35:042][7115][A]:(00000008):         AgoraService::setAudioSessionPreset(this:0x7133507370, scenario:0)
[08/24/23 09:45:35:042][7115][A]:(00000009):         AgoraService::registerAgoraServiceObserver(this:0x7133507370, observer:0x70f35a8ad8)
[08/24/23 09:45:35:050][7115][A]:(00000010):         AgoraService::createMediaNodeFactory(this:0x7133507370, void)
[08/24/23 09:45:35:050][16227][A]:(00000011): MediaPlayerImpl::initialize(this:0x71534e35d0, {"agora_service":"0x7133507370"})
[08/24/23 09:45:35:051][16227][A]:(00000012):   AgoraService::createMediaNodeFactory(this:0x7133507370, void)
[08/24/23 09:45:35:051][16227][A]:(00000013):   MediaNodeFactoryImpl::createMediaPlayerSource(this:0x70e366ae00, void)
[08/24/23 09:45:35:051][16238][A]:(00000014): MediaPlayerImpl::registerPlayerSourceObserver(this:0x716381d298, observer:0x7113480b90)
[08/24/23 09:45:35:051][16238][A]:(00000015): MediaPlayerImpl::registerVideoFrameObserver(this:0x716381d298, observer:0x7113480b98)
[08/24/23 09:45:35:052][16238][A]:(00000016): MediaPlayerImpl::registerAudioFrameObserver(this:0x716381d298, observer:0x7113480ba0)
[08/24/23 09:45:35:052][16238][A]:(00000017): MediaPlayerImpl::SetReportSender(this:0x716381d298, sender:0x711348fe90)
[08/24/23 09:45:35:052][16238][A]:(00000018): AgoraService::createMediaNodeFactory(this:0x7133507370, void)
[08/24/23 09:45:35:052][16238][A]:(00000019): MediaNodeFactoryImpl::createAudioPcmDataSender(this:0x70e366ae00, void)
[08/24/23 09:45:35:052][16238][A]:(00000020): MediaNodeFactoryImpl::createVideoFrameSender(this:0x70e366ae00, void)
[08/24/23 09:45:35:052][16227][A]:(00000021):   MediaPlayerSourceFFMpeg::registerPlayerSourceObserver(this:0x7113480b90, observer: 0x71534e35d8)
[08/24/23 09:45:35:053][16227][A]:(00000022):   AgoraService::createMediaPlayerVideoTrack(this:0x7133507370, playerVideoSource:0x7113480ba8)
[08/24/23 09:45:35:053][16227][A]:(00000023):     MediaPlayerSourceFFMpeg::getVideoFrameSender(this:0x7113480b90, void)
[08/24/23 09:45:35:060][16227][A]:(00000024):     VideoFrameRotator::setOutputFormat(this:0x70a358bb70, format:(width:960, height:540, fps:15, fixed:1))
[08/24/23 09:45:35:069][16227][A]:(00000025):     VideoFrameAdapter::setOutputFormat(this:0x713350a970, format:(width:960, height:540, fps:15))
[08/24/23 09:45:35:070][16227][A]:(00000026):   LocalVideoTrackImpl::addRenderer(this:0x719352c4b0, videoRenderer:0x70b3572850)
[08/24/23 09:45:35:070][16227][A]:(00000027):     VideoFrameRotator::setOutputFormat(this:0x70a358d100, format:(width:960, height:540, fps:15, fixed:1))
[08/24/23 09:45:35:070][16227][A]:(00000028):   AgoraService::createMediaPlayerAudioTrack(this:0x7133507370, playerSource:0x7113480ba8)
[08/24/23 09:45:35:070][16227][A]:(00000029):     MediaPlayerSourceFFMpeg::getAudioPcmDataSender(this:0x7113480b90, void)
[08/24/23 09:45:35:071][16227][A]:(00000030): MediaPlayerImpl::getMediaPlayerId(this:0x71534e35d0, {})
[08/24/23 09:45:35:071][16227][A]:(00000031):   MediaPlayerSourceFFMpeg::getSourceId(this:0x7113480b90, void)
[08/24/23 09:45:35:072][16227][A]:(00000032): MediaPlayerImpl::getMediaPlayerId(this:0x71534e35d0, {})
[08/24/23 09:45:35:072][16227][A]:(00000033):   MediaPlayerSourceFFMpeg::getSourceId(this:0x7113480b90, void)
[08/24/23 09:45:35:072][7115][A]:(00000034):         MediaPlayerImpl::getMediaPlayerId(this:0x71534e35d0, {})
[08/24/23 09:45:35:072][16227][A]:(00000035): MediaPlayerSourceFFMpeg::getSourceId(this:0x7113480b90, void)
[08/24/23 09:45:35:072][7115][A]:(00000036):         MediaPlayerImpl::registerPlayerSourceObserver(this:0x71534e35d0, {"observer":"0x71438811d0"})
[08/24/23 09:45:35:072][7115][A]:(00000037):         RhythmPlayerImpl::RhythmPlayerImpl(this:0x713350b270, void)
[08/24/23 09:45:35:073][16227][A]:(00000038): AgoraService::createRtcConnectionEx(this:0x7133507370, cfg:(autoSubscribeAudio:1, autoSubscribeVideo:1, enableAudioRecordingOrPlayout:1maxSendBitrate:-1, minPort:0, maxPort:0,  clientRoleType:2, clientType:0, vosList.size:0), connId:0)
[08/24/23 09:45:35:073][16227][A]:(00000039):   RtcConnectionImpl::initializeEx(this:0x717357b8d0, serviceCfg:(enableAudioProcessor:1, enableAudioDevice:1, enableVideo:1, context:0x3486), cfg:(autoSubscribeAudio:1, autoSubscribeVideo:1, enableAudioRecordingOrPlayout:1, maxSendBitrate:-1, minPort:0, maxPort:0, clientRoleType:2, clientType:0, channelProfile:1, vosList.size:0, recvType:(audio: 0, video: 0)))
[08/24/23 09:45:35:090][16227][A]:(00000040):     RtcConnectionImpl::getUserRole(this:0x717357b8d0, void)
[08/24/23 09:45:35:097][16227][A]:(00000041):     RtcConnectionImpl::subscribeReceivePacketHandler(this:0x717357b8d0, void)
[08/24/23 09:45:35:146][16227][A]:(00000042): RtcConnectionImpl::registerObserver(this:0x717357b8d0, observer:0x7183653ab0)
[08/24/23 09:45:35:146][16227][A]:(00000043): RtcConnectionImpl::registerNetworkObserver(this:0x717357b8d0, observer:0x7183653ab8)
[08/24/23 09:45:35:146][16227][A]:(00000044): LocalUserImpl::registerLocalUserObserver(this:0x7193522a30, observer:0x7183653ac0)
[08/24/23 09:45:35:156][7115][A]:(00000045):         AgoraService::createAudioDeviceManager(this:0x7133507370, void)
[08/24/23 09:45:35:156][7115][A]:(00000046):         AudioDeviceManagerImpl::registerObserver(this:0x70d34f9ed0, observer:0x70f35a8ad0)
[08/24/23 09:45:35:157][7115][A]:(00000047):       RtcEngine::queryInterface(this:0x718378b3f0, {"iid":3, "inter":"0x7ff9f60348"})
[08/24/23 09:45:35:157][7115][A]:(00000048):       RtcEngine::setParametersInternal(this:0x718378b3f0, {"parameters":{"rtc.channel_profile":1}})
[08/24/23 09:45:35:158][16227][A]:(00000049): LocalUserImpl::setAudioScenario(this:0x7193522a30, config:(scenario:0))
[08/24/23 09:45:35:188][7115][A]:(00000050):     RtcEngine::enableLocalAudio(this:0x718378b3f0, {"enabled":1})
[08/24/23 09:45:35:189][7115][A]:(00000051):       RtcEngine::enableLocalAudioInternal(this:0x718378b3f0, enabled:1)
[08/24/23 09:45:35:189][7115][A]:(00000052):         RtcEngine::queryInterface(this:0x718378b3f0, {"iid":3, "inter":"0x7ff9f602a8"})
[08/24/23 09:45:35:189][7115][A]:(00000053):         RtcEngine::setParametersInternal(this:0x718378b3f0, {"parameters":{"che.audio.record":true}})
[08/24/23 09:45:35:189][7115][A]:(00000054):     RtcEngine::enableLocalVideo(this:0x718378b3f0, {"enabled":0})
[08/24/23 09:45:35:191][7115][A]:(00000055):       RtcEngine::enableLocalVideoInternal(this:0x718378b3f0, enabled:0)
[08/24/23 09:45:35:194][7115][U]:(00000056): RtcEngine::queryInterface(this:0x718378b3f0, {"iid":4, "inter":"0x7ff9f60590"})
[08/24/23 09:45:35:196][7115][U]:(00000057): RtcEngine::setParameters(this:0x718378b3f0, {"parameters":{"rtc.api.set_uid_compatible_mode":true}})
[08/24/23 09:45:35:196][7115][A]:(00000058):   RtcEngine::setParametersInternal(this:0x718378b3f0, {"parameters":{"rtc.api.set_uid_compatible_mode":true}})
[08/24/23 09:45:35:197][7115][U]:(00000059): RtcEngine::setDefaultAudioRouteToSpeakerphone(this:0x718378b3f0, {"defaultToSpeaker":1})
[08/24/23 09:45:35:198][7115][A]:(00000060):   AgoraService::createAudioDeviceManager(this:0x7133507370, void)
[08/24/23 09:45:35:198][7115][A]:(00000061):   AudioDeviceManagerImpl::setDefaultAudioRouting(this:0x70d34f9ed0, route:3)
[08/24/23 09:45:35:198][7115][U]:(00000062): RtcEngine::setAudioProfile(this:0x718378b3f0, {"profile":4})
[08/24/23 09:45:35:199][16227][A]:(00000063): LocalUserImpl::setAudioEncoderConfiguration(this:0x7193522a30, config:(audioProfile:4))
[08/24/23 09:45:35:201][7115][A]:(00000064):   RtcEngine::setParametersInternal(this:0x718378b3f0, {"parameters":{"che.audio.profile":{"config":4}}})
[08/24/23 09:45:35:204][7115][U]:(00000065): RtcEngine::setAudioScenario(this:0x718378b3f0, {"scenario":3})
[08/24/23 09:45:35:205][16227][A]:(00000066): AgoraService::setAudioSessionPreset(this:0x7133507370, scenario:3)
[08/24/23 09:45:35:205][16227][E]:[CONN-0][CALLCTX]: set audio scenario type: new type(3) does not equal to previous type(0)...
[08/24/23 09:45:35:205][16227][A]:(00000067): LocalUserImpl::setAudioScenario(this:0x7193522a30, config:(scenario:3))
[08/24/23 09:45:35:206][7115][U]:(00000068): RtcEngine::setClientRole(this:0x718378b3f0, {"role":1, "options":{"audienceLatencyLevel":2}})
[08/24/23 09:45:35:207][7115][A]:(00000069):   RtcEngine::setClientRoleInternal(this:0x718378b3f0, {"role":1, "options":{"audienceLatencyLevel":2}})
[08/24/23 09:45:35:212][7115][U]:(00000070): RtcEngine::setParameters(this:0x718378b3f0, {"parameters":{"che.audio.opensl":true}})
[08/24/23 09:45:35:212][7115][A]:(00000071):   RtcEngine::setParametersInternal(this:0x718378b3f0, {"parameters":{"che.audio.opensl":true}})
[08/24/23 09:45:35:214][7115][U]:(00000072): RtcEngine::joinChannel(this:0x718378b3f0, {"token":"0****k", "channelId":"6d507c57-7539-5639-9d68-2436333cdeec", "uid":248, "options":{...}})
[08/24/23 09:45:35:214][7115][A]:(00000073):   RtcEngine::doJoinChannel(this:0x718378b3f0, token:"0****k", channelId:"6d507c57-7539-5639-9d68-2436333cdeec", localUid:"248", userId:"", options:["publishMicrophone":empty, "publishCustomAudio":empty, "publishCustomAudioTrackId":empty, "publishMediaPlayerAudio":empty, "publishCamera":empty, "publishSecondaryCameraTrack":empty, "publishScreenCaptureVideo":empty, "publishScreenCaptureAudio":empty, "publishCustomVideo":empty, "publishEncodedVideo":empty, "publishTranscodedVideoTrack":empty, "publishMediaPlayerVideo":empty, "publishMediaPlayerId":empty, "publishRhythmPlayerTrack":empty, "isAudioFilterable":empty, "autoSubscribeAudio":1, "autoSubscribeVideo":empty, "enableAudioRecordingOrPlayout":empty, "clientRoleType":1, "audienceLatencyLevel":empty, "defaultVideoStreamType":empty, "channelProfile":1, "audioDelayMs":empty, "enableBuiltInMediaEncryption":empty, "mediaPlayerAudioDelayMs":empty, "customVideoTrackId":empty, "isInteractiveAudience":empty])
[08/24/23 09:45:35:217][7115][A]:(00000074):     RtcEngine::getVersion(this:0x718378b3f0, void)
[08/24/23 09:45:35:221][16227][A]:(00000075): LocalUserImpl::setAudioEncoderConfiguration(this:0x7193522a30, config:(audioProfile:4))
[08/24/23 09:45:35:222][16227][A]:(00000076): LocalUserImpl::setAudioScenario(this:0x7193522a30, config:(scenario:3))
[08/24/23 09:45:35:222][16227][A]:(00000077): LocalUserImpl::subscribeAllAudio(this:0x7193522a30, void)
[08/24/23 09:45:35:222][16227][A]:(00000078): LocalUserImpl::unsubscribeAllVideo(this:0x7193522a30, void)
[08/24/23 09:45:35:223][16227][A]:(00000079): LocalUserImpl::setUserRole(this:0x7193522a30, role:1)
[08/24/23 09:45:35:223][16227][A]:(00000080):   RtcConnectionImpl::setUserRole(this:0x717357b8d0, role:1)
[08/24/23 09:45:35:223][16227][A]:(00000081):     LegacyEventProxy::onClientRoleChanged->onChangeRoleSuccess(this:0x70a358d9a0, oldRole:2, newRole:1, newRoleLatencyLevel:2)
[08/24/23 09:45:35:223][16227][A]:(00000082): LocalUserImpl::setAudienceLatencyLevel(this:0x7193522a30, audience latency level:2)
[08/24/23 09:45:35:224][16229][A]:(00000083): ChannelProxy::onChangeRoleSuccess->onClientRoleChanged(this:0x7183653ab0, oldRole:2, newRole:1, newRoleLatencyLevel:2)
[08/24/23 09:45:35:224][16227][A]:(00000084): AgoraService::createLocalAudioTrack(this:0x7133507370, void)
[08/24/23 09:45:35:287][16227][A]:(00000085): LocalAudioTrackRecorderImpl::registerTrackObserver(this:0x7153506410, observer:0x70f35a8ae0)
[08/24/23 09:45:35:287][16227][A]:(00000086): LocalAudioTrackRecorderImpl::registerTrackObserver(this:0x7153506410, observer:0x7183653ac8)
[08/24/23 09:45:35:287][16227][A]:(00000087): LocalUserImpl::publishAudio(this:0x7193522a30, audioTrack:0x7153506410)
[08/24/23 09:45:35:293][16229][A]:(00000088): ChannelProxy::onAudioPublishStateChanged->onAudioPublishStateChanged(this:0x7183653ab0, channel:6d507c57-7539-5639-9d68-2436333cdeec, oldState:0, newState:2, elapseSinceLastState:147)
[08/24/23 09:45:35:296][16227][A]:(00000089):   LocalAudioTrackImpl::attach(this:0x7153506410, sourceId: 3147431818)
[08/24/23 09:45:35:297][16227][A]:(00000090): RtcConnectionImpl::connect(this:0x717357b8d0, token:"0****k", channelId:"6d507c57-7539-5639-9d68-2436333cdeec", userId:"248")
[08/24/23 09:45:35:314][16227][A]:(00000091): LocalAudioTrackRecorderImpl::setEnabled(this:0x7153506410, enable:1)
[08/24/23 09:45:35:317][16227][A]:(00000092):   LocalAudioTrackImpl::setEnabled(this:0x7153506410, enable: 1)
[08/24/23 09:45:35:350][16227][A]:(00000093): LocalAudioTrackRecorderImpl::enableEarMonitor(this:0x7153506410, enable: 0, includeAudioFilters: 2)
[08/24/23 09:45:35:350][16227][A]:(00000094): RtcConnectionImpl::stopLastmileProbeTest(this:0x717357b8d0, void)
[08/24/23 09:45:35:353][16227][A]:(00000095): RtcConnectionImpl::setConnectionState(this:0x717357b8d0, state: 2)
[08/24/23 09:45:35:354][16227][A]:(00000096): LegacyEventProxy::onConnectionStateChanged->onConnecting(this:0x70a358d9a0, channel:"6d507c57-7539-5639-9d68-2436333cdeec", userId:"248", reason:0)
[08/24/23 09:45:35:354][16229][A]:(00000097): ChannelProxy::emitConnStateChanged->onConnectionStateChanged(this:0x7183653ab0, state:2, reason:0)
[08/24/23 09:45:35:358][16227][A]:(00000098): AudioDeviceEventManager::CallbackOnRoutingChanged->CallbackOnRoutingChanged(this:0x70c3534c80, route: 3)
[08/24/23 09:45:35:359][16227][A]:(00000099):   ModuleEventHandler::CallbackOnRoutingChanged(this:0x70b3571ca8, [USB] route:3)
[08/24/23 09:45:35:361][16229][A]:(00000100): RtcEngineEventHandlerCallback::onRoutingChanged->onAudioRoutingChanged(this:0x70f35a8ac8, route:3)
[08/24/23 09:45:35:362][7115][U]:(00000101): RtcEngine::enableAudio(this:0x718378b3f0, {})
[08/24/23 09:45:35:362][7115][A]:(00000102):   RtcEngine::enableAudioPlayoutInternal(this:0x718378b3f0, enabled:1)
[08/24/23 09:45:35:427][16227][A]:(00000103): RtcEngine::setParametersByTds(this:0x7133510b50, {"parameters":{"che.audio.adm_android_mode":5,"che.audio.opensl":false}})
[08/24/23 09:45:35:427][16227][A]:(00000104): RtcEngine::setParametersByTds(this:0x7133510b50, {"parameters":{"rtc.enable_xdump":true,"rtc.enable_xdump_file":true,"rtc.enable_xdump_upload":true}})
[08/24/23 09:45:35:440][16348][E]:WebRtcAudioTrack [JavaAdm]: audioTimestamp is unavailable
[08/24/23 09:45:35:452][16227][A]:(00000105): LocalAudioTrackRecorderImpl::enableEarMonitor(this:0x7153506410, enable: 0, includeAudioFilters: 2)
[08/24/23 09:45:35:452][7115][A]:(00000106):   RtcEngine::enableLocalAudio(this:0x718378b3f0, {"enabled":1})
[08/24/23 09:45:35:453][7115][A]:(00000107):     RtcEngine::enableLocalAudioInternal(this:0x718378b3f0, enabled:1)
[08/24/23 09:45:35:456][16227][A]:(00000108): LocalAudioTrackMediaPlayerImpl::setLocalPlaybackExtraDelay(this:0x71438ad5f0, delayMs:0)
[08/24/23 09:45:35:456][16227][A]:(00000109): LocalUserImpl::setAudienceLatencyLevel(this:0x7193522a30, audience latency level:2)
[08/24/23 09:45:35:458][7115][A]:(00000110):       RtcEngine::queryInterface(this:0x718378b3f0, {"iid":3, "inter":"0x7ff9f608d8"})
[08/24/23 09:45:35:458][7115][A]:(00000111):       RtcEngine::setParametersInternal(this:0x718378b3f0, {"parameters":{"che.audio.record":true}})
[08/24/23 09:45:35:459][16227][A]:(00000112): LocalUserImpl::subscribeAllAudio(this:0x7193522a30, void)
[08/24/23 09:45:35:460][16227][A]:(00000113): LocalUserImpl::setAudienceLatencyLevel(this:0x7193522a30, audience latency level:2)
[08/24/23 09:45:35:461][7115][A]:(00000114):   RtcEngine::queryInterface(this:0x718378b3f0, {"iid":3, "inter":"0x7ff9f60a48"})
[08/24/23 09:45:35:461][7115][A]:(00000115):   RtcEngine::setParametersInternal(this:0x718378b3f0, {"parameters":{"che.audio.enabled":true}})
[08/24/23 09:45:35:541][16227][A]:(00000116): RtcConnectionImpl::setConnectionState(this:0x717357b8d0, state: 3)
[08/24/23 09:45:35:541][16227][A]:(00000117): LegacyEventProxy::onJoinChannelSuccess->onConnected(this:0x70a358d9a0, channel:"6d507c57-7539-5639-9d68-2436333cdeec", uid:"248", elapsed:326)
[08/24/23 09:45:35:541][16227][A]:(00000118):   RtcConnectionImpl::getUserInfoByUid(this:0x717357b8d0, uid:248)
[08/24/23 09:45:35:541][16227][A]:(00000119):   RtcConnectionImpl::setLocalUserId(this:0x717357b8d0, userId:"248")
[08/24/23 09:45:35:541][16229][A]:(00000120): ChannelProxy::onConnected->onJoinChannelSuccess(this:0x7183653ab0, channel:"6d507c57-7539-5639-9d68-2436333cdeec", uid:"248", elapsed:327, reason:1)
[08/24/23 09:45:35:542][16229][A]:(00000121):   ChannelProxy::emitConnStateChanged->onConnectionStateChanged(this:0x7183653ab0, state:3, reason:1)
[08/24/23 09:45:35:544][16229][A]:(00000122): ChannelProxy::onVideoPublishStateChanged->onVideoPublishStateChanged(this:0x7183653ab0, channel:6d507c57-7539-5639-9d68-2436333cdeec, oldState:0, newState:1, elapseSinceLastState:396)
[08/24/23 09:45:35:546][16227][A]:(00000123): LocalAudioTrackRecorderImpl::setEnabled(this:0x7153506410, enable:1)
[08/24/23 09:45:35:547][16227][A]:(00000124): AudioDeviceEventManager::CallbackOnDeviceStateChanged->CallbackOnDeviceStateChanged(this:0x70c3534c80, deviceType:"1", deviceState:"1", reason:0)
[08/24/23 09:45:35:552][16229][A]:(00000125): ChannelProxy::onLocalAudioTrackStateChanged->onLocalAudioTrackStateChanged(this:0x7183653ab0, state:1 errorCode:0)
[08/24/23 09:45:35:552][16229][A]:(00000126): RtcEngineEventHandlerCallback::onLocalAudioTrackStateChanged->onLocalAudioTrackStateChanged(this:0x70f35a8ac8, state:1 errorCode:0)
[08/24/23 09:45:35:627][16227][A]:(00000127): LocalAudioTrackRecorderImpl::getState(this:0x7153506410, void)
[08/24/23 09:45:35:627][16227][A]:(00000128): LocalAudioTrackRecorderImpl::getState(this:0x7153506410, void)
[08/24/23 09:45:35:628][16229][A]:(00000129): ChannelProxy::onLocalAudioTrackStateChanged->onLocalAudioTrackStateChanged(this:0x7183653ab0, state:2 errorCode:0)
[08/24/23 09:45:35:629][16229][A]:(00000130): RtcEngineEventHandlerCallback::onLocalAudioTrackStateChanged->onLocalAudioTrackStateChanged(this:0x70f35a8ac8, state:2 errorCode:0)
[08/24/23 09:45:35:630][16229][A]:(00000131): ChannelProxy::onAudioPublishStateChanged->onAudioPublishStateChanged(this:0x7183653ab0, channel:6d507c57-7539-5639-9d68-2436333cdeec, oldState:2, newState:3, elapseSinceLastState:337)
[08/24/23 09:45:35:631][16229][A]:(00000132): ChannelProxy::onAudioTrackPublishSuccess->onFirstLocalAudioFramePublished(this:0x7183653ab0, elapsed:416)
[08/24/23 09:45:39:099][16227][E]:[ADGM-UP](0x70d3582e50): state 50, category 53, reason -1 due to invalid send bitrate 0, audio send stream size 1
[08/24/23 09:50:01:151][16227][E]:[ADGM-UP](0x70d3582e50): state 50, category 51, reason -1 due to near in signal level 89 consecutive cnt 10
[08/24/23 10:19:44:211][22065][U]:(00000000): RtcEngine::initializeInternal(this:0x718378a700, {"context":{"eventHandler":"0x70935391d0", "areaCode":4294967295, "logConfig":{"filePath":"/data/user/0/com.edkey.quicktakes/files/20230824.log"}, "autoRegisterAgoraExtensions":1}})
[08/24/23 10:19:44:211][22065][A]:(00000001):   RtcEngine::initializeEx(this:0x718378a700, context:(isPassThruMode:1 maxOutputBitrateKpbs:30000, channelProfile:1, audioScenario:0, areaCode:4294967295))
[08/24/23 10:19:44:211][22065][A]:(00000002):     RtcEngine::startService(this:0x718378a700, context:(isPassThruMode:1, maxOutputBitrateKpbs:30000))
[08/24/23 10:19:44:211][22065][A]:(00000003):       RtcEngine::initLowLevelModules(this:0x718378a700, void)
[08/24/23 10:19:44:211][22065][A]:(00000004): AgoraService::initializeEx(this:0x7133500890, configEx:(engineType:0, enableAudioProcessor:1, enableAudioDevice:1, enableVideo:1, context:0x344a, bitrateConstraints:(min_bitrate_bps:0, start_bitrate_bps:300000, min_bitrate_bps:0), logDir: /data/user/0/com.edkey.quicktakes/files/20230824.log, domainLimit:0))
[08/24/23 10:19:44:262][22065][A]:(00000005):   AgoraService::setLogFilter(this:0x7133500890, filters:12)
[08/24/23 10:19:44:309][22118][E]:audio_device_generic.cc: (line 65): SetPlayoutDevice: Not supported on this platform
[08/24/23 10:19:44:310][22118][E]:audio_device_generic.cc: (line 71): SetRecordingDevice: Not supported on this platform
[08/24/23 10:19:44:321][22065][A]:(00000006): AgoraService::createAudioDeviceManager(this:0x7133500890, void)
[08/24/23 10:19:44:321][22065][A]:(00000007): AudioDeviceManagerImpl::setDefaultAudioRouting(this:0x70d3519370, route:3)
[08/24/23 10:19:44:322][11585][A]:(00000008):         AgoraService::setAudioSessionPreset(this:0x7133500890, scenario:0)
[08/24/23 10:19:44:322][11585][A]:(00000009):         AgoraService::registerAgoraServiceObserver(this:0x7133500890, observer:0x70f386af78)
[08/24/23 10:19:44:324][11585][A]:(00000010):         AgoraService::createMediaNodeFactory(this:0x7133500890, void)
[08/24/23 10:19:44:325][22065][A]:(00000011): MediaPlayerImpl::initialize(this:0x71534f0ed0, {"agora_service":"0x7133500890"})
[08/24/23 10:19:44:325][22065][A]:(00000012):   AgoraService::createMediaNodeFactory(this:0x7133500890, void)
[08/24/23 10:19:44:325][22065][A]:(00000013):   MediaNodeFactoryImpl::createMediaPlayerSource(this:0x70e366e4b0, void)
[08/24/23 10:19:44:325][22079][A]:(00000014): MediaPlayerImpl::registerPlayerSourceObserver(this:0x71638139f8, observer:0x7113499790)
[08/24/23 10:19:44:325][22079][A]:(00000015): MediaPlayerImpl::registerVideoFrameObserver(this:0x71638139f8, observer:0x7113499798)
[08/24/23 10:19:44:325][22079][A]:(00000016): MediaPlayerImpl::registerAudioFrameObserver(this:0x71638139f8, observer:0x71134997a0)
[08/24/23 10:19:44:325][22079][A]:(00000017): MediaPlayerImpl::SetReportSender(this:0x71638139f8, sender:0x7113479990)
[08/24/23 10:19:44:326][22079][A]:(00000018): AgoraService::createMediaNodeFactory(this:0x7133500890, void)
[08/24/23 10:19:44:326][22079][A]:(00000019): MediaNodeFactoryImpl::createAudioPcmDataSender(this:0x70e366e4b0, void)
[08/24/23 10:19:44:326][22079][A]:(00000020): MediaNodeFactoryImpl::createVideoFrameSender(this:0x70e366e4b0, void)
[08/24/23 10:19:44:326][22065][A]:(00000021):   MediaPlayerSourceFFMpeg::registerPlayerSourceObserver(this:0x7113499790, observer: 0x71534f0ed8)
[08/24/23 10:19:44:327][22065][A]:(00000022):   AgoraService::createMediaPlayerVideoTrack(this:0x7133500890, playerVideoSource:0x71134997a8)
[08/24/23 10:19:44:327][22065][A]:(00000023):     MediaPlayerSourceFFMpeg::getVideoFrameSender(this:0x7113499790, void)
[08/24/23 10:19:44:332][22065][A]:(00000024):     VideoFrameRotator::setOutputFormat(this:0x70a354bbb0, format:(width:960, height:540, fps:15, fixed:1))
[08/24/23 10:19:44:335][22065][A]:(00000025):     VideoFrameAdapter::setOutputFormat(this:0x7133503b30, format:(width:960, height:540, fps:15))
[08/24/23 10:19:44:335][22065][A]:(00000026):   LocalVideoTrackImpl::addRenderer(this:0x719350c820, videoRenderer:0x70b3563f90)
[08/24/23 10:19:44:335][22065][A]:(00000027):     VideoFrameRotator::setOutputFormat(this:0x70a354f000, format:(width:960, height:540, fps:15, fixed:1))
[08/24/23 10:19:44:335][22065][A]:(00000028):   AgoraService::createMediaPlayerAudioTrack(this:0x7133500890, playerSource:0x71134997a8)
[08/24/23 10:19:44:335][22065][A]:(00000029):     MediaPlayerSourceFFMpeg::getAudioPcmDataSender(this:0x7113499790, void)
[08/24/23 10:19:44:337][22065][A]:(00000030): MediaPlayerImpl::getMediaPlayerId(this:0x71534f0ed0, {})
[08/24/23 10:19:44:337][22065][A]:(00000031):   MediaPlayerSourceFFMpeg::getSourceId(this:0x7113499790, void)
[08/24/23 10:19:44:337][22065][A]:(00000032): MediaPlayerImpl::getMediaPlayerId(this:0x71534f0ed0, {})
[08/24/23 10:19:44:337][22065][A]:(00000033):   MediaPlayerSourceFFMpeg::getSourceId(this:0x7113499790, void)
[08/24/23 10:19:44:337][11585][A]:(00000034):         MediaPlayerImpl::getMediaPlayerId(this:0x71534f0ed0, {})
[08/24/23 10:19:44:337][22065][A]:(00000035): MediaPlayerSourceFFMpeg::getSourceId(this:0x7113499790, void)
[08/24/23 10:19:44:337][11585][A]:(00000036):         MediaPlayerImpl::registerPlayerSourceObserver(this:0x71534f0ed0, {"observer":"0x71438643d0"})
[08/24/23 10:19:44:338][11585][A]:(00000037):         RhythmPlayerImpl::RhythmPlayerImpl(this:0x71334f9ed0, void)
[08/24/23 10:19:44:338][22065][A]:(00000038): AgoraService::createRtcConnectionEx(this:0x7133500890, cfg:(autoSubscribeAudio:1, autoSubscribeVideo:1, enableAudioRecordingOrPlayout:1maxSendBitrate:-1, minPort:0, maxPort:0,  clientRoleType:2, clientType:0, vosList.size:0), connId:0)
[08/24/23 10:19:44:338][22065][A]:(00000039):   RtcConnectionImpl::initializeEx(this:0x71735676f0, serviceCfg:(enableAudioProcessor:1, enableAudioDevice:1, enableVideo:1, context:0x344a), cfg:(autoSubscribeAudio:1, autoSubscribeVideo:1, enableAudioRecordingOrPlayout:1, maxSendBitrate:-1, minPort:0, maxPort:0, clientRoleType:2, clientType:0, channelProfile:1, vosList.size:0, recvType:(audio: 0, video: 0)))
[08/24/23 10:19:44:344][22065][A]:(00000040):     RtcConnectionImpl::getUserRole(this:0x71735676f0, void)
[08/24/23 10:19:44:347][22065][A]:(00000041):     RtcConnectionImpl::subscribeReceivePacketHandler(this:0x71735676f0, void)
[08/24/23 10:19:44:381][22065][A]:(00000042): RtcConnectionImpl::registerObserver(this:0x71735676f0, observer:0x7183784c70)
[08/24/23 10:19:44:381][22065][A]:(00000043): RtcConnectionImpl::registerNetworkObserver(this:0x71735676f0, observer:0x7183784c78)
[08/24/23 10:19:44:381][22065][A]:(00000044): LocalUserImpl::registerLocalUserObserver(this:0x7193508e30, observer:0x7183784c80)
[08/24/23 10:19:44:385][11585][A]:(00000045):         AgoraService::createAudioDeviceManager(this:0x7133500890, void)
[08/24/23 10:19:44:385][11585][A]:(00000046):         AudioDeviceManagerImpl::registerObserver(this:0x70d3519370, observer:0x70f386af70)
[08/24/23 10:19:44:385][11585][A]:(00000047):       RtcEngine::queryInterface(this:0x718378a700, {"iid":3, "inter":"0x7ff9f602c8"})
[08/24/23 10:19:44:385][11585][A]:(00000048):       RtcEngine::setParametersInternal(this:0x718378a700, {"parameters":{"rtc.channel_profile":1}})
[08/24/23 10:19:44:386][22065][A]:(00000049): LocalUserImpl::setAudioScenario(this:0x7193508e30, config:(scenario:0))
[08/24/23 10:19:44:391][11585][A]:(00000050):     RtcEngine::enableLocalAudio(this:0x718378a700, {"enabled":1})
[08/24/23 10:19:44:391][11585][A]:(00000051):       RtcEngine::enableLocalAudioInternal(this:0x718378a700, enabled:1)
[08/24/23 10:19:44:391][11585][A]:(00000052):         RtcEngine::queryInterface(this:0x718378a700, {"iid":3, "inter":"0x7ff9f60228"})
[08/24/23 10:19:44:392][11585][A]:(00000053):         RtcEngine::setParametersInternal(this:0x718378a700, {"parameters":{"che.audio.record":true}})
[08/24/23 10:19:44:392][11585][A]:(00000054):     RtcEngine::enableLocalVideo(this:0x718378a700, {"enabled":0})
[08/24/23 10:19:44:392][11585][A]:(00000055):       RtcEngine::enableLocalVideoInternal(this:0x718378a700, enabled:0)
[08/24/23 10:19:44:392][11585][U]:(00000056): RtcEngine::queryInterface(this:0x718378a700, {"iid":4, "inter":"0x7ff9f60510"})
[08/24/23 10:19:44:393][11585][U]:(00000057): RtcEngine::setParameters(this:0x718378a700, {"parameters":{"rtc.api.set_uid_compatible_mode":true}})
[08/24/23 10:19:44:393][11585][A]:(00000058):   RtcEngine::setParametersInternal(this:0x718378a700, {"parameters":{"rtc.api.set_uid_compatible_mode":true}})
[08/24/23 10:19:44:394][11585][U]:(00000059): RtcEngine::setDefaultAudioRouteToSpeakerphone(this:0x718378a700, {"defaultToSpeaker":1})
[08/24/23 10:19:44:394][11585][A]:(00000060):   AgoraService::createAudioDeviceManager(this:0x7133500890, void)
[08/24/23 10:19:44:394][11585][A]:(00000061):   AudioDeviceManagerImpl::setDefaultAudioRouting(this:0x70d3519370, route:3)
[08/24/23 10:19:44:394][11585][U]:(00000062): RtcEngine::setAudioProfile(this:0x718378a700, {"profile":4})
[08/24/23 10:19:44:394][22065][A]:(00000063): LocalUserImpl::setAudioEncoderConfiguration(this:0x7193508e30, config:(audioProfile:4))
[08/24/23 10:19:44:394][11585][A]:(00000064):   RtcEngine::setParametersInternal(this:0x718378a700, {"parameters":{"che.audio.profile":{"config":4}}})
[08/24/23 10:19:44:394][11585][U]:(00000065): RtcEngine::setAudioScenario(this:0x718378a700, {"scenario":3})
[08/24/23 10:19:44:394][22065][A]:(00000066): AgoraService::setAudioSessionPreset(this:0x7133500890, scenario:3)
[08/24/23 10:19:44:394][22065][E]:[CONN-0][CALLCTX]: set audio scenario type: new type(3) does not equal to previous type(0)...
[08/24/23 10:19:44:394][22065][A]:(00000067): LocalUserImpl::setAudioScenario(this:0x7193508e30, config:(scenario:3))
[08/24/23 10:19:44:396][11585][U]:(00000068): RtcEngine::setClientRole(this:0x718378a700, {"role":1, "options":{"audienceLatencyLevel":2}})
[08/24/23 10:19:44:396][11585][A]:(00000069):   RtcEngine::setClientRoleInternal(this:0x718378a700, {"role":1, "options":{"audienceLatencyLevel":2}})
[08/24/23 10:19:44:397][11585][U]:(00000070): RtcEngine::setParameters(this:0x718378a700, {"parameters":{"che.audio.opensl":true}})
[08/24/23 10:19:44:397][11585][A]:(00000071):   RtcEngine::setParametersInternal(this:0x718378a700, {"parameters":{"che.audio.opensl":true}})
[08/24/23 10:19:44:397][11585][U]:(00000072): RtcEngine::joinChannel(this:0x718378a700, {"token":"0****k", "channelId":"e0d25eda-9683-52e1-8a93-081f9316df16", "uid":248, "options":{...}})
[08/24/23 10:19:44:397][11585][A]:(00000073):   RtcEngine::doJoinChannel(this:0x718378a700, token:"0****k", channelId:"e0d25eda-9683-52e1-8a93-081f9316df16", localUid:"248", userId:"", options:["publishMicrophone":empty, "publishCustomAudio":empty, "publishCustomAudioTrackId":empty, "publishMediaPlayerAudio":empty, "publishCamera":empty, "publishSecondaryCameraTrack":empty, "publishScreenCaptureVideo":empty, "publishScreenCaptureAudio":empty, "publishCustomVideo":empty, "publishEncodedVideo":empty, "publishTranscodedVideoTrack":empty, "publishMediaPlayerVideo":empty, "publishMediaPlayerId":empty, "publishRhythmPlayerTrack":empty, "isAudioFilterable":empty, "autoSubscribeAudio":1, "autoSubscribeVideo":empty, "enableAudioRecordingOrPlayout":empty, "clientRoleType":1, "audienceLatencyLevel":empty, "defaultVideoStreamType":empty, "channelProfile":1, "audioDelayMs":empty, "enableBuiltInMediaEncryption":empty, "mediaPlayerAudioDelayMs":empty, "customVideoTrackId":empty, "isInteractiveAudience":empty])
[08/24/23 10:19:44:397][11585][A]:(00000074):     RtcEngine::getVersion(this:0x718378a700, void)
[08/24/23 10:19:44:403][22065][A]:(00000075): AudioDeviceEventManager::CallbackOnRoutingChanged->CallbackOnRoutingChanged(this:0x70c35066f0, route: 3)
[08/24/23 10:19:44:403][22065][A]:(00000076):   ModuleEventHandler::CallbackOnRoutingChanged(this:0x70b355f4e8, [USB] route:3)
[08/24/23 10:19:44:404][22067][A]:(00000077): RtcEngineEventHandlerCallback::onRoutingChanged->onAudioRoutingChanged(this:0x70f386af68, route:3)
[08/24/23 10:19:44:405][22065][A]:(00000078): LocalUserImpl::setAudioEncoderConfiguration(this:0x7193508e30, config:(audioProfile:4))
[08/24/23 10:19:44:405][22065][A]:(00000079): LocalUserImpl::setAudioScenario(this:0x7193508e30, config:(scenario:3))
[08/24/23 10:19:44:405][22065][A]:(00000080): LocalUserImpl::subscribeAllAudio(this:0x7193508e30, void)
[08/24/23 10:19:44:405][22065][A]:(00000081): LocalUserImpl::unsubscribeAllVideo(this:0x7193508e30, void)
[08/24/23 10:19:44:405][22065][A]:(00000082): LocalUserImpl::setUserRole(this:0x7193508e30, role:1)
[08/24/23 10:19:44:405][22065][A]:(00000083):   RtcConnectionImpl::setUserRole(this:0x71735676f0, role:1)
[08/24/23 10:19:44:406][22065][A]:(00000084):     LegacyEventProxy::onClientRoleChanged->onChangeRoleSuccess(this:0x70a354fa50, oldRole:2, newRole:1, newRoleLatencyLevel:2)
[08/24/23 10:19:44:406][22065][A]:(00000085): LocalUserImpl::setAudienceLatencyLevel(this:0x7193508e30, audience latency level:2)
[08/24/23 10:19:44:406][22065][A]:(00000086): AgoraService::createLocalAudioTrack(this:0x7133500890, void)
[08/24/23 10:19:44:425][22065][A]:(00000087): LocalAudioTrackRecorderImpl::registerTrackObserver(this:0x71534fd2d0, observer:0x70f386af80)
[08/24/23 10:19:44:425][22065][A]:(00000088): LocalAudioTrackRecorderImpl::registerTrackObserver(this:0x71534fd2d0, observer:0x7183784c88)
[08/24/23 10:19:44:425][22065][A]:(00000089): LocalUserImpl::publishAudio(this:0x7193508e30, audioTrack:0x71534fd2d0)
[08/24/23 10:19:44:429][22065][A]:(00000090):   LocalAudioTrackImpl::attach(this:0x71534fd2d0, sourceId: 3147431818)
[08/24/23 10:19:44:429][22065][A]:(00000091): RtcConnectionImpl::connect(this:0x71735676f0, token:"0****k", channelId:"e0d25eda-9683-52e1-8a93-081f9316df16", userId:"248")
[08/24/23 10:19:44:436][22065][A]:(00000092): LocalAudioTrackRecorderImpl::setEnabled(this:0x71534fd2d0, enable:1)
[08/24/23 10:19:44:437][22065][A]:(00000093):   LocalAudioTrackImpl::setEnabled(this:0x71534fd2d0, enable: 1)
[08/24/23 10:19:44:447][22065][A]:(00000094): LocalAudioTrackRecorderImpl::enableEarMonitor(this:0x71534fd2d0, enable: 0, includeAudioFilters: 2)
[08/24/23 10:19:44:447][22065][A]:(00000095): LocalAudioTrackRecorderImpl::enableEarMonitor(this:0x71534fd2d0, enable: 0, includeAudioFilters: 2)
[08/24/23 10:19:44:447][22065][A]:(00000096): RtcConnectionImpl::stopLastmileProbeTest(this:0x71735676f0, void)
[08/24/23 10:19:44:448][22067][A]:(00000097): ChannelProxy::onChangeRoleSuccess->onClientRoleChanged(this:0x7183784c70, oldRole:2, newRole:1, newRoleLatencyLevel:2)
[08/24/23 10:19:44:448][22067][A]:(00000098): ChannelProxy::onAudioPublishStateChanged->onAudioPublishStateChanged(this:0x7183784c70, channel:e0d25eda-9683-52e1-8a93-081f9316df16, oldState:0, newState:2, elapseSinceLastState:47)
[08/24/23 10:19:44:449][22065][A]:(00000099): RtcConnectionImpl::setConnectionState(this:0x71735676f0, state: 2)
[08/24/23 10:19:44:449][22065][A]:(00000100): LegacyEventProxy::onConnectionStateChanged->onConnecting(this:0x70a354fa50, channel:"e0d25eda-9683-52e1-8a93-081f9316df16", userId:"248", reason:0)
[08/24/23 10:19:44:449][22067][A]:(00000101): ChannelProxy::emitConnStateChanged->onConnectionStateChanged(this:0x7183784c70, state:2, reason:0)
[08/24/23 10:19:44:451][11585][U]:(00000102): RtcEngine::enableAudio(this:0x718378a700, {})
[08/24/23 10:19:44:451][11585][A]:(00000103):   RtcEngine::enableAudioPlayoutInternal(this:0x718378a700, enabled:1)
[08/24/23 10:19:44:459][11585][A]:(00000104):   RtcEngine::enableLocalAudio(this:0x718378a700, {"enabled":1})
[08/24/23 10:19:44:460][11585][A]:(00000105):     RtcEngine::enableLocalAudioInternal(this:0x718378a700, enabled:1)
[08/24/23 10:19:44:460][22065][A]:(00000106): LocalAudioTrackMediaPlayerImpl::setLocalPlaybackExtraDelay(this:0x71438ae670, delayMs:0)
[08/24/23 10:19:44:460][22065][A]:(00000107): LocalUserImpl::setAudienceLatencyLevel(this:0x7193508e30, audience latency level:2)
[08/24/23 10:19:44:460][11585][A]:(00000108):       RtcEngine::queryInterface(this:0x718378a700, {"iid":3, "inter":"0x7ff9f60858"})
[08/24/23 10:19:44:460][11585][A]:(00000109):       RtcEngine::setParametersInternal(this:0x718378a700, {"parameters":{"che.audio.record":true}})
[08/24/23 10:19:44:460][22065][A]:(00000110): LocalUserImpl::subscribeAllAudio(this:0x7193508e30, void)
[08/24/23 10:19:44:460][22065][A]:(00000111): LocalUserImpl::setAudienceLatencyLevel(this:0x7193508e30, audience latency level:2)
[08/24/23 10:19:44:461][11585][A]:(00000112):   RtcEngine::queryInterface(this:0x718378a700, {"iid":3, "inter":"0x7ff9f609c8"})
[08/24/23 10:19:44:461][11585][A]:(00000113):   RtcEngine::setParametersInternal(this:0x718378a700, {"parameters":{"che.audio.enabled":true}})
[08/24/23 10:19:44:472][22065][A]:(00000114): RtcEngine::setParametersByTds(this:0x7133500ad0, {"parameters":{"che.audio.adm_android_mode":5,"che.audio.opensl":false}})
[08/24/23 10:19:44:472][22065][A]:(00000115): RtcEngine::setParametersByTds(this:0x7133500ad0, {"parameters":{"rtc.enable_xdump":true,"rtc.enable_xdump_file":true,"rtc.enable_xdump_upload":true}})
[08/24/23 10:19:44:516][22193][E]:WebRtcAudioTrack [JavaAdm]: audioTimestamp is unavailable
[08/24/23 10:19:44:534][22065][A]:(00000116): RtcConnectionImpl::setConnectionState(this:0x71735676f0, state: 3)
[08/24/23 10:19:44:534][22065][A]:(00000117): LegacyEventProxy::onJoinChannelSuccess->onConnected(this:0x70a354fa50, channel:"e0d25eda-9683-52e1-8a93-081f9316df16", uid:"248", elapsed:137)
[08/24/23 10:19:44:534][22065][A]:(00000118):   RtcConnectionImpl::getUserInfoByUid(this:0x71735676f0, uid:248)
[08/24/23 10:19:44:534][22065][A]:(00000119):   RtcConnectionImpl::setLocalUserId(this:0x71735676f0, userId:"248")
[08/24/23 10:19:44:534][22067][A]:(00000120): ChannelProxy::onConnected->onJoinChannelSuccess(this:0x7183784c70, channel:"e0d25eda-9683-52e1-8a93-081f9316df16", uid:"248", elapsed:137, reason:1)
[08/24/23 10:19:44:534][22067][A]:(00000121):   ChannelProxy::emitConnStateChanged->onConnectionStateChanged(this:0x7183784c70, state:3, reason:1)
[08/24/23 10:19:44:534][22067][A]:(00000122): ChannelProxy::onVideoPublishStateChanged->onVideoPublishStateChanged(this:0x7183784c70, channel:e0d25eda-9683-52e1-8a93-081f9316df16, oldState:0, newState:1, elapseSinceLastState:153)
[08/24/23 10:19:44:535][22065][A]:(00000123): LocalAudioTrackRecorderImpl::setEnabled(this:0x71534fd2d0, enable:1)
[08/24/23 10:19:44:643][22065][A]:(00000124): AudioDeviceEventManager::CallbackOnDeviceStateChanged->CallbackOnDeviceStateChanged(this:0x70c35066f0, deviceType:"1", deviceState:"1", reason:0)
[08/24/23 10:19:44:643][22067][A]:(00000125): ChannelProxy::onLocalAudioTrackStateChanged->onLocalAudioTrackStateChanged(this:0x7183784c70, state:1 errorCode:0)
[08/24/23 10:19:44:643][22067][A]:(00000126): RtcEngineEventHandlerCallback::onLocalAudioTrackStateChanged->onLocalAudioTrackStateChanged(this:0x70f386af68, state:1 errorCode:0)
[08/24/23 10:19:44:708][22065][A]:(00000127): LocalAudioTrackRecorderImpl::getState(this:0x71534fd2d0, void)
[08/24/23 10:19:44:709][22065][A]:(00000128): LocalAudioTrackRecorderImpl::getState(this:0x71534fd2d0, void)
[08/24/23 10:19:44:709][22067][A]:(00000129): ChannelProxy::onLocalAudioTrackStateChanged->onLocalAudioTrackStateChanged(this:0x7183784c70, state:2 errorCode:0)
[08/24/23 10:19:44:709][22067][A]:(00000130): RtcEngineEventHandlerCallback::onLocalAudioTrackStateChanged->onLocalAudioTrackStateChanged(this:0x70f386af68, state:2 errorCode:0)
[08/24/23 10:19:44:709][22067][A]:(00000131): ChannelProxy::onAudioPublishStateChanged->onAudioPublishStateChanged(this:0x7183784c70, channel:e0d25eda-9683-52e1-8a93-081f9316df16, oldState:2, newState:3, elapseSinceLastState:281)
[08/24/23 10:19:44:710][22067][A]:(00000132): ChannelProxy::onAudioTrackPublishSuccess->onFirstLocalAudioFramePublished(this:0x7183784c70, elapsed:312)
[08/24/23 10:19:48:348][22065][E]:[ADGM-UP](0x70d35b5730): state 50, category 53, reason -1 due to invalid send bitrate 0, audio send stream size 1

My Foreground service:

package com.quicktakes;

import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;

import static io.agora.rtc2.Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY;
import static io.agora.rtc2.Constants.AUDIO_SCENARIO_GAME_STREAMING;
import static io.agora.rtc2.Constants.AudioProfile.MUSIC_HIGH_QUALITY;
import static io.agora.rtc2.Constants.CHANNEL_PROFILE_LIVE_BROADCASTING;
import static io.agora.rtc2.Constants.CLIENT_ROLE_BROADCASTER;
import static io.agora.rtc2.Constants.LOG_FILTER_DEBUG;
import static io.agora.rtc2.Constants.LOG_FILTER_INFO;
import static io.agora.rtc2.RtcEngineConfig.AreaCode.AREA_CODE_GLOB;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.media.MediaRecorder;
import android.os.Build;
import android.os.IBinder;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;

import com.edkey.quicktakes.MainActivity;
import com.edkey.quicktakes.R;
import com.quicktakes.network.ApiError;
import com.quicktakes.network.NetworkManager;
import com.quicktakes.network.Repository;
import com.quicktakes.network.model.PreSignedUrlModel;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

import io.agora.rtc2.ChannelMediaOptions;
import io.agora.rtc2.IRtcEngineEventHandler;
import io.agora.rtc2.RtcEngine;
import io.agora.rtc2.RtcEngineConfig;

import static io.agora.rtc2.Constants.CONNECTION_STATE_RECONNECTING;
import static io.agora.rtc2.Constants.CONNECTION_STATE_CONNECTED;
import static io.agora.rtc2.Constants.CONNECTION_STATE_FAILED;
import okhttp3.ResponseBody;

/**
 * ForegroundService to start a service which will record the audio for the 40 minutes max.
 * Same service is used to upload the recorded file to s3.
 * 4 actions are supported by the service: START, PAUSE, RESUME, STOP
 */
public class ForegroundService extends Service {

    public static final String CHANNEL_ID = "ForegroundServiceChannel";
    private static String mFileName = null;
    private MediaRecorder mRecorder;
    private Timer timer;

    //timeRemaining is used to track the time updates happening because of TimerTask.
    //initial value is MAX_RECORD_TIME with additional 1 second delay. because on RN side recording start
    //little late.
    private long timeRemaining = initialTime();

    private long initialTime() {
        return Constants.MAX_RECORD_TIME + Constants.SEC_UNIT;
    }

    private NetworkManager networkManager;

    private RtcEngine agoraEngine;
    @Override
    public void onCreate() {
        super.onCreate();
        networkManager = new NetworkManager(getApplicationContext());
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        Log.d("Eric", "ForegroundService onStartCommand");
        Log.d("Eric", "ForegroundService onStartCommand intent.getAction() :: " + intent.getAction());
        switch (intent.getAction()) {
            case Constants.ACTION_START:
                Log.d("Eric", "ForegroundService onStartCommand run here 1");
                createNotificationChannel();
                Intent notificationIntent = new Intent(this, MainActivity.class);
                PendingIntent pendingIntent = PendingIntent.getActivity(this,
                        0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
                Notification notification = createNotification(pendingIntent);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                    startForeground(1, notification, FOREGROUND_SERVICE_TYPE_MICROPHONE);
                } else {
                    startForeground(1, notification);
                }
//                startRecording();
                String token = SharedPrefManager.getAgoraToken();
                String uuid = SharedPrefManager.getAgoraDocumentId();
                int userId = SharedPrefManager.getAgoraUserId();
                startRecordingAgora(token, uuid, userId);
                timeRemaining = initialTime();
                startTimer();
                break;
            case Constants.ACTION_PAUSE:
                pauseRecording();
                break;
            case Constants.ACTION_RESUME:
                resumeRecording();
                break;
            case Constants.ACTION_STOP_MANUAL:
                stopRecording();
                break;
            default:
                Log.d("Vishal", "invalid acton" + intent.getAction());
        }

        return START_NOT_STICKY;
    }

    private Notification createNotification(PendingIntent pendingIntent) {
        return new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentTitle("Foreground Service")
                .setContentText("Start Recording")
                .setSmallIcon(R.drawable.ic_arrow_back_white)
                .setContentIntent(pendingIntent)
                .setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE)
                .build();
    }

    /**
     * creates the Timer and TimerTask if "START" or "RESUME" action is triggered.
     */
    private void startTimer() {
        Log.d("Vishal", "Timer started with remaining time" + timeRemaining);
        timer = new Timer();
        timer.scheduleAtFixedRate(createTimer(), 0, Constants.SEC_UNIT);
    }

    /**
     * Cancels the timer if the PAUSE or STOP action triggered.
     * It also cancels the timer if it reaches the maximum time defined (40 minutes).
     */
    private void stopTimer() {
        Log.d("Vishal", "Timer canceled/stopped. is timer null: " + (timer == null));
        if (timer != null) {
            timer.cancel();
        }
    }

    /**
     * Creates a TimerTask with given instructions. it executes run() as soon an parameters in Timer are satisfied.
     * START and RESUME creates TimerTask. START creates a TimerTask with 40 minutes (MAX defined time.)
     * RESUME creates a TimerTask depending upon the value of timeRemaining.
     *
     * @return TimerTask created.
     */
    private TimerTask createTimer() {
        return new TimerTask() {
            @Override
            public void run() {
                timeRemaining -= Constants.SEC_UNIT;
                Log.d("Vishal", "timeRemaining: " + timeRemaining);
                if (timeRemaining <= 0) {
                    Log.d("Vishal", "reached max time");
                    stopRecordingWithoutAPICall(true);
                }
            }
        };
    }

    /**
     * as soon as PAUSE action received. this method pauses the recording and cancels the current timer.
     */
    private void pauseRecording() {
        try {
//            mRecorder.pause();
            agoraEngine.muteLocalAudioStream(true);
            stopTimer();
        } catch (IllegalStateException exception) {
            Log.e("Vishal", "IllegalState: pauseRecording", exception);
        } catch (Exception exception) {
            Log.e("Vishal", "Exception: pauseRecording", exception);
        }
    }

    /**
     * If RESUME action is received, it will resume the previously paused recording and
     * it will start a new timer with the updated timeRemaining value.
     */
    private void resumeRecording() {
        try {
//            mRecorder.resume();
            agoraEngine.muteLocalAudioStream(false);
            startTimer();
        } catch (IllegalStateException exception) {
            Log.e("Vishal", "IllegalState: resumeRecording", exception);
        } catch (Exception exception) {
            Log.e("Vishal", "Exception: resumeRecording", exception);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
//        timer not required if service destroyed.
        if (timer != null) {
            timer.cancel();
        }
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    private void createNotificationChannel() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel serviceChannel = new NotificationChannel(
                    CHANNEL_ID,
                    "Foreground Service Channel",
                    NotificationManager.IMPORTANCE_DEFAULT
            );
            NotificationManager manager = getSystemService(NotificationManager.class);
            manager.createNotificationChannel(serviceChannel);
        }
    }

    public void startRecording() {
        try {
            mFileName = getFilesDir().getAbsolutePath();
            mFileName += "/AudioRecording.m4a";
            Log.d("Eric", "startRecording mFileName:: " + mFileName);
            //below method is used to initialize the media recorder clss
            mRecorder = new MediaRecorder();
            //below method is used to set the audio source which we are using a mic.
            mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            //below method is used to set the output format of the audio.
            mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            //below method is used to set the audio encoder for our recorded audio.
            mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

            mRecorder.setAudioChannels(1);
            mRecorder.setAudioSamplingRate(44100);
            mRecorder.setAudioEncodingBitRate(96000);

            //below method is used to set the output file location for our recorded audio
            mRecorder.setOutputFile(mFileName);
            //below mwthod will prepare our audio recorder class
            mRecorder.prepare();
            mRecorder.start();
            Log.e("Eric", "startRecording() started..");
        } catch (IOException e) {
            Log.e("Eric", "prepare() failed");
            Log.e("Eric", "prepare() failed" + e);
        }
        // start method will start the audio recording.

    }

    public void stopRecording() {
        stopTimer();
//        if (mRecorder == null) return;
//        mRecorder.stop();
//        //below method will release the media recorder class.
//        mRecorder.release();
//        mRecorder = null;
        Log.e("Eric", "stopRecording() started..");

//        uploadAudio();
        if (agoraEngine != null) {
            int leaveChannelInt = agoraEngine.leaveChannel();
            Log.d("Eric", "leaveChannelInt :: " + leaveChannelInt);
            new Thread(() -> {
                RtcEngine.destroy();
                agoraEngine = null;
            }).start();
        }
        updateAgoraFileStatusAPICall();
        // call api

    }

    private void updateAgoraFileStatusAPICall() {/* API call to our server*/}

    private void uploadAudio() {}

    private void sendError(ApiError error) {}

    private void stopService() {
        stopForeground(true);
        stopSelf();
        AudioRecordingModule.sendEvent("showLoading", false);
    }

    private void startRecordingAgora(String token, String channelName, int uid) {
        setupVoiceSDKEngine();
        joinChannel(token, channelName, uid);
    }
    //todo
    private void joinChannel(String token, String channelName, int uid) {
        ChannelMediaOptions options = new ChannelMediaOptions();
        options.autoSubscribeAudio = true;
        // Set both clients as the BROADCASTER.
        options.clientRoleType = CLIENT_ROLE_BROADCASTER;
        // Set the channel profile as BROADCASTING.
        options.channelProfile = CHANNEL_PROFILE_LIVE_BROADCASTING;

        // Join the channel with a temp token.
        // You need to specify the user ID yourself, and ensure that it is unique in the channel.
        agoraEngine.setDefaultAudioRoutetoSpeakerphone(true);
//        agoraEngine.setAudioProfile(AUDIO_PROFILE_MUSIC_HIGH_QUALITY);
//        agoraEngine.setAudioScenario(AUDIO_SCENARIO_GAME_STREAMING);
        agoraEngine.setClientRole(CLIENT_ROLE_BROADCASTER);
        agoraEngine.setParameters("{\"che.audio.opensl\":true}");

        int joinChannelResult = agoraEngine.joinChannel(token, channelName, uid, options);
        agoraEngine.enableAudio();
        Log.d("Eric", "joinChannel :: " + joinChannelResult);
    }
    private void setupVoiceSDKEngine() {
        try {

            // Java
            RtcEngineConfig.LogConfig logConfig = new RtcEngineConfig.LogConfig();
// Set the log filter to ERROR
            logConfig.level = io.agora.rtc2.Constants.LogLevel.getValue(io.agora.rtc2.Constants.LogLevel.LOG_LEVEL_ERROR);
// Set the log file path
            String ts = new SimpleDateFormat("yyyyMMdd").format(new Date());
            logConfig.filePath = getFilesDir().getAbsolutePath() + "/" + ts + ".log";
// Set the log file size to 2 MB
            logConfig.fileSizeInKB = 2048;

            RtcEngineConfig config = new RtcEngineConfig();
            config.mContext = getApplicationContext();
            config.mAppId = "*****************";//not the actual mAppId
            config.mEventHandler = mRtcEventHandler;
            config.mChannelProfile = CHANNEL_PROFILE_LIVE_BROADCASTING;
            config.mAreaCode = AREA_CODE_GLOB;
            config.mLogConfig = logConfig;
            agoraEngine = RtcEngine.create(config);
        } catch (Exception e) {
            throw new RuntimeException("Check the error.");
        }
    }
    private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {
        @Override
        // Listen for the remote user joining the channel.
        public void onUserJoined(int uid, int elapsed) {
        }

        @Override
        public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
            // Successfully joined a channel
            Log.d("eric", "onJoinChannelSuccess :: " + channel);
        }

        @Override
        public void onUserOffline(int uid, int reason) {
            // Listen for remote users leaving the channel
        }

        @Override
        public void onLeaveChannel(RtcStats     stats) {
            // Listen for the local user leaving the channel
        }

        @Override
        public void onConnectionStateChanged(int state, int reason) {
            Log.d("eric", "onConnectionStateChanged" + state);
            Log.d("eric", "onConnectionStateChanged" + reason);
            if( state == CONNECTION_STATE_RECONNECTING) {
                AudioRecordingModule.sendEvent("handleAgoraDisconnected", "");
            } else if (state == CONNECTION_STATE_CONNECTED || state == CONNECTION_STATE_FAILED) {
                AudioRecordingModule.sendEvent("handleAgoraReconnected", "");
            }
        }
    };

    /**
     * When the app is killed by the user or the system, This function will be called.
     *
     * @param rootIntent The original root Intent that was used to launch
     *                   the task that is being removed.
     */
    @Override
    public void onTaskRemoved(Intent rootIntent) {
        super.onTaskRemoved(rootIntent);
        stopRecording();
    }
}
LichKing-2234 commented 1 year ago

Seems like you are using the Android SDK, not the react-native SDK. You can ask for tech support.

vishaledkey commented 1 year ago

Hi @LichKing-2234, I'm actually new to React-Native but I have added the Agora library to my react-native project and I'm using the generated native classes from it. My package.json

    "react-native": "0.71.6",
    "react-native-agora": "^4.2.1",

There's no mention of agora in my build.gradle file. Also, in the below screenshot, you'll find the same generated library I'm referring to.

image