Rationalise #undef-ing of ERROR.
[libdcp.git] / src / frame.h
index 54b74e552ee4ea8f2693558715908403c9d4b412..01dfe8b4ab1286ed6ccd630a9727e800c35d3f43 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
     files in the program, then also delete it here.
 */
 
-#include "decryption_context.h"
+
+/** @file  src/frame.h
+ *  @brief Frame class
+ */
+
+
+#ifndef LIBDCP_FRAME_H
+#define LIBDCP_FRAME_H
+
+
+#include "crypto_context.h"
 #include "exceptions.h"
 #include <asdcp/KM_fileio.h>
 #include <asdcp/AS_DCP.h>
-#include <boost/noncopyable.hpp>
+
 
 namespace dcp {
 
+
 template <class R, class B>
-class Frame : public boost::noncopyable
+class Frame
 {
 public:
-       Frame (R* reader, int n, boost::shared_ptr<const DecryptionContext> c)
+       Frame (R* reader, int n, std::shared_ptr<const DecryptionContext> c, bool check_hmac)
        {
                /* XXX: unfortunate guesswork on this buffer size */
-               _buffer = new B (Kumu::Megabyte);
+               _buffer = std::make_shared<B>(Kumu::Megabyte);
 
-               if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->decryption()))) {
-                       boost::throw_exception (DCPReadError ("could not read frame"));
+               if (ASDCP_FAILURE(reader->ReadFrame(n, *_buffer, c->context(), check_hmac ? c->hmac() : nullptr))) {
+                       boost::throw_exception (ReadError ("could not read frame"));
                }
        }
 
-       ~Frame ()
-       {
-               delete _buffer;
-       }
+       Frame (Frame const&) = delete;
+       Frame& operator= (Frame const&) = delete;
 
        uint8_t const * data () const
        {
@@ -69,7 +78,11 @@ public:
        }
 
 private:
-       B* _buffer;
+       std::shared_ptr<B> _buffer;
 };
 
+
 }
+
+
+#endif