|
| 1 | +# vStream via VSI |
| 2 | + |
| 3 | +This directory contains the implementation of vStream interface for audio and video streaming |
| 4 | +using Virtual Streaming Interface (VSI). The vStream interface is defined by CMSIS-Driver and |
| 5 | +offers standardized interface to interact with various streaming devices to allow seamless |
| 6 | +development on one platform and deployment on another. |
| 7 | + |
| 8 | +Implementation consists of two components |
| 9 | + |
| 10 | +- vStream driver implementation in C (targeting embedded application) |
| 11 | +- implementation of VSI Python interface in Python (targeting host PC) |
| 12 | + |
| 13 | +## vStream Drivers |
| 14 | + |
| 15 | +Directory `source` contains CMSIS-Driver vStream implementations for audio input/output |
| 16 | +and video input/output streaming. |
| 17 | + |
| 18 | +**Audio Drivers**: |
| 19 | + |
| 20 | +- `vstream_audio_in.c/h` - vStream_AudioIn implementation |
| 21 | +- `vstream_audio_out.c/h` - vStream_AudioOut implementation |
| 22 | + |
| 23 | +**Video Drivers**: |
| 24 | + |
| 25 | +- `vstream_video_in.c/h` - vStream_VideoIn implementation |
| 26 | +- `vstream_video_out.c/h` - vStream_VideoOut implementation |
| 27 | + |
| 28 | +### Configuration for vStream Drivers |
| 29 | + |
| 30 | +Directory `config` contains configuration headers for vStream drivers. |
| 31 | + |
| 32 | +Configuration enables user to configure basic audio and video stream parameters |
| 33 | +to adapt vStream driver to embedded application expectation. |
| 34 | + |
| 35 | +**Configuration Files**: |
| 36 | + |
| 37 | +- `vstream_audio_in_config.h` - configures vStream_AudioIn |
| 38 | +- `vstream_audio_out_config.h` - configures vStream_AudioOut |
| 39 | +- `vstream_video_in_config.h` - configures vStream_VideoIn |
| 40 | +- `vstream_video_out_config.h` - configures vStream_VideoOut |
| 41 | + |
| 42 | +**Audio Stream Configuration**: |
| 43 | + |
| 44 | +Configuration options for configuring vStream audio drivers are: |
| 45 | + |
| 46 | +| Parameter | Description | Available Options | Configuration Macro | |
| 47 | +|---------------------------|------------------------------------------------------|---------------------------------|------------------------------| |
| 48 | +| Number of channels | Defines the number of audio channels in stream | Mono (1), Stereo (2) | `AUDIO_[IN/OUT]_CHANNELS` | |
| 49 | +| Number of bits per sample | Defines number of bits of information in each sample | 8-bit, 16-bit, 24-bit, 32-bit | `AUDIO_[IN/OUT]_SAMPLE_BITS` | |
| 50 | +| Sample rate | Defines the number of samples per second | 8 kHz, 16 kHz, 44.1 kHz, 48 kHz | `AUDIO_[IN/OUT]_SAMPLE_RATE` | |
| 51 | + |
| 52 | +**Video Stream Configuration**: |
| 53 | + |
| 54 | +Configuration options for configuring vStream Video drivers are: |
| 55 | + |
| 56 | +| Parameter | Description | Available Options | Configuration Macro | |
| 57 | +|--------------|----------------------------------------------------------|---------------------------------|-------------------------------| |
| 58 | +| Frame width | Defines the video stream frame width in pixels | User-defined (e.g., 320, 640) | `VIDEO_[IN/OUT]_FRAME_WIDTH` | |
| 59 | +| Frame height | Defines the video stream frame height in pixels | User-defined (e.g., 240, 480) | `VIDEO_[IN/OUT]_FRAME_HEIGHT` | |
| 60 | +| Frame rate | Defines the video stream frame rate in frames per second | User-defined (e.g., 15, 30, 60) | `VIDEO_[IN/OUT]_FRAME_RATE` | |
| 61 | +| Color format | Defines the video frame color space | Grayscale, RGB888, BGR565 | `VIDEO_[IN/OUT]_FRAME_COLOR` | |
| 62 | + |
| 63 | +**Common Configuration**: |
| 64 | + |
| 65 | +Besides stream configuration there are configuration options related to stream source selection. The below table shows possible stream sources: |
| 66 | + |
| 67 | +| Stream Type | Stream Source | Description | Configuration | |
| 68 | +|---------------|-----------------------|-----------------------------------------------|------------------------------------------| |
| 69 | +| **Audio In** | System Default Input | Uses the system's default audio input device | `AUDIO_IN_DEVICE = -1` | |
| 70 | +| | Specific Audio Device | Uses a specific audio input device by index | `AUDIO_IN_DEVICE = <device_index>` | |
| 71 | +| | Audio File | Reads audio data from a file | `AUDIO_IN_FILENAME = "path/to/file.wav"` | |
| 72 | +| **Audio Out** | System Default Output | Uses the system's default audio output device | `AUDIO_OUT_DEVICE = -1` | |
| 73 | +| | Specific Audio Device | Uses a specific audio output device by index | `AUDIO_OUT_DEVICE = <device_index>` | |
| 74 | +| | Audio File | Writes audio data to a file | `AUDIO_OUT_FILENAME = "path/to/file.wav"`| |
| 75 | +| **Video In** | System Default Input | Uses the system's default video input device | `VIDEO_IN_DEVICE = -1` | |
| 76 | +| | Specific Input Device | Uses a specific camera device by index | `VIDEO_IN_DEVICE = <device_index>` | |
| 77 | +| | Video File | Reads video frames from a file | `VIDEO_IN_FILENAME = "path/to/file.mp4"` | |
| 78 | +| **Video Out** | Display Window | Displays video frames in a window | No device configuration needed | |
| 79 | +| | Video File | Writes video frames to a file | `VIDEO_OUT_FILENAME = "path/to/file.mp4"`| |
| 80 | + |
| 81 | +> [!NOTE] |
| 82 | +> |
| 83 | +> OpenCV is not able to automatically detect system default device. Instead it enumerates devices, for example: |
| 84 | +> |
| 85 | +> - 0 being the internal camera |
| 86 | +> - 1 is the first external camera |
| 87 | +
|
| 88 | +## Virtual Streaming Interface for Python |
| 89 | + |
| 90 | +Directory `python` contains Python scripts that implement [VSI for Python](https://arm-software.github.io/AVH/main/simulation/html/group__arm__vsi__py.html) |
| 91 | +and execute on host PC. Audio and video servers are implemented independently to support access to audio and video streams. |
| 92 | + |
| 93 | +**VSI scripts for Python**: |
| 94 | + |
| 95 | +The `arm_vsi*.py` files provide VSI implementations for different channels. |
| 96 | + |
| 97 | +- `arm_vsi0.py` and `arm_vsi1.py` implement Audio streaming channels |
| 98 | +- `arm_vsi4/vsi5/vsi6/vsi7.py` - implement Video streaming channels |
| 99 | + |
| 100 | +**Audio Server**: |
| 101 | + |
| 102 | +- `vsi_audio_server.py` and |
| 103 | +- `vsi_audio.py` |
| 104 | + |
| 105 | + implement Python server and client for audio streaming using PyAudio. |
| 106 | + |
| 107 | +**Video Server**: |
| 108 | + |
| 109 | +- `vsi_video_server.py` and |
| 110 | +- `vsi_video.py` |
| 111 | + |
| 112 | + implement Python server and client for video streaming using OpenCV. |
| 113 | + |
| 114 | +### Audio Server |
| 115 | + |
| 116 | +The Audio Server implements a TCP-based server for audio streaming operations using PyAudio. It provides comprehensive audio I/O capabilities for both real-time audio devices and file-based streaming. |
| 117 | + |
| 118 | +**Key Features**: |
| 119 | + |
| 120 | +- Supports both audio input (microphone/file recording) and audio output (speaker/file playback) |
| 121 | +- Supports automatic detection and configuration of system audio devices |
| 122 | +- Supports WAV file reading and writing |
| 123 | +- Allows multiple client connections |
| 124 | + |
| 125 | +### Video Server |
| 126 | + |
| 127 | +The Video Server implements a TCP-based server for video streaming operations using OpenCV. It provides video I/O capabilities for accessing cameras and video files. |
| 128 | + |
| 129 | +**Key Features**: |
| 130 | + |
| 131 | +- Supports both video input (camera/file capture) and video output (display/file recording) |
| 132 | +- Supports access to system cameras and USB video devices |
| 133 | +- Supports multiple video formats (AVI, MP4, WMV) and image formats (BMP, PNG, JPG) |
| 134 | +- Supports frame-by-frame processing with automatic format conversion |
| 135 | +- Allows multiple client connections |
0 commit comments