Temasys / AdapterJS

AdapterJS Javascript Polyfill and Tools for WebRTC - Skylink WebRTC
http://skylink.io/web
Other
432 stars 100 forks source link

MediaStream and getVideoTracks / getAudioTracks #75

Closed yurytarasevich closed 9 years ago

yurytarasevich commented 9 years ago

Hi guys,

I try to get a real name of device and have incorrect behaviour. When I use getUserMedia() method and call getAudioTracks() / getVideoTracks() with "stream" here, Temasys plugin returns non-readable string. Something like this: "J+fpdCSBad".

I would like to get name like as "Microphone (Logitech USB Headset)". Also this correct information we have after calling GetSources() method.

I know about this case (some code from adapter.js):

  // Fake get{Video,Audio}Tracks
  if (!MediaStream.prototype.getVideoTracks) {
    MediaStream.prototype.getVideoTracks = function () {
      return [];
    };
  }
  if (!MediaStream.prototype.getAudioTracks) {
    MediaStream.prototype.getAudioTracks = function () {
      return [];
    };
  }

But could you clarify can I get a real name of device from "stream"? Or I can not access to there.

Thanks.

johache commented 9 years ago

Hi,

  1. The code you are referring to only concern Firefox, nothing to do with the plugin
  2. The plugin will NOT let you know the name of the device being used from the stream itself Note that you will have the same behavior with Firefox. Chrome is basically the exception. See the specs for more information : http://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-getusermedia

I hope that helps, J-O

yurytarasevich commented 9 years ago

If I correctly understand you, when I use something like this:

TemasysAdapter.getUserMedia(
    {video: true},
    function (stream) {
        console.log(stream.getVideoTracks()[0]);
    },
    function (err) {
        console.log(err);
    }
);

In console (Internet Explorer) I will see next object:

{
   attachEvent: {},
   detachEvent: {},
   enabled: true,
   getAttribute: {},
   getLastException: {},
   id: "81horFdUWw",
   kind: "video",
   label: "81horFdUWw",
   readyState: "live",
   setAttribute: {},
   toString: {},
   valid: true,
   value: "<JSAPI-Auto Javascript Object>"
}

And this is correct value for label label: "81horFdUWw" in this case. Am I right?

johache commented 9 years ago

Yes, that sounds about right.

You should use id to identify the track. Label is currently a reference to id, but according to the spec it should either be empty or be the name of the device. Therefore I don't suggest you rely on it too much as we will update it eventually.

ztana commented 7 years ago

I got the similar problem during using this plugin. Anyone can tell me how to create an blob url from that video track? I'm trying to window.URL.createObjectURL(stream). but that stream must be a MediaStream object, not a JSAPI-auto Javascript Object. my html looks like <div class="col-md-4"> <video ng-src="{{getLocalVideo()}}" autoplay></video> </div> now if I got that stream object I can using video.trustAsResourceURL in my getLocalVideo function. And I tried video.vidSrc = stream(JSAPI Obj). but seems it will keep looping my getlocalvideo function.

johache commented 7 years ago

This is not possible with the plugin. Due to the ActiveX/NPAPI we have to use, we cannot interact with a video element. Please use attachMediaStream defined in AJS and see the previous comments.