summaryrefslogtreecommitdiff
path: root/src/lib/subtitle_content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-11-23 20:24:51 +0000
committerCarl Hetherington <cth@carlh.net>2013-11-23 20:24:51 +0000
commitc3da7c64f01420447dbab7f5c2ea42ff1b911cc5 (patch)
tree77832e3b515987132ce8fe64ee82eaa2e87b8bd0 /src/lib/subtitle_content.cc
parentbab2a1cf99c58dcb598fed383015b1937d3ea07f (diff)
Basics of joining.
Diffstat (limited to 'src/lib/subtitle_content.cc')
-rw-r--r--src/lib/subtitle_content.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc
index 1194e2dc9..6c0d3af86 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/subtitle_content.cc
@@ -20,10 +20,15 @@
#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;
@@ -47,6 +52,28 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, shared_ptr<const cxm
_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
{