Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with v1.0 update of samples. #156

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\..\nuget.config = ..\..\nuget.config
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Common", "..\..\Common\Sample.Common\Sample.Common.csproj", "{3268E59C-90DC-4D7B-97EA-A1DBB2716DF3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Common.Beta", "..\..\Common\Sample.Common.Beta\Sample.Common.Beta.csproj", "{3268E59C-90DC-4D7B-97EA-A1DBB2716DF3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CRFrontEnd", "ComplianceRecordingBot\FrontEnd\CRFrontEnd.csproj", "{739D09C4-47E8-42B7-9B89-94DCB890AC0F}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Sample.ComplianceRecordingBot.FrontEnd.Bot
/// <summary>
/// Call Handler Logic.
/// </summary>
internal class CallHandler : IDisposable
internal class CallHandler : HeartbeatHandler
{
/// <summary>
/// MSI when there is no dominant speaker.
Expand All @@ -41,9 +41,6 @@ internal class CallHandler : IDisposable
// This dictionnary helps maintaining a mapping of the sockets subscriptions
private readonly ConcurrentDictionary<uint, uint> msiToSocketIdMapping = new ConcurrentDictionary<uint, uint>();

// Graph logger.
private readonly IGraphLogger logger;

private readonly Timer recordingStatusFlipTimer;

private int recordingStatusIndex = -1;
Expand All @@ -53,10 +50,9 @@ internal class CallHandler : IDisposable
/// </summary>
/// <param name="statefulCall">The stateful call.</param>
public CallHandler(ICall statefulCall)
: base(TimeSpan.FromMinutes(10), statefulCall?.GraphLogger)
{
this.Call = statefulCall;
this.logger = statefulCall.GraphLogger;

this.Call.OnUpdated += this.CallOnUpdated;

// subscribe to dominant speaker event on the audioSocket
Expand All @@ -67,7 +63,7 @@ public CallHandler(ICall statefulCall)
this.Call.Participants.OnUpdated += this.ParticipantsOnUpdated;

// attach the botMediaStream
this.BotMediaStream = new BotMediaStream(this.Call.GetLocalMediaSession(), this.logger);
this.BotMediaStream = new BotMediaStream(this.Call.GetLocalMediaSession(), this.GraphLogger);

// initialize the timer
var timer = new Timer(1000 * 60); // every 60 seconds
Expand All @@ -86,9 +82,17 @@ public CallHandler(ICall statefulCall)
/// </summary>
public BotMediaStream BotMediaStream { get; private set; }

/// <inheritdoc/>
protected override Task HeartbeatAsync(ElapsedEventArgs args)
{
return this.Call.KeepAliveAsync();
}

/// <inheritdoc />
public void Dispose()
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

var audioSocket = this.Call.GetLocalMediaSession().AudioSocket;
audioSocket.DominantSpeakerChanged -= this.OnDominantSpeakerChanged;

Expand Down Expand Up @@ -120,15 +124,15 @@ private void OnRecordingStatusFlip(object source, ElapsedEventArgs e)
{
var recordedParticipantId = this.Call.Resource.IncomingContext.ObservedParticipantId;

this.logger.Warn($"We've rolled through all the status'... removing participant {recordedParticipantId}");
this.GraphLogger.Warn($"We've rolled through all the status'... removing participant {recordedParticipantId}");
var recordedParticipant = this.Call.Participants[recordedParticipantId];
await recordedParticipant.DeleteAsync().ConfigureAwait(false);
return;
}

var newStatus = recordingStatus[recordingIndex];

this.logger.Info($"Flipping recording status to {newStatus}");
this.GraphLogger.Info($"Flipping recording status to {newStatus}");

try
{
Expand All @@ -141,9 +145,9 @@ await this.Call
}
catch (Exception exc)
{
this.logger.Error(exc, $"Failed to flip the recording status to {newStatus}");
this.GraphLogger.Error(exc, $"Failed to flip the recording status to {newStatus}");
}
}).ForgetAndLogExceptionAsync(this.logger);
}).ForgetAndLogExceptionAsync(this.GraphLogger);
}

/// <summary>
Expand Down Expand Up @@ -269,7 +273,7 @@ private void SubscribeToParticipantVideo(IParticipant participant, bool forceSub
}

updateMSICache = true;
this.logger.Info($"[{this.Call.Id}:SubscribeToParticipant(socket {socketId} available, the number of remaining sockets is {this.availableSocketIds.Count}, subscribing to the participant {participant.Id})");
this.GraphLogger.Info($"[{this.Call.Id}:SubscribeToParticipant(socket {socketId} available, the number of remaining sockets is {this.availableSocketIds.Count}, subscribing to the participant {participant.Id})");
}
else if (forceSubscribe)
{
Expand All @@ -294,7 +298,7 @@ private void SubscribeToParticipantVideo(IParticipant participant, bool forceSub
{
this.msiToSocketIdMapping.AddOrUpdate(msi, socketId, (k, v) => socketId);

this.logger.Info($"[{this.Call.Id}:SubscribeToParticipant(subscribing to the participant {participant.Id} on socket {socketId})");
this.GraphLogger.Info($"[{this.Call.Id}:SubscribeToParticipant(subscribing to the participant {participant.Id} on socket {socketId})");
this.BotMediaStream.Subscribe(MediaType.Video, msi, VideoResolution.HD1080p, socketId);
}
}
Expand All @@ -305,7 +309,7 @@ private void SubscribeToParticipantVideo(IParticipant participant, bool forceSub
if (vbssParticipant != null)
{
// new sharer
this.logger.Info($"[{this.Call.Id}:SubscribeToParticipant(subscribing to the VBSS sharer {participant.Id})");
this.GraphLogger.Info($"[{this.Call.Id}:SubscribeToParticipant(subscribing to the VBSS sharer {participant.Id})");
this.BotMediaStream.Subscribe(MediaType.Vbss, uint.Parse(vbssParticipant.SourceId), VideoResolution.HD1080p, socketId);
}
}
Expand All @@ -321,7 +325,7 @@ private void SubscribeToParticipantVideo(IParticipant participant, bool forceSub
/// </param>
private void OnDominantSpeakerChanged(object sender, DominantSpeakerChangedEventArgs e)
{
this.logger.Info($"[{this.Call.Id}:OnDominantSpeakerChanged(DominantSpeaker={e.CurrentDominantSpeaker})]");
this.GraphLogger.Info($"[{this.Call.Id}:OnDominantSpeakerChanged(DominantSpeaker={e.CurrentDominantSpeaker})]");

if (e.CurrentDominantSpeaker != DominantSpeakerNone)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
<Reference Include="System.Data.Entity" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Common\Sample.Common\Sample.Common.csproj">
<Project>{3268e59c-90dc-4d7b-97ea-a1dbb2716df3}</Project>
<Name>Sample.Common</Name>
<ProjectReference Include="..\..\..\..\Common\Sample.Common.Beta\Sample.Common.Beta.csproj">
<Project>{88b67fbe-6de8-4dc3-83cf-9f6b4ea10138}</Project>
<Name>Sample.Common.Beta</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
</InstanceAddress>
</AddressAssignments>
</NetworkConfiguration>
</ServiceConfiguration>
</ServiceConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
</InstanceAddress>
</AddressAssignments>
</NetworkConfiguration>
</ServiceConfiguration>
</ServiceConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Common\Sample.Common\Sample.Common.csproj">
<Project>{3268e59c-90dc-4d7b-97ea-a1dbb2716df3}</Project>
<Name>Sample.Common</Name>
<ProjectReference Include="..\..\..\..\Common\Sample.Common.Beta\Sample.Common.Beta.csproj">
<Project>{88b67fbe-6de8-4dc3-83cf-9f6b4ea10138}</Project>
<Name>Sample.Common.Beta</Name>
</ProjectReference>
<ProjectReference Include="..\FrontEnd\CRFrontEnd.csproj">
<Project>{739d09c4-47e8-42b7-9b89-94dcb890ac0f}</Project>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Sample.OnlineMeeting
{
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Graph;
Expand Down Expand Up @@ -49,7 +48,7 @@ public async Task<OnlineMeeting> GetOnlineMeetingByVtcIdAsync(string tenantId, s
this.graphEndpointUri.AbsoluteUri,
this.GetAuthenticationProvider(tenantId, scenarioId));

var meetingRequestCollection = statelessClient.App.OnlineMeetings.Request();
var meetingRequestCollection = statelessClient.Communications.OnlineMeetings.Request();
meetingRequestCollection.Filter($"VideoTeleconferenceId eq '{vtcId}'");

var meeting = await meetingRequestCollection.GetAsync().ConfigureAwait(false);
Expand All @@ -72,7 +71,7 @@ public async Task<OnlineMeeting> CreateOnlineMeetingAsync(string tenantId, strin
this.graphEndpointUri.AbsoluteUri,
this.GetAuthenticationProvider(tenantId, scenarioId));

var meetingRequest = statelessClient.App.OnlineMeetings.Request();
var meetingRequest = statelessClient.Communications.OnlineMeetings.Request();

var onlineMeeting = new OnlineMeeting()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Common\Sample.Common\Sample.Common.csproj" />
<ProjectReference Include="..\..\..\Common\Sample.Common.Beta\Sample.Common.Beta.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Sample.OnlineMeeting
{
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Graph;
using Microsoft.Graph.Communications.Client.Authentication;
Expand Down
33 changes: 33 additions & 0 deletions Samples/Common/Sample.Common.Beta/Sample.Common.Beta.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<RootNamespace>Sample.Common</RootNamespace>
<AssemblyName>Sample.Common</AssemblyName>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\Graph.props" />

<ItemGroup>
<PackageReference Include="Microsoft.Graph.Communications.Client" Version="1.2.0-beta.1" />
<PackageReference Include="Microsoft.Graph.Communications.Core" Version="1.2.0-beta.1" />
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="5.2.3" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="5.5.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Sample.Common\**\*.cs" Exclude="..\Sample.Common\obj\**\*.cs" />
</ItemGroup>

</Project>
Loading