- Fill in the rest of the FFmpeg test output code for testing so it actually properly outputs data. - Improve the main video subsystem to be a bit more optimal and automatically output I420 or NV12 if needed. - Fix audio subsystem insertation and byte calculation. Now it will seamlessly insert new audio data in to the audio stream based upon its timestamp value. (Be extremely cautious when using floating point calculations for important things like this, and always round your values and check your values) - Use 32 byte alignment in case of future optimizations and export a function to get the current alignment. - Make os_sleepto_ns return true if slept, false if the time has already been passed before the call. - Fix sinewave output so that it actually properly calculates a middle C sinewave. - Change the use of row_bytes to linesize (also makes it a bit more consistent with FFmpeg's naming as well)
117 lines
3.1 KiB
C
117 lines
3.1 KiB
C
/******************************************************************************
|
|
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
******************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
#include "../util/c99defs.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Base video output component. Use this to create an video output track. */
|
|
|
|
#define MAX_VIDEO_PLANES 8
|
|
|
|
struct video_output;
|
|
typedef struct video_output *video_t;
|
|
|
|
enum video_format {
|
|
VIDEO_FORMAT_NONE,
|
|
|
|
/* planar 420 format */
|
|
VIDEO_FORMAT_I420, /* three-plane */
|
|
VIDEO_FORMAT_NV12, /* two-plane, luma and packed chroma */
|
|
|
|
/* packed 422 formats */
|
|
VIDEO_FORMAT_YVYU,
|
|
VIDEO_FORMAT_YUY2, /* YUYV */
|
|
VIDEO_FORMAT_UYVY,
|
|
|
|
/* packed uncompressed formats */
|
|
VIDEO_FORMAT_RGBA,
|
|
VIDEO_FORMAT_BGRA,
|
|
VIDEO_FORMAT_BGRX,
|
|
};
|
|
|
|
struct video_frame {
|
|
const uint8_t *data[MAX_VIDEO_PLANES];
|
|
uint32_t linesize[MAX_VIDEO_PLANES];
|
|
uint64_t timestamp;
|
|
};
|
|
|
|
struct video_output_info {
|
|
const char *name;
|
|
|
|
enum video_format format;
|
|
uint32_t fps_num;
|
|
uint32_t fps_den;
|
|
uint32_t width;
|
|
uint32_t height;
|
|
};
|
|
|
|
struct video_convert_info {
|
|
enum video_format format;
|
|
uint32_t width;
|
|
uint32_t height;
|
|
};
|
|
|
|
static inline bool format_is_yuv(enum video_format format)
|
|
{
|
|
switch (format) {
|
|
case VIDEO_FORMAT_I420:
|
|
case VIDEO_FORMAT_NV12:
|
|
case VIDEO_FORMAT_YVYU:
|
|
case VIDEO_FORMAT_YUY2:
|
|
case VIDEO_FORMAT_UYVY:
|
|
return true;
|
|
case VIDEO_FORMAT_NONE:
|
|
case VIDEO_FORMAT_RGBA:
|
|
case VIDEO_FORMAT_BGRA:
|
|
case VIDEO_FORMAT_BGRX:
|
|
return false;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
#define VIDEO_OUTPUT_SUCCESS 0
|
|
#define VIDEO_OUTPUT_INVALIDPARAM -1
|
|
#define VIDEO_OUTPUT_FAIL -2
|
|
|
|
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_convert_info *conversion,
|
|
void (*callback)(void *param, const struct video_frame *frame),
|
|
void *param);
|
|
EXPORT void video_output_disconnect(video_t video,
|
|
void (*callback)(void *param, const 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);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|