Skip to content

Commit f3aec86

Browse files
authored
add is_screencast to VideoSource (#575)
1 parent b8ac9a2 commit f3aec86

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

livekit-rtc/livekit/rtc/video_source.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,41 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from __future__ import annotations
16+
1517
from ._ffi_client import FfiHandle, FfiClient
1618
from ._proto import ffi_pb2 as proto_ffi
1719
from ._proto import video_frame_pb2 as proto_video
1820
from .video_frame import VideoFrame
1921

2022

2123
class VideoSource:
22-
def __init__(self, width: int, height: int) -> None:
24+
def __init__(self, width: int, height: int, *, is_screencast: bool = False) -> None:
25+
"""
26+
Create a new video source.
27+
28+
Args:
29+
width (int): Initial width of the video source.
30+
height (int): Initial height of the video source.
31+
is_screencast (bool, optional): Optimize the WebRTC pipeline for screen content.
32+
Defaults to False.
33+
34+
When True, WebRTC will:
35+
36+
- Maintain resolution under congestion by dropping frames instead of
37+
downscaling (keeps text crisp)
38+
- Disable quality scaling and denoising to preserve text/UI readability
39+
- Guarantee a minimum 1200 kbps bitrate floor
40+
- Enable zero-hertz mode, stopping frame transmission when the screen
41+
is static to save bandwidth
42+
- Set content type to screen, adjusting encoder configuration throughout
43+
the pipeline (VP9 inter-layer prediction, simulcast layer allocation, etc.)
44+
"""
2345
req = proto_ffi.FfiRequest()
2446
req.new_video_source.type = proto_video.VideoSourceType.VIDEO_SOURCE_NATIVE
2547
req.new_video_source.resolution.width = width
2648
req.new_video_source.resolution.height = height
49+
req.new_video_source.is_screencast = is_screencast
2750

2851
resp = FfiClient.instance.request(req)
2952
self._info = resp.new_video_source.source

0 commit comments

Comments
 (0)