@pipecat-ai/daily-transport 0.4.0 → 1.1.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.
- package/dist/index.d.ts +20 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +153 -43
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +154 -44
- package/dist/index.module.js.map +1 -1
- package/package.json +3 -3
package/dist/index.module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import $7zbD8$dailycodailyjs from "@daily-co/daily-js";
|
|
2
|
-
import {logger as $7zbD8$logger, RTVIError as $7zbD8$RTVIError, TransportStartError as $7zbD8$TransportStartError, RTVIMessage as $7zbD8$RTVIMessage, Transport as $7zbD8$Transport} from "@pipecat-ai/client-js";
|
|
2
|
+
import {logger as $7zbD8$logger, DeviceError as $7zbD8$DeviceError, RTVIError as $7zbD8$RTVIError, TransportStartError as $7zbD8$TransportStartError, RTVIMessage as $7zbD8$RTVIMessage, Transport as $7zbD8$Transport} from "@pipecat-ai/client-js";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
function $parcel$interopDefault(a) {
|
|
@@ -784,6 +784,7 @@ class $62bc376044a05513$export$439b217ca659a877 {
|
|
|
784
784
|
this.outputToSpeakers = outputToSpeakers;
|
|
785
785
|
this.debug = !!debug;
|
|
786
786
|
this._deviceChangeCallback = null;
|
|
787
|
+
this._deviceErrorCallback = null;
|
|
787
788
|
this._devices = [];
|
|
788
789
|
this.deviceSelection = null;
|
|
789
790
|
// State variables
|
|
@@ -942,21 +943,42 @@ class $62bc376044a05513$export$439b217ca659a877 {
|
|
|
942
943
|
return true;
|
|
943
944
|
}
|
|
944
945
|
/**
|
|
946
|
+
* Provide a callback for if/when device errors occur
|
|
947
|
+
* @param {(({devices: Array<"cam" | "mic">, type: string, error?: Error}) => void) | null} callback
|
|
948
|
+
* @returns {true}
|
|
949
|
+
*/ listenForDeviceErrors(callback) {
|
|
950
|
+
this._deviceErrorCallback = callback;
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
945
953
|
* Manually request permission to use the microphone
|
|
946
954
|
* @returns {Promise<true>}
|
|
947
955
|
*/ async requestPermission() {
|
|
948
956
|
const permissionStatus = await navigator.permissions.query({
|
|
949
957
|
name: 'microphone'
|
|
950
958
|
});
|
|
951
|
-
if (permissionStatus.state === 'denied')
|
|
952
|
-
|
|
959
|
+
if (permissionStatus.state === 'denied') {
|
|
960
|
+
if (this._deviceErrorCallback) this._deviceErrorCallback({
|
|
961
|
+
devices: [
|
|
962
|
+
"mic"
|
|
963
|
+
],
|
|
964
|
+
type: "unknown",
|
|
965
|
+
error: new Error("Microphone access denied")
|
|
966
|
+
});
|
|
967
|
+
} else if (permissionStatus.state === 'prompt') try {
|
|
953
968
|
const stream = await navigator.mediaDevices.getUserMedia({
|
|
954
969
|
audio: true
|
|
955
970
|
});
|
|
956
971
|
const tracks = stream.getTracks();
|
|
957
972
|
tracks.forEach((track)=>track.stop());
|
|
958
973
|
} catch (e) {
|
|
959
|
-
|
|
974
|
+
console.error("Error accessing microphone.");
|
|
975
|
+
if (this._deviceErrorCallback) this._deviceErrorCallback({
|
|
976
|
+
devices: [
|
|
977
|
+
"mic"
|
|
978
|
+
],
|
|
979
|
+
type: "unknown",
|
|
980
|
+
error: e
|
|
981
|
+
});
|
|
960
982
|
}
|
|
961
983
|
return true;
|
|
962
984
|
}
|
|
@@ -993,7 +1015,16 @@ class $62bc376044a05513$export$439b217ca659a877 {
|
|
|
993
1015
|
* @returns {Promise<true>}
|
|
994
1016
|
*/ async begin(deviceId) {
|
|
995
1017
|
if (this.processor) throw new Error(`Already connected: please call .end() to start a new session`);
|
|
996
|
-
if (!navigator.mediaDevices || !('getUserMedia' in navigator.mediaDevices))
|
|
1018
|
+
if (!navigator.mediaDevices || !('getUserMedia' in navigator.mediaDevices)) {
|
|
1019
|
+
if (this._deviceErrorCallback) this._deviceErrorCallback({
|
|
1020
|
+
devices: [
|
|
1021
|
+
"mic",
|
|
1022
|
+
"cam"
|
|
1023
|
+
],
|
|
1024
|
+
type: "undefined-mediadevices"
|
|
1025
|
+
});
|
|
1026
|
+
throw new Error('Could not request user media');
|
|
1027
|
+
}
|
|
997
1028
|
deviceId = deviceId ?? this.deviceSelection?.deviceId;
|
|
998
1029
|
try {
|
|
999
1030
|
const config = {
|
|
@@ -1006,6 +1037,13 @@ class $62bc376044a05513$export$439b217ca659a877 {
|
|
|
1006
1037
|
};
|
|
1007
1038
|
this.stream = await navigator.mediaDevices.getUserMedia(config);
|
|
1008
1039
|
} catch (err) {
|
|
1040
|
+
if (this._deviceErrorCallback) this._deviceErrorCallback({
|
|
1041
|
+
devices: [
|
|
1042
|
+
"mic"
|
|
1043
|
+
],
|
|
1044
|
+
type: "unknown",
|
|
1045
|
+
error: err
|
|
1046
|
+
});
|
|
1009
1047
|
throw new Error('Could not start media stream');
|
|
1010
1048
|
}
|
|
1011
1049
|
this.listDevices().then((devices)=>{
|
|
@@ -1427,7 +1465,7 @@ globalThis.WavRecorder = WavRecorder;
|
|
|
1427
1465
|
|
|
1428
1466
|
|
|
1429
1467
|
var $58d19ff082af5e5c$exports = {};
|
|
1430
|
-
$58d19ff082af5e5c$exports = JSON.parse("{\"name\":\"@pipecat-ai/daily-transport\",\"version\":\"
|
|
1468
|
+
$58d19ff082af5e5c$exports = JSON.parse("{\"name\":\"@pipecat-ai/daily-transport\",\"version\":\"1.1.0\",\"license\":\"BSD-2-Clause\",\"main\":\"dist/index.js\",\"module\":\"dist/index.module.js\",\"types\":\"dist/index.d.ts\",\"source\":\"src/index.ts\",\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/pipecat-ai/pipecat-client-web-transports.git\"},\"files\":[\"dist\",\"package.json\",\"README.md\"],\"scripts\":{\"build\":\"parcel build --no-cache\",\"dev\":\"parcel watch\",\"lint\":\"eslint . --ext ts --report-unused-disable-directives --max-warnings 0\"},\"devDependencies\":{\"@pipecat-ai/client-js\":\"^1.1.0\",\"eslint\":\"9.11.1\",\"eslint-config-prettier\":\"^9.1.0\",\"eslint-plugin-simple-import-sort\":\"^12.1.1\"},\"peerDependencies\":{\"@pipecat-ai/client-js\":\"~1.1.0\"},\"dependencies\":{\"@daily-co/daily-js\":\"^0.77.0\"},\"description\":\"Pipecat Daily Transport Package\",\"author\":\"Daily.co\",\"bugs\":{\"url\":\"https://github.com/pipecat-ai/pipecat-client-web-transports/issues\"},\"homepage\":\"https://github.com/pipecat-ai/pipecat-client-web-transports/blob/main/transports/daily-webrtc/README.md\"}");
|
|
1431
1469
|
|
|
1432
1470
|
|
|
1433
1471
|
var $683f111f61e07358$export$ef180de88fd317cc;
|
|
@@ -1444,18 +1482,18 @@ class $683f111f61e07358$var$DailyCallWrapper {
|
|
|
1444
1482
|
let errMsg;
|
|
1445
1483
|
switch(String(prop)){
|
|
1446
1484
|
// Disable methods that modify the lifecycle of the call. These operations
|
|
1447
|
-
// should be performed via the
|
|
1485
|
+
// should be performed via the PipecatClient in order to keep state in sync.
|
|
1448
1486
|
case "preAuth":
|
|
1449
1487
|
errMsg = `Calls to preAuth() are disabled. Please use Transport.preAuth()`;
|
|
1450
1488
|
break;
|
|
1451
1489
|
case "startCamera":
|
|
1452
|
-
errMsg = `Calls to startCamera() are disabled. Please use
|
|
1490
|
+
errMsg = `Calls to startCamera() are disabled. Please use PipecatClient.initDevices()`;
|
|
1453
1491
|
break;
|
|
1454
1492
|
case "join":
|
|
1455
|
-
errMsg = `Calls to join() are disabled. Please use
|
|
1493
|
+
errMsg = `Calls to join() are disabled. Please use PipecatClient.connect()`;
|
|
1456
1494
|
break;
|
|
1457
1495
|
case "leave":
|
|
1458
|
-
errMsg = `Calls to leave() are disabled. Please use
|
|
1496
|
+
errMsg = `Calls to leave() are disabled. Please use PipecatClient.disconnect()`;
|
|
1459
1497
|
break;
|
|
1460
1498
|
case "destroy":
|
|
1461
1499
|
errMsg = `Calls to destroy() are disabled.`;
|
|
@@ -1479,7 +1517,7 @@ class $683f111f61e07358$var$DailyCallWrapper {
|
|
|
1479
1517
|
}
|
|
1480
1518
|
}
|
|
1481
1519
|
class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
1482
|
-
constructor(
|
|
1520
|
+
constructor(opts = {}){
|
|
1483
1521
|
super();
|
|
1484
1522
|
this._botId = "";
|
|
1485
1523
|
this._selectedCam = {};
|
|
@@ -1488,8 +1526,9 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1488
1526
|
this._currentAudioTrack = null;
|
|
1489
1527
|
this._audioQueue = [];
|
|
1490
1528
|
this._callbacks = {};
|
|
1491
|
-
|
|
1492
|
-
this.
|
|
1529
|
+
const { bufferLocalAudioUntilBotReady: bufferLocalAudioUntilBotReady, ...dailyOpts } = opts;
|
|
1530
|
+
this._dailyFactoryOptions = dailyOpts;
|
|
1531
|
+
this._bufferLocalAudioUntilBotReady = bufferLocalAudioUntilBotReady || false;
|
|
1493
1532
|
this._daily = (0, $7zbD8$dailycodailyjs).createCallObject({
|
|
1494
1533
|
...this._dailyFactoryOptions,
|
|
1495
1534
|
allowMultipleCallInstances: true
|
|
@@ -1523,7 +1562,7 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1523
1562
|
const pcmByteArray = new Uint8Array(data);
|
|
1524
1563
|
return btoa(String.fromCharCode(...pcmByteArray));
|
|
1525
1564
|
});
|
|
1526
|
-
const
|
|
1565
|
+
const audioMessage = {
|
|
1527
1566
|
id: "raw-audio-batch",
|
|
1528
1567
|
label: "rtvi-ai",
|
|
1529
1568
|
type: "raw-audio-batch",
|
|
@@ -1533,7 +1572,7 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1533
1572
|
numChannels: 1
|
|
1534
1573
|
}
|
|
1535
1574
|
};
|
|
1536
|
-
this.sendMessage(
|
|
1575
|
+
this.sendMessage(audioMessage);
|
|
1537
1576
|
}
|
|
1538
1577
|
initialize(options, messageHandler) {
|
|
1539
1578
|
if (this._bufferLocalAudioUntilBotReady) this.setupRecorder();
|
|
@@ -1545,7 +1584,7 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1545
1584
|
this._dailyFactoryOptions.startAudioOff = !(options.enableMic ?? true);
|
|
1546
1585
|
this.attachEventListeners();
|
|
1547
1586
|
this.state = "disconnected";
|
|
1548
|
-
(0, $7zbD8$logger).debug("[
|
|
1587
|
+
(0, $7zbD8$logger).debug("[Daily Transport] Initialized", (0, (/*@__PURE__*/$parcel$interopDefault($58d19ff082af5e5c$exports))).version);
|
|
1549
1588
|
}
|
|
1550
1589
|
get dailyCallClient() {
|
|
1551
1590
|
return this._dailyWrapper.proxy;
|
|
@@ -1558,6 +1597,9 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1558
1597
|
this._state = state;
|
|
1559
1598
|
this._callbacks.onTransportStateChanged?.(state);
|
|
1560
1599
|
}
|
|
1600
|
+
getSessionInfo() {
|
|
1601
|
+
return this._daily.meetingSessionSummary();
|
|
1602
|
+
}
|
|
1561
1603
|
async getAllCams() {
|
|
1562
1604
|
const { devices: devices } = await this._daily.enumerateDevices();
|
|
1563
1605
|
return devices.filter((d)=>d.kind === "videoinput");
|
|
@@ -1595,6 +1637,10 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1595
1637
|
outputDeviceId: speakerId
|
|
1596
1638
|
}).then((infos)=>{
|
|
1597
1639
|
this._selectedSpeaker = infos.speaker;
|
|
1640
|
+
}).catch((e)=>{
|
|
1641
|
+
this._callbacks.onDeviceError?.(new (0, $7zbD8$DeviceError)([
|
|
1642
|
+
"speaker"
|
|
1643
|
+
], e.type ?? "unknown", e.message));
|
|
1598
1644
|
});
|
|
1599
1645
|
}
|
|
1600
1646
|
get selectedSpeaker() {
|
|
@@ -1638,23 +1684,20 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1638
1684
|
}
|
|
1639
1685
|
async startRecording() {
|
|
1640
1686
|
try {
|
|
1641
|
-
(0, $7zbD8$logger).info("[
|
|
1687
|
+
(0, $7zbD8$logger).info("[Daily Transport] Initializing recording");
|
|
1642
1688
|
await this._mediaStreamRecorder.record((data)=>{
|
|
1643
1689
|
this.handleUserAudioStream(data.mono);
|
|
1644
1690
|
}, $683f111f61e07358$export$b1ca982aa1e488c1.RECORDER_CHUNK_SIZE);
|
|
1645
|
-
this.
|
|
1646
|
-
|
|
1647
|
-
data: {}
|
|
1648
|
-
});
|
|
1649
|
-
(0, $7zbD8$logger).info("[RTVI Transport] Recording Initialized");
|
|
1691
|
+
this._callbacks.onAudioBufferingStarted?.();
|
|
1692
|
+
(0, $7zbD8$logger).info("[Daily Transport] Recording Initialized");
|
|
1650
1693
|
} catch (e) {
|
|
1651
1694
|
const err = e;
|
|
1652
1695
|
if (!err.message.includes("Already recording")) (0, $7zbD8$logger).error("Error starting recording", e);
|
|
1653
1696
|
}
|
|
1654
1697
|
}
|
|
1655
|
-
async preAuth(
|
|
1656
|
-
this._dailyFactoryOptions =
|
|
1657
|
-
await this._daily.preAuth(
|
|
1698
|
+
async preAuth(dailyCallOptions) {
|
|
1699
|
+
this._dailyFactoryOptions = dailyCallOptions;
|
|
1700
|
+
await this._daily.preAuth(dailyCallOptions);
|
|
1658
1701
|
}
|
|
1659
1702
|
async initDevices() {
|
|
1660
1703
|
if (!this._daily) throw new (0, $7zbD8$RTVIError)("Transport instance not initialized");
|
|
@@ -1678,23 +1721,33 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1678
1721
|
if (!this._daily.isRemoteParticipantsAudioLevelObserverRunning()) await this._daily.startRemoteParticipantsAudioLevelObserver(100);
|
|
1679
1722
|
this.state = "initialized";
|
|
1680
1723
|
}
|
|
1681
|
-
|
|
1724
|
+
_validateConnectionParams(connectParams) {
|
|
1725
|
+
if (connectParams === undefined || connectParams === null) return undefined;
|
|
1726
|
+
if (typeof connectParams !== "object") throw new (0, $7zbD8$RTVIError)("Invalid connection parameters");
|
|
1727
|
+
const tmpParams = connectParams;
|
|
1728
|
+
if (tmpParams.room_url) {
|
|
1729
|
+
tmpParams.url = tmpParams.room_url;
|
|
1730
|
+
delete tmpParams.room_url;
|
|
1731
|
+
}
|
|
1732
|
+
if (!tmpParams.token) // Daily doesn't like token being in the map and undefined or null
|
|
1733
|
+
delete tmpParams.token;
|
|
1734
|
+
return tmpParams;
|
|
1735
|
+
}
|
|
1736
|
+
async _connect(connectParams) {
|
|
1682
1737
|
if (!this._daily) throw new (0, $7zbD8$RTVIError)("Transport instance not initialized");
|
|
1683
|
-
if (
|
|
1738
|
+
if (connectParams) this._dailyFactoryOptions = {
|
|
1739
|
+
...this._dailyFactoryOptions,
|
|
1740
|
+
...connectParams
|
|
1741
|
+
};
|
|
1684
1742
|
this.state = "connecting";
|
|
1685
|
-
const opts = this._dailyFactoryOptions;
|
|
1686
|
-
opts.url = authBundle.room_url ?? opts.url;
|
|
1687
|
-
if (authBundle.token != null) opts.token = authBundle.token;
|
|
1688
1743
|
try {
|
|
1689
|
-
await this._daily.join(
|
|
1690
|
-
const room = await this._daily.room();
|
|
1691
|
-
if (room && "id" in room) this._expiry = room.config?.exp;
|
|
1744
|
+
await this._daily.join(this._dailyFactoryOptions);
|
|
1692
1745
|
} catch (e) {
|
|
1693
1746
|
(0, $7zbD8$logger).error("Failed to join room", e);
|
|
1694
1747
|
this.state = "error";
|
|
1695
1748
|
throw new (0, $7zbD8$TransportStartError)();
|
|
1696
1749
|
}
|
|
1697
|
-
if (
|
|
1750
|
+
if (this._abortController?.signal.aborted) return;
|
|
1698
1751
|
this.state = "connected";
|
|
1699
1752
|
this._callbacks.onConnected?.();
|
|
1700
1753
|
}
|
|
@@ -1712,12 +1765,21 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1712
1765
|
this.stopRecording();
|
|
1713
1766
|
resolve();
|
|
1714
1767
|
};
|
|
1768
|
+
for(const id in this._daily.participants()){
|
|
1769
|
+
const p = this._daily.participants()[id];
|
|
1770
|
+
if (!p.local && p.tracks?.audio?.persistentTrack) {
|
|
1771
|
+
// If we already have a remote audio track, we can send the ready message immediately
|
|
1772
|
+
sendReadyMessage();
|
|
1773
|
+
resolve();
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1715
1777
|
const readyHandler = (ev)=>{
|
|
1716
1778
|
if (!ev.participant?.local) {
|
|
1717
1779
|
this._daily.off("track-started", readyHandler);
|
|
1718
1780
|
// Check if it's an iOS device
|
|
1719
1781
|
if (isIOS()) {
|
|
1720
|
-
(0, $7zbD8$logger).debug("[
|
|
1782
|
+
(0, $7zbD8$logger).debug("[Daily Transport] iOS device detected, adding 0.5 second delay before sending ready message");
|
|
1721
1783
|
// Add 500ms delay for iOS devices:
|
|
1722
1784
|
// This is a workaround for iOS devices clipping a portion
|
|
1723
1785
|
// of the audio after the track becomes playable.
|
|
@@ -1733,15 +1795,13 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1733
1795
|
if (this._mediaStreamRecorder && this._mediaStreamRecorder.getStatus() !== "ended") {
|
|
1734
1796
|
// disconnecting, we don't need to record anymore
|
|
1735
1797
|
this._mediaStreamRecorder.end();
|
|
1736
|
-
this.
|
|
1737
|
-
type: $683f111f61e07358$export$ef180de88fd317cc.AUDIO_BUFFERING_STOPPED,
|
|
1738
|
-
data: {}
|
|
1739
|
-
});
|
|
1798
|
+
this._callbacks.onAudioBufferingStopped?.();
|
|
1740
1799
|
}
|
|
1741
1800
|
}
|
|
1742
1801
|
attachEventListeners() {
|
|
1743
1802
|
this._daily.on("available-devices-updated", this.handleAvailableDevicesUpdated.bind(this));
|
|
1744
1803
|
this._daily.on("selected-devices-updated", this.handleSelectedDevicesUpdated.bind(this));
|
|
1804
|
+
this._daily.on("camera-error", this.handleDeviceError.bind(this));
|
|
1745
1805
|
this._daily.on("track-started", this.handleTrackStarted.bind(this));
|
|
1746
1806
|
this._daily.on("track-stopped", this.handleTrackStopped.bind(this));
|
|
1747
1807
|
this._daily.on("participant-joined", this.handleParticipantJoined.bind(this));
|
|
@@ -1753,7 +1813,7 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1753
1813
|
this._daily.on("error", this.handleFatalError.bind(this));
|
|
1754
1814
|
this._daily.on("nonfatal-error", this.handleNonFatalError.bind(this));
|
|
1755
1815
|
}
|
|
1756
|
-
async
|
|
1816
|
+
async _disconnect() {
|
|
1757
1817
|
this.state = "disconnecting";
|
|
1758
1818
|
this._daily.stopLocalAudioLevelObserver();
|
|
1759
1819
|
this._daily.stopRemoteParticipantsAudioLevelObserver();
|
|
@@ -1792,24 +1852,74 @@ class $683f111f61e07358$export$b1ca982aa1e488c1 extends (0, $7zbD8$Transport) {
|
|
|
1792
1852
|
this._callbacks.onSpeakerUpdated?.(ev.devices.speaker);
|
|
1793
1853
|
}
|
|
1794
1854
|
}
|
|
1855
|
+
handleDeviceError(ev) {
|
|
1856
|
+
const generateDeviceError = (error)=>{
|
|
1857
|
+
const devices = [];
|
|
1858
|
+
switch(error.type){
|
|
1859
|
+
case "permissions":
|
|
1860
|
+
error.blockedMedia.forEach((d)=>{
|
|
1861
|
+
devices.push(d === "video" ? "cam" : "mic");
|
|
1862
|
+
});
|
|
1863
|
+
return new (0, $7zbD8$DeviceError)(devices, error.type, error.msg, {
|
|
1864
|
+
blockedBy: error.blockedBy
|
|
1865
|
+
});
|
|
1866
|
+
case "not-found":
|
|
1867
|
+
error.missingMedia.forEach((d)=>{
|
|
1868
|
+
devices.push(d === "video" ? "cam" : "mic");
|
|
1869
|
+
});
|
|
1870
|
+
return new (0, $7zbD8$DeviceError)(devices, error.type, error.msg);
|
|
1871
|
+
case "constraints":
|
|
1872
|
+
error.failedMedia.forEach((d)=>{
|
|
1873
|
+
devices.push(d === "video" ? "cam" : "mic");
|
|
1874
|
+
});
|
|
1875
|
+
return new (0, $7zbD8$DeviceError)(devices, error.type, error.msg, {
|
|
1876
|
+
reason: error.reason
|
|
1877
|
+
});
|
|
1878
|
+
case "cam-in-use":
|
|
1879
|
+
devices.push("cam");
|
|
1880
|
+
return new (0, $7zbD8$DeviceError)(devices, "in-use", error.msg);
|
|
1881
|
+
case "mic-in-use":
|
|
1882
|
+
devices.push("mic");
|
|
1883
|
+
return new (0, $7zbD8$DeviceError)(devices, "in-use", error.msg);
|
|
1884
|
+
case "cam-mic-in-use":
|
|
1885
|
+
devices.push("cam");
|
|
1886
|
+
devices.push("mic");
|
|
1887
|
+
return new (0, $7zbD8$DeviceError)(devices, "in-use", error.msg);
|
|
1888
|
+
case "undefined-mediadevices":
|
|
1889
|
+
case "unknown":
|
|
1890
|
+
default:
|
|
1891
|
+
devices.push("cam");
|
|
1892
|
+
devices.push("mic");
|
|
1893
|
+
return new (0, $7zbD8$DeviceError)(devices, error.type, error.msg);
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
this._callbacks.onDeviceError?.(generateDeviceError(ev.error));
|
|
1897
|
+
}
|
|
1795
1898
|
async handleLocalAudioTrack(track) {
|
|
1796
1899
|
if (this.state == "ready" || !this._bufferLocalAudioUntilBotReady) return;
|
|
1797
1900
|
const status = this._mediaStreamRecorder.getStatus();
|
|
1798
1901
|
switch(status){
|
|
1799
1902
|
case "ended":
|
|
1800
|
-
|
|
1801
|
-
|
|
1903
|
+
try {
|
|
1904
|
+
await this._mediaStreamRecorder.begin(track);
|
|
1905
|
+
await this.startRecording();
|
|
1906
|
+
} catch (e) {
|
|
1907
|
+
// void. nothing to do.
|
|
1908
|
+
}
|
|
1802
1909
|
break;
|
|
1803
1910
|
case "paused":
|
|
1804
1911
|
await this.startRecording();
|
|
1805
1912
|
break;
|
|
1806
1913
|
case "recording":
|
|
1807
1914
|
default:
|
|
1808
|
-
if (this._currentAudioTrack !== track) {
|
|
1915
|
+
if (this._currentAudioTrack !== track) try {
|
|
1809
1916
|
await this._mediaStreamRecorder.end();
|
|
1810
1917
|
await this._mediaStreamRecorder.begin(track);
|
|
1811
1918
|
await this.startRecording();
|
|
1812
|
-
}
|
|
1919
|
+
} catch (e) {
|
|
1920
|
+
// void. nothing to do.
|
|
1921
|
+
}
|
|
1922
|
+
else (0, $7zbD8$logger).warn("track-started event received for current track and already recording");
|
|
1813
1923
|
break;
|
|
1814
1924
|
}
|
|
1815
1925
|
this._currentAudioTrack = track;
|