Bug 1106941 - Part 2. Firefox Hello doesn't work properly when no video camera is installed - fix incoming conversations. r=mikedeboer

This commit is contained in:
Mark Banner 2015-03-09 23:42:08 +00:00
Родитель ee86ece308
Коммит d624a877f8
8 изменённых файлов: 121 добавлений и 4 удалений

Просмотреть файл

@ -66,6 +66,7 @@ loop.conversation = (function(mozL10n) {
client: this.props.client,
conversation: this.props.conversation,
sdk: this.props.sdk,
isDesktop: true,
conversationAppStore: this.props.conversationAppStore}
));
}

Просмотреть файл

@ -66,6 +66,7 @@ loop.conversation = (function(mozL10n) {
client={this.props.client}
conversation={this.props.conversation}
sdk={this.props.sdk}
isDesktop={true}
conversationAppStore={this.props.conversationAppStore}
/>);
}

Просмотреть файл

@ -347,10 +347,17 @@ loop.conversationViews = (function(mozL10n) {
conversation: React.PropTypes.instanceOf(sharedModels.ConversationModel)
.isRequired,
sdk: React.PropTypes.object.isRequired,
isDesktop: React.PropTypes.bool,
conversationAppStore: React.PropTypes.instanceOf(
loop.store.ConversationAppStore).isRequired
},
getDefaultProps: function() {
return {
isDesktop: false
};
},
getInitialState: function() {
return {
callFailed: false, // XXX this should be removed when bug 1047410 lands.
@ -403,6 +410,7 @@ loop.conversationViews = (function(mozL10n) {
return (
React.createElement(sharedViews.ConversationView, {
isDesktop: this.props.isDesktop,
initiate: true,
sdk: this.props.sdk,
model: this.props.conversation,

Просмотреть файл

@ -347,10 +347,17 @@ loop.conversationViews = (function(mozL10n) {
conversation: React.PropTypes.instanceOf(sharedModels.ConversationModel)
.isRequired,
sdk: React.PropTypes.object.isRequired,
isDesktop: React.PropTypes.bool,
conversationAppStore: React.PropTypes.instanceOf(
loop.store.ConversationAppStore).isRequired
},
getDefaultProps: function() {
return {
isDesktop: false
};
},
getInitialState: function() {
return {
callFailed: false, // XXX this should be removed when bug 1047410 lands.
@ -403,6 +410,7 @@ loop.conversationViews = (function(mozL10n) {
return (
<sharedViews.ConversationView
isDesktop={this.props.isDesktop}
initiate={true}
sdk={this.props.sdk}
model={this.props.conversation}

Просмотреть файл

@ -251,12 +251,14 @@ loop.shared.views = (function(_, l10n) {
sdk: React.PropTypes.object.isRequired,
video: React.PropTypes.object,
audio: React.PropTypes.object,
initiate: React.PropTypes.bool
initiate: React.PropTypes.bool,
isDesktop: React.PropTypes.bool
},
getDefaultProps: function() {
return {
initiate: true,
isDesktop: false,
video: {enabled: true, visible: true},
audio: {enabled: true, visible: true}
};
@ -271,6 +273,23 @@ loop.shared.views = (function(_, l10n) {
componentDidMount: function() {
if (this.props.initiate) {
/**
* XXX This is a workaround for desktop machines that do not have a
* camera installed. As we don't yet have device enumeration, when
* we do, this can be removed (bug 1138851), and the sdk should handle it.
*/
if (this.props.isDesktop &&
!window.MediaStreamTrack.getSources) {
// If there's no getSources function, the sdk defines its own and caches
// the result. So here we define the "normal" one which doesn't get cached, so
// we can change it later.
window.MediaStreamTrack.getSources = function(callback) {
callback([{kind: "audio"}, {kind: "video"}]);
};
}
this.listenTo(this.props.sdk, "exception", this._handleSdkException.bind(this));
this.listenTo(this.props.model, "session:connected",
this._onSessionConnected);
this.listenTo(this.props.model, "session:stream-created",
@ -317,6 +336,35 @@ loop.shared.views = (function(_, l10n) {
}));
},
/**
* Handles the SDK Exception event.
*
* https://tokbox.com/opentok/libraries/client/js/reference/ExceptionEvent.html
*
* @param {ExceptionEvent} event
*/
_handleSdkException: function(event) {
/**
* XXX This is a workaround for desktop machines that do not have a
* camera installed. As we don't yet have device enumeration, when
* we do, this can be removed (bug 1138851), and the sdk should handle it.
*/
if (this.publisher &&
event.code === OT.ExceptionCodes.UNABLE_TO_PUBLISH &&
event.message === "GetUserMedia" &&
this.state.video.enabled) {
this.state.video.enabled = false;
window.MediaStreamTrack.getSources = function(callback) {
callback([{kind: "audio"}]);
};
this.stopListening(this.publisher);
this.publisher.destroy();
this.startPublishing();
}
},
/**
* Publishes remote streams available once a session is connected.
*

Просмотреть файл

@ -251,12 +251,14 @@ loop.shared.views = (function(_, l10n) {
sdk: React.PropTypes.object.isRequired,
video: React.PropTypes.object,
audio: React.PropTypes.object,
initiate: React.PropTypes.bool
initiate: React.PropTypes.bool,
isDesktop: React.PropTypes.bool
},
getDefaultProps: function() {
return {
initiate: true,
isDesktop: false,
video: {enabled: true, visible: true},
audio: {enabled: true, visible: true}
};
@ -271,6 +273,23 @@ loop.shared.views = (function(_, l10n) {
componentDidMount: function() {
if (this.props.initiate) {
/**
* XXX This is a workaround for desktop machines that do not have a
* camera installed. As we don't yet have device enumeration, when
* we do, this can be removed (bug 1138851), and the sdk should handle it.
*/
if (this.props.isDesktop &&
!window.MediaStreamTrack.getSources) {
// If there's no getSources function, the sdk defines its own and caches
// the result. So here we define the "normal" one which doesn't get cached, so
// we can change it later.
window.MediaStreamTrack.getSources = function(callback) {
callback([{kind: "audio"}, {kind: "video"}]);
};
}
this.listenTo(this.props.sdk, "exception", this._handleSdkException.bind(this));
this.listenTo(this.props.model, "session:connected",
this._onSessionConnected);
this.listenTo(this.props.model, "session:stream-created",
@ -317,6 +336,35 @@ loop.shared.views = (function(_, l10n) {
}));
},
/**
* Handles the SDK Exception event.
*
* https://tokbox.com/opentok/libraries/client/js/reference/ExceptionEvent.html
*
* @param {ExceptionEvent} event
*/
_handleSdkException: function(event) {
/**
* XXX This is a workaround for desktop machines that do not have a
* camera installed. As we don't yet have device enumeration, when
* we do, this can be removed (bug 1138851), and the sdk should handle it.
*/
if (this.publisher &&
event.code === OT.ExceptionCodes.UNABLE_TO_PUBLISH &&
event.message === "GetUserMedia" &&
this.state.video.enabled) {
this.state.video.enabled = false;
window.MediaStreamTrack.getSources = function(callback) {
callback([{kind: "audio"}]);
};
this.stopListening(this.publisher);
this.publisher.destroy();
this.startPublishing();
}
},
/**
* Publishes remote streams available once a session is connected.
*

Просмотреть файл

@ -344,7 +344,8 @@ describe("loop.shared.views", function() {
}, Backbone.Events);
fakeSDK = {
initPublisher: sandbox.stub().returns(fakePublisher),
initSession: sandbox.stub().returns(fakeSession)
initSession: sandbox.stub().returns(fakeSession),
on: sandbox.stub()
};
model = new sharedModels.ConversationModel(fakeSessionData, {
sdk: fakeSDK

Просмотреть файл

@ -126,7 +126,9 @@ describe("loop.webapp", function() {
client: client,
conversation: conversation,
notifications: notifications,
sdk: {},
sdk: {
on: sandbox.stub()
},
dispatcher: dispatcher
});
});