#include <libcxml/cxml.h>
#include "subtitle_content.h"
+#include "util.h"
+#include "exceptions.h"
+
+#include "i18n.h"
using std::string;
+using std::vector;
using boost::shared_ptr;
using boost::lexical_cast;
+using boost::dynamic_pointer_cast;
int const SubtitleContentProperty::SUBTITLE_OFFSET = 500;
int const SubtitleContentProperty::SUBTITLE_SCALE = 501;
, _subtitle_offset (0)
, _subtitle_scale (1)
{
+ LocaleGuard lg;
+
_subtitle_offset = node->number_child<float> ("SubtitleOffset");
_subtitle_scale = node->number_child<float> ("SubtitleScale");
}
+SubtitleContent::SubtitleContent (shared_ptr<const Film> f, vector<shared_ptr<Content> > c)
+ : Content (f, c)
+{
+ shared_ptr<SubtitleContent> ref = dynamic_pointer_cast<SubtitleContent> (c[0]);
+ assert (ref);
+
+ for (size_t i = 0; i < c.size(); ++i) {
+ shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c[i]);
+
+ if (sc->subtitle_offset() != ref->subtitle_offset()) {
+ throw JoinError (_("Content to be joined must have the same subtitle offset."));
+ }
+
+ if (sc->subtitle_scale() != ref->subtitle_scale()) {
+ throw JoinError (_("Content to be joined must have the same subtitle scale."));
+ }
+ }
+
+ _subtitle_offset = ref->subtitle_offset ();
+ _subtitle_scale = ref->subtitle_scale ();
+}
+
void
SubtitleContent::as_xml (xmlpp::Node* root) const
{
+ LocaleGuard lg;
+
root->add_child("SubtitleOffset")->add_child_text (lexical_cast<string> (_subtitle_offset));
root->add_child("SubtitleScale")->add_child_text (lexical_cast<string> (_subtitle_scale));
}
void
-SubtitleContent::set_subtitle_offset (int o)
+SubtitleContent::set_subtitle_offset (double o)
{
{
boost::mutex::scoped_lock lm (_mutex);
}
void
-SubtitleContent::set_subtitle_scale (float s)
+SubtitleContent::set_subtitle_scale (double s)
{
{
boost::mutex::scoped_lock lm (_mutex);