Commit 57d903ef authored by Mickaël Turnel's avatar Mickaël Turnel

Added a workaround to make the microphone and camera permissions windows pop

parent 5b06581c
......@@ -33,6 +33,8 @@ using Windows.UI.Notifications;
using Windows.Data.Xml.Dom;
using Windows.System.Threading;
using Linphone.Views;
using Windows.Media.Audio;
using System.Threading.Tasks;
namespace Linphone.Model {
class LinphoneManager{
......@@ -288,7 +290,10 @@ namespace Linphone.Model {
}
}
public void NewOutgoingCall(String sipAddress) {
public async void NewOutgoingCall(String sipAddress) {
// Workaround to pop the microphone permission window
await openMicrophonePopup();
Call LCall = Core.Invite(sipAddress);
}
......@@ -508,11 +513,28 @@ namespace Linphone.Model {
public delegate void CallStateChangedEventHandler(Call call, CallState state);
public event CallStateChangedEventHandler CallStateChangedEvent;
private async Task openMicrophonePopup() {
AudioGraphSettings settings = new AudioGraphSettings(Windows.Media.Render.AudioRenderCategory.Media);
CreateAudioGraphResult result = await AudioGraph.CreateAsync(settings);
AudioGraph audioGraph = result.Graph;
CreateAudioDeviceInputNodeResult resultNode = await audioGraph.CreateDeviceInputNodeAsync(Windows.Media.Capture.MediaCategory.Media);
AudioDeviceInputNode deviceInputNode = resultNode.DeviceInputNode;
deviceInputNode.Dispose();
audioGraph.Dispose();
}
void CallStateChanged(Core lc, Call call, CallState state, string message) {
if (CallStateChangedEvent != null) {
CallStateChangedEvent(call, state);
}
// Workaround to make windows pop the microphone permission window
if (state == CallState.IncomingReceived) {
openMicrophonePopup();
}
if (state == CallState.OutgoingProgress) {
Debug.WriteLine("[LinphoneManager] Outgoing progress\r\n");
......
......@@ -21,9 +21,11 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Windows.ApplicationModel.Resources;
using Windows.Devices.Sensors;
using Windows.Graphics.Display;
using Windows.Media.Capture;
using Windows.Phone.Media.Devices;
using Windows.UI.Core;
using Windows.UI.Popups;
......@@ -82,7 +84,10 @@ namespace Linphone.Views {
}
#region Buttons
private void buttons_VideoClick(object sender, bool isVideoOn) {
private async void buttons_VideoClick(object sender, bool isVideoOn) {
// Workaround to pop the camera permission window
await openCameraPopup();
Call call = LinphoneManager.Instance.Core.CurrentCall;
CallParams param = call.CurrentParams.Copy();
param.VideoEnabled = isVideoOn;
......@@ -267,6 +272,12 @@ namespace Linphone.Views {
}
}
private async Task openCameraPopup() {
MediaCapture mediaCapture = new Windows.Media.Capture.MediaCapture();
await mediaCapture.InitializeAsync();
mediaCapture.Dispose();
}
public async void AskVideoPopup(Call call) {
if (askingVideo) return;
askingVideo = true;
......@@ -278,6 +289,8 @@ namespace Linphone.Views {
var res = await dialog.ShowAsync();
CallParams parameters = LinphoneManager.Instance.Core.CreateCallParams(call);
if ((int)res.Id == 0) {
// Workaround to pop the camera permission window
await openCameraPopup();
parameters.VideoEnabled = true;
}
LinphoneManager.Instance.Core.AcceptCallUpdate(call, parameters);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment