2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG.
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
22 #include "consumer/ffmpeg_consumer.h"
\r
23 #include "producer/ffmpeg_producer.h"
\r
25 #include <core/consumer/frame_consumer.h>
\r
26 #include <core/producer/frame_producer.h>
\r
28 #include <tbb/mutex.h>
\r
30 #if defined(_MSC_VER)
\r
31 #pragma warning (disable : 4244)
\r
36 #define __STDC_CONSTANT_MACROS
\r
37 #define __STDC_LIMIT_MACROS
\r
38 #include <libavformat/avformat.h>
\r
39 #include <libswscale/swscale.h>
\r
40 #include <libavutil/avutil.h>
\r
41 #include <libavfilter/avfilter.h>
\r
46 int ffmpeg_lock_callback(void **mutex, enum AVLockOp op)
\r
51 auto my_mutex = reinterpret_cast<tbb::mutex*>(*mutex);
\r
55 case AV_LOCK_CREATE:
\r
57 *mutex = new tbb::mutex();
\r
60 case AV_LOCK_OBTAIN:
\r
66 case AV_LOCK_RELEASE:
\r
69 my_mutex->unlock();
\r
72 case AV_LOCK_DESTROY:
\r
84 avfilter_register_all();
\r
87 avcodec_register_all();
\r
88 av_lockmgr_register(ffmpeg_lock_callback);
\r
90 core::register_consumer_factory([](const std::vector<std::wstring>& params){return create_ffmpeg_consumer(params);});
\r
91 core::register_producer_factory(create_ffmpeg_producer);
\r
94 void uninit_ffmpeg()
\r
97 av_lockmgr_register(nullptr);
\r
100 std::wstring make_version(unsigned int ver)
\r
102 std::wstringstream str;
\r
103 str << ((ver >> 16) & 0xFF) << L"." << ((ver >> 8) & 0xFF) << L"." << ((ver >> 0) & 0xFF);
\r
107 std::wstring get_avcodec_version()
\r
109 return make_version(avcodec_version());
\r
112 std::wstring get_avformat_version()
\r
114 return make_version(avformat_version());
\r
117 std::wstring get_avutil_version()
\r
119 return make_version(avutil_version());
\r
122 std::wstring get_avfilter_version()
\r
124 return make_version(avfilter_version());
\r
127 std::wstring get_swscale_version()
\r
129 return make_version(swscale_version());
\r