mirror of
https://github.com/koush/scrypted.git
synced 2026-02-09 16:52:18 +00:00
sdk/ui: rtc signaling types
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ScryptedDevice, ScryptedMimeTypes, RTCAVMessage, MediaManager, VideoCamera, MediaStreamOptions, MediaObject } from '@scrypted/sdk/types';
|
||||
import { ScryptedDevice, ScryptedMimeTypes, RTCAVMessage, MediaManager, VideoCamera, MediaStreamOptions, MediaObject, RTCAVSource } from '@scrypted/sdk/types';
|
||||
|
||||
export async function streamCamera(mediaManager: MediaManager, device: ScryptedDevice & VideoCamera, getVideo: () => HTMLVideoElement, createPeerConnection: (configuration: RTCConfiguration) => RTCPeerConnection) {
|
||||
let selectedStream: MediaStreamOptions;
|
||||
@@ -19,20 +19,22 @@ export async function streamCamera(mediaManager: MediaManager, device: ScryptedD
|
||||
if (videoStream.mimeType.startsWith(ScryptedMimeTypes.RTCAVSignalingPrefix)) {
|
||||
trickle = false;
|
||||
|
||||
const mic = await navigator.mediaDevices.getUserMedia({video: false, audio: true})
|
||||
|
||||
const buffer = await mediaManager.convertMediaObjectToBuffer(
|
||||
videoStream,
|
||||
videoStream.mimeType,
|
||||
);
|
||||
const avsource: RTCAVSource = JSON.parse(buffer.toString());
|
||||
|
||||
pc = createPeerConnection({})
|
||||
for (const track of mic.getTracks()) {
|
||||
pc.addTrack(track);
|
||||
}
|
||||
// pc.createDataChannel("dataSendChannel");
|
||||
// const audioTrans = pc.addTransceiver("audio", {
|
||||
// direction: 'sendrecv',
|
||||
// });
|
||||
// pc.addTransceiver("video", {
|
||||
// direction: 'recvonly',
|
||||
// });
|
||||
// it's possible to do talkback to ring.
|
||||
// const mic = await navigator.mediaDevices.getUserMedia({video: false, audio: true})
|
||||
// for (const track of mic.getTracks()) {
|
||||
// pc.addTrack(track);
|
||||
// }
|
||||
if (avsource.datachannel)
|
||||
pc.createDataChannel(avsource.datachannel.label, avsource.datachannel.dict);
|
||||
pc.addTransceiver("audio", avsource.audio);
|
||||
pc.addTransceiver("video", avsource.video);
|
||||
|
||||
const offer = await pc.createOffer();
|
||||
await pc.setLocalDescription(offer);
|
||||
|
||||
@@ -1228,6 +1228,15 @@ export enum ScryptedInterface {
|
||||
|
||||
}
|
||||
|
||||
export interface RTCAVSource {
|
||||
audio: RTCRtpTransceiverInit;
|
||||
video: RTCRtpTransceiverInit;
|
||||
datachannel?: {
|
||||
label: string;
|
||||
dict?: RTCDataChannelInit;
|
||||
}
|
||||
}
|
||||
|
||||
export interface RTCAVMessage {
|
||||
id: string;
|
||||
description: RTCSessionDescriptionInit;
|
||||
|
||||
8
sdk/types.d.ts
vendored
8
sdk/types.d.ts
vendored
@@ -1272,6 +1272,14 @@ export declare enum ScryptedInterface {
|
||||
HumiditySetting = "HumiditySetting",
|
||||
Fan = "Fan"
|
||||
}
|
||||
export interface RTCAVSource {
|
||||
audio: RTCRtpTransceiverInit;
|
||||
video: RTCRtpTransceiverInit;
|
||||
datachannel?: {
|
||||
label: string;
|
||||
dict?: RTCDataChannelInit;
|
||||
};
|
||||
}
|
||||
export interface RTCAVMessage {
|
||||
id: string;
|
||||
description: RTCSessionDescriptionInit;
|
||||
|
||||
@@ -1860,6 +1860,15 @@ export enum ScryptedInterface {
|
||||
|
||||
}
|
||||
|
||||
export interface RTCAVSource {
|
||||
audio: RTCRtpTransceiverInit;
|
||||
video: RTCRtpTransceiverInit;
|
||||
datachannel?: {
|
||||
label: string;
|
||||
dict?: RTCDataChannelInit;
|
||||
}
|
||||
}
|
||||
|
||||
export interface RTCAVMessage {
|
||||
id: string;
|
||||
description: RTCSessionDescriptionInit;
|
||||
|
||||
Reference in New Issue
Block a user