|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +from __future__ import annotations |
| 16 | + |
15 | 17 | from ._ffi_client import FfiHandle, FfiClient |
16 | 18 | from ._proto import ffi_pb2 as proto_ffi |
17 | 19 | from ._proto import video_frame_pb2 as proto_video |
18 | 20 | from .video_frame import VideoFrame |
19 | 21 |
|
20 | 22 |
|
21 | 23 | 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 | + """ |
23 | 45 | req = proto_ffi.FfiRequest() |
24 | 46 | req.new_video_source.type = proto_video.VideoSourceType.VIDEO_SOURCE_NATIVE |
25 | 47 | req.new_video_source.resolution.width = width |
26 | 48 | req.new_video_source.resolution.height = height |
| 49 | + req.new_video_source.is_screencast = is_screencast |
27 | 50 |
|
28 | 51 | resp = FfiClient.instance.request(req) |
29 | 52 | self._info = resp.new_video_source.source |
|
0 commit comments