Skip to content

Commit

Permalink
usb stream squash commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alibukharai committed Nov 13, 2023
1 parent ec4a23a commit c1f8854
Show file tree
Hide file tree
Showing 23 changed files with 8,131 additions and 55 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/build_test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude: 'src/original'
repos:
- repo: https://github.com/igrr/astyle_py.git
rev: master
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# ChangeLog

## v0.0.1 - [xxx]
## v0.0.1 - [2023-11-10]

### Enhancements:

* [xxx]
* Only support for ESP32-S2 and ESP32-S3 SoCs.
* Support video stream through UVC Stream interface.
* Support microphone stream and speaker stream through the UAC Stream interface
* Support volume, mute and other features control through the UAC Control interface
* Support stream separately suspend and resume
4 changes: 0 additions & 4 deletions CMakeLists.txt

This file was deleted.

61 changes: 46 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,69 @@
[![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)
[![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)

# [xxx]
# [ESP32_USB_STREAM]

[xxx] is an Arduino library designed for driving [xxx] using ESP SoCs.
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.

[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.
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.

## Features

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

## Supported Drivers

| **Driver** | **Version** |
| ------------------------------------------------------------------ | ----------- |
| [xxx](https://components.espressif.com/components/espressif/xxx) | |

## Dependencies Version

| **Name** | **Version** |
| ----------------------------------------------------------- | ----------- |
| [xxx] | v0.x.x |
| [arduino-esp32](https://github.com/espressif/arduino-esp32) | >= [xxx] |
| [usb_stream](https://components.espressif.com/components/espressif/usb_stream) |1.2.0|

## How to Use

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).

## Dependencies Version

| **Name** | **Version** |
| -------------------------------------------------------------------------- | ----------- |
| [arduino-esp32](https://github.com/espressif/arduino-esp32) | >= v2.0.14 |

### Examples

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

### Detailed Usage

```cpp
[xxx]
#include "USB_STREAM.h"

// Instantiate a Ustream object
USB_STREAM *usb = new USB_STREAM();

// allocate memory
uint8_t *_xferBufferA = (uint8_t *)malloc(55 * 1024);
assert(_xferBufferA != NULL);
uint8_t *_xferBufferB = (uint8_t *)malloc(55 * 1024);
assert(_xferBufferB != NULL);
uint8_t *_frameBuffer = (uint8_t *)malloc(55 * 1024);
assert(_frameBuffer != NULL);

// Config the parameter
usb->uvcConfiguration(FRAME_RESOLUTION_ANY, FRAME_RESOLUTION_ANY, FRAME_INTERVAL_FPS_15, 55 * 1024, _xferBufferA, _xferBufferB, 55 * 1024, _frameBuffer);


//Register the camera frame callback function
usb->uvcCamRegisterFrameCb(&cameraFramecb, NULL);

usb->start();

/*Dont forget to free the allocated memory*/
// free(_xferBufferA);
// free(_xferBufferB);
// free(_frameBuffer);

```
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).
45 changes: 45 additions & 0 deletions examples/GettingStartUAC/GettingStartUAC.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <Arduino.h>
#include "USB_STREAM.h"

/* Define the Mic frame callback function implementation */
static void onMicFrameCallback(mic_frame_t *frame, void *ptr)
{
// We should using higher baudrate here, to reduce the blocking time here
Serial.printf("mic callback! bit_resolution = %u, samples_frequence = %"PRIu32", data_bytes = %"PRIu32"\n", frame->bit_resolution, frame->samples_frequence, frame->data_bytes);
}

void setup()
{
Serial.begin(115200);
// Instantiate a Ustream object
USB_STREAM *usb = new USB_STREAM();

// Config the parameter
usb->uacConfiguration(UAC_CH_ANY, UAC_BITS_ANY, UAC_FREQUENCY_ANY, 6400, UAC_CH_ANY, UAC_BITS_ANY, UAC_FREQUENCY_ANY, 6400);

//Register the camera frame callback function
usb->uacMicRegisterCb(&onMicFrameCallback, NULL);

usb->start();

usb->connectWait(1000);
delay(5000);

usb->uacMicMute((void *)0);
delay(5000);

usb->uacMicVolume((void *)60);

usb->uacMicSuspend(NULL);
delay(5000);

usb->uacMicResume(NULL);

}

// The loop function runs repeatedly
void loop()
{
// Delay the task for 100ms
vTaskDelay(5000);
}
50 changes: 50 additions & 0 deletions examples/GettingStartUVC/GettingStartUVC.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <Arduino.h>
#include "USB_STREAM.h"

/* Define the camera frame callback function implementation */
static void onCameraFrameCallback(uvc_frame *frame, void *user_ptr)
{
Serial.printf("uvc callback! frame_format = %d, seq = %" PRIu32 ", width = %" PRIu32", height = %" PRIu32 ", length = %u, ptr = %d\n",
frame->frame_format, frame->sequence, frame->width, frame->height, frame->data_bytes, (int)user_ptr);
}

void setup()
{
Serial.begin(115200);
// Instantiate an object
USB_STREAM *usb = new USB_STREAM();

// allocate memory
uint8_t *_xferBufferA = (uint8_t *)malloc(55 * 1024);
assert(_xferBufferA != NULL);
uint8_t *_xferBufferB = (uint8_t *)malloc(55 * 1024);
assert(_xferBufferB != NULL);
uint8_t *_frameBuffer = (uint8_t *)malloc(55 * 1024);
assert(_frameBuffer != NULL);

// Config the parameter
usb->uvcConfiguration(FRAME_RESOLUTION_ANY, FRAME_RESOLUTION_ANY, FRAME_INTERVAL_FPS_15, 55 * 1024, _xferBufferA, _xferBufferB, 55 * 1024, _frameBuffer);

//Register the camera frame callback function
usb->uvcCamRegisterCb(&onCameraFrameCallback, NULL);

usb->start();

usb->connectWait(1000);
delay(5000);

usb->uvcCamSuspend(NULL);
delay(5000);

usb->uvcCamResume(NULL);

/*Dont forget to free the allocated memory*/
// free(_xferBufferA);
// free(_xferBufferB);
// free(_frameBuffer);
}

void loop()
{
vTaskDelay(100);
}
12 changes: 6 additions & 6 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name=[xxx]
name=ESP32_USB_STREAM
version=0.0.1
author=espressif
maintainer=[xxx]
sentence=[xxx] is a library designed for [xxx] using ESP SoCs
paragraph=Currently support [xxx]
maintainer=alibukharai
sentence=ESP32_USB_STREAM is a specialized library created to facilitate the implementation of USB stream functionality on ESP SoCs.
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.
category=Other
architectures=esp32
url=[xxx]
includes=[xxx]
url=https://github.com/esp-arduino-libs/ESP32_USB_Stream
includes=USB_STREAM.h
Loading

0 comments on commit c1f8854

Please sign in to comment.