Streaming

Streaming

Here's how to stream an interactive Windows desktop from one Peer to another.

🚧

Platform limitations on streaming

In its current beta state, the Rainway SDK only supports streams

  • from a Windows desktop, using the Native Runtime,
  • to a web browser, using the Web Runtime.

So make sure you have both of these set up if you want to try out streaming.

If you want to try streaming without writing any code yourself, you can install the C# demo on a Windows desktop, and use the web demo page to connect to it from a browser on another computer.

Before a stream is initiated, the peer-to-peer connection is symmetrical. Once streaming begins, this changes. The streaming Peer (native app) is referred to as the host, and the Peer consuming the stream (the host's web app) is the client.

A desktop stream may be initiated when a client requests it. Here's what that looks like.

Requested streams

Stream requests come in on the Peer as a StreamRequest event.

The host specifies which input permissions to grant, and which processes to stream:

peer.StreamRequest += async (sender, ev) => {
  // who's requesting the stream
  var requesterId = ev.Id;
  
  // what input level are they requesting
  var requesterPerms = ev.Permissions;
  
  // we can choose to accept or reject, here we'll accept
  // the returned task resolves to an OutboundStream object
  var stream = await ev.AcceptAsync(new OutboundStreamOptions(){
    // grant them what they asked for
    Permissions = requesterPerms,
    
    // share the full desktop
    Type = StreamType.FullDesktop
    });
};

Calling AcceptAsync will start streaming media to the web app, which it can display in a container on the page.

Alternatively, the host can call RejectAsync with a human-readable reason string.


Did this page help you?