diff --git a/README.md b/README.md index 1f1daac..456d4e1 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,16 @@ 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 The following snippet shows how to capture a camera stream and store a frame as a jpeg image: diff --git a/pkg/driver/microphone/microphone.go b/pkg/driver/microphone/microphone.go index 6bfbf56..26c85d7 100644 --- a/pkg/driver/microphone/microphone.go +++ b/pkg/driver/microphone/microphone.go @@ -1,3 +1,6 @@ +//go:build !nomicrophone +// +build !nomicrophone + package microphone import ( diff --git a/pkg/driver/microphone/microphone_stub.go b/pkg/driver/microphone/microphone_stub.go new file mode 100644 index 0000000..34eec05 --- /dev/null +++ b/pkg/driver/microphone/microphone_stub.go @@ -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