
    Hui                         d dl Z d dlmZ d dlmZmZ d dlmZm	Z	 d dl
mZmZ d dlmZ d dlmZ e j"                   G d d	e             Zy)
    N)libav)AudioFormatget_audio_format)
AudioFramealloc_audio_frame)AudioLayoutget_audio_layout)Frame)Packetc                      e Zd Zej                  dedz  fd       Zej                  defd       Zej                  dedefd       Z	e
d	        Ze
d
        Zej                  dej                  fd       Ze
d        Zej                  d        Ze
d        Ze
d        Zej                  d        Ze
d        Zej                  d        Zy)AudioCodecContextinput_frameNc                    |}| j                   j                  j                  t        j                  z  }| j
                  sTt        | j                  | j                  | j                   j                  |rd n| j                   j                        | _        | j
                  j                  |      }||j                  d        |S )N)formatlayoutrate
frame_size)ptrcodeccapabilitieslib AV_CODEC_CAP_VARIABLE_FRAME_SIZE	resamplerAudioResamplerr   r   sample_rater   resampleappend)selfr   frameallow_var_frame_sizeframess        G/opt/pipecat/venv/lib/python3.12/site-packages/av/audio/codeccontext.py_prepare_frames_for_encodez,AudioCodecContext._prepare_frames_for_encode   s    #.HHNN''#*N*NN 	 ~~+{{{{XX))#74TXX=P=P	DN ((/MM$    returnc                     t               S N)r   r   s    r"   _alloc_next_framez#AudioCodecContext._alloc_next_frame"   s     ""r$   r   packetc                 V    t         j                  | ||       |}|j                          y r'   )CodecContext_setup_decoded_frame_init_user_attributes)r   r   r*   aframes       r"   r-   z&AudioCodecContext._setup_decoded_frame&   s%    ))$v>"$$&r$   c                 .    | j                   j                  S )zV
        Number of samples per channel in an audio frame.

        :type: int
        )r   r   r(   s    r"   r   zAudioCodecContext.frame_size,   s     xx"""r$   c                 .    | j                   j                  S )z[
        Sample rate of the audio data, in samples per second.

        :type: int
        r   r   r(   s    r"   r   zAudioCodecContext.sample_rate5   s     xx###r$   valuec                 &    || j                   _        y r'   r2   r   r3   s     r"   r   zAudioCodecContext.sample_rate>   s    $r$   c                     | j                   S )z%Another name for :attr:`sample_rate`.r   r(   s    r"   r   zAudioCodecContext.rateB   s     r$   c                     || _         y r'   r7   r5   s     r"   r   zAudioCodecContext.rateG   s
     r$   c                 .    | j                   j                  S r'   )r   nb_channelsr(   s    r"   channelszAudioCodecContext.channelsK   s    {{&&&r$   c                 @    t        | j                  j                        S )zG
        The audio channel layout.

        :type: AudioLayout
        )r	   r   	ch_layoutr(   s    r"   r   zAudioCodecContext.layoutO   s       2 233r$   c                 P    t        |      }|j                  | j                  _        y r'   )r   r   r   r=   )r   r3   r   s      r"   r   zAudioCodecContext.layoutX   s    )%0#]]r$   c                 @    t        | j                  j                        S )zF
        The audio sample format.

        :type: AudioFormat
        )r   r   
sample_fmtr(   s    r"   r   zAudioCodecContext.format]   s       3 344r$   c                 P    t        |      }|j                  | j                  _        y r'   )r   r@   r   )r   r3   r   s      r"   r   zAudioCodecContext.formatf   s    )%0$//r$   )__name__
__module____qualname__cythoncfuncr
   r#   r)   r   r-   propertyr   r   setterintr   r;   r   r    r$   r"   r   r   
   sM   \\edl  * \\#5 # # \\'% ' ' '
 # # $ $ % % %     
[[! ! ' ' 4 4 ]]+ + 5 5 ]]0 0r$   r   )rE   cython.cimportsr   r   cython.cimports.av.audio.formatr   r   cython.cimports.av.audio.framer   r   cython.cimports.av.audio.layoutr   r	   cython.cimports.av.framer
   cython.cimports.av.packetr   cclassr,   r   rJ   r$   r"   <module>rR      s<     ( I H I * , ^0 ^0 ^0r$   