Permalink
Browse files

ref(RTC): add getRemoteTracks method

  • Loading branch information...
paweldomas committed Jan 12, 2017
1 parent 0902fc5 commit 5d1f40eacaaa955a0c0a23e4775b6f39db24d2c6
Showing with 45 additions and 23 deletions.
  1. +5 −5 JitsiConference.js
  2. +40 −18 modules/RTC/RTC.js
View
@@ -16,6 +16,7 @@ import * as JitsiTrackEvents from "./JitsiTrackEvents";
var ComponentsVersions = require("./modules/version/ComponentsVersions");
var GlobalOnErrorHandler = require("./modules/util/GlobalOnErrorHandler");
var JitsiConferenceEventManager = require("./JitsiConferenceEventManager");
import MediaType from "./service/RTC/MediaType";
var VideoType = require('./service/RTC/VideoType');
var RTCBrowserType = require("./modules/RTC/RTCBrowserType.js");
var Transcriber = require("./modules/transcription/transcriber");
@@ -402,12 +403,11 @@ JitsiConference.prototype.getTranscriber = function(){
}
}.bind(this));
//and all remote audio tracks
// FIXME accessing remoteTracks field directly
this.rtc.remoteTracks.forEach(function (remoteTrack){
if(remoteTrack.isAudioTrack()){
this.rtc.getRemoteTracks(MediaType.AUDIO).forEach(
function (remoteTrack) {
this.transcriber.addTrack(remoteTrack);
}
}.bind(this));
}.bind(this)
);
}
return this.transcriber;
};
View
@@ -69,13 +69,10 @@ export default class RTC extends Listenable {
if (RTCUtils.isDeviceChangeAvailable('output')) {
RTCUtils.addListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
(deviceId) => {
for (var key in this.remoteTracks) {
if (this.remoteTracks.hasOwnProperty(key)
&& this.remoteTracks[key].audio) {
this.remoteTracks[key].audio
.setAudioOutput(deviceId);
}
}
this.getRemoteTracks(MediaType.AUDIO).forEach(
function (track) {
track.setAudioOutput(deviceId);
});
});
}
}
@@ -274,6 +271,37 @@ export default class RTC extends Listenable {
return this.localVideo;
}
/**
* Obtains all remote tracks currently known to this RTC module instance.
* @param {MediaType} [mediaType] the remote tracks will be filtered
* by their media type if this argument is specified.
* @return {Array<JitsiRemoteTrack>}
*/
getRemoteTracks (mediaType) {
const remoteTracks = [];
Object.keys(this.remoteTracks).forEach(
function(endpoint) {
const endpointTracks = this.remoteTracks[endpoint];
endpointTracks && Object.keys(endpointTracks).forEach(
function (trackMediaType) {
// per media type filtering
if (mediaType && mediaType !== trackMediaType) {
return;
}
const mediaTrack = endpointTracks[trackMediaType];
if (mediaTrack) {
remoteTracks.push(mediaTrack);
}
});
}, this);
return remoteTracks;
}
/**
* Gets JitsiRemoteTrack for the passed MediaType associated with given MUC
* nickname (resource part of the JID).
@@ -620,19 +648,13 @@ export default class RTC extends Listenable {
* Searches in remoteTracks for the ssrc and returns the corresponding
* track.
* @param ssrc the ssrc to check.
* @return {JitsiRemoteTrack|undefined} return the first remote tracks that
* matches given SSRC or <tt>undefined</tt> if no such track was found.
*/
getRemoteTrackBySSRC (ssrc) {
for (var resource in this.remoteTracks) {
var track = this.getRemoteAudioTrack(resource);
if(track && track.getSSRC() == ssrc) {
return track;
}
track = this.getRemoteVideoTrack(resource);
if(track && track.getSSRC() == ssrc) {
return track;
}
}
return null;
return this.getRemoteTracks().find(function (remoteTrack) {
return ssrc == remoteTrack.getSSRC();
});
}
/**

0 comments on commit 5d1f40e

Please sign in to comment.