Example #1
0
 public WebRTCDemo()
 {
     startOrStopCallback = new RunnableAnonymousInnerClassHelper(this);
     viEAndroidJavaAPI   = new ViEAndroidJavaAPI(Application.Context);
 }
Example #2
0
        private void startMain()
        {
            mTabHost.CurrentTab = 0;

            mLlRemoteSurface = (LinearLayout)FindViewById(Resource.Id.llRemoteView);
            mLlLocalSurface  = (LinearLayout)FindViewById(Resource.Id.llLocalView);

            if (null == vieAndroidAPI)
            {
                vieAndroidAPI = new ViEAndroidJavaAPI(this);
            }
            if (0 > setupVoE() || 0 > viEAndroidJavaAPI.VideoEngine || 0 > viEAndroidJavaAPI.Init(enableTrace))
            {
                // Show dialog
                AlertDialog alertDialog = (new AlertDialog.Builder(this)).Create();
                alertDialog.SetTitle("WebRTC Error");
                alertDialog.SetMessage("Can not init video engine.");
                alertDialog.SetButton((int)DialogInterface.ButtonPositive, "OK", new OnClickListenerAnonymousInnerClassHelper(this));
                alertDialog.Show();
            }

            btSwitchCamera = (Button)FindViewById(Resource.Id.btSwitchCamera);
            if (cameraOrientations[0] != -1 && cameraOrientations[1] != -1)
            {
                btSwitchCamera.SetOnClickListener(this);
            }
            else
            {
                btSwitchCamera.Enabled = false;
            }
            btStartStopCall = (Button)FindViewById(Resource.Id.btStartStopCall);
            btStartStopCall.SetOnClickListener(this);
            FindViewById(Resource.Id.btExit).SetOnClickListener(this);

            // cleaning
            remoteSurfaceView = null;
            svLocal           = null;

            // Video codec
            mVideoCodecsStrings = viEAndroidJavaAPI.GetCodecs();
            spCodecType         = (Spinner)FindViewById(Resource.Id.spCodecType);
            spCodecType.OnItemSelectedListener = this;
            spCodecType.Adapter = new SpinnerAdapter(this, this, Resource.Layout.row, mVideoCodecsStrings);
            spCodecType.SetSelection(0);

            // Video Codec size
            spCodecSize = (Spinner)FindViewById(Resource.Id.spCodecSize);
            spCodecSize.OnItemSelectedListener = this;
            spCodecSize.Adapter = new SpinnerAdapter(this, this, Resource.Layout.row, mVideoCodecsSizeStrings);
            spCodecSize.SetSelection(mVideoCodecsSizeStrings.Length - 1);

            // Voice codec
            mVoiceCodecsStrings = viEAndroidJavaAPI.VoE_GetCodecs();
            spVoiceCodecType    = (Spinner)FindViewById(Resource.Id.spVoiceCodecType);
            spVoiceCodecType.OnItemSelectedListener = this;
            spVoiceCodecType.Adapter = new SpinnerAdapter(this, this, Resource.Layout.row, mVoiceCodecsStrings);
            spVoiceCodecType.SetSelection(0);
            // Find ISAC and use it
            for (int i = 0; i < mVoiceCodecsStrings.Length; ++i)
            {
                if (mVoiceCodecsStrings[i].Contains("ISAC"))
                {
                    spVoiceCodecType.SetSelection(i);
                    break;
                }
            }

            RadioGroup radioGroup = (RadioGroup)FindViewById(Resource.Id.radio_group1);

            radioGroup.ClearCheck();
            if (renderType == RenderType.OPENGL)
            {
                radioGroup.Check(Resource.Id.radio_opengl);
            }
            else if (renderType == RenderType.SURFACE)
            {
                radioGroup.Check(Resource.Id.radio_surface);
            }
            else if (renderType == RenderType.MEDIACODEC)
            {
                radioGroup.Check(Resource.Id.radio_mediacodec);
            }

            etRemoteIp      = (EditText)FindViewById(Resource.Id.etRemoteIp);
            etRemoteIp.Text = remoteIp;

            cbLoopback         = (CheckBox)FindViewById(Resource.Id.cbLoopback);
            cbLoopback.Checked = loopbackMode;

            cbStats         = (CheckBox)FindViewById(Resource.Id.cbStats);
            cbStats.Checked = isStatsOn;

            cbVoice         = (CheckBox)FindViewById(Resource.Id.cbVoice);
            cbVoice.Checked = enableVoice;

            cbVideoSend            = (CheckBox)FindViewById(Resource.Id.cbVideoSend);
            cbVideoSend.Checked    = enableVideoSend;
            cbVideoReceive         = (CheckBox)FindViewById(Resource.Id.cbVideoReceive);
            cbVideoReceive.Checked = enableVideoReceive;

            etVTxPort      = (EditText)FindViewById(Resource.Id.etVTxPort);
            etVTxPort.Text = Convert.ToString(destinationPortVideo);

            etVRxPort      = (EditText)FindViewById(Resource.Id.etVRxPort);
            etVRxPort.Text = Convert.ToString(receivePortVideo);

            etATxPort      = (EditText)FindViewById(Resource.Id.etATxPort);
            etATxPort.Text = Convert.ToString(destinationPortVoice);

            etARxPort      = (EditText)FindViewById(Resource.Id.etARxPort);
            etARxPort.Text = Convert.ToString(receivePortVoice);

            cbEnableNack         = (CheckBox)FindViewById(Resource.Id.cbNack);
            cbEnableNack.Checked = enableNack;

            cbEnableSpeaker      = (CheckBox)FindViewById(Resource.Id.cbSpeaker);
            cbEnableAGC          = (CheckBox)FindViewById(Resource.Id.cbAutoGainControl);
            cbEnableAGC.Checked  = enableAGC;
            cbEnableAECM         = (CheckBox)FindViewById(Resource.Id.cbAECM);
            cbEnableAECM.Checked = enableAECM;
            cbEnableNS           = (CheckBox)FindViewById(Resource.Id.cbNoiseSuppression);
            cbEnableNS.Checked   = enableNS;

            cbEnableDebugAPM         = (CheckBox)FindViewById(Resource.Id.cbDebugRecording);
            cbEnableDebugAPM.Checked = false;             // Disable APM debugging by default

            cbEnableVideoRTPDump         = (CheckBox)FindViewById(Resource.Id.cbVideoRTPDump);
            cbEnableVideoRTPDump.Checked = false;             // Disable Video RTP Dump

            cbEnableVoiceRTPDump         = (CheckBox)FindViewById(Resource.Id.cbVoiceRTPDump);
            cbEnableVoiceRTPDump.Checked = false;             // Disable Voice RTP Dump

            etRemoteIp.SetOnClickListener(this);
            cbLoopback.SetOnClickListener(this);
            cbStats.SetOnClickListener(this);
            cbEnableNack.SetOnClickListener(this);
            cbEnableSpeaker.SetOnClickListener(this);
            cbEnableAECM.SetOnClickListener(this);
            cbEnableAGC.SetOnClickListener(this);
            cbEnableNS.SetOnClickListener(this);
            cbEnableDebugAPM.SetOnClickListener(this);
            cbEnableVideoRTPDump.SetOnClickListener(this);
            cbEnableVoiceRTPDump.SetOnClickListener(this);

            if (loopbackMode)
            {
                remoteIp        = LOOPBACK_IP;
                etRemoteIp.Text = remoteIp;
            }
            else
            {
                remoteIp        = LocalIpAddress;
                etRemoteIp.Text = remoteIp;
            }

            // Read settings to refresh each configuration
            readSettings();
        }