Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FFmpeg to v4.0 #2473

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Library/TeamTalkLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set (CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
set (CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
message(WARNING "No deployment target specified. Defaulting to ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()

Expand All @@ -59,7 +59,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "iOS")

if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set (CMAKE_OSX_DEPLOYMENT_TARGET 7.0)
set (CMAKE_OSX_DEPLOYMENT_TARGET 8.0)
message(WARNING "No deployment target specified. Defaulting to ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
list (APPEND COMPILE_FLAGS -fembed-bitcode)
Expand Down
2 changes: 1 addition & 1 deletion Library/TeamTalkLib/avstream/AVFCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace vidcap {

class AVFCapture : public FFMpeg3Capture
class AVFCapture : public FFmpegCapture
{
protected:
ffmpegvideoinput_t createStreamer(const VidCapDevice& viddevice,
Expand Down
2 changes: 1 addition & 1 deletion Library/TeamTalkLib/avstream/AVFVideoInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool AVFVideoInput::SetupInput(AVInputFormat *iformat,
av_dict_set(&options, "pixel_format", "0rgb", 0);
av_dict_set_int(&options, "video_device_index", atoi(m_dev.deviceid.c_str()), 0);

return FFMpegVideoInput::SetupInput(iformat, options, fmt_ctx,
return FFmpegVideoInput::SetupInput(iformat, options, fmt_ctx,
aud_dec_ctx, vid_dec_ctx,
audio_stream_index,
video_stream_index);
Expand Down
8 changes: 4 additions & 4 deletions Library/TeamTalkLib/avstream/AVFVideoInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
*
*/

#include "FFMpeg3Capture.h"
#include "FFmpegCapture.h"

namespace vidcap {

class AVFVideoInput : public FFMpegVideoInput
class AVFVideoInput : public FFmpegVideoInput
{
public:
AVFVideoInput(const VidCapDevice& viddevice,
const media::VideoFormat& fmt)
: FFMpegVideoInput(viddevice, fmt) {
: FFmpegVideoInput(viddevice, fmt) {
}

// FFMpegStreamer override
// FFmpegStreamer override
bool SetupInput(struct AVInputFormat *iformat,
struct AVDictionary *options,
struct AVFormatContext*& fmt_ctx,
Expand Down
2 changes: 1 addition & 1 deletion Library/TeamTalkLib/avstream/AudioResampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#if defined(ENABLE_DMORESAMPLER)
#include "DMOResampler.h"
#elif defined(ENABLE_FFMPEG3)
#include "FFMpeg3Resampler.h"
#include "FFmpegResampler.h"
#endif

#include <myace/MyACE.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

#include "FFMpeg3Capture.h"
#include "FFmpegCapture.h"

#include <memory>
#include <sstream>
Expand All @@ -30,23 +30,23 @@
using namespace std::placeholders;
using namespace vidcap;

FFMpegVideoInput::FFMpegVideoInput(const VidCapDevice& viddevice,
FFmpegVideoInput::FFmpegVideoInput(const VidCapDevice& viddevice,
const media::VideoFormat& fmt)
: FFMpegStreamer(viddevice.deviceid, MediaStreamOutput(fmt)), m_dev(viddevice), m_vidfmt(fmt)
: FFmpegStreamer(viddevice.deviceid, MediaStreamOutput(fmt)), m_dev(viddevice), m_vidfmt(fmt)
{
}


FFMpeg3Capture::FFMpeg3Capture()
FFmpegCapture::FFmpegCapture()
{
InitAVConv();
}

FFMpeg3Capture::~FFMpeg3Capture()
FFmpegCapture::~FFmpegCapture()
{
}

bool FFMpeg3Capture::InitVideoCapture(const ACE_TString& deviceid,
bool FFmpegCapture::InitVideoCapture(const ACE_TString& deviceid,
const media::VideoFormat& vidfmt)
{
vidcap_devices_t devs = GetDevices();
Expand All @@ -60,9 +60,9 @@ bool FFMpeg3Capture::InitVideoCapture(const ACE_TString& deviceid,

ffmpegvideoinput_t streamer = createStreamer(dev, vidfmt);
assert(streamer.get());
streamer->RegisterVideoCallback(std::bind(&FFMpeg3Capture::MediaStreamVideoCallback,
streamer->RegisterVideoCallback(std::bind(&FFmpegCapture::MediaStreamVideoCallback,
this, _1, _2), true);
streamer->RegisterStatusCallback(std::bind(&FFMpeg3Capture::MediaStreamStatusCallback,
streamer->RegisterStatusCallback(std::bind(&FFmpegCapture::MediaStreamStatusCallback,
this, _1, _2), true);
if (!streamer->Open())
return false;
Expand All @@ -72,7 +72,7 @@ bool FFMpeg3Capture::InitVideoCapture(const ACE_TString& deviceid,
return true;
}

bool FFMpeg3Capture::StartVideoCapture()
bool FFmpegCapture::StartVideoCapture()
{
if (!m_videoinput)
return false;
Expand All @@ -86,20 +86,20 @@ bool FFMpeg3Capture::StartVideoCapture()
return true;
}

void FFMpeg3Capture::StopVideoCapture()
void FFmpegCapture::StopVideoCapture()
{
m_videoinput.reset();
m_callback = {};
}

media::VideoFormat FFMpeg3Capture::GetVideoCaptureFormat()
media::VideoFormat FFmpegCapture::GetVideoCaptureFormat()
{
if (m_videoinput)
return m_videoinput->GetVideoFormat();
return media::VideoFormat();
}

bool FFMpeg3Capture::RegisterVideoFormat(VideoCaptureCallback callback, media::FourCC fcc)
bool FFmpegCapture::RegisterVideoFormat(VideoCaptureCallback callback, media::FourCC fcc)
{
if (m_videoinput && m_videoinput->GetVideoFormat().fourcc == fcc)
{
Expand All @@ -109,15 +109,15 @@ bool FFMpeg3Capture::RegisterVideoFormat(VideoCaptureCallback callback, media::F
return false;
}

void FFMpeg3Capture::UnregisterVideoFormat(media::FourCC fcc)
void FFmpegCapture::UnregisterVideoFormat(media::FourCC fcc)
{
if (m_videoinput && m_videoinput->GetVideoFormat().fourcc == fcc)
{
m_callback = {};
}
}

bool FFMpeg3Capture::MediaStreamVideoCallback(media::VideoFrame& video_frame,
bool FFmpegCapture::MediaStreamVideoCallback(media::VideoFrame& video_frame,
ACE_Message_Block* mb_video)
{
assert(m_videoinput.get());
Expand All @@ -128,7 +128,7 @@ bool FFMpeg3Capture::MediaStreamVideoCallback(media::VideoFrame& video_frame,
return false;
}

void FFMpeg3Capture::MediaStreamStatusCallback(const MediaFileProp& /*mfp*/,
void FFmpegCapture::MediaStreamStatusCallback(const MediaFileProp& /*mfp*/,
MediaStreamStatus /*status*/)
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@
#define FFMPEG3CAPTURE_H

#include "VideoCapture.h"
#include "FFMpeg3Streamer.h"
#include "FFmpegStreamer.h"
#include <myace/MyACE.h>

#include <map>

namespace vidcap {

class FFMpegVideoInput : public FFMpegStreamer
class FFmpegVideoInput : public FFmpegStreamer
{
protected:
VidCapDevice m_dev;
media::VideoFormat m_vidfmt;

public:
FFMpegVideoInput(const VidCapDevice& viddevice,
FFmpegVideoInput(const VidCapDevice& viddevice,
const media::VideoFormat& fmt);
virtual media::VideoFormat GetVideoFormat() = 0;

bool IsSystemTime() const override { return true; }
};

typedef std::unique_ptr<FFMpegVideoInput> ffmpegvideoinput_t;
typedef std::unique_ptr<FFmpegVideoInput> ffmpegvideoinput_t;

class FFMpeg3Capture : public VideoCapture
class FFmpegCapture : public VideoCapture
{
protected:
virtual ffmpegvideoinput_t createStreamer(const VidCapDevice& viddevice,
Expand All @@ -57,8 +57,8 @@ namespace vidcap {
VideoCaptureCallback m_callback;

public:
FFMpeg3Capture();
virtual ~FFMpeg3Capture();
FFmpegCapture();
virtual ~FFmpegCapture();

// VideoCapture interface
bool InitVideoCapture(const ACE_TString& deviceid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*
*/

#include "FFMpeg3Resampler.h"
#include "FFmpegResampler.h"
#include <assert.h>

#include "FFMpeg3Streamer.h" // need InitAVConv()
#include "FFmpegStreamer.h" // need InitAVConv()

extern "C" {
#include <libswresample/swresample.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

#include "FFMpeg3Streamer.h"
#include "FFmpegStreamer.h"

#include <inttypes.h>
#include <myace/MyACE.h>
Expand All @@ -33,13 +33,13 @@
#include <mach/mach_time.h>
#endif

// FFMpeg type collides with AVFoundation, so keep in cpp file
// FFmpeg type collides with AVFoundation, so keep in cpp file
extern "C" {
#include <libavutil/rational.h>
#include <libavcodec/avcodec.h>
#include <libavdevice/avdevice.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfiltergraph.h>
#include <libavfilter/avfilter.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include <libavutil/opt.h>
Expand Down Expand Up @@ -86,13 +86,13 @@ bool OpenInput(const ACE_TString& filename,

if (avformat_open_input(&fmt_ctx, filename.c_str(), iformat, &options) < 0)
{
MYTRACE(ACE_TEXT("FFMpeg opened %s\n"), filename.c_str());
MYTRACE(ACE_TEXT("FFmpeg opened %s\n"), filename.c_str());
goto cleanup;
}

if (avformat_find_stream_info(fmt_ctx, NULL) < 0)
{
MYTRACE(ACE_TEXT("FFMpeg found stream info\n"));
MYTRACE(ACE_TEXT("FFmpeg found stream info\n"));
goto cleanup;
}

Expand Down Expand Up @@ -215,19 +215,19 @@ bool GetAVMediaFileProp(const ACE_TString& filename, MediaFileProp& out_prop)
}


FFMpegStreamer::FFMpegStreamer(const ACE_TString& filename, const MediaStreamOutput& out_prop)
FFmpegStreamer::FFmpegStreamer(const ACE_TString& filename, const MediaStreamOutput& out_prop)
: MediaFileStreamer(filename, out_prop)
{
InitAVConv();
}

FFMpegStreamer::~FFMpegStreamer()
FFmpegStreamer::~FFmpegStreamer()
{
Close();
MYTRACE(ACE_TEXT("~FFMpegStreamer()\n"));
MYTRACE(ACE_TEXT("~FFmpegStreamer()\n"));
}

bool FFMpegStreamer::SetupInput(AVInputFormat *iformat,
bool FFmpegStreamer::SetupInput(AVInputFormat *iformat,
AVDictionary *options,
AVFormatContext*& fmt_ctx,
AVCodecContext*& aud_dec_ctx,
Expand All @@ -240,7 +240,7 @@ bool FFMpegStreamer::SetupInput(AVInputFormat *iformat,
}


void FFMpegStreamer::Run()
void FFmpegStreamer::Run()
{
AVFormatContext *fmt_ctx = NULL;
int audio_stream_index = -1, video_stream_index = -1;
Expand Down Expand Up @@ -328,7 +328,7 @@ void FFMpegStreamer::Run()
InitBuffers();

//wait for start signal
MYTRACE(ACE_TEXT("FFMpeg3 waiting to start streaming: %s\n"), m_media_in.filename.c_str());
MYTRACE(ACE_TEXT("FFmpeg waiting to start streaming: %s\n"), m_media_in.filename.c_str());
m_run.get(start);
if(!start)
goto fail;
Expand Down Expand Up @@ -528,7 +528,7 @@ void FFMpegStreamer::Run()
if (m_statuscallback && !m_stop)
m_statuscallback(m_media_in, MEDIASTREAM_FINISHED);

MYTRACE(ACE_TEXT("FFMpeg3 finished streaming: %s\n"), m_media_in.filename.c_str());
MYTRACE(ACE_TEXT("FFmpeg finished streaming: %s\n"), m_media_in.filename.c_str());
goto end;

fail:
Expand All @@ -555,10 +555,10 @@ void FFMpegStreamer::Run()
av_frame_free(&aud_frame);
av_frame_free(&vid_frame);
av_frame_free(&filt_frame);
MYTRACE(ACE_TEXT("Quitting FFMpegStreamer thread\n"));
MYTRACE(ACE_TEXT("Quitting FFmpegStreamer thread\n"));
}

int64_t FFMpegStreamer::ProcessAudioBuffer(AVFilterContext* aud_buffersink_ctx,
int64_t FFmpegStreamer::ProcessAudioBuffer(AVFilterContext* aud_buffersink_ctx,
AVFrame* filt_frame,
AVStream* aud_stream,
ACE_UINT32 start_time,
Expand Down Expand Up @@ -606,7 +606,7 @@ int64_t FFMpegStreamer::ProcessAudioBuffer(AVFilterContext* aud_buffersink_ctx,
return frame_timestamp;
}

int64_t FFMpegStreamer::ProcessVideoBuffer(AVFilterContext* vid_buffersink_ctx,
int64_t FFmpegStreamer::ProcessVideoBuffer(AVFilterContext* vid_buffersink_ctx,
AVFrame* filt_frame,
AVStream* vid_stream,
ACE_UINT32 start_time,
Expand Down Expand Up @@ -694,8 +694,8 @@ AVFilterGraph* createAudioFilterGraph(AVFormatContext *fmt_ctx,
//init filters
AVFilterGraph *filter_graph = NULL;

AVFilter *abuffersrc = avfilter_get_by_name("abuffer");
AVFilter *abuffersink = avfilter_get_by_name("abuffersink");
const AVFilter *abuffersrc = avfilter_get_by_name("abuffer");
const AVFilter *abuffersink = avfilter_get_by_name("abuffersink");
AVFilterInOut *outputs = avfilter_inout_alloc(); //TODO: Free??
AVFilterInOut *inputs = avfilter_inout_alloc(); //TODO: Free??
const enum AVSampleFormat out_sample_fmts[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE };
Expand Down Expand Up @@ -812,8 +812,8 @@ AVFilterGraph* createVideoFilterGraph(AVFormatContext *fmt_ctx,
AVFilterGraph *filter_graph;
char args[512];
int ret;
AVFilter *buffersrc = avfilter_get_by_name("buffer");
AVFilter *buffersink = avfilter_get_by_name("buffersink");
const AVFilter *buffersrc = avfilter_get_by_name("buffer");
const AVFilter *buffersink = avfilter_get_by_name("buffersink");
AVFilterInOut *outputs = avfilter_inout_alloc();
AVFilterInOut *inputs = avfilter_inout_alloc();
const enum AVPixelFormat pix_fmts[] = { output_pixfmt, AV_PIX_FMT_NONE };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ void InitAVConv();

bool GetAVMediaFileProp(const ACE_TString& filename, MediaFileProp& out_prop);

class FFMpegStreamer : public MediaFileStreamer
class FFmpegStreamer : public MediaFileStreamer
{
public:
FFMpegStreamer(const ACE_TString& filename, const MediaStreamOutput& out_prop);
virtual ~FFMpegStreamer();
FFmpegStreamer(const ACE_TString& filename, const MediaStreamOutput& out_prop);
virtual ~FFmpegStreamer();

virtual bool IsSystemTime() const { return false; }

Expand Down
Loading
Loading