@100mslive/react-native-hms 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +52 -24
  2. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +245 -62
  3. package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +15 -6
  4. package/ios/HMSConstants.swift +3 -1
  5. package/ios/HMSDecoder.swift +1 -1
  6. package/ios/HMSHelper.swift +44 -7
  7. package/ios/HMSManager.m +8 -0
  8. package/ios/HMSManager.swift +35 -1
  9. package/ios/HMSRNSDK.swift +268 -38
  10. package/lib/commonjs/classes/HMSAudioTrackSettings.js +14 -0
  11. package/lib/commonjs/classes/HMSAudioTrackSettings.js.map +1 -1
  12. package/lib/commonjs/classes/HMSEncoder.js +2 -1
  13. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  14. package/lib/commonjs/classes/HMSIOSAudioMode.js +13 -0
  15. package/lib/commonjs/classes/HMSIOSAudioMode.js.map +1 -0
  16. package/lib/commonjs/classes/HMSSDK.js +50 -0
  17. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  18. package/lib/commonjs/classes/HMSSessionStore.js +173 -0
  19. package/lib/commonjs/classes/HMSSessionStore.js.map +1 -0
  20. package/lib/commonjs/classes/HMSUpdateListenerActions.js +8 -0
  21. package/lib/commonjs/classes/HMSUpdateListenerActions.js.map +1 -1
  22. package/lib/commonjs/classes/HMSVideoTrackSettings.js +5 -0
  23. package/lib/commonjs/classes/HMSVideoTrackSettings.js.map +1 -1
  24. package/lib/commonjs/index.js +12 -0
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/utils/emitter/EventEmitter.js +162 -0
  27. package/lib/commonjs/utils/emitter/EventEmitter.js.map +1 -0
  28. package/lib/commonjs/utils/emitter/_EmitterSubscription.js +46 -0
  29. package/lib/commonjs/utils/emitter/_EmitterSubscription.js.map +1 -0
  30. package/lib/commonjs/utils/emitter/_EventSubscription.js +36 -0
  31. package/lib/commonjs/utils/emitter/_EventSubscription.js.map +1 -0
  32. package/lib/commonjs/utils/emitter/_EventSubscriptionVendor.js +90 -0
  33. package/lib/commonjs/utils/emitter/_EventSubscriptionVendor.js.map +1 -0
  34. package/lib/commonjs/utils/index.js +17 -0
  35. package/lib/commonjs/utils/index.js.map +1 -0
  36. package/lib/module/classes/HMSAudioTrackSettings.js +14 -0
  37. package/lib/module/classes/HMSAudioTrackSettings.js.map +1 -1
  38. package/lib/module/classes/HMSEncoder.js +2 -1
  39. package/lib/module/classes/HMSEncoder.js.map +1 -1
  40. package/lib/module/classes/HMSIOSAudioMode.js +6 -0
  41. package/lib/module/classes/HMSIOSAudioMode.js.map +1 -0
  42. package/lib/module/classes/HMSSDK.js +50 -0
  43. package/lib/module/classes/HMSSDK.js.map +1 -1
  44. package/lib/module/classes/HMSSessionStore.js +166 -0
  45. package/lib/module/classes/HMSSessionStore.js.map +1 -0
  46. package/lib/module/classes/HMSUpdateListenerActions.js +8 -0
  47. package/lib/module/classes/HMSUpdateListenerActions.js.map +1 -1
  48. package/lib/module/classes/HMSVideoTrackSettings.js +5 -0
  49. package/lib/module/classes/HMSVideoTrackSettings.js.map +1 -1
  50. package/lib/module/index.js +1 -0
  51. package/lib/module/index.js.map +1 -1
  52. package/lib/module/utils/emitter/EventEmitter.js +151 -0
  53. package/lib/module/utils/emitter/EventEmitter.js.map +1 -0
  54. package/lib/module/utils/emitter/_EmitterSubscription.js +39 -0
  55. package/lib/module/utils/emitter/_EmitterSubscription.js.map +1 -0
  56. package/lib/module/utils/emitter/_EventSubscription.js +29 -0
  57. package/lib/module/utils/emitter/_EventSubscription.js.map +1 -0
  58. package/lib/module/utils/emitter/_EventSubscriptionVendor.js +83 -0
  59. package/lib/module/utils/emitter/_EventSubscriptionVendor.js.map +1 -0
  60. package/lib/module/utils/index.js +2 -0
  61. package/lib/module/utils/index.js.map +1 -0
  62. package/lib/typescript/classes/HMSAudioTrackSettings.d.ts +14 -0
  63. package/lib/typescript/classes/HMSIOSAudioMode.d.ts +4 -0
  64. package/lib/typescript/classes/HMSSDK.d.ts +16 -0
  65. package/lib/typescript/classes/HMSSessionStore.d.ts +63 -0
  66. package/lib/typescript/classes/HMSUpdateListenerActions.d.ts +9 -1
  67. package/lib/typescript/classes/HMSVideoTrackSettings.d.ts +5 -0
  68. package/lib/typescript/index.d.ts +2 -0
  69. package/lib/typescript/utils/emitter/EventEmitter.d.ts +91 -0
  70. package/lib/typescript/utils/emitter/_EmitterSubscription.d.ts +29 -0
  71. package/lib/typescript/utils/emitter/_EventSubscription.d.ts +19 -0
  72. package/lib/typescript/utils/emitter/_EventSubscriptionVendor.d.ts +44 -0
  73. package/lib/typescript/utils/index.d.ts +1 -0
  74. package/package.json +21 -2
  75. package/sdk-versions.json +2 -2
  76. package/src/classes/HMSAudioTrackSettings.ts +16 -0
  77. package/src/classes/HMSEncoder.ts +1 -0
  78. package/src/classes/HMSIOSAudioMode.ts +4 -0
  79. package/src/classes/HMSSDK.tsx +70 -4
  80. package/src/classes/HMSSessionStore.ts +209 -0
  81. package/src/classes/HMSUpdateListenerActions.ts +8 -0
  82. package/src/classes/HMSVideoTrackSettings.ts +5 -0
  83. package/src/index.ts +5 -0
  84. package/src/utils/emitter/EventEmitter.ts +160 -0
  85. package/src/utils/emitter/_EmitterSubscription.ts +44 -0
  86. package/src/utils/emitter/_EventSubscription.ts +28 -0
  87. package/src/utils/emitter/_EventSubscriptionVendor.ts +89 -0
  88. package/src/utils/index.ts +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EventSubscriptionVendor","constructor","_defineProperty","_subscriptionsForType","_currentSubscription","addSubscription","eventType","subscription","subscriber","console","warn","eventSubscriptions","key","length","push","removeAllSubscriptions","undefined","removeSubscription","subscriptionsForType","getSubscriptionsForType"],"sources":["_EventSubscriptionVendor.ts"],"sourcesContent":["import type { EventSubscription } from './_EventSubscription';\n\n/**\n * EventSubscriptionVendor stores a set of EventSubscriptions that are\n * subscribed to a particular event type.\n */\nexport class EventSubscriptionVendor {\n _subscriptionsForType: Record<string, EventSubscription[] | null | undefined>;\n _currentSubscription: EventSubscription | null | undefined;\n\n constructor() {\n this._subscriptionsForType = {};\n this._currentSubscription = null;\n }\n\n /**\n * Adds a subscription keyed by an event type.\n *\n * @param {string} eventType\n * @param {EventSubscription} subscription\n */\n addSubscription(\n eventType: string,\n subscription: EventSubscription\n ): EventSubscription {\n if (subscription.subscriber !== this) {\n console.warn('The subscriber of the subscription is incorrectly set.'); // TODO: throw error or use logger?\n }\n if (!this._subscriptionsForType[eventType]) {\n this._subscriptionsForType[eventType] = [];\n }\n const eventSubscriptions = this._subscriptionsForType[\n eventType\n ] as EventSubscription[];\n const key = eventSubscriptions.length;\n eventSubscriptions.push(subscription);\n subscription.eventType = eventType;\n subscription.key = key;\n return subscription;\n }\n\n /**\n * Removes a bulk set of the subscriptions.\n *\n * @param {?string} eventType - Optional name of the event type whose\n * registered supscriptions to remove, if null or undefined remove all subscriptions.\n */\n removeAllSubscriptions(eventType: string | undefined | null) {\n if (eventType === undefined || eventType === null) {\n this._subscriptionsForType = {};\n } else {\n delete this._subscriptionsForType[eventType];\n }\n }\n\n /**\n * Removes a specific subscription. Instead of calling this function, call\n * `subscription.remove()` directly.\n *\n * @param {object} subscription\n */\n removeSubscription(subscription: EventSubscription) {\n const eventType = subscription.eventType;\n const key = subscription.key;\n\n const subscriptionsForType = this._subscriptionsForType[eventType];\n if (subscriptionsForType) {\n delete subscriptionsForType[key];\n }\n }\n\n /**\n * Returns the array of subscriptions that are currently registered for the\n * given event type.\n *\n * Note: This array can be potentially sparse as subscriptions are deleted\n * from it when they are removed.\n *\n * TODO: This returns a nullable array. wat?\n *\n * @param {string} eventType\n * @returns {?array}\n */\n getSubscriptionsForType(\n eventType: string\n ): EventSubscription[] | null | undefined {\n return this._subscriptionsForType[eventType];\n }\n}\n"],"mappings":";;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMA,uBAAuB,CAAC;EAInCC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IAAAA,eAAA;IACZ,IAAI,CAACC,qBAAqB,GAAG,CAAC,CAAC;IAC/B,IAAI,CAACC,oBAAoB,GAAG,IAAI;EAClC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEC,eAAeA,CACbC,SAAiB,EACjBC,YAA+B,EACZ;IACnB,IAAIA,YAAY,CAACC,UAAU,KAAK,IAAI,EAAE;MACpCC,OAAO,CAACC,IAAI,CAAC,wDAAwD,CAAC,CAAC,CAAC;IAC1E;;IACA,IAAI,CAAC,IAAI,CAACP,qBAAqB,CAACG,SAAS,CAAC,EAAE;MAC1C,IAAI,CAACH,qBAAqB,CAACG,SAAS,CAAC,GAAG,EAAE;IAC5C;IACA,MAAMK,kBAAkB,GAAG,IAAI,CAACR,qBAAqB,CACnDG,SAAS,CACa;IACxB,MAAMM,GAAG,GAAGD,kBAAkB,CAACE,MAAM;IACrCF,kBAAkB,CAACG,IAAI,CAACP,YAAY,CAAC;IACrCA,YAAY,CAACD,SAAS,GAAGA,SAAS;IAClCC,YAAY,CAACK,GAAG,GAAGA,GAAG;IACtB,OAAOL,YAAY;EACrB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEQ,sBAAsBA,CAACT,SAAoC,EAAE;IAC3D,IAAIA,SAAS,KAAKU,SAAS,IAAIV,SAAS,KAAK,IAAI,EAAE;MACjD,IAAI,CAACH,qBAAqB,GAAG,CAAC,CAAC;IACjC,CAAC,MAAM;MACL,OAAO,IAAI,CAACA,qBAAqB,CAACG,SAAS,CAAC;IAC9C;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEW,kBAAkBA,CAACV,YAA+B,EAAE;IAClD,MAAMD,SAAS,GAAGC,YAAY,CAACD,SAAS;IACxC,MAAMM,GAAG,GAAGL,YAAY,CAACK,GAAG;IAE5B,MAAMM,oBAAoB,GAAG,IAAI,CAACf,qBAAqB,CAACG,SAAS,CAAC;IAClE,IAAIY,oBAAoB,EAAE;MACxB,OAAOA,oBAAoB,CAACN,GAAG,CAAC;IAClC;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEO,uBAAuBA,CACrBb,SAAiB,EACuB;IACxC,OAAO,IAAI,CAACH,qBAAqB,CAACG,SAAS,CAAC;EAC9C;AACF"}
@@ -0,0 +1,2 @@
1
+ export * from './emitter/EventEmitter';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './emitter/EventEmitter';\n"],"mappings":"AAAA,cAAc,wBAAwB"}
@@ -1,11 +1,25 @@
1
+ import type { HMSIOSAudioMode } from './HMSIOSAudioMode';
1
2
  import type { HMSTrackSettingsInitState } from './HMSTrackSettingsInitState';
3
+ /**
4
+ * Customize local peer's Audio track settings before Joining the Room.
5
+ *
6
+ * Checkout Track Settings docs for more details {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/track/track-settings}
7
+ */
2
8
  export declare class HMSAudioTrackSettings {
3
9
  initialState?: HMSTrackSettingsInitState;
4
10
  useHardwareEchoCancellation?: boolean;
5
11
  audioSource?: string[];
12
+ /**
13
+ * [iOS only] `audioMode` allows you to capture audio in its highest quality
14
+ * by disabling voice processing and increasing the maximum bandwidth limit
15
+ *
16
+ * Checkout Music Mode docs for more details {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/configure-your-device/microphone/music-mode}
17
+ */
18
+ audioMode?: HMSIOSAudioMode;
6
19
  constructor(params: {
7
20
  initialState?: HMSTrackSettingsInitState;
8
21
  useHardwareEchoCancellation?: boolean;
9
22
  audioSource?: string[];
23
+ audioMode?: HMSIOSAudioMode;
10
24
  });
11
25
  }
@@ -0,0 +1,4 @@
1
+ export declare enum HMSIOSAudioMode {
2
+ VOICE = "voice",
3
+ MUSIC = "music"
4
+ }
@@ -49,6 +49,7 @@ export declare class HMSSDK {
49
49
  private onRemoteAudioStatsDelegate?;
50
50
  private onRemoteVideoStatsDelegate?;
51
51
  private onAudioDeviceChangedDelegate?;
52
+ private onSessionStoreAvailableDelegate?;
52
53
  private onPIPRoomLeaveDelegate?;
53
54
  private emitterSubscriptions;
54
55
  private constructor();
@@ -501,7 +502,19 @@ export declare class HMSSDK {
501
502
  * @memberof HMSSDK
502
503
  */
503
504
  setAudioDeviceChangeListener: (callback: Function) => any;
505
+ /**
506
+ * @deprecated Older SessionMetaData APIs has been deprecated in favour of newer Session Store APIs.
507
+ * You can subscribe to `ON_SESSION_STORE_AVAILABLE` event to get notified when the `HMSSessionStore`
508
+ * is available and use `set` method on `HMSSessionStore` instance
509
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/}
510
+ */
504
511
  setSessionMetaData: (sessionMetaData: string | null) => Promise<any>;
512
+ /**
513
+ * @deprecated Older SessionMetaData APIs has been deprecated in favour of newer Session Store APIs.
514
+ * You can subscribe to `ON_SESSION_STORE_AVAILABLE` event to get notified when the `HMSSessionStore`
515
+ * is available and use `get` or `addKeyChangeListener` method on `HMSSessionStore` instance
516
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/}
517
+ */
505
518
  getSessionMetaData: () => Promise<any>;
506
519
  getRemoteVideoTrackFromTrackId: (trackId: string) => Promise<import("./HMSRemoteVideoTrack").HMSRemoteVideoTrack>;
507
520
  getRemoteAudioTrackFromTrackId: (trackId: string) => Promise<import("./HMSRemoteAudioTrack").HMSRemoteAudioTrack>;
@@ -564,6 +577,9 @@ export declare class HMSSDK {
564
577
  device: string;
565
578
  audioDevicesList: string[];
566
579
  }) => void;
580
+ onSessionStoreAvailableListener: (data: {
581
+ id: string;
582
+ }) => void;
567
583
  onPIPRoomLeaveListener: (data: {
568
584
  id: string;
569
585
  }) => void;
@@ -0,0 +1,63 @@
1
+ type Nullable<T> = T | null | undefined;
2
+ export type HMSSessionStoreValue = Nullable<string>;
3
+ /**
4
+ * Session store is a shared realtime key-value store that is accessible by everyone in the room.
5
+ * It can be utilized to implement features such as pinned text, spotlight (which brings a particular
6
+ * peer to the center stage for everyone in the room) and more.
7
+ *
8
+ * To get an instance of `HMSSessionStore` class, You can add an event listener for `ON_SESSION_STORE_AVAILABLE`
9
+ * event on the `HMSSDK` instance
10
+ *
11
+ * For example:
12
+ * ```
13
+ * hmsInstance.addEventListener(HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE, <your callback function>);
14
+ * ```
15
+ *
16
+ * Checkout Session Store docs fore more details ${@link https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/room/session-store}
17
+ */
18
+ export declare class HMSSessionStore {
19
+ private _deviceEventEmitterSubscription?;
20
+ private _eventEmitter?;
21
+ private _addedKeyChangeListenerCount;
22
+ /**
23
+ * This method sets a value for a specific key on session store.
24
+ * Once a value is assigned, it will be available for other peers in the room
25
+ * who are listening for changes in value for that specific key.
26
+ *
27
+ * @param {HMSSessionStoreValue} value
28
+ * @param {string} key
29
+ * @returns {Promise}
30
+ */
31
+ set(value: HMSSessionStoreValue, key: string): Promise<{
32
+ success: true;
33
+ finalValue: HMSSessionStoreValue;
34
+ }>;
35
+ /**
36
+ * This method returns the value of any specified key on session store.
37
+ * Note that you will not get updates for any change in value of the specified key,
38
+ * It returns the latest value at the time it was called.
39
+ *
40
+ * To listen to value change updates use `addKeyChangeListener` method instead.
41
+ *
42
+ * @param {string} key
43
+ * @returns {Promise}
44
+ */
45
+ get(key: string): Promise<HMSSessionStoreValue>;
46
+ /**
47
+ * This method registers a callback function for listening to value changes of a particular key.
48
+ * Registered Callback function will be called initially with latest value and whenever the value updates
49
+ *
50
+ * @param {string[]} forKeys
51
+ * @param {Function} callback
52
+ * @returns {Object} subscription object
53
+ */
54
+ addKeyChangeListener<T extends string[]>(forKeys: T, callback: (error: string | null, data: {
55
+ key: T[number];
56
+ value: HMSSessionStoreValue;
57
+ } | null) => void): {
58
+ remove: () => void;
59
+ };
60
+ private _cleanup;
61
+ private _deviceEventEmitterListener;
62
+ }
63
+ export {};
@@ -1,3 +1,9 @@
1
+ /**
2
+ * These are the available events emitted by the `HMSSDK`
3
+ *
4
+ * For more info about these events, checkout Event Listener docs
5
+ * {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/listen-to-room-updates/event-listeners}
6
+ */
1
7
  export declare enum HMSUpdateListenerActions {
2
8
  ON_PREVIEW = "ON_PREVIEW",
3
9
  ON_JOIN = "ON_JOIN",
@@ -17,5 +23,7 @@ export declare enum HMSUpdateListenerActions {
17
23
  ON_LOCAL_VIDEO_STATS = "ON_LOCAL_VIDEO_STATS",
18
24
  ON_REMOTE_AUDIO_STATS = "ON_REMOTE_AUDIO_STATS",
19
25
  ON_REMOTE_VIDEO_STATS = "ON_REMOTE_VIDEO_STATS",
20
- ON_AUDIO_DEVICE_CHANGED = "ON_AUDIO_DEVICE_CHANGED"
26
+ ON_AUDIO_DEVICE_CHANGED = "ON_AUDIO_DEVICE_CHANGED",
27
+ ON_SESSION_STORE_AVAILABLE = "ON_SESSION_STORE_AVAILABLE",
28
+ ON_SESSION_STORE_CHANGED = "ON_SESSION_STORE_CHANGED"
21
29
  }
@@ -1,6 +1,11 @@
1
1
  import type { HMSSimulcastLayerSettings } from './HMSSimulcastLayerSettings';
2
2
  import type { HMSCameraFacing } from './HMSCameraFacing';
3
3
  import type { HMSTrackSettingsInitState } from './HMSTrackSettingsInitState';
4
+ /**
5
+ * Customize local peer's Video track settings before Joining the Room.
6
+ *
7
+ * Checkout Track Settings docs for more details {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/track/track-settings}
8
+ */
4
9
  export declare class HMSVideoTrackSettings {
5
10
  readonly simulcastSettings?: HMSSimulcastLayerSettings[];
6
11
  initialState?: HMSTrackSettingsInitState;
@@ -80,6 +80,8 @@ export * from './classes/HMSSimulcastLayerDefinition';
80
80
  export * from './classes/HMSQualityLimitationReasons';
81
81
  export * from './classes/HMSQualityLimitationReason';
82
82
  export * from './classes/HMSCameraControl';
83
+ export * from './classes/HMSIOSAudioMode';
84
+ export type { HMSSessionStore, HMSSessionStoreValue, } from './classes/HMSSessionStore';
83
85
  export type { HmsViewComponent as HMSView } from './classes/HmsView';
84
86
  import { HMSSDK as HmsManager } from './classes/HMSSDK';
85
87
  export default HmsManager;
@@ -0,0 +1,91 @@
1
+ import { EmitterSubscription } from './_EmitterSubscription';
2
+ import { EventSubscriptionVendor } from './_EventSubscriptionVendor';
3
+ export { EmitterSubscription } from './_EmitterSubscription';
4
+ /**
5
+ * @class EventEmitter
6
+ * @description
7
+ * An EventEmitter is responsible for managing a set of listeners and publishing
8
+ * events to them when it is told that such events happened. In addition to the
9
+ * data for the given event it also sends a event control object which allows
10
+ * the listeners/handlers to prevent the default behavior of the given event.
11
+ *
12
+ * The emitter is designed to be generic enough to support all the different
13
+ * contexts in which one might want to emit events. It is a simple multicast
14
+ * mechanism on top of which extra functionality can be composed. For example, a
15
+ * more advanced emitter may use an EventHolder and EventFactory.
16
+ */
17
+ export declare class EventEmitter {
18
+ _subscriber: EventSubscriptionVendor;
19
+ /**
20
+ * @constructor
21
+ *
22
+ * @param {EventSubscriptionVendor} subscriber - Optional subscriber instance
23
+ * to use. If omitted, a new subscriber will be created for the emitter.
24
+ */
25
+ constructor(subscriber?: EventSubscriptionVendor | null);
26
+ /**
27
+ * Adds a listener to be invoked when events of the specified type are
28
+ * emitted. An optional calling context may be provided. The data arguments
29
+ * emitted will be passed to the listener function.
30
+ *
31
+ * TODO: Annotate the listener arg's type. This is tricky because listeners
32
+ * can be invoked with varargs.
33
+ *
34
+ * @param {string} eventType - Name of the event to listen to
35
+ * @param {function} listener - Function to invoke when the specified event is
36
+ * emitted
37
+ * @param {*} context - Optional context object to use when invoking the
38
+ * listener
39
+ */
40
+ addListener(eventType: string, listener: Function, context: Object | null | undefined): EmitterSubscription;
41
+ /**
42
+ * Removes all of the registered listeners, including those registered as
43
+ * listener maps.
44
+ *
45
+ * @param {?string} eventType - Optional name of the event whose registered
46
+ * listeners to remove
47
+ */
48
+ removeAllListeners(eventType: string | undefined | null): void;
49
+ /**
50
+ * Removes a specific subscription. Called by the `remove()` method of the
51
+ * subscription itself to ensure any necessary cleanup is performed.
52
+ */
53
+ removeSubscription(subscription: EmitterSubscription): void;
54
+ /**
55
+ * Returns the number of listeners that are currently registered for the given
56
+ * event.
57
+ *
58
+ * @param {string} eventType - Name of the event to query
59
+ * @returns {number}
60
+ */
61
+ listenerCount(eventType: string): number;
62
+ /**
63
+ * Emits an event of the given type with the given data. All handlers of that
64
+ * particular type will be notified.
65
+ *
66
+ * @param {string} eventType - Name of the event to emit
67
+ * @param {...*} Arbitrary arguments to be passed to each registered listener
68
+ *
69
+ * @example
70
+ * emitter.addListener('someEvent', function(message) {
71
+ * console.log(message);
72
+ * });
73
+ *
74
+ * emitter.emit('someEvent', 'abc'); // logs 'abc'
75
+ */
76
+ emit(eventType: string, ...args: any[]): void;
77
+ /**
78
+ * Removes the given listener for event of specific type.
79
+ *
80
+ * @param {string} eventType - Name of the event to emit
81
+ * @param {function} listener - Function to invoke when the specified event is
82
+ * emitted
83
+ *
84
+ * @example
85
+ * emitter.removeListener('someEvent', function(message) {
86
+ * console.log(message);
87
+ * }); // removes the listener if already registered
88
+ *
89
+ */
90
+ removeListener(eventType: string, listener: Function): void;
91
+ }
@@ -0,0 +1,29 @@
1
+ import { EventSubscription } from './_EventSubscription';
2
+ import type { EventEmitter } from './EventEmitter';
3
+ import type { EventSubscriptionVendor } from './_EventSubscriptionVendor';
4
+ /**
5
+ * EmitterSubscription represents a subscription with listener and context data.
6
+ */
7
+ export declare class EmitterSubscription extends EventSubscription {
8
+ emitter: EventEmitter;
9
+ listener: Function;
10
+ context: Object | null | undefined;
11
+ /**
12
+ * @param {EventEmitter} emitter - The event emitter that registered this
13
+ * subscription
14
+ * @param {EventSubscriptionVendor} subscriber - The subscriber that controls
15
+ * this subscription
16
+ * @param {function} listener - Function to invoke when the specified event is
17
+ * emitted
18
+ * @param {*} context - Optional context object to use when invoking the
19
+ * listener
20
+ */
21
+ constructor(emitter: EventEmitter, subscriber: EventSubscriptionVendor, listener: Function, context: Object | undefined | null);
22
+ /**
23
+ * Removes this subscription from the emitter that registered it.
24
+ * Note: we're overriding the `remove()` method of EventSubscription here
25
+ * but deliberately not calling `super.remove()` as the responsibility
26
+ * for removing the subscription lies with the EventEmitter.
27
+ */
28
+ remove(): void;
29
+ }
@@ -0,0 +1,19 @@
1
+ import type { EventSubscriptionVendor } from './_EventSubscriptionVendor';
2
+ /**
3
+ * EventSubscription represents a subscription to a particular event. It can
4
+ * remove its own subscription.
5
+ */
6
+ export declare class EventSubscription {
7
+ eventType: string;
8
+ key: number;
9
+ subscriber: EventSubscriptionVendor;
10
+ /**
11
+ * @param {EventSubscriptionVendor} subscriber the subscriber that controls
12
+ * this subscription.
13
+ */
14
+ constructor(subscriber: EventSubscriptionVendor);
15
+ /**
16
+ * Removes this subscription from the subscriber that controls it.
17
+ */
18
+ remove(): void;
19
+ }
@@ -0,0 +1,44 @@
1
+ import type { EventSubscription } from './_EventSubscription';
2
+ /**
3
+ * EventSubscriptionVendor stores a set of EventSubscriptions that are
4
+ * subscribed to a particular event type.
5
+ */
6
+ export declare class EventSubscriptionVendor {
7
+ _subscriptionsForType: Record<string, EventSubscription[] | null | undefined>;
8
+ _currentSubscription: EventSubscription | null | undefined;
9
+ constructor();
10
+ /**
11
+ * Adds a subscription keyed by an event type.
12
+ *
13
+ * @param {string} eventType
14
+ * @param {EventSubscription} subscription
15
+ */
16
+ addSubscription(eventType: string, subscription: EventSubscription): EventSubscription;
17
+ /**
18
+ * Removes a bulk set of the subscriptions.
19
+ *
20
+ * @param {?string} eventType - Optional name of the event type whose
21
+ * registered supscriptions to remove, if null or undefined remove all subscriptions.
22
+ */
23
+ removeAllSubscriptions(eventType: string | undefined | null): void;
24
+ /**
25
+ * Removes a specific subscription. Instead of calling this function, call
26
+ * `subscription.remove()` directly.
27
+ *
28
+ * @param {object} subscription
29
+ */
30
+ removeSubscription(subscription: EventSubscription): void;
31
+ /**
32
+ * Returns the array of subscriptions that are currently registered for the
33
+ * given event type.
34
+ *
35
+ * Note: This array can be potentially sparse as subscriptions are deleted
36
+ * from it when they are removed.
37
+ *
38
+ * TODO: This returns a nullable array. wat?
39
+ *
40
+ * @param {string} eventType
41
+ * @returns {?array}
42
+ */
43
+ getSubscriptionsForType(eventType: string): EventSubscription[] | null | undefined;
44
+ }
@@ -0,0 +1 @@
1
+ export * from './emitter/EventEmitter';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@100mslive/react-native-hms",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Integrate Real Time Audio and Video conferencing, Interactive Live Streaming, and Chat in your apps with 100ms React Native SDK. With support for HLS and RTMP Live Streaming and Recording, Picture-in-Picture (PiP), one-to-one Video Call Modes, Audio Rooms, Video Player and much more, add immersive real-time communications to your apps.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -68,7 +68,26 @@
68
68
  "ios",
69
69
  "android",
70
70
  "web",
71
- "interactive"
71
+ "interactive",
72
+ "hls",
73
+ "rtmp",
74
+ "pip",
75
+ "voip",
76
+ "player",
77
+ "webrtc",
78
+ "stream",
79
+ "communication",
80
+ "conference",
81
+ "whiteboard",
82
+ "session",
83
+ "polls",
84
+ "quiz",
85
+ "call",
86
+ "callkit",
87
+ "connection",
88
+ "service",
89
+ "telecom",
90
+ "reaction"
72
91
  ],
73
92
  "repository": "https://github.com/100mslive/100ms-react-native",
74
93
  "author": "Yogesh <yogesh@100ms.live> (https://www.100ms.live/)",
package/sdk-versions.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "ios": "0.9.2",
2
+ "ios": "0.9.3",
3
3
  "iOSBroadcastExtension": "0.0.9",
4
- "android": "2.6.1"
4
+ "android": "2.6.2"
5
5
  }
@@ -1,17 +1,33 @@
1
+ import type { HMSIOSAudioMode } from './HMSIOSAudioMode';
1
2
  import type { HMSTrackSettingsInitState } from './HMSTrackSettingsInitState';
2
3
 
4
+ /**
5
+ * Customize local peer's Audio track settings before Joining the Room.
6
+ *
7
+ * Checkout Track Settings docs for more details {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/track/track-settings}
8
+ */
3
9
  export class HMSAudioTrackSettings {
4
10
  initialState?: HMSTrackSettingsInitState;
5
11
  useHardwareEchoCancellation?: boolean; // android only
6
12
  audioSource?: string[]; // ios only
7
13
 
14
+ /**
15
+ * [iOS only] `audioMode` allows you to capture audio in its highest quality
16
+ * by disabling voice processing and increasing the maximum bandwidth limit
17
+ *
18
+ * Checkout Music Mode docs for more details {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/configure-your-device/microphone/music-mode}
19
+ */
20
+ audioMode?: HMSIOSAudioMode; // ios only
21
+
8
22
  constructor(params: {
9
23
  initialState?: HMSTrackSettingsInitState;
10
24
  useHardwareEchoCancellation?: boolean;
11
25
  audioSource?: string[];
26
+ audioMode?: HMSIOSAudioMode;
12
27
  }) {
13
28
  this.useHardwareEchoCancellation = params.useHardwareEchoCancellation;
14
29
  this.initialState = params.initialState;
15
30
  this.audioSource = params.audioSource;
31
+ this.audioMode = params.audioMode;
16
32
  }
17
33
  }
@@ -196,6 +196,7 @@ export class HMSEncoder {
196
196
  const encodedObj = {
197
197
  useHardwareEchoCancellation: settings?.useHardwareAcousticEchoCanceler,
198
198
  initialState: settings?.initialState,
199
+ audioMode: settings?.audioMode,
199
200
  };
200
201
 
201
202
  return new HMSAudioTrackSettings(encodedObj);
@@ -0,0 +1,4 @@
1
+ export enum HMSIOSAudioMode {
2
+ VOICE = 'voice',
3
+ MUSIC = 'music',
4
+ }
@@ -25,10 +25,8 @@ import type { HMSAudioMixingMode } from './HMSAudioMixingMode';
25
25
  import type { HMSLogSettings } from './HMSLogSettings';
26
26
  import { HMSMessageType } from './HMSMessageType';
27
27
  import { HMSPIPListenerActions } from './HMSPIPListenerActions';
28
- import {
29
- type HMSEventSubscription,
30
- HMSNativeEventEmitter,
31
- } from './HMSNativeEventEmitter';
28
+ import type { HMSEventSubscription } from './HMSNativeEventEmitter';
29
+ import { HMSNativeEventEmitter } from './HMSNativeEventEmitter';
32
30
  import {
33
31
  clearHmsPeersCache,
34
32
  getHmsPeersCache,
@@ -42,6 +40,7 @@ import {
42
40
  setHmsRoomCache,
43
41
  } from './HMSRoomCache';
44
42
  import { HMSPeerUpdateOrdinals } from './HMSPeerUpdate';
43
+ import { HMSSessionStore } from './HMSSessionStore';
45
44
 
46
45
  type HmsViewProps = Omit<HmsComponentProps, 'id'>;
47
46
 
@@ -89,6 +88,7 @@ export class HMSSDK {
89
88
  private onRemoteAudioStatsDelegate?: any;
90
89
  private onRemoteVideoStatsDelegate?: any;
91
90
  private onAudioDeviceChangedDelegate?: any;
91
+ private onSessionStoreAvailableDelegate?: any;
92
92
  private onPIPRoomLeaveDelegate?: any;
93
93
 
94
94
  private emitterSubscriptions: Partial<
@@ -1058,6 +1058,12 @@ export class HMSSDK {
1058
1058
  }
1059
1059
  };
1060
1060
 
1061
+ /**
1062
+ * @deprecated Older SessionMetaData APIs has been deprecated in favour of newer Session Store APIs.
1063
+ * You can subscribe to `ON_SESSION_STORE_AVAILABLE` event to get notified when the `HMSSessionStore`
1064
+ * is available and use `set` method on `HMSSessionStore` instance
1065
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/}
1066
+ */
1061
1067
  setSessionMetaData = async (sessionMetaData: string | null) => {
1062
1068
  logger?.verbose('#Function setSessionMetaData', {
1063
1069
  id: this.id,
@@ -1069,6 +1075,12 @@ export class HMSSDK {
1069
1075
  });
1070
1076
  };
1071
1077
 
1078
+ /**
1079
+ * @deprecated Older SessionMetaData APIs has been deprecated in favour of newer Session Store APIs.
1080
+ * You can subscribe to `ON_SESSION_STORE_AVAILABLE` event to get notified when the `HMSSessionStore`
1081
+ * is available and use `get` or `addKeyChangeListener` method on `HMSSessionStore` instance
1082
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/}
1083
+ */
1072
1084
  getSessionMetaData = async () => {
1073
1085
  logger?.verbose('#Function getSessionMetaData', {
1074
1086
  id: this.id,
@@ -1470,6 +1482,27 @@ export class HMSSDK {
1470
1482
  this.onAudioDeviceChangedDelegate = callback;
1471
1483
  break;
1472
1484
  }
1485
+ case HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE: {
1486
+ // Checking if we already have ON_SESSION_STORE_AVAILABLE subscription
1487
+ if (
1488
+ !this.emitterSubscriptions[
1489
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
1490
+ ]
1491
+ ) {
1492
+ // Adding ON_SESSION_STORE_AVAILABLE native listener
1493
+ const sessionStoreAvailableSubscription = HmsEventEmitter.addListener(
1494
+ this.id,
1495
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE,
1496
+ this.onSessionStoreAvailableListener
1497
+ );
1498
+ this.emitterSubscriptions[
1499
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
1500
+ ] = sessionStoreAvailableSubscription;
1501
+ }
1502
+ // Adding Session Store Available App Delegate listener
1503
+ this.onSessionStoreAvailableDelegate = callback;
1504
+ break;
1505
+ }
1473
1506
  case HMSPIPListenerActions.ON_PIP_ROOM_LEAVE: {
1474
1507
  if (Platform.OS === 'android') {
1475
1508
  // Checking if we already have ON_PIP_ROOM_LEAVE subscription
@@ -1796,6 +1829,23 @@ export class HMSSDK {
1796
1829
  this.onAudioDeviceChangedDelegate = null;
1797
1830
  break;
1798
1831
  }
1832
+ case HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE: {
1833
+ const subscription =
1834
+ this.emitterSubscriptions[
1835
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
1836
+ ];
1837
+ // Removing ON_SESSION_STORE_AVAILABLE native listener
1838
+ if (subscription) {
1839
+ subscription.remove();
1840
+
1841
+ this.emitterSubscriptions[
1842
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
1843
+ ] = undefined;
1844
+ }
1845
+ // Removing App Delegate listener
1846
+ this.onSessionStoreAvailableDelegate = null;
1847
+ break;
1848
+ }
1799
1849
  case HMSPIPListenerActions.ON_PIP_ROOM_LEAVE: {
1800
1850
  if (Platform.OS === 'android') {
1801
1851
  const subscription =
@@ -2212,6 +2262,22 @@ export class HMSSDK {
2212
2262
  }
2213
2263
  };
2214
2264
 
2265
+ onSessionStoreAvailableListener = (data: { id: string }) => {
2266
+ if (data.id !== this.id) {
2267
+ return;
2268
+ }
2269
+ if (this.onSessionStoreAvailableDelegate) {
2270
+ logger?.verbose(
2271
+ '#Listener ON_SESSION_STORE_AVAILABLE_LISTENER_CALL',
2272
+ data
2273
+ );
2274
+ this.onSessionStoreAvailableDelegate({
2275
+ ...data,
2276
+ sessionStore: new HMSSessionStore(),
2277
+ });
2278
+ }
2279
+ };
2280
+
2215
2281
  onPIPRoomLeaveListener = (data: { id: string }) => {
2216
2282
  if (data.id !== this.id) {
2217
2283
  return;