Skip to content

Commit 70567d1

Browse files
Mofizur Rahmanpardeljeffswartz
authored
DEVX-5442 Add forceMuteStream and forceMuteAll (#205)
* add muteall feature and unit test * add license for MuteAllProperties * add javadoc for MuteAllProperties * Docs edits * update muteall streamid * Update src/main/java/com/opentok/MuteAllProperties.java Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com> * Update src/main/java/com/opentok/OpenTok.java Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com> * add active in MuteAllProperties * remove active flag add active = false in forceMuteAll add active = true in disableForceMute * Docs edits for fore mute API * update license year * optimize imports Co-authored-by: Paul Ardeleanu <paul.ardeleanu@vonage.com> Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>
1 parent 173f567 commit 70567d1

File tree

5 files changed

+463
-118
lines changed

5 files changed

+463
-118
lines changed

README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55

66
<img src="https://assets.tokbox.com/img/vonage/Vonage_VideoAPI_black.svg" height="48px" alt="Tokbox is now known as Vonage" />
77

8-
The OpenTok Java SDK lets you generate
9-
[sessions](https://tokbox.com/developer/guides/create-session/) and
10-
[tokens](https://tokbox.com/developer/guides/create-token/) for
11-
[OpenTok](http://www.tokbox.com/) applications that run on the JVM. It also includes methods for
12-
working with OpenTok [archives](https://tokbox.com/developer/guides/archiving),
13-
working with OpenTok [live streaming
14-
broadcasts](https://tokbox.com/developer/guides/broadcast/live-streaming/),
15-
working with OpenTok [SIP interconnect](https://tokbox.com/developer/guides/sip),
16-
[signaling OpenTok sessions from the server](https://tokbox.com/developer/guides/signaling/),
17-
and [disconnecting clients from sessions](https://tokbox.com/developer/guides/moderation/rest/).
8+
The OpenTok Java SDK provides methods for:
9+
10+
* Generating [sessions](https://tokbox.com/developer/guides/create-session/) and
11+
[tokens](https://tokbox.com/developer/guides/create-token/) for
12+
[OpenTok](https://www.vonage.com/communications-apis/video/) applications
13+
* Working with OpenTok [archives](https://tokbox.com/developer/guides/archiving)
14+
* Working with OpenTok [live streaming broadcasts](https://tokbox.com/developer/guides/broadcast/live-streaming/)
15+
* Working with OpenTok [SIP interconnect](https://tokbox.com/developer/guides/sip)
16+
* [Sending signals to clients connected to a session](https://tokbox.com/developer/guides/signaling/)
17+
* [Disconnecting clients from sessions](https://tokbox.com/developer/guides/moderation/rest/)
18+
* [Forcing clients in a session to disconnect or mute published audio](https://tokbox.com/developer/guides/moderation/)
1819

1920
## Installation
2021

@@ -366,6 +367,19 @@ The `connectionId` parameter is used to specify the connection ID of a client co
366367

367368
For more information on the force disconnect functionality and exception codes, please see the [REST API documentation](https://tokbox.com/developer/rest/#forceDisconnect).
368369

370+
### Forcing clients in a session to mute published audio
371+
372+
You can force the publisher of a specific stream to stop publishing audio using the
373+
`Opentok.forceMuteStream(String sessionId, String streamId)`method.
374+
375+
You can force the publisher of all streams in a session (except for an optional list of streams)
376+
to stop publishing audio using the `Opentok.forceMuteAll(String sessionId, MuteAllProperties properties)`
377+
method. You can then disable the mute state of the session by calling the
378+
`Opentok.disableForceMute(String sessionId)` method.
379+
380+
For more information, see
381+
[Muting the audio of streams in a session](https://tokbox.com/developer/guides/moderation/#force_mute).
382+
369383
### Signaling
370384

371385
You can send signals to all the connections in a session or to a specific connection:
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* OpenTok Java SDK
3+
* Copyright (C) 2022 Vonage.
4+
* http://www.tokbox.com
5+
*
6+
* Licensed under The MIT License (MIT). See LICENSE file for more information.
7+
*/
8+
package com.opentok;
9+
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
import java.util.stream.Collectors;
13+
14+
/**
15+
* Defines values for the <code>properties</code> parameter of the
16+
* {@link OpenTok#forceMuteAll(String, MuteAllProperties)} method.
17+
*
18+
* @see OpenTok#forceMuteAll(String, MuteAllProperties)
19+
*/
20+
public class MuteAllProperties {
21+
private List<String> excludedStreamIds;
22+
23+
private MuteAllProperties(MuteAllProperties.Builder builder) {
24+
this.excludedStreamIds = builder.excludedStreamIds;
25+
}
26+
27+
/**
28+
* Use this class to create a MuteAllProperties object.
29+
*
30+
* @see MuteAllProperties
31+
*/
32+
public static class Builder {
33+
private List<String> excludedStreamIds = new ArrayList<>();
34+
35+
/**
36+
* Call this method to add a List of stream IDs for streams to be excluded
37+
* from the force mute action.
38+
*
39+
* @param ids The List of stream IDs.
40+
*
41+
* @return The MuteAllProperties.Builder object with excludedStreamIds list.
42+
*/
43+
public MuteAllProperties.Builder excludedStreamIds(List<String> ids) {
44+
this.excludedStreamIds.addAll(ids);
45+
return this;
46+
}
47+
48+
/**
49+
* Builds the MuteAllProperties object.
50+
*
51+
* @return The MuteAllProperties object.
52+
*/
53+
public MuteAllProperties build() {
54+
return new MuteAllProperties(this);
55+
}
56+
}
57+
58+
/**
59+
* Returns the excludedStreams list. This is a list of stream IDs for
60+
* streams to be excluded from the force mute action.
61+
*
62+
* @return The list of stream IDs.
63+
*/
64+
public List<String> getExcludedStreamIds() {
65+
return this.excludedStreamIds;
66+
}
67+
}

0 commit comments

Comments
 (0)