Skip to content

Commit 7070622

Browse files
committed
AudioDeviceModule: added stop/start methods for playout/recording
1 parent 1d69449 commit 7070622

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

webrtc-jni/src/main/cpp/include/JNI_AudioDeviceModule.h

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webrtc-jni/src/main/cpp/src/JNI_AudioDeviceModule.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,30 @@ JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_init
4242
}
4343
}
4444

45+
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_stopPlayout
46+
(JNIEnv* env, jobject caller)
47+
{
48+
webrtc::AudioDeviceModule* audioModule = GetHandle<webrtc::AudioDeviceModule>(env, caller);
49+
CHECK_HANDLE(audioModule);
50+
51+
if (audioModule->StopPlayout() != 0) {
52+
env->Throw(jni::JavaError(env, "Stop playout failed"));
53+
return;
54+
}
55+
}
56+
57+
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_startPlayout
58+
(JNIEnv* env, jobject caller)
59+
{
60+
webrtc::AudioDeviceModule* audioModule = GetHandle<webrtc::AudioDeviceModule>(env, caller);
61+
CHECK_HANDLE(audioModule);
62+
63+
if (audioModule->StartPlayout() != 0) {
64+
env->Throw(jni::JavaError(env, "Start playout failed"));
65+
return;
66+
}
67+
}
68+
4569
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_initRecording
4670
(JNIEnv * env, jobject caller)
4771
{
@@ -54,6 +78,30 @@ JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_init
5478
}
5579
}
5680

81+
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_stopRecording
82+
(JNIEnv* env, jobject caller)
83+
{
84+
webrtc::AudioDeviceModule* audioModule = GetHandle<webrtc::AudioDeviceModule>(env, caller);
85+
CHECK_HANDLE(audioModule);
86+
87+
if (audioModule->StopRecording() != 0) {
88+
env->Throw(jni::JavaError(env, "Stop recording failed"));
89+
return;
90+
}
91+
}
92+
93+
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_startRecording
94+
(JNIEnv* env, jobject caller)
95+
{
96+
webrtc::AudioDeviceModule* audioModule = GetHandle<webrtc::AudioDeviceModule>(env, caller);
97+
CHECK_HANDLE(audioModule);
98+
99+
if (audioModule->StartRecording() != 0) {
100+
env->Throw(jni::JavaError(env, "Start recording failed"));
101+
return;
102+
}
103+
}
104+
57105
JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_getPlayoutDevices
58106
(JNIEnv* env, jobject caller)
59107
{

webrtc/src/main/java/dev/onvoid/webrtc/media/audio/AudioDeviceModule.java

+8
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@ public AudioDeviceModule(AudioLayer audioLayer) {
3232

3333
public native void initPlayout();
3434

35+
public native void stopPlayout();
36+
37+
public native void startPlayout();
38+
3539
public native void initRecording();
3640

41+
public native void stopRecording();
42+
43+
public native void startRecording();
44+
3745
public native List<AudioDevice> getPlayoutDevices();
3846

3947
public native List<AudioDevice> getRecordingDevices();

0 commit comments

Comments
 (0)