]> git.sesse.net Git - casparcg/commitdiff
Started using ptree_get, ptree_get_value, witerate_children and welement_context_iter...
authorHelge Norberg <helge.norberg@svt.se>
Wed, 2 Dec 2015 19:17:45 +0000 (20:17 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Wed, 2 Dec 2015 19:17:45 +0000 (20:17 +0100)
core/frame/audio_channel_layout.cpp
core/producer/scene/scene_cg_proxy.cpp
core/producer/scene/xml_scene_producer.cpp
modules/bluefish/consumer/bluefish_consumer.cpp
modules/decklink/consumer/decklink_consumer.cpp
modules/ffmpeg/consumer/ffmpeg_consumer.cpp
modules/ffmpeg/consumer/streaming_consumer.cpp
modules/oal/consumer/oal_consumer.cpp
shell/main.cpp
shell/server.cpp

index 40f43a0180d7d74052f9d27efa88578910d1840f..956830d857e3d84e0fca9f795f83369ae735cc4a 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "audio_channel_layout.h"
 
+#include <common/ptree.h>
+
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string/join.hpp>
 #include <boost/range/algorithm/equal.hpp>
@@ -128,13 +130,13 @@ void audio_channel_layout_repository::register_all_layouts(const boost::property
        auto& self = *impl_;
        boost::lock_guard<boost::mutex> lock(self.mutex_);
 
-       for (auto& layout : layouts)
+       for (auto& layout : layouts | welement_context_iteration)
        {
-               CASPAR_VERIFY(layout.first == L"channel-layout");
+               ptree_verify_element_name(layout, L"channel-layout");
 
-               auto name                       = layout.second.get<std::wstring>(L"<xmlattr>.name");
-               auto type                       = layout.second.get<std::wstring>(L"<xmlattr>.type");
-               auto num_channels       = layout.second.get<int>(L"<xmlattr>.num-channels");
+               auto name                       = ptree_get<std::wstring>(layout.second, L"<xmlattr>.name");
+               auto type                       = ptree_get<std::wstring>(layout.second, L"<xmlattr>.type");
+               auto num_channels       = ptree_get<int>(layout.second, L"<xmlattr>.num-channels");
                auto channel_order      = layout.second.get<std::wstring>(L"<xmlattr>.channel-order", L"");
 
                boost::to_upper(name);
@@ -192,13 +194,13 @@ void audio_mix_config_repository::register_all_configs(const boost::property_tre
        auto& self = *impl_;
        boost::lock_guard<boost::mutex> lock(self.mutex_);
 
-       for (auto& config : configs)
+       for (auto& config : configs | welement_context_iteration)
        {
-               CASPAR_VERIFY(config.first == L"mix-config");
+               ptree_verify_element_name(config, L"mix-config");
 
-               auto from_type          = config.second.get<std::wstring>(L"<xmlattr>.from-type");
-               auto to_types_str       = config.second.get<std::wstring>(L"<xmlattr>.to-types");
-               auto mix_config         = config.second.get<std::wstring>(L"<xmlattr>.mix");
+               auto from_type          = ptree_get<std::wstring>(config.second, L"<xmlattr>.from-type");
+               auto to_types_str       = ptree_get<std::wstring>(config.second, L"<xmlattr>.to-types");
+               auto mix_config         = ptree_get<std::wstring>(config.second, L"<xmlattr>.mix");
 
                boost::to_upper(from_type);
                std::vector<std::wstring> to_types;
index a741aae5e95271c240350c4c3eb3c496ced6b182..5e6d0523563d2ba9f88692d5a22dac3f2cd93264 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "scene_cg_proxy.h"
 
+#include <common/ptree.h>
+
 #include <core/producer/frame_producer.h>
 
 #include <boost/property_tree/ptree.hpp>
@@ -95,10 +97,12 @@ void scene_cg_proxy::update(int layer, const std::wstring& data)
 
        std::vector<std::wstring> parameters;
 
-       for (auto value : root.get_child(L"templateData"))
+       for (auto value : root | witerate_children(L"templateData") | welement_context_iteration)
        {
-               auto id = value.second.get<std::wstring>(L"<xmlattr>.id");
-               auto val = value.second.get<std::wstring>(L"data.<xmlattr>.value");
+               ptree_verify_element_name(value, L"componentData");
+
+               auto id         = ptree_get<std::wstring>(value.second, L"<xmlattr>.id");
+               auto val        = ptree_get<std::wstring>(value.second, L"data.<xmlattr>.value");
 
                parameters.push_back(std::move(id));
                parameters.push_back(std::move(val));
index bc97a3f6ca3b0ce1c912f9dac11f4edd55ea50e6..592fc172df30b56fe867e63af1debd0b7b37d7ba 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <common/env.h>
 #include <common/os/filesystem.h>
+#include <common/filesystem.h>
+#include <common/ptree.h>
 #include <core/producer/frame_producer.h>
 #include <core/help/help_repository.h>
 #include <core/help/help_sink.h>
@@ -88,6 +90,8 @@ spl::shared_ptr<core::frame_producer> create_xml_scene_producer(
 
        std::wstring filename = *found;
 
+       CASPAR_SCOPED_CONTEXT_MSG(get_relative(filename, env::template_folder()).string() + ": ");
+
        boost::property_tree::wptree root;
        boost::filesystem::wifstream file(filename);
        boost::property_tree::read_xml(
@@ -96,17 +100,19 @@ spl::shared_ptr<core::frame_producer> create_xml_scene_producer(
                        boost::property_tree::xml_parser::trim_whitespace
                                        | boost::property_tree::xml_parser::no_comments);
 
-       int width = root.get<int>(L"scene.<xmlattr>.width");
-       int height = root.get<int>(L"scene.<xmlattr>.height");
+       int width = ptree_get<int>(root, L"scene.<xmlattr>.width");
+       int height = ptree_get<int>(root, L"scene.<xmlattr>.height");
 
        auto scene = spl::make_shared<scene_producer>(L"scene", width, height, dependencies.format_desc);
 
-       for (auto elem : root.get_child(L"scene.variables"))
+       for (auto elem : root | witerate_children(L"scene.variables") | welement_context_iteration)
        {
-               auto type = elem.second.get<std::wstring>(L"<xmlattr>.type");
-               auto id = elem.second.get<std::wstring>(L"<xmlattr>.id");
-               auto is_public = elem.second.get(L"<xmlattr>.public", false);
-               auto expr = elem.second.get_value<std::wstring>();
+               ptree_verify_element_name(elem, L"variable");
+
+               auto type               = ptree_get<std::wstring>(elem.second, L"<xmlattr>.type");
+               auto id                 = ptree_get<std::wstring>(elem.second, L"<xmlattr>.id");
+               auto is_public  = elem.second.get(L"<xmlattr>.public", false);
+               auto expr               = ptree_get_value<std::wstring>(elem.second);
 
                if (!is_public)
                        id = L"variable." + id;
@@ -119,40 +125,47 @@ spl::shared_ptr<core::frame_producer> create_xml_scene_producer(
                        scene->create_variable<bool>(id, is_public, expr);
        }
 
-       for (auto& elem : root.get_child(L"scene.layers"))
+       for (auto& elem : root | witerate_children(L"scene.layers") | welement_context_iteration)
        {
-               auto id = elem.second.get<std::wstring>(L"<xmlattr>.id");
-               auto producer = dependencies.producer_registry->create_producer(dependencies, elem.second.get<std::wstring>(L"producer"));
-               auto& layer = scene->create_layer(producer, 0, 0, id);
-               auto variable_prefix = L"layer." + id + L".";
-
-               layer.hidden = scene->create_variable<bool>(variable_prefix + L"hidden", false, elem.second.get(L"hidden", L"false"));
-               layer.position.x = scene->create_variable<double>(variable_prefix + L"x", false, elem.second.get<std::wstring>(L"x"));
-               layer.position.y = scene->create_variable<double>(variable_prefix + L"y", false, elem.second.get<std::wstring>(L"y"));
-               layer.anchor.x = scene->create_variable<double>(variable_prefix + L"anchor_x", false, elem.second.get<std::wstring>(L"anchor_x", L"0.0"));
-               layer.anchor.y = scene->create_variable<double>(variable_prefix + L"anchor_y", false, elem.second.get<std::wstring>(L"anchor_y", L"0.0"));
-               layer.rotation = scene->create_variable<double>(variable_prefix + L"rotation", false, elem.second.get<std::wstring>(L"rotation", L"0.0"));
-               layer.crop.upper_left.x = scene->create_variable<double>(variable_prefix + L"crop_upper_left_x", false, elem.second.get<std::wstring>(L"crop_upper_left_x", L"0.0"));
-               layer.crop.upper_left.y = scene->create_variable<double>(variable_prefix + L"crop_upper_left_y", false, elem.second.get<std::wstring>(L"crop_upper_left_y", L"0.0"));
-               layer.crop.lower_right.x = scene->create_variable<double>(variable_prefix + L"crop_lower_right_x", false, elem.second.get<std::wstring>(L"crop_lower_right_x", layer.producer.get()->pixel_constraints().width.as<std::wstring>().get()));
-               layer.crop.lower_right.y = scene->create_variable<double>(variable_prefix + L"crop_lower_right_y", false, elem.second.get<std::wstring>(L"crop_lower_right_y", layer.producer.get()->pixel_constraints().height.as<std::wstring>().get()));
-               layer.perspective.upper_left.x = scene->create_variable<double>(variable_prefix + L"perspective_upper_left_x", false, elem.second.get<std::wstring>(L"perspective_upper_left_x", L"0.0"));
-               layer.perspective.upper_left.y = scene->create_variable<double>(variable_prefix + L"perspective_upper_left_y", false, elem.second.get<std::wstring>(L"perspective_upper_left_y", L"0.0"));
-               layer.perspective.upper_right.x = scene->create_variable<double>(variable_prefix + L"perspective_upper_right_x", false, elem.second.get<std::wstring>(L"perspective_upper_right_x", layer.producer.get()->pixel_constraints().width.as<std::wstring>().get()));
-               layer.perspective.upper_right.y = scene->create_variable<double>(variable_prefix + L"perspective_upper_right_y", false, elem.second.get<std::wstring>(L"perspective_upper_right_y", L"0.0"));
-               layer.perspective.lower_right.x = scene->create_variable<double>(variable_prefix + L"perspective_lower_right_x", false, elem.second.get<std::wstring>(L"perspective_lower_right_x", layer.producer.get()->pixel_constraints().width.as<std::wstring>().get()));
-               layer.perspective.lower_right.y = scene->create_variable<double>(variable_prefix + L"perspective_lower_right_y", false, elem.second.get<std::wstring>(L"perspective_lower_right_y", layer.producer.get()->pixel_constraints().height.as<std::wstring>().get()));
-               layer.perspective.lower_left.x = scene->create_variable<double>(variable_prefix + L"perspective_lower_left_x", false, elem.second.get<std::wstring>(L"perspective_lower_left_x", L"0.0"));
-               layer.perspective.lower_left.y = scene->create_variable<double>(variable_prefix + L"perspective_lower_left_y", false, elem.second.get<std::wstring>(L"perspective_lower_left_y", layer.producer.get()->pixel_constraints().height.as<std::wstring>().get()));
-
-               layer.adjustments.opacity = scene->create_variable<double>(variable_prefix + L"adjustment.opacity", false, elem.second.get(L"adjustments.opacity", L"1.0"));
-               layer.is_key = scene->create_variable<bool>(variable_prefix + L"is_key", false, elem.second.get(L"is_key", L"false"));
-               layer.use_mipmap = scene->create_variable<bool>(variable_prefix + L"use_mipmap", false, elem.second.get(L"use_mipmap", L"false"));
-               layer.blend_mode = scene->create_variable<std::wstring>(variable_prefix + L"blend_mode", false, elem.second.get(L"blend_mode", L"normal")).transformed([](const std::wstring& b) { return get_blend_mode(b); });
-               layer.chroma_key.key = scene->create_variable<std::wstring>(variable_prefix + L"chroma_key.key", false, elem.second.get(L"chroma_key.key", L"none")).transformed([](const std::wstring& k) { return get_chroma_mode(k); });
-               layer.chroma_key.threshold = scene->create_variable<double>(variable_prefix + L"chroma_key.threshold", false, elem.second.get(L"chroma_key.threshold", L"0.0"));
-               layer.chroma_key.softness = scene->create_variable<double>(variable_prefix + L"chroma_key.softness", false, elem.second.get(L"chroma_key.softness", L"0.0"));
-               layer.chroma_key.spill = scene->create_variable<double>(variable_prefix + L"chroma_key.spill", false, elem.second.get(L"chroma_key.spill", L"0.0"));
+               ptree_verify_element_name(elem, L"layer");
+
+               auto id                                                 = ptree_get<std::wstring>(elem.second, L"<xmlattr>.id");
+               auto producer_string                    = ptree_get<std::wstring>(elem.second, L"producer");
+               auto producer                                   = [&]
+               {
+                       CASPAR_SCOPED_CONTEXT_MSG(" -> ");
+                       return dependencies.producer_registry->create_producer(dependencies, producer_string);
+               }();
+               auto& layer                                             = scene->create_layer(producer, 0, 0, id);
+               auto variable_prefix                    = L"layer." + id + L".";
+
+               layer.hidden                                    = scene->create_variable<bool>(variable_prefix + L"hidden", false, elem.second.get(L"hidden", L"false"));
+               layer.position.x                                = scene->create_variable<double>(variable_prefix + L"x", false, ptree_get<std::wstring>(elem.second, L"x"));
+               layer.position.y                                = scene->create_variable<double>(variable_prefix + L"y", false, ptree_get<std::wstring>(elem.second, L"y"));
+               layer.anchor.x                                  = scene->create_variable<double>(variable_prefix + L"anchor_x", false, elem.second.get<std::wstring>(L"anchor_x", L"0.0"));
+               layer.anchor.y                                  = scene->create_variable<double>(variable_prefix + L"anchor_y", false, elem.second.get<std::wstring>(L"anchor_y", L"0.0"));
+               layer.rotation                                  = scene->create_variable<double>(variable_prefix + L"rotation", false, elem.second.get<std::wstring>(L"rotation", L"0.0"));
+               layer.crop.upper_left.x                 = scene->create_variable<double>(variable_prefix + L"crop_upper_left_x", false, elem.second.get<std::wstring>(L"crop_upper_left_x", L"0.0"));
+               layer.crop.upper_left.y                 = scene->create_variable<double>(variable_prefix + L"crop_upper_left_y", false, elem.second.get<std::wstring>(L"crop_upper_left_y", L"0.0"));
+               layer.crop.lower_right.x                = scene->create_variable<double>(variable_prefix + L"crop_lower_right_x", false, elem.second.get<std::wstring>(L"crop_lower_right_x", layer.producer.get()->pixel_constraints().width.as<std::wstring>().get()));
+               layer.crop.lower_right.y                = scene->create_variable<double>(variable_prefix + L"crop_lower_right_y", false, elem.second.get<std::wstring>(L"crop_lower_right_y", layer.producer.get()->pixel_constraints().height.as<std::wstring>().get()));
+               layer.perspective.upper_left.x  = scene->create_variable<double>(variable_prefix + L"perspective_upper_left_x", false, elem.second.get<std::wstring>(L"perspective_upper_left_x", L"0.0"));
+               layer.perspective.upper_left.y  = scene->create_variable<double>(variable_prefix + L"perspective_upper_left_y", false, elem.second.get<std::wstring>(L"perspective_upper_left_y", L"0.0"));
+               layer.perspective.upper_right.x = scene->create_variable<double>(variable_prefix + L"perspective_upper_right_x", false, elem.second.get<std::wstring>(L"perspective_upper_right_x", layer.producer.get()->pixel_constraints().width.as<std::wstring>().get()));
+               layer.perspective.upper_right.y = scene->create_variable<double>(variable_prefix + L"perspective_upper_right_y", false, elem.second.get<std::wstring>(L"perspective_upper_right_y", L"0.0"));
+               layer.perspective.lower_right.x = scene->create_variable<double>(variable_prefix + L"perspective_lower_right_x", false, elem.second.get<std::wstring>(L"perspective_lower_right_x", layer.producer.get()->pixel_constraints().width.as<std::wstring>().get()));
+               layer.perspective.lower_right.y = scene->create_variable<double>(variable_prefix + L"perspective_lower_right_y", false, elem.second.get<std::wstring>(L"perspective_lower_right_y", layer.producer.get()->pixel_constraints().height.as<std::wstring>().get()));
+               layer.perspective.lower_left.x  = scene->create_variable<double>(variable_prefix + L"perspective_lower_left_x", false, elem.second.get<std::wstring>(L"perspective_lower_left_x", L"0.0"));
+               layer.perspective.lower_left.y  = scene->create_variable<double>(variable_prefix + L"perspective_lower_left_y", false, elem.second.get<std::wstring>(L"perspective_lower_left_y", layer.producer.get()->pixel_constraints().height.as<std::wstring>().get()));
+
+               layer.adjustments.opacity               = scene->create_variable<double>(variable_prefix + L"adjustment.opacity", false, elem.second.get(L"adjustments.opacity", L"1.0"));
+               layer.is_key                                    = scene->create_variable<bool>(variable_prefix + L"is_key", false, elem.second.get(L"is_key", L"false"));
+               layer.use_mipmap                                = scene->create_variable<bool>(variable_prefix + L"use_mipmap", false, elem.second.get(L"use_mipmap", L"false"));
+               layer.blend_mode                                = scene->create_variable<std::wstring>(variable_prefix + L"blend_mode", false, elem.second.get(L"blend_mode", L"normal")).transformed([](const std::wstring& b) { return get_blend_mode(b); });
+               layer.chroma_key.key                    = scene->create_variable<std::wstring>(variable_prefix + L"chroma_key.key", false, elem.second.get(L"chroma_key.key", L"none")).transformed([](const std::wstring& k) { return get_chroma_mode(k); });
+               layer.chroma_key.threshold              = scene->create_variable<double>(variable_prefix + L"chroma_key.threshold", false, elem.second.get(L"chroma_key.threshold", L"0.0"));
+               layer.chroma_key.softness               = scene->create_variable<double>(variable_prefix + L"chroma_key.softness", false, elem.second.get(L"chroma_key.softness", L"0.0"));
+               layer.chroma_key.spill                  = scene->create_variable<double>(variable_prefix + L"chroma_key.spill", false, elem.second.get(L"chroma_key.spill", L"0.0"));
 
                scene->create_variable<double>(variable_prefix + L"width", false) = layer.producer.get()->pixel_constraints().width;
                scene->create_variable<double>(variable_prefix + L"height", false) = layer.producer.get()->pixel_constraints().height;
@@ -173,32 +186,38 @@ spl::shared_ptr<core::frame_producer> create_xml_scene_producer(
 
        if (root.get_child_optional(L"scene.marks"))
        {
-               for (auto& mark : root.get_child(L"scene.marks"))
+               for (auto& mark : root | witerate_children(L"scene.marks") | welement_context_iteration)
                {
-                       auto at = mark.second.get<int64_t>(L"<xmlattr>.at");
-                       auto type = get_mark_action(mark.second.get<std::wstring>(L"<xmlattr>.type"));
-                       auto label = mark.second.get(L"<xmlattr>.label", L"");
+                       ptree_verify_element_name(mark, L"mark");
+
+                       auto at         = ptree_get<int64_t>(mark.second, L"<xmlattr>.at");
+                       auto type       = get_mark_action(ptree_get<std::wstring>(mark.second, L"<xmlattr>.type"));
+                       auto label      = mark.second.get(L"<xmlattr>.label", L"");
 
                        scene->add_mark(at, type, label);
                }
        }
 
-       for (auto& elem : root.get_child(L"scene.timelines"))
+       for (auto& elem : root | witerate_children(L"scene.timelines") | welement_context_iteration)
        {
-               auto& variable = scene->get_variable(elem.second.get<std::wstring>(L"<xmlattr>.variable"));
+               ptree_verify_element_name(elem, L"timeline");
+
+               auto& variable = scene->get_variable(ptree_get<std::wstring>(elem.second, L"<xmlattr>.variable"));
 
                for (auto& k : elem.second)
                {
                        if (k.first == L"<xmlattr>")
                                continue;
 
-                       auto easing = k.second.get(L"<xmlattr>.easing", L"");
-                       auto at = k.second.get<int64_t>(L"<xmlattr>.at");
+                       ptree_verify_element_name(k, L"keyframe");
+
+                       auto easing     = k.second.get(L"<xmlattr>.easing", L"");
+                       auto at         = ptree_get<int64_t>(k.second, L"<xmlattr>.at");
 
                        if (variable.is<double>())
-                               scene->add_keyframe(variable.as<double>(), k.second.get_value<double>(), at, easing);
+                               scene->add_keyframe(variable.as<double>(), ptree_get_value<double>(k.second), at, easing);
                        else if (variable.is<int>())
-                               scene->add_keyframe(variable.as<int>(), k.second.get_value<int>(), at, easing);
+                               scene->add_keyframe(variable.as<int>(), ptree_get_value<int>(k.second), at, easing);
                }
        }
 
@@ -209,6 +228,7 @@ spl::shared_ptr<core::frame_producer> create_xml_scene_producer(
 
        for (auto& var_name : scene->get_variables())
        {
+               CASPAR_SCOPED_CONTEXT_MSG(L"/scene/variables/variable[@id=" + var_name + L"]/text()");
                deduce_expression(scene->get_variable(var_name), repo);
        }
 
index 17d2f2db8160d85df2e8c79ff8963f6be1cbb592..50529d9f10360d15ad3e52d0e352795424d59134 100644 (file)
@@ -498,6 +498,8 @@ spl::shared_ptr<core::frame_consumer> create_preconfigured_consumer(
 
        if (channel_layout)
        {
+               CASPAR_SCOPED_CONTEXT_MSG("/channel-layout")
+
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(*channel_layout);
 
                if (!found_layout)
index 7d5454255ce5f5e5a157f9612363786cb58a066c..2031d19d675afdb00cbac41b76d739c5c06c83f4 100644 (file)
@@ -866,6 +866,8 @@ spl::shared_ptr<core::frame_consumer> create_preconfigured_consumer(
 
        if (channel_layout)
        {
+               CASPAR_SCOPED_CONTEXT_MSG("/channel-layout")
+
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(*channel_layout);
 
                if (!found_layout)
index 40a19292470da4975ae8f7b6eec0d30b573981cc..84c7aa15c71728852776c44d84340bfded338a4b 100644 (file)
@@ -48,6 +48,7 @@
 #include <common/assert.h>
 #include <common/memshfl.h>
 #include <common/timer.h>
+#include <common/ptree.h>
 
 #include <boost/algorithm/string.hpp>
 #include <boost/property_tree/ptree.hpp>
@@ -926,7 +927,7 @@ spl::shared_ptr<core::frame_consumer> create_consumer(
 spl::shared_ptr<core::frame_consumer> create_preconfigured_consumer(
                const boost::property_tree::wptree& ptree, core::interaction_sink*)
 {
-       auto filename           = ptree.get<std::wstring>(L"path");
+       auto filename           = ptree_get<std::wstring>(ptree, L"path");
        auto codec                      = ptree.get(L"vcodec", L"libx264");
        auto separate_key       = ptree.get(L"separate-key", false);
 
index f8daf9199cbfafdaecc25a0a3fa4118340fd0fb1..2ba5f03297c99a282128f472827201d1ec55a311 100644 (file)
@@ -11,6 +11,7 @@
 #include <common/future.h>
 #include <common/env.h>
 #include <common/scope_exit.h>
+#include <common/ptree.h>
 
 #include <core/consumer/frame_consumer.h>
 #include <core/frame/frame.h>
@@ -1299,7 +1300,7 @@ spl::shared_ptr<core::frame_consumer> create_preconfigured_streaming_consumer(
                const boost::property_tree::wptree& ptree, core::interaction_sink*)
 {                      
        return spl::make_shared<streaming_consumer>(
-                       u8(ptree.get<std::wstring>(L"path")), 
+                       u8(ptree_get<std::wstring>(ptree, L"path")), 
                        u8(ptree.get<std::wstring>(L"args", L"")),
                        false);
 }
index 1458b128a3fe586de26a5136a368ee078c99c4bd..da6108c6917f497c499ca2c8bdb23301e1ba1023 100644 (file)
@@ -323,6 +323,8 @@ spl::shared_ptr<core::frame_consumer> create_preconfigured_consumer(const boost:
 
        if (channel_layout_spec)
        {
+               CASPAR_SCOPED_CONTEXT_MSG("/channel-layout")
+
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(*channel_layout_spec);
 
                if (!found_layout)
index 5cfbb4d15e195b2dece8cc650096b14837243710..ffac2a4cded2060ec96880f06b2942e9099070fc 100644 (file)
@@ -212,7 +212,7 @@ bool run(const std::wstring& config_file_name, tbb::atomic<bool>& should_wait_fo
 
        // Create server object which initializes channels, protocols and controllers.
        std::unique_ptr<server> caspar_server(new server(shutdown_server_now));
-       
+
        // Print environment information.
        print_system_info(caspar_server->get_system_info_provider_repo());
 
@@ -221,7 +221,10 @@ bool run(const std::wstring& config_file_name, tbb::atomic<bool>& should_wait_fo
        boost::property_tree::write_xml(str, env::properties(), w);
        CASPAR_LOG(info) << config_file_name << L":\n-----------------------------------------\n" << str.str() << L"-----------------------------------------";
        
-       caspar_server->start();
+       {
+               CASPAR_SCOPED_CONTEXT_MSG(config_file_name + L": ")
+               caspar_server->start();
+       }
 
        // Create a dummy client which prints amcp responses to console.
        auto console_client = spl::make_shared<IO::ConsoleClientInfo>();
index 9f9c159470e2aa412dfca3ea55bd53e830759403..409ddf3edd2d8106faec2a2250787faa5962b219 100644 (file)
@@ -32,6 +32,7 @@
 #include <common/utf.h>
 #include <common/memory.h>
 #include <common/polling_filesystem_monitor.h>
+#include <common/ptree.h>
 
 #include <core/video_channel.h>
 #include <core/video_format.h>
@@ -232,17 +233,25 @@ struct server::impl : boost::noncopyable
                auto custom_mix_configs         = pt.get_child_optional(L"configuration.audio.mix-configs");
 
                if (custom_channel_layouts)
+               {
+                       CASPAR_SCOPED_CONTEXT_MSG("/configuration/audio/channel-layouts");
                        audio_channel_layout_repository::get_default()->register_all_layouts(*custom_channel_layouts);
+               }
 
                if (custom_mix_configs)
+               {
+                       CASPAR_SCOPED_CONTEXT_MSG("/configuration/audio/mix-configs");
                        audio_mix_config_repository::get_default()->register_all_configs(*custom_mix_configs);
+               }
        }
 
        void setup_channels(const boost::property_tree::wptree& pt)
        {   
                using boost::property_tree::wptree;
-               for (auto& xml_channel : pt.get_child(L"configuration.channels"))
+               for (auto& xml_channel : pt | witerate_children(L"configuration.channels") | welement_context_iteration)
                {
+                       ptree_verify_element_name(xml_channel, L"channel");
+
                        auto format_desc_str = xml_channel.second.get(L"video-mode", L"PAL");
                        auto format_desc = video_format_desc(format_desc_str);
                        if(format_desc.format == video_format::invalid)
@@ -258,8 +267,8 @@ struct server::impl : boost::noncopyable
 
                        core::diagnostics::scoped_call_context save;
                        core::diagnostics::call_context::for_thread().video_channel = channel->index();
-                       
-                       for (auto& xml_consumer : xml_channel.second.get_child(L"consumers"))
+
+                       for (auto& xml_consumer : xml_channel.second | witerate_children(L"consumers") | welement_context_iteration)
                        {
                                auto name = xml_consumer.first;
 
@@ -271,7 +280,7 @@ struct server::impl : boost::noncopyable
                                catch (const user_error& e)
                                {
                                        CASPAR_LOG_CURRENT_EXCEPTION_AT_LEVEL(debug);
-                                       CASPAR_LOG(error) << *boost::get_error_info<msg_info_t>(e) << L". Error found in " << name << L" consumer configuration. Turn on log level debug for stacktrace.";
+                                       CASPAR_LOG(error) << get_message_and_context(e) << " Turn on log level debug for stacktrace.";
                                }
                                catch (...)
                                {
@@ -311,12 +320,14 @@ struct server::impl : boost::noncopyable
 
                if (predefined_clients)
                {
-                       for (auto& predefined_client : *predefined_clients)
+                       for (auto& predefined_client : pt | witerate_children(L"configuration.osc.predefined-clients") | welement_context_iteration)
                        {
+                               ptree_verify_element_name(predefined_client, L"predefined_client");
+
                                const auto address =
-                                               predefined_client.second.get<std::wstring>(L"address");
+                                               ptree_get<std::wstring>(predefined_client.second, L"address");
                                const auto port =
-                                               predefined_client.second.get<unsigned short>(L"port");
+                                               ptree_get<unsigned short>(predefined_client.second, L"port");
                                predefined_osc_subscriptions_.push_back(
                                                osc_client_->get_subscription_token(udp::endpoint(
                                                                address_v4::from_string(u8(address)),
@@ -380,14 +391,14 @@ struct server::impl : boost::noncopyable
                amcp::register_commands(*amcp_command_repo_);
 
                using boost::property_tree::wptree;
-               for (auto& xml_controller : pt.get_child(L"configuration.controllers"))
+               for (auto& xml_controller : pt | witerate_children(L"configuration.controllers") | welement_context_iteration)
                {
                        auto name = xml_controller.first;
-                       auto protocol = xml_controller.second.get<std::wstring>(L"protocol");   
+                       auto protocol = ptree_get<std::wstring>(xml_controller.second, L"protocol");
 
                        if(name == L"tcp")
                        {                                       
-                               unsigned int port = xml_controller.second.get(L"port", 5250);
+                               auto port = ptree_get<unsigned int>(xml_controller.second, L"port");
                                auto asyncbootstrapper = spl::make_shared<IO::AsyncEventServer>(
                                                io_service_,
                                                create_protocol(protocol, L"TCP Port " + boost::lexical_cast<std::wstring>(port)),