public void join(string channel) { Debug.Log("calling join (channel = " + channel + ")"); if (mRtcEngine == null) { return; } // set callbacks (optional) mRtcEngine.OnJoinChannelSuccess = onJoinChannelSuccess; mRtcEngine.OnUserJoined = onUserJoined; mRtcEngine.OnUserOffline = onUserOffline; // enable video mRtcEngine.EnableVideo(); // allow camera output callback mRtcEngine.EnableVideoObserver(); // join channel mRtcEngine.JoinChannel(channel, null, 0); // Optional: if a data stream is required, here is a good place to create it int streamID = mRtcEngine.CreateDataStream(true, true); Debug.Log("initializeEngine done, data stream id = " + streamID); }
public void join(string channel) { Debug.Log("calling join (channel = " + channel + ")"); if (mRtcEngine == null) { return; } // set callbacks (optional) mRtcEngine.OnJoinChannelSuccess = onJoinChannelSuccess; mRtcEngine.OnUserJoined = onUserJoined; mRtcEngine.OnUserOffline = onUserOffline; // enable video mRtcEngine.EnableVideo(); // allow camera output callback mRtcEngine.EnableVideoObserver(); //mRtcEngine.EnableLocalVideo(false); CameraCapturerConfiguration config = new CameraCapturerConfiguration(); config.preference = CAPTURER_OUTPUT_PREFERENCE.CAPTURER_OUTPUT_PREFERENCE_AUTO; config.cameraDirection = CAMERA_DIRECTION.CAMERA_REAR; mRtcEngine.SetCameraCapturerConfiguration(config); mRtcEngine.SetExternalVideoSource(true, false); // join channel mRtcEngine.JoinChannel(channel, null, 0); // Optional: if a data stream is required, here is a good place to create it int streamID = mRtcEngine.CreateDataStream(true, true); Debug.Log("initializeEngine done, data stream id = " + streamID); }
public override void OnSceneLoaded() { base.OnSceneLoaded(); GameObject gameObject = GameObject.Find(SelfVideoName); if (gameObject != null) { gameObject.AddComponent <VideoSurface>(); } gameObject = GameObject.Find("ColorController"); if (gameObject != null) { colorButtonController = gameObject.GetComponent <ColorButtonController>(); monoProxy = colorButtonController.GetComponent <MonoBehaviour>(); } gameObject = GameObject.Find("TouchWatcher"); if (gameObject != null) { touchWatcher = gameObject.GetComponent <AudienceTouchWatcher>(); touchWatcher.DrawColor = colorButtonController.SelectedColor; touchWatcher.ProcessDrawing += ProcessDrawing; touchWatcher.NotifyClearDrawings += delegate() { monoProxy.StartCoroutine(CoClearDrawing()); }; colorButtonController.OnColorChange += delegate(Color color) { touchWatcher.DrawColor = color; }; } if (ViewOnly) { colorButtonController?.gameObject.SetActive(false); touchWatcher?.gameObject.SetActive(false); GameObject.Find(SelfVideoName)?.SetActive(false); GameObject.Find("ToggleButton")?.SetActive(false); GameObject.Find("ButtonClear")?.SetActive(false); } rtcEngine = IRtcEngine.QueryEngine(); dataStreamId = rtcEngine.CreateDataStream(reliable: true, ordered: true); }
public void sendChannelMsg(string message) { Debug.Log("sendChannelMsg"); if (mDataStreamId <= 0) { mDataStreamId = mRtcEngine.CreateDataStream(true, true); // boolean reliable, boolean ordered } if (mDataStreamId < 0) { String errorMsg = "onstreammessage Create data stream error happened " + mDataStreamId; Debug.LogError(errorMsg); return; } mRtcEngine.SendStreamMessage(mDataStreamId, message); }
//Called to join or leave a session. Engine must be loaded first! public void join(string channel) { if (String.IsNullOrEmpty(channel)) { Debug.LogWarning("Empty channel name. Ignoring join request."); return; } loadEngine(AppID); // load engine if (mRtcEngine == null) { return; } Debug.Log("calling join (channel = " + channel + ")"); // set callbacks (optional) mRtcEngine.OnJoinChannelSuccess = onJoinChannelSuccess; mRtcEngine.OnLeaveChannel = onLeaveChannel; mRtcEngine.OnUserJoined = onUserJoined; mRtcEngine.OnUserOffline = onUserOffline; mRtcEngine.OnStreamMessage = onStreamMessage; mRtcEngine.OnRtcStats = onRtcStats; //set timeout timer (optional) if (timeout > 0) { timeoutTimer = timeout; hideWarningLabel(); } //Audio settings if (useAudio) { mRtcEngine.EnableAudio(); // enable audio in general mRtcEngine.EnableLocalAudio(!muteLocalAudio); //controls sending local out HARD STOP mRtcEngine.MuteLocalAudioStream(muteLocalAudio); //still sending, but not audible mRtcEngine.MuteAllRemoteAudioStreams(muteRemoteAudio); //still sending, but not audible mRtcEngine.AdjustRecordingSignalVolume(localVolume); mRtcEngine.AdjustPlaybackSignalVolume(remoteVolume); } else { mRtcEngine.DisableAudio(); } // disable video in general //Begin video feed if (useVideo) { mRtcEngine.EnableVideo(); // enable video in general mRtcEngine.EnableVideoObserver(); mRtcEngine.EnableLocalVideo(!muteLocalVideo); //controls sending local out HARD STOP mRtcEngine.MuteLocalVideoStream(muteLocalVideo); //Send local video to remote? mRtcEngine.MuteAllRemoteVideoStreams(muteRemoteVideo); //still receiving, but not visible //if(muteRemoteVideo) { mRtcEngine.DisableVideoObserver(); } //controls receiving video HARD STOP //else { mRtcEngine.EnableVideoObserver(); } //Change Video feed settings VideoEncoderConfiguration videoConfig = new VideoEncoderConfiguration(); videoConfig.dimensions.width = 1280; videoConfig.dimensions.height = 720; videoConfig.frameRate = FRAME_RATE.FRAME_RATE_FPS_15; mRtcEngine.SetVideoEncoderConfiguration(videoConfig); //WEBCAMS: Show list of all webcam devices mRtcEngine.GetVideoDeviceManager().CreateAVideoDeviceManager(); int deviceCount = mRtcEngine.GetVideoDeviceManager().GetVideoDeviceCount(); Debug.Log("Video device count: " + deviceCount); string deviceName = ""; string deviceId = ""; for (int i = 0; i < deviceCount; i++) //Show list of webcams { mRtcEngine.GetVideoDeviceManager().GetVideoDevice(i, ref deviceName, ref deviceId); Debug.Log("Device[i] deviceName = \"" + deviceName + "\" | deviceId = \"" + deviceId + "\""); } //---Show current video device--- mRtcEngine.GetVideoDeviceManager().GetCurrentVideoDevice(ref deviceId); Debug.Log("CurrentVideoDevice deviceId = \"" + deviceId + "\""); //---Pick the first one?--- mRtcEngine.GetVideoDeviceManager().GetVideoDevice(0, ref deviceName, ref deviceId); mRtcEngine.GetVideoDeviceManager().SetVideoDevice(deviceId); } else { mRtcEngine.DisableVideo(); } // disable video in general //Join Channel UID = mRtcEngine.JoinChannel(channel, null, 0); // join channel // Optional: if a data stream is required, here is a good place to create it. streamID = mRtcEngine.CreateDataStream(true, true); Debug.Log("initializeEngine done, data stream id = " + streamID); //Show local video showLocalVideo(); //Hide Join Button and Show Leave button if assigned joinButton.SetActive(false); leaveButton.SetActive(true); //Hide warning label if still there hideWarningLabel(); }