- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.2k
          Migrated modules/RTC/RTC.ts
          #2879
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| Hi, thanks for your contribution! | 
43550ea    to
    5ce95dd      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the modules/RTC/RTC.ts file to TypeScript by adding comprehensive type definitions and interfaces. The migration transforms JavaScript functions and class methods to TypeScript with proper type annotations while maintaining the existing functionality.
Key changes:
- Added TypeScript interfaces for RTC options, media stream metadata, and peer connection configurations
- Converted class methods and static functions to use explicit TypeScript typing
- Reorganized method declarations with proper access modifiers and type safety
- Added type annotations for parameters, return values, and class properties
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description | 
|---|---|
| modules/RTC/RTC.ts | Complete TypeScript migration with comprehensive interfaces and type definitions | 
| modules/RTC/JitsiLocalTrack.ts | Changed method visibility from private to public with @internal annotation | 
| modules/RTC/BridgeChannel.ts | Updated import to use interface instead of concrete class | 
| JitsiMediaDevices.ts | Added @ts-ignore comment for type compatibility | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
        
          
                modules/RTC/RTC.ts
              
                Outdated
          
        
      | this._receiverVideoConstraints = cloneDeep(constraints); | ||
|  | ||
| if (this._channel && this._channel.isOpen()) { | ||
| if (this?._channel.isOpen()) { | 
    
      
    
      Copilot
AI
    
    
    
      Aug 28, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chaining operator ?. is incorrect here. Since _channel is being checked for truthiness, it should be this._channel?.isOpen() or this._channel && this._channel.isOpen() to properly handle null/undefined cases.
        
          
                modules/RTC/RTC.ts
              
                Outdated
          
        
      | sendSourceVideoType(sourceName, videoType) { | ||
| if (this._channel && this._channel.isOpen()) { | ||
| public sendSourceVideoType(sourceName: SourceName, videoType: BridgeVideoType): void { | ||
| if (this?._channel.isOpen()) { | 
    
      
    
      Copilot
AI
    
    
    
      Aug 28, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chaining operator ?. is incorrect here. Since _channel is being checked for truthiness, it should be this._channel?.isOpen() or this._channel && this._channel.isOpen() to properly handle null/undefined cases.
        
          
                modules/RTC/RTC.ts
              
                Outdated
          
        
      | sendEndpointStatsMessage(payload) { | ||
| if (this._channel && this._channel.isOpen()) { | ||
| public sendEndpointStatsMessage(payload: any): void { | ||
| if (this?._channel.isOpen()) { | 
    
      
    
      Copilot
AI
    
    
    
      Aug 28, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chaining operator ?. is incorrect here. Since _channel is being checked for truthiness, it should be this._channel?.isOpen() or this._channel && this._channel.isOpen() to properly handle null/undefined cases.
        
          
                modules/RTC/RTC.ts
              
                Outdated
          
        
      | sendReceiverAudioSubscriptionMessage(message) { | ||
| if (this._channel && this._channel.isOpen()) { | ||
| public sendReceiverAudioSubscriptionMessage(message: any): void { | ||
| if (this?._channel.isOpen()) { | 
    
      
    
      Copilot
AI
    
    
    
      Aug 28, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chaining operator ?. is incorrect here. Since _channel is being checked for truthiness, it should be this._channel?.isOpen() or this._channel && this._channel.isOpen() to properly handle null/undefined cases.
        
          
                modules/RTC/RTC.ts
              
                Outdated
          
        
      | if (this._lastN !== value) { | ||
| this._lastN = value; | ||
| if (this._channel && this._channel.isOpen()) { | ||
| if (this?._channel.isOpen()) { | 
    
      
    
      Copilot
AI
    
    
    
      Aug 28, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chaining operator ?. is incorrect here. Since _channel is being checked for truthiness, it should be this._channel?.isOpen() or this._channel && this._channel.isOpen() to properly handle null/undefined cases.
        
          
                modules/RTC/RTC.ts
              
                Outdated
          
        
      | enteringForwardedSources = forwardedSources.filter( | ||
| sourceName => oldForwardedSources.indexOf(sourceName) === -1); | ||
|  | ||
| logger.debug(`Fowarded sources changed leaving=${leavingForwardedSources}, entering=` | 
    
      
    
      Copilot
AI
    
    
    
      Aug 28, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the debug message: 'Fowarded' should be 'Forwarded'.
| logger.debug(`Fowarded sources changed leaving=${leavingForwardedSources}, entering=` | |
| logger.debug(`Forwarded sources changed leaving=${leavingForwardedSources}, entering=` | 
        
          
                JitsiMediaDevices.ts
              
                Outdated
          
        
      | // We would still want to update the permissions cache in case the permissions API is not supported. | ||
| RTC.addListener( | ||
| RTCEvents.PERMISSIONS_CHANGED, | ||
| // @ts-ignore | 
    
      
    
      Copilot
AI
    
    
    
      Aug 28, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using @ts-ignore suppresses type checking without addressing the underlying type issue. Consider fixing the type mismatch or using a more specific TypeScript directive like @ts-expect-error with an explanation.
| // @ts-ignore | |
| // @ts-expect-error: The type of 'permissions' from RTCEvents.PERMISSIONS_CHANGED may not match the expected type for _handlePermissionsChange, but this is intentional due to legacy event payloads. | 
| changes dine and rebased please take a look | 
| * @param options | ||
| */ | ||
| constructor(conference, options = {}) { | ||
| constructor(conference: JitsiConference, options: IRTCOptions | IConferenceOptions = {}) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it the union of both types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i put the union of it IRTCOptions | IConferenceOptions
| public conference: JitsiConference; | ||
| public peerConnections: Map<number, TraceablePeerConnection>; | ||
| public localTracks: JitsiLocalTrack[]; | ||
| public options: IRTCOptions | IConferenceOptions; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have defined this above as static.
        
          
                modules/RTC/RTC.ts
              
                Outdated
          
        
      | timestamp); | ||
| } | ||
|  | ||
| /* eslint-enable max-params */ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this? if we do, please keep it as narrow as possible, just for the one function(s)
        
          
                modules/RTC/RTC.ts
              
                Outdated
          
        
      | * @param eventType | ||
| * @param listener | ||
| */ | ||
| public static addListener(eventType: string, listener: EventListener): void { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class already extends from Listenable, what's going on here?
        
          
                modules/xmpp/JingleSessionPC.ts
              
                Outdated
          
        
      | audioQuality: options.audioQuality, | ||
| capScreenshareBitrate: undefined, | ||
| codecSettings: options.codecSettings, | ||
| codecSettings: options.codecSettings ? { codecList: options.codecSettings } : undefined, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right?
| updated and rebased please take a look. | 
ee0b1ba    to
    3dc7f21      
    Compare
  
    | ping @saghul , @jallamsetty1 | 
| Jenkins please test this please. | 
No description provided.