Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / webrtc / sources.js
1 /**
2  * Copyright 2014 The Chromium Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /**
8  * Queries for video sources on the current system using the getSources API.
9  *
10  * This does not guarantee that a getUserMedia with video will succeed, as the
11  * camera could be busy for instance.
12  *
13  * Returns has-video-source to the test if there is a webcam available,
14  * no-video-sources otherwise.
15  */
16 function HasVideoSourceOnSystem() {
17   MediaStreamTrack.getSources(function(sources) {
18     var hasVideoSource = false;
19     sources.forEach(function(source) {
20       if (source.kind == 'video')
21         hasVideoSource = true;
22     });
23
24     if (hasVideoSource)
25       returnToTest('has-video-source');
26     else
27       returnToTest('no-video-sources');
28   });
29 }