Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-1019 use ts wrapper for streaming #1717

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions web/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@mdi/js": "^6.9.96",
"@viamrobotics/prime": "^0.0.100",
"@viamrobotics/rpc": "^0.1.32",
"@viamrobotics/sdk": "^0.0.9",
"@viamrobotics/sdk": "^0.0.10",
"@vitejs/plugin-vue": "^3.1.2",
"@vueuse/core": "^9.3.1",
"eslint-import-resolver-custom-alias": "^1.3.0",
Expand Down
7 changes: 4 additions & 3 deletions web/frontend/src/components/audio-input.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">

import { ref } from 'vue';
import { StreamClient } from '@viamrobotics/sdk';
import type { Client, ServiceError } from '@viamrobotics/sdk';
import { displayError } from '../lib/error';
import { addStream, removeStream } from '../lib/stream';

interface Props {
name: string
Expand All @@ -19,17 +19,18 @@ const toggleExpand = async () => {

const isOn = audioInput.value;

const streams = new StreamClient(props.client);
if (isOn) {
try {
await addStream(props.client, props.name);
await streams.add(props.name);
} catch (error) {
displayError(error as ServiceError);
}
return;
}

try {
await removeStream(props.client, props.name);
await streams.remove(props.name);
} catch (error) {
displayError(error as ServiceError);
}
Expand Down
9 changes: 5 additions & 4 deletions web/frontend/src/components/base.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup lang="ts">

import { ref, onMounted, onUnmounted } from 'vue';
import { Client, type ServiceError, BaseClient, commonApi } from '@viamrobotics/sdk';
import { Client, BaseClient, commonApi, StreamClient } from '@viamrobotics/sdk';
import type { ServiceError } from '@viamrobotics/sdk';
import { filterResources } from '../lib/resource';
import { displayError } from '../lib/error';
import KeyboardInput, { type Keys } from './keyboard-input.vue';
import { addStream, removeStream } from '../lib/stream';
import { cameraStreamStates, baseStreamStates } from '../lib/camera-state';

interface Props {
Expand Down Expand Up @@ -192,12 +192,13 @@ const baseRun = async () => {
};

const viewPreviewCamera = (values: string) => {
const streams = new StreamClient(props.client);
for (const [key] of baseStreamStates) {
if (values.split(',').includes(key)) {
try {
// Only add stream if other components have not already
if (!cameraStreamStates.get(key) && !baseStreamStates.get(key)) {
addStream(props.client, key);
streams.add(key);
}
} catch (error) {
displayError(error as ServiceError);
Expand All @@ -207,7 +208,7 @@ const viewPreviewCamera = (values: string) => {
try {
// Only remove stream if other components are not using the stream
if (!cameraStreamStates.get(key)) {
removeStream(props.client, key);
streams.remove(key);
}
} catch (error) {
displayError(error as ServiceError);
Expand Down
8 changes: 4 additions & 4 deletions web/frontend/src/components/camera.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import { ref, onMounted } from 'vue';
import { displayError } from '../lib/error';
import { CameraClient, Camera, Client, commonApi, ServiceError } from '@viamrobotics/sdk';
import { StreamClient, CameraClient, Camera, Client, commonApi, ServiceError } from '@viamrobotics/sdk';
import { toast } from '../lib/toast';
import InfoButton from './info-button.vue';
import PCD from './pcd.vue';
import { addStream, removeStream } from '../lib/stream';
import { cameraStreamStates, baseStreamStates } from '../lib/camera-state';

interface Props {
Expand Down Expand Up @@ -36,11 +35,12 @@ const initStreamState = () => {
};

const viewCamera = async (isOn: boolean) => {
const streams = new StreamClient(props.client);
if (isOn) {
try {
// only add stream if not already active
if (!baseStreamStates.get(props.cameraName) && !cameraStreamStates.get(props.cameraName)) {
await addStream(props.client, props.cameraName);
await streams.add(props.cameraName);
}
} catch (error) {
displayError(error as ServiceError);
Expand All @@ -50,7 +50,7 @@ const viewCamera = async (isOn: boolean) => {
try {
// only remove camera stream if active and base stream is not active
if (!baseStreamStates.get(props.cameraName) && cameraStreamStates.get(props.cameraName)) {
await removeStream(props.client, props.cameraName);
await streams.remove(props.cameraName);
}
} catch (error) {
displayError(error as ServiceError);
Expand Down
33 changes: 0 additions & 33 deletions web/frontend/src/lib/stream.ts

This file was deleted.

2 changes: 1 addition & 1 deletion web/runtime-shared/static/control.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/runtime-shared/static/control.js.map

Large diffs are not rendered by default.