🎮.NET Standard client library for the Xbox One SmartGlass protocol
Clone or download
Latest commit 51a5366 Dec 12, 2018


Xbox One SmartGlass client library for .NET

Build Status Build status NuGet Discord

Build from source

cd xbox-smartglass-sharp
dotnet build

Command line tool

Print usage

dotnet run -p SmartGlass.Cli -- --help

API usage

Discover consoles

using SmartGlass;

IEnumerable<SmartGlass.Device> devices = await SmartGlass.Device.DiscoverAsync();

foreach (SmartGlass.Device device in devices)
    Console.WriteLine($"{device.Name} ({device.HardwareId}) {device.Address}");

Power on console

using SmartGlass;

string liveId = "FD0123456789";
SmartGlass.Device device = await SmartGlass.Device.PowerOnAsync(liveId);
Console.WriteLine($"{device.Name} ({device.HardwareId}) {device.Address}");

Connect to console

using SmartGlass;

SmartGlassClient client = null;

    client = await SmartGlassClient.ConnectAsync("");
catch (SmartGlassException e)
    Console.WriteLine($"Failed to connect: {e.Message}");
catch (TimeoutException)
    Console.WriteLine($"Timeout while connecting");

Start Nano (gamestreaming)

using SmartGlass;
using SmartGlass.Channels;
using SmartGlass.Channels.Broadcast;
using SmartGlass.Common;
using SmartGlass.Nano;
using SmartGlass.Nano.Packets;

SmartGlassClient client = /* Connect to console */;

// Get general gamestream configuration
GamestreamConfiguration config = GamestreamConfiguration.GetStandardConfig();
/* Modify standard config, if desired */

GamestreamSession session = await client.BroadcastChannel.StartGamestreamAsync(config);

    $"Connecting to NANO // TCP: {session.TcpPort}, UDP: {session.UdpPort}");

NanoClient nano = new NanoClient(hostName, session);

// General Handshaking & Opening channels
await nano.InitializeProtocolAsync();

// Audio & Video client handshaking
// Sets desired AV formats
AudioFormat audioFormat = nano.AudioFormats[0];
VideoFormat videoFormat = nano.VideoFormats[0];
await nano.InitializeStreamAsync(audioFormat, videoFormat);

// Start ChatAudio channel
AudioFormat chatAudioFormat = new AudioFormat(1, 24000, AudioCodec.Opus);
await nano.OpenChatAudioChannelAsync(chatAudioFormat);

IConsumer consumer = /* initialize consumer */;

// Start consumer, if necessary

// Tell console to start sending AV frames
await nano.StartStreamAsync();

// Start Controller input channel
await nano.OpenInputChannelAsync(1280, 720);

/* Run a mainloop, to gather controller input events or similar */

Project originally developed by Joel Day

Special thanks to Team OpenXbox for their contribution of documentation, tools and samples for the SmartGlass protocol.