ソースを参照

typescript implementation of JitsiTrackEvents

tags/v0.0.2
Gary Hunt 3年前
コミット
3d30f587ab
4個のファイルの変更143行の追加120行の削除
  1. 0
    58
      JitsiTrackEvents.js
  2. 12
    11
      JitsiTrackEvents.spec.ts
  3. 70
    0
      JitsiTrackEvents.ts
  4. 61
    51
      types/auto/JitsiTrackEvents.d.ts

+ 0
- 58
JitsiTrackEvents.js ファイルの表示

@@ -1,58 +0,0 @@
1
-/**
2
- * The media track was removed to the conference.
3
- */
4
-export const LOCAL_TRACK_STOPPED = 'track.stopped';
5
-
6
-/**
7
- * Audio levels of a this track was changed.
8
- * The first argument is a number with audio level value in range [0, 1].
9
- * The second argument is a <tt>TraceablePeerConnection</tt> which is the peer
10
- * connection which measured the audio level (one audio track can be added
11
- * to multiple peer connection at the same time). This argument is optional for
12
- * local tracks for which we can measure audio level without the peer
13
- * connection (the value will be <tt>undefined</tt>).
14
- *
15
- * NOTE The second argument should be treated as library internal and can be
16
- * removed at any time.
17
- */
18
-export const TRACK_AUDIO_LEVEL_CHANGED = 'track.audioLevelsChanged';
19
-
20
-/**
21
- * The audio output of the track was changed.
22
- */
23
-export const TRACK_AUDIO_OUTPUT_CHANGED = 'track.audioOutputChanged';
24
-
25
-/**
26
- * A media track mute status was changed.
27
- */
28
-export const TRACK_MUTE_CHANGED = 'track.trackMuteChanged';
29
-
30
-/**
31
- * The video type("camera" or "desktop") of the track was changed.
32
- */
33
-export const TRACK_VIDEOTYPE_CHANGED = 'track.videoTypeChanged';
34
-
35
-/**
36
- * Indicates that the track is not receiving any data even though we expect it
37
- * to receive data (i.e. the stream is not stopped).
38
- */
39
-export const NO_DATA_FROM_SOURCE = 'track.no_data_from_source';
40
-
41
-/**
42
- * Indicates that the local audio track is not receiving any audio input from
43
- * the microphone that is currently selected.
44
- */
45
-export const NO_AUDIO_INPUT = 'track.no_audio_input';
46
-
47
-/**
48
- * Event fired whenever video track's streaming changes.
49
- * First argument is the sourceName of the track and the second is a string indicating if the connection is currently
50
- * - active - the connection is active.
51
- * - inactive - the connection is inactive, was intentionally interrupted by the bridge because of low BWE or because
52
- *   of the endpoint falling out of last N.
53
- * - interrupted - a network problem occurred.
54
- * - restoring - the connection was inactive and is restoring now.
55
- *
56
- * The current status value can be obtained by calling JitsiRemoteTrack.getTrackStreamingStatus().
57
- */
58
-export const TRACK_STREAMING_STATUS_CHANGED = 'track.streaming_status_changed';

+ 12
- 11
JitsiTrackEvents.spec.ts ファイルの表示

@@ -14,7 +14,7 @@ describe( "/JitsiTrackEvents members", () => {
14 14
         NO_AUDIO_INPUT,
15 15
         JitsiTrackEvents,
16 16
         ...others
17
-    } = exported as any; // TODO: remove cast after typescript conversion
17
+    } = exported;
18 18
 
19 19
     it( "known members", () => {
20 20
         expect( LOCAL_TRACK_STOPPED ).toBe( 'track.stopped' );
@@ -24,16 +24,17 @@ describe( "/JitsiTrackEvents members", () => {
24 24
         expect( TRACK_VIDEOTYPE_CHANGED ).toBe( 'track.videoTypeChanged' );
25 25
         expect( NO_DATA_FROM_SOURCE ).toBe( 'track.no_data_from_source' );
26 26
         expect( NO_AUDIO_INPUT ).toBe( 'track.no_audio_input' );
27
-        if ( JitsiTrackEvents ) {
28
-            expect( JitsiTrackEvents.LOCAL_TRACK_STOPPED ).toBe( 'track.stopped' );
29
-            expect( JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED ).toBe( 'track.audioLevelsChanged' );
30
-            expect( JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED ).toBe( 'track.audioOutputChanged' );
31
-            expect( JitsiTrackEvents.TRACK_MUTE_CHANGED ).toBe( 'track.trackMuteChanged' );
32
-            expect( JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED ).toBe( 'track.streaming_status_changed' );
33
-            expect( JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED ).toBe( 'track.videoTypeChanged' );
34
-            expect( JitsiTrackEvents.NO_DATA_FROM_SOURCE ).toBe( 'track.no_data_from_source' );
35
-            expect( JitsiTrackEvents.NO_AUDIO_INPUT ).toBe( 'track.no_audio_input' );
36
-        }
27
+
28
+        expect( JitsiTrackEvents ).toBeDefined();
29
+
30
+        expect( JitsiTrackEvents.LOCAL_TRACK_STOPPED ).toBe( 'track.stopped' );
31
+        expect( JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED ).toBe( 'track.audioLevelsChanged' );
32
+        expect( JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED ).toBe( 'track.audioOutputChanged' );
33
+        expect( JitsiTrackEvents.TRACK_MUTE_CHANGED ).toBe( 'track.trackMuteChanged' );
34
+        expect( JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED ).toBe( 'track.streaming_status_changed' );
35
+        expect( JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED ).toBe( 'track.videoTypeChanged' );
36
+        expect( JitsiTrackEvents.NO_DATA_FROM_SOURCE ).toBe( 'track.no_data_from_source' );
37
+        expect( JitsiTrackEvents.NO_AUDIO_INPUT ).toBe( 'track.no_audio_input' );
37 38
     } );
38 39
 
39 40
     it( "unknown members", () => {

+ 70
- 0
JitsiTrackEvents.ts ファイルの表示

@@ -0,0 +1,70 @@
1
+export enum JitsiTrackEvents {
2
+    /**
3
+     * The media track was removed to the conference.
4
+     */
5
+    LOCAL_TRACK_STOPPED = 'track.stopped',
6
+
7
+    /**
8
+     * Audio levels of a this track was changed.
9
+     * The first argument is a number with audio level value in range [0, 1].
10
+     * The second argument is a <tt>TraceablePeerConnection</tt> which is the peer
11
+     * connection which measured the audio level (one audio track can be added
12
+     * to multiple peer connection at the same time). This argument is optional for
13
+     * local tracks for which we can measure audio level without the peer
14
+     * connection (the value will be <tt>undefined</tt>).
15
+     *
16
+     * NOTE The second argument should be treated as library internal and can be
17
+     * removed at any time.
18
+     */
19
+    TRACK_AUDIO_LEVEL_CHANGED = 'track.audioLevelsChanged',
20
+
21
+    /**
22
+     * The audio output of the track was changed.
23
+     */
24
+    TRACK_AUDIO_OUTPUT_CHANGED = 'track.audioOutputChanged',
25
+
26
+    /**
27
+     * A media track mute status was changed.
28
+     */
29
+    TRACK_MUTE_CHANGED = 'track.trackMuteChanged',
30
+
31
+    /**
32
+     * The video type("camera" or "desktop") of the track was changed.
33
+     */
34
+    TRACK_VIDEOTYPE_CHANGED = 'track.videoTypeChanged',
35
+
36
+    /**
37
+     * Indicates that the track is not receiving any data even though we expect it
38
+     * to receive data (i.e. the stream is not stopped).
39
+     */
40
+    NO_DATA_FROM_SOURCE = 'track.no_data_from_source',
41
+
42
+    /**
43
+     * Indicates that the local audio track is not receiving any audio input from
44
+     * the microphone that is currently selected.
45
+     */
46
+    NO_AUDIO_INPUT = 'track.no_audio_input',
47
+
48
+    /**
49
+     * Event fired whenever video track's streaming changes.
50
+     * First argument is the sourceName of the track and the second is a string indicating if the connection is currently
51
+     * - active - the connection is active.
52
+     * - inactive - the connection is inactive, was intentionally interrupted by the bridge because of low BWE or because
53
+     *   of the endpoint falling out of last N.
54
+     * - interrupted - a network problem occurred.
55
+     * - restoring - the connection was inactive and is restoring now.
56
+     *
57
+     * The current status value can be obtained by calling JitsiRemoteTrack.getTrackStreamingStatus().
58
+     */
59
+    TRACK_STREAMING_STATUS_CHANGED = 'track.streaming_status_changed'
60
+};
61
+
62
+// exported for backward compatibility
63
+export const LOCAL_TRACK_STOPPED = JitsiTrackEvents.LOCAL_TRACK_STOPPED;
64
+export const TRACK_AUDIO_LEVEL_CHANGED = JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED;
65
+export const TRACK_AUDIO_OUTPUT_CHANGED = JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED;
66
+export const TRACK_MUTE_CHANGED = JitsiTrackEvents.TRACK_MUTE_CHANGED;
67
+export const TRACK_VIDEOTYPE_CHANGED = JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED;
68
+export const NO_DATA_FROM_SOURCE = JitsiTrackEvents.NO_DATA_FROM_SOURCE;
69
+export const NO_AUDIO_INPUT = JitsiTrackEvents.NO_AUDIO_INPUT;
70
+export const TRACK_STREAMING_STATUS_CHANGED = JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED;

+ 61
- 51
types/auto/JitsiTrackEvents.d.ts ファイルの表示

@@ -1,51 +1,61 @@
1
-/**
2
- * The media track was removed to the conference.
3
- */
4
-export const LOCAL_TRACK_STOPPED: "track.stopped";
5
-/**
6
- * Audio levels of a this track was changed.
7
- * The first argument is a number with audio level value in range [0, 1].
8
- * The second argument is a <tt>TraceablePeerConnection</tt> which is the peer
9
- * connection which measured the audio level (one audio track can be added
10
- * to multiple peer connection at the same time). This argument is optional for
11
- * local tracks for which we can measure audio level without the peer
12
- * connection (the value will be <tt>undefined</tt>).
13
- *
14
- * NOTE The second argument should be treated as library internal and can be
15
- * removed at any time.
16
- */
17
-export const TRACK_AUDIO_LEVEL_CHANGED: "track.audioLevelsChanged";
18
-/**
19
- * The audio output of the track was changed.
20
- */
21
-export const TRACK_AUDIO_OUTPUT_CHANGED: "track.audioOutputChanged";
22
-/**
23
- * A media track mute status was changed.
24
- */
25
-export const TRACK_MUTE_CHANGED: "track.trackMuteChanged";
26
-/**
27
- * The video type("camera" or "desktop") of the track was changed.
28
- */
29
-export const TRACK_VIDEOTYPE_CHANGED: "track.videoTypeChanged";
30
-/**
31
- * Indicates that the track is not receiving any data even though we expect it
32
- * to receive data (i.e. the stream is not stopped).
33
- */
34
-export const NO_DATA_FROM_SOURCE: "track.no_data_from_source";
35
-/**
36
- * Indicates that the local audio track is not receiving any audio input from
37
- * the microphone that is currently selected.
38
- */
39
-export const NO_AUDIO_INPUT: "track.no_audio_input";
40
-/**
41
- * Event fired whenever video track's streaming changes.
42
- * First argument is the sourceName of the track and the second is a string indicating if the connection is currently
43
- * - active - the connection is active.
44
- * - inactive - the connection is inactive, was intentionally interrupted by the bridge because of low BWE or because
45
- *   of the endpoint falling out of last N.
46
- * - interrupted - a network problem occurred.
47
- * - restoring - the connection was inactive and is restoring now.
48
- *
49
- * The current status value can be obtained by calling JitsiRemoteTrack.getTrackStreamingStatus().
50
- */
51
-export const TRACK_STREAMING_STATUS_CHANGED: "track.streaming_status_changed";
1
+export declare enum JitsiTrackEvents {
2
+    /**
3
+     * The media track was removed to the conference.
4
+     */
5
+    LOCAL_TRACK_STOPPED = "track.stopped",
6
+    /**
7
+     * Audio levels of a this track was changed.
8
+     * The first argument is a number with audio level value in range [0, 1].
9
+     * The second argument is a <tt>TraceablePeerConnection</tt> which is the peer
10
+     * connection which measured the audio level (one audio track can be added
11
+     * to multiple peer connection at the same time). This argument is optional for
12
+     * local tracks for which we can measure audio level without the peer
13
+     * connection (the value will be <tt>undefined</tt>).
14
+     *
15
+     * NOTE The second argument should be treated as library internal and can be
16
+     * removed at any time.
17
+     */
18
+    TRACK_AUDIO_LEVEL_CHANGED = "track.audioLevelsChanged",
19
+    /**
20
+     * The audio output of the track was changed.
21
+     */
22
+    TRACK_AUDIO_OUTPUT_CHANGED = "track.audioOutputChanged",
23
+    /**
24
+     * A media track mute status was changed.
25
+     */
26
+    TRACK_MUTE_CHANGED = "track.trackMuteChanged",
27
+    /**
28
+     * The video type("camera" or "desktop") of the track was changed.
29
+     */
30
+    TRACK_VIDEOTYPE_CHANGED = "track.videoTypeChanged",
31
+    /**
32
+     * Indicates that the track is not receiving any data even though we expect it
33
+     * to receive data (i.e. the stream is not stopped).
34
+     */
35
+    NO_DATA_FROM_SOURCE = "track.no_data_from_source",
36
+    /**
37
+     * Indicates that the local audio track is not receiving any audio input from
38
+     * the microphone that is currently selected.
39
+     */
40
+    NO_AUDIO_INPUT = "track.no_audio_input",
41
+    /**
42
+     * Event fired whenever video track's streaming changes.
43
+     * First argument is the sourceName of the track and the second is a string indicating if the connection is currently
44
+     * - active - the connection is active.
45
+     * - inactive - the connection is inactive, was intentionally interrupted by the bridge because of low BWE or because
46
+     *   of the endpoint falling out of last N.
47
+     * - interrupted - a network problem occurred.
48
+     * - restoring - the connection was inactive and is restoring now.
49
+     *
50
+     * The current status value can be obtained by calling JitsiRemoteTrack.getTrackStreamingStatus().
51
+     */
52
+    TRACK_STREAMING_STATUS_CHANGED = "track.streaming_status_changed"
53
+}
54
+export declare const LOCAL_TRACK_STOPPED = JitsiTrackEvents.LOCAL_TRACK_STOPPED;
55
+export declare const TRACK_AUDIO_LEVEL_CHANGED = JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED;
56
+export declare const TRACK_AUDIO_OUTPUT_CHANGED = JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED;
57
+export declare const TRACK_MUTE_CHANGED = JitsiTrackEvents.TRACK_MUTE_CHANGED;
58
+export declare const TRACK_VIDEOTYPE_CHANGED = JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED;
59
+export declare const NO_DATA_FROM_SOURCE = JitsiTrackEvents.NO_DATA_FROM_SOURCE;
60
+export declare const NO_AUDIO_INPUT = JitsiTrackEvents.NO_AUDIO_INPUT;
61
+export declare const TRACK_STREAMING_STATUS_CHANGED = JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED;

読み込み中…
キャンセル
保存