
    3j&              	          S SK JrJr  S SKrS SKJr  S SKJr  S SK	J
r
  S SKJrJrJrJr   " S S\5      r " S	 S
\5      r\R$                  " \\" 5       5      r\R*                  S\S\R.                  \R0                     S\S\4S j5       r\R8                   " S S5      5       r\R:                  \R8                   " S S\5      5       5       r\R:                  \R8                   " S S\5      5       5       rg)    )IntEnumIntFlagN)libav)	err_check)wrap_index_entries)avdict_to_dictavrational_to_fractiondict_to_avdictto_avrationalc                   `    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrSrSrSrSrSrSrSrSrg)Disposition                      @         i   i   i   i   i   i   i   i   i   i     N)__name__
__module____qualname____firstlineno__defaultduboriginalcommentlyricskaraokeforcedhearing_impairedvisual_impairedclean_effectsattached_pictimed_thumbnailsnon_diegeticcaptionsdescriptionsmetadata	dependentstill_image
multilayer__static_attributes__r       C/home/wildlama/miniconda3/lib/python3.13/site-packages/av/stream.pyr   r      sc    G
CHGFGFOMLLHLHIKJr1   r   c                       \ rS rSr\R
                  r\R                  r\R                  r
\R                  r\R                  r\R                  r\R"                  rSrg)Discard%   r   N)r   r   r   r   libAVDISCARD_NONEnoneAVDISCARD_DEFAULTr   AVDISCARD_NONREFnonrefAVDISCARD_BIDIRbidirAVDISCARD_NONINTRAnonintraAVDISCARD_NONKEYnonkeyAVDISCARD_ALLallr0   r   r1   r2   r4   r4   %   sO    D##G!!FE%%H!!F


Cr1   r4   	containerc_streamcodec_contextreturnc                 t   U R                   R                  UR                     U:X  d   eSSKJn  SSKJn  SSKJn  UR                  R                  [        R                  :X  a  UR                  U[        5      nGO*UR                  R                  [        R                  :X  a  UR                  U[        5      nOUR                  R                  [        R                   :X  a  UR                  U[        5      nOUR                  R                  [        R"                  :X  a  [$        R                  [$        [        5      nOeUR                  R                  [        R&                  :X  a  [(        R                  [(        [        5      nO[*        R                  [*        [        5      nUR-                  XU5        U$ )z~Build an av.Stream for an existing AVStream.

The AVStream MUST be fully constructed and ready for use before this is called.
r   )AudioStream)SubtitleStream)VideoStream)ptrstreamsindexav.audio.streamrI   av.subtitles.streamrJ   av.video.streamrK   codecpar
codec_typer6   AVMEDIA_TYPE_VIDEO__new___cinit_bypass_sentinelAVMEDIA_TYPE_AUDIOAVMEDIA_TYPE_SUBTITLEAVMEDIA_TYPE_ATTACHMENTAttachmentStreamAVMEDIA_TYPE_DATA
DataStreamStream_init)rD   rE   rF   rI   rJ   rK   	py_streams          r2   wrap_streamr`   2   s7    ==  0H<<< ,2+##s'='==''5KL					%	%)?)?	?''5KL					%	%)B)B	B"**>;QR					%	%)D)D	D$,,-=?UV					%	%)>)>	>&&z3IJ	NN6+AB	OOI7r1   c                      \ rS rSrSrS r\R                  S\S\R                  \
R                     S\4S j5       rS rS	 r\R                  S
 5       r\S 5       r\R                  S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSrg)r]   W   a  
A single stream of audio, video or subtitles within a :class:`.Container`.

::

    >>> fh = av.open(video_path)
    >>> stream = fh.streams.video[0]
    >>> stream
    <av.VideoStream #0 h264, yuv420p 1280x720 at 0x...>

This encapsulates a :class:`.CodecContext`, located at :attr:`Stream.codec_context`.
Attribute access is passed through to that context when attributes are missing
on the stream itself. E.g. ``stream.options`` will be the options on the
context.
c                 ,    U[         L a  g [        S5      e)Nz"cannot manually instantiate Stream)rV   RuntimeErrorselfnames     r2   	__cinit__Stream.__cinit__i   s    ))?@@r1   rD   streamrF   c                 8   Xl         X l        [        U R                  5      U l        X0l        U R                  (       a  UR
                  U R                  l        [        UR                  U R                   R                  U R                   R                  S9U l        g N)encodingerrors)rD   rL   r   index_entriesrF   rN   stream_indexr   r,   metadata_encodingmetadata_errors)rf   rD   rj   rF   s       r2   r^   Stream._initn   sm     #/9*.4llD+&OO^^55>>11
r1   c                     [        U SS 5      nSU R                  R                   SU R                   SU R                  =(       d    S SU=(       d    S S[        U 5      S	 S
3$ )Nrg   <av. # z<notype>/	<nocodec> at 0xx>)getattr	__class__r   rN   typeidre   s     r2   __repr__Stream.__repr__   sb    tVT*4>>**+2djj\499;R
:SST"{#6"T(1Q8	
r1   c                 v   US:X  a  U R                  U5        g US:X  a  X R                  l        g US:X  a%  [        U5      R                  U R                  l        g US:X  a5  [        U[        R                  " U R                  R                  5      5        g U R                  b  [        U R                  X5        g g )Nr   dispositiondiscard	time_base)_set_idrL   r   r4   valuer   r   cythonaddressr   rF   setattr)rf   rg   r   s      r2   __setattr__Stream.__setattr__   s    4<LL= #(HH 9&u~33DHH;%0B0B!CD )D&&4 *r1   c                 $   [        [        R                  " U R                  R                  5      U R                  U R
                  R                  U R
                  R                  S9  U R                  c  g U R                  R                  R                  (       d/  U R                  R                  R                  U R                  l	        [        [        R                  " U R                  R                  U R                  R                  5      5        g rl   )r
   r   r   rL   r,   rD   rq   rr   rF   r   numr   r6   avcodec_parameters_from_contextrR   rf   s    r2   _finalize_for_outputStream._finalize_for_output   s    NN488,,-MM^^55>>11		
 %xx!!%%!%!3!3!7!7!A!ADHH 	//!!4#5#5#9#9	
r1   c                 .    U R                   R                  $ )z5
The format-specific ID of this stream.

:type: int

rL   r   r   s    r2   r   	Stream.id   s     xx{{r1   c                 N    Uc  SU R                   l        g XR                   l        g )Nr   r   )rf   r   s     r2   r   Stream._set_id   s    =DHHKHHKr1   c                 T    U R                   (       a  U R                   R                  $ / $ )z@
List the available profiles for this stream.

:type: list[str]
)rF   profilesr   s    r2   r   Stream.profiles   s$     %%...Ir1   c                 R    U R                   (       a  U R                   R                  $ g)z)
The profile of this stream.

:type: str
N)rF   profiler   s    r2   r   Stream.profile   s"     %%---r1   c                 .    U R                   R                  $ )zB
The index of this stream in its :class:`.Container`.

:type: int
)rL   rN   r   s    r2   rN   Stream.index   s     xx~~r1   c                 h    [        [        R                  " U R                  R                  5      5      $ )zp
The unit of time (in fractional seconds) in which timestamps are expressed.

:type: fractions.Fraction | None

)r	   r   r   rL   r   r   s    r2   r   Stream.time_base   s"     &fnnTXX5G5G&HIIr1   c                     U R                   R                  [        R                  :w  a  U R                   R                  $ g)zm
The presentation timestamp in :attr:`time_base` units of the first
frame in this stream.

:type: int | None
N)rL   
start_timer6   AV_NOPTS_VALUEr   s    r2   r   Stream.start_time   s1     88#"4"4488&&& 5r1   c                     U R                   R                  [        R                  :w  a  U R                   R                  $ g)zM
The duration of this stream in :attr:`time_base` units.

:type: int | None

N)rL   durationr6   r   r   s    r2   r   Stream.duration   s1     88 2 2288$$$ 3r1   c                 .    U R                   R                  $ )z[
The number of frames this stream contains.

Returns ``0`` if it is not known.

:type: int
)rL   	nb_framesr   s    r2   framesStream.frames  s     xx!!!r1   c                 8    U R                   R                  S5      $ )z0
The language of the stream.

:type: str | None
languager,   getr   s    r2   r   Stream.language       }}  ,,r1   c                 @    [        U R                  R                  5      $ N)r   rL   r   r   s    r2   r   Stream.disposition  s    488//00r1   c                 @    [        U R                  R                  5      $ )a  
Controls which packets of this stream are discarded by the demuxer.

Set this to e.g. :attr:`Discard.all` on streams you don't need so that
:meth:`.Container.demux` and :meth:`.Container.seek` skip them, avoiding
the cost of synchronizing streams you never read.

:type: Discard
)r4   rL   r   r   s    r2   r   Stream.discard  s     txx''((r1   c                     [         R                  " U R                  R                  R                  5      nU[
        R                  :X  a  S$ U$ )z]
The type of the stream.

:type: Literal["audio", "video", "subtitle", "data", "attachment"]
unknown)r6   av_get_media_type_stringrL   rR   rS   r   NULL)rf   
media_types     r2   r   Stream.type)  s:     11$((2C2C2N2NO
&&++5yE:Er1   )rF   rD   ro   r,   rL   N) r   r   r   r   __doc__rh   r   cfunc	Containerpointerr6   AVStreamCodecContextr^   r   r   r   propertyr   r   r   r   rN   r   r   r   r   r   r   r   r   r0   r   r1   r2   r]   r]   W   s|    A
 \\

 s||,
 $	
 
(
5$ \\
 
*   \\    	 	 	 	   J J ' ' % % " " - - 1 1 
) 
) F Fr1   r]   c                   *    \ rS rSrS r\S 5       rSrg)r\   i4  c           
          SU R                   R                   SU R                   SU R                  =(       d    S S[	        U 5      S S3	$ )Nru   rv   z data/ry   rz   r{   r|   )r~   r   rN   rg   r   r   s    r2   r   DataStream.__repr__7  sG    4>>**+2djj\yy'K(r$xl!=	
r1   c                     [         R                  " U R                  R                  R                  5      nU[
        R                  :X  a  g UR                  $ r   )r6   avcodec_descriptor_getrL   rR   codec_idr   r   rg   )rf   descs     r2   rg   DataStream.name=  sB     &&txx'8'8'A'AB 	 6;;yyr1   r   N)r   r   r   r   r   r   rg   r0   r   r1   r2   r\   r\   4  s    
  r1   r\   c                   H    \ rS rSrSr\S 5       r\S 5       r\S 5       rSr	g)rZ   iG  z
An :class:`AttachmentStream` represents a stream of attachment data within a media container.
Typically used to attach font files that are referenced in ASS/SSA Subtitle Streams.
c                 8    U R                   R                  S5      $ )z>
Returns the file name of the attachment.

:rtype: str | None
filenamer   r   s    r2   rg   AttachmentStream.nameO  r   r1   c                 8    U R                   R                  S5      $ )z>
Returns the MIME type of the attachment.

:rtype: str | None
mimetyper   r   s    r2   r   AttachmentStream.mimetypeX  r   r1   c                    U R                   R                  R                  nU R                   R                  R                  nU[        R
                  :X  d  US::  a  g[        U5      n[        U5       H	  nX   X4'   M     [        U5      $ )z+Return the raw attachment payload as bytes.r   r1   )	rL   rR   	extradataextradata_sizer   r   	bytearrayrangebytes)rf   r   sizepayloadis        r2   dataAttachmentStream.dataa  so     %)HH$5$5$?$?	"&(("3"3"B"B#tqyD/tA"GJ  W~r1   r   N)
r   r   r   r   r   r   rg   r   r   r0   r   r1   r2   rZ   rZ   G  sC    
 - - - -  r1   rZ   ) enumr   r   r   cython.cimportsr   r6   cython.cimports.av.errorr   cython.cimports.av.indexr   cython.cimports.av.utilsr   r	   r
   r   r   r4   declareobjectrV   r   r   r   r   r   r]   r`   cclassfinalr\   rZ   r   r1   r2   <module>r      s   !  ( . 7 ' ,g   9  !!nnS\\*!  ! 	! !H YF YF YFx    " $v $  $r1   