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:
jp9000
2014-01-14 01:58:47 -07:00
parent 2c0118b2d7
commit 62c2b1d74e
18 changed files with 317 additions and 422 deletions

View File

@@ -18,16 +18,12 @@
#pragma once
#include "../util/c99defs.h"
#include "media-io.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Base video output component. Use this to create an video output track
* for the media.
*/
/* Base video output component. Use this to create an video output track. */
struct video_output;
typedef struct video_output *video_t;
@@ -37,7 +33,7 @@ enum video_format {
/* planar 420 format */
VIDEO_FORMAT_I420, /* three-plane */
VIDEO_FORMAT_NV12, /* two-plane, lum and packed chroma */
VIDEO_FORMAT_NV12, /* two-plane, luma and packed chroma */
/* packed 422 formats */
VIDEO_FORMAT_YVYU,
@@ -54,33 +50,47 @@ enum video_format {
struct video_frame {
const void *data;
uint32_t row_size; /* for RGB/BGR formats and UYVX */
uint32_t row_size; /* for RGB/BGR formats and UYVX */
uint64_t timestamp;
};
struct video_info {
struct video_output_info {
const char *name;
enum video_format type;
uint32_t fps_num; /* numerator */
uint32_t fps_den; /* denominator */
uint32_t fps_num;
uint32_t fps_den;
uint32_t width;
uint32_t height;
};
struct video_info {
enum video_format type;
uint32_t width;
uint32_t height;
uint32_t row_size; /* if any */
};
#define VIDEO_OUTPUT_SUCCESS 0
#define VIDEO_OUTPUT_INVALIDPARAM -1
#define VIDEO_OUTPUT_FAIL -2
EXPORT int video_output_open(video_t *video, media_t media,
struct video_info *info);
EXPORT const struct video_info *video_output_getinfo(video_t video);
EXPORT int video_output_open(video_t *video, struct video_output_info *info);
EXPORT void video_output_close(video_t video);
EXPORT void video_output_connect(video_t video, struct video_info *format,
void (*callback)(void *param, struct video_frame *frame),
void *param);
EXPORT void video_output_disconnect(video_t video,
void (*callback)(void *param, struct video_frame *frame),
void *param);
EXPORT const struct video_output_info *video_output_getinfo(video_t video);
EXPORT void video_output_frame(video_t video, struct video_frame *frame);
EXPORT bool video_output_wait(video_t video);
EXPORT uint64_t video_getframetime(video_t video);
EXPORT uint64_t video_gettime(video_t video);
EXPORT void video_output_stop(video_t video);
EXPORT void video_output_close(video_t video);
#ifdef __cplusplus
}