AVCapture
Supported Hardware Devices: Pro Capture cards
Contents Demonstrated in the Sample:
- Preview captured video and monitor captured audio
- Freely select video capture devices and their corresponding audio devices
- Freely switch capture parameters: resolution, frame rate, color space
- Support multi-channel capture: simultaneously capture one or two audio/video streams and render them separately.
- Record captured audio and video data as FLV files.
Call Logic:
- Obtain version information, initialize and enumerate devices: MWGetVersion, MWCaptureInitInstance, MWRefreshDevice, MWGetChannelCount
- Filter supported devices based on device information and interface information: MWGetChannelInfoByIndex
- Create a video rendering layer and overlay it on the current window: createPreviewLayer
- Open channel: MWGetDevicePath, MWOpenChannelByPath
- Create audio renderer: MWAudioRenderCreate, MWAudioRenderStart
- Start video capture and rendering thread
- Start audio capture and rendering thread
- Enter main thread loop
- Click menu to switch audio/video channels or capture parameters:
- Stop audio capture and rendering thread
- Stop video capture and rendering thread
- Destroy audio renderer: MWAudioRenderStop, MWAudioRenderDestroy
- Close channel: MWCloseChannel
- Open channel and capture/render according to set channel and capture parameters: steps 4, 5, 6, 7
- After clicking the close button, exit capture and release resources:
- Stop audio capture and rendering thread
- Stop video capture and rendering thread
- Destroy audio renderer: MWAudioRenderStop, MWAudioRenderDestroy
- Close channel: MWCloseChannel
- Destroy instance: MWCaptureExitInstance.
Video Capture and Rendering Thread:
- Start video capture: MMWStartVideoCapture
- Create Event: MWCreateEvent
- Register timer: MWRegisterTimer
- Set time schedule: MWScheduleTimer
- Wait for Event: MWTryWaitEvent, MWWaitEvent, MWMultiWaitEvent
- Capture video data: MWCaptureVideoFrameToVirtualAddressEx
- Get current capture status and release capture card resources: MWGetVideoCaptureStatus
- Repeat steps 4, 5, 6, 7 until thread exits
- Unregister timer: MWUnregisterTimer
- Close Event: MWCloseEvent
- Stop capture: MWStopVideoCapture
Audio Capture and Rendering Thread:
- Start audio capture: MWStartAudioCapture
- Create Event: MWCreateEvent
- Register message notification: MWRegisterNotify
- Wait for Event: MWTryWaitEvent, MWWaitEvent, MWMultiWaitEvent
- Capture audio data: MWCaptureAudioFrame
- Render audio data
- Repeat steps 4, 5, 6 until thread exits
- Unregister message notification: MWUnregisterNotify
- Close Event: MWCloseEvent
- Stop capture: MWStopAudioCapture
Result:
Flowchart:
