Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The original idea was to have a system that would have connecting media inputs and outputs, but at a certain point I realized that this was an unnecessary complexity for what we wanted to do. (Also, it reminded me of directshow filters, and I HATE directshow with a passion, and wouldn't wish it upon my greatest enemy) Now, audio/video outputs are connected to directly, with better callback handlers, and will eventually have the ability to automatically handle conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses them. Doing this will allow the video/audio i/o handlers to also prevent duplicate conversion, as well as make it easier/simple to use. My true goal for this is to make output and encoder plugins as simple to create as possible. I want to be able to be able to create an output plugin with almost no real hassle of having to worry about image conversions, media inputs/outputs, etc. A plugin developer shouldn't have to handle that sort of stuff when he/she doesn't really need to. Plugins will be able to simply create a callback via obs_video() and/or obs_audio(), and they will automatically receive the audio/video data in the formats requested via a simple callback, without needing to do almost anything else at all.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../util/c99defs.h"
|
||||
#include "media-io.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -63,16 +62,21 @@ struct audio_data {
|
||||
float volume;
|
||||
};
|
||||
|
||||
struct audio_info {
|
||||
struct audio_output_info {
|
||||
const char *name;
|
||||
|
||||
uint32_t samples_per_sec;
|
||||
enum audio_format format;
|
||||
enum speaker_layout speakers;
|
||||
|
||||
uint64_t buffer_ms;
|
||||
};
|
||||
|
||||
struct audio_info {
|
||||
uint32_t samples_per_sec;
|
||||
enum audio_format format;
|
||||
enum speaker_layout speakers;
|
||||
};
|
||||
|
||||
static inline uint32_t get_audio_channels(enum speaker_layout speakers)
|
||||
{
|
||||
switch (speakers) {
|
||||
@@ -117,13 +121,20 @@ static inline size_t get_audio_size(enum audio_format type,
|
||||
#define AUDIO_OUTPUT_INVALIDPARAM -1
|
||||
#define AUDIO_OUTPUT_FAIL -2
|
||||
|
||||
EXPORT int audio_output_open(audio_t *audio, media_t media,
|
||||
struct audio_info *info);
|
||||
EXPORT audio_line_t audio_output_createline(audio_t audio, const char *name);
|
||||
EXPORT size_t audio_output_blocksize(audio_t audio);
|
||||
EXPORT const struct audio_info *audio_output_getinfo(audio_t audio);
|
||||
EXPORT int audio_output_open(audio_t *audio, struct audio_output_info *info);
|
||||
EXPORT void audio_output_close(audio_t audio);
|
||||
|
||||
EXPORT void audio_output_connect(audio_t video, struct audio_info *format,
|
||||
void (*callback)(void *param, const struct audio_data *data),
|
||||
void *param);
|
||||
EXPORT void audio_output_disconnect(audio_t video,
|
||||
void (*callback)(void *param, const struct audio_data *data),
|
||||
void *param);
|
||||
|
||||
EXPORT size_t audio_output_blocksize(audio_t audio);
|
||||
EXPORT const struct audio_output_info *audio_output_getinfo(audio_t audio);
|
||||
|
||||
EXPORT audio_line_t audio_output_createline(audio_t audio, const char *name);
|
||||
EXPORT void audio_line_destroy(audio_line_t line);
|
||||
EXPORT void audio_line_output(audio_line_t line, const struct audio_data *data);
|
||||
|
||||
|
Reference in New Issue
Block a user