1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18 #include "copyrightatom.h"
19 #include "atomutils.h"
20 #include "atomdefs.h"
21
CopyRightAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)22 CopyRightAtom::CopyRightAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
23 : FullAtom(fp, size, type)
24 {
25 uint32 count = getDefaultSize();
26
27 if (_success)
28 {
29 if (!AtomUtils::read16(fp, _language_code))
30 {
31 _success = false;
32 _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
33 }
34
35 count += 2;
36
37 if (count <= _size)
38 {
39 uint32 delta = (_size - count);
40 MP4FFParserOriginalCharEnc CharType;
41
42 if (delta > 0)
43 {
44 if (!AtomUtils::readString(fp, delta, CharType , _copyRightNotice))
45 {
46 //error
47 _success = false;
48 _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
49 return;
50 }
51 count += delta;
52 }
53 else
54 {
55 //error
56 _success = false;
57 _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
58 return;
59 }
60
61 if (count < _size)
62 {
63 AtomUtils::seekFromCurrPos(fp, (_size - count));
64 count = _size;
65 }
66 }
67 else if (count > _size)
68 {
69 _success = false;
70 _mp4ErrorCode = READ_USER_DATA_ATOM_FAILED;
71 return;
72 }
73 }
74 else
75 {
76 if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
77 _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
78 }
79 }
80
81
82 // Destructor
~CopyRightAtom()83 CopyRightAtom::~CopyRightAtom()
84 {
85 }
86
87