Skip to content

feat(HikVision): add CapturePicture function#7407

Merged
ArgoZhang merged 2 commits intomainfrom
feat-capture
Dec 25, 2025
Merged

feat(HikVision): add CapturePicture function#7407
ArgoZhang merged 2 commits intomainfrom
feat-capture

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Dec 25, 2025

Link issues

fixes #7406

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Add a HikVision sample action to capture and download a snapshot during real-time playback and update related UI state handling.

New Features:

  • Introduce a CapturePictureAndDownload trigger in the HikVision sample to grab snapshots while streaming.

Enhancements:

  • Adjust sound control state initialization on real-play start/stop to better reflect the current playback status.

Copilot AI review requested due to automatic review settings December 25, 2025 00:59
@bb-auto bb-auto Bot added the enhancement New feature or request label Dec 25, 2025
@bb-auto bb-auto Bot added this to the v10.1.0 milestone Dec 25, 2025
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Dec 25, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a CapturePicture feature to the HikVision sample, wiring a new UI button to an async capture-and-download method and adjusting sound state handling on real-play lifecycle events.

Sequence diagram for HikVision capture picture feature

sequenceDiagram
  actor User
  participant HikVisionsComponent
  participant HikVisionService
  participant BrowserDownload

  User->>HikVisionsComponent: Click capture picture button
  HikVisionsComponent->>HikVisionsComponent: OnCapture()
  HikVisionsComponent->>HikVisionService: CapturePictureAndDownload()
  HikVisionService-->>BrowserDownload: Stream captured image data
  BrowserDownload-->>User: Prompt image download/save
Loading

Updated class diagram for HikVisions component and HikVision service

classDiagram
  class HikVisionsComponent {
    - bool _startRealPlayStatus
    - bool _stopRealPlayStatus
    - bool _openSoundStatus
    - bool _closeSoundStatus
    - int _streamType
    - int _channelId
    - HikVisionService _hikVision
    - bool _inited
    + Task OnStartRealPlay()
    + Task OnOpenSound()
    + Task OnCloseSound()
    + Task OnCapture()
    + Task OnInitedAsync(bool initialized)
    + Task OnStartRealPlayedAsync()
    + Task OnStopRealPlayedAsync()
  }

  class HikVisionService {
    + bool IsRealPlaying
    + Task StartRealPlay(int streamType, int channelId)
    + Task StopRealPlay()
    + Task OpenSound()
    + Task CloseSound()
    + Task CapturePictureAndDownload()
  }

  HikVisionsComponent --> HikVisionService : uses
Loading

File-Level Changes

Change Details Files
Wire a new capture-picture action from the HikVision sample UI to the HikVision service.
  • Add OnCapture async handler that calls the HikVision service capture-and-download method
  • Expose a new '抓图' button in the toolbar that calls the capture handler and is disabled when real play is stopped
src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor.cs
src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor
Adjust sound status flags to be updated during real-play lifecycle callbacks instead of at start only.
  • Remove sound status flag changes from the start-real-play handler
  • Update sound status flags in the real-play started callback to reflect sound being off by default
  • Update sound status flags in the real-play stopped callback to re-enable sound controls
src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#7406 Add a CapturePicture function to the HikVision integration, including wiring it into the UI and calling the underlying HikVision service to capture and download a picture.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ArgoZhang ArgoZhang merged commit 32aebe2 into main Dec 25, 2025
6 of 8 checks passed
@ArgoZhang ArgoZhang deleted the feat-capture branch December 25, 2025 00:59
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider guarding OnCapture so it’s a no-op (or shows feedback) when the HikVision component is not initialized or not in a real-play state, rather than relying solely on the _stopRealPlayStatus flag for the button disable logic.
  • The state transitions for _openSoundStatus and _closeSoundStatus in OnStartRealPlayedAsync and OnStopRealPlayedAsync look asymmetric; double-check that both flags reflect the intended enabled/disabled state of the sound buttons immediately after start and stop (e.g., _closeSoundStatus is set to true in both callbacks).
  • If CapturePictureAndDownload can take noticeable time or fail, you might want to add basic busy/error handling around OnCapture (e.g., temporary button disable and try/catch) to avoid repeated rapid clicks or unhandled exceptions surfacing to the UI.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider guarding `OnCapture` so it’s a no-op (or shows feedback) when the HikVision component is not initialized or not in a real-play state, rather than relying solely on the `_stopRealPlayStatus` flag for the button disable logic.
- The state transitions for `_openSoundStatus` and `_closeSoundStatus` in `OnStartRealPlayedAsync` and `OnStopRealPlayedAsync` look asymmetric; double-check that both flags reflect the intended enabled/disabled state of the sound buttons immediately after start and stop (e.g., `_closeSoundStatus` is set to `true` in both callbacks).
- If `CapturePictureAndDownload` can take noticeable time or fail, you might want to add basic busy/error handling around `OnCapture` (e.g., temporary button disable and try/catch) to avoid repeated rapid clicks or unhandled exceptions surfacing to the UI.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (61871f2) to head (ff0c3d6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7407   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          748       748           
  Lines        32793     32793           
  Branches      4551      4551           
=========================================
  Hits         32793     32793           
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a capture picture functionality to the HikVision web plugin component, allowing users to capture and download images from the video stream. The implementation includes a new capture button in the UI and refactors the sound status initialization logic to be handled in the event callbacks rather than in the button click handlers.

  • Added CapturePictureAndDownload functionality with a new capture button
  • Refactored sound status initialization from OnStartRealPlay to OnStartRealPlayedAsync callback
  • Updated BootstrapBlazor.HikVision package from version 10.0.5 to 10.0.6

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
HikVisions.razor.cs Added OnCapture method and moved sound status initialization from OnStartRealPlay to the OnStartRealPlayedAsync/OnStopRealPlayedAsync callbacks for proper state management
HikVisions.razor Added capture button that is disabled when the real-time stream is not playing
BootstrapBlazor.Server.csproj Updated HikVision package dependency to version 10.0.6 which includes the new CapturePictureAndDownload API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +112 to +115
private async Task OnCapture()
{
await _hikVision.CapturePictureAndDownload();
}
Copy link

Copilot AI Dec 25, 2025

Choose a reason for hiding this comment

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

The OnCapture method lacks user feedback for success or failure. Unlike OnOpenSound and OnCloseSound methods which provide toast notifications to inform users of the operation result, this method silently executes without any feedback. Consider adding success/error toast messages similar to the sound control methods to improve user experience.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(HikVision): add CapturePicture function

2 participants