mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-06-25 08:09:53 -04:00
Frontend plugins should not require being placed in the frontend directory to be built successfully. Indeed they should only depend on libobs and the obs-frontend-api and thus their source tree should be able to exist anywhere (even standalone) and the plugin should still compile successfully (just like any 3rd party plugin). Thus moving those plugins into the main plugin directory ensures that they don't require on any "special sauce" within the source tree to compile.
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <media-io/audio-resampler.h>
|
|
#include <obs-module.h>
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
class resampler_obj {
|
|
audio_resampler_t *resampler = nullptr;
|
|
|
|
public:
|
|
inline ~resampler_obj() { audio_resampler_destroy(resampler); }
|
|
|
|
inline bool reset(const resample_info &dst, const resample_info &src)
|
|
{
|
|
audio_resampler_destroy(resampler);
|
|
resampler = audio_resampler_create(&dst, &src);
|
|
return !!resampler;
|
|
}
|
|
|
|
inline operator audio_resampler_t *() { return resampler; }
|
|
};
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
typedef std::function<void(const std::string &)> captions_cb;
|
|
|
|
#define CAPTIONS_ERROR_GENERIC_FAIL std::string(obs_module_text("Captions.Error.GenericFail"))
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
class captions_handler {
|
|
captions_cb cb;
|
|
resampler_obj resampler;
|
|
|
|
protected:
|
|
inline void callback(const std::string &text) { cb(text); }
|
|
|
|
virtual void pcm_data(const void *data, size_t frames) = 0;
|
|
|
|
/* always resamples to 1 channel */
|
|
bool reset_resampler(enum audio_format format, uint32_t sample_rate);
|
|
|
|
public:
|
|
/* throw std::string for errors shown to users */
|
|
captions_handler(captions_cb callback, enum audio_format format, uint32_t sample_rate);
|
|
virtual ~captions_handler() {}
|
|
|
|
void push_audio(const audio_data *audio);
|
|
};
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
struct captions_handler_info {
|
|
std::string (*name)(void);
|
|
captions_handler *(*create)(captions_cb cb, const std::string &lang);
|
|
};
|