|
| 1 | +# Open Screen Protocol Explainer |
| 2 | + |
| 3 | +The Open Screen Protocol allows one networked device to discover another on the |
| 4 | +local network, create a secure connection, and request that the other device |
| 5 | +render an application or streaming media using Web APIs such as the |
| 6 | +[Presentation API](https://w3c.github.io/presentation-api/) and [Remote Playback |
| 7 | +API](https://w3c.github.io/remote-playback/). |
| 8 | + |
| 9 | +We call devices that implement this protocol Open Screen Agents. |
| 10 | + |
| 11 | +## Why should users care? |
| 12 | + |
| 13 | +Currently there are several proprietary solutions that allow media accessed on |
| 14 | +one device to be played on a different device. Examples include [Google |
| 15 | +Cast](https://developers.google.com/cast/), [Apple |
| 16 | +AirPlay](https://www.apple.com/airplay/), and [Spotify |
| 17 | +Connect](https://www.spotify.com/us/connect/). |
| 18 | + |
| 19 | +However, the application, browser and/or OS largely determine what devices work |
| 20 | +together for media playback. The choice of one device, OS or browser largely |
| 21 | +determines what other media devices are compatible for launching Web |
| 22 | +applications and remote media playback. This in turn may force users into using |
| 23 | +specific devices, OSes, or browsers in order to take advantage of second screen |
| 24 | +functionality. It also prevents some browsers from implementing second screen |
| 25 | +Web APIs at all. |
| 26 | + |
| 27 | +## Why should Web developers care? |
| 28 | + |
| 29 | +Web developers who want to integrate second screen functionality into their |
| 30 | +applications currently need to write different code for each browser to |
| 31 | +interface with the devices supported by that browser. This discourages wide |
| 32 | +adoption of remote playback functionality. For applications that do add second |
| 33 | +screen support, they tend to pick one device type versus integrating multiple |
| 34 | +device-specific SDKs into their application. |
| 35 | + |
| 36 | +One goal of Second Screen APIs is to allow developers to write one application |
| 37 | +for remote media playback and expect it to function as expected across as many |
| 38 | +devices and browsers as possible. |
| 39 | + |
| 40 | +## Assumptions and Goals |
| 41 | + |
| 42 | +The primary goal of the Open Screen Protocol is to provide a complete network |
| 43 | +protocol to allow devices from different vendors to implement second screen |
| 44 | +APIs and work together. |
| 45 | + |
| 46 | +The protocol specifically targets the [requirements of second screen Web |
| 47 | +APIs](requirements.md): the [Remote Playback |
| 48 | +API](https://w3c.github.io/remote-playback/) and the [Presentation |
| 49 | +API](https://w3c.github.io/presentation-api/). |
| 50 | + |
| 51 | +A design goal is to re-use existing network and data standards like mDNS, QUIC |
| 52 | +and CBOR as building blocks, versus inventing our own. |
| 53 | + |
| 54 | +The protocol also provides [security and privacy |
| 55 | +guarantees](requirements.md#privacy-and-security), especially with regards to |
| 56 | +other devices on the network. |
| 57 | + |
| 58 | +We assume that the protocol should work on devices with [low-end CPUs and |
| 59 | +constrained memory](device_specs.md), which are typical in special purpose |
| 60 | +devices like smart TVs and connected speakers. We also assume the protocol will |
| 61 | +be used on [battery-powered devices](requirements.md#hardware-and-efficiency). |
| 62 | + |
| 63 | +## Non-Goals |
| 64 | + |
| 65 | +A non-goal is to enable every Web application to be able to successfully render |
| 66 | +content on every Open Screen Protocol device. Devices have a wide range of |
| 67 | +rendering capabilities and policies about what content they wish to support. |
| 68 | +The protocol allows devices to indicate whether they are compatible with a |
| 69 | +specific URL or media type. |
| 70 | + |
| 71 | +## Alternatives Considered |
| 72 | + |
| 73 | +We considered adopting an existing protocol like [Google |
| 74 | +Cast](https://developers.google.com/cast/) or [HbbTV |
| 75 | +2.0](https://www.hbbtv.org/news-events/hbbtv-2-0-specification-released/) |
| 76 | +instead of inventing a new protocol from scratch. However these have significant |
| 77 | +limitations that motivated the development of a new protocol: |
| 78 | + |
| 79 | + * They were not free to implement by other vendors. |
| 80 | + * They did not fully support the Web APIs as written. |
| 81 | + * They did not have a security model that met the requirements of the Web APIs. |
| 82 | + * They would be harder to extend to anticipated future use cases, |
| 83 | + like cross-LAN support, or future cross-device Web APIs. |
| 84 | + |
| 85 | +## Protocol Overview |
| 86 | + |
| 87 | +An interaction between Open Screen agents consists of the following phases. |
| 88 | + |
| 89 | +*Phase 1.* Discovery and connection. |
| 90 | + |
| 91 | +Initially, an agent _S_ [advertises itself using |
| 92 | +mDNS](https://w3c.github.io/openscreenprotocol/#discovery) as available for |
| 93 | +other agents to connect to. Another agent, _C_, [initiates a connection](https://w3c.github.io/openscreenprotocol/#transport) using QUIC to the port and IP address advertised by _S_. |
| 94 | + |
| 95 | +*Phase 2.* Authentication. |
| 96 | + |
| 97 | +[TLS 1.3 is used to secure the |
| 98 | +connection](https://w3c.github.io/openscreenprotocol/#tls-13) between _C_ and |
| 99 | +_S_. If _C_ and _S_ have not authenticated before, they negotiate one party to |
| 100 | +present a one-time code and the other party to accept the code. (Typically the |
| 101 | +end user is asked to input into _C_ a code presented on the screen of |
| 102 | +_S_.) [SPAKE2 is used to generate a shared |
| 103 | +secret](https://w3c.github.io/openscreenprotocol/#authentication-with-spake2) |
| 104 | +and verify the identities of the TLS 1.3 endpoints. |
| 105 | + |
| 106 | +*Phase 3.* Capability exchange. |
| 107 | + |
| 108 | +Once the connection is authenticated, |
| 109 | +[the two agents exchange capabilities](https://w3c.github.io/openscreenprotocol/#metadata), |
| 110 | +which map to sets of messages that each agent understands. For example, one |
| 111 | +agent may be an initiator of media remote playback, and the other agent may be |
| 112 | +the receiver of remote playback requests. |
| 113 | + |
| 114 | +Some capabilities are defined by the spec corresponding to the needs of the |
| 115 | +Remote Playback API and Presentation API. However, the [set of capabilities is |
| 116 | +open ended](https://w3c.github.io/openscreenprotocol/#protocol-extensions) and |
| 117 | +may be extended to accomodate future requirements, additional Web APIs, or |
| 118 | +device-specific features. |
| 119 | + |
| 120 | +*Phase 4.* API-specific usage. |
| 121 | + |
| 122 | +Once the two agents have learned each other's capabilities, they can exchange |
| 123 | +messages at the request of Web applications through supported Web APIs. |
| 124 | + |
| 125 | +For example, if _C_ wishes to [start a presentation](https://w3c.github.io/openscreenprotocol/#presentation-api) on _S_, it would: |
| 126 | + |
| 127 | +1. Send a `presentation-url-availability-request` to learn if _S_ can use the URL to start a presentation. |
| 128 | +2. Send a `presentation-start-request` to request that _S_ start a presentation with the URL. |
| 129 | +3. Send and receive `presentation-connection-message`s to exchange messages with the active presentation. |
| 130 | +4. Disconnect from the presentation with `presentation-connection-close-event` or request its termination with `presentation-termination-request`. |
| 131 | + |
| 132 | +All messages that are specific to the Open Screen Protocol are encoded with CBOR |
| 133 | +which provides a good tradeoff between performance, conciseness and Web compatibility. |
| 134 | + |
| 135 | + |
| 136 | +## Privacy and security |
| 137 | + |
| 138 | +The protocol is responsible for enabling a secure network connection between two |
| 139 | +Open Screen agents. The spec includes guidelines for the presentation and |
| 140 | +consumption of the pairing code, how agents can track other agents that have |
| 141 | +been previously authenticated, and when an agent should be reauthenticated. |
| 142 | + |
| 143 | +Other aspects of security and privacy for second screen applications using the |
| 144 | +protocol are covered in other specifications, handled by specific agent |
| 145 | +implementations, or may be in scope for future revisions of the protocol. |
| 146 | + |
| 147 | +## Relationship to other Web specifications |
| 148 | + |
| 149 | +[WebRTC-QUIC](https://w3c.github.io/webrtc-quic/) is a proposal to enable Web |
| 150 | +applications to create peer-to-peer QUIC connections. This could enable |
| 151 | +applications to implement parts of the Open Screen Protocol in script. |
| 152 | + |
| 153 | +[WebTransport](https://w3c.github.io/webtransport/) allows Web applications to |
| 154 | +construct HTTP/3 connections to servers. It may be possible to implement parts |
| 155 | +of the Open Screen protocol in application script on top of an HTTP/3 |
| 156 | +WebTransport. |
| 157 | + |
| 158 | +With either of these capabiliites, applications still cannot discover and |
| 159 | +authenticate to Open Screen agents on their own. Those aspects would need to be |
| 160 | +handled by the user agent, or new APIs developed to enable Web applications to |
| 161 | +take them on. |
0 commit comments