Fix a number of MSVC warnings
Fixes a number of warnings with all modules
This commit is contained in:
parent
ffdecc34f4
commit
0d6204c8af
@ -8,8 +8,18 @@
|
||||
#include <util/windows/CoTaskMemPtr.hpp>
|
||||
#include <util/threading.h>
|
||||
#include <util/platform.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
#include <sphelper.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <obs.hpp>
|
||||
|
||||
#include <thread>
|
||||
|
@ -10,8 +10,18 @@
|
||||
#include <util/windows/WinHandle.hpp>
|
||||
#include <util/windows/ComPtr.hpp>
|
||||
#include <obs-module.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
#include <sphelper.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
20
deps/libff/libff/ff-util.c
vendored
20
deps/libff/libff/ff-util.c
vendored
@ -16,11 +16,21 @@
|
||||
|
||||
#include "ff-util.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4244)
|
||||
#pragma warning(disable : 4204)
|
||||
#endif
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavdevice/avdevice.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/log.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct ff_format_desc {
|
||||
@ -68,7 +78,7 @@ static bool get_codecs(const AVCodecDescriptor*** descs, unsigned int *size)
|
||||
unsigned int codec_count = 0;
|
||||
unsigned int i = 0;
|
||||
|
||||
while ((desc = avcodec_descriptor_next(desc)))
|
||||
while ((desc = avcodec_descriptor_next(desc)) != NULL)
|
||||
codec_count++;
|
||||
|
||||
codecs = av_calloc(codec_count, sizeof(AVCodecDescriptor *));
|
||||
@ -79,7 +89,7 @@ static bool get_codecs(const AVCodecDescriptor*** descs, unsigned int *size)
|
||||
return false;
|
||||
}
|
||||
|
||||
while ((desc = avcodec_descriptor_next(desc)))
|
||||
while ((desc = avcodec_descriptor_next(desc)) != NULL)
|
||||
codecs[i++] = desc;
|
||||
|
||||
*size = codec_count;
|
||||
@ -89,7 +99,7 @@ static bool get_codecs(const AVCodecDescriptor*** descs, unsigned int *size)
|
||||
|
||||
static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev)
|
||||
{
|
||||
while ((prev = av_codec_next(prev))) {
|
||||
while ((prev = av_codec_next(prev)) != NULL) {
|
||||
if (prev->id == id && av_codec_is_encoder(prev))
|
||||
return prev;
|
||||
}
|
||||
@ -156,7 +166,7 @@ static void get_codecs_for_id(const struct ff_format_desc *format_desc,
|
||||
enum AVCodecID id, bool ignore_compatability)
|
||||
{
|
||||
const AVCodec *codec = NULL;
|
||||
while ((codec = next_codec_for_id(id, codec)))
|
||||
while ((codec = next_codec_for_id(id, codec)) != NULL)
|
||||
add_codec_to_list(format_desc, first, current, codec->id,
|
||||
codec, ignore_compatability);
|
||||
}
|
||||
@ -277,7 +287,7 @@ const struct ff_format_desc *ff_format_supported()
|
||||
struct ff_format_desc *desc = NULL;
|
||||
struct ff_format_desc *current = NULL;
|
||||
|
||||
while ((output_format = av_oformat_next(output_format))) {
|
||||
while ((output_format = av_oformat_next(output_format)) != NULL) {
|
||||
struct ff_format_desc *d;
|
||||
if (is_output_device(output_format->priv_class))
|
||||
continue;
|
||||
|
2
deps/lzma/CMakeLists.txt
vendored
2
deps/lzma/CMakeLists.txt
vendored
@ -31,6 +31,8 @@ add_definitions(
|
||||
if(WIN32)
|
||||
if(MSVC)
|
||||
add_compile_options("$<$<CONFIG:RelWithDebInfo>:/MT>")
|
||||
add_compile_options("/wd4244")
|
||||
add_compile_options("/wd4267")
|
||||
endif()
|
||||
add_definitions(
|
||||
-Dinline=_inline
|
||||
|
3
deps/lzma/liblzma/api/lzma/index.h
vendored
3
deps/lzma/liblzma/api/lzma/index.h
vendored
@ -565,7 +565,8 @@ extern LZMA_API(lzma_bool) lzma_index_iter_locate(
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_cat(
|
||||
lzma_index *dest, lzma_index *src, lzma_allocator *allocator)
|
||||
lzma_index *restrict dest, lzma_index *restrict src,
|
||||
lzma_allocator *allocator)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
|
8
deps/lzma/liblzma/api/lzma/vli.h
vendored
8
deps/lzma/liblzma/api/lzma/vli.h
vendored
@ -113,7 +113,8 @@ typedef uint64_t lzma_vli;
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
uint8_t *restrict out, size_t *restrict out_pos,
|
||||
size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
@ -151,8 +152,9 @@ extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
|
||||
* - LZMA_BUF_ERROR: No input was provided.
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *restrict vli,
|
||||
size_t *vli_pos, const uint8_t *restrict in,
|
||||
size_t *restrict in_pos, size_t in_size)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
|
@ -1034,7 +1034,6 @@ void device_load_vertexshader(gs_device_t *device, gs_shader_t *vertshader)
|
||||
return;
|
||||
|
||||
gs_vertex_shader *vs = static_cast<gs_vertex_shader*>(vertshader);
|
||||
gs_vertex_buffer *curVB = device->curVertexBuffer;
|
||||
|
||||
if (vertshader) {
|
||||
if (vertshader->type != GS_SHADER_VERTEX) {
|
||||
|
@ -164,8 +164,19 @@ static bool ffmpeg_image_decode(struct ffmpeg_image *info, uint8_t *out,
|
||||
}
|
||||
|
||||
while (!got_frame) {
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
|
||||
ret = avcodec_send_packet(info->decoder_ctx, &packet);
|
||||
if (ret == 0)
|
||||
ret = avcodec_receive_frame(info->decoder_ctx, frame);
|
||||
|
||||
got_frame = (ret == 0);
|
||||
|
||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
||||
ret = 0;
|
||||
#else
|
||||
ret = avcodec_decode_video2(info->decoder_ctx, frame,
|
||||
&got_frame, &packet);
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
blog(LOG_WARNING, "Failed to decode frame for '%s': %s",
|
||||
info->file, av_err2str(ret));
|
||||
@ -176,7 +187,7 @@ static bool ffmpeg_image_decode(struct ffmpeg_image *info, uint8_t *out,
|
||||
success = ffmpeg_image_reformat_frame(info, frame, out, linesize);
|
||||
|
||||
fail:
|
||||
av_free_packet(&packet);
|
||||
av_packet_unref(&packet);
|
||||
av_frame_free(&frame);
|
||||
return success;
|
||||
}
|
||||
|
@ -92,7 +92,13 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = avcodec_copy_context(out_stream->codec, in_stream->codec);
|
||||
AVCodecParameters *par = avcodec_parameters_alloc();
|
||||
ret = avcodec_parameters_from_context(par, in_stream->codec);
|
||||
if (ret == 0)
|
||||
ret = avcodec_parameters_to_context(out_stream->codec,
|
||||
par);
|
||||
avcodec_parameters_free(&par);
|
||||
|
||||
if (ret < 0) {
|
||||
blog(LOG_ERROR, "media_remux: Failed to copy context");
|
||||
return false;
|
||||
@ -194,7 +200,7 @@ static inline int process_packets(media_remux_job_t job,
|
||||
job->ofmt_ctx->streams[pkt.stream_index]);
|
||||
|
||||
ret = av_interleaved_write_frame(job->ofmt_ctx, &pkt);
|
||||
av_free_packet(&pkt);
|
||||
av_packet_unref(&pkt);
|
||||
|
||||
if (ret < 0) {
|
||||
blog(LOG_ERROR, "media_remux: Error muxing packet: %s",
|
||||
|
@ -300,8 +300,19 @@ static bool do_encode(struct enc_encoder *enc,
|
||||
|
||||
enc->total_samples += enc->frame_size;
|
||||
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
|
||||
ret = avcodec_send_frame(enc->context, enc->aframe);
|
||||
if (ret == 0)
|
||||
ret = avcodec_receive_packet(enc->context, &avpacket);
|
||||
|
||||
got_packet = (ret == 0);
|
||||
|
||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
||||
ret = 0;
|
||||
#else
|
||||
ret = avcodec_encode_audio2(enc->context, &avpacket, enc->aframe,
|
||||
&got_packet);
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
warn("avcodec_encode_audio2 failed: %s", av_err2str(ret));
|
||||
return false;
|
||||
|
@ -42,7 +42,6 @@ struct nvenc_encoder {
|
||||
AVCodec *nvenc;
|
||||
AVCodecContext *context;
|
||||
|
||||
AVPicture dst_picture;
|
||||
AVFrame *vframe;
|
||||
|
||||
DARRAY(uint8_t) buffer;
|
||||
@ -108,16 +107,13 @@ static bool nvenc_init_codec(struct nvenc_encoder *enc)
|
||||
enc->vframe->colorspace = enc->context->colorspace;
|
||||
enc->vframe->color_range = enc->context->color_range;
|
||||
|
||||
ret = avpicture_alloc(&enc->dst_picture, enc->context->pix_fmt,
|
||||
enc->context->width, enc->context->height);
|
||||
ret = av_frame_get_buffer(enc->vframe, base_get_alignment());
|
||||
if (ret < 0) {
|
||||
warn("Failed to allocate dst_picture: %s", av_err2str(ret));
|
||||
warn("Failed to allocate vframe: %s", av_err2str(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
enc->initialized = true;
|
||||
|
||||
*((AVPicture*)enc->vframe) = enc->dst_picture;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -245,18 +241,23 @@ static void nvenc_destroy(void *data)
|
||||
int r_pkt = 1;
|
||||
|
||||
while (r_pkt) {
|
||||
if (avcodec_encode_video2(enc->context, &pkt, NULL,
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
|
||||
if (avcodec_receive_packet(enc->context, &pkt) < 0)
|
||||
break;
|
||||
#else
|
||||
if (avcodec_receive_packet(enc->context, &pkt, NULL,
|
||||
&r_pkt) < 0)
|
||||
break;
|
||||
#endif
|
||||
|
||||
if (r_pkt)
|
||||
av_free_packet(&pkt);
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
avcodec_close(enc->context);
|
||||
av_frame_unref(enc->vframe);
|
||||
av_frame_free(&enc->vframe);
|
||||
avpicture_free(&enc->dst_picture);
|
||||
da_free(enc->buffer);
|
||||
bfree(enc->header);
|
||||
bfree(enc->sei);
|
||||
@ -300,7 +301,7 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void copy_data(AVPicture *pic, const struct encoder_frame *frame,
|
||||
static inline void copy_data(AVFrame *pic, const struct encoder_frame *frame,
|
||||
int height, enum AVPixelFormat format)
|
||||
{
|
||||
int h_chroma_shift, v_chroma_shift;
|
||||
@ -336,11 +337,22 @@ static bool nvenc_encode(void *data, struct encoder_frame *frame,
|
||||
|
||||
av_init_packet(&av_pkt);
|
||||
|
||||
copy_data(&enc->dst_picture, frame, enc->height, enc->context->pix_fmt);
|
||||
copy_data(enc->vframe, frame, enc->height, enc->context->pix_fmt);
|
||||
|
||||
enc->vframe->pts = frame->pts;
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
|
||||
ret = avcodec_send_frame(enc->context, enc->vframe);
|
||||
if (ret == 0)
|
||||
ret = avcodec_receive_packet(enc->context, &av_pkt);
|
||||
|
||||
got_packet = (ret == 0);
|
||||
|
||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
||||
ret = 0;
|
||||
#else
|
||||
ret = avcodec_encode_video2(enc->context, &av_pkt, enc->vframe,
|
||||
&got_packet);
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
warn("nvenc_encode: Error encoding: %s", av_err2str(ret));
|
||||
return false;
|
||||
@ -374,7 +386,7 @@ static bool nvenc_encode(void *data, struct encoder_frame *frame,
|
||||
*received_packet = false;
|
||||
}
|
||||
|
||||
av_free_packet(&av_pkt);
|
||||
av_packet_unref(&av_pkt);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,6 @@ struct ffmpeg_data {
|
||||
struct SwsContext *swscale;
|
||||
|
||||
int64_t total_frames;
|
||||
AVPicture dst_picture;
|
||||
AVFrame *vframe;
|
||||
int frame_size;
|
||||
|
||||
@ -198,15 +197,13 @@ static bool open_video_codec(struct ffmpeg_data *data)
|
||||
data->vframe->colorspace = data->config.color_space;
|
||||
data->vframe->color_range = data->config.color_range;
|
||||
|
||||
ret = avpicture_alloc(&data->dst_picture, context->pix_fmt,
|
||||
context->width, context->height);
|
||||
ret = av_frame_get_buffer(data->vframe, base_get_alignment());
|
||||
if (ret < 0) {
|
||||
blog(LOG_WARNING, "Failed to allocate dst_picture: %s",
|
||||
blog(LOG_WARNING, "Failed to allocate vframe: %s",
|
||||
av_err2str(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
*((AVPicture*)data->vframe) = data->dst_picture;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -446,7 +443,7 @@ static inline bool open_output_file(struct ffmpeg_data *data)
|
||||
static void close_video(struct ffmpeg_data *data)
|
||||
{
|
||||
avcodec_close(data->video->codec);
|
||||
avpicture_free(&data->dst_picture);
|
||||
av_frame_unref(data->vframe);
|
||||
|
||||
// This format for some reason derefs video frame
|
||||
// too many times
|
||||
@ -654,7 +651,7 @@ static void ffmpeg_output_destroy(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void copy_data(AVPicture *pic, const struct video_data *frame,
|
||||
static inline void copy_data(AVFrame *pic, const struct video_data *frame,
|
||||
int height, enum AVPixelFormat format)
|
||||
{
|
||||
int h_chroma_shift, v_chroma_shift;
|
||||
@ -703,15 +700,15 @@ static void receive_video(void *param, struct video_data *frame)
|
||||
if (!!data->swscale)
|
||||
sws_scale(data->swscale, (const uint8_t *const *)frame->data,
|
||||
(const int*)frame->linesize,
|
||||
0, data->config.height, data->dst_picture.data,
|
||||
data->dst_picture.linesize);
|
||||
0, data->config.height, data->vframe->data,
|
||||
data->vframe->linesize);
|
||||
else
|
||||
copy_data(&data->dst_picture, frame, context->height, context->pix_fmt);
|
||||
copy_data(data->vframe, frame, context->height, context->pix_fmt);
|
||||
|
||||
if (data->output->flags) {
|
||||
packet.flags |= AV_PKT_FLAG_KEY;
|
||||
packet.stream_index = data->video->index;
|
||||
packet.data = data->dst_picture.data[0];
|
||||
packet.data = data->vframe->data[0];
|
||||
packet.size = sizeof(AVPicture);
|
||||
|
||||
pthread_mutex_lock(&output->write_mutex);
|
||||
@ -721,8 +718,19 @@ static void receive_video(void *param, struct video_data *frame)
|
||||
|
||||
} else {
|
||||
data->vframe->pts = data->total_frames;
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
|
||||
ret = avcodec_send_frame(context, data->vframe);
|
||||
if (ret == 0)
|
||||
ret = avcodec_receive_packet(context, &packet);
|
||||
|
||||
got_packet = (ret == 0);
|
||||
|
||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
||||
ret = 0;
|
||||
#else
|
||||
ret = avcodec_encode_video2(context, &packet, data->vframe,
|
||||
&got_packet);
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
blog(LOG_WARNING, "receive_video: Error encoding "
|
||||
"video: %s", av_err2str(ret));
|
||||
@ -780,8 +788,19 @@ static void encode_audio(struct ffmpeg_output *output,
|
||||
|
||||
data->total_samples += data->frame_size;
|
||||
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
|
||||
ret = avcodec_send_frame(context, data->aframe);
|
||||
if (ret == 0)
|
||||
ret = avcodec_receive_packet(context, &packet);
|
||||
|
||||
got_packet = (ret == 0);
|
||||
|
||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
||||
ret = 0;
|
||||
#else
|
||||
ret = avcodec_encode_audio2(context, &packet, data->aframe,
|
||||
&got_packet);
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
blog(LOG_WARNING, "encode_audio: Error encoding audio: %s",
|
||||
av_err2str(ret));
|
||||
|
@ -459,7 +459,7 @@ static void set_peak_bitrate(struct ftl_stream *stream)
|
||||
// will queue data on the client and start adding latency. If the internet
|
||||
// connection really can't handle the bitrate the user will see either lost frame
|
||||
// and recovered frame counts go up, which is reflect in the dropped_frames count.
|
||||
stream->peak_kbps = stream->params.peak_kbps = user_desired_bitrate * 1.2;
|
||||
stream->peak_kbps = stream->params.peak_kbps = user_desired_bitrate * 12 / 10;
|
||||
ftl_ingest_update_params(&stream->ftl_handle, &stream->params);
|
||||
}
|
||||
|
||||
@ -602,34 +602,6 @@ static int init_send(struct ftl_stream *stream)
|
||||
return OBS_OUTPUT_SUCCESS;
|
||||
}
|
||||
|
||||
static int lookup_ingest_ip(const char *ingest_location, char *ingest_ip)
|
||||
{
|
||||
struct hostent *remoteHost;
|
||||
struct in_addr addr;
|
||||
int retval = -1;
|
||||
ingest_ip[0] = '\0';
|
||||
|
||||
remoteHost = gethostbyname(ingest_location);
|
||||
|
||||
if (remoteHost && remoteHost->h_addrtype == AF_INET) {
|
||||
int i = 0;
|
||||
|
||||
while (remoteHost->h_addr_list[i] != 0) {
|
||||
addr.s_addr = *(u_long *)remoteHost->h_addr_list[i++];
|
||||
blog(LOG_INFO, "IP Address #%d of ingest is: %s",
|
||||
i, inet_ntoa(addr));
|
||||
|
||||
/*only use the first ip found*/
|
||||
if (strlen(ingest_ip) == 0) {
|
||||
strcpy(ingest_ip, inet_ntoa(addr));
|
||||
retval = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int try_connect(struct ftl_stream *stream)
|
||||
{
|
||||
ftl_status_t status_code;
|
||||
@ -888,7 +860,7 @@ static uint64_t ftl_stream_total_bytes_sent(void *data)
|
||||
static int ftl_stream_dropped_frames(void *data)
|
||||
{
|
||||
struct ftl_stream *stream = data;
|
||||
return stream->dropped_frames;
|
||||
return (int)stream->dropped_frames;
|
||||
}
|
||||
|
||||
static float ftl_stream_congestion(void *data)
|
||||
|
@ -15,6 +15,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
|
||||
#include "net-if.h"
|
||||
#include <util/platform.h>
|
||||
#include <util/dstr.h>
|
||||
|
@ -53,7 +53,7 @@ extern void twitch_ingests_refresh(int seconds);
|
||||
|
||||
static void refresh_callback(void *unused, calldata_t *cd)
|
||||
{
|
||||
int seconds = calldata_int(cd, "seconds");
|
||||
int seconds = (int)calldata_int(cd, "seconds");
|
||||
if (seconds <= 0)
|
||||
seconds = 3;
|
||||
if (seconds > 10)
|
||||
|
@ -124,14 +124,14 @@ static inline void copy_data(struct ffmpeg_decode *decode, uint8_t *data,
|
||||
memcpy(decode->packet_buffer, data, size);
|
||||
}
|
||||
|
||||
int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
|
||||
bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
|
||||
uint8_t *data, size_t size,
|
||||
struct obs_source_audio *audio,
|
||||
bool *got_output)
|
||||
{
|
||||
AVPacket packet = {0};
|
||||
int got_frame = false;
|
||||
int len;
|
||||
int ret = 0;
|
||||
|
||||
*got_output = false;
|
||||
|
||||
@ -144,32 +144,42 @@ int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
|
||||
if (!decode->frame) {
|
||||
decode->frame = av_frame_alloc();
|
||||
if (!decode->frame)
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
len = avcodec_decode_audio4(decode->decoder, decode->frame, &got_frame,
|
||||
&packet);
|
||||
if (data && size)
|
||||
ret = avcodec_send_packet(decode->decoder, &packet);
|
||||
if (ret == 0)
|
||||
ret = avcodec_receive_frame(decode->decoder, decode->frame);
|
||||
|
||||
if (len <= 0 || !got_frame)
|
||||
return len;
|
||||
got_frame = (ret == 0);
|
||||
|
||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
||||
ret = 0;
|
||||
|
||||
if (ret < 0)
|
||||
return false;
|
||||
else if (ret == 0 || !got_frame)
|
||||
return true;
|
||||
|
||||
for (size_t i = 0; i < MAX_AV_PLANES; i++)
|
||||
audio->data[i] = decode->frame->data[i];
|
||||
|
||||
audio->samples_per_sec = decode->frame->sample_rate;
|
||||
audio->speakers = convert_speaker_layout(decode->decoder->channels);
|
||||
audio->format = convert_sample_format(decode->frame->format);
|
||||
audio->speakers =
|
||||
convert_speaker_layout((uint8_t)decode->decoder->channels);
|
||||
|
||||
audio->frames = decode->frame->nb_samples;
|
||||
|
||||
if (audio->format == AUDIO_FORMAT_UNKNOWN)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
*got_output = true;
|
||||
return len;
|
||||
return true;
|
||||
}
|
||||
|
||||
int ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
uint8_t *data, size_t size, long long *ts,
|
||||
struct obs_source_frame *frame,
|
||||
bool *got_output)
|
||||
@ -177,7 +187,7 @@ int ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
AVPacket packet = {0};
|
||||
int got_frame = false;
|
||||
enum video_format new_format;
|
||||
int len;
|
||||
int ret;
|
||||
|
||||
*got_output = false;
|
||||
|
||||
@ -195,14 +205,22 @@ int ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
if (!decode->frame) {
|
||||
decode->frame = av_frame_alloc();
|
||||
if (!decode->frame)
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
len = avcodec_decode_video2(decode->decoder, decode->frame, &got_frame,
|
||||
&packet);
|
||||
ret = avcodec_send_packet(decode->decoder, &packet);
|
||||
if (ret == 0)
|
||||
ret = avcodec_receive_frame(decode->decoder, decode->frame);
|
||||
|
||||
if (len <= 0 || !got_frame)
|
||||
return len;
|
||||
got_frame = (ret == 0);
|
||||
|
||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
||||
ret = 0;
|
||||
|
||||
if (ret < 0)
|
||||
return false;
|
||||
else if (ret == 0 || !got_frame)
|
||||
return true;
|
||||
|
||||
for (size_t i = 0; i < MAX_AV_PLANES; i++) {
|
||||
frame->data[i] = decode->frame->data[i];
|
||||
@ -228,7 +246,7 @@ int ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
blog(LOG_ERROR, "Failed to get video format "
|
||||
"parameters for video format %u",
|
||||
VIDEO_CS_601);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,8 +257,8 @@ int ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
frame->flip = false;
|
||||
|
||||
if (frame->format == VIDEO_FORMAT_NONE)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
*got_output = true;
|
||||
return len;
|
||||
return true;
|
||||
}
|
||||
|
@ -49,12 +49,12 @@ struct ffmpeg_decode {
|
||||
extern int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id);
|
||||
extern void ffmpeg_decode_free(struct ffmpeg_decode *decode);
|
||||
|
||||
extern int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
|
||||
extern bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
|
||||
uint8_t *data, size_t size,
|
||||
struct obs_source_audio *audio,
|
||||
bool *got_output);
|
||||
|
||||
extern int ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
extern bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
uint8_t *data, size_t size, long long *ts,
|
||||
struct obs_source_frame *frame,
|
||||
bool *got_output);
|
||||
|
@ -433,9 +433,9 @@ void DShowInput::OnEncodedVideoData(enum AVCodecID id,
|
||||
}
|
||||
|
||||
bool got_output;
|
||||
int len = ffmpeg_decode_video(video_decoder, data, size, &ts,
|
||||
bool success = ffmpeg_decode_video(video_decoder, data, size, &ts,
|
||||
&frame, &got_output);
|
||||
if (len < 0) {
|
||||
if (!success) {
|
||||
blog(LOG_WARNING, "Error decoding video");
|
||||
return;
|
||||
}
|
||||
@ -532,11 +532,11 @@ void DShowInput::OnEncodedAudioData(enum AVCodecID id,
|
||||
}
|
||||
}
|
||||
|
||||
bool got_output = false;
|
||||
do {
|
||||
bool got_output;
|
||||
int len = ffmpeg_decode_audio(audio_decoder, data, size,
|
||||
bool success = ffmpeg_decode_audio(audio_decoder, data, size,
|
||||
&audio, &got_output);
|
||||
if (len < 0) {
|
||||
if (!success) {
|
||||
blog(LOG_WARNING, "Error decoding audio");
|
||||
return;
|
||||
}
|
||||
@ -553,9 +553,9 @@ void DShowInput::OnEncodedAudioData(enum AVCodecID id,
|
||||
|
||||
ts += int64_t(audio_decoder->frame->nb_samples) * 10000000LL /
|
||||
int64_t(audio_decoder->frame->sample_rate);
|
||||
size -= (size_t)len;
|
||||
data += len;
|
||||
} while (size > 0);
|
||||
size = 0;
|
||||
data = nullptr;
|
||||
} while (got_output);
|
||||
}
|
||||
|
||||
void DShowInput::OnAudioData(const AudioConfig &config,
|
||||
@ -575,7 +575,7 @@ void DShowInput::OnAudioData(const AudioConfig &config,
|
||||
return;
|
||||
}
|
||||
|
||||
audio.speakers = convert_speaker_layout(config.channels);
|
||||
audio.speakers = convert_speaker_layout((uint8_t)config.channels);
|
||||
audio.format = ConvertAudioFormat(config.format);
|
||||
audio.samples_per_sec = (uint32_t)config.sampleRate;
|
||||
audio.data[0] = data;
|
||||
@ -759,7 +759,6 @@ static inline bool IsEncoded(const VideoConfig &config)
|
||||
inline void DShowInput::SetupBuffering(obs_data_t *settings)
|
||||
{
|
||||
BufferingType bufType;
|
||||
uint32_t flags = obs_source_get_flags(source);
|
||||
bool useBuffering;
|
||||
|
||||
bufType = (BufferingType)obs_data_get_int(settings, BUFFERING_VAL);
|
||||
|
@ -36,7 +36,7 @@ SegServerImpl::SegServerImpl()
|
||||
m_sharedBuffer = NULL;
|
||||
}
|
||||
|
||||
SegServerImpl::SegServerImpl(SegServerImpl const& src) {};
|
||||
SegServerImpl::SegServerImpl(SegServerImpl const&) {};
|
||||
SegServerImpl::~SegServerImpl()
|
||||
{
|
||||
if (m_server)
|
||||
@ -46,7 +46,7 @@ SegServerImpl::~SegServerImpl()
|
||||
}
|
||||
instance = nullptr;
|
||||
};
|
||||
SegServerImpl& SegServerImpl::operator=(const SegServerImpl & src) { return *this; };
|
||||
SegServerImpl& SegServerImpl::operator=(const SegServerImpl &) { return *this; };
|
||||
|
||||
SegServer* SegServerImpl::CreateServer()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user