|
| 1 | +Depsite the lack of granularity in the error responses returned by |
| 2 | ++getUserMedia()+, with a little forensic work it is possible to derive a |
| 3 | +better picture of the WebRTC media capabilities of the host browser. |
| 4 | + |
| 5 | +In the first instance, support of any kind for +getUserMedia()+ is tested |
| 6 | +and if not present, an error is raised. |
| 7 | + |
| 8 | +Where +getUserMedia()+ is supported, a method can then be used to check |
| 9 | +whether or not multimedia input devices are available to the application. |
| 10 | +Key to this is accessing the MediaStream API methods +getAudioTracks()+ and |
| 11 | ++getVideoTracks()+, both returning arrays, on the stream passed into the |
| 12 | ++success+ callback supplied to +getUserMedia()+. |
| 13 | + |
| 14 | +The required contraints parameter for +getUserMedia()+ has two boolean |
| 15 | +attributes +audio+ and +video+ allowing the developer to request access to |
| 16 | +audio and video input respectively. |
| 17 | + |
| 18 | +If audio is requested, and +getAudioTracks()+ has a length of 0 then it can |
| 19 | +be inferred that no microphone is available. It may be physically not present |
| 20 | +or blocked by another process, but in any case it is not available to the |
| 21 | +requesting application. The same applies to video and +getVideoTracks()+. |
| 22 | + |
| 23 | +In the case of the entire call to +getUserMedia()+ failing for some reason, |
| 24 | +the +failure+ callback is called with an error. |
| 25 | + |
| 26 | +=== Errors === |
| 27 | + |
| 28 | +The +getUserMedia()+ errors that can be raised by openRMC are laid out below. |
| 29 | +There are two contexts in which errors are raised, both outlined in the |
| 30 | +following sections, which raise a different subset of errors. |
| 31 | + |
| 32 | +* *+NOT_SUPPORTED+* - WebRTC is not supported on the host browser |
| 33 | +* *+PERMISSION_DENIED+* - Access to multimedia input devices is denied |
| 34 | +* *+CONSTRAINT_NOT_SATISFIED+* - A mandatory constraint was requested, and |
| 35 | +could not be satisfied |
| 36 | +* *+CONSTRAINTS_REQUIRED+* - At least one of audio or video must be requested |
| 37 | +* *+AUDIO_NOT_AVAILABLE+* - Raised when audio is requested, but no audio |
| 38 | +input is available |
| 39 | +* *+VIDEO_NOT_AVAILABLE+* - Raised when video is requested, but no video |
| 40 | +input is available |
| 41 | +* *+AV_NOT_AVAILABLE+* - Raised when both audio and video are requested, |
| 42 | +but neither audio nor video inputs are available |
| 43 | + |
| 44 | + |
| 45 | +=== Error Checking Scenarios === |
| 46 | + |
| 47 | +In the openRMC scenario, there are two instances where errors are returned, |
| 48 | +the exact subset of errors depending on the calling context: |
| 49 | + |
| 50 | +==== +openrmc.webrtc.api.init()+ ==== |
| 51 | + |
| 52 | ++getUserMedia()+ is called with optional audio/video media constraints as |
| 53 | +part of the WebRTC API initialisation. The capabilities available to the |
| 54 | +app are then tested, and a context created. |
| 55 | + |
| 56 | +The +failure(errCxt)+ callback is called with a context +errCxt+ with an |
| 57 | ++error+ attribute corresponding to one of the openRMC media errors outlined |
| 58 | +above. The possible error returned are +NOT_SUPPORTED+, +PERMISSION_DENIED+, |
| 59 | +and +CONSTRAINTS_REQUIRED+ |
| 60 | + |
| 61 | +==== +openrmc.webrtc.api.getUserMedia() ==== |
| 62 | + |
| 63 | ++openrmc.webrtc.api.getUserMedia()+ wraps the native +getUserMedia()+ and |
| 64 | +provides the enhanced diagnostics described in this document. |
| 65 | +The +failure(errCxt)+ callback is called with a context +errCxt+ with an |
| 66 | ++error+ attribute corresponding to one of the openRMC media errors outlined |
| 67 | +above. This can contain any of the error conditions described above. |
| 68 | + |
| 69 | + |
| 70 | +=== Application Checking Of Capabilities === |
| 71 | + |
| 72 | +The WebRTC API must be properly initialised by calling |
| 73 | ++openrmc.webrtc.api.init()+. This created a WebRTC context awhich can be |
| 74 | +queried for capabilities. This is available as an attribute +baseContext+ |
| 75 | + |
| 76 | ++baseContext+ (and indeed any context passed to the +success(cxt)+ callback) |
| 77 | +has a methods to check availablity of a particular resource: |
| 78 | + |
| 79 | +* +isrtcavailable()+ - +true+ if WebRTC is available, +false+ otherwise |
| 80 | +* +isrtcaudioavailable()+ - Returns +true+ if an audio input is available, |
| 81 | +otherwise +false+ |
| 82 | +* +isrtcvideoavailable()+ - Returns +true+ if a video input is available, |
| 83 | +otherwise +false+ |
| 84 | + |
| 85 | +With respect to +baseContext+, these methods are are all wrapped in |
| 86 | +convenience methods with the same signature in +openrmc.webrtc.api+ |
| 87 | + |
| 88 | +It is the application's responsibility to query +baseContext+ for host |
| 89 | +browser capabilities following a call to +openrmc.webrtc.api.init()+. |
| 90 | +Should a subsequent call to +openrmc.webrtc.api.getUserMedia()+ be |
| 91 | +made requesting a resource or resources not detected on init, one of the |
| 92 | ++XXX_NOT_AVAILABLE+ errors will be raised. |
| 93 | + |
0 commit comments