75e39a010b92f65868cba970bf6e0bb5125dd8da
[libdcp.git] / src / content.h
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef LIBDCP_CONTENT_H
21 #define LIBDCP_CONTENT_H
22
23 #include <string>
24 #include <list>
25 #include <boost/filesystem.hpp>
26 #include <boost/function.hpp>
27 #include <libxml++/libxml++.h>
28 #include "types.h"
29 #include "asset.h"
30
31 namespace ASDCP {
32         class WriterInfo;
33 }
34
35 namespace xmlpp {
36         class Element;
37 }
38
39 namespace dcp
40 {
41
42 /** @class Content
43  *  @brief An asset that represents a piece of content, i.e. picture, sound or subtitle.
44  *
45  *  Such a piece of content will be contained in a file (either MXF or XML) within a DCP.
46  */
47 class Content : public Asset
48 {
49 public:
50         Content (boost::filesystem::path file);
51         Content (int edit_rate);
52
53         virtual ~Content () {}
54
55         /** Write details of the asset to a PKL AssetList node.
56          *  @param p Parent node.
57          */
58         void write_to_pkl (xmlpp::Node *) const;
59
60         /** Write details of the asset to a ASSETMAP stream.
61          *  @param s Stream.
62          */
63         void write_to_assetmap (xmlpp::Node *) const;
64
65         boost::filesystem::path file () const {
66                 return _file;
67         }
68
69         void set_file (boost::filesystem::path file) {
70                 _file = file;
71         }
72
73         int edit_rate () const {
74                 return _edit_rate;
75         }
76
77         void set_edit_rate (int r) {
78                 _edit_rate = r;
79         }
80
81         void set_entry_point (int64_t p) {
82                 _entry_point = p;
83         }
84
85         int64_t intrinsic_duration () const {
86                 return _intrinsic_duration;
87         }
88
89         void set_intrinsic_duration (int64_t d) {
90                 _intrinsic_duration = d;
91         }
92
93         int64_t duration () const {
94                 return _duration;
95         }
96
97         void set_duration (int64_t d) {
98                 _duration = d;
99         }
100
101         virtual bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const;
102
103 protected:
104         boost::filesystem::path _file;
105         /** The edit rate; this is normally equal to the number of video frames per second */
106         int _edit_rate;
107         int64_t _entry_point;
108         int64_t _intrinsic_duration;
109         int64_t _duration;
110 };
111
112 }
113
114 #endif