1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2007 libmkv
7 * Authors: Nathan Caldwell
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
27 int mk_createChapterSimple(mk_Writer
*w
, uint64_t start
, uint64_t end
, char *name
)
31 if (w
->chapters
== NULL
)
33 if ((w
->chapters
= mk_createContext(w
, w
->root
, 0x1043a770)) == NULL
) // Chapters
35 if ((w
->edition_entry
= mk_createContext(w
, w
->chapters
, 0x45b9)) == NULL
) // EditionEntry
37 CHECK(mk_writeUInt(w
->edition_entry
, 0x45db, 1)); // EditionFlagDefault - Force this to be the default.
38 CHECK(mk_writeUInt(w
->edition_entry
, 0x45dd, 0)); // EditionFlagOrdered - Force simple chapters.
40 if ((ca
= mk_createContext(w
, w
->edition_entry
, 0xb6)) == NULL
) // ChapterAtom
42 CHECK(mk_writeUInt(ca
, 0x73c4, ++w
->chapter_uid
));
43 CHECK(mk_writeUInt(ca
, 0x91, start
)); // ChapterTimeStart
44 if (end
!= start
) // Just create a StartTime if chapter length would be 0.
45 CHECK(mk_writeUInt(ca
, 0x92, end
)); // ChapterTimeEnd
47 if ((cd
= mk_createContext(w
, ca
, 0x80)) == NULL
) // ChapterDisplay
49 CHECK(mk_writeStr(cd
, 0x85, name
)); // ChapterDisplay
50 CHECK(mk_closeContext(cd
, 0));
52 CHECK(mk_closeContext(ca
, 0));
57 int mk_writeChapters(mk_Writer
*w
) {
58 if ((w
->chapters
== NULL
) || (w
->edition_entry
== NULL
))
60 CHECK(mk_closeContext(w
->edition_entry
, 0));
61 CHECK(mk_closeContext(w
->chapters
, 0));