File tree Expand file tree Collapse file tree
main/java/dev/onvoid/webrtc/client
test/java/dev/onvoid/webrtc/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717package dev .onvoid .webrtc .client ;
1818
19+ import java .util .concurrent .CompletableFuture ;
20+
1921/**
2022 * A track this side sends, made by {@link WebRtc#media()}. One track may be sent
2123 * on any number of peers.
@@ -60,6 +62,16 @@ public interface LocalTrack extends AutoCloseable {
6062 */
6163 boolean isEnded ();
6264
65+ /**
66+ * Stops sending the track on every peer, without renegotiating, and stops
67+ * its capture.
68+ *
69+ * @return a future that completes once the native track is released, after
70+ * which a source the track was made over, with {@link
71+ * LocalMedia#videoTrack} or {@link LocalMedia#audioTrack}, may be closed.
72+ */
73+ CompletableFuture <Void > closeAsync ();
74+
6375 /**
6476 * Stops sending the track on every peer, without renegotiating, and stops
6577 * its capture. Never blocks, may be called more than once.
Original file line number Diff line number Diff line change @@ -124,6 +124,11 @@ public synchronized boolean isEnded() {
124124 return ended ;
125125 }
126126
127+ @ Override
128+ public CompletableFuture <Void > closeAsync () {
129+ return closeInternal ();
130+ }
131+
127132 @ Override
128133 public void close () {
129134 closeInternal ();
Original file line number Diff line number Diff line change @@ -329,6 +329,10 @@ void tracksOverOwnSources() throws Exception {
329329 VideoFrame frame = new VideoFrame (NativeI420Buffer .allocate (160 , 120 ), System .nanoTime ());
330330 videoSource .pushFrame (frame );
331331 frame .release ();
332+
333+ // Once released, the source may go before the runtime does.
334+ await (audio .closeAsync ());
335+ assertTrue (audio .isEnded ());
332336 }
333337 finally {
334338 feeder .shutdownNow ();
You can’t perform that action at this time.
0 commit comments