forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopus_encoder.h
More file actions
49 lines (40 loc) · 1.08 KB
/
Copy pathopus_encoder.h
File metadata and controls
49 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef OPUS_ENCODER_H
#define OPUS_ENCODER_H
#include <Arduino.h>
#include <stdint.h>
// Callback type for encoded audio data
typedef void (*opus_encoded_handler)(uint8_t *data, size_t len);
/**
* @brief Initialize the Opus encoder
* @return true if successful
*/
bool opus_encoder_init();
/**
* @brief Encode PCM audio samples to Opus
* @param pcm_data Input PCM samples (16-bit signed)
* @param samples Number of samples
* @return Number of encoded bytes, or -1 on error
*/
int opus_encode_frame(int16_t *pcm_data, size_t samples);
/**
* @brief Set callback for encoded data
* @param callback Function to call when encoded data is ready
*/
void opus_set_callback(opus_encoded_handler callback);
/**
* @brief Process queued PCM data (call from main loop)
*/
void opus_process();
/**
* @brief Feed PCM data to encoder
* @param data PCM samples
* @param samples Number of samples
* @return 0 on success
*/
int opus_receive_pcm(int16_t *data, size_t samples);
/**
* @brief Get the codec ID
* @return Codec ID (20 = Opus)
*/
uint8_t opus_get_codec_id();
#endif // OPUS_ENCODER_H