mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-07-02 10:38:16 +00:00
feat: enhance audio codec phonebook functionality and messaging integration
This commit is contained in:
parent
c8faa19835
commit
0098673a5e
4 changed files with 135 additions and 67 deletions
|
|
@ -280,6 +280,8 @@ public class DeviceJsonApi
|
|||
/// at the end of the path
|
||||
/// </summary>
|
||||
public static object FindObjectOnPath(string deviceObjectPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = deviceObjectPath.Split('.');
|
||||
|
||||
|
|
@ -360,6 +362,12 @@ public class DeviceJsonApi
|
|||
}
|
||||
return obj;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Error, e, "Error finding object on path {deviceObjectPath}", deviceObjectPath);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a property on an object.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
|
@ -8,16 +9,35 @@ using Serilog.Events;
|
|||
|
||||
namespace PepperDash.Essentials.Devices.Common.AudioCodec;
|
||||
|
||||
public class MockAC : AudioCodecBase
|
||||
public class MockAC : AudioCodecBase, IAudioCodecPhonebook
|
||||
{
|
||||
public event EventHandler<PhonebookListChangedEventArgs> ListChanged;
|
||||
|
||||
public List<CodecPhonebookEntry> PhonebookEntries { get; }
|
||||
|
||||
public MockAC(string key, string name, MockAcPropertiesConfig props)
|
||||
: base(key, name)
|
||||
{
|
||||
CodecInfo = new MockAudioCodecInfo();
|
||||
|
||||
CodecInfo.PhoneNumber = props.PhoneNumber;
|
||||
|
||||
PhonebookEntries = new List<CodecPhonebookEntry>
|
||||
{
|
||||
new() { Name = "Judge Chambers", Number = "5551001" },
|
||||
new() { Name = "Clerk Office", Number = "5551002" },
|
||||
new() { Name = "Court Reporter", Number = "5551003" },
|
||||
new() { Name = "Jury Room", Number = "5551004" },
|
||||
new() { Name = "Witness Room", Number = "5551005" },
|
||||
new() { Name = "Prosecution", Number = "5551006" },
|
||||
new() { Name = "Defense Counsel", Number = "5551007" },
|
||||
new() { Name = "Bailiff Station", Number = "5551008" },
|
||||
new() { Name = "Conference Room A", Number = "5551009" },
|
||||
new() { Name = "Conference Room B", Number = "5551010" },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public override void Dial(string number)
|
||||
{
|
||||
if (!IsInCall)
|
||||
|
|
@ -79,6 +99,29 @@ public class MockAC : AudioCodecBase
|
|||
Debug.LogMessage(LogEventLevel.Debug, this, "BEEP BOOP SendDTMF: {0}", s);
|
||||
}
|
||||
|
||||
public void SetPhonebookEntry(int index, string name, string number)
|
||||
{
|
||||
if (index < 0 || index >= PhonebookEntries.Count)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "SetPhonebookEntry: index {0} out of range", index);
|
||||
return;
|
||||
}
|
||||
|
||||
PhonebookEntries[index] = new CodecPhonebookEntry { Name = name, Number = number };
|
||||
ListChanged?.Invoke(this, new PhonebookListChangedEventArgs(PhonebookEntries));
|
||||
}
|
||||
|
||||
public void DialPhonebookEntry(int index)
|
||||
{
|
||||
if (index < 0 || index >= PhonebookEntries.Count)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "DialPhonebookEntry: index {0} out of range", index);
|
||||
return;
|
||||
}
|
||||
|
||||
Dial(PhonebookEntries[index].Number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||
: base(key, messagePath, device)
|
||||
{
|
||||
_phonebook = device as IAudioCodecPhonebook ?? throw new ArgumentNullException(nameof(device));
|
||||
|
||||
_phonebook.ListChanged += (sender, args) => SendFullStatus();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
@ -43,7 +45,12 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||
{
|
||||
var entry = content.ToObject<SetPhonebookEntryContent>();
|
||||
_phonebook.SetPhonebookEntry(entry.Index, entry.Name, entry.Number);
|
||||
SendFullStatus();
|
||||
});
|
||||
|
||||
AddAction("/dialEntry", (id, content) =>
|
||||
{
|
||||
var request = content.ToObject<MobileControlSimpleContent<int>>();
|
||||
_phonebook.DialPhonebookEntry(request.Value);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -251,6 +251,16 @@ namespace PepperDash.Essentials
|
|||
(d, mp, ck) => new IDialerCallStatusMessenger(
|
||||
$"{d.Key}-audioCodec-{ck}", (IDialerCallStatus)d, mp)
|
||||
),
|
||||
new MessengerFactoryEntry(
|
||||
typeof(IAudioCodecInfo),
|
||||
(d, mp, ck) => new IAudioCodecInfoMessenger(
|
||||
$"{d.Key}-audioCodecInfo-{ck}", mp, d)
|
||||
),
|
||||
new MessengerFactoryEntry(
|
||||
typeof(IAudioCodecPhonebook),
|
||||
(d, mp, ck) => new IAudioCodecPhonebookMessenger(
|
||||
$"{d.Key}-audioCodecPhonebook-{ck}", mp, d)
|
||||
),
|
||||
|
||||
// ── Set-top box controls ──────────────────────────────────────────────────
|
||||
new MessengerFactoryEntry(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue