1 /*****************************************************************************
2 * Copyright (C) 2013 VLC authors and VideoLAN
4 * Authors: Nicolas Bertrand <nico@isf.cc>
5 * Jean-Baptiste Kempf <jb@videolan.org>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20 *****************************************************************************/
24 * @brief Parse DCP XML files
35 /* VLC core API headers */
36 #include <vlc_common.h>
37 #include <vlc_demux.h>
38 #include <vlc_plugin.h>
63 class AssetList: public std::list<Asset *> {};
67 /* This struct stores useful information about an MXF for demux() */
73 int i_correction; /* entrypoint - sum of previous durations */
74 int i_absolute_end; /* correction + duration */
77 /* This struct stores the most important information about the DCP */
80 string path; /* Path to DCP directory */
83 AssetList *p_asset_list;
85 vector<info_reel> audio_reels;
86 vector<info_reel> video_reels;
89 p_asset_list(NULL) {};
93 if ( p_asset_list != NULL ) {
94 vlc_delete_all(*p_asset_list);
104 XmlFile( demux_t * p_demux, string s_path):
105 p_demux(p_demux), s_path(s_path),
113 virtual int Parse() = 0;
115 bool IsCPL() { return type == XML_CPL; }
122 xml_reader_t *p_xmlReader;
132 Chunk(demux_t * demux):
133 i_vol_index(1), i_offset(0), i_length(0),
135 int Parse(xml_reader_t *p_xmlReader, string p_node, int p_type);
136 string getPath() { return this->s_path; };
148 Asset (demux_t * demux):
149 b_is_packing_list(false), ui_size(0),
150 i_intrisic_duration(0), i_entry_point(0), i_duration(0),
154 void setId(string p_string ) { this->s_id = p_string; };
155 void setPath(string p_string) { this->s_path = p_string; };
156 void setAnnotation(string p_string) {
157 if (this->s_annotation.empty())
158 this->s_annotation = p_string;
160 this->s_annotation = this->s_annotation + "--" + p_string;
162 void setPackingList(bool p_bool) { this->s_path = p_bool; };
163 void setEntryPoint(int i_val) { this->i_entry_point = i_val; };
164 void setDuration (int i_val) { this->i_duration = i_val; };
165 void setIntrinsicDuration (int i_val) { this->i_intrisic_duration = i_val; };
166 string getId() const { return this->s_id; } ;
167 string getPath() const { return this->s_path; };
168 string getType() const { return this->s_type; };
169 string getOriginalFilename() const { return this->s_original_filename; };
170 int getEntryPoint() const { return this->i_entry_point; };
171 int getDuration() const { return this->i_duration; };
172 int getIntrinsicDuration() const { return this->i_intrisic_duration; };
174 bool isPackingList() const { return this->b_is_packing_list; };
176 int Parse( xml_reader_t *p_xmlReader, string node, int type);
177 int ParsePKL( xml_reader_t *p_xmlReader);
186 bool b_is_packing_list;
190 string s_original_filename;
191 TrackType_t e_track_type;
193 int i_intrisic_duration;
196 /* encryption attribute */
198 /* Picture attributes */
200 string s_screen_aspect_ratio;
201 /* sound and subtitle */
205 std::vector<Chunk> chunk_vec;
208 int parseChunkList( xml_reader_t *p_xmlReader, string p_node, int p_type);
217 Reel(demux_t * demux, AssetList *asset_list, xml_reader_t *xmlReader)
218 : p_asset_list(asset_list), p_xmlReader(xmlReader), p_demux(demux)
220 int Parse(string p_node, int p_type);
221 Asset * getTrack(TrackType_t e_track);
224 AssetList *p_asset_list;
225 xml_reader_t *p_xmlReader;
230 Asset *p_picture_track;
231 Asset *p_sound_track;
232 Asset *p_subtitle_track;
234 int ParseAssetList(string p_node, int p_type);
235 int ParseAsset(string p_node, int p_type, TrackType_t e_track);
238 class CPL : public XmlFile
241 CPL(demux_t *, string, AssetList*);
245 Reel *getReel(int pos) { return this->vec_reel[pos]; } ;
246 std::vector<Reel *> getReelList() { return this->vec_reel; } ;
249 AssetList *asset_list;
257 string s_content_title;
258 string s_content_kind;
259 /* TODO: ContentVersion, RatingList, signer and signature */
261 std::vector<Reel *> vec_reel;
262 int DummyParse(string p_node, int p_type);
263 int ParseReelList(string p_node, int p_type);
267 class PKL : public XmlFile
270 PKL ( demux_t * p_demux, string s_path, AssetList *asset_list,
276 CPL *getCPL(int pos) { return this->vec_cpl[pos]; };
279 AssetList *asset_list;
289 std::vector<CPL *> vec_cpl;
291 int ParseAssetList(string p_node, int p_type);
292 int ParseAsset(string p_node, int p_type);
293 int ParseSigner(string p_node, int p_type);
294 int ParseSignature(string p_node, int p_type);
298 class AssetMap : public XmlFile {
301 AssetMap( demux_t * p_demux, string s_path, dcp_t *_p_dcp)
302 : XmlFile( p_demux, s_path ), p_dcp( _p_dcp) {};
305 static Asset * getAssetById(AssetList*, const string p_id);
311 int ParseAssetList (xml_reader_t *p_xmlReader, const string p_node, int p_type);
313 #endif /* _DCPPARSER_H */