Add preliminary output/encoder interface

- First, I redid the output interface for libobs.  I feel like it's
  going in a pretty good direction in terms of design.

  Right now, the design is so that outputs and encoders are separate.
  One or more outputs can connect to a specific encoder to receive its
  data, or the output can connect directly to raw data from libobs
  output itself, if the output doesn't want to use a designated encoder.
  Data is received via callbacks set when you connect to the encoder or
  raw output.  Multiple outputs can receive the data from a single
  encoder context if need be (such as for streaming to multiple channels
  at once, and/or recording with the same data).

  When an encoder is first connected to, it will connect to raw output,
  and start encoding.  Additional connections will receive that same
  data being encoded as well after that.  When the last encoder has
  disconnected, it will stop encoding.  If for some reason the encoder
  needs to stop, it will use the callback with NULL to signal that
  encoding has stopped.  Some of these things may be subject to change
  in the future, though it feels pretty good with this design so far.
  Will have to see how well it works out in practice versus theory.

- Second, Started adding preliminary RTMP/x264 output plugin code.

  To speed things up, I might just make a direct raw->FFmpeg output to
  create a quick output plugin that we can start using for testing all
  the subsystems.
This commit is contained in:
jp9000
2014-01-16 22:34:51 -07:00
parent 62c2b1d74e
commit 29b7d3621c
22 changed files with 894 additions and 47 deletions

View File

@@ -1,3 +1,4 @@
#include <string.h>
#include "obs-outputs.h"
static const char *outputs[] = {"rtmp_stream"};

View File

@@ -1,5 +1,5 @@
#pragma once
#include "util/c99defs.h"
#include <util/c99defs.h>
EXPORT const char *enum_outputs(size_t idx);

View File

@@ -1,6 +1,23 @@
/******************************************************************************
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/>.
******************************************************************************/
#include "obs-stream.h"
void *rtmp_stream_getname(const char *locale)
const char *rtmp_stream_getname(const char *locale)
{
/* TODO: locale stuff */
return "RTMP Stream";
@@ -8,21 +25,26 @@ void *rtmp_stream_getname(const char *locale)
void *rtmp_stream_create(const char *settings, obs_output_t output)
{
struct rtmp_stream *stream = bmalloc(sizeof(struct rtmp_stream));
memset(stream, 0, sizeof(struct rtmp_stream));
}
void *rtmp_stream_destroy(void *data)
void rtmp_stream_destroy(struct rtmp_stream *stream)
{
}
void *rtmp_stream_update(void *data, const char *settings)
void rtmp_stream_update(struct rtmp_stream *stream, const char *settings)
{
}
void rtmp_stream_start(void *data)
bool rtmp_stream_start(struct rtmp_stream *stream)
{
}
void rtmp_stream_stop(void *data)
void rtmp_stream_stop(struct rtmp_stream *stream)
{
}
bool rtmp_stream_active(struct rtmp_stream *stream)
{
}

View File

@@ -1,15 +1,39 @@
/******************************************************************************
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"
#include "obs.h"
#include <util/c99defs.h>
#include <obs.h>
struct rtmp_stream {
obs_output_t handler;
obs_output_t output;
obs_encoder_t video_encoder;
obs_encoder_t audio_encoder;
obs_service_t service;
bool active;
};
EXPORT void *rtmp_stream_getname(const char *locale);
EXPORT const char *rtmp_stream_getname(const char *locale);
EXPORT void *rtmp_stream_create(const char *settings, obs_output_t output);
EXPORT void *rtmp_stream_destroy(void *data);
EXPORT void *rtmp_stream_update(void *data, const char *settings);
EXPORT void rtmp_stream_start(void *data);
EXPORT void rtmp_stream_stop(void *data);
EXPORT void rtmp_stream_destroy(struct rtmp_stream *stream);
EXPORT void rtmp_stream_update(struct rtmp_stream *stream,
const char *settings);
EXPORT bool rtmp_stream_start(struct rtmp_stream *stream);
EXPORT void rtmp_stream_stop(struct rtmp_stream *stream);
EXPORT bool rtmp_stream_active(struct rtmp_stream *stream);

View File

@@ -0,0 +1,58 @@
/******************************************************************************
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/>.
******************************************************************************/
#include "obs-x264.h"
const char *obs_x264_getname(const char *locale)
{
/* TODO locale lookup */
return "x264 (Software)";
}
struct obs_x264 *obs_x264_create(const char *settings, obs_encoder_t encoder)
{
struct obs_x264 *data = bmalloc(sizeof(struct obs_x264));
}
void obs_x264_destroy(struct obs_x264 *data)
{
}
void obs_x264_update(struct obs_x264 *data, const char *settings)
{
}
void obs_x264_reset(struct obs_x264 *data)
{
}
int obs_x264_encode(struct obs_x264 *data, struct encoder_packet **packets)
{
}
int obs_x264_getheader(struct obs_x264 *data, struct encoder_packet **packets)
{
}
void obs_x264_setbitrate(struct obs_x264 *data, uint32_t bitrate,
uint32_t buffersize)
{
}
void obs_x264_request_keyframe(struct obs_x264 *data)
{
}

View File

@@ -0,0 +1,49 @@
/******************************************************************************
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>
#include <obs.h>
#include <x264.h>
struct obs_x264 {
obs_encoder_t encoder;
x264_param_t params;
x264_t *context;
x264_picture_t pic_out;
};
EXPORT const char *obs_x264_getname(const char *locale);
EXPORT struct obs_x264 *obs_x264_create(const char *settings,
obs_encoder_t encoder);
EXPORT void obs_x264_destroy(struct obs_x264 *data);
EXPORT void obs_x264_update(struct obs_x264 *data, const char *settings);
EXPORT void obs_x264_reset(struct obs_x264 *data);
EXPORT int obs_x264_encode(struct obs_x264 *data,
struct encoder_packet **packets);
EXPORT int obs_x264_getheader(struct obs_x264 *data,
struct encoder_packet **packets);
EXPORT void obs_x264_setbitrate(struct obs_x264 *data, uint32_t bitrate,
uint32_t buffersize);
EXPORT void obs_x264_request_keyframe(struct obs_x264 *data);