mirror of
https://github.com/pion/mediadevices.git
synced 2026-04-22 15:57:27 +08:00
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
This commit is contained in:
@@ -21,6 +21,16 @@
|
|||||||
go get -u github.com/pion/mediadevices
|
go get -u github.com/pion/mediadevices
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Build Tags
|
||||||
|
|
||||||
|
`mediadevices` provides a `nomicrophone` build tag. Use this tag to build without microphone support. This is particularly useful for:
|
||||||
|
- Cross-compilation where CGO dependencies like `malgo` are unavailable.
|
||||||
|
- Projects where audio is not required.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go build -tags nomicrophone
|
||||||
|
```
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
The following snippet shows how to capture a camera stream and store a frame as a jpeg image:
|
The following snippet shows how to capture a camera stream and store a frame as a jpeg image:
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
//go:build !nomicrophone
|
||||||
|
// +build !nomicrophone
|
||||||
|
|
||||||
package microphone
|
package microphone
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
//go:build nomicrophone
|
||||||
|
// +build nomicrophone
|
||||||
|
|
||||||
|
package microphone
|
||||||
|
|
||||||
|
// This stub file is used when building with the 'nomicrophone' build tag.
|
||||||
|
// Use this when cross-compiling or when malgo (miniaudio) dependencies are not available.
|
||||||
|
//
|
||||||
|
// To build without microphone support:
|
||||||
|
// go build -tags nomicrophone
|
||||||
|
//
|
||||||
|
// This is particularly useful for:
|
||||||
|
// - Cross-compilation where CGO dependencies are unavailable
|
||||||
|
// - Environments without audio system development libraries
|
||||||
|
// - Minimal builds that only need camera/video support
|
||||||
Reference in New Issue
Block a user