Skip to content

Commit 914e1bf

Browse files
committed
- Extended CastDeviceCapability and created DeviceType
- Corrected JavaDoc and reduced thread idle timeout
1 parent afd5f68 commit 914e1bf

3 files changed

Lines changed: 89 additions & 5 deletions

File tree

src/main/java/org/digitalmediaserver/cast/CastDevice.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ public void disconnect() throws IOException {
598598
}
599599

600600
/**
601-
* @return {@code true} if the associated {@link Channel} is closed,
602-
* {@code false} if it's open.
601+
* @return {@code true} if the associated {@link Channel} is open,
602+
* {@code false} if it's closed.
603603
*/
604604
public boolean isConnected() {
605605
return !channel.isClosed();
@@ -1095,7 +1095,7 @@ protected static ExecutorService createExecutor() {
10951095
ThreadPoolExecutor result = new ThreadPoolExecutor(
10961096
0,
10971097
Integer.MAX_VALUE,
1098-
300L,
1098+
60L,
10991099
TimeUnit.SECONDS,
11001100
new SynchronousQueue<Runnable>(true),
11011101
new ThreadFactory() {

src/main/java/org/digitalmediaserver/cast/CastDeviceCapability.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,26 @@ public enum CastDeviceCapability {
4545
/** The cast device supports or is in (?) development mode */
4646
DEV_MODE(1 << 4),
4747

48-
/** The cast device supports multizone groups */
49-
MULTIZONE_GROUP(1 << 5);
48+
/** The device is a multizone group */
49+
MULTIZONE_GROUP(1 << 5),
50+
51+
/** The device is a dynamic group */
52+
DYNAMIC_GROUP(1 << 6),
53+
54+
/** The device is a multichannel group */
55+
MULTI_CHANNEL_GROUP(1 << 7),
56+
57+
/** The device is a multichannel member */
58+
MULTI_CHANNEL_MEMBER(1 << 8),
59+
60+
/** The device has master or fixed volume mode capability */
61+
MASTER_OR_FIXED_VOLUME(1 << 11),
62+
63+
/** The device has attenuation or fixed volume mode capability */
64+
ATTENUATION_OR_FIXED_VOLUME(1 << 12),
65+
66+
/** The device can be part of a dynamic group */
67+
DYNAMIC_GROUPING_SUPPORTED(1 << 16);
5068

5169
private final int mask;
5270

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (C) 2025 Digital Media Server developers.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.digitalmediaserver.cast.message.enumeration;
17+
18+
import java.util.Locale;
19+
import javax.annotation.Nullable;
20+
import org.digitalmediaserver.cast.util.Util;
21+
import com.fasterxml.jackson.annotation.JsonCreator;
22+
23+
/**
24+
* This represents the type of cast device.
25+
*
26+
* @author Nadahar
27+
*/
28+
public enum DeviceType {
29+
30+
/** Generic Cast device */
31+
GENERIC,
32+
33+
/** Cast-enabled TV */
34+
TV,
35+
36+
/** Cast-enabled speaker or other audio device */
37+
SPEAKER,
38+
39+
/** Speaker group */
40+
SPEAKER_GROUP,
41+
42+
/** The "Nearby Devices" pseudo-device, which represents any nearby unpaired guest-mode devices */
43+
NEARBY_UNPAIRED;
44+
45+
/**
46+
* Parses the specified string and returns the corresponding
47+
* {@link DeviceType}, or {@code null} if no match could be found.
48+
*
49+
* @param deviceType the string to parse.
50+
* @return The resulting {@link DeviceType} or {@code null}.
51+
*/
52+
@Nullable
53+
@JsonCreator
54+
public static DeviceType typeOf(String deviceType) {
55+
if (Util.isBlank(deviceType)) {
56+
return null;
57+
}
58+
String typeString = deviceType.toUpperCase(Locale.ROOT).replace(' ', '_');
59+
for (DeviceType type : values()) {
60+
if (typeString.equals(type.name())) {
61+
return type;
62+
}
63+
}
64+
return null;
65+
}
66+
}

0 commit comments

Comments
 (0)