Coder Social home page Coder Social logo

topcats / xbox-smartglass-csharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openxbox/xbox-smartglass-csharp

0.0 1.0 0.0 446 KB

๐ŸŽฎ.NET Standard client library for the Xbox One SmartGlass protocol

License: MIT License

C# 100.00%
xbox csharp smartglass

xbox-smartglass-csharp's Introduction

Xbox One SmartGlass client library for .NET

GitHub Workflow - Build 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;

try
{
    client = await SmartGlassClient.ConnectAsync("192.168.0.234");
}
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);

Console.WriteLine(
    $"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 */;
nano.AddConsumer(consumer);

// Start consumer, if necessary
consumer.Start();

// 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 */

Troubleshooting

The wrong network interface gets choosen for SmartGlass communication

Solution: Before doing any network I/O with the library, set the BindAddress to the local IP address of the desired interface.

using System.Net;
using SmartGlass;

// Adjust 192.168.0.1 to your actual local IP address
GlobalConfiguration.BindAddress = IPAddress.Parse("192.168.0.1");

// Do stuff

Project originally developed by Joel Day

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

xbox-smartglass-csharp's People

Contributors

aspann avatar icfjoeld avatar joelday avatar mitchcapper avatar pristinesource avatar queequac avatar topcats avatar tuxuser avatar zb140 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.