Skip to content

Shubhra/ajs 137 add resampler to input#541

Merged
Shubhrakanti merged 2 commits intodev-1.0from
shubhra/ajs-137-add-resampler-to-input
Jul 16, 2025
Merged

Shubhra/ajs 137 add resampler to input#541
Shubhrakanti merged 2 commits intodev-1.0from
shubhra/ajs-137-add-resampler-to-input

Conversation

@Shubhrakanti
Copy link
Copy Markdown
Contributor

@Shubhrakanti Shubhrakanti commented Jul 15, 2025

Re-sample the input based on user config

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jul 15, 2025

⚠️ No Changeset found

Latest commit: 872043d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Shubhrakanti Shubhrakanti changed the base branch from main to dev-1.0 July 15, 2025 21:21
Comment thread agents/src/utils.ts
return typeof array === 'object' && !!(array as any)[READONLY_SYMBOL];
}

export function resampleStream({
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will probably need this in the plugins. That's why I kept it a separate utility.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a brief function spec to this function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like a JS doc you mean?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, just a one or two line brief description would be fine

@Shubhrakanti Shubhrakanti requested a review from toubatbrian July 15, 2025 21:37
Comment thread agents/src/utils.ts
}
},
});
return stream.pipeThrough(transformStream);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this will lock the input stream argument. When doing resource cleanup, we need to keep this in mind to avoid potential locking issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this a good callout. I'll add a comment for the function.

Copy link
Copy Markdown
Contributor

@toubatbrian toubatbrian Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we make it a class like "ResampledStream" and we expose method for unlock, cancel, just like deferred readable stream.

I think instead of using pipeThrough we should probably use manual getReader() to pipe the input stream to the transformStream just to make things consistent, because we might need to deal with bugs if using pipeThrough as we lose control of input stream's lock. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just use the streampipe options?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried it yet, but feel free to try it.

this.logger.debug({ track, publication, participant }, 'track subscribed');
this.deferredStream.setSource(this.createStream(track));
this.deferredStream.setSource(
resampleStream({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ same, we need to take care of un-pipeThrough whenever we are going to use it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean "un-pipeThrough"? If you call cancel on the output stream then it will signal it back down the chain?

Copy link
Copy Markdown
Contributor

@toubatbrian toubatbrian Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we cancel the pipeThrough the source and destination stream will be cancelled as well and stop stream immediately, but in some situation, like deferred readable stream, when we"detach" source stream we still want to keep source stream "alive" and pipe to other stream later. Not sure if we'd ever want to "detach" source stream here tho

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great point. Let me look through the code base and see what makes sense.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we"detach" source stream we still want to keep source stream "alive" and pipe to other stream later

you can do this via preventCancel/Abort? [source]

Copy link
Copy Markdown
Contributor Author

@Shubhrakanti Shubhrakanti Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would set preventCancel to true in this case? Screenshot 2025-07-15 at 4 19 30 PM

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think you're right. Going to test it with restaurant agent and handoff to make sure it works okay. Then I'll let you know.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hand off worked correctly so I think we don't need it here.

@Shubhrakanti Shubhrakanti merged commit 2458616 into dev-1.0 Jul 16, 2025
8 checks passed
@Shubhrakanti Shubhrakanti deleted the shubhra/ajs-137-add-resampler-to-input branch July 16, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants