Commit Graph

335 Commits

Author SHA1 Message Date
sean yu 3d4fceab3d (3/3) Fix concurrency webcam windows (#684)
* Import wmcodecdsp and try to use their nv12 const

* Remove ifndef

* Enhance getCameraName function to retrieve friendly name from IPropertyBag, with fallback to display name. Update LDFLAGS in camera_windows.go to include oleaut32 library.

* Don't mistake label for friendly name

* Initialize COM for thread safety in Open and VideoRecord methods of camera_windows.go

* Refactor camera handling in camera_windows.go and camera_windows.cpp

- Introduced mutex for thread safety in camera struct to protect shared resources.
- Updated Open method to initialize done channel and manage camera state.
- Enhanced Close method to ensure proper cleanup and prevent double closing.
- Improved resolution listing logic in camera_windows.cpp by ensuring media types are freed correctly.
- Changed memory deletion from single to array deletion for camera properties.

* Fix issues post-rebase

* Refactor Close method

* Transfer golang buffer management to c to avoid gc

* Fix race condition in imageCallback by fixing unlock code location
2026-04-21 09:25:31 -04:00
sean yu 63c09cb1f4 Expose LogLevel param for x264 codec (#685)
* Suppress noisy x264 [info] log messages and expose LogLevel param

x264's default log level (X264_LOG_INFO) causes it to write encoder
stats, CPU capabilities, and profile info to stderr. When used with
viam-server, these appear as warn-level logs and create noise.

Default to LogWarning to suppress info messages while preserving
actual warnings and errors. Expose a LogLevel field on Params so
consumers can control the verbosity themselves.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Default to info to avoid breaking change; Fix comment

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 10:39:48 -04:00
sean yu 9a3d191368 (2/3) Fix windows camera names (#683)
* Add NV12 support

* Fix camera resolution listing by supporting FORMAT_VideoInfo2 in addition to FORMAT_VideoInfo. This change allows for better compatibility with various video formats by correctly retrieving width, height, and compression details from both format types (NV12 and YUY2)

* Add support for configuring video capture pin format in open method

* Import wmcodecdsp and try to use their nv12 const

* Remove ifndef

* Use subtype.Data1 instead of biCompression

* Enhance getCameraName function to retrieve friendly name from IPropertyBag, with fallback to display name. Update LDFLAGS in camera_windows.go to include oleaut32 library.

* Don't mistake label for friendly name

* Improve camera device name handling and memory management in Windows driver. Added checks for valid device names and initialized camera lists to prevent memory issues. Enhanced resolution listing by ensuring proper media type handling and freeing resources appropriately.
2026-03-17 09:02:45 -04:00
sean yu d8f14db1ef (1/3) Add NV12 frame format support for windows (#682)
* Add NV12 support

* Fix camera resolution listing by supporting FORMAT_VideoInfo2 in addition to FORMAT_VideoInfo. This change allows for better compatibility with various video formats by correctly retrieving width, height, and compression details from both format types (NV12 and YUY2)

* Add support for configuring video capture pin format in open method

* Import wmcodecdsp and try to use their nv12 const

* Remove ifndef
2026-03-02 06:40:45 -05:00
sean yu 932e23af03 Add conditional build tag to exclude microphones for camera-only builds (#679)
* Add tag

* Add nomicrophone build tag for optional microphone support

- Changed from platform-specific (!windows) to opt-out build tag (!nomicrophone)
- Microphone support included by default (non-breaking)
- Use -tags nomicrophone to exclude when malgo deps unavailable
- Useful for cross-compilation and minimal builds
- Renamed microphone_windows.go to microphone_stub.go for clarity

* Update README
2026-02-05 13:30:34 -05:00
sean yu 85194b499f Fix null camera enum windows (#681) 2026-02-04 08:34:58 -05:00
sean yu 0bee5c1f8f Fix av1 SVT_AV1_PRED_LOW_DELAY_B deprecation in their latest release (4.0.0+) (#680)
* Change

* Remove

* Polyfill based on docs recommendation

* Update comment

* Update pkg/codec/svtav1/bridge.h comment to actual repo

Co-authored-by: Atsushi Watanabe <atsushi.w@ieee.org>

---------

Co-authored-by: Atsushi Watanabe <atsushi.w@ieee.org>
2026-02-03 14:03:16 -05:00
David von Wrangel 09fe4a9a6e Move AVFoundation to parent directory (#677) 2026-01-08 18:36:41 +01:00
sean yu 03900dcb1b Add darwin runtime device observer support (#670)
* wip

* wip

* Organize

* Remove unnecessary change in camera_darwin.go filtering

* wip

* Make observer stop safe during startup

* wip IsAvailable impl

* Fix non-darwin builds

* Lock bg loop to main thread and add comment

* Remove fmt prints

* Simplify isAvailable; Add timeout for Read darwin

* Match comment with code

* Change to singleton pattern; Add clearer safer state machine states; Change language from Stop to Destroy; Add new error for when observer is unavailable;

* Add stubs for linux

* Move cancel() up so its not dead code sometimes

* Add stubs for Windows too

* Remove StopObserver usage

* Add camera tests

* Add device observer tests

* Fix multiple destroy calls bug; Call setup in start

* Improve isAvailable

* Improve string handling in device observer c

* Add error handling in example

* Add comment about setup vs start

* Rename and organize device observer darwin

* Explicitly case initial state for setup

* Fix potential destroy goroutine leak; Use only modern build tag; Return err not nil for stubs; Improve comments

* Close startDone channel on device observer stop not wait
2025-12-28 13:33:36 -08:00
sean yu 0e726eac75 Add context with timeout to darwin Read() calls (#674)
* Add timeout

* Clean
2025-12-10 22:30:30 -05:00
Atsushi Watanabe 810921d448 Add SVT-AV1 codec (#660) 2025-11-10 09:26:21 +09:00
Haily Nguyen a5e2538787 Revert "Add VPX wrappers (#652)" (#662)
This reverts commit a68a5ba4a6.
2025-10-22 02:45:06 -07:00
Haily Nguyen a68a5ba4a6 Add VPX wrappers (#652)
* Add VPX improvements from pion-mediadevices

- Add vpx_image.go: VpxImage wrapper for vpx_image_t with convenient methods
- Move BitrateTracker to vpx package: More specific to VPX codec usage
- Add bitrate_tracker_test.go: Test coverage for VPX-specific bitrate tracking
- Remove generic codec-level BitrateTracker: Replaced by VPX-specific version

These changes improve VPX codec functionality and organization by:
1. Adding image handling utilities specific to VPX
2. Providing better bitrate tracking for VPX codecs
3. Improving code organization by moving VPX-specific code to VPX package

* Revert bitrate tracker changes

- Remove vpx-specific bitrate tracker files
- Restore original codec-level bitrate tracker and test
- Keep only the vpx_image.go addition from pion-mediadevices

* Add comprehensive unit tests for VpxImage

- Add vpx_image_test.go with full test coverage for VpxImage wrapper
- Test interface compliance and constructor behavior
- Test nil pointer handling (documents expected panic behavior)
- Test common video format constants and plane indices
- All tests pass and integrate with existing VPX test suite

This improves test coverage for the new VpxImage utility from pion-mediadevices.

* Add comprehensive unit tests for VpxImage

- Add vpx_image_test.go with full test coverage for VpxImage wrapper
- Test interface compliance and constructor behavior
- Test nil pointer handling (documents expected panic behavior)
- Test common video format constants and plane indices
- All tests pass and integrate with existing VPX test suite

This improves test coverage for the new VpxImage utility from pion-mediadevices.
2025-10-09 16:15:33 -07:00
philipch07 5a0a5b00d4 Use isZero for reflection (#655) 2025-10-07 16:36:03 -04:00
Lei Kang cb394eb4c5 resolve comment 2025-09-17 16:50:52 -07:00
Atsushi Watanabe e9f3dc20b6 Fix reading multiple decoded frames 2025-09-17 16:50:52 -07:00
Lei Kang 0710906fc7 fix the test 2025-09-17 16:50:52 -07:00
Lei Kang 7fdafa9598 add codec decoder interface 2025-09-17 16:50:52 -07:00
Lei Kang 5a19127623 add return error code 2025-09-17 16:50:52 -07:00
Lei Kang 8ca6903676 add null pointer from C 2025-09-17 16:50:52 -07:00
Lei Kang de517d790b wrap vpx_image into a struct 2025-09-17 16:50:52 -07:00
Lei Kang 81cfc047d5 add vpx decoder 2025-09-17 16:50:52 -07:00
philipch07 c0721738c4 Apply go modernize (#650) 2025-09-14 21:55:37 -04:00
Leo (Lei) Kang 6047a32ea0 [VPX] vpx dynamic encoding (#647)
* Add vp8 decoder and dynamic vp8 decoding

* Add QPController

* change parameters into const

* move decoder into another PR

* use explicit parameter name
2025-09-04 14:33:07 -07:00
Leo (Lei) Kang 60bf158757 [CODEC] Add encoder bitrate tracker (#646)
add encoder bitrate tracker
2025-09-03 15:55:37 -07:00
Jingyang Kang 84ccb15157 Align H265 payloadType in NewRTPH265Codec with RegisterDefaultCodecs (#631) 2025-06-01 23:37:30 +08:00
Kyle 20e8c50735 Implement bitrate controller in vpx and h264 codecs (#467)
Add bitrate control to vpx and h264 encoders

Co-authored-by: Jingyang Kang <3drxkjy@gmail.com>
2025-04-11 12:05:01 +08:00
代码人生 cd5f8eb43a set bitrate for openh264 (#566)
* Added the set bitrate function for openh264

* add examples

* Format

---------

Co-authored-by: Jingyang Kang <3drxkjy@gmail.com>
2025-04-06 20:47:23 +08:00
Jingyang Kang 5cad3f1b41 Feat/add helper function for av1 and h265 codec (#611)
* bump deps version

* Add NewRTPAV1Codec

* fix comment

* Update SDPFmtpLine for RTPAV1Codec

* Add helper function for h265 as well
2025-03-10 07:25:25 -07:00
Yohan Totting ce9b412d0e Fix the VPX encoder is not properly handling the frame timestamp (#606)
* Fix the VPX encoder is not properly handling the frame timestamp

* Apply suggestions from code review

Co-authored-by: Atsushi Watanabe <atsushi.w@ieee.org>

---------

Co-authored-by: Atsushi Watanabe <atsushi.w@ieee.org>
2025-02-14 12:37:53 +07:00
Jingyang Kang 4027590fcb Migrate to pion/webrtc/v4 (#592) 2024-12-10 14:12:02 +09:00
Sean Pollock 8fb8d65764 Add webcam close to linux camera discover (#568)
Add webcam close to linux discover
2024-04-30 10:14:26 -04:00
qiulin ae63fa65bf Remove Windows camera cpp inline function (#569)
Co-authored-by: Qiulin Li <liqiulin@outlook.com>
2024-04-29 09:54:45 -04:00
sean yu a9046e6ac1 Add fix that strips unexpected padding for NV12 frames (#556) 2024-03-01 12:23:05 -05:00
Eric Daniels 2bc011f39f Update malgo to v0.11.21 for a macOS microphone fix (#551) 2024-01-24 09:48:40 -05:00
hexbabe 09b497727d Removed 'unreachable' else initialization and replaced with error indicating a wtf 2023-10-31 14:48:49 -04:00
hexbabe 7ae82fbda7 Remove old unnecessary macro 2023-10-31 14:48:49 -04:00
hexbabe 4477898296 Use new macro and also use @ available 2023-10-31 14:48:49 -04:00
hexbabe d5d41e9ca5 Switch to what I think is the correct preprocessor method 2023-10-31 14:48:49 -04:00
hexbabe 9fb24fb036 Use identifier conditional compilation (hackier) but might work and is still decently readable 2023-10-31 14:48:49 -04:00
hexbabe 1cd1b136cc This @available compile time directive really should work... confused 2023-10-31 14:48:49 -04:00
hexbabe 08fb3e8a48 Change code conditional to conditional compilation directive to avoid CI failure 2023-10-31 14:48:49 -04:00
hexbabe 4aae1bc842 Add conditional to choose types based on pre vs. post sonoma update 2023-10-31 14:48:49 -04:00
seanavery 3c9fee958e Add manager clearing mechanism 2023-10-17 16:41:33 -04:00
Valentin Cocaud 2882fd42d5 use thread safe atomic bool 2023-09-20 15:46:33 -04:00
Valentin Cocaud 694b4abd83 fix ForceKeyFrame signature for VP8 2023-09-20 15:46:33 -04:00
Valentin Cocaud afb2f78e3c force key frame implementation for vaapi 2023-09-20 15:46:33 -04:00
seanavery 03c44ee803 Remove extra comment 2023-07-24 12:07:38 -04:00
seanavery dad145ef11 Add props even if framerate is not supported 2023-07-24 12:07:38 -04:00
Atsushi Watanabe 72c1d7bb89 Fix invalid memory access in ScalerFastBoxSampling (#513)
[src-px]->[dst-px] of 4x1px to 2x1px scaling was
  0->0, 1->1, 2->1, 3->2(out of bounds)
Fix it to be
  0->0, 1->0, 2->1, 3->1
2023-07-05 12:01:40 +09:00