set(OPENAL_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/openal/include")
set(BLUEFISH_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/bluefish/include")
-set(FFMPEG_BIN_PATH "${DEPENDENCIES_FOLDER}/ffmpeg/bin")
-set(FREEIMAGE_BIN_PATH "${DEPENDENCIES_FOLDER}/freeimage/bin")
+if (MSVC)
+ set(PLATFORM_FOLDER_NAME "win32")
+elseif (CMAKE_COMPILER_IS_GNUCXX)
+ set(PLATFORM_FOLDER_NAME "linux")
+endif ()
+
+set(FFMPEG_BIN_PATH "${DEPENDENCIES_FOLDER}/ffmpeg/bin/${PLATFORM_FOLDER_NAME}")
+set(FREEIMAGE_BIN_PATH "${DEPENDENCIES_FOLDER}/freeimage/bin/${PLATFORM_FOLDER_NAME}")
set(GLEW_BIN_PATH "${DEPENDENCIES_FOLDER}/glew/bin")
set(OPENAL_BIN_PATH "${DEPENDENCIES_FOLDER}/openal/bin")
-set(TBB_BIN_PATH "${DEPENDENCIES_FOLDER}/tbb/bin")
+set(TBB_BIN_PATH "${DEPENDENCIES_FOLDER}/tbb/bin/${PLATFORM_FOLDER_NAME}")
set(LIBERATION_FONTS_BIN_PATH "${DEPENDENCIES_FOLDER}/liberation-fonts")
-link_directories("${DEPENDENCIES_FOLDER}/boost/stage/lib")
-link_directories("${DEPENDENCIES_FOLDER}/tbb/lib")
+link_directories("${DEPENDENCIES_FOLDER}/boost/stage/lib/${PLATFORM_FOLDER_NAME}")
+link_directories("${DEPENDENCIES_FOLDER}/tbb/lib/${PLATFORM_FOLDER_NAME}")
link_directories("${DEPENDENCIES_FOLDER}/glew/lib")
-link_directories("${DEPENDENCIES_FOLDER}/sfml/lib")
+link_directories("${DEPENDENCIES_FOLDER}/sfml/lib/${PLATFORM_FOLDER_NAME}")
link_directories("${DEPENDENCIES_FOLDER}/sfml/extlibs/lib")
link_directories("${DEPENDENCIES_FOLDER}/freetype/objs/win32/vc2010")
-link_directories("${DEPENDENCIES_FOLDER}/ffmpeg/lib")
+link_directories("${DEPENDENCIES_FOLDER}/ffmpeg/lib/${PLATFORM_FOLDER_NAME}")
link_directories("${DEPENDENCIES_FOLDER}/asmlib")
-link_directories("${DEPENDENCIES_FOLDER}/freeimage/lib")
+link_directories("${DEPENDENCIES_FOLDER}/freeimage/lib/${PLATFORM_FOLDER_NAME}")
link_directories("${DEPENDENCIES_FOLDER}/openal/lib")
link_directories("${DEPENDENCIES_FOLDER}/bluefish/lib")
link_directories("${DEPENDENCIES_FOLDER}/zlib/lib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa /Zi /W4 /WX /MP /fp:fast /FIcommon/compiler/vs/disable_silly_warnings.h")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D TBB_USE_ASSERT=1 /D TBB_USE_DEBUG /bigobj")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /Ot /Gy")
-
elseif (CMAKE_COMPILER_IS_GNUCXX)
add_compile_options( -std=c++11 )
add_compile_options( -msse3 )
add_compile_options( -mssse3 )
add_compile_options( -msse4.1 )
+ add_compile_options( -pthread )
endif ()
cmake_policy(SET CMP0045 OLD)
)
elseif (CMAKE_COMPILER_IS_GNUCXX)
set(OS_SPECIFIC_SOURCES
+ os/linux/prec_timer.cpp
os/linux/signal_handlers.cpp
os/linux/scheduling.cpp
os/linux/stack_trace.cpp
--- /dev/null
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG 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 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG 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 CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#include "../../stdafx.h"
+
+#include "../../prec_timer.h"
+
+#include <boost/thread.hpp>
+#include <boost/chrono/system_clocks.hpp>
+
+using namespace boost::chrono;
+
+namespace caspar {
+
+prec_timer::prec_timer()
+ : time_(0)
+{
+}
+
+void prec_timer::tick_millis(int64_t ticks_to_wait)
+{
+ auto t = duration_cast<milliseconds>(high_resolution_clock::now().time_since_epoch()).count();
+
+ if (time_ != 0)
+ {
+ bool done = 0;
+ do
+ {
+ auto ticks_passed = t - time_;
+ auto ticks_left = ticks_to_wait - ticks_passed;
+
+ if (t < time_) // time wrap
+ done = 1;
+ if (ticks_passed >= ticks_to_wait)
+ done = 1;
+
+ if (!done)
+ {
+ // if > 0.002s left, do Sleep(1), which will actually sleep some
+ // steady amount, probably 1-2 ms,
+ // and do so in a nice way (cpu meter drops; laptop battery spared).
+ // otherwise, do a few Sleep(0)'s, which just give up the timeslice,
+ // but don't really save cpu or battery, but do pass a tiny
+ // amount of time.
+ if (ticks_left > 2)
+ boost::this_thread::sleep_for(milliseconds(1));
+ /*else
+ for (int i = 0; i < 10; ++i)
+ Sleep(0); // causes thread to give up its timeslice*/
+ }
+
+ t = duration_cast<milliseconds>(high_resolution_clock::now().time_since_epoch()).count();
+ } while (!done);
+ }
+
+ time_ = t;
+}
+
+}
namespace caspar { namespace core {
-std::vector<consumer_factory_t> g_factories;
-std::map<std::wstring, preconfigured_consumer_factory_t> g_preconfigured_factories;
+std::vector<consumer_factory_t> g_consumer_factories;
+std::map<std::wstring, preconfigured_consumer_factory_t> g_preconfigured_consumer_factories;
void register_consumer_factory(const consumer_factory_t& factory)
{
- g_factories.push_back(factory);
+ g_consumer_factories.push_back(factory);
}
void register_preconfigured_consumer_factory(
const std::wstring& element_name,
const preconfigured_consumer_factory_t& factory)
{
- g_preconfigured_factories.insert(std::make_pair(element_name, factory));
+ g_preconfigured_consumer_factories.insert(std::make_pair(element_name, factory));
}
class destroy_consumer_proxy : public frame_consumer
CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("params") << arg_value_info(""));
auto consumer = frame_consumer::empty();
- std::any_of(g_factories.begin(), g_factories.end(), [&](const consumer_factory_t& factory) -> bool
+ std::any_of(g_consumer_factories.begin(), g_consumer_factories.end(), [&](const consumer_factory_t& factory) -> bool
{
try
{
const boost::property_tree::wptree& element,
interaction_sink* sink)
{
- auto found = g_preconfigured_factories.find(element_name);
+ auto found = g_preconfigured_consumer_factories.find(element_name);
- if (found == g_preconfigured_factories.end())
+ if (found == g_preconfigured_consumer_factories.end())
CASPAR_THROW_EXCEPTION(file_not_found()
<< msg_info(L"No consumer factory registered for element name " + element_name));
namespace caspar { namespace core {
-std::vector<producer_factory_t> g_factories;
+std::vector<producer_factory_t> g_producer_factories;
std::vector<producer_factory_t> g_thumbnail_factories;
void register_producer_factory(const producer_factory_t& factory)
{
- g_factories.push_back(factory);
+ g_producer_factories.push_back(factory);
}
void register_thumbnail_producer_factory(const producer_factory_t& factory)
{
spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<frame_factory>& my_frame_factory, const video_format_desc& format_desc, const std::vector<std::wstring>& params)
{
- auto producer = do_create_producer(my_frame_factory, format_desc, params, g_factories);
+ auto producer = do_create_producer(my_frame_factory, format_desc, params, g_producer_factories);
auto key_producer = frame_producer::empty();
try // to find a key file.
if(params_copy.size() > 0)
{
params_copy[0] += L"_A";
- key_producer = do_create_producer(my_frame_factory, format_desc, params_copy, g_factories);
+ key_producer = do_create_producer(my_frame_factory, format_desc, params_copy, g_producer_factories);
if(key_producer == frame_producer::empty())
{
params_copy[0] += L"LPHA";
- key_producer = do_create_producer(my_frame_factory, format_desc, params_copy, g_factories);
+ key_producer = do_create_producer(my_frame_factory, format_desc, params_copy, g_producer_factories);
}
}
}
L"Unexpected end of input (Expected operator) in " + str));
}
-template<typename T>
-T as(const boost::any& value)
-{
- return boost::any_cast<T>(value);
-}
-
boost::any as_binding(const boost::any& value)
{
// Wrap supported constants as bindings
return as_binding(tokens.at(0));
}
-template<>
+/*template<>
binding<std::wstring> parse_expression(
const std::wstring& str, const variable_repository& var_repo)
{
CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
L"parse_expression() Unsupported type "
+ u16(expr.type().name())));
-}
+}*/
}}}
return value.type() == typeid(T);
}
+template<typename T>
+T as(const boost::any& value)
+{
+ return boost::any_cast<T>(value);
+}
+
template<typename T>
static binding<T> parse_expression(
const std::wstring& str, const variable_repository& var_repo)
template<>
binding<std::wstring> parse_expression(
- const std::wstring& str, const variable_repository& var_repo);
+ const std::wstring& str, const variable_repository& var_repo)
+{
+ auto cursor = str.cbegin();
+ auto expr = parse_expression(cursor, str, var_repo);
+
+ if (is<binding<std::wstring>>(expr))
+ return as<binding<std::wstring>>(expr);
+ else if (is<binding<double>>(expr))
+ return as<binding<double>>(expr).as<std::wstring>();
+ else
+ CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+ L"parse_expression() Unsupported type "
+ + u16(expr.type().name())));
+}
}}}
--- /dev/null
+libavcodec.so.55
\ No newline at end of file
--- /dev/null
+libavfilter.so.4
\ No newline at end of file
--- /dev/null
+libavformat.so.55
\ No newline at end of file
--- /dev/null
+libavutil.so.52
\ No newline at end of file
--- /dev/null
+libswresample.so.0
\ No newline at end of file
--- /dev/null
+libswscale.so.2
\ No newline at end of file
--- /dev/null
+../bin/linux
\ No newline at end of file
--- /dev/null
+../lib/linux
\ No newline at end of file
--- /dev/null
+libfreeimage.so.3
\ No newline at end of file
--- /dev/null
+../lib/linux
\ No newline at end of file
--- /dev/null
+libtbb.so.2
\ No newline at end of file
--- /dev/null
+libtbb_debug.so.2
\ No newline at end of file
--- /dev/null
+libtbb_preview.so.2
\ No newline at end of file
--- /dev/null
+libtbb_preview_debug.so.2
\ No newline at end of file
--- /dev/null
+libtbbmalloc.so.2
\ No newline at end of file
--- /dev/null
+libtbbmalloc_debug.so.2
\ No newline at end of file
--- /dev/null
+libtbbmalloc_proxy.so.2
\ No newline at end of file
--- /dev/null
+libtbbmalloc_proxy_debug.so.2
\ No newline at end of file
#include <cmath>
#include <cstdint>
+#include <algorithm>
namespace caspar { namespace image {
template<class SrcDstView>
void premultiply(SrcDstView& view_to_modify)
{
- std::for_each(view_to_modify.begin(), view_to_modify.end(), [&](SrcDstView::pixel_type& pixel)
+ std::for_each(view_to_modify.begin(), view_to_modify.end(), [&](typename SrcDstView::pixel_type& pixel)
{
int alpha = static_cast<int>(pixel.a());
#include <boost/filesystem.hpp>
#include <boost/range/algorithm.hpp>
-#include "../common/utf.h"
-#include "../common/memory.h"
+#include <common/utf.h>
+#include <common/memory.h>
//#include "../common/executor.h" // Can't include this due to MSVC lambda bug
-#include "../common/log.h"
-#include "../common/except.h"
+#include <common/log.h>
+#include <common/except.h>
#include <assert.h>
source_group(sources ./*)
-target_link_libraries(casparcg
- accelerator
- common
- core
- protocol
-
- "${CASPARCG_MODULE_PROJECTS}"
- reroute
-
+if (MSVC)
+ set(LIBRARIES_TO_LINK
alibcof64.lib
jpeg.lib
sndfile.lib
debug FreeImaged.lib
freetype.lib
zlibstat.lib
+ )
+else ()
+ set(LIBRARIES_TO_LINK
+ "${DEPENDENCIES_FOLDER}/asmlib/alibelf64.a"
+ avformat
+ avcodec
+ avutil
+ avfilter
+ swscale
+ swresample
+ freetype
+ freeimage
+ boost_system
+ boost_thread
+ boost_chrono
+ boost_filesystem
+ boost_log
+ boost_locale
+ boost_regex
+ boost_date_time
+ tbb
+ tbbmalloc
+ tbbmalloc_proxy
+ sfml-system-s
+ sfml-window-s
+ sfml-graphics-s
+ GLEW
+ GL
+ X11
+ jpeg
+ sndfile
+ freetype
+ udev
+ Xrandr
+ pthread
+ )
+endif ()
+
+target_link_libraries(casparcg
+ accelerator
+ common
+ core
+ protocol
+
+ "${CASPARCG_MODULE_PROJECTS}"
+
+ reroute
+
+ "${LIBRARIES_TO_LINK}"
)
set(OUTPUT_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}")
void setup_prerequisites()
{
-
+ // TODO: implement if needed.
}
void setup_console_window()
{
-
+ // TODO: implement.
}
void increase_process_priority()
{
+ // TODO: implement.
}
void wait_for_keypress()
{
+ // TODO: implement if desirable.
}
std::shared_ptr<void> setup_debugging_environment()
{
+ // TODO: implement if applicable.
return nullptr;
}
void wait_for_remote_debugging()
{
-
+ // TODO: implement if applicable.
}
}
async_servers_.clear();
channels_.clear();
- boost::this_thread::sleep(boost::posix_time::milliseconds(500));
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
//Sleep(500); // HACK: Wait for asynchronous destruction of producers and consumers.
uninitialize_modules();