o
    iv                     @  sR   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 dZd	S )
    )annotations   )	FfiHandle	FfiClient)ffi_pb2)video_frame_pb2)
VideoFramec                   @  s<   e Zd Zdddd
dZdejjddddZdddZdS )VideoSourceF)is_screencastwidthintheightr
   boolreturnNonec                C  sZ   t  }tjj|j_||jj_||jj_	||j_
tj|}|jj| _t| jjj| _dS )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
resolutionr   r   r
   r   instancerequestsource_infor   handleid_ffi_handle)selfr   r   r
   reqresp r#   Z/var/www/html/livekit_bhavya/venv/lib/python3.10/site-packages/livekit/rtc/video_source.py__init__   s   


zVideoSource.__init__r   )timestamp_usrotationframer   r&   r'   #proto_video.VideoRotation.ValueTypec                C  sF   t  }| jj|j_|jj|  ||j_	||j_
tj| d S N)r   r   r   r   capture_video_framesource_handlebufferCopyFrom_proto_infor'   r&   r   r   r   )r    r(   r&   r'   r!   r#   r#   r$   capture_frame7   s   zVideoSource.capture_framec                   s   | j   d S r*   )r   dispose)r    r#   r#   r$   acloseE   s   zVideoSource.acloseN)r   r   r   r   r
   r   r   r   )r(   r   r&   r   r'   r)   r   r   )r   r   )	__name__
__module____qualname__r%   r   VideoRotationVIDEO_ROTATION_0r0   r2   r#   r#   r#   r$   r	      s    #r	   N)
__future__r   _ffi_clientr   r   _protor   r   r   r   video_framer   r	   r#   r#   r#   r$   <module>   s   