@@ -20,17 +20,15 @@ public class HeadlessADMIntegrationTest {
2020
2121 @ Test
2222 void audioReceivedOnSink () throws Exception {
23- HeadlessAudioDeviceModule senderAdm = new HeadlessAudioDeviceModule ();
24- HeadlessAudioDeviceModule receiverAdm = new HeadlessAudioDeviceModule ();
25- PeerConnectionFactory senderFactory = new PeerConnectionFactory (senderAdm );
26- PeerConnectionFactory receiverFactory = new PeerConnectionFactory (receiverAdm );
23+ HeadlessAudioDeviceModule adm = new HeadlessAudioDeviceModule ();
24+ PeerConnectionFactory factory = new PeerConnectionFactory (adm );
2725
2826 // Ensure the playout pipeline is started (headless output).
29- receiverAdm .initPlayout ();
30- receiverAdm .startPlayout ();
27+ adm .initPlayout ();
28+ adm .startPlayout ();
3129
32- senderAdm .initRecording ();
33- senderAdm .startRecording ();
30+ adm .initRecording ();
31+ adm .startRecording ();
3432
3533 RTCConfiguration cfg = new RTCConfiguration ();
3634
@@ -100,21 +98,21 @@ public void onConnectionChange(RTCPeerConnectionState state) {
10098 }
10199 };
102100
103- RTCPeerConnection senderPc = senderFactory .createPeerConnection (cfg , senderObserver );
104- RTCPeerConnection receiverPc = receiverFactory .createPeerConnection (cfg , receiverObserver );
101+ RTCPeerConnection senderPc = factory .createPeerConnection (cfg , senderObserver );
102+ RTCPeerConnection receiverPc = factory .createPeerConnection (cfg , receiverObserver );
105103 senderPcRef .set (senderPc );
106104 receiverPcRef .set (receiverPc );
107105
108106 // Add an explicit receive-only audio transceiver on the receiver side.
109- AudioTrackSource rxSource = receiverFactory .createAudioSource (new AudioOptions ());
110- AudioTrack receiverTrack = receiverFactory .createAudioTrack ("rx-audio" , rxSource );
107+ AudioTrackSource rxSource = factory .createAudioSource (new AudioOptions ());
108+ AudioTrack receiverTrack = factory .createAudioTrack ("rx-audio" , rxSource );
111109 RTCRtpTransceiverInit recvOnlyInit = new RTCRtpTransceiverInit ();
112110 recvOnlyInit .direction = RTCRtpTransceiverDirection .RECV_ONLY ;
113111 receiverPc .addTransceiver (receiverTrack , recvOnlyInit );
114112
115113 // Create sender audio from CustomAudioSource and add to PC.
116114 CustomAudioSource customSource = new CustomAudioSource ();
117- AudioTrack senderTrack = senderFactory .createAudioTrack ("audio0" , customSource );
115+ AudioTrack senderTrack = factory .createAudioTrack ("audio0" , customSource );
118116 senderPc .addTrack (senderTrack , Collections .singletonList ("stream0" ));
119117
120118 // SDP offer/answer exchange.
@@ -166,8 +164,8 @@ public void onConnectionChange(RTCPeerConnectionState state) {
166164 assertTrue (sinkFramesLatch .await (3 , TimeUnit .SECONDS ),
167165 "No audio frames received on remote AudioTrack sink" );
168166
169- receiverAdm .stopPlayout ();
170- senderAdm .stopRecording ();
167+ adm .stopPlayout ();
168+ adm .stopRecording ();
171169
172170 // Cleanup.
173171 senderPc .close ();
@@ -183,11 +181,9 @@ public void onConnectionChange(RTCPeerConnectionState state) {
183181// receiverTrack.dispose();
184182 customSource .dispose ();
185183
186- receiverFactory .dispose ();
187- senderFactory .dispose ();
184+ factory .dispose ();
188185
189- senderAdm .dispose ();
190- receiverAdm .dispose ();
186+ adm .dispose ();
191187 }
192188
193189
0 commit comments