Skip to content

Commit

Permalink
allow muting via setting the direction a channel (#1179)
Browse files Browse the repository at this point in the history
* allow muting via setting the direction a channel

supported for audio only, currently

* update JMT version
  • Loading branch information
bbaldino authored Apr 8, 2020
1 parent a31bd71 commit 4cf3ce1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jitsi-media-transform</artifactId>
<version>1.0-139-g33e0a49</version>
<version>1.0-142-g94e1c26</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/jitsi/videobridge/Endpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,27 @@ public void updateAcceptedMediaTypes()
this.acceptVideo = acceptVideo;
}

public void updateForceMute()
{
boolean audioForcedMuted = false;
for (ChannelShim channelShim : channelShims)
{
if (!channelShim.allowIncomingMedia())
{
switch (channelShim.getMediaType())
{
case AUDIO:
audioForcedMuted = true;
break;
case VIDEO:
logger.warn(() -> "Tried to mute the incoming video stream, but that is not currently supported");
break;
}
}
}
transceiver.forceMuteAudio(audioForcedMuted);
}

/**
* @return this {@link Endpoint}'s transceiver.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/jitsi/videobridge/shim/ChannelShim.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,19 @@ public boolean allowsSendingMedia()
"sendonly".equalsIgnoreCase(direction);
}

/**
* Checks if incoming media (from the endpoint to the bridge) is being
* forcibly "muted"
* @return true if media for this channel is allowed, false if it should
* be forcibly "muted" (dropped)
*/
public boolean allowIncomingMedia()
{
return "sendrecv".equalsIgnoreCase(direction) ||
"recvonly".equalsIgnoreCase(direction);

}

/**
* Sets the media direction of this channel.
* @param direction the direction to set.
Expand All @@ -392,6 +405,7 @@ public void setDirection(String direction)
{
this.direction = direction;
this.endpoint.updateAcceptedMediaTypes();
this.endpoint.updateForceMute();
}
}

Expand Down

0 comments on commit 4cf3ce1

Please sign in to comment.