Support reading of encrypted subtitles.
[libdcp.git] / src / subtitle_asset.cc
index 47baaa4eaed4a1e13dcbfb2d36af76a3b5f3e487..b9f6336c594928d09c6990aeaf035e2f37c936dd 100644 (file)
     You should have received a copy of the GNU General Public License
     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
 
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of portions of this program with the
+    OpenSSL library under certain conditions as described in each
+    individual source file, and distribute linked combinations
+    including the two.
+
+    You must obey the GNU General Public License in all respects
+    for all of the code used other than OpenSSL.  If you modify
+    file(s) with this exception, you may extend this exception to your
+    version of the file(s), but you are not obligated to do so.  If you
+    do not wish to do so, delete this exception statement from your
+    version.  If you delete this exception statement from all source
+    files in the program, then also delete it here.
 */
 
 #include "raw_convert.h"
 #include "text_node.h"
 #include "subtitle_string.h"
 #include "dcp_assert.h"
-#include "AS_DCP.h"
-#include "KM_util.h"
+#include <asdcp/AS_DCP.h>
+#include <asdcp/KM_util.h>
 #include <libxml++/nodes/element.h>
 #include <boost/algorithm/string.hpp>
 #include <boost/shared_array.hpp>
 #include <boost/foreach.hpp>
-#include <fstream>
 
 using std::string;
 using std::list;
-using std::ostream;
-using std::ofstream;
-using std::stringstream;
 using std::cout;
 using std::cerr;
 using std::map;
@@ -145,6 +154,7 @@ SubtitleAsset::maybe_add_subtitle (string text, ParseState const & parse_state)
                        effective_font.id,
                        effective_font.italic.get_value_or (false),
                        effective_font.bold.get_value_or (false),
+                       effective_font.underline.get_value_or (false),
                        effective_font.colour.get_value_or (dcp::Colour (255, 255, 255)),
                        effective_font.size,
                        effective_font.aspect_adjust.get_value_or (1.0),
@@ -236,11 +246,12 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
 
        string const xmlns = standard == SMPTE ? "dcst" : "";
 
-       /* XXX: script, underlined not supported */
+       /* XXX: script not supported */
 
        optional<string> font;
        bool italic = false;
        bool bold = false;
+       bool underline = false;
        Colour colour;
        int size = 0;
        float aspect_adjust = 1.0;
@@ -266,6 +277,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
                        font          != i.font()          ||
                        italic        != i.italic()        ||
                        bold          != i.bold()          ||
+                       underline     != i.underline()     ||
                        colour        != i.colour()        ||
                        size          != i.size()          ||
                        fabs (aspect_adjust - i.aspect_adjust()) > ASPECT_ADJUST_EPSILON ||
@@ -276,6 +288,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
                        font = i.font ();
                        italic = i.italic ();
                        bold = i.bold ();
+                       underline = i.underline ();
                        colour = i.colour ();
                        size = i.size ();
                        aspect_adjust = i.aspect_adjust ();
@@ -302,9 +315,9 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
                        font_element->set_attribute ("EffectColor", effect_colour.to_argb_string());
                        font_element->set_attribute ("Script", "normal");
                        if (standard == SMPTE) {
-                               font_element->set_attribute ("Underline", "no");
+                               font_element->set_attribute ("Underline", underline ? "yes" : "no");
                        } else {
-                               font_element->set_attribute ("Underlined", "no");
+                               font_element->set_attribute ("Underlined", underline ? "yes" : "no");
                        }
                        font_element->set_attribute ("Weight", bold ? "bold" : "normal");
                }