Skip to content

Commit 1f4970d

Browse files
Ali Hassan ShahLzw655
authored andcommitted
usb stream squash commit
1 parent ec4a23a commit 1f4970d

23 files changed

+8131
-55
lines changed

.github/workflows/build_test.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
exclude: 'src/original'
12
repos:
23
- repo: https://github.com/igrr/astyle_py.git
34
rev: master

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# ChangeLog
22

3-
## v0.0.1 - [xxx]
3+
## v0.0.1 - [2023-11-10]
44

55
### Enhancements:
66

7-
* [xxx]
7+
* Only support for ESP32-S2 and ESP32-S3 SoCs.
8+
* Support video stream through UVC Stream interface.
9+
* Support microphone stream and speaker stream through the UAC Stream interface
10+
* Support volume, mute and other features control through the UAC Control interface
11+
* Support stream separately suspend and resume

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,69 @@
1-
[![Arduino Lint](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/pre-commit.yml) [![Build Test Apps](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/build_test.yml/badge.svg)](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/build_test.yml)
1+
[![Arduino Lint](https://github.com/esp-arduino-libs/ESP32_USB_Stream/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_USB_Stream/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/ESP32_USB_Stream/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_USB_Stream/actions/workflows/pre-commit.yml)
22

3-
# [xxx]
3+
# ESP32_USB_STREAM
44

5-
[xxx] is an Arduino library designed for driving [xxx] using ESP SoCs.
5+
ESP32_USB_STREAM is an Arduino library designed to support USB UVC + UAC host driver for ESP32-S2/ESP32-S3. It supports read/write/control multimedia streaming from usb device. For example, at most one UVC + one Microphone + one Speaker streaming can be supported at the same time.
66

7-
[xxx] encapsulates the component from the [Espressif Components Registry](https://components.espressif.com/). It is developed based on [arduino-esp32](https://github.com/espressif/arduino-esp32) and can be easily downloaded and integrated into the Arduino IDE.
7+
ESP32_USB_STREAM encapsulates the component from the [Espressif Components Registry](https://components.espressif.com/). It is developed based on [arduino-esp32](https://github.com/espressif/arduino-esp32) and can be easily downloaded and integrated into the Arduino IDE.
88

99
## Features
1010

11-
* [xxx]
11+
* Only support for ESP32-S2 and ESP32-S3 SoCs.
12+
* Support video stream through UVC Stream interface.
13+
* Support microphone stream and speaker stream through the UAC Stream interface
14+
* Support volume, mute and other features control through the UAC Control interface
15+
* Support stream separately suspend and resume
1216

1317
## Supported Drivers
1418

1519
| **Driver** | **Version** |
1620
| ------------------------------------------------------------------ | ----------- |
17-
| [xxx](https://components.espressif.com/components/espressif/xxx) | |
18-
19-
## Dependencies Version
20-
21-
| **Name** | **Version** |
22-
| ----------------------------------------------------------- | ----------- |
23-
| [xxx] | v0.x.x |
24-
| [arduino-esp32](https://github.com/espressif/arduino-esp32) | >= [xxx] |
21+
| [usb_stream](https://components.espressif.com/components/espressif/usb_stream) |1.2.0|
2522

2623
## How to Use
2724

2825
For information on how to use the library in the Arduino IDE, please refer to the documentation for [Arduino IDE v1.x.x](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries) or [Arduino IDE v2.x.x](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-installing-a-library).
2926

27+
## Dependencies Version
28+
29+
| **Name** | **Version** |
30+
| -------------------------------------------------------------------------- | ----------- |
31+
| [arduino-esp32](https://github.com/espressif/arduino-esp32) | >= v2.0.14 |
32+
3033
### Examples
3134

32-
* [xxx](examples/xxx): Demonstrates how to use [xxx] and test all functions.
35+
* [Getting started with a UVC](examples/GettingStartUVC/): Demonstrates how to use usb video streaming.
36+
* [Getting started with a UAC](examples/GettingStartUAC/): Demonstrates how to use usb audio streaming.
3337

3438
### Detailed Usage
3539

3640
```cpp
37-
[xxx]
41+
#include "USB_STREAM.h"
42+
43+
// Instantiate a Ustream object
44+
USB_STREAM *usb = new USB_STREAM();
45+
46+
// allocate memory
47+
uint8_t *_xferBufferA = (uint8_t *)malloc(55 * 1024);
48+
assert(_xferBufferA != NULL);
49+
uint8_t *_xferBufferB = (uint8_t *)malloc(55 * 1024);
50+
assert(_xferBufferB != NULL);
51+
uint8_t *_frameBuffer = (uint8_t *)malloc(55 * 1024);
52+
assert(_frameBuffer != NULL);
53+
54+
// Config the parameter
55+
usb->uvcConfiguration(FRAME_RESOLUTION_ANY, FRAME_RESOLUTION_ANY, FRAME_INTERVAL_FPS_15, 55 * 1024, _xferBufferA, _xferBufferB, 55 * 1024, _frameBuffer);
56+
57+
58+
//Register the camera frame callback function
59+
usb->uvcCamRegisterFrameCb(&cameraFramecb, NULL);
60+
61+
usb->start();
62+
63+
/*Dont forget to free the allocated memory*/
64+
// free(_xferBufferA);
65+
// free(_xferBufferB);
66+
// free(_frameBuffer);
67+
3868
```
69+
Note: For additional details and information about the **usb_stream** functionality, please refer to the documentation provided by [ESP-IOT Solutions](https://github.com/espressif/esp-iot-solution/tree/master/components/usb/usb_stream).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <Arduino.h>
2+
#include "USB_STREAM.h"
3+
4+
/* Define the Mic frame callback function implementation */
5+
static void onMicFrameCallback(mic_frame_t *frame, void *ptr)
6+
{
7+
// We should using higher baudrate here, to reduce the blocking time here
8+
Serial.printf("mic callback! bit_resolution = %u, samples_frequence = %"PRIu32", data_bytes = %"PRIu32"\n", frame->bit_resolution, frame->samples_frequence, frame->data_bytes);
9+
}
10+
11+
void setup()
12+
{
13+
Serial.begin(115200);
14+
// Instantiate a Ustream object
15+
USB_STREAM *usb = new USB_STREAM();
16+
17+
// Config the parameter
18+
usb->uacConfiguration(UAC_CH_ANY, UAC_BITS_ANY, UAC_FREQUENCY_ANY, 6400, UAC_CH_ANY, UAC_BITS_ANY, UAC_FREQUENCY_ANY, 6400);
19+
20+
//Register the camera frame callback function
21+
usb->uacMicRegisterCb(&onMicFrameCallback, NULL);
22+
23+
usb->start();
24+
25+
usb->connectWait(1000);
26+
delay(5000);
27+
28+
usb->uacMicMute((void *)0);
29+
delay(5000);
30+
31+
usb->uacMicVolume((void *)60);
32+
33+
usb->uacMicSuspend(NULL);
34+
delay(5000);
35+
36+
usb->uacMicResume(NULL);
37+
38+
}
39+
40+
// The loop function runs repeatedly
41+
void loop()
42+
{
43+
// Delay the task for 100ms
44+
vTaskDelay(5000);
45+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <Arduino.h>
2+
#include "USB_STREAM.h"
3+
4+
/* Define the camera frame callback function implementation */
5+
static void onCameraFrameCallback(uvc_frame *frame, void *user_ptr)
6+
{
7+
Serial.printf("uvc callback! frame_format = %d, seq = %" PRIu32 ", width = %" PRIu32", height = %" PRIu32 ", length = %u, ptr = %d\n",
8+
frame->frame_format, frame->sequence, frame->width, frame->height, frame->data_bytes, (int)user_ptr);
9+
}
10+
11+
void setup()
12+
{
13+
Serial.begin(115200);
14+
// Instantiate an object
15+
USB_STREAM *usb = new USB_STREAM();
16+
17+
// allocate memory
18+
uint8_t *_xferBufferA = (uint8_t *)malloc(55 * 1024);
19+
assert(_xferBufferA != NULL);
20+
uint8_t *_xferBufferB = (uint8_t *)malloc(55 * 1024);
21+
assert(_xferBufferB != NULL);
22+
uint8_t *_frameBuffer = (uint8_t *)malloc(55 * 1024);
23+
assert(_frameBuffer != NULL);
24+
25+
// Config the parameter
26+
usb->uvcConfiguration(FRAME_RESOLUTION_ANY, FRAME_RESOLUTION_ANY, FRAME_INTERVAL_FPS_15, 55 * 1024, _xferBufferA, _xferBufferB, 55 * 1024, _frameBuffer);
27+
28+
//Register the camera frame callback function
29+
usb->uvcCamRegisterCb(&onCameraFrameCallback, NULL);
30+
31+
usb->start();
32+
33+
usb->connectWait(1000);
34+
delay(5000);
35+
36+
usb->uvcCamSuspend(NULL);
37+
delay(5000);
38+
39+
usb->uvcCamResume(NULL);
40+
41+
/*Dont forget to free the allocated memory*/
42+
// free(_xferBufferA);
43+
// free(_xferBufferB);
44+
// free(_frameBuffer);
45+
}
46+
47+
void loop()
48+
{
49+
vTaskDelay(100);
50+
}

library.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name=[xxx]
1+
name=ESP32_USB_STREAM
22
version=0.0.1
33
author=espressif
4-
maintainer=[xxx]
5-
sentence=[xxx] is a library designed for [xxx] using ESP SoCs
6-
paragraph=Currently support [xxx]
4+
maintainer=alibukharai
5+
sentence=ESP32_USB_STREAM is a specialized library created to facilitate the implementation of USB stream functionality on ESP SoCs.
6+
paragraph=This means that it provides a convenient and efficient way to transmit audio and video data through USB connections, making it an invaluable tool for a wide range of applications such as audio and video streaming, data transfer, and more. Currently, it is only competible with ESP32-S2 and ESP32-S3.
77
category=Other
88
architectures=esp32
9-
url=[xxx]
10-
includes=[xxx]
9+
url=https://github.com/esp-arduino-libs/ESP32_USB_Stream
10+
includes=USB_STREAM.h

0 commit comments

Comments
 (0)