Skip to content

Commit

Permalink
fix: conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed Feb 26, 2024
2 parents 4ed9db2 + b7d5e76 commit ae25146
Show file tree
Hide file tree
Showing 31 changed files with 441 additions and 187 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/alpha-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Publish and deploy alpha versions

on:
push:
branches:
- publish-alpha

jobs:
bump_versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git user
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
- name: Install packages
run: yarn install --frozen-lockfile

- name: Update versions
env:
BUMP: ${{ github.event.inputs.versionBump }}
run: |
yarn global add lerna@5
lerna -v
echo $(lerna version $BUMP --no-git-tag-version --exact --yes --no-private)
lerna add @100mslive/hms-video-store --peer --scope=@100mslive/hms-virtual-background --exact
lerna add @100mslive/roomkit-react --scope=prebuilt-react-integration --exact
- name: Commit and push changes
run: |
git add .
git commit -m "build: update versions for release"
git push origin HEAD:publish-alpha
publish_packages:
runs-on: ubuntu-latest
needs: bump_versions
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Install packages
run: yarn install

- name: Test
run: yarn test

- name: Configure Git user
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
# from-package will publish whatever version is present in each package's package.json
# it will not publish if the version is already published in npm
- name: Publish
run: yarn lerna:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_FLAG: alpha

# Delay to wait for the publish to finish
- name: Delay for 2 minutes
run: sleep 120

- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT }}
repository: 100mslive/100ms-links
event-type: alpha-publish

22 changes: 22 additions & 0 deletions .github/workflows/sync-alpha-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Update publish-alpha
on:
pull_request:
types: [closed]
branches:
- main

jobs:
pull-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: pull-request
uses: repo-sync/pull-request@v2
if: github.event.pull_request.merged == true
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: 'main'
destination_branch: 'publish-alpha'
pr_title: 'Update publish-alpha'
pr_body: ':robot: Automated PR from main to publish-alpha'
pr_label: 'auto-pr'
2 changes: 1 addition & 1 deletion examples/prebuilt-react-integration/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hls-player/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hls-stats/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hms-video-store/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export class AudioSinkManager {
private volume = 100;
private state = { ...INITIAL_STATE };
private listener?: HMSUpdateListener;
private timer: ReturnType<typeof setInterval> | null = null;

constructor(private store: Store, private deviceManager: DeviceManager, private eventBus: EventBus) {
this.eventBus.audioTrackAdded.subscribe(this.handleTrackAdd);
this.eventBus.audioTrackRemoved.subscribe(this.handleTrackRemove);
this.eventBus.audioTrackUpdate.subscribe(this.handleTrackUpdate);
this.eventBus.deviceChange.subscribe(this.handleAudioDeviceChange);
this.startPollingForDevices();
}

setListener(listener?: HMSUpdateListener) {
Expand Down Expand Up @@ -93,6 +95,10 @@ export class AudioSinkManager {
cleanup() {
this.audioSink?.remove();
this.audioSink = undefined;
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
this.eventBus.audioTrackAdded.unsubscribe(this.handleTrackAdd);
this.eventBus.audioTrackRemoved.unsubscribe(this.handleTrackRemove);
this.eventBus.audioTrackUpdate.unsubscribe(this.handleTrackUpdate);
Expand Down Expand Up @@ -261,6 +267,19 @@ export class AudioSinkManager {
}
};

private startPollingForDevices = () => {
// device change supported, no polling needed
if ('ondevicechange' in navigator.mediaDevices) {
return;
}
this.timer = setInterval(() => {
(async () => {
await this.deviceManager.init(true);
await this.autoSelectAudioOutput();
})();
}, 5000);
};

/**
* Mweb is not able to play via call channel by default, this is to switch from media channel to call channel
*/
Expand Down Expand Up @@ -288,9 +307,14 @@ export class AudioSinkManager {
}
const localAudioTrack = this.store.getLocalPeer()?.audioTrack;
if (localAudioTrack && earpiece) {
const externalDeviceID = bluetoothDevice?.deviceId || wired?.deviceId || speakerPhone?.deviceId;
// already selected appropriate device
if (localAudioTrack.settings.deviceId === externalDeviceID) {
return;
}
await localAudioTrack.setSettings({ deviceId: earpiece?.deviceId });
await localAudioTrack.setSettings({
deviceId: bluetoothDevice?.deviceId || wired?.deviceId || speakerPhone?.deviceId,
deviceId: externalDeviceID,
});
}
}
Expand Down
20 changes: 20 additions & 0 deletions packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { HMSMediaStreamPlugin, HMSVideoPluginsManager } from '../../plugins/vide
import { HMSMediaStreamPluginsManager } from '../../plugins/video/HMSMediaStreamPluginsManager';
import { LocalTrackManager } from '../../sdk/LocalTrackManager';
import HMSLogger from '../../utils/logger';
import { isBrowser, isMobile } from '../../utils/support';
import { getVideoTrack, isEmptyTrack } from '../../utils/track';
import { HMSVideoTrackSettings, HMSVideoTrackSettingsBuilder } from '../settings';
import { HMSLocalStream } from '../streams';
Expand All @@ -36,6 +37,7 @@ export class HMSLocalVideoTrack extends HMSVideoTrack {
private processedTrack?: MediaStreamTrack;
private _layerDefinitions: HMSSimulcastLayerDefinition[] = [];
private TAG = '[HMSLocalVideoTrack]';
private enabledStateBeforeBackground = false;

/**
* true if it's screenshare and current tab is what is being shared. Browser dependent, Chromium only
Expand Down Expand Up @@ -80,6 +82,9 @@ export class HMSLocalVideoTrack extends HMSVideoTrack {
this.pluginsManager = new HMSVideoPluginsManager(this, eventBus);
this.mediaStreamPluginsManager = new HMSMediaStreamPluginsManager(eventBus);
this.setFirstTrackId(this.trackId);
if (isBrowser && isMobile()) {
document.addEventListener('visibilitychange', this.handleVisibilityChange);
}
}

/** @internal */
Expand Down Expand Up @@ -232,6 +237,9 @@ export class HMSLocalVideoTrack extends HMSVideoTrack {
await this.pluginsManager.cleanup();
this.processedTrack?.stop();
this.isPublished = false;
if (isBrowser && isMobile()) {
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
}
}

/**
Expand Down Expand Up @@ -477,4 +485,16 @@ export class HMSLocalVideoTrack extends HMSVideoTrack {
}
await this.replaceSenderTrack(this.processedTrack || this.nativeTrack);
};

private handleVisibilityChange = async () => {
if (document.visibilityState === 'hidden' && this.source === 'regular') {
this.enabledStateBeforeBackground = this.enabled;
this.nativeTrack.enabled = false;
this.replaceSenderTrack(this.nativeTrack);
} else {
this.nativeTrack.enabled = this.enabledStateBeforeBackground;
this.replaceSenderTrack(this.nativeTrack);
}
this.eventBus.localVideoEnabled.publish({ enabled: this.nativeTrack.enabled, track: this });
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HMSAction } from '../../error/HMSAction';
import { EventBus } from '../../events/EventBus';
import { HMSLocalVideoTrack } from '../../media/tracks';
import HMSLogger from '../../utils/logger';
import { workerSleep } from '../../utils/timer-utils';
import { reusableWorker, workerSleep } from '../../utils/timer-utils';
import { HMSPluginUnsupportedTypes } from '../audio';

const DEFAULT_FRAME_RATE = 24;
Expand Down Expand Up @@ -57,6 +57,7 @@ export class HMSVideoPluginsManager {
private pluginNumFramesToSkip: Record<string, number>;
private pluginNumFramesSkipped: Record<string, number>;
private canvases: Array<CanvasElement>; //array of canvases to store intermediate result
private reusableWorker = reusableWorker();

constructor(track: HMSLocalVideoTrack, eventBus: EventBus) {
this.hmsTrack = track;
Expand Down Expand Up @@ -288,7 +289,7 @@ export class HMSVideoPluginsManager {
this.resetCanvases();
}
this.pluginsLoopState = 'paused';
await workerSleep(sleepTimeMs);
await this.reusableWorker.sleep(sleepTimeMs);
continue;
}
let processingTime = 0;
Expand All @@ -306,7 +307,7 @@ export class HMSVideoPluginsManager {
}
this.pluginsLoopState = 'running';
// take into account processing time to decide time to wait for the next loop
await workerSleep(sleepTimeMs - processingTime);
await this.reusableWorker.sleep(sleepTimeMs - processingTime);
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/hms-video-store/src/reactive-store/HMSSDKActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,9 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
mergeNewPeersInDraft(draftPeers, newHmsPeers);
mergeNewTracksInDraft(draftTracks, newHmsTracks);
Object.assign(draftStore.settings, newMediaSettings);
Object.assign(draftStore.connectionQualities, newNetworkQuality);
if (draftStore.room.isConnected) {
Object.assign(draftStore.connectionQualities, newNetworkQuality);
}

/**
* if preview is already present merge,
Expand Down
23 changes: 22 additions & 1 deletion packages/hms-video-store/src/utils/timer-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const worker = `(function metronomeWorkerSetup() {
export const worker = `(function workerSetup() {
function ticker() {
self.postMessage('tick');
}
Expand Down Expand Up @@ -47,6 +47,27 @@ export function workerSleep(ms: number): Promise<void> {
});
}

export function reusableWorker() {
if (typeof Worker === 'undefined') {
return {
sleep: (ms: number) => sleep(ms),
};
}
const WorkerThread = new Worker(URL.createObjectURL(new Blob([worker], { type: 'application/javascript' })));
return {
sleep: (ms: number) => {
WorkerThread.postMessage(['start', ms]);
return new Promise<void>(resolve => {
WorkerThread.onmessage = event => {
if (event.data === 'tick') {
resolve();
}
};
});
},
};
}

/**
* Debounce Fn - Function to limit the number of executions of the passed in
* function in a given time duration
Expand Down
6 changes: 3 additions & 3 deletions packages/hms-virtual-background/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/react-icons/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/react-sdk/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ae25146

Please sign in to comment.