User:Shellylin/InputPort
Goals
Provide DOM API access to the input ports of devices. With InputPort API, application developers are able to browse available input ports of the current device, retrieve media content provided by a particular port, detect whether an input port has connected to a source provider.
Contributors
Status
Features
- Enumerate available input ports on the current device. Supported types of input ports include A/V, VGA and HDMI.
- Retrieve media content from an input port, provided by its source provider. Presented as a MediaStream object.
- Read and write the attributes of a selected input port.
- Examples of input port attributes: frame rate, color system, aspect ratio...etc.
- Support hotplug detection on each input port.
Proposed API
Basic Port Interface
enum InputPortType { "av", "displayport", "hdmi", "pc" };
interface InputPort { readonly attribute DOMString name; readonly attribute DOMString id; readonly attribute InputPortType type; readonly attribute MediaStream stream; attribute EventHandler onconnect; attribute EventHandler ondisconnect; };
Attributes
name of type DOMString, readonly
The name of this input port, e.g. "HDMI1", "HDMI2".
id of type DOMString, readonly
When an InputPort object is created, the user agent MUST generate an identifier string, and MUST initialize the object's id attribute to that string. A good practice is to use an UUID, which is 36 characters long in its canonical form.
The id attribute MUST return the value to which it was initialized when the object was created.
p.s. The idea behind InputPort's id is identical to the id of MediaStream, we want to differentiate InputPort instances created by different UA, so the above statement is copied from the definition of MediaStream's id.
type of type InputPortType, readonly
The type of this input port, value must be defined in the enum of InputPortType, e.g. "av", "displayport".
stream of type MediaStream, readonly
The stream represents the media content provided by this input port.
Specific Port Interfaces
A/V
enum AVInputPortType { "scart", "rca" }; enum AVInputPortVideoFormat { "component", "composite", "rgb" }; interface AVInputPort : InputPort { sequence<AVInputPortVideoFormat> getSupportedVideoFormats (); readonly attribute AVInputPortType type; }
PC
enum PCInputPortType { "audio", "dvi" };
interface PCInputPort : InputPort { readonly attribute PCInputPortType type; }
HDMI/DisplayPort
enum HDMIInputPortAudioFormat { "LPCM", "Dolby Digital" };
interface HDMIInputPort : InputPort { sequence<HDMIInputPortAudioFormat> getSupportedAudioFormats (); }
enum DisplayPortInputPortAudioFormat { "LPCM" };
interface DisplayPortInputPort : InputPort { sequence<DisplayPortInputPortAudioFormat> getSupportedAudioFormats (); }
p.s. Supposely the enum of HDMIInputPortAudioFormat and DisplayPortInputPortAudioFormat depended on its manufacturer, we will not define those attributes in the InputPort API.
InputPortManager
This will be an object in window.navigator
named InputPortManager
with the following interface:
partial interface Navigator { readonly attribute InputPortManager inputPortManager; };
interface InputPortManager { sequence<InputPort> getInputPorts (); };