Skip to content

Commit 9fa29ff

Browse files
author
Stasonych
committed
Added additional fields for devices and fixes merge request. It can be useful, for example, if there is a need in the application code to set a priority for selecting a playback device. I also added a patch that fixes an empty device GUID on macOS.
1 parent 645fdfe commit 9fa29ff

File tree

16 files changed

+80
-584
lines changed

16 files changed

+80
-584
lines changed

webrtc-jni/src/main/cpp/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ add_subdirectory(dependencies/jni-voithos)
5050

5151
file(GLOB SOURCES_ROOT "src/*.cpp")
5252
file(GLOB SOURCES_API "src/api/*.cpp")
53+
file(GLOB SOURCES_API_AUDIO "src/api/audio/*.cpp")
5354
file(GLOB SOURCES_MEDIA "src/media/*.cpp")
5455
file(GLOB SOURCES_MEDIA_AUDIO "src/media/audio/*.cpp")
5556
file(GLOB SOURCES_MEDIA_AUDIO_OS "src/media/audio/${SOURCE_TARGET}/*.cpp")
@@ -63,6 +64,7 @@ file(GLOB SOURCES_RTC "src/rtc/*.cpp")
6364
list(APPEND SOURCES
6465
${SOURCES_ROOT}
6566
${SOURCES_API}
67+
${SOURCES_API_AUDIO}
6668
${SOURCES_MEDIA}
6769
${SOURCES_MEDIA_AUDIO}
6870
${SOURCES_MEDIA_AUDIO_OS}

webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,16 @@ if (PATCHES)
237237
message(STATUS "Applying ${PATCH}")
238238

239239
execute_process(
240-
COMMAND patch -p0 --forward
241-
WORKING_DIRECTORY "${WEBRTC_SRC_DIR}"
240+
COMMAND git apply
241+
WORKING_DIRECTORY "${WEBRTC_SRC}"
242242
INPUT_FILE "${PATCH}"
243243
OUTPUT_VARIABLE OUTPUT
244244
RESULT_VARIABLE RESULT)
245245

246246
if (RESULT EQUAL 0)
247247
message(STATUS "Patch applied: ${PATCH}")
248+
else()
249+
message(STATUS "Warning: Patch ${PATCH} not applied ....")
248250
endif()
249251
endforeach(PATCH)
250252
endif()

webrtc-jni/src/main/cpp/dependencies/webrtc/patches/macos/patch_for_mac_deviceId.patch

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,27 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
66
<+>UTF-8
77
===================================================================
88
diff --git a/modules/audio_device/mac/audio_device_mac.cc b/modules/audio_device/mac/audio_device_mac.cc
9-
--- a/modules/audio_device/mac/audio_device_mac.cc (revision d75b9e9ff07ee42841b4e416629c9fbd4b058905)
10-
+++ b/modules/audio_device/mac/audio_device_mac.cc (date 1696335540383)
11-
@@ -831,9 +831,11 @@
12-
13-
memset(name, 0, kAdmMaxDeviceNameSize);
14-
15-
- if (guid != NULL) {
16-
- memset(guid, 0, kAdmMaxGuidSize);
17-
- }
18-
+ memset(guid, 0, kAdmMaxGuidSize);
19-
+ AudioDeviceID deviceIds[MaxNumberDevices];
20-
+ int numberDevices = GetNumberDevices(kAudioDevicePropertyScopeOutput, deviceIds, MaxNumberDevices);
21-
+ std::string deviceId = std::to_string(deviceIds[index]);
22-
+ deviceId.copy(guid, kAdmMaxGuidSize);
23-
9+
--- a/modules/audio_device/mac/audio_device_mac.cc (revision e4445e46a910eb407571ec0b0b8b7043562678cf)
10+
+++ b/modules/audio_device/mac/audio_device_mac.cc (date 1757498230183)
11+
@@ -834,6 +834,10 @@
12+
13+
if (guid != NULL) {
14+
memset(guid, 0, kAdmMaxGuidSize);
15+
+ AudioDeviceID deviceIds[MaxNumberDevices];
16+
+ int numberDevices = GetNumberDevices(kAudioDevicePropertyScopeOutput, deviceIds, MaxNumberDevices);
17+
+ std::string deviceId = std::to_string(deviceIds[index]);
18+
+ deviceId.copy(guid, kAdmMaxGuidSize);
19+
}
20+
2421
return GetDeviceName(kAudioDevicePropertyScopeOutput, index,
25-
rtc::ArrayView<char>(name, kAdmMaxDeviceNameSize));
26-
@@ -850,9 +852,11 @@
27-
28-
memset(name, 0, kAdmMaxDeviceNameSize);
29-
30-
- if (guid != NULL) {
31-
- memset(guid, 0, kAdmMaxGuidSize);
32-
- }
33-
+ memset(guid, 0, kAdmMaxGuidSize);
34-
+ AudioDeviceID deviceIds[MaxNumberDevices];
35-
+ int numberDevices = GetNumberDevices(kAudioDevicePropertyScopeInput, deviceIds, MaxNumberDevices);
36-
+ std::string deviceId = std::to_string(deviceIds[index]);
37-
+ deviceId.copy(guid, kAdmMaxGuidSize);
38-
22+
@@ -853,6 +857,10 @@
23+
24+
if (guid != NULL) {
25+
memset(guid, 0, kAdmMaxGuidSize);
26+
+ AudioDeviceID deviceIds[MaxNumberDevices];
27+
+ int numberDevices = GetNumberDevices(kAudioDevicePropertyScopeInput, deviceIds, MaxNumberDevices);
28+
+ std::string deviceId = std::to_string(deviceIds[index]);
29+
+ deviceId.copy(guid, kAdmMaxGuidSize);
30+
}
31+
3932
return GetDeviceName(kAudioDevicePropertyScopeInput, index,
40-
rtc::ArrayView<char>(name, kAdmMaxDeviceNameSize));

webrtc-jni/src/main/cpp/include/media/Device.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace jni
2929
namespace avdev
3030
{
3131
/**
32-
DeviceTransport and DeviceFormFactor only foe audio devices.
32+
DeviceTransport and DeviceFormFactor only for audio devices.
3333
*/
3434
enum class DeviceTransport {
3535
trUnknown,
@@ -59,8 +59,6 @@ namespace jni
5959
std::string getDescriptor() const;
6060
DeviceTransport getDeviceTransport();
6161
DeviceFormFactor getDeviceFormFactor();
62-
void setDeviceTransport(DeviceTransport deviceTransport);
63-
void setDeviceFormFactor(DeviceFormFactor deviceFormFactor);
6462

6563
protected:
6664
Device(std::string name, std::string descriptor);

webrtc-jni/src/main/cpp/include/media/audio/AudioDevice.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ namespace jni
2828
namespace avdev
2929
{
3030

31-
enum class AudioDeviceDirectionType {
32-
adtUnknown,
33-
adtCapture,
34-
adtRender
35-
};
31+
enum class AudioDeviceDirectionType {
32+
adtUnknown,
33+
adtCapture,
34+
adtRender
35+
};
3636

3737
class AudioDevice : public Device
3838
{
3939
public:
4040
AudioDevice(std::string name, std::string descriptor);
4141
virtual ~AudioDevice() {};
42-
AudioDeviceDirectionType audioDeviceDirectionType;
42+
AudioDeviceDirectionType directionType;
4343
};
4444
}
4545

@@ -54,7 +54,7 @@ namespace jni
5454
jmethodID ctor;
5555
jfieldID name;
5656
jfieldID descriptor;
57-
jfieldID audioDeviceDirectionType;
57+
jfieldID directionType;
5858
};
5959

6060
JavaLocalRef<jobject> toJavaAudioDevice(JNIEnv * env, avdev::DevicePtr device);

0 commit comments

Comments
 (0)