audio_stream.h 1019 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. #include "esp_err.h"
  6. #include "audio_receiver.h"
  7. typedef struct audio_stream audio_stream_t;
  8. typedef struct {
  9. esp_err_t (*start)(audio_stream_t *stream, uint16_t port);
  10. void (*stop)(audio_stream_t *stream);
  11. bool (*receive_packet)(audio_stream_t *stream);
  12. int (*decrypt_payload)(audio_stream_t *stream, const uint8_t *in,
  13. size_t in_len, uint8_t *out, size_t out_cap);
  14. uint16_t (*get_port)(audio_stream_t *stream);
  15. bool (*is_running)(audio_stream_t *stream);
  16. void (*destroy)(audio_stream_t *stream);
  17. } audio_stream_ops_t;
  18. struct audio_stream {
  19. const audio_stream_ops_t *ops;
  20. audio_stream_type_t type;
  21. bool running;
  22. audio_format_t format;
  23. audio_encrypt_t encrypt;
  24. void *ctx;
  25. };
  26. audio_stream_t *audio_stream_create_realtime(void);
  27. audio_stream_t *audio_stream_create_buffered(void);
  28. void audio_stream_destroy(audio_stream_t *stream);
  29. bool audio_stream_uses_buffer(audio_stream_type_t type);