Skip to content

Commit

Permalink
✨ Issue #6: Implement missing MediaStreamTrack
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Nov 10, 2017
1 parent a8b1d2c commit cb4ab76
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
39 changes: 39 additions & 0 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@
var cordova = require('./helper/cordova');
var mediaDevices = require('../www/mediadevices');
var MediaStream = require('../www/mediastream');
var MediaStreamTrack = require('../www/mediastreamtrack');

var mockStream = { id: 'ack', audioTracks: [], videoTracks: [] };
var mockTrack = {
kind: 'audio',
id: 'ack',
label: 'Internal microphone',
enabled: true,
muted: false,
readyState: 'live'
};

/*!
* Specification.
Expand Down Expand Up @@ -57,4 +66,34 @@ describe('phonegap-plugin-media-stream', function () {
expect(typeof stream.clone).toBe('function');
});
});

describe('MediaStreamTrack', function () {
it('MediaStreamTrack constructor', function () {
var track = new MediaStreamTrack(mockTrack);

expect(track).toBeDefined();
expect(typeof track).toBe('object');
expect(track.kind).toEqual('audio');
expect(track.id).toEqual('ack');
expect(track.label).toEqual('Internal microphone');
expect(track.enabled).toEqual(true);
expect(track.muted).toEqual(false);
// expect(track.onmute).toEqual('');
// expect(track.onunmute).toEqual('');
// expect(track.onended).toEqual('');
expect(track.readyState).toEqual('live');
expect(track.clone).toBeDefined();
expect(typeof track.clone).toBe('function');
expect(track.stop).toBeDefined();
expect(typeof track.stop).toBe('function');
expect(track.getCapabilities).toBeDefined();
expect(typeof track.getCapabilities).toBe('function');
expect(track.getConstraints).toBeDefined();
expect(typeof track.getConstraints).toBe('function');
expect(track.getSettings).toBeDefined();
expect(typeof track.getSettings).toBe('function');
expect(track.applyConstraints).toBeDefined();
expect(typeof track.applyConstraints).toBe('function');
});
});
});
38 changes: 38 additions & 0 deletions www/mediastreamtrack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

var MediaStreamTrack = function (track) {
this.kind = track.kind;
this.id = track.id;
this.label = track.label;
this.enabled = track.enabled;
this.muted = track.muted;
this.readyState = track.readyState;
};

MediaStreamTrack.prototype.clone = function () {};
MediaStreamTrack.prototype.stop = function () {};
MediaStreamTrack.prototype.getCapabilities = function () {};
MediaStreamTrack.prototype.getConstraints = function () {};
MediaStreamTrack.prototype.getSettings = function () {};
MediaStreamTrack.prototype.applyConstraints = function () {};

module.exports = MediaStreamTrack;

0 comments on commit cb4ab76

Please sign in to comment.