
    C1i#              	          S SK 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\R                   " \\" 5       5      r\R&                  S	\S
\R*                  \R,                     S\S\4S j5       r\R4                   " S S5      5       r\R4                   " S S\5      5       r\R4                   " S S\5      5       rg)    )FlagN)libav)	err_check)Packet)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/james-whalen/.local/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Jr0   r   	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.streamr7   av.subtitles.streamr8   av.video.streamr9   codecpar
codec_typelibAVMEDIA_TYPE_VIDEO__new___cinit_bypass_sentinelAVMEDIA_TYPE_AUDIOAVMEDIA_TYPE_SUBTITLEAVMEDIA_TYPE_ATTACHMENTAttachmentStreamAVMEDIA_TYPE_DATA
DataStreamStream_init)r2   r3   r4   r7   r8   r9   	py_streams          r1   wrap_streamrO   (   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r0   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rg)rL   M   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)rE   RuntimeErrorselfnames     r1   	__cinit__Stream.__cinit___   s    ))?@@r0   r2   streamr4   c                    Xl         X 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)	r2   r:   r4   r<   stream_indexr   r+   metadata_encodingmetadata_errors)rU   r2   rY   r4   s       r1   rM   Stream._initd   s\     #*.4llD+&OO^^55>>11
r0   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$ )NrV   <av. # z<notype>/	<nocodec> at 0xx>)getattr	__class__r   r<   typeidrT   s     r1   __repr__Stream.__repr__x   sb    tVT*4>>**+2djj\499;R
:SST"{#6"T(1Q8	
r0   c                     US:X  a  U R                  U5        g US:X  a  X R                  l        g US:X  a5  [        U[        R
                  " U R                  R                  5      5        g U R                  b  [        U R                  X5        g g )Nrn   disposition	time_base)	_set_idr:   rr   r
   cythonaddressrs   r4   setattr)rU   rV   values      r1   __setattr__Stream.__setattr__   sx    4<LL= #(HH ;%0B0B!CD )D&&4 *r0   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 r[   )r	   ru   rv   r:   r+   r2   r_   r`   r4   rs   numr   rB   avcodec_parameters_from_contextr@   rU   s    r1   _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	
r0   c                 .    U R                   R                  $ )z5
The format-specific ID of this stream.

:type: int

r:   rn   r~   s    r1   rn   	Stream.id   s     xx{{r0   c                 N    Uc  SU R                   l        g XR                   l        g )Nr   r   )rU   rx   s     r1   rt   Stream._set_id   s    =DHHKHHKr0   c                 T    U R                   (       a  U R                   R                  $ / $ )z@
List the available profiles for this stream.

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

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

:type: int
)r:   r<   r~   s    r1   r<   Stream.index   s     xx~~r0   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   ru   rv   r:   rs   r~   s    r1   rs   Stream.time_base   s"     &fnnTXX5G5G&HIIr0   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)r:   
start_timerB   AV_NOPTS_VALUEr~   s    r1   r   Stream.start_time   s1     88#"4"4488&&& 5r0   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)r:   durationrB   r   r~   s    r1   r   Stream.duration   s1     88 2 2288$$$ 3r0   c                 .    U R                   R                  $ )z[
The number of frames this stream contains.

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

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

:type: str | None
languager+   getr~   s    r1   r   Stream.language       }}  ,,r0   c                 @    [        U R                  R                  5      $ N)r   r:   rr   r~   s    r1   rr   Stream.disposition
  s    488//00r0   c                 j    [         R                  " U R                  R                  R                  5      $ )z]
The type of the stream.

:type: Literal["audio", "video", "subtitle", "data", "attachment"]
)rB   av_get_media_type_stringr:   r@   rA   r~   s    r1   rm   Stream.type  s%     ++DHH,=,=,H,HIIr0   )r4   r2   r+   r:   N)r   r   r   r   __doc__rW   ru   cfunc	ContainerpointerrB   AVStreamCodecContextrM   ro   ry   r   propertyrn   rt   r   r   r<   rs   r   r   r   r   rr   rm   r/   r   r0   r1   rL   rL   M   sh    A
 \\

 s||,
 $	
 
&
5 \\
 
*   \\    	 	 	 	   J J ' ' % % " " - - 1 1 J Jr0   rL   c                   *    \ rS rSrS r\S 5       rSrg)rK   i  c           
          SU R                   R                   SU R                   SU R                  =(       d    S S[	        U 5      S S3	$ )Nrc   rd   z data/rg   rh   ri   rj   )rl   r   r<   rV   rn   r~   s    r1   ro   DataStream.__repr__  sG    4>>**+2djj\yy'K(r$xl!=	
r0   c                     [         R                  " U R                  R                  R                  5      nU[
        R                  :X  a  g UR                  $ r   )rB   avcodec_descriptor_getr:   r@   codec_idru   NULLrV   )rU   descs     r1   rV   DataStream.name   sB     &&txx'8'8'A'AB 	 6;;yyr0   r   N)r   r   r   r   ro   r   rV   r/   r   r0   r1   rK   rK     s    
  r0   rK   c                   H    \ rS rSrSr\S 5       r\S 5       r\S 5       rSr	g)rI   i*  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    r1   rV   AttachmentStream.name1  r   r0   c                 8    U R                   R                  S5      $ )z>
Returns the MIME type of the attachment.

:rtype: str | None
mimetyper   r~   s    r1   r   AttachmentStream.mimetype:  r   r0   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   r0   )	r:   r@   	extradataextradata_sizeru   r   	bytearrayrangebytes)rU   r   sizepayloadis        r1   dataAttachmentStream.dataC  so     %)HH$5$5$?$?	"&(("3"3"B"B#tqyD/tA"GJ  W~r0   r   N)
r   r   r   r   r   r   rV   r   r   r/   r   r0   r1   rI   rI   *  sC    
 - - - -  r0   rI   )enumr   ru   cython.cimportsr   rB   cython.cimports.av.errorr   cython.cimports.av.packetr   cython.cimports.av.utilsr   r   r	   r
   r   declareobjectrE   r   r   r   r   r   rL   rO   cclassrK   rI   r   r0   r1   <module>r      s      ( . , $ ,  9  !!nnS\\*!  ! 	! !H GJ GJ GJT   " $v $ $r0   