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-9703] - Maintain dynamic resolution preference through reconfigures #4738

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

seanavery
Copy link
Member

@seanavery seanavery commented Jan 23, 2025

Description

This PR adds a check before refreshing a video source to see if it is in resized mode. If the streamState is resized, we re-apply the resize transformation before swapping.

Tests

  • fake camera
    • maintains resize state through reconfigures ✅
    • toggle animated flag ✅
  • webcam
    • maintains resize state through reconfigures ✅
    • can change video_path ✅
  • viamrtsp
    • maintains resize state through reconfigures ✅
    • can change rtsp url ✅

@seanavery seanavery marked this pull request as draft January 23, 2025 21:21
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 23, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 24, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 24, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 24, 2025
@seanavery seanavery changed the title [RSDK-9703] - Do not refresh stream if camera component has not been reconfigured [RSDK-9703] - Maintain dynamic resolution preference through reconfigures Jan 24, 2025
@seanavery seanavery marked this pull request as ready for review January 24, 2025 16:49
@seanavery seanavery requested a review from randhid January 24, 2025 16:54
Comment on lines +414 to +416
func (state *StreamState) IsResized() bool {
return state.isResized
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this thread safe?

Comment on lines +661 to +691
// Check stream state for the camera to see if it is in resized mode.
// If it is in resized mode, we want to apply the resize transformation to the
// video source before swapping it.
streamState, ok := server.nameToStreamState[cam.Name().SDPTrackName()]
if ok && streamState.IsResized() {
server.logger.Debugf("stream %q is resized attempting to reapply resize transformation", cam.Name().SDPTrackName())
mediaProps, err := existing.MediaProperties(server.closedCtx)
if err != nil {
server.logger.Errorf("error getting media properties from resize source: %v", err)
} else {
// resizeVideoSource should always have a width and height set.
height, width := mediaProps.Height, mediaProps.Width
if height != 0 && width != 0 {
server.logger.Debugf(
"resizing video source to width %d and height %d",
width, height,
)
resizer := gostream.NewResizeVideoSource(cam, width, height)
existing.Swap(resizer)
continue
}
}
// If we can't get the media properties or the width and height are 0, we fall back to
// the original source and need to notify the stream state that the source is no longer
// resized.
server.logger.Warnf("falling back to original source for stream %q", cam.Name().SDPTrackName())
err = streamState.Reset()
if err != nil {
server.logger.Errorf("error resetting stream %q: %v", cam.Name().SDPTrackName(), err)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to test this within an existing test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants