2022-10-17 11:28:01 +00:00
|
|
|
import { IStateful } from '../base/app/types';
|
|
|
|
import { MEDIA_TYPE } from '../base/media/constants';
|
|
|
|
import { toState } from '../base/redux/functions';
|
2022-11-08 19:15:49 +00:00
|
|
|
import { isLocalTrackMuted } from '../base/tracks/functions';
|
2022-10-17 11:28:01 +00:00
|
|
|
import { addHashParamsToURL } from '../base/util/uri';
|
2022-03-17 14:13:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the current track state to the passed URL.
|
|
|
|
*
|
|
|
|
* @param {URL} url - The URL that will be modified.
|
|
|
|
* @param {Function|Object} stateful - The redux store or {@code getState} function.
|
|
|
|
* @returns {URL} - Returns the modified URL.
|
|
|
|
*/
|
2022-10-17 11:28:01 +00:00
|
|
|
export function addTrackStateToURL(url: string, stateful: IStateful) {
|
2022-03-17 14:13:58 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
const tracks = state['features/base/tracks'];
|
2022-11-08 19:15:49 +00:00
|
|
|
const isVideoMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO);
|
2022-03-17 14:13:58 +00:00
|
|
|
const isAudioMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO);
|
|
|
|
|
|
|
|
return addHashParamsToURL(new URL(url), { // use new URL object in order to not pollute the passed parameter.
|
|
|
|
'config.startWithAudioMuted': isAudioMuted,
|
|
|
|
'config.startWithVideoMuted': isVideoMuted
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|