Skip to content

Commit

Permalink
typescript implementation of JitsiTrackEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
garyhuntddn authored and jallamsetty1 committed Mar 2, 2022
1 parent 313e0dd commit 3d30f58
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 120 deletions.
58 changes: 0 additions & 58 deletions JitsiTrackEvents.js

This file was deleted.

23 changes: 12 additions & 11 deletions JitsiTrackEvents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe( "/JitsiTrackEvents members", () => {
NO_AUDIO_INPUT,
JitsiTrackEvents,
...others
} = exported as any; // TODO: remove cast after typescript conversion
} = exported;

it( "known members", () => {
expect( LOCAL_TRACK_STOPPED ).toBe( 'track.stopped' );
Expand All @@ -24,16 +24,17 @@ describe( "/JitsiTrackEvents members", () => {
expect( TRACK_VIDEOTYPE_CHANGED ).toBe( 'track.videoTypeChanged' );
expect( NO_DATA_FROM_SOURCE ).toBe( 'track.no_data_from_source' );
expect( NO_AUDIO_INPUT ).toBe( 'track.no_audio_input' );
if ( JitsiTrackEvents ) {
expect( JitsiTrackEvents.LOCAL_TRACK_STOPPED ).toBe( 'track.stopped' );
expect( JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED ).toBe( 'track.audioLevelsChanged' );
expect( JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED ).toBe( 'track.audioOutputChanged' );
expect( JitsiTrackEvents.TRACK_MUTE_CHANGED ).toBe( 'track.trackMuteChanged' );
expect( JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED ).toBe( 'track.streaming_status_changed' );
expect( JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED ).toBe( 'track.videoTypeChanged' );
expect( JitsiTrackEvents.NO_DATA_FROM_SOURCE ).toBe( 'track.no_data_from_source' );
expect( JitsiTrackEvents.NO_AUDIO_INPUT ).toBe( 'track.no_audio_input' );
}

expect( JitsiTrackEvents ).toBeDefined();

expect( JitsiTrackEvents.LOCAL_TRACK_STOPPED ).toBe( 'track.stopped' );
expect( JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED ).toBe( 'track.audioLevelsChanged' );
expect( JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED ).toBe( 'track.audioOutputChanged' );
expect( JitsiTrackEvents.TRACK_MUTE_CHANGED ).toBe( 'track.trackMuteChanged' );
expect( JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED ).toBe( 'track.streaming_status_changed' );
expect( JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED ).toBe( 'track.videoTypeChanged' );
expect( JitsiTrackEvents.NO_DATA_FROM_SOURCE ).toBe( 'track.no_data_from_source' );
expect( JitsiTrackEvents.NO_AUDIO_INPUT ).toBe( 'track.no_audio_input' );
} );

it( "unknown members", () => {
Expand Down
70 changes: 70 additions & 0 deletions JitsiTrackEvents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
export enum JitsiTrackEvents {
/**
* The media track was removed to the conference.
*/
LOCAL_TRACK_STOPPED = 'track.stopped',

/**
* Audio levels of a this track was changed.
* The first argument is a number with audio level value in range [0, 1].
* The second argument is a <tt>TraceablePeerConnection</tt> which is the peer
* connection which measured the audio level (one audio track can be added
* to multiple peer connection at the same time). This argument is optional for
* local tracks for which we can measure audio level without the peer
* connection (the value will be <tt>undefined</tt>).
*
* NOTE The second argument should be treated as library internal and can be
* removed at any time.
*/
TRACK_AUDIO_LEVEL_CHANGED = 'track.audioLevelsChanged',

/**
* The audio output of the track was changed.
*/
TRACK_AUDIO_OUTPUT_CHANGED = 'track.audioOutputChanged',

/**
* A media track mute status was changed.
*/
TRACK_MUTE_CHANGED = 'track.trackMuteChanged',

/**
* The video type("camera" or "desktop") of the track was changed.
*/
TRACK_VIDEOTYPE_CHANGED = 'track.videoTypeChanged',

/**
* Indicates that the track is not receiving any data even though we expect it
* to receive data (i.e. the stream is not stopped).
*/
NO_DATA_FROM_SOURCE = 'track.no_data_from_source',

/**
* Indicates that the local audio track is not receiving any audio input from
* the microphone that is currently selected.
*/
NO_AUDIO_INPUT = 'track.no_audio_input',

/**
* Event fired whenever video track's streaming changes.
* First argument is the sourceName of the track and the second is a string indicating if the connection is currently
* - active - the connection is active.
* - inactive - the connection is inactive, was intentionally interrupted by the bridge because of low BWE or because
* of the endpoint falling out of last N.
* - interrupted - a network problem occurred.
* - restoring - the connection was inactive and is restoring now.
*
* The current status value can be obtained by calling JitsiRemoteTrack.getTrackStreamingStatus().
*/
TRACK_STREAMING_STATUS_CHANGED = 'track.streaming_status_changed'
};

// exported for backward compatibility
export const LOCAL_TRACK_STOPPED = JitsiTrackEvents.LOCAL_TRACK_STOPPED;
export const TRACK_AUDIO_LEVEL_CHANGED = JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED;
export const TRACK_AUDIO_OUTPUT_CHANGED = JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED;
export const TRACK_MUTE_CHANGED = JitsiTrackEvents.TRACK_MUTE_CHANGED;
export const TRACK_VIDEOTYPE_CHANGED = JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED;
export const NO_DATA_FROM_SOURCE = JitsiTrackEvents.NO_DATA_FROM_SOURCE;
export const NO_AUDIO_INPUT = JitsiTrackEvents.NO_AUDIO_INPUT;
export const TRACK_STREAMING_STATUS_CHANGED = JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED;
112 changes: 61 additions & 51 deletions types/auto/JitsiTrackEvents.d.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,61 @@
/**
* The media track was removed to the conference.
*/
export const LOCAL_TRACK_STOPPED: "track.stopped";
/**
* Audio levels of a this track was changed.
* The first argument is a number with audio level value in range [0, 1].
* The second argument is a <tt>TraceablePeerConnection</tt> which is the peer
* connection which measured the audio level (one audio track can be added
* to multiple peer connection at the same time). This argument is optional for
* local tracks for which we can measure audio level without the peer
* connection (the value will be <tt>undefined</tt>).
*
* NOTE The second argument should be treated as library internal and can be
* removed at any time.
*/
export const TRACK_AUDIO_LEVEL_CHANGED: "track.audioLevelsChanged";
/**
* The audio output of the track was changed.
*/
export const TRACK_AUDIO_OUTPUT_CHANGED: "track.audioOutputChanged";
/**
* A media track mute status was changed.
*/
export const TRACK_MUTE_CHANGED: "track.trackMuteChanged";
/**
* The video type("camera" or "desktop") of the track was changed.
*/
export const TRACK_VIDEOTYPE_CHANGED: "track.videoTypeChanged";
/**
* Indicates that the track is not receiving any data even though we expect it
* to receive data (i.e. the stream is not stopped).
*/
export const NO_DATA_FROM_SOURCE: "track.no_data_from_source";
/**
* Indicates that the local audio track is not receiving any audio input from
* the microphone that is currently selected.
*/
export const NO_AUDIO_INPUT: "track.no_audio_input";
/**
* Event fired whenever video track's streaming changes.
* First argument is the sourceName of the track and the second is a string indicating if the connection is currently
* - active - the connection is active.
* - inactive - the connection is inactive, was intentionally interrupted by the bridge because of low BWE or because
* of the endpoint falling out of last N.
* - interrupted - a network problem occurred.
* - restoring - the connection was inactive and is restoring now.
*
* The current status value can be obtained by calling JitsiRemoteTrack.getTrackStreamingStatus().
*/
export const TRACK_STREAMING_STATUS_CHANGED: "track.streaming_status_changed";
export declare enum JitsiTrackEvents {
/**
* The media track was removed to the conference.
*/
LOCAL_TRACK_STOPPED = "track.stopped",
/**
* Audio levels of a this track was changed.
* The first argument is a number with audio level value in range [0, 1].
* The second argument is a <tt>TraceablePeerConnection</tt> which is the peer
* connection which measured the audio level (one audio track can be added
* to multiple peer connection at the same time). This argument is optional for
* local tracks for which we can measure audio level without the peer
* connection (the value will be <tt>undefined</tt>).
*
* NOTE The second argument should be treated as library internal and can be
* removed at any time.
*/
TRACK_AUDIO_LEVEL_CHANGED = "track.audioLevelsChanged",
/**
* The audio output of the track was changed.
*/
TRACK_AUDIO_OUTPUT_CHANGED = "track.audioOutputChanged",
/**
* A media track mute status was changed.
*/
TRACK_MUTE_CHANGED = "track.trackMuteChanged",
/**
* The video type("camera" or "desktop") of the track was changed.
*/
TRACK_VIDEOTYPE_CHANGED = "track.videoTypeChanged",
/**
* Indicates that the track is not receiving any data even though we expect it
* to receive data (i.e. the stream is not stopped).
*/
NO_DATA_FROM_SOURCE = "track.no_data_from_source",
/**
* Indicates that the local audio track is not receiving any audio input from
* the microphone that is currently selected.
*/
NO_AUDIO_INPUT = "track.no_audio_input",
/**
* Event fired whenever video track's streaming changes.
* First argument is the sourceName of the track and the second is a string indicating if the connection is currently
* - active - the connection is active.
* - inactive - the connection is inactive, was intentionally interrupted by the bridge because of low BWE or because
* of the endpoint falling out of last N.
* - interrupted - a network problem occurred.
* - restoring - the connection was inactive and is restoring now.
*
* The current status value can be obtained by calling JitsiRemoteTrack.getTrackStreamingStatus().
*/
TRACK_STREAMING_STATUS_CHANGED = "track.streaming_status_changed"
}
export declare const LOCAL_TRACK_STOPPED = JitsiTrackEvents.LOCAL_TRACK_STOPPED;
export declare const TRACK_AUDIO_LEVEL_CHANGED = JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED;
export declare const TRACK_AUDIO_OUTPUT_CHANGED = JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED;
export declare const TRACK_MUTE_CHANGED = JitsiTrackEvents.TRACK_MUTE_CHANGED;
export declare const TRACK_VIDEOTYPE_CHANGED = JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED;
export declare const NO_DATA_FROM_SOURCE = JitsiTrackEvents.NO_DATA_FROM_SOURCE;
export declare const NO_AUDIO_INPUT = JitsiTrackEvents.NO_AUDIO_INPUT;
export declare const TRACK_STREAMING_STATUS_CHANGED = JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED;

0 comments on commit 3d30f58

Please sign in to comment.