feat(SS): pass the source type to lib-jitsi-meet.

This commit is contained in:
hristoterezov 2017-07-07 17:45:24 -05:00
parent 2968f8edf8
commit 1a9a8a2098
4 changed files with 50 additions and 15 deletions

View File

@ -2129,5 +2129,17 @@ export default {
*/ */
getDesktopSharingSourceId() { getDesktopSharingSourceId() {
return localVideo.sourceId; return localVideo.sourceId;
},
/**
* Returns the desktop sharing source type or undefined if the desktop
* sharing is not active at the moment.
*
* @returns {'screen'|'window'|undefined} - The source type. If the track is
* not desktop track or the source type is not available, undefined will be
* returned.
*/
getDesktopSharingSourceType() {
return localVideo.sourceType;
} }
}; };

View File

@ -85,7 +85,7 @@ class DesktopPicker extends Component {
super(props); super(props);
this.state = { this.state = {
selectedSourceId: '' selectedSource: {}
}; };
this._poller = null; this._poller = null;
@ -116,10 +116,13 @@ class DesktopPicker extends Component {
* @returns {void} * @returns {void}
*/ */
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if (!this.state.selectedSourceId if (!this.state.selectedSource.id
&& nextProps.sources.screen.length) { && nextProps.sources.screen.length) {
this.setState({ this.setState({
selectedSourceId: nextProps.sources.screen[0].id selectedSource: {
id: nextProps.sources.screen[0].id,
type: 'screen'
}
}); });
} }
} }
@ -155,14 +158,16 @@ class DesktopPicker extends Component {
/** /**
* Dispatches an action to hide the DesktopPicker and invokes the passed in * Dispatches an action to hide the DesktopPicker and invokes the passed in
* callback with a selectedSourceId, if any. * callback with a selectedSource, if any.
* *
* @param {string} id - The id of the DesktopCapturerSource to pass into the * @param {string} id - The id of the DesktopCapturerSource to pass into the
* onSourceChoose callback. * onSourceChoose callback.
* @param {string} type - The type of the DesktopCapturerSource to pass into
* the onSourceChoose callback.
* @returns {void} * @returns {void}
*/ */
_onCloseModal(id = '') { _onCloseModal(id, type) {
this.props.onSourceChoose(id); this.props.onSourceChoose(id, type);
this.props.dispatch(hideDialog()); this.props.dispatch(hideDialog());
} }
@ -170,10 +175,16 @@ class DesktopPicker extends Component {
* Sets the currently selected DesktopCapturerSource. * Sets the currently selected DesktopCapturerSource.
* *
* @param {string} id - The id of DesktopCapturerSource. * @param {string} id - The id of DesktopCapturerSource.
* @param {string} type - The type of DesktopCapturerSource.
* @returns {void} * @returns {void}
*/ */
_onPreviewClick(id) { _onPreviewClick(id, type) {
this.setState({ selectedSourceId: id }); this.setState({
selectedSource: {
id,
type
}
});
} }
/** /**
@ -183,7 +194,9 @@ class DesktopPicker extends Component {
* @returns {void} * @returns {void}
*/ */
_onSubmit() { _onSubmit() {
this._onCloseModal(this.state.selectedSourceId); const { id, type } = this.state.selectedSource;
this._onCloseModal(id, type);
} }
/** /**
@ -193,7 +206,7 @@ class DesktopPicker extends Component {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
_renderTabs() { _renderTabs() {
const { selectedSourceId } = this.state; const { selectedSource } = this.state;
const { sources, t } = this.props; const { sources, t } = this.props;
const tabs const tabs
= TABS_TO_POPULATE.map(({ defaultSelected, label, type }) => { = TABS_TO_POPULATE.map(({ defaultSelected, label, type }) => {
@ -202,7 +215,7 @@ class DesktopPicker extends Component {
key = { type } key = { type }
onClick = { this._onPreviewClick } onClick = { this._onPreviewClick }
onDoubleClick = { this._onCloseModal } onDoubleClick = { this._onCloseModal }
selectedSourceId = { selectedSourceId } selectedSourceId = { selectedSource.id }
sources = { sources[type] || [] } sources = { sources[type] || [] }
type = { type } />, type = { type } />,
defaultSelected, defaultSelected,

View File

@ -66,7 +66,8 @@ class DesktopPickerPane extends Component {
onClick = { onClick } onClick = { onClick }
onDoubleClick = { onDoubleClick } onDoubleClick = { onDoubleClick }
selected = { source.id === selectedSourceId } selected = { source.id === selectedSourceId }
source = { source } />); source = { source }
type = { type } />);
return ( return (
<div className = { classNames }> <div className = { classNames }>

View File

@ -34,7 +34,12 @@ class DesktopSourcePreview extends Component {
/** /**
* The DesktopCapturerSource to display. * The DesktopCapturerSource to display.
*/ */
source: React.PropTypes.object source: React.PropTypes.object,
/**
* The source type of the DesktopCapturerSources to display.
*/
type: React.PropTypes.string
}; };
/** /**
@ -83,7 +88,9 @@ class DesktopSourcePreview extends Component {
* @returns {void} * @returns {void}
*/ */
_onClick() { _onClick() {
this.props.onClick(this.props.source.id); const { source, type } = this.props;
this.props.onClick(source.id, type);
} }
/** /**
@ -92,7 +99,9 @@ class DesktopSourcePreview extends Component {
* @returns {void} * @returns {void}
*/ */
_onDoubleClick() { _onDoubleClick() {
this.props.onDoubleClick(this.props.source.id); const { source, type } = this.props;
this.props.onDoubleClick(source.id, type);
} }
} }