-
Notifications
You must be signed in to change notification settings - Fork 14
fix: stop video drain when real subscriber arrives #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
01f50fc
fix: stop video drain when real subscriber arrives
aliev 9ea7275
fix: prevent GC from collecting blackhole stop task
aliev 8efddcd
docs: document drain_video_frames and align defaults across layers
aliev 032e3de
docs: move drain_video_frames docstring to ConnectionManager
aliev feb2d55
Merge branch 'main' into fix/stop-drain-on-subscribe
aliev d1ca6fb
refactor: merge blackhole and drain task into single dict
aliev ba06494
fix: explicitly cancel drain_task on subscriber arrival
aliev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| """Tests for SubscriberPeerConnection video drain behavior.""" | ||
|
|
||
| from unittest.mock import AsyncMock, Mock | ||
|
|
||
| import pytest | ||
| from aiortc.contrib.media import MediaRelay | ||
|
|
||
| from getstream.video.rtc.pc import SubscriberPeerConnection | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def subscriber_pc(): | ||
| """Create a SubscriberPeerConnection bypassing heavy parent inits.""" | ||
| pc = SubscriberPeerConnection.__new__(SubscriberPeerConnection) | ||
| pc.connection = Mock() | ||
| pc._drain_video_frames = True | ||
| pc.track_map = {} | ||
| pc.video_frame_trackers = {} | ||
| pc._video_blackholes = {} | ||
| pc._background_tasks = set() | ||
| pc._listeners = {} | ||
| return pc | ||
|
|
||
|
|
||
| class TestAddTrackSubscriberStopsDrain: | ||
| @pytest.mark.asyncio | ||
| async def test_blackhole_stopped_when_subscriber_added(self, subscriber_pc): | ||
| track_id = "user123:video:0" | ||
| relay = MediaRelay() | ||
| original_track = Mock() | ||
| subscriber_pc.track_map[track_id] = (relay, original_track) | ||
|
|
||
| blackhole = Mock() | ||
| blackhole.stop = AsyncMock() | ||
| subscriber_pc._video_blackholes[track_id] = (blackhole, Mock()) | ||
|
|
||
| subscriber_pc.add_track_subscriber(track_id) | ||
|
|
||
| blackhole.stop.assert_called_once() | ||
| assert track_id not in subscriber_pc._video_blackholes | ||
|
|
||
| def test_no_error_when_no_drain_exists(self, subscriber_pc): | ||
| track_id = "user123:video:0" | ||
| relay = MediaRelay() | ||
| original_track = Mock() | ||
| subscriber_pc.track_map[track_id] = (relay, original_track) | ||
|
|
||
| result = subscriber_pc.add_track_subscriber(track_id) | ||
| assert result is not None |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.