
    q	hi              	      R   S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJrJ	r	J
r
JrJrJrJrJrJr  S SKJrJr  SSKJrJr  SSKJr  SSKJr  SS	KJr  SS
KJ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)  SSK*J+r+  SSK,J-r-  SSK.J/r/  SSK0J1r1  SSK,J2r2  SSK3J4r4J5r5J6r6J7r7   " S S\85      r9 " S S\85      r: " S S\85      r; " S S\85      r< " S S\85      r= " S S \5      r>\
S!/\	\\\?      \\?   4   4   r@\" S"\
\2/\	\\\?      \\?   4   4   S#9rA " S$ S%\>5      rB " S& S'\>5      rCg)(    )annotationsN)	ListUnionCallableDict	AwaitableOptionalMappingcastTypeVar)abstractmethodABC   )	FfiClient	FfiHandle)ffi_pb2)participant_pb2)TrackPublishOptions)TranscriptionSegment)ParticipantTrackPermission)BroadcastQueue)
LocalTrack)LocalTrackPublicationRemoteTrackPublicationTrackPublication)Transcription)RpcError)"RpcMethodInvocationResponseRequest)logger)RpcInvocationData)TextStreamWriterByteStreamWriterByteStreamInfoSTREAM_CHUNK_SIZEc                      \ rS rSrSS jrSrg)PublishTrackError:   c                    Xl         g Nmessageselfr+   s     I/var/www/html/env/lib/python3.13/site-packages/livekit/rtc/participant.py__init__PublishTrackError.__init__;           r*   Nr+   strreturnNone__name__
__module____qualname____firstlineno__r/   __static_attributes__ r2   r.   r&   r&   :       r2   r&   c                      \ rS rSrSS jrSrg)UnpublishTrackError?   c                    Xl         g r)   r*   r,   s     r.   r/   UnpublishTrackError.__init__@   r1   r2   r*   Nr3   r7   r=   r2   r.   r@   r@   ?   r>   r2   r@   c                      \ rS rSrSS jrSrg)PublishDataErrorD   c                    Xl         g r)   r*   r,   s     r.   r/   PublishDataError.__init__E   r1   r2   r*   Nr3   r7   r=   r2   r.   rE   rE   D   r>   r2   rE   c                      \ rS rSrSS jrSrg)PublishDTMFErrorI   c                    Xl         g r)   r*   r,   s     r.   r/   PublishDTMFError.__init__J   r1   r2   r*   Nr3   r7   r=   r2   r.   rJ   rJ   I   r>   r2   rJ   c                      \ rS rSrSS jrSrg)PublishTranscriptionErrorN   c                    Xl         g r)   r*   r,   s     r.   r/   "PublishTranscriptionError.__init__O   r1   r2   r*   Nr3   r7   r=   r2   r.   rO   rO   N   r>   r2   rO   c                      \ rS rSrSS jr\\SS j5       5       r\SS j5       r\SS j5       r	\SS j5       r
\SS j5       r\SS j5       r\SS	 j5       r\  SS
 j5       rSrg)ParticipantS   c                n    UR                   U l        [        UR                  R                  5      U l        g r)   )info_infor   handleid_ffi_handle)r-   
owned_infos     r.   r/   Participant.__init__T   s&    __
$Z%6%6%9%9:r2   c                    g)E
A dictionary of track publications associated with the participant.
Nr=   r-   s    r.   track_publicationsParticipant.track_publicationsX   s     	r2   c                .    U R                   R                  $ r)   )rX   sidr`   s    r.   rd   Participant.sid`   s    zz~~r2   c                .    U R                   R                  $ r)   )rX   namer`   s    r.   rg   Participant.named   s    zzr2   c                .    U R                   R                  $ r)   )rX   identityr`   s    r.   rj   Participant.identityh       zz"""r2   c                .    U R                   R                  $ r)   )rX   metadatar`   s    r.   rn   Participant.metadatal   rl   r2   c                @    [        U R                  R                  5      $ )z2Custom attributes associated with the participant.)dictrX   
attributesr`   s    r.   rr   Participant.attributesp   s     DJJ))**r2   c                .    U R                   R                  $ )zLParticipant's kind (e.g., regular participant, ingress, egress, sip, agent).)rX   kindr`   s    r.   ru   Participant.kindu   s     zzr2   c                    U R                   R                  [        R                  R                  :X  a  gU R                   R                  $ )aX  Reason for the participant's disconnection.

Returns one of DisconnectReasons or None if the participant isn't disconnected. Common reasons are:
- CLIENT_INITIATED - the client initiated the disconnect
- DUPLICATE_IDENTITY - another participant with the same identity has joined the room
- SERVER_SHUTDOWN - the server instance is shutting down
- PARTICIPANT_REMOVED - RoomService.RemoveParticipant was called
- ROOM_DELETED - RoomService.DeleteRoom was called
- STATE_MISMATCH - the client is attempting to resume a session, but server is not aware of it
- JOIN_FAILURE - client was unable to connect fully

When dialing a participant via SIP, you may see the following reasons:
- USER_UNAVAILABLE - SIP callee did not respond in time
- USER_REJECTED - SIP callee rejected the call (busy)
- SIP_TRUNK_FAILURE - SIP protocol failure or unexpected response
N)rX   disconnect_reasonproto_participantDisconnectReasonUNKNOWN_REASONr`   s    r.   rx   Participant.disconnect_reasonz   s6    ( ::''+<+M+M+\+\\zz+++r2   )r[   rX   Nr\   "proto_participant.OwnedParticipantr5   r6   )r5   zMapping[str, TrackPublication]r5   r4   )r5   dict[str, str])r5   z+proto_participant.ParticipantKind.ValueType)r5   z6Optional[proto_participant.DisconnectReason.ValueType])r8   r9   r:   r;   r/   propertyr   ra   rd   rg   rj   rn   rr   ru   rx   r<   r=   r2   r.   rT   rT   S   s    ;        # # # # + +   ,	?, ,r2   rT   r    F)boundc                  :  ^  \ rS rSrSr      S#U 4S jjr\S$S j5       rS/ SS.         S%S jjrS&S	 jr	S'S
 jr
SS.         S(S jjr S)     S*S jjrS+S jrSS.     S,S jjr              S-S jrS.S jrS/S jrS0S jrSSSSSSSS.               S1S jjrSSSSS.         S2S jjrSSSSSSS.               S3S jjrSSSSS.           S4S jjr\" 5       4     S5S jjrS6S  jrS7S! jrS"rU =r$ )8LocalParticipant   z+Represents the local participant in a room.c                L   > [         TU ]  U5        Xl        0 U l        0 U l        g r)   )superr/   _room_queue_track_publications_rpc_handlers)r-   
room_queuer\   	__class__s      r.   r/   LocalParticipant.__init__   s(    
 	$%EG 46r2   c                    U R                   $ r_   r   r`   s    r.   ra   #LocalParticipant.track_publications       
 '''r2   T )reliabledestination_identitiestopicc                 ^
#    [        U[        5      (       a  UR                  S5      n[        U5      n[        R
                  U-  " U6 n[        R                  " 5       nU R                  R                  UR                  l        [        R                  " U5      UR                  l        XWR                  l        X'R                  l        XGR                  l        UR                  R"                  R%                  U5        [&        R(                  R*                  R-                  5       n [&        R(                  R/                  U5      m
UR1                  U
4S j5      I Sh  vN n	[&        R(                  R*                  R3                  U5        U	R                  R4                  (       a  [7        U	R                  R4                  5      eg Nh! [&        R(                  R*                  R3                  U5        f = f7f)a  
Publish arbitrary data to the room.

Args:
    payload (Union[bytes, str]): The data to publish.
    reliable (bool, optional): Whether to send reliably or not. Defaults to True.
    destination_identities (List[str], optional): List of participant identities to send to. Defaults to [].
    topic (str, optional): The topic under which to publish the data. Defaults to "".

Raises:
    PublishDataError: If there is an error in publishing data.
zutf-8c                ^   > U R                   R                  TR                   R                  :H  $ r)   )publish_dataasync_ideresps    r.   <lambda>/LocalParticipant.publish_data.<locals>.<lambda>   s     !..11T5F5F5O5OOr2   N)
isinstancer4   encodelenctypesc_byte	proto_ffi
FfiRequestr[   rY   r   local_participant_handle	addressofdata_ptrdata_lenr   r   r   extendr   instancequeue	subscriberequestwait_forunsubscribeerrorrE   )r-   payloadr   r   r   r   cdatareqr   cbr   s             @r.   r   LocalParticipant.publish_data   so    ( gs##nnW-Gw<)G4""$484D4D4K4K1$*$4$4U$;!$,!$,!!&//667MN""((224	8%%--c2D+0>>O, &B $$007??  "2??#8#899 !& $$007s1   D$G8(7G
 G G
 $A$G8G
 
+G55G8c                 ^#    [         R                  " 5       nU R                  R                  UR                  l        XR                  l        X#R                  l        [        R                  R                  R                  5       n [        R                  R                  U5      mUR                  U4S j5      I Sh  vN n[        R                  R                  R                  U5        UR                  R                  (       a  [!        UR                  R                  5      eg Nh! [        R                  R                  R                  U5        f = f7f)z
Publish SIP DTMF message.

Args:
    code (int): DTMF code.
    digit (str): DTMF digit.

Raises:
    PublishDTMFError: If there is an error in publishing SIP DTMF message.
c                ^   > U R                   R                  TR                   R                  :H  $ r)   )publish_sip_dtmfr   r   s    r.   r   /LocalParticipant.publish_dtmf.<locals>.<lambda>   s"    !,,559N9N9W9WWr2   N)r   r   r[   rY   r   r   codedigitr   r   r   r   r   r   r   r   rJ   )r-   r   r   r   r   r   r   s         @r.   publish_dtmfLocalParticipant.publish_dtmf   s      ""$8<8H8H8O8O5$(!%*"""((224	8%%--c2D+0>>W, &B $$007$$"2#6#6#<#<== %& $$007s1   BE7D) >D'?D) A$E'D) )+EEc                  ^#    [         R                  " 5       nUR                   Vs/ s HM  n[        UR                  UR
                  UR                  UR                  UR                  UR                  S9PMO     nnU R                  R                  UR                  l        UR                  UR                  l        UR                  R                  R                  U5        UR                   UR                  l        [$        R&                  R(                  R+                  5       n [$        R&                  R-                  U5      mUR/                  U4S j5      I Sh  vN n[$        R&                  R(                  R1                  U5        UR                  R2                  (       a  [5        UR                  R2                  5      egs  snf  Nm! [$        R&                  R(                  R1                  U5        f = f7f)z
Publish transcription data to the room.

Args:
    transcription (Transcription): The transcription data to publish.

Raises:
    PublishTranscriptionError: If there is an error in publishing transcription.
)rZ   text
start_timeend_timefinallanguagec                ^   > U R                   R                  TR                   R                  :H  $ r)   )publish_transcriptionr   r   s    r.   r   8LocalParticipant.publish_transcription.<locals>.<lambda>  s"    !11::d>X>X>a>aar2   N)r   r   segmentsProtoTranscriptionSegmentrZ   r   r   r   r   r   r[   rY   r   r   participant_identityr   	track_sidtrack_idr   r   r   r   r   r   r   r   rO   )r-   transcriptionr   sproto_segmentsr   r   r   s          @r.   r   &LocalParticipant.publish_transcription   s     ""$ #++

 , &44VV<<gg , 	 

 >B=M=M=T=T!!:9F9[9[!!6!!**11.A-:-D-D!!*""((224	8%%--c2D+0>>a, &B $$007##))+B,D,D,J,JKK *5

(& $$007s=   $G;AG;B*G;&7G GG "A)G;G +G88G;N)response_timeoutc               \  ^#    [         R                  " 5       nU R                  R                  UR                  l        XR                  l        X%R                  l        X5R                  l        Ub  [        US-  5      UR                  l
        [        R                  R                  R                  5       n [        R                  R                  U5      mUR!                  U4S j5      I Sh  vN n[        R                  R                  R#                  U5        UR                  R%                  S5      (       a*  [&        R(                  " UR                  R*                  5      eUR                  R                  $  N! [        R                  R                  R#                  U5        f = f7f)a  
Initiate an RPC call to a remote participant.

Args:
    destination_identity (str): The `identity` of the destination participant
    method (str): The method name to call
    payload (str): The method payload
    response_timeout (Optional[float]): Timeout for receiving a response after initial connection

Returns:
    str: The response payload

Raises:
    RpcError: On failure. Details in `message`.
Ni  c                ^   > U R                   R                  TR                   R                  :H  $ r)   )perform_rpcr   r   s    r.   r   .LocalParticipant.perform_rpc.<locals>.<lambda>B  s     1==11T5E5E5N5NNr2   r   )r   r   r[   rY   r   r   destination_identitymethodr   intresponse_timeout_msr   r   r   r   r   r   r   HasFieldr   _from_protor   )	r-   r   r   r   r   r   r   r   r   s	           @r.   r   LocalParticipant.perform_rpc  s2    . ""$373C3C3J3J0/C,!'")'256F6M2NCOO/""((224	8%%--c2D~~O B $$007>>""7++&&r~~';';<<~~%%% $$007s1   B3F,77E> .E</E> 3B	F,<E> >+F))F,c                2   ^ ^ SUU 4S jjnUb  U" U5      $ U$ )a  
Establishes the participant as a receiver for calls of the specified RPC method.
Can be used either as a decorator or a regular method.

The handler will receive one argument of type `RpcInvocationData` and should return a string response which will be forwarded back to the caller.

The handler may be synchronous or asynchronous.

If unable to respond within `response_timeout`, the caller will hang up and receive an error on their side.

You may raise errors of type `RpcError` in the handler, and they will be forwarded to the caller.

Other errors raised in your handler will be caught and forwarded to the caller as "1500 Application Error".

Args:
    method_name (str): The name of the indicated RPC method.
    handler (Optional[Callable]): Handler to be invoked whenever an RPC request for this method is received.  Omit this argument to use the decorator syntax.

Returns:
    None (when used as a decorator it returns the decorator function)

Example:
    # As a decorator:
    @room.local_participant.register_rpc_method("greet")
    async def greet_handler(data: RpcInvocationData) -> str:
        print(f"Received greeting from {data.caller_identity}: {data.payload}")
        return f"Hello, {data.caller_identity}!"

    # As a regular method:
    async def greet_handler(data: RpcInvocationData) -> str:
        print(f"Received greeting from {data.caller_identity}: {data.payload}")
        return f"Hello, {data.caller_identity}!"

    room.local_participant.register_rpc_method('greet', greet_handler)
c                   > U TR                   T'   [        R                  " 5       nTR                  R                  UR
                  l        TUR
                  l        [        R                  R                  U5        U $ r)   )r   r   r   r[   rY   register_rpc_methodr   r   r   r   r   )handler_funcr   method_namer-   s     r.   register6LocalParticipant.register_rpc_method.<locals>.registeru  sc    .:D{+&&(C?C?O?O?V?VC##<-8C##*&&s+r2   )r   r   r5   r   r=   )r-   r   handlerr   s   ``  r.   r   $LocalParticipant.register_rpc_methodL  s&    R	  	  G$$Or2   c                   U R                   R                  US5        [        R                  " 5       nU R                  R
                  UR                  l        XR                  l        [        R                  R                  U5        g)zs
Unregisters a previously registered RPC method.

Args:
    method (str): The name of the RPC method to unregister
N)r   popr   r   r[   rY   unregister_rpc_methodr   r   r   r   r   )r-   r   r   s      r.   r   &LocalParticipant.unregister_rpc_method  sb     	vt,""$=A=M=M=T=T!!:+1!!(""3'r2   )participant_permissionsc               *   Uc  / n[         R                  " 5       nU R                  R                  UR                  l        XR                  l        UR                  R                  R                  U5        [        R                  R                  U5        g)a\  
Set the track subscription permissions for the local participant.

Args:
    allow_all_participants (bool): Whether to allow all participants to subscribe to this participant's tracks.
    participant_permissions (List[ParticipantTrackPermission]): Participant-specific track subscription permissions, ignored if `allow_all_participants` is True.
N)r   r   r[   rY   "set_track_subscription_permissionsr   all_participants_allowedpermissionsr   r   r   r   )r-   allow_all_participantsr   r   s       r.   r   3LocalParticipant.set_track_subscription_permissions  ss     #*&(#""$JNJZJZJaJa..GJ`..G..::AABYZ""3'r2   c           	       #    S nS n[        X4XV5      n	U R                  R                  U5      n
U
(       d/  [        R                  " [        R
                  R                  5      nO_ [        R                  " U
5      (       a%   [        R                  " U
" U	5      US9I S h  vN nO[        [        [            U
" U	5      5      n [*        R,                  " [/        U R0                  R2                  UU(       a  UR5                  5       OS US9S9n[6        R8                  R;                  U5      nUR<                  R>                  (       a0  UR<                  R>                  n[$        R>                  " SU 35        g g  N! [        R                   a/    [        R                  " [        R
                  R                  5      e[        R                   a/    [        R                  " [        R
                  R                  5      ef = f! [         a  nUn S nAGNOS nAf["         aL    [$        R&                  " SU S35        [        R                  " [        R
                  R(                  5      n GNf = f7f)N)timeoutz+Uncaught error returned by RPC handler for z'. Returning APPLICATION_ERROR instead. )r   invocation_idr   r   )rpc_method_invocation_responsez.error sending rpc method invocation response: ) r    r   getr   	_built_in	ErrorCodeUNSUPPORTED_METHODasyncioiscoroutinefunctionr   TimeoutErrorRESPONSE_TIMEOUTCancelledErrorRECIPIENT_DISCONNECTEDr   r	   r4   	Exceptionr   	exceptionAPPLICATION_ERRORr   r   r   r[   rY   	_to_protor   r   r   r   r   )r-   r   r   
request_idcaller_identityr   r   response_errorresponse_payloadparamsr   r   r   reserrs                  r.   _handle_rpc_method_invocation.LocalParticipant._handle_rpc_method_invocation  s     .2*.":Z$$((0%//0B0B0U0UVNZ..w77\181A1A#FO5E2 ,( (,HSM76?'K$ ""+M)-)9)9)@)@+4Bn..0(	,
   ((---3344::CLLI#OP 4;, #// V&001C1C1T1TUU"11 \&001C1C1Z1Z[[\  '!& Z  A& J< < "*!3!3H4F4F4X4X!YZso   A"I.%H  E9 E7 E9 $I.%H  B5I.7E9 9BG==H   
I+
HI.AI+'I.*I++I.c                  ^#    [         R                  " 5       nU R                  R                  UR                  l        XR                  l        [        R                  R                  R                  5       n [        R                  R                  U5      mUR                  U4S j5      I Sh  vN   [        R                  R                  R                  U5        g N.! [        R                  R                  R                  U5        f = f7f)z
Set the metadata for the local participant.

Note: this requires `canUpdateOwnMetadata` permission.

Args:
    metadata (str): The new metadata.
c                ^   > U R                   R                  TR                   R                  :H  $ r)   )set_local_metadatar   r   s    r.   r   /LocalParticipant.set_metadata.<locals>.<lambda>  s"    !..774;R;R;[;[[r2   N)r   r   r[   rY   r  r   rn   r   r   r   r   r   r   r   )r-   rn   r   r   r   s       @r.   set_metadataLocalParticipant.set_metadata  s      ""$:>:J:J:Q:Q7*2'""((224	8%%--c2D..[   $$007	 $$0070   A3D77C .C/C 3*DC +D

Dc                  ^#    [         R                  " 5       nU R                  R                  UR                  l        XR                  l        [        R                  R                  R                  5       n [        R                  R                  U5      mUR                  U4S j5      I Sh  vN   [        R                  R                  R                  U5        g N.! [        R                  R                  R                  U5        f = f7f)z
Set the name for the local participant.

Note: this requires `canUpdateOwnMetadata` permission.

Args:
    name (str): The new name.
c                ^   > U R                   R                  TR                   R                  :H  $ r)   )set_local_namer   r   s    r.   r   +LocalParticipant.set_name.<locals>.<lambda>  s"    !**33t7J7J7S7SSr2   N)r   r   r[   rY   r  r   rg   r   r   r   r   r   r   r   )r-   rg   r   r   r   s       @r.   set_nameLocalParticipant.set_name  s      ""$6:6F6F6M6M3"&""((224	8%%--c2D..S   $$007	 $$007r  c                0  ^#    [         R                  " 5       nU R                  R                  UR                  l        UR                  R                   Vs0 s H  o3R                  UR                  _M     nnUR                  U5        UR                  5        H5  u  pVUR                  R                  R                  5       nXSl        Xcl        M7     [        R                  R                  R                  5       n [        R                  R!                  U5      mUR#                  U4S j5      I Sh  vN   [        R                  R                  R%                  U5        gs  snf  N3! [        R                  R                  R%                  U5        f = f7f)z
Set custom attributes for the local participant.

Note: this requires `canUpdateOwnMetadata` permission.

Args:
    attributes (dict[str, str]): A dictionary of attributes to set.
c                ^   > U R                   R                  TR                   R                  :H  $ r)   )set_local_attributesr   r   s    r.   r   1LocalParticipant.set_attributes.<locals>.<lambda>#  s"    !0099T=V=V=_=__r2   N)r   r   r[   rY   r  r   rr   keyvalueupdateitemsaddr   r   r   r   r   r   r   )	r-   rr   r   entryexisting_attributesr  r   r   r   s	           @r.   set_attributesLocalParticipant.set_attributes
  s@     ""$<@<L<L<S<S  9030H0H0S0S
0SuIIu{{"0S 	 
 	"":.-335JC,,77;;=EIK 6
 ""((224	8%%--c2D.._   $$007#
 $$007s=   AF E!6BF;7E( 2E&3E( 7/F&E( (+FF)r   r   rr   	stream_idreply_to_id
total_sizesender_identityc               b   #    [        U UUUUUUUS9nUR                  5       I Sh  vN   U$  N7f)z
Returns a TextStreamWriter that allows to write individual chunks of text to a text stream.
In most cases where you want to simply send a text message use send_text() instead.
)r   rr   r)  r   r*  r(  r+  N)r!   _send_header)	r-   r   r   rr   r(  r)  r*  r+  writers	            r.   stream_textLocalParticipant.stream_text(  sG      "!##9!+	
 !!### 	$   $/-/)r   r   rr   r)  c                  #    [        UR                  5       5      nU R                  UUUUUS9I S h  vN nUR                  U5      I S h  vN   UR	                  5       I S h  vN   UR
                  $  NA N* N7f)N)r   r   rr   r)  r*  )r   r   r/  writeacloserW   )r-   r   r   r   rr   r)  r*  r.  s           r.   	send_textLocalParticipant.send_textF  sz      '
''#9!#! ( 
 
 ll4   mmo{{
 	!s3   0A:A4A:A6A:#A8$A:6A:8A:application/octet-stream)r*  	mime_typerr   r(  r   r   c               b   #    [        U UUUUUUUS9nUR                  5       I Sh  vN   U$  N7f)z
Returns a ByteStreamWriter that allows to write individual chunks of bytes to a byte stream.
In cases where you want to simply send a file from the file system use send_file() instead.
)rg   rr   r*  r(  r8  r   r   N)r"   r-  )	r-   rg   r*  r8  rr   r(  r   r   r.  s	            r.   stream_bytesLocalParticipant.stream_bytes]  sG      "!!#9	
 !!### 	$r1  )r   r   rr   r(  c          
       #    [         R                  R                  U5      n[         R                  R                  U5      n[        R
                  " U5      u  pUc  SnU R                  UUUUUUUS9I S h  vN n
[        R                  " US5       IS h  vN nUR                  [        5      I S h  vN =n(       a?  U
R                  U5      I S h  vN   UR                  [        5      I S h  vN =n(       a  M?  S S S 5      IS h  vN   U
R                  5       I S h  vN   U
R                  $  N N N Nd NI N2! , IS h  vN  (       d  f       NG= f N67f)Nr7  )rg   r*  r8  rr   r(  r   r   rb)ospathgetsizebasename	mimetypes
guess_typer:  aiofilesopenreadr$   r3  r4  rW   )r-   	file_pathr   r   rr   r(  	file_size	file_namer8  _r.  fbytess                r.   	send_fileLocalParticipant.send_file{  s     GGOOI.	GG$$Y/	 ++I6	2I)-):): !#9 *; *
 $
 ==D11Q!"(9!:::%:ll5))) "#(9!:::%: 21 mmo{{$
 2:) ; 2111 	s   A4E6D27ED4ED>3D64D>D8D>0D:1D>>E	D<
E!E"E4E6D>8D>:D><E>EEEEc                  ^#    [         R                  " 5       nUR                  R                  UR                  l        U R                  R                  UR                  l        UR                  R                  R                  U5        U R                  R                  5       n [        R                  R                  U5      mUR                  U4S j5      I Sh  vN nUR                  R                  (       a  [!        UR                  R                  5      e[#        UR                  R$                  5      nXl        UR(                  UR*                  l        X`R,                  UR(                  '   UR/                  5         UU R                  R1                  U5        $  N! U R                  R1                  U5        f = f7f)aC  
Publish a local track to the room.

Args:
    track (LocalTrack): The track to publish.
    options (TrackPublishOptions, optional): Options for publishing the track.

Returns:
    LocalTrackPublication: The publication of the published track.

Raises:
    PublishTrackError: If there is an error in publishing the track.
c                ^   > U R                   R                  TR                   R                  :H  $ r)   )publish_trackr   r   s    r.   r   0LocalParticipant.publish_track.<locals>.<lambda>  s     !//22d6H6H6Q6QQr2   N)r   r   r[   rY   rQ  track_handler   optionsCopyFromr   r   r   r   r   r   r   r&   r   publication_trackrd   rX   r   	task_doner   )r-   trackrT  r   r   r   track_publicationr   s          @r.   rQ  LocalParticipant.publish_track  sQ      ""$).):):)A)A&595E5E5L5L2!!**73  **,	0%%--c2D+0>>Q, &B %%'(8(8(>(>?? 5b6F6F6R6R S',$/33EKKO>O$$%6%:%:;OO$((/& ((/s1   BG #7F  FB'F  G F   F==G c                  ^#    [         R                  " 5       nU R                  R                  UR                  l        XR                  l        SUR                  l        U R                  R                  5       n [        R                  R                  U5      mUR                  U4S j5      I Sh  vN nUR                  R                  (       a  [        UR                  R                  5      eU R                   R#                  U5      nSUl        UR'                  5         U R                  R)                  U5        g N! U R                  R)                  U5        f = f7f)z
Unpublish a track from the room.

Args:
    track_sid (str): The SID of the track to unpublish.

Raises:
    UnpublishTrackError: If there is an error in unpublishing the track.
Tc                ^   > U R                   R                  TR                   R                  :H  $ r)   )unpublish_trackr   r   s    r.   r   2LocalParticipant.unpublish_track.<locals>.<lambda>  s"    !++448L8L8U8UUr2   N)r   r   r[   rY   r^  r   r   stop_on_unpublishr   r   r   r   r   r   r   r@   r   r   rW  rX  r   )r-   r   r   r   r   rV  r   s         @r.   r^   LocalParticipant.unpublish_track  s     ""$7;7G7G7N7N4(1%04-  **,	0%%--c2D+0>>U, &B !!'')"*<*<*B*BCC2266yAK!%KOO((/& ((/s1   A6E :7E  1D>2A0E  "E >E   EE c                V    SU R                    SU R                   SU R                   S3$ )Nzrtc.LocalParticipant(sid=, identity=, name=)rd   rj   rg   r`   s    r.   __repr__LocalParticipant.__repr__  s.    *488*KgVZV_V_U``abbr2   )r   r   r   )r   z"BroadcastQueue[proto_ffi.FfiEvent]r\   r~   r5   r6   )r5   z#Mapping[str, LocalTrackPublication])
r   zUnion[bytes, str]r   boolr   z	List[str]r   r4   r5   r6   )r   r   r   r4   r5   r6   )r   r   r5   r6   )
r   r4   r   r4   r   r4   r   zOptional[float]r5   r4   r)   )r   r4   r   zOptional[F]r5   zUnion[F, Callable[[F], F]])r   r4   r5   r6   )r   ri  r   z*Optional[List[ParticipantTrackPermission]]r5   r6   )r   r   r   r4   r  r4   r  r4   r   r4   r   floatr5   r6   )rn   r4   r5   r6   )rg   r4   r5   r6   )rr   r   r5   r6   )r   Optional[List[str]]r   r4   rr   Optional[Dict[str, str]]r(  
str | Noner)  rm  r*  
int | Noner+  rm  r5   r!   )
r   r4   r   rk  r   r4   rr   rl  r)  rm  )rg   r4   r*  rn  r8  r4   rr   rl  r(  rm  r   rk  r   r4   r5   r"   )rG  r4   r   r4   r   rk  rr   rl  r(  rm  r5   r#   )rY  r   rT  r   r5   r   )r   r4   r5   r6   r   )r8   r9   r:   r;   __doc__r/   r   ra   r   r   r   r   r   r   r   r  r  r  r&  r/  r5  r:  rM  r   rQ  r^  rg  r<   __classcell__r   s   @r.   r   r      s   5767 77 
	7 ( ( ,.,:",: 	,:
 !*,: ,: 
,:\>8&L\ -1+& "+& 	+&
 +& *+& 
+&`  $44 4 
$	4l(& OS	( !%( "L	(
 
(,5Q5Q 5Q 	5Q
 5Q 5Q  5Q 
5Qn8,8,8B 7;/3 $"&!%&* !4 	
 -     $ 
D 7;/3"& !4	
  -  6 "&3/3 $6: 	
  -  !4  
D 6:/3 $ 	
 !4 -  
B AT@U'0'0*='0	'0R0>c cr2   r   c                  J   ^  \ rS rSrSU 4S jjr\SS j5       rSS jrSrU =r	$ )	RemoteParticipanti  c                2   > [         TU ]  U5        0 U l        g r)   )r   r/   r   )r-   r\   r   s     r.   r/   RemoteParticipant.__init__  s    $FH r2   c                    U R                   $ r   r   r`   s    r.   ra   $RemoteParticipant.track_publications  r   r2   c                V    SU R                    SU R                   SU R                   S3$ )Nzrtc.RemoteParticipant(sid=rc  rd  re  rf  r`   s    r.   rg  RemoteParticipant.__repr__  s.    +DHH:[wW[W`W`Vaabccr2   r   r}   )r5   z$Mapping[str, RemoteTrackPublication]r   )
r8   r9   r:   r;   r/   r   ra   rg  r<   rp  rq  s   @r.   rs  rs    s)    I ( (d dr2   rs  )D
__future__r   r   r   r>  rB  rD  typingr   r   r   r   r   r	   r
   r   r   abcr   r   _ffi_clientr   r   _protor   r   r   ry   _proto.room_pb2r   r   r   _proto.track_pb2r   _utilsr   rY  r   rZ  r   r   r   r   r   rpcr   _proto.rpc_pb2r   logr   r    data_streamr!   r"   r#   r$   r  r&   r@   rE   rJ   rO   rT   r4   
RpcHandlerr   r   rs  r=   r2   r.   <module>r     s4   #   	   [ [ [ # - ( 8 #  
 )  >  " 	 
) 
y 
y 
	 
=,# =,@ *+U9Xc]3KXVY]3Z-[[\
x*+U9Xc]3KXVY]3Z-[[\
K	c{ K	c\d dr2   