[rtcweb] determining mic/webcam availability on page load

Daniel Pocock <daniel@pocock.com.au> Sun, 22 September 2013 18:16 UTC

Return-Path: <daniel@pocock.com.au>
X-Original-To: rtcweb@ietfa.amsl.com
Delivered-To: rtcweb@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 2C7CE11E8110 for <rtcweb@ietfa.amsl.com>; Sun, 22 Sep 2013 11:16:51 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.001
X-Spam-Level:
X-Spam-Status: No, score=0.001 tagged_above=-999 required=5 tests=[BAYES_50=0.001]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8DZFoQdiqSML for <rtcweb@ietfa.amsl.com>; Sun, 22 Sep 2013 11:16:46 -0700 (PDT)
Received: from mail1.trendhosting.net (mail1.trendhosting.net [195.8.117.5]) by ietfa.amsl.com (Postfix) with ESMTP id 8E5AA11E810B for <rtcweb@ietf.org>; Sun, 22 Sep 2013 11:16:46 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by mail1.trendhosting.net (Postfix) with ESMTP id 0471415203 for <rtcweb@ietf.org>; Sun, 22 Sep 2013 19:16:45 +0100 (BST)
Received: from mail1.trendhosting.net ([127.0.0.1]) by localhost (thp003.trendhosting.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 6HN6K9-DOYq2 for <rtcweb@ietf.org>; Sun, 22 Sep 2013 19:16:39 +0100 (BST)
Message-ID: <523F3407.1060204@pocock.com.au>
Date: Sun, 22 Sep 2013 20:16:39 +0200
From: Daniel Pocock <daniel@pocock.com.au>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130827 Icedove/17.0.8
MIME-Version: 1.0
To: rtcweb@ietf.org
X-Enigmail-Version: 1.5.1
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
Subject: [rtcweb] determining mic/webcam availability on page load
X-BeenThere: rtcweb@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Real-Time Communication in WEB-browsers working group list <rtcweb.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/rtcweb>, <mailto:rtcweb-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/rtcweb>
List-Post: <mailto:rtcweb@ietf.org>
List-Help: <mailto:rtcweb-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/rtcweb>, <mailto:rtcweb-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 22 Sep 2013 18:16:51 -0000

Hi,

I'm not sure if this has been discussed before, but I think it would be
very useful for some applications to determine what hardware is
available very early, well before trying to do things like SIP
registration or making a call.

However, if I use the code below, the result is that the user is
prompted twice for permissions, once during the initial hardware
detection and later when they try to make or receive a call.

Regards,

Daniel



navigator.webkitGetUserMedia(

 {audio: true, video: true},

  function (stream) {
          var has_audio = false;
          var has_video = false;
	  if(stream.getAudioTracks().length > 0)
		  has_audio = true;
	  if(stream.getVideoTracks().length > 0)
		  has_video = true;
	  console.log("closing unused stream");
	  stream.stop();
	  delete stream;
          checksDone(has_audio, has_video);
  },

  function(err) {
	  console.log(err.name + ": " + err.message);
          checksDone(false, false);
  }

);