1 /*******************************************************************************
2  ndhd.c
3 
4  libquicktime - A library for reading and writing quicktime/avi/mp4 files.
5  http://libquicktime.sourceforge.net
6 
7  Copyright (C) 2002 Heroine Virtual Ltd.
8  Copyright (C) 2002-2011 Members of the libquicktime project.
9 
10  This library is free software; you can redistribute it and/or modify it under
11  the terms of the GNU Lesser General Public License as published by the Free
12  Software Foundation; either version 2.1 of the License, or (at your option)
13  any later version.
14 
15  This library is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
18  details.
19 
20  You should have received a copy of the GNU Lesser General Public License along
21  with this library; if not, write to the Free Software Foundation, Inc., 51
22  Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 *******************************************************************************/
24 
25 #include "lqt_private.h"
26 
quicktime_ndhd_init(quicktime_ndhd_t * ndhd)27 int quicktime_ndhd_init(quicktime_ndhd_t *ndhd)
28 {
29        ndhd->version = 2;
30        ndhd->revision = 0;
31        ndhd->nodeType[0] = 'o';
32        ndhd->nodeType[1] = 'b';
33        ndhd->nodeType[2] = 'j';
34        ndhd->nodeType[3] = 'e';
35        ndhd->nodeID = 1;
36        ndhd->nameAtomID = 0;
37        ndhd->commentAtomID = 0;
38        return 0;
39 }
40 
quicktime_ndhd_delete(quicktime_ndhd_t * ndhd)41 int quicktime_ndhd_delete(quicktime_ndhd_t *ndhd)
42 {
43     return 0;
44 }
45 
quicktime_ndhd_dump(quicktime_ndhd_t * ndhd)46 void quicktime_ndhd_dump(quicktime_ndhd_t *ndhd)
47 {
48        lqt_dump("node header (ndhd)\n");
49        lqt_dump(" version %i\n", ndhd->version );
50        lqt_dump(" revision %i\n", ndhd->revision );
51 
52        lqt_dump(" node type %c%c%c%c\n", ndhd->nodeType[0],ndhd->nodeType[1],ndhd->nodeType[2],ndhd->nodeType[3] );
53        lqt_dump(" node id %ld\n", ndhd->nodeID );
54        lqt_dump(" name atom id %ld\n", ndhd->nameAtomID );
55        lqt_dump(" comment atom id %ld\n", ndhd->commentAtomID );
56 }
57 
quicktime_read_ndhd(quicktime_t * file,quicktime_ndhd_t * ndhd)58 int quicktime_read_ndhd(quicktime_t *file, quicktime_ndhd_t *ndhd)
59 {
60        ndhd->version = quicktime_read_int16(file);
61        ndhd->revision = quicktime_read_int16(file);
62 
63        quicktime_read_char32(file, ndhd->nodeType);
64        ndhd->nodeID = quicktime_read_int32(file);
65        ndhd->nameAtomID = quicktime_read_int32(file);
66        ndhd->commentAtomID = quicktime_read_int32(file);
67 
68        return 0;
69 }
70 
quicktime_write_ndhd(quicktime_t * file,quicktime_ndhd_t * ndhd)71 void quicktime_write_ndhd(quicktime_t *file, quicktime_ndhd_t *ndhd)
72 {
73     	quicktime_write_int16(file, ndhd->version);
74     	quicktime_write_int16(file, ndhd->revision);
75 	quicktime_write_char32(file, ndhd->nodeType);
76 	quicktime_write_int32(file, ndhd->nodeID);
77     	quicktime_write_int32(file, ndhd->nameAtomID);
78     	quicktime_write_int32(file, ndhd->commentAtomID);
79     	quicktime_write_int32(file, ndhd->reserved1);
80     	quicktime_write_int32(file, ndhd->reserved2);
81 
82 	return;
83 }
84 
85