Add MusicBridge protocol documentation and implement system volume control
- Created PROTOCOL.md to outline the MusicBridge protocol v1, detailing setup, TLS, pairing, state management, and command structure. - Implemented SystemVolume class for managing system audio levels, including methods for setting, reading, changing, and muting volume. - Added unit tests for the MusicBridge agent, covering pairing, identity storage, command validation, and media state management. - Included tests for real-time media reading from Windows and ensured proper handling of artwork caching and retrieval.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
namespace MusicBridge.Agent.Network;
|
||||
|
||||
// Data for a future DNS-SD publisher. Does not open sockets or advertise pairing secrets.
|
||||
internal sealed record DiscoveryDescriptor(int ProtocolVersion, string AgentId, string ServiceType, string InstanceName)
|
||||
{
|
||||
public static DiscoveryDescriptor Create(string certificateSha256)
|
||||
{
|
||||
if (certificateSha256.Length != 64 || !certificateSha256.All(Uri.IsHexDigit))
|
||||
throw new ArgumentException("Неверный идентификатор сертификата.");
|
||||
var id = certificateSha256.ToUpperInvariant();
|
||||
return new(1, id, "_musicbridge._tcp.local.", "MusicBridge-" + id[..12]);
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<string, string> TxtRecords() => new Dictionary<string, string>
|
||||
{
|
||||
["v"] = ProtocolVersion.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
["id"] = AgentId
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user