Skip to content

Commit

Permalink
Merge pull request #104 from AgoraIO-Community/revert-94-main
Browse files Browse the repository at this point in the history
Revert "Unmuting now publish track if not already publishing"
  • Loading branch information
icywind authored Jun 17, 2022
2 parents 9ea2d09 + 8963816 commit 03970eb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class AgoraChannel {
const vad = 0;
const channel_str = this.channelId;
result.forEach(function (volume, index) {
//console.log(`${index} UID ${volume.uid} Level ${volume.level}`);
console.log(`${index} UID ${volume.uid} Level ${volume.level}`);

if (volume.level > total) {
total = volume.level;
Expand Down Expand Up @@ -280,8 +280,9 @@ class AgoraChannel {
if (this.client_role === 1 && this.videoEnabled) {
await this.setupLocalVideoTrack();
if (localTracks.videoTrack != undefined) {
await this.client.publish(localTracks.videoTrack);
localTracks.videoTrack.play("local-player");
}
await this.client.publish(localTracks.videoTrack);
this.is_publishing = true;
}

Expand Down Expand Up @@ -607,14 +608,8 @@ class AgoraChannel {
await this.client.unpublish(localTracks.audioTrack);
}
} else {
if(localTracks.audioTrack) {
if (localTracks.audioTrack) {
await this.client.publish(localTracks.audioTrack);
} else {
await this.setupLocalAudioTrack();
if (localTracks.audioTrack != undefined) {
await this.client.publish(localTracks.audioTrack);
}
this.is_publishing = true;
}
}
this.audioEnabled = !mute;
Expand All @@ -634,15 +629,16 @@ class AgoraChannel {
AgoraRTC.createCameraVideoTrack(),
]);
localTracks.videoTrack.play("local-player");
this.is_publishing = true;
await this.client.publish(localTracks.videoTrack);
if (this.is_publishing) {
await this.client.publish(localTracks.videoTrack);
}
}
this.videoEnabled = !mute;
}
}

muteRemoteAudioStream(uid, mute) {
Object.keys(this.remoteUsers).forEach((uid2) => {

if (uid2 == uid) {
if (mute == true) {
this.unsubscribe(this.remoteUsers[uid], "audio");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,17 +435,34 @@ class ClientManager {
// Help function for JoinChannel
async processJoinChannelAVTrack() {
if (this.videoEnabled && this.isHosting()) {
await this.setupLocalVideoTrack();
[localTracks.videoTrack] = await Promise.all([
AgoraRTC.createCameraVideoTrack(this._customVideoConfiguration)
]);
currentVideoDevice = wrapper.getCameraDeviceIdFromDeviceName(
localTracks.videoTrack._deviceName
);
}

if (this.audioEnabled && this.isHosting()) {
await this.setupLocalAudioTrack();
[localTracks.audioTrack] = await Promise.all([
AgoraRTC.createMicrophoneAudioTrack()
]);
currentAudioDevice = wrapper.getMicrophoneDeviceIdFromDeviceName(
localTracks.audioTrack._deviceName
);
}

event_manager.raiseGetCurrentVideoDevice();
event_manager.raiseGetCurrentAudioDevice();
event_manager.raiseGetCurrentPlayBackDevice();

// videoTrack exists implies videoEnabled
if (localTracks.videoTrack) {
localTracks.videoTrack.play("local-player", {
fit: "cover",
mirror: mlocal,
});
}

$("#local-player-name").text(`localVideo(${this.options.uid})`);
if (this.isHosting() && this._inChannel) {
for (var trackName in localTracks) {
Expand All @@ -457,32 +474,6 @@ class ClientManager {
}
}

async setupLocalVideoTrack(){
[localTracks.videoTrack] = await Promise.all([
AgoraRTC.createCameraVideoTrack(this._customVideoConfiguration)
]);
currentVideoDevice = wrapper.getCameraDeviceIdFromDeviceName(
localTracks.videoTrack._deviceName
);

// videoTrack exists implies videoEnabled
if (localTracks.videoTrack) {
localTracks.videoTrack.play("local-player", {
fit: "cover",
mirror: mlocal,
});
}
}

async setupLocalAudioTrack(){
[localTracks.audioTrack] = await Promise.all([
AgoraRTC.createMicrophoneAudioTrack()
]);
currentAudioDevice = wrapper.getMicrophoneDeviceIdFromDeviceName(
localTracks.audioTrack._deviceName
);
}

async setClientRole(role, optionLevel) {
if (this.client) {
var wasAudience = (this.client_role == 2);
Expand Down Expand Up @@ -524,22 +515,12 @@ class ClientManager {
// can still be on
// if wanting both off, call disableLocalVideo
async muteLocalVideoStream(mute) {
if (this.client && !this.is_screensharing) {
if (localTracks.videoTrack) {
if (mute) {
if (localTracks.videoTrack) {
localTracks.videoTrack.stop();
localTracks.videoTrack.close();
await this.client.unpublish(localTracks.videoTrack);
}
await this.client.unpublish(localTracks.videoTrack);
} else {
if (localTracks.videoTrack) {
await this.client.publish(localTracks.videoTrack);
} else {
await this.setupLocalVideoTrack();
await this.client.publish(localTracks.videoTrack);
}
await this.client.publish(localTracks.videoTrack);
}
this.videoEnabled = !mute;
}
}

Expand All @@ -551,12 +532,8 @@ class ClientManager {
} else {
if (localTracks.audioTrack) {
await this.client.publish(localTracks.audioTrack);
} else {
await this.setupLocalAudioTrack();
await this.client.publish(localTracks.audioTrack);
}
}
this.audioEnabled = !mute;
}

async enableLocalVideo(enabled) {
Expand Down Expand Up @@ -1026,4 +1003,4 @@ class ClientManager {
event_manager.raiseOnClientVideoSizeChanged(uid, width, height);
});
}
}
}

0 comments on commit 03970eb

Please sign in to comment.