Beispiel #1
0
        public static AudioEffectManagerImpl GetInstance(IRtcEngine rtcEngine)
        {
            if (_audioEffectManagerImplInstance == null)
            {
                _audioEffectManagerImplInstance = new AudioEffectManagerImpl(rtcEngine);
            }

            return(_audioEffectManagerImplInstance);
        }
Beispiel #2
0
 public static void ReleaseInstance()
 {
     _audioEffectManagerImplInstance = null;
 }
    // Use this for initialization
    void Start()
    {
        if (!mInitialized)
        {
            mInitialized = true;
            isRecord     = false;

            mRtcEngine = IRtcEngine.GetEngine(appId);

            mRtcEngine.OnJoinChannelSuccess += (string channelName, uint uid, int elapsed) => {
                string joinSuccessMessage = string.Format("joinChannel callback uid: {0}, channel: {1}, version: {2}", uid, channelName, IRtcEngine.GetSdkVersion());
                Debug.Log(joinSuccessMessage);

                mShownMessage.GetComponent <Text> ().text = (joinSuccessMessage);
            };

            mRtcEngine.OnLeaveChannel += (RtcStats stats) => {
                string leaveChannelMessage = string.Format("onLeaveChannel callback duration {0}, tx: {1}, rx: {2}, tx kbps: {3}, rx kbps: {4}", stats.duration, stats.txBytes, stats.rxBytes, stats.txKBitRate, stats.rxKBitRate);
                Debug.Log(leaveChannelMessage);
                mShownMessage.GetComponent <Text> ().text = (leaveChannelMessage);
            };

            mRtcEngine.OnUserJoined += (uint uid, int elapsed) => {
                string userJoinedMessage = string.Format("onUserJoined callback uid {0} {1}", uid, elapsed);
                //int a = mRtcEngine.SetRemoteVoicePosition (uid, -1 ,50.0);
                //Debug.Log ("OnUserJoined  setRemoteVoicePosition a = "+ a);
                AudioEffectManagerImpl audio = new AudioEffectManagerImpl(mRtcEngine);
                int a = audio.SetRemoteVoicePosition(uid, -1, 0);
                Debug.Log("OnUserJoined  setRemoteVoicePosition = " + a);
                Debug.Log(userJoinedMessage);
            };

            mRtcEngine.OnUserOffline += (uint uid, USER_OFFLINE_REASON reason) => {
                string userOfflineMessage = string.Format("onUserOffline callback uid {0} {1}", uid, reason);
                Debug.Log(userOfflineMessage);
            };

            mRtcEngine.OnVolumeIndication += (AudioVolumeInfo[] speakers, int speakerNumber, int totalVolume) => {
                if (speakerNumber == 0 || speakers == null)
                {
                    Debug.Log(string.Format("onVolumeIndication only local {0}", totalVolume));
                }

                for (int idx = 0; idx < speakerNumber; idx++)
                {
                    string volumeIndicationMessage = string.Format("{0} onVolumeIndication {1} {2}", speakerNumber, speakers [idx].uid, speakers [idx].volume);
                    Debug.Log(volumeIndicationMessage);
                }
            };

            mRtcEngine.OnUserMuted += (uint uid, bool muted) => {
                string userMutedMessage = string.Format("onUserMuted callback uid {0} {1}", uid, muted);
                Debug.Log(userMutedMessage);
            };

            mRtcEngine.OnWarning += (int warn, string msg) => {
                string description    = IRtcEngine.GetErrorDescription(warn);
                string warningMessage = string.Format("onWarning callback {0} {1} {2}", warn, msg, description);
                Debug.Log(warningMessage);
            };

            mRtcEngine.OnError += (int error, string msg) => {
                string description  = IRtcEngine.GetErrorDescription(error);
                string errorMessage = string.Format("onError callback {0} {1} {2}", error, msg, description);
                Debug.Log(errorMessage);
            };

            mRtcEngine.OnRtcStats += (RtcStats stats) => {
                string rtcStatsMessage = string.Format("onRtcStats callback duration {0}, tx: {1}, rx: {2}, tx kbps: {3}, rx kbps: {4}, tx(a) kbps: {5}, rx(a) kbps: {6} users {7}",
                                                       stats.duration, stats.txBytes, stats.rxBytes, stats.txKBitRate, stats.rxKBitRate, stats.txAudioKBitRate, stats.rxAudioKBitRate, stats.users);
                Debug.Log(rtcStatsMessage);

                int lengthOfMixingFile = mRtcEngine.GetAudioMixingDuration();
                int currentTs          = mRtcEngine.GetAudioMixingCurrentPosition();

                string mixingMessage = string.Format("Mixing File Meta {0}, {1}", lengthOfMixingFile, currentTs);
                Debug.Log(mixingMessage);
            };

            mRtcEngine.OnAudioRouteChanged += (AUDIO_ROUTE route) => {
                string routeMessage = string.Format("onAudioRouteChanged {0}", route);
                Debug.Log(routeMessage);
            };

            mRtcEngine.OnRequestChannelKey += () => {
                string requestKeyMessage = string.Format("OnRequestChannelKey");
                Debug.Log(requestKeyMessage);
            };

            mRtcEngine.OnConnectionInterrupted += () => {
                string interruptedMessage = string.Format("OnConnectionInterrupted");
                Debug.Log(interruptedMessage);
            };

            mRtcEngine.OnConnectionLost += () => {
                string lostMessage = string.Format("OnConnectionLost");
                Debug.Log(lostMessage);
            };

            mRtcEngine.SetLogFilter(LOG_FILTER.INFO);

            // mRtcEngine.setLogFile("path_to_file_unity.log");

            mRtcEngine.SetChannelProfile(CHANNEL_PROFILE.GAME_FREE_MODE);
            mRtcEngine.EnableAudio();

            // mRtcEngine.SetChannelProfile (CHANNEL_PROFILE.GAME_COMMAND_MODE);
            // mRtcEngine.SetClientRole (CLIENT_ROLE.BROADCASTER);
        }
    }