Ë
    §q±iv  ã                  óX   — d dl mZ ddlmZmZ ddlmZ ddlmZ	 ddl
mZ  G d„ d«      Zy	)
é    )Úannotationsé   )Ú	FfiHandleÚ	FfiClient)Úffi_pb2)Úvideo_frame_pb2)Ú
VideoFramec                  óh   — e Zd Zddœd	d„Zdej
                  j                  dœ	 	 	 	 	 	 	 d
d„Zdd„Zy)ÚVideoSourceF)Úis_screencastc               óÜ  — t        j                  «       }t        j                  j                  |j
                  _        ||j
                  j                  _        ||j
                  j                  _	        ||j
                  _
        t        j                  j                  |«      }|j
                  j                  | _        t!        | j                  j"                  j$                  «      | _        y)a¶  
        Create a new video source.

        Args:
            width (int): Initial width of the video source.
            height (int): Initial height of the video source.
            is_screencast (bool, optional): Optimize the WebRTC pipeline for screen content.
                Defaults to False.

                When True, WebRTC will:

                - Maintain resolution under congestion by dropping frames instead of
                  downscaling (keeps text crisp)
                - Disable quality scaling and denoising to preserve text/UI readability
                - Guarantee a minimum 1200 kbps bitrate floor
                - Enable zero-hertz mode, stopping frame transmission when the screen
                  is static to save bandwidth
                - Set content type to screen, adjusting encoder configuration throughout
                  the pipeline (VP9 inter-layer prediction, simulcast layer allocation, etc.)
        N)Ú	proto_ffiÚ
FfiRequestÚproto_videoÚVideoSourceTypeÚVIDEO_SOURCE_NATIVEÚnew_video_sourceÚtypeÚ
resolutionÚwidthÚheightr   r   ÚinstanceÚrequestÚsourceÚ_infor   ÚhandleÚidÚ_ffi_handle)Úselfr   r   r   ÚreqÚresps         úJ/opt/pipecat/venv/lib/python3.12/site-packages/livekit/rtc/video_source.pyÚ__init__zVideoSource.__init__   s¨   € ô* ×"Ñ"Ó$ˆÜ$/×$?Ñ$?×$SÑ$Sˆ×ÑÔ!Ø05ˆ×Ñ×'Ñ'Ô-Ø17ˆ×Ñ×'Ñ'Ô.Ø-:ˆ×ÑÔ*ä×!Ñ!×)Ñ)¨#Ó.ˆØ×*Ñ*×1Ñ1ˆŒ
Ü$ T§Z¡Z×%6Ñ%6×%9Ñ%9Ó:ˆÕó    r   )Útimestamp_usÚrotationc               ó^  — t        j                  «       }| j                  j                  |j                  _        |j                  j                  j                  |j                  «       «       ||j                  _	        ||j                  _
        t        j                  j                  |«       y ©N)r   r   r   r   Úcapture_video_frameÚsource_handleÚbufferÚCopyFromÚ_proto_infor&   r%   r   r   r   )r   Úframer%   r&   r    s        r"   Úcapture_framezVideoSource.capture_frame7   s   € ô ×"Ñ"Ó$ˆØ04×0@Ñ0@×0GÑ0Gˆ×ÑÔ-Ø×Ñ×&Ñ&×/Ñ/°×0AÑ0AÓ0CÔDØ+3ˆ×ÑÔ(Ø/;ˆ×ÑÔ,Ü×Ñ×"Ñ" 3Õ'r$   c              ƒ  ó@   K  — | j                   j                  «        y ­wr(   )r   Údispose)r   s    r"   ÚaclosezVideoSource.acloseE   s   è ø€ Ø×Ñ× Ñ Õ"ùs   ‚N)r   Úintr   r3   r   ÚboolÚreturnÚNone)r.   r	   r%   r3   r&   z#proto_video.VideoRotation.ValueTyper5   r6   )r5   r6   )	Ú__name__Ú
__module__Ú__qualname__r#   r   ÚVideoRotationÚVIDEO_ROTATION_0r/   r2   © r$   r"   r   r      sO   „ ØINõ ;ðF Ø8C×8QÑ8Q×8bÑ8bñ(àð(ð ð	(ð
 6ð(ð 
ó(ô#r$   r   N)Ú
__future__r   Ú_ffi_clientr   r   Ú_protor   r   r   r   Úvideo_framer	   r   r<   r$   r"   ú<module>rA      s    ðõ #ç -Ý (Ý 2Ý #÷/#ò /#r$   