Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2010-04-09 18:12:59 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2010-04-09 18:12:59 +0400
commitefbc9d9043ff8ff92716ddd00a5f61412d535593 (patch)
tree8f3e621f756cf1f5b4d64d97964c7e7abd8aaf08 /src/filters/parser/MP4Splitter/AP4
parentdf6b139a6d9027156f614b68687e039e3a5854db (diff)
revert r1783
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1785 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/MP4Splitter/AP4')
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.cpp172
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.h24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.cpp266
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.h24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.cpp216
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.h177
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.cpp183
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.h19
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4.h74
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.cpp28
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.h29
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Array.h93
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.cpp374
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.h476
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.cpp625
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.h27
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.cpp264
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.h14
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.cpp140
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.h46
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.cpp312
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.h94
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.cpp42
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.h24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.cpp42
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.h27
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.cpp50
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.h14
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.cpp2
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.h15
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.cpp31
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.h6
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.cpp75
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.h23
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.cpp56
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.h18
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.cpp57
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.h30
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.cpp14
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.h22
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Debug.cpp2
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.cpp39
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.h39
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.cpp18
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.h9
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.cpp8
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.h38
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.cpp63
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.h6
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.cpp27
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.h2
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.cpp47
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.h19
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.cpp108
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.h42
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.cpp24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.h11
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.cpp42
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.h38
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.cpp48
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.h77
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileByteStream.h56
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.cpp7
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.h3
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.cpp74
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.h14
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.cpp199
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.h37
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.cpp4
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.h12
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.cpp28
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.h50
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.cpp26
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.h24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.cpp22
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.h32
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.cpp49
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.h34
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.cpp128
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.h21
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.cpp18
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.h4
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.cpp42
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.h17
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Interfaces.h2
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.cpp22
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.h11
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.cpp97
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.h83
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.cpp26
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.h2
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.cpp24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.h17
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.cpp7
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.h10
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.cpp244
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.h38
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.cpp143
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.h50
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4List.h203
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.cpp747
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.h61
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.cpp71
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.h29
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.cpp27
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.h16
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.cpp10
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.h14
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.cpp18
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.h13
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.cpp192
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.h13
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.cpp89
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.h22
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.cpp88
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.h19
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.cpp545
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.h59
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.cpp65
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.h24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.cpp8
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.h4
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.cpp204
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.h102
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.cpp18
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.h17
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.cpp42
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.h18
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.cpp21
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.h19
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.cpp59
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.h50
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.cpp716
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.h62
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.cpp837
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.h116
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.cpp305
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.h101
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.cpp890
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.h106
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Results.cpp75
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.cpp17
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.h10
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.cpp212
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.h140
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.cpp2
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.h4
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.cpp12
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.h100
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.cpp505
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.h211
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.cpp669
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.h205
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.cpp24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.h24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.cpp97
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.h13
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.cpp88
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.h23
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.cpp17
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.h7
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.cpp14
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.h4
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.cpp57
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.h16
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.cpp60
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.h30
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.cpp119
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.h25
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.cpp52
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.h2
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.cpp42
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.h13
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.cpp79
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.h16
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.cpp86
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.h28
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.cpp123
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.h41
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.cpp89
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.h66
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.cpp350
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.h16
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.cpp4
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.h10
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.cpp70
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.h51
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.cpp199
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.h58
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.cpp166
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.h22
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.cpp24
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.h18
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.cpp10
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.h41
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.cpp132
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.h28
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Types.h29
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.cpp41
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.h4
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.cpp177
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.h61
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.cpp82
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.h21
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.cpp16
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.h4
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.cpp614
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.h22
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.cpp296
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.h9
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.cpp78
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.h6
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.cpp232
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.h49
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.cpp1021
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.h337
216 files changed, 8510 insertions, 11834 deletions
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.cpp
index 0a1aaf518..1e46bbcee 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.cpp
@@ -40,7 +40,7 @@
#define AP4_ADTS_SYNC_MASK 0xFFF6 /* 12 sync bits plus 2 layer bits */
#define AP4_ADTS_SYNC_PATTERN 0xFFF0 /* 12 sync bits=1 layer=0 */
-const unsigned long
+const unsigned long
AP4_AdtsSamplingFrequencyTable[16] =
{
96000,
@@ -67,15 +67,15 @@ AP4_AdtsSamplingFrequencyTable[16] =
AP4_AdtsHeader::AP4_AdtsHeader(const AP4_UI08* bytes)
{
// fixed part
- m_Id = (bytes[1] & 0x08) >> 3;
+ m_Id = ( bytes[1] & 0x08) >> 3;
m_ProtectionAbsent = bytes[1] & 0x01;
- m_ProfileObjectType = (bytes[2] & 0xC0) >> 6;
- m_SamplingFrequencyIndex = (bytes[2] & 0x3C) >> 2;
- m_ChannelConfiguration = ((bytes[2] & 0x01) << 2) |
+ m_ProfileObjectType = ( bytes[2] & 0xC0) >> 6;
+ m_SamplingFrequencyIndex = ( bytes[2] & 0x3C) >> 2;
+ m_ChannelConfiguration = ((bytes[2] & 0x01) << 2) |
((bytes[3] & 0xC0) >> 6);
// variable part
m_FrameLength = ((unsigned int)(bytes[3] & 0x03) << 11) |
- ((unsigned int)(bytes[4]) << 3) |
+ ((unsigned int)(bytes[4] ) << 3) |
((unsigned int)(bytes[5] & 0xE0) >> 5);
m_RawDataBlocks = bytes[6] & 0x03;
}
@@ -89,15 +89,12 @@ AP4_AdtsHeader::AP4_AdtsHeader(const AP4_UI08* bytes)
bool
AP4_AdtsHeader::MatchFixed(unsigned char* a, unsigned char* b)
{
- if(a[0] == b[0] &&
- a[1] == b[1] &&
- a[2] == b[2] &&
- (a[3] & 0xF0) == (b[3] & 0xF0))
- {
+ if (a[0] == b[0] &&
+ a[1] == b[1] &&
+ a[2] == b[2] &&
+ (a[3] & 0xF0) == (b[3] & 0xF0)) {
return true;
- }
- else
- {
+ } else {
return false;
}
}
@@ -109,14 +106,12 @@ AP4_Result
AP4_AdtsHeader::Check()
{
// check that the sampling frequency index is valid
- if(m_SamplingFrequencyIndex >= 0xD)
- {
+ if (m_SamplingFrequencyIndex >= 0xD) {
return AP4_FAILURE;
}
/* MPEG2 does not use all profiles */
- if(m_Id == 1 && m_ProfileObjectType == 3)
- {
+ if (m_Id == 1 && m_ProfileObjectType == 3) {
return AP4_FAILURE;
}
@@ -152,7 +147,7 @@ AP4_AdtsParser::Reset()
| AP4_AdtsParser::Feed
+----------------------------------------------------------------------*/
AP4_Result
-AP4_AdtsParser::Feed(const AP4_UI08* buffer,
+AP4_AdtsParser::Feed(const AP4_UI08* buffer,
AP4_Size* buffer_size,
AP4_Flags flags)
{
@@ -162,19 +157,18 @@ AP4_AdtsParser::Feed(const AP4_UI08* buffer,
m_Bits.m_Flags = flags;
/* possible shortcut */
- if(buffer == NULL ||
- buffer_size == NULL ||
- *buffer_size == 0)
- {
+ if (buffer == NULL ||
+ buffer_size == NULL ||
+ *buffer_size == 0) {
return AP4_SUCCESS;
}
/* see how much data we can write */
free_space = m_Bits.GetBytesFree();
- if(*buffer_size > free_space) *buffer_size = free_space;
+ if (*buffer_size > free_space) *buffer_size = free_space;
/* write the data */
- return m_Bits.WriteBytes(buffer, *buffer_size);
+ return m_Bits.WriteBytes(buffer, *buffer_size);
}
/*----------------------------------------------------------------------+
@@ -183,30 +177,26 @@ AP4_AdtsParser::Feed(const AP4_UI08* buffer,
AP4_Result
AP4_AdtsParser::FindHeader(AP4_UI08* header)
{
- int available = m_Bits.GetBytesAvailable();
- unsigned int sync = 0;
- long nbr_skipped_bytes = 0;
-
- /* look for the sync pattern */
- while(available-- >= AP4_ADTS_HEADER_SIZE)
- {
- sync = (m_Bits.ReadByte() << 8) | m_Bits.PeekByte();
-
- if((sync & AP4_ADTS_SYNC_MASK) == AP4_ADTS_SYNC_PATTERN)
- {
- /* found a sync pattern, read the rest of the header */
- header[0] = (sync >> 8) & 0xFF;
- m_Bits.ReadBytes(&header[1], AP4_ADTS_HEADER_SIZE - 1);
-
- return AP4_SUCCESS;
- }
- else
- {
- ++ nbr_skipped_bytes;
- }
- }
-
- return AP4_ERROR_NOT_ENOUGH_DATA;
+ int available = m_Bits.GetBytesAvailable();
+ unsigned int sync = 0;
+ long nbr_skipped_bytes = 0;
+
+ /* look for the sync pattern */
+ while (available-- >= AP4_ADTS_HEADER_SIZE) {
+ sync = (m_Bits.ReadByte() << 8) | m_Bits.PeekByte();
+
+ if ((sync & AP4_ADTS_SYNC_MASK) == AP4_ADTS_SYNC_PATTERN) {
+ /* found a sync pattern, read the rest of the header */
+ header[0] = (sync >> 8) & 0xFF;
+ m_Bits.ReadBytes(&header[1], AP4_ADTS_HEADER_SIZE-1);
+
+ return AP4_SUCCESS;
+ } else {
+ ++ nbr_skipped_bytes;
+ }
+ }
+
+ return AP4_ERROR_NOT_ENOUGH_DATA;
}
/*----------------------------------------------------------------------+
@@ -221,85 +211,77 @@ AP4_AdtsParser::FindFrame(AP4_AacFrame& frame)
/* align to the start of the next byte */
m_Bits.ByteAlign();
-
+
/* find a frame header */
result = FindHeader(raw_header);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
/* parse the header */
AP4_AdtsHeader adts_header(raw_header);
/* check the header */
result = adts_header.Check();
- if(AP4_FAILED(result)) goto fail;
-
+ if (AP4_FAILED(result)) goto fail;
+
/* check that we have enough data to peek at the next header */
available = AP4_ADTS_HEADER_SIZE + m_Bits.GetBytesAvailable();
- if(m_Bits.m_Flags & AP4_BITSTREAM_FLAG_EOS)
- {
+ if (m_Bits.m_Flags & AP4_BITSTREAM_FLAG_EOS) {
/* we're at the end of the stream, we only need the entire frame */
- if(available < adts_header.m_FrameLength)
- {
+ if (available < adts_header.m_FrameLength) {
return AP4_ERROR_NOT_ENOUGH_DATA;
- }
- }
- else
- {
+ }
+ } else {
/* peek at the header of the next frame */
unsigned char peek_raw_header[AP4_ADTS_HEADER_SIZE];
- if(available < adts_header.m_FrameLength + AP4_ADTS_HEADER_SIZE)
- {
+ if (available < adts_header.m_FrameLength+AP4_ADTS_HEADER_SIZE) {
return AP4_ERROR_NOT_ENOUGH_DATA;
- }
- m_Bits.SkipBytes(adts_header.m_FrameLength - AP4_ADTS_HEADER_SIZE);
+ }
+ m_Bits.SkipBytes(adts_header.m_FrameLength-AP4_ADTS_HEADER_SIZE);
m_Bits.PeekBytes(peek_raw_header, AP4_ADTS_HEADER_SIZE);
- m_Bits.SkipBytes(-((int)adts_header.m_FrameLength - AP4_ADTS_HEADER_SIZE));
+ m_Bits.SkipBytes(-((int)adts_header.m_FrameLength-AP4_ADTS_HEADER_SIZE));
/* check the header */
AP4_AdtsHeader peek_adts_header(peek_raw_header);
result = peek_adts_header.Check();
- if(AP4_FAILED(result)) goto fail;
+ if (AP4_FAILED(result)) goto fail;
/* check that the fixed part of this header is the same as the */
/* fixed part of the previous header */
- if(!AP4_AdtsHeader::MatchFixed(peek_raw_header, raw_header))
- {
+ if (!AP4_AdtsHeader::MatchFixed(peek_raw_header, raw_header)) {
goto fail;
}
}
/* fill in the frame info */
- frame.m_Info.m_Standard = (adts_header.m_Id == 1 ?
- AP4_AAC_STANDARD_MPEG2 :
- AP4_AAC_STANDARD_MPEG4);
- switch(adts_header.m_ProfileObjectType)
- {
- case 0:
- frame.m_Info.m_Profile = AP4_AAC_PROFILE_MAIN;
- break;
-
- case 1:
- frame.m_Info.m_Profile = AP4_AAC_PROFILE_LC;
- break;
-
- case 2:
- frame.m_Info.m_Profile = AP4_AAC_PROFILE_SSR;
- break;
-
- case 3:
- frame.m_Info.m_Profile = AP4_AAC_PROFILE_LTP;
+ frame.m_Info.m_Standard = (adts_header.m_Id == 1 ?
+ AP4_AAC_STANDARD_MPEG2 :
+ AP4_AAC_STANDARD_MPEG4);
+ switch (adts_header.m_ProfileObjectType) {
+ case 0:
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_MAIN;
+ break;
+
+ case 1:
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_LC;
+ break;
+
+ case 2:
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_SSR;
+ break;
+
+ case 3:
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_LTP;
}
- frame.m_Info.m_FrameLength = adts_header.m_FrameLength - AP4_ADTS_HEADER_SIZE;
+ frame.m_Info.m_FrameLength = adts_header.m_FrameLength-AP4_ADTS_HEADER_SIZE;
frame.m_Info.m_ChannelConfiguration = adts_header.m_ChannelConfiguration;
frame.m_Info.m_SamplingFrequencyIndex = adts_header.m_SamplingFrequencyIndex;
frame.m_Info.m_SamplingFrequency = AP4_AdtsSamplingFrequencyTable[adts_header.m_SamplingFrequencyIndex];
/* skip crc if present */
- if(adts_header.m_ProtectionAbsent == 0)
- {
+ if (adts_header.m_ProtectionAbsent == 0) {
m_Bits.SkipBits(16);
- }
+ }
/* set the frame source */
frame.m_Source = &m_Bits;
@@ -319,7 +301,7 @@ fail:
AP4_Size
AP4_AdtsParser::GetBytesFree()
{
- return (m_Bits.GetBytesFree());
+ return (m_Bits.GetBytesFree());
}
@@ -327,10 +309,10 @@ AP4_AdtsParser::GetBytesFree()
/*----------------------------------------------------------------------+
| AP4_AdtsParser::GetBytesAvailable
+----------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_AdtsParser::GetBytesAvailable()
{
- return (m_Bits.GetBytesAvailable());
+ return (m_Bits.GetBytesAvailable());
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.h b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.h
index 8b5b4e8da..1db5f27b4 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AdtsParser.h
@@ -43,12 +43,11 @@ extern const unsigned long AP4_AdtsSamplingFrequencyTable[16];
/*----------------------------------------------------------------------
| types
+---------------------------------------------------------------------*/
-class AP4_AdtsHeader
-{
+class AP4_AdtsHeader {
public:
// constructor
AP4_AdtsHeader(const AP4_UI08* bytes);
-
+
// methods
AP4_Result Check();
@@ -69,38 +68,33 @@ public:
static bool MatchFixed(unsigned char* a, unsigned char* b);
};
-typedef enum
-{
+typedef enum {
AP4_AAC_STANDARD_MPEG2,
AP4_AAC_STANDARD_MPEG4
} AP4_AacStandard;
-typedef enum
-{
+typedef enum {
AP4_AAC_PROFILE_MAIN,
AP4_AAC_PROFILE_LC,
AP4_AAC_PROFILE_SSR,
AP4_AAC_PROFILE_LTP
} AP4_AacProfile;
-typedef struct
-{
+typedef struct {
AP4_AacStandard m_Standard;
AP4_AacProfile m_Profile;
unsigned int m_SamplingFrequencyIndex;
unsigned long m_SamplingFrequency;
unsigned int m_ChannelConfiguration;
- unsigned int m_FrameLength;
+ unsigned int m_FrameLength;
} AP4_AacFrameInfo;
-typedef struct
-{
+typedef struct {
AP4_BitStream* m_Source;
AP4_AacFrameInfo m_Info;
} AP4_AacFrame;
-class AP4_AdtsParser
-{
+class AP4_AdtsParser {
public:
// constructor and destructor
AP4_AdtsParser();
@@ -108,7 +102,7 @@ public:
// methods
AP4_Result Reset();
- AP4_Result Feed(const AP4_UI08* buffer,
+ AP4_Result Feed(const AP4_UI08* buffer,
AP4_Size* buffer_size,
AP4_Flags flags = 0);
AP4_Result FindFrame(AP4_AacFrame& frame);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.cpp
index 3d7608c39..ad568459d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.cpp
@@ -38,46 +38,26 @@
const char*
AP4_AvcParser::NaluTypeName(unsigned int nalu_type)
{
- switch(nalu_type)
- {
- case 0:
- return "Unspecified";
- case 1:
- return "Coded slice of a non-IDR picture";
- case 2:
- return "Coded slice data partition A";
- case 3:
- return "Coded slice data partition B";
- case 4:
- return "Coded slice data partition C";
- case 5:
- return "Coded slice of an IDR picture";
- case 6:
- return "Supplemental enhancement information (SEI)";
- case 7:
- return "Sequence parameter set";
- case 8:
- return "Picture parameter set";
- case 9:
- return "Access unit delimiter";
- case 10:
- return "End of sequence";
- case 11:
- return "End of stream";
- case 12:
- return "Filler data";
- case 13:
- return "Sequence parameter set extension";
- case 14:
- return "Prefix NAL unit in scalable extension";
- case 15:
- return "Subset sequence parameter set";
- case 19:
- return "Coded slice of an auxiliary coded picture without partitioning";
- case 20:
- return "Coded slice in scalable extension";
- default:
- return NULL;
+ switch (nalu_type) {
+ case 0: return "Unspecified";
+ case 1: return "Coded slice of a non-IDR picture";
+ case 2: return "Coded slice data partition A";
+ case 3: return "Coded slice data partition B";
+ case 4: return "Coded slice data partition C";
+ case 5: return "Coded slice of an IDR picture";
+ case 6: return "Supplemental enhancement information (SEI)";
+ case 7: return "Sequence parameter set";
+ case 8: return "Picture parameter set";
+ case 9: return "Access unit delimiter";
+ case 10: return "End of sequence";
+ case 11: return "End of stream";
+ case 12: return "Filler data";
+ case 13: return "Sequence parameter set extension";
+ case 14: return "Prefix NAL unit in scalable extension";
+ case 15: return "Subset sequence parameter set";
+ case 19: return "Coded slice of an auxiliary coded picture without partitioning";
+ case 20: return "Coded slice in scalable extension";
+ default: return NULL;
}
}
@@ -87,26 +67,16 @@ AP4_AvcParser::NaluTypeName(unsigned int nalu_type)
const char*
AP4_AvcParser::PrimaryPicTypeName(unsigned int primary_pic_type)
{
- switch(primary_pic_type)
- {
- case 0:
- return "I";
- case 1:
- return "I, P";
- case 2:
- return "I, P, B";
- case 3:
- return "SI";
- case 4:
- return "SI, SP";
- case 5:
- return "I, SI";
- case 6:
- return "I, SI, P, SP";
- case 7:
- return "I, SI, P, SP, B";
- default:
- return NULL;
+ switch (primary_pic_type) {
+ case 0: return "I";
+ case 1: return "I, P";
+ case 2: return "I, P, B";
+ case 3: return "SI";
+ case 4: return "SI, SP";
+ case 5: return "I, SI";
+ case 6: return "I, SI, P, SP";
+ case 7: return "I, SI, P, SP, B";
+ default: return NULL;
}
}
@@ -116,30 +86,18 @@ AP4_AvcParser::PrimaryPicTypeName(unsigned int primary_pic_type)
const char*
AP4_AvcParser::SliceTypeName(unsigned int slice_type)
{
- switch(slice_type)
- {
- case 0:
- return "P";
- case 1:
- return "B";
- case 2:
- return "I";
- case 3:
- return "SP";
- case 4:
- return "SI";
- case 5:
- return "P";
- case 6:
- return "B";
- case 7:
- return "I";
- case 8:
- return "SP";
- case 9:
- return "SI";
- default:
- return NULL;
+ switch (slice_type) {
+ case 0: return "P";
+ case 1: return "B";
+ case 2: return "I";
+ case 3: return "SP";
+ case 4: return "SI";
+ case 5: return "P";
+ case 6: return "B";
+ case 7: return "I";
+ case 8: return "SP";
+ case 9: return "SI";
+ default: return NULL;
}
}
@@ -155,9 +113,9 @@ AP4_AvcParser::AP4_AvcParser() :
/*----------------------------------------------------------------------
| AP4_AvcParser::Feed
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AvcParser::Feed(const void* data,
- AP4_Size data_size,
+AP4_Result
+AP4_AvcParser::Feed(const void* data,
+ AP4_Size data_size,
AP4_Size& bytes_consumed,
const AP4_DataBuffer*& nalu,
bool is_eos)
@@ -165,113 +123,95 @@ AP4_AvcParser::Feed(const void* data,
// default return values
nalu = NULL;
bytes_consumed = 0;
-
+
// iterate the state machine
unsigned int data_offset;
unsigned int payload_start = 0;
unsigned int payload_end = 0;
bool found_nalu = false;
- for(data_offset = 0; data_offset < data_size && !found_nalu; data_offset++)
- {
+ for (data_offset=0; data_offset<data_size && !found_nalu; data_offset++) {
unsigned char byte = ((const unsigned char*)data)[data_offset];
- switch(m_State)
- {
- case STATE_RESET:
- if(byte == 0)
- {
- m_State = STATE_START_CODE_1;
- }
- break;
-
- case STATE_START_CODE_1:
- if(byte == 0)
- {
- m_State = STATE_START_CODE_2;
- }
- else
- {
- m_State = STATE_RESET;
- }
- break;
-
- case STATE_START_CODE_2:
- if(byte == 0) break;
- if(byte == 1)
- {
- m_State = STATE_START_NALU;
- }
- else
- {
- m_State = STATE_RESET;
- }
- break;
-
- case STATE_START_NALU:
- m_Buffer.SetDataSize(0);
- m_ZeroTrail = 0;
- payload_start = payload_end = data_offset;
- m_State = STATE_IN_NALU;
- // FALLTHROUGH
-
- case STATE_IN_NALU:
- if(byte == 0)
- {
- m_ZeroTrail++;
+ switch (m_State) {
+ case STATE_RESET:
+ if (byte == 0) {
+ m_State = STATE_START_CODE_1;
+ }
+ break;
+
+ case STATE_START_CODE_1:
+ if (byte == 0) {
+ m_State = STATE_START_CODE_2;
+ } else {
+ m_State = STATE_RESET;
+ }
break;
- }
- if(m_ZeroTrail >= 2)
- {
- if(byte == 1)
- {
- found_nalu = true;
+
+ case STATE_START_CODE_2:
+ if (byte == 0) break;
+ if (byte == 1) {
m_State = STATE_START_NALU;
+ } else {
+ m_State = STATE_RESET;
}
- else
- {
- payload_end += m_ZeroTrail + 1;
+ break;
+
+ case STATE_START_NALU:
+ m_Buffer.SetDataSize(0);
+ m_ZeroTrail = 0;
+ payload_start = payload_end = data_offset;
+ m_State = STATE_IN_NALU;
+ // FALLTHROUGH
+
+ case STATE_IN_NALU:
+ if (byte == 0) {
+ m_ZeroTrail++;
+ break;
+ }
+ if (m_ZeroTrail >= 2) {
+ if (byte == 1) {
+ found_nalu = true;
+ m_State = STATE_START_NALU;
+ } else {
+ payload_end += m_ZeroTrail+1;
+ }
+ } else {
+ payload_end += m_ZeroTrail+1;
}
- }
- else
- {
- payload_end += m_ZeroTrail + 1;
- }
- m_ZeroTrail = 0;
- break;
+ m_ZeroTrail = 0;
+ break;
}
}
- if(is_eos && m_State == STATE_IN_NALU && data_offset == data_size)
- {
+ if (is_eos && m_State == STATE_IN_NALU && data_offset == data_size) {
found_nalu = true;
m_ZeroTrail = 0;
m_State = STATE_RESET;
}
- if(payload_end > payload_start)
- {
+ if (payload_end > payload_start) {
AP4_Size current_payload_size = m_Buffer.GetDataSize();
- m_Buffer.SetDataSize(m_Buffer.GetDataSize() + (payload_end - payload_start));
- AP4_CopyMemory(((unsigned char *)m_Buffer.UseData()) + current_payload_size,
- ((const unsigned char*)data) + payload_start,
- payload_end - payload_start);
+ m_Buffer.SetDataSize(m_Buffer.GetDataSize()+(payload_end-payload_start));
+ AP4_CopyMemory(((unsigned char *)m_Buffer.UseData())+current_payload_size,
+ ((const unsigned char*)data)+payload_start,
+ payload_end-payload_start);
}
-
+
// compute how many bytes we have consumed
bytes_consumed = data_offset;
-
+
// return the NALU if we found one
- if(found_nalu) nalu = &m_Buffer;
-
+ if (found_nalu) nalu = &m_Buffer;
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_AvcParser::Reset
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_AvcParser::Reset()
{
m_State = STATE_RESET;
m_ZeroTrail = 0;
m_Buffer.SetDataSize(0);
-
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.h b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.h
index 3f9aac33f..ffb626c94 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4AvcParser.h
@@ -39,15 +39,14 @@
/*----------------------------------------------------------------------
| AP4_AvcParser
+---------------------------------------------------------------------*/
-class AP4_AvcParser
-{
+class AP4_AvcParser {
public:
static const char* NaluTypeName(unsigned int nalu_type);
static const char* PrimaryPicTypeName(unsigned int primary_pic_type);
static const char* SliceTypeName(unsigned int slice_type);
-
+
AP4_AvcParser();
-
+
/**
* Feed some data to the parser and look for the next NAL Unit.
*
@@ -57,34 +56,33 @@ public:
* @param bytes_consumed: Number of bytes from the data buffer that were
* consumed and stored by the parser.
* @param nalu: Reference to a pointer to a buffer object that contains
- * a NAL unit found in the previously fed data, or a NULL pointer if no
+ * a NAL unit found in the previously fed data, or a NULL pointer if no
* NAL unit can be found so far.
* @param eos: Boolean flag that indicates if this buffer is the last
* buffer in the stream/file (End Of Stream).
*
* @result: AP4_SUCCESS is the call succeeds, or an error code if it
* fails.
- *
+ *
* The caller must not feed the same data twice. When this method
* returns, the caller should inspect the value of bytes_consumed and
* advance the input stream source accordingly, such that the next
* buffer passed to this method will be exactly bytes_consumed bytes
* after what was passed in this call.
*/
- AP4_Result Feed(const void* data,
- AP4_Size data_size,
+ AP4_Result Feed(const void* data,
+ AP4_Size data_size,
AP4_Size& bytes_consumed,
const AP4_DataBuffer*& nalu,
- bool eos = false);
-
+ bool eos=false);
+
/**
* Reset the state of the parser (for example, to parse a new stream).
*/
AP4_Result Reset();
-
+
private:
- enum
- {
+ enum {
STATE_RESET,
STATE_START_CODE_1,
STATE_START_CODE_2,
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.cpp
index 57a1d8afe..0e1ebd596 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.cpp
@@ -72,11 +72,11 @@ AP4_BitStream::Reset()
/*----------------------------------------------------------------------
| AP4_BitStream::ByteAlign
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_BitStream::ByteAlign()
{
unsigned int to_flush = m_BitsCached & 7;
- if(to_flush > 0) SkipBits(to_flush);
+ if (to_flush > 0) SkipBits(to_flush);
return AP4_SUCCESS;
}
@@ -87,11 +87,11 @@ AP4_BitStream::ByteAlign()
AP4_Size
AP4_BitStream::GetContiguousBytesFree()
{
- return
+ return
(m_In < m_Out) ?
(m_Out - m_In - 1) :
(m_Out == 0 ? (AP4_BITSTREAM_BUFFER_SIZE - m_In - 1) :
- (AP4_BITSTREAM_BUFFER_SIZE - m_In));
+ (AP4_BITSTREAM_BUFFER_SIZE - m_In));
}
/*----------------------------------------------------------------------
@@ -100,9 +100,9 @@ AP4_BitStream::GetContiguousBytesFree()
AP4_Size
AP4_BitStream::GetBytesFree()
{
- return
- (m_In < m_Out) ?
- (m_Out - m_In - 1) :
+ return
+ (m_In < m_Out) ?
+ (m_Out - m_In - 1) :
(AP4_BITSTREAM_BUFFER_SIZE + (m_Out - m_In) - 1);
}
@@ -110,38 +110,33 @@ AP4_BitStream::GetBytesFree()
| AP4_BitStream::WriteBytes
+----------------------------------------------------------------------*/
AP4_Result
-AP4_BitStream::WriteBytes(const AP4_UI08* bytes,
+AP4_BitStream::WriteBytes(const AP4_UI08* bytes,
AP4_Size byte_count)
{
/* check parameters */
- if(byte_count == 0) return AP4_SUCCESS;
- if(bytes == NULL) return AP4_ERROR_INVALID_PARAMETERS;
+ if (byte_count == 0) return AP4_SUCCESS;
+ if (bytes == NULL) return AP4_ERROR_INVALID_PARAMETERS;
/* check that we have enough space */
- if(GetBytesFree() < byte_count)
- {
+ if (GetBytesFree() < byte_count) {
return AP4_FAILURE;
}
/* write the bytes */
- if(m_In < m_Out)
- {
- AP4_CopyMemory(m_Buffer + m_In, bytes, byte_count);
+ if (m_In < m_Out) {
+ AP4_CopyMemory(m_Buffer+m_In, bytes, byte_count);
AP4_BITSTREAM_POINTER_ADD(m_In, byte_count);
- }
- else
- {
+ } else {
unsigned int chunk = AP4_BITSTREAM_BUFFER_SIZE - m_In;
- if(chunk > byte_count) chunk = byte_count;
+ if (chunk > byte_count) chunk = byte_count;
- AP4_CopyMemory(m_Buffer + m_In, bytes, chunk);
+ AP4_CopyMemory(m_Buffer+m_In, bytes, chunk);
AP4_BITSTREAM_POINTER_ADD(m_In, chunk);
- if(chunk != byte_count)
- {
- AP4_CopyMemory(m_Buffer + m_In,
- bytes + chunk, byte_count - chunk);
- AP4_BITSTREAM_POINTER_ADD(m_In, byte_count - chunk);
+ if (chunk != byte_count) {
+ AP4_CopyMemory(m_Buffer+m_In,
+ bytes+chunk, byte_count-chunk);
+ AP4_BITSTREAM_POINTER_ADD(m_In, byte_count-chunk);
}
}
@@ -154,8 +149,8 @@ AP4_BitStream::WriteBytes(const AP4_UI08* bytes,
AP4_Size
AP4_BitStream::GetContiguousBytesAvailable()
{
- return
- (m_Out <= m_In) ?
+ return
+ (m_Out <= m_In) ?
(m_In - m_Out) :
(AP4_BITSTREAM_BUFFER_SIZE - m_Out);
}
@@ -166,8 +161,8 @@ AP4_BitStream::GetContiguousBytesAvailable()
AP4_Size
AP4_BitStream::GetBytesAvailable()
{
- return
- (m_Out <= m_In) ?
+ return
+ (m_Out <= m_In) ?
(m_In - m_Out) :
(m_In + (AP4_BITSTREAM_BUFFER_SIZE - m_Out));
}
@@ -176,105 +171,90 @@ AP4_BitStream::GetBytesAvailable()
| AP4_BitStream::ReadBytes
+----------------------------------------------------------------------*/
AP4_Result
-AP4_BitStream::ReadBytes(AP4_UI08* bytes,
+AP4_BitStream::ReadBytes(AP4_UI08* bytes,
AP4_Size byte_count)
{
- if(byte_count == 0 || bytes == NULL)
- {
- return AP4_ERROR_INVALID_PARAMETERS;
- }
-
- /* Gets bytes from the cache */
- ByteAlign();
- while(m_BitsCached > 0 && byte_count > 0)
- {
- *bytes = ReadBits(8);
- ++ bytes;
- -- byte_count;
- }
-
- /* Get other bytes */
- if(byte_count > 0)
- {
- if(m_Out < m_In)
- {
- AP4_CopyMemory(bytes, m_Buffer + m_Out, byte_count);
- AP4_BITSTREAM_POINTER_ADD(m_Out, byte_count);
- }
- else
- {
- unsigned int chunk = AP4_BITSTREAM_BUFFER_SIZE - m_Out;
- if(chunk >= byte_count) chunk = byte_count;
-
- AP4_CopyMemory(bytes, m_Buffer + m_Out, chunk);
- AP4_BITSTREAM_POINTER_ADD(m_Out, chunk);
-
- if(chunk != byte_count)
- {
- AP4_CopyMemory(bytes + chunk,
- m_Buffer + m_Out,
- byte_count - chunk);
- AP4_BITSTREAM_POINTER_ADD(m_Out, byte_count - chunk);
- }
- }
- }
-
- return AP4_SUCCESS;
+ if (byte_count == 0 || bytes == NULL) {
+ return AP4_ERROR_INVALID_PARAMETERS;
+ }
+
+ /* Gets bytes from the cache */
+ ByteAlign();
+ while (m_BitsCached > 0 && byte_count > 0) {
+ *bytes = ReadBits(8);
+ ++ bytes;
+ -- byte_count;
+ }
+
+ /* Get other bytes */
+ if (byte_count > 0) {
+ if (m_Out < m_In) {
+ AP4_CopyMemory(bytes, m_Buffer + m_Out, byte_count);
+ AP4_BITSTREAM_POINTER_ADD(m_Out, byte_count);
+ } else {
+ unsigned int chunk = AP4_BITSTREAM_BUFFER_SIZE - m_Out;
+ if (chunk >= byte_count) chunk = byte_count;
+
+ AP4_CopyMemory(bytes, m_Buffer+m_Out, chunk);
+ AP4_BITSTREAM_POINTER_ADD(m_Out, chunk);
+
+ if (chunk != byte_count) {
+ AP4_CopyMemory(bytes+chunk,
+ m_Buffer+m_Out,
+ byte_count-chunk);
+ AP4_BITSTREAM_POINTER_ADD(m_Out, byte_count-chunk);
+ }
+ }
+ }
+
+ return AP4_SUCCESS;
}
/*----------------------------------------------------------------------+
| AP4_BitStream::PeekBytes
+----------------------------------------------------------------------*/
AP4_Result
-AP4_BitStream::PeekBytes(AP4_UI08* bytes,
+AP4_BitStream::PeekBytes(AP4_UI08* bytes,
AP4_Size byte_count)
{
- int bits_cached_byte;
-
- if(byte_count == 0 || bytes == NULL)
- {
- return AP4_ERROR_INVALID_PARAMETERS;
- }
-
- /* Gets bytes from the cache */
- bits_cached_byte = m_BitsCached & ~7;
- while(bits_cached_byte > 0 && byte_count > 0)
- {
- *bytes = (m_Cache >> bits_cached_byte) & 0xFF;
- ++ bytes;
- -- byte_count;
- bits_cached_byte -= 8;
- }
-
- /* Get other bytes */
- if(byte_count > 0)
- {
- if(m_In > m_Out)
- {
- AP4_CopyMemory(bytes, m_Buffer + m_Out, byte_count);
- }
- else
- {
- unsigned int out = m_Out;
- unsigned int chunk = AP4_BITSTREAM_BUFFER_SIZE - out;
- if(chunk >= byte_count)
- {
- chunk = byte_count;
- }
-
- AP4_CopyMemory(bytes, m_Buffer + out, chunk);
- AP4_BITSTREAM_POINTER_ADD(out, chunk);
-
- if(chunk != byte_count)
- {
- AP4_CopyMemory(bytes + chunk,
- m_Buffer + out,
- byte_count - chunk);
- }
- }
- }
-
- return AP4_SUCCESS;
+ int bits_cached_byte;
+
+ if (byte_count == 0 || bytes == NULL) {
+ return AP4_ERROR_INVALID_PARAMETERS;
+ }
+
+ /* Gets bytes from the cache */
+ bits_cached_byte = m_BitsCached & ~7;
+ while (bits_cached_byte > 0 && byte_count > 0) {
+ *bytes = (m_Cache >> bits_cached_byte) & 0xFF;
+ ++ bytes;
+ -- byte_count;
+ bits_cached_byte -= 8;
+ }
+
+ /* Get other bytes */
+ if (byte_count > 0) {
+ if (m_In > m_Out) {
+ AP4_CopyMemory(bytes, m_Buffer + m_Out, byte_count);
+ } else {
+ unsigned int out = m_Out;
+ unsigned int chunk = AP4_BITSTREAM_BUFFER_SIZE - out;
+ if (chunk >= byte_count) {
+ chunk = byte_count;
+ }
+
+ AP4_CopyMemory(bytes, m_Buffer+out, chunk);
+ AP4_BITSTREAM_POINTER_ADD(out, chunk);
+
+ if (chunk != byte_count) {
+ AP4_CopyMemory(bytes+chunk,
+ m_Buffer+out,
+ byte_count-chunk);
+ }
+ }
+ }
+
+ return AP4_SUCCESS;
}
/*----------------------------------------------------------------------+
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.h b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.h
index 5697e86d9..c0bb0566e 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4BitStream.h
@@ -40,7 +40,7 @@
+---------------------------------------------------------------------*/
const int AP4_ERROR_BASE_BITSTREAM = -10000;
-// the max frame size we can handle
+// the max frame size we can handle
const unsigned int AP4_BITSTREAM_BUFFER_SIZE = 8192;
// flags
@@ -100,7 +100,7 @@ private:
// methods
AP4_BitsWord ReadCache() const;
};
-
+
/*----------------------------------------------------------------------
| macros
+---------------------------------------------------------------------*/
@@ -121,31 +121,28 @@ private:
inline AP4_BitsWord
AP4_BitStream::ReadCache() const
{
- unsigned int pos = m_Out;
- AP4_BitsWord cache;
+ unsigned int pos = m_Out;
+ AP4_BitsWord cache;
#if AP4_WORD_BITS != 32
#error unsupported word size /* 64 and other word size not yet implemented */
#endif
- if(pos <= AP4_BITSTREAM_BUFFER_SIZE - AP4_WORD_BYTES)
- {
- unsigned char* out_ptr = &m_Buffer[pos];
- cache = (((AP4_BitsWord) out_ptr[0]) << 24)
- | (((AP4_BitsWord) out_ptr[1]) << 16)
- | (((AP4_BitsWord) out_ptr[2]) << 8)
- | (((AP4_BitsWord) out_ptr[3]));
- }
- else
- {
- unsigned char* buf_ptr = m_Buffer;
- cache = (((AP4_BitsWord) buf_ptr[ pos ]) << 24)
- | (((AP4_BitsWord) buf_ptr[AP4_BITSTREAM_POINTER_OFFSET(pos, 1)]) << 16)
- | (((AP4_BitsWord) buf_ptr[AP4_BITSTREAM_POINTER_OFFSET(pos, 2)]) << 8)
- | (((AP4_BitsWord) buf_ptr[AP4_BITSTREAM_POINTER_OFFSET(pos, 3)]));
- }
-
- return cache;
+ if (pos <= AP4_BITSTREAM_BUFFER_SIZE - AP4_WORD_BYTES) {
+ unsigned char* out_ptr = &m_Buffer[pos];
+ cache = (((AP4_BitsWord) out_ptr[0]) << 24)
+ | (((AP4_BitsWord) out_ptr[1]) << 16)
+ | (((AP4_BitsWord) out_ptr[2]) << 8)
+ | (((AP4_BitsWord) out_ptr[3]) );
+ } else {
+ unsigned char* buf_ptr = m_Buffer;
+ cache = (((AP4_BitsWord) buf_ptr[ pos ]) << 24)
+ | (((AP4_BitsWord) buf_ptr[AP4_BITSTREAM_POINTER_OFFSET (pos, 1)]) << 16)
+ | (((AP4_BitsWord) buf_ptr[AP4_BITSTREAM_POINTER_OFFSET (pos, 2)]) << 8)
+ | (((AP4_BitsWord) buf_ptr[AP4_BITSTREAM_POINTER_OFFSET (pos, 3)]) );
+ }
+
+ return cache;
}
/*----------------------------------------------------------------------
@@ -155,14 +152,11 @@ inline AP4_UI32
AP4_BitStream::ReadBits(unsigned int n)
{
AP4_BitsWord result;
- if(m_BitsCached >= n)
- {
+ if (m_BitsCached >= n) {
/* we have enough bits in the cache to satisfy the request */
m_BitsCached -= n;
result = (m_Cache >> m_BitsCached) & AP4_BIT_MASK(n);
- }
- else
- {
+ } else {
/* not enough bits in the cache */
AP4_BitsWord word;
@@ -192,8 +186,7 @@ inline int
AP4_BitStream::ReadBit()
{
AP4_BitsWord result;
- if(m_BitsCached == 0)
- {
+ if (m_BitsCached == 0) {
/* the cache is empty */
/* read the next word into the cache */
@@ -203,9 +196,7 @@ AP4_BitStream::ReadBit()
/* return the first bit */
result = m_Cache >> (AP4_WORD_BITS - 1);
- }
- else
- {
+ } else {
/* get the bit from the cache */
result = (m_Cache >> (--m_BitsCached)) & 1;
}
@@ -218,21 +209,18 @@ AP4_BitStream::ReadBit()
inline AP4_UI32
AP4_BitStream::PeekBits(unsigned int n)
{
- /* we have enough bits in the cache to satisfy the request */
- if(m_BitsCached >= n)
- {
- return (m_Cache >> (m_BitsCached - n)) & AP4_BIT_MASK(n);
- }
- else
- {
- /* not enough bits in the cache, read the next word */
- AP4_BitsWord word = ReadCache();
-
- /* combine the new word and the cache, and update the state */
- AP4_BitsWord cache = m_Cache & AP4_BIT_MASK(m_BitsCached);
- n -= m_BitsCached;
- return (word >> (AP4_WORD_BITS - n)) | (cache << n);
- }
+ /* we have enough bits in the cache to satisfy the request */
+ if (m_BitsCached >= n) {
+ return (m_Cache >> (m_BitsCached - n)) & AP4_BIT_MASK(n);
+ } else {
+ /* not enough bits in the cache, read the next word */
+ AP4_BitsWord word = ReadCache();
+
+ /* combine the new word and the cache, and update the state */
+ AP4_BitsWord cache = m_Cache & AP4_BIT_MASK(m_BitsCached);
+ n -= m_BitsCached;
+ return (word >> (AP4_WORD_BITS - n)) | (cache << n);
+ }
}
/*----------------------------------------------------------------------
@@ -241,20 +229,17 @@ AP4_BitStream::PeekBits(unsigned int n)
inline int
AP4_BitStream::PeekBit()
{
- /* the cache is empty */
- if(m_BitsCached == 0)
- {
- /* read the next word into the cache */
- AP4_BitsWord cache = ReadCache();
-
- /* return the first bit */
- return cache >> (AP4_WORD_BITS - 1);
- }
- else
- {
- /* get the bit from the cache */
- return (m_Cache >> (m_BitsCached - 1)) & 1;
- }
+ /* the cache is empty */
+ if (m_BitsCached == 0) {
+ /* read the next word into the cache */
+ AP4_BitsWord cache = ReadCache();
+
+ /* return the first bit */
+ return cache >> (AP4_WORD_BITS - 1);
+ } else {
+ /* get the bit from the cache */
+ return (m_Cache >> (m_BitsCached-1)) & 1;
+ }
}
/*----------------------------------------------------------------------
@@ -263,30 +248,23 @@ AP4_BitStream::PeekBit()
inline void
AP4_BitStream::SkipBits(unsigned int n)
{
- if(n <= m_BitsCached)
- {
- m_BitsCached -= n;
- }
- else
- {
- n -= m_BitsCached;
- while(n >= AP4_WORD_BITS)
- {
- m_Out = AP4_BITSTREAM_POINTER_OFFSET(m_Out, AP4_WORD_BYTES);
- n -= AP4_WORD_BITS;
- }
- if(n)
- {
- m_Cache = ReadCache();
- m_BitsCached = AP4_WORD_BITS - n;
- m_Out = AP4_BITSTREAM_POINTER_OFFSET(m_Out, AP4_WORD_BYTES);
- }
- else
- {
- m_BitsCached = 0;
- m_Cache = 0;
- }
- }
+ if (n <= m_BitsCached) {
+ m_BitsCached -= n;
+ } else {
+ n -= m_BitsCached;
+ while (n >= AP4_WORD_BITS) {
+ m_Out = AP4_BITSTREAM_POINTER_OFFSET(m_Out, AP4_WORD_BYTES);
+ n -= AP4_WORD_BITS;
+ }
+ if (n) {
+ m_Cache = ReadCache();
+ m_BitsCached = AP4_WORD_BITS-n;
+ m_Out = AP4_BITSTREAM_POINTER_OFFSET(m_Out, AP4_WORD_BYTES);
+ } else {
+ m_BitsCached = 0;
+ m_Cache = 0;
+ }
+ }
}
/*----------------------------------------------------------------------
@@ -295,16 +273,13 @@ AP4_BitStream::SkipBits(unsigned int n)
inline void
AP4_BitStream::SkipBit()
{
- if(m_BitsCached == 0)
- {
- m_Cache = ReadCache();
- m_Out = AP4_BITSTREAM_POINTER_OFFSET(m_Out, AP4_WORD_BYTES);
- m_BitsCached = AP4_WORD_BITS - 1;
- }
- else
- {
- --m_BitsCached;
- }
+ if (m_BitsCached == 0) {
+ m_Cache = ReadCache();
+ m_Out = AP4_BITSTREAM_POINTER_OFFSET(m_Out, AP4_WORD_BYTES);
+ m_BitsCached = AP4_WORD_BITS - 1;
+ } else {
+ --m_BitsCached;
+ }
}
/*----------------------------------------------------------------------
@@ -313,8 +288,8 @@ AP4_BitStream::SkipBit()
inline AP4_UI08
AP4_BitStream::ReadByte()
{
- SkipBits(m_BitsCached & 7);
- return ReadBits(8);
+ SkipBits(m_BitsCached & 7);
+ return ReadBits(8);
}
/*----------------------------------------------------------------------
@@ -323,11 +298,11 @@ AP4_BitStream::ReadByte()
inline AP4_UI08
AP4_BitStream::PeekByte()
{
- int extra_bits = m_BitsCached & 7;
- int data = PeekBits(extra_bits + 8);
- int byte = data & 0xFF;
+ int extra_bits = m_BitsCached & 7;
+ int data = PeekBits(extra_bits + 8);
+ int byte = data & 0xFF;
- return byte;
+ return byte;
}
#endif // _AP4_BIT_STREAM_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.cpp
index b08f13cf7..a054f0c97 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.cpp
@@ -40,9 +40,9 @@
const unsigned int AP4_AAC_MAX_SAMPLING_FREQUENCY_INDEX = 12;
static const unsigned int AP4_AacSamplingFreqTable[13] =
{
- 96000, 88200, 64000, 48000,
- 44100, 32000, 24000, 22050,
- 16000, 12000, 11025, 8000,
+ 96000, 88200, 64000, 48000,
+ 44100, 32000, 24000, 22050,
+ 16000, 12000, 11025, 8000,
7350
};
@@ -53,30 +53,25 @@ class AP4_Mp4AudioDsiParser
{
public:
AP4_Mp4AudioDsiParser(const AP4_UI08* data, AP4_Size data_size) :
- m_Data(data, data_size),
+ m_Data(data, data_size),
m_Position(0) {}
-
- AP4_Size BitsLeft()
- {
- return 8 * m_Data.GetDataSize() - m_Position;
- }
- AP4_UI32 ReadBits(unsigned int n)
- {
+
+ AP4_Size BitsLeft() { return 8*m_Data.GetDataSize()-m_Position; }
+ AP4_UI32 ReadBits(unsigned int n) {
AP4_UI32 result = 0;
const AP4_UI08* data = m_Data.GetData();
- while(n)
- {
- unsigned int bits_avail = 8 - (m_Position % 8);
+ while (n) {
+ unsigned int bits_avail = 8-(m_Position%8);
unsigned int chunk_size = bits_avail >= n ? n : bits_avail;
- unsigned int chunk_bits = (((unsigned int)(data[m_Position/8])) >> (bits_avail - chunk_size)) & ((1 << chunk_size) - 1);
+ unsigned int chunk_bits = (((unsigned int)(data[m_Position/8]))>>(bits_avail-chunk_size))&((1<<chunk_size)-1);
result = (result << chunk_size) | chunk_bits;
n -= chunk_size;
m_Position += chunk_size;
}
-
+
return result;
}
-
+
private:
AP4_DataBuffer m_Data;
unsigned int m_Position;
@@ -117,14 +112,13 @@ AP4_Mp4AudioDecoderConfig::Reset()
AP4_Result
AP4_Mp4AudioDecoderConfig::ParseAudioObjectType(AP4_Mp4AudioDsiParser& parser, AP4_UI08& object_type)
{
- if(parser.BitsLeft() < 5) return AP4_ERROR_INVALID_FORMAT;
+ if (parser.BitsLeft() < 5) return AP4_ERROR_INVALID_FORMAT;
object_type = (AP4_UI08)parser.ReadBits(5);
- if((int)object_type == 31)
- {
- if(parser.BitsLeft() < 6) return AP4_ERROR_INVALID_FORMAT;
- object_type = (AP4_UI08)(32 + parser.ReadBits(6));
- }
- return AP4_SUCCESS;
+ if ((int)object_type == 31) {
+ if (parser.BitsLeft() < 6) return AP4_ERROR_INVALID_FORMAT;
+ object_type = (AP4_UI08)(32 + parser.ReadBits(6));
+ }
+ return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
@@ -133,24 +127,20 @@ AP4_Mp4AudioDecoderConfig::ParseAudioObjectType(AP4_Mp4AudioDsiParser& parser, A
AP4_Result
AP4_Mp4AudioDecoderConfig::ParseGASpecificInfo(AP4_Mp4AudioDsiParser& parser)
{
- if(parser.BitsLeft() < 2) return AP4_ERROR_INVALID_FORMAT;
- m_FrameLengthFlag = (parser.ReadBits(1) == 1);
- m_DependsOnCoreCoder = (parser.ReadBits(1) == 1);
- if(m_DependsOnCoreCoder)
- {
- if(parser.BitsLeft() < 14) return AP4_ERROR_INVALID_FORMAT;
- m_CoreCoderDelay = parser.ReadBits(14);
- }
- else
- {
+ if (parser.BitsLeft() < 2) return AP4_ERROR_INVALID_FORMAT;
+ m_FrameLengthFlag = (parser.ReadBits(1) == 1);
+ m_DependsOnCoreCoder = (parser.ReadBits(1) == 1);
+ if (m_DependsOnCoreCoder) {
+ if (parser.BitsLeft() < 14) return AP4_ERROR_INVALID_FORMAT;
+ m_CoreCoderDelay = parser.ReadBits(14);
+ } else {
m_CoreCoderDelay = 0;
}
- if(parser.BitsLeft() < 1) return AP4_ERROR_INVALID_FORMAT;
- parser.ReadBits(1); /* extensionFlag */
- if(m_ChannelConfiguration == CHANNEL_CONFIG_NONE)
- {
- /*program_config_element (); */
- }
+ if (parser.BitsLeft() < 1) return AP4_ERROR_INVALID_FORMAT;
+ parser.ReadBits(1); /* extensionFlag */
+ if (m_ChannelConfiguration == CHANNEL_CONFIG_NONE) {
+ /*program_config_element (); */
+ }
return AP4_SUCCESS;
}
@@ -159,30 +149,23 @@ AP4_Mp4AudioDecoderConfig::ParseGASpecificInfo(AP4_Mp4AudioDsiParser& parser)
| AP4_Mp4AudioDecoderConfig::ParseSamplingFrequency
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Mp4AudioDecoderConfig::ParseSamplingFrequency(AP4_Mp4AudioDsiParser& parser,
- unsigned int& sampling_frequency_index,
- unsigned int& sampling_frequency)
+AP4_Mp4AudioDecoderConfig::ParseSamplingFrequency(AP4_Mp4AudioDsiParser& parser,
+ unsigned int& sampling_frequency_index,
+ unsigned int& sampling_frequency)
{
- if(parser.BitsLeft() < 4)
- {
+ if (parser.BitsLeft() < 4) {
return AP4_ERROR_INVALID_FORMAT;
}
sampling_frequency_index = parser.ReadBits(4);
- if(sampling_frequency_index == 0xF)
- {
- if(parser.BitsLeft() < 24)
- {
+ if (sampling_frequency_index == 0xF) {
+ if (parser.BitsLeft() < 24) {
return AP4_ERROR_INVALID_FORMAT;
}
sampling_frequency = parser.ReadBits(24);
- }
- else if(sampling_frequency_index <= AP4_AAC_MAX_SAMPLING_FREQUENCY_INDEX)
- {
+ } else if (sampling_frequency_index <= AP4_AAC_MAX_SAMPLING_FREQUENCY_INDEX) {
sampling_frequency = AP4_AacSamplingFreqTable[sampling_frequency_index];
- }
- else
- {
+ } else {
sampling_frequency = 0;
return AP4_ERROR_INVALID_FORMAT;
}
@@ -194,7 +177,7 @@ AP4_Mp4AudioDecoderConfig::ParseSamplingFrequency(AP4_Mp4AudioDsiParser& parser,
| AP4_Mp4AudioDecoderConfig::Parse
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Mp4AudioDecoderConfig::Parse(const unsigned char* data,
+AP4_Mp4AudioDecoderConfig::Parse(const unsigned char* data,
AP4_Size data_size)
{
AP4_Result result;
@@ -202,73 +185,65 @@ AP4_Mp4AudioDecoderConfig::Parse(const unsigned char* data,
// default config
Reset();
-
+
// parse the audio object type
- result = ParseAudioObjectType(bits, m_ObjectType);
- if(AP4_FAILED(result)) return result;
+ result = ParseAudioObjectType(bits, m_ObjectType);
+ if (AP4_FAILED(result)) return result;
// parse the sampling frequency
- result = ParseSamplingFrequency(bits,
- m_SamplingFrequencyIndex,
+ result = ParseSamplingFrequency(bits,
+ m_SamplingFrequencyIndex,
m_SamplingFrequency);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
- if(bits.BitsLeft() < 4)
- {
+ if (bits.BitsLeft() < 4) {
return AP4_ERROR_INVALID_FORMAT;
}
- m_ChannelConfiguration = (ChannelConfiguration)bits.ReadBits(4);
+ m_ChannelConfiguration = (ChannelConfiguration)bits.ReadBits(4);
m_ChannelCount = (unsigned int)m_ChannelConfiguration;
- if(m_ChannelCount == 7)
- {
+ if (m_ChannelCount == 7) {
m_ChannelCount = 8;
- }
- else if(m_ChannelCount > 7)
- {
+ } else if (m_ChannelCount > 7) {
m_ChannelCount = 0;
}
-
- if(m_ObjectType == AP4_MPEG4_AUDIO_OBJECT_TYPE_SBR ||
- m_ObjectType == AP4_MPEG4_AUDIO_OBJECT_TYPE_PS)
- {
- m_Extension.m_ObjectType = AP4_MPEG4_AUDIO_OBJECT_TYPE_SBR;
- m_Extension.m_SbrPresent = true;
+
+ if (m_ObjectType == AP4_MPEG4_AUDIO_OBJECT_TYPE_SBR ||
+ m_ObjectType == AP4_MPEG4_AUDIO_OBJECT_TYPE_PS) {
+ m_Extension.m_ObjectType = AP4_MPEG4_AUDIO_OBJECT_TYPE_SBR;
+ m_Extension.m_SbrPresent = true;
m_Extension.m_PsPresent = m_ObjectType == AP4_MPEG4_AUDIO_OBJECT_TYPE_PS;
- result = ParseSamplingFrequency(bits,
- m_Extension.m_SamplingFrequencyIndex,
+ result = ParseSamplingFrequency(bits,
+ m_Extension.m_SamplingFrequencyIndex,
m_Extension.m_SamplingFrequency);
- if(AP4_FAILED(result)) return result;
- result = ParseAudioObjectType(bits, m_ObjectType);
- if(AP4_FAILED(result)) return result;
- }
- else
- {
+ if (AP4_FAILED(result)) return result;
+ result = ParseAudioObjectType(bits, m_ObjectType);
+ if (AP4_FAILED(result)) return result;
+ } else {
m_Extension.m_ObjectType = 0;
m_Extension.m_SamplingFrequency = 0;
m_Extension.m_SamplingFrequencyIndex = 0;
m_Extension.m_SbrPresent = false;
m_Extension.m_PsPresent = false;
}
-
- switch(m_ObjectType)
- {
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_MAIN:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LC:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SSR:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LTP:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SCALABLE:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_TWINVQ:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LC:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LTP:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LD:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_TWINVQ:
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_BSAC:
- result = ParseGASpecificInfo(bits);
- break;
-
- default:
- return AP4_ERROR_NOT_SUPPORTED;
+
+ switch (m_ObjectType) {
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_MAIN:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LC:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SSR:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LTP:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SCALABLE:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_TWINVQ:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LC:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LTP:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LD:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_TWINVQ:
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_BSAC:
+ result = ParseGASpecificInfo(bits);
+ break;
+
+ default:
+ return AP4_ERROR_NOT_SUPPORTED;
}
return AP4_SUCCESS;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.h b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.h
index 337c125a8..eeb629069 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Codecs/Ap4Mp4AudioInfo.h
@@ -44,14 +44,12 @@ class AP4_Mp4AudioDsiParser;
* DecoderConfigDescriptor descriptor carried in the sample description
* for the audio samples. See 14496-1, subpart 2, p 2.6.6 for details.
*/
-class AP4_Mp4AudioDecoderConfig
-{
+class AP4_Mp4AudioDecoderConfig {
public:
/**
* Channel configuration for multichannel audio buffers.
*/
- typedef enum
- {
+ typedef enum {
CHANNEL_CONFIG_NONE = 0, /**< No channel (not used) */
CHANNEL_CONFIG_MONO = 1, /**< Mono (single audio channel) */
CHANNEL_CONFIG_STEREO = 2, /**< Stereo (Two audio channels) */
@@ -65,17 +63,17 @@ public:
// constructor
AP4_Mp4AudioDecoderConfig();
-
+
/**
* Parser a DecoderSpecificInfo buffer
*/
AP4_Result Parse(const AP4_UI08* data, AP4_Size data_size);
-
+
/**
* Reset all members to default values (0)
*/
void Reset();
-
+
// members
AP4_UI08 m_ObjectType; /**< Type identifier for the audio data */
unsigned int m_SamplingFrequencyIndex; /**< Index of the sampling frequency in the sampling frequency table */
@@ -86,19 +84,18 @@ public:
bool m_DependsOnCoreCoder; /**< Depends on Core Coder */
unsigned int m_CoreCoderDelay; /**< Core Code delay */
/** Extension details */
- struct
- {
+ struct {
bool m_SbrPresent; /**< SBR is present */
bool m_PsPresent; /**< PS is present */
AP4_UI08 m_ObjectType; /**< Extension object type */
unsigned int m_SamplingFrequencyIndex; /**< Sampling frequency index of the extension */
unsigned int m_SamplingFrequency; /**< Sampling frequency of the extension */
} m_Extension;
-
+
private:
AP4_Result ParseAudioObjectType(AP4_Mp4AudioDsiParser& parser, AP4_UI08& object_type);
AP4_Result ParseGASpecificInfo(AP4_Mp4AudioDsiParser& parser);
- AP4_Result ParseSamplingFrequency(AP4_Mp4AudioDsiParser& parser,
+ AP4_Result ParseSamplingFrequency(AP4_Mp4AudioDsiParser& parser,
unsigned int& sampling_frequency_index,
unsigned int& sampling_frequency);
};
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4.h
index b7648bca3..aa81266d4 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4.h
@@ -25,7 +25,7 @@
| 02111-1307, USA.
|
****************************************************************/
-/**
+/**
* @file
* @brief Top Level include file
*
@@ -37,23 +37,23 @@
*
* @section intro_sec Introduction
* Bento4/AP4 is a C++ class library designed to read and write ISO-MP4 files.
-* This format is defined in ISO/IEC 14496-12, 14496-14 and 14496-15.
-* The format is a derivative of the Apple Quicktime file format.
-* Because of that, Bento4 can be used to read and write a number of Quicktime files
+* This format is defined in ISO/IEC 14496-12, 14496-14 and 14496-15.
+* The format is a derivative of the Apple Quicktime file format.
+* Because of that, Bento4 can be used to read and write a number of Quicktime files
* as well, even though some Quicktime specific features are not supported.
* In addition, Bento4 supports a number of extensions as defined in various
* other specifications. This includes some support for ISMA Encrytion and
-* Decryption as defined in the ISMA E&A specification (http://www.isma.tv),
+* Decryption as defined in the ISMA E&A specification (http://www.isma.tv),
* OMA 2.0 PDCF Encryption and Decryption as defined in the OMA 2.0 PDCF
* specification (http://www.openmobilealliance.org) and iTunes compatible
* metadata.
* The SDK includes a number of command line tools, built using the class library,
* that serve as general purpose tools as well as examples of how to use the API.
-*
+*
* The SDK is designed to be cross-platform. The code is very portable; it can
* be compiled with any sufficiently modern C++ compiler. The code does not rely
* on any external library; all the code necessary to compile the SDK and its
-* tools is included in the standard distribution. The standard distribution
+* tools is included in the standard distribution. The standard distribution
* contains makefiles for unix-like operating systems, including Linux, project
* files for Microsoft Visual Studio, and an XCode project for MacOS X. There is
* also support for building the library with the SCons build system.
@@ -71,9 +71,9 @@
* will create the SDK directory structure as described above.
*
* @subsection build_linux Linux
-* Go to Build/Targets/x86-unknown-linux or Build/Targets/<target-name>
+* Go to Build/Targets/x86-unknown-linux or Build/Targets/<target-name>
* for any linux-based target, and use the 'make'
-* command to build the library and tools, or 'make sdk' to build the SDK
+* command to build the library and tools, or 'make sdk' to build the SDK
* directory structure.
*
* @subsection build_cygwin Cygwin
@@ -85,37 +85,37 @@
*
* @subsection build_scons Using SCons
* There is experimental support for building the SDK using the python-based
-* SCons tool (http://www.scons.org). The top level configuration is located
+* SCons tool (http://www.scons.org). The top level configuration is located
* at the root of the SDK, and will output all the object files and binaries
* to a sub-directory under Build/SCons/Targets/<target-name>/<config-name>.
*
* @subsection build_others Other Platforms
* Other plaftorms can be built by adapting the makefiles for the generic
-* gcc-based configurations.
+* gcc-based configurations.
*
* @section mp4_structure Structure of an MP4 file
*
* An MP4 file consists of a tree of atoms (also known as boxes). The atoms
* contain the information about the different media tracks for the file, as
* well as other information, such as metadata.
-* The Bento4 class library parses files an constructs an in-memory representation
+* The Bento4 class library parses files an constructs an in-memory representation
* of the atoms, and provides an API that is an abstraction layer for the
* way the information is actually encoded in those atoms.
*
* @section reading Reading Files
*
* The class #AP4_File represents all the information about an MP4 file.
-* Internally, a tree of #AP4_Atom objects plus other helper objects holds
+* Internally, a tree of #AP4_Atom objects plus other helper objects holds
* the actual information.
-* To create an instance of the class, the caller must pass a reference to
+* To create an instance of the class, the caller must pass a reference to
* an #AP4_ByteStream object that represents the file data storage. The SDK
-* includes two subclasses of the abstract #AP4_ByteStream class:
+* includes two subclasses of the abstract #AP4_ByteStream class:
* #AP4_FileByteStream for reading/writing disk-based files and
* #AP4_MemoryByteStream for working with in-memory file images.
* Once you have created an #AP4_File object, you can get to the media data by
* accessing the #AP4_Track objects of its #AP4_Movie (see #AP4_File::GetMovie).
* The #AP4_Track exposes the necessary methods for you to get the
-* #AP4_SampleDescription (typically to initialize your decoder) and to get the
+* #AP4_SampleDescription (typically to initialize your decoder) and to get the
* #AP4_Sample objects from the track.
* These #AP4_Sample objects give you the meta information you need (such as
* timestamps) as well as the sample data that they point to.
@@ -124,16 +124,16 @@
* base class for a visitor of the tree of #AP4_Atom objects. The SDK includes
* an concrete subclass, #AP4_PrintInspector, can be used to print out a text
* representation of the atoms as they are visited. See the Mp4Dump command line
-* application for an example.
-*
+* application for an example.
+*
* @section writing Writing Files
*
* To create a new MP4 file, you first create an #AP4_SyntheticSampleTable
* sample table for each track in your file. You specify the sample description
* for the media samples in each track by calling #AP4_SyntheticSampleTable::AddSampleDescription
* with the description for the samples of that track. Samples can then be added
-* to the sample table with the #AP4_SyntheticSampleTable::AddSample method.
-* Once all the samples of all the tracks have been added to the sample tables,
+* to the sample table with the #AP4_SyntheticSampleTable::AddSample method.
+* Once all the samples of all the tracks have been added to the sample tables,
* you can create an #AP4_Movie, and an #AP4_Track from each sample table, add the track
* to the movie, and finally create an #AP4_File from the movie object.
* Finally, the #AP4_File object can be serialized to a byte stream (such as an
@@ -141,20 +141,20 @@
* See the Aac2Mp4 application for an example.
*
* @section tracks Tracks
-*
+*
* The #AP4_Movie object of an #AP4_File has a list of #AP4_Track objects. Each
-* #AP4_Track represents a media track in the file. From this object, you can
+* #AP4_Track represents a media track in the file. From this object, you can
* obtain the type, duration, etc.. of the tracks. This object also provides
* access to the media samples in the track. Tracks are made up of media samples,
* stored in an 'mdat' atom (media data) and a sample table that provides all the
* information about the individual samples, such as size, timestamps, sample
-* description, etc... Media samples are represented by #AP4_Sample objects.
-* You can obtain a track's samples by calling the #AP4_Track::GetSample method.
+* description, etc... Media samples are represented by #AP4_Sample objects.
+* You can obtain a track's samples by calling the #AP4_Track::GetSample method.
* You can also directly read the payload of a media sample by calling the
* #AP4_Track::ReadSample method if you want to bypass the intermediate step of
* going through an #AP4_Sample object.
* The information about the samples in a track is represented by subclasses of
-* the #AP4_SampleDescription class. The sample descriptions contain information
+* the #AP4_SampleDescription class. The sample descriptions contain information
* about media-specific parameters, such as video resolution, audio sampling rates
* and others.
* See the Mp4Info and Mp42Aac command line applications as examples.
@@ -164,15 +164,15 @@
* @subsection factory Custom Atoms
*
* The SDK has built-in support for most of the standard atom types as defined
-* in the spec. But an application may want to extend the library to support
+* in the spec. But an application may want to extend the library to support
* non-standard atom type, such as custom atoms whose definition is proprietary.
* The base class for all atoms is #AP4_Atom. Instances of subclasses of this class
-* are created by the #AP4_AtomFactory object. The factory knows about all the
-* #AP4_Atom subclasses included in the SDK, and maintains a list of
+* are created by the #AP4_AtomFactory object. The factory knows about all the
+* #AP4_Atom subclasses included in the SDK, and maintains a list of
* #AP4_AtomFactory::TypeHandler type handlers. When the factory encounters an atom
* that is not one of the built-in atom type, it calls all the registered type
-* handlers, in turn, until one of them accept to handle the type and create the
-* corresponding atom. The custom atoms must be implemented as subclasses of
+* handlers, in turn, until one of them accept to handle the type and create the
+* corresponding atom. The custom atoms must be implemented as subclasses of
* #AP4_Atom and override at least the #AP4_Atom::WriteFields method. The custom
* atoms should also override #AP4_Atom::InspectFields if they want to provide
* meaningful information when inspected.
@@ -180,7 +180,7 @@
* @subsection tranformations Transformations
* The SDK provides support for transforming MP4 files. Transformations are useful
* to perform tasks such as editing (removing or adding atoms) and encryption or
-* decryption. When the atom tree for the file changes, the entire file needs to
+* decryption. When the atom tree for the file changes, the entire file needs to
* change, because in most cases, the size of the 'moov' atom will change, and
* thus change the offset of the media samples in the 'mdat' atom.
* To facilitate this operation, the class #AP4_Processor provides the base
@@ -192,18 +192,18 @@
* of #AP4_Processor may create such an #AP4_Processor::TrackHandler subclass instance
* when is #AP4_Processor::CreateTrackHandler is called for one of the tracks in the
* file.
-* See the sample applications Mp4Edit, Mp4Encrpt and Mp4Decrypt as examples.
+* See the sample applications Mp4Edit, Mp4Encrpt and Mp4Decrypt as examples.
*
* @subsection encryption Encryption and Decryption
*
* The SDK has support for encrypting and decrypting tracks as specified by the
-* ISMA Encryption and Authentication specification as well as OMA 2.0 and 2.1 DCF and PDCF.
+* ISMA Encryption and Authentication specification as well as OMA 2.0 and 2.1 DCF and PDCF.
* The supporting classes found in Ap4IsmaCryp.h and AP4_OmaDcf.h provide a subclass
-* of #AP4_Processor for encrypting or decrypting entire files.
+* of #AP4_Processor for encrypting or decrypting entire files.
* The class #AP4_IsmaCipher and #AP4_OmaDcfSampleDecrypter implement the generic
* #AP4_SampleDecrypter interface that provides support for decrypting individual samples.
-* The parameters necessary to instantiate an #AP4_IsmaCipher or an #AP4_OmaDcfSampleDecrypter
-* can be retrieved from an encrypted track by accessing the track's sample descriptions,
+* The parameters necessary to instantiate an #AP4_IsmaCipher or an #AP4_OmaDcfSampleDecrypter
+* can be retrieved from an encrypted track by accessing the track's sample descriptions,
* which are instances of the #AP4_ProtectedSampleDescription class. A more general factory
* method, #AP4_SampleDecrypter::Create can be called, passing an instance of
* #AP4_ProtectedSampleDescription and the cipher key, and the correct concrete class will
@@ -213,7 +213,7 @@
*
* For files that contain hint tracks, the SDK provides support for generating
* RTP packets that can be used to stream the media using the RTP and RTSP protocols.
-* See the application Mp4RtpHintInfo for an example of how to generate the create
+* See the application Mp4RtpHintInfo for an example of how to generate the create
* RTP packets from a file and generate the SDP information for the RTSP protocol.
*/
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.cpp
index a7b671d39..99828d98b 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - 8bdl Atoms
+| AP4 - 8bdl Atoms
|
| Copyright 2002-2009 Axiomatic Systems, LLC
|
@@ -25,7 +25,7 @@
| 02111-1307, USA.
|
****************************************************************/
-
+
/*----------------------------------------------------------------------
| includes
+---------------------------------------------------------------------*/
@@ -44,7 +44,7 @@ AP4_8bdlAtom::AP4_8bdlAtom(AP4_UI32 encoding,
AP4_UI32 encoding_version,
const AP4_Byte* data,
AP4_Size data_size) :
- AP4_Atom(AP4_ATOM_TYPE_8BDL, (AP4_UI32)(AP4_ATOM_HEADER_SIZE + 8 + data_size)),
+ AP4_Atom(AP4_ATOM_TYPE_8BDL, (AP4_UI32)(AP4_ATOM_HEADER_SIZE+8+data_size)),
m_Encoding(encoding),
m_EncodingVersion(encoding_version),
m_BundleData(data, data_size)
@@ -58,12 +58,9 @@ AP4_8bdlAtom*
AP4_8bdlAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
// make sure we have enough data
- if(size < AP4_ATOM_HEADER_SIZE + 8)
- {
+ if (size < AP4_ATOM_HEADER_SIZE+8) {
return NULL;
- }
- else
- {
+ } else {
return new AP4_8bdlAtom(size, stream);
}
}
@@ -74,7 +71,7 @@ AP4_8bdlAtom::Create(AP4_Size size, AP4_ByteStream& stream)
AP4_8bdlAtom::AP4_8bdlAtom(AP4_Size size,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_8BDL, (AP4_UI32)(size)),
- m_BundleData(size - AP4_ATOM_HEADER_SIZE - 8)
+ m_BundleData(size-AP4_ATOM_HEADER_SIZE-8)
{
stream.ReadUI32(m_Encoding);
stream.ReadUI32(m_EncodingVersion);
@@ -92,15 +89,15 @@ AP4_8bdlAtom::WriteFields(AP4_ByteStream& stream)
// encoding
result = stream.WriteUI32(m_Encoding);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// encoding version
result = stream.WriteUI32(m_EncodingVersion);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// bundle_data
result = stream.Write(m_BundleData.GetData(), m_BundleData.GetDataSize());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return result;
}
@@ -115,14 +112,11 @@ AP4_8bdlAtom::InspectFields(AP4_AtomInspector& inspector)
AP4_FormatFourChars(enc, m_Encoding);
inspector.AddField("encoding", enc);
inspector.AddField("encoding_version", m_EncodingVersion);
- if(m_Encoding == AP4_8BDL_XML_DATA_ENCODING)
- {
+ if (m_Encoding == AP4_8BDL_XML_DATA_ENCODING) {
// we, in fact have an xml string
AP4_String xml((const char*)m_BundleData.GetData(), m_BundleData.GetDataSize());
inspector.AddField("bundle_data", xml.GetChars());
- }
- else
- {
+ } else {
inspector.AddField("bundle_data", m_BundleData.GetData(), m_BundleData.GetDataSize());
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.h
index 6845c7b22..3c3cadd2e 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap48bdlAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - 8bdl Atoms
+| AP4 - 8bdl Atoms
|
| Copyright 2002-2009 Axiomatic Systems, LLC
|
@@ -25,10 +25,10 @@
| 02111-1307, USA.
|
****************************************************************/
-
-#ifndef _AP4_8BDL_ATOM_H_
-#define _AP4_8BDL_ATOM_H_
-
+
+ #ifndef _AP4_8BDL_ATOM_H_
+ #define _AP4_8BDL_ATOM_H_
+
/*----------------------------------------------------------------------
| includes
+---------------------------------------------------------------------*/
@@ -39,7 +39,7 @@
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_8BDL_XML_DATA_ENCODING = AP4_ATOM_TYPE('x', 'm', 'l', ' ');
+const AP4_UI32 AP4_8BDL_XML_DATA_ENCODING = AP4_ATOM_TYPE('x','m','l',' ');
/*----------------------------------------------------------------------
| AP4_8bdlAtom
@@ -51,7 +51,7 @@ public:
// virtual constructor
static AP4_8bdlAtom* Create(AP4_Size size, AP4_ByteStream& stream);
-
+
// constructors
AP4_8bdlAtom(AP4_UI32 encoding,
AP4_UI32 encoding_version,
@@ -63,18 +63,9 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- AP4_UI32 GetEncoding()
- {
- return m_Encoding;
- }
- AP4_UI32 GetEncodingVersion()
- {
- return m_EncodingVersion;
- }
- const AP4_DataBuffer& GetBundleData()
- {
- return m_BundleData;
- }
+ AP4_UI32 GetEncoding() { return m_Encoding; }
+ AP4_UI32 GetEncodingVersion() { return m_EncodingVersion; }
+ const AP4_DataBuffer& GetBundleData() { return m_BundleData; }
private:
// methods
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Array.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Array.h
index ebbd42748..b62bac22c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Array.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Array.h
@@ -26,7 +26,7 @@
|
****************************************************************/
/**
- * @file
+ * @file
* @brief Arrays
*/
@@ -51,28 +51,19 @@ const int AP4_ARRAY_INITIAL_COUNT = 64;
/*----------------------------------------------------------------------
| AP4_Array
+---------------------------------------------------------------------*/
-template <typename T>
-class AP4_Array
+template <typename T>
+class AP4_Array
{
public:
// methods
- AP4_Array(): m_AllocatedCount(0), m_ItemCount(0), m_Items(0) {}
- AP4_Array(const T* items, AP4_Size count);
+ AP4_Array(): m_AllocatedCount(0), m_ItemCount(0), m_Items(0) {}
+ AP4_Array(const T* items, AP4_Size count);
virtual ~AP4_Array();
- AP4_Cardinal ItemCount() const
- {
- return m_ItemCount;
- }
+ AP4_Cardinal ItemCount() const { return m_ItemCount; }
AP4_Result Append(const T& item);
AP4_Result RemoveLast();
- T& operator[](unsigned long idx)
- {
- return m_Items[idx];
- }
- const T& operator[](unsigned long idx) const
- {
- return m_Items[idx];
- }
+ T& operator[](unsigned long idx) { return m_Items[idx]; }
+ const T& operator[](unsigned long idx) const { return m_Items[idx]; }
AP4_Result Clear();
AP4_Result EnsureCapacity(AP4_Cardinal count);
AP4_Result SetItemCount(AP4_Cardinal item_count);
@@ -93,9 +84,8 @@ AP4_Array<T>::AP4_Array(const T* items, AP4_Size count) :
m_ItemCount(count),
m_Items((T*)::operator new(count*sizeof(T)))
{
- for(unsigned int i = 0; i < count; i++)
- {
- new((void*)&m_Items[i]) T(items[i]);
+ for (unsigned int i=0; i<count; i++) {
+ new ((void*)&m_Items[i]) T(items[i]);
}
}
@@ -117,8 +107,7 @@ AP4_Result
AP4_Array<T>::Clear()
{
// destroy all items
- for(AP4_Ordinal i = 0; i < m_ItemCount; i++)
- {
+ for (AP4_Ordinal i=0; i<m_ItemCount; i++) {
m_Items[i].~T();
}
@@ -135,19 +124,16 @@ AP4_Result
AP4_Array<T>::EnsureCapacity(AP4_Cardinal count)
{
// check if we already have enough
- if(count <= m_AllocatedCount) return AP4_SUCCESS;
+ if (count <= m_AllocatedCount) return AP4_SUCCESS;
// (re)allocate the items
- T* new_items = (T*) ::operator new(count * sizeof(T));
- if(new_items == NULL)
- {
+ T* new_items = (T*) ::operator new (count*sizeof(T));
+ if (new_items == NULL) {
return AP4_ERROR_OUT_OF_MEMORY;
}
- if(m_ItemCount && m_Items)
- {
- for(unsigned int i = 0; i < m_ItemCount; i++)
- {
- new((void*)&new_items[i]) T(m_Items[i]);
+ if (m_ItemCount && m_Items) {
+ for (unsigned int i=0; i<m_ItemCount; i++) {
+ new ((void*)&new_items[i]) T(m_Items[i]);
m_Items[i].~T();
}
::operator delete((void*)m_Items);
@@ -162,32 +148,29 @@ AP4_Array<T>::EnsureCapacity(AP4_Cardinal count)
| AP4_Array<T>::SetItemCount
+---------------------------------------------------------------------*/
template <typename T>
-AP4_Result
+AP4_Result
AP4_Array<T>::SetItemCount(AP4_Cardinal item_count)
{
// shortcut
- if(item_count == m_ItemCount) return AP4_SUCCESS;
-
+ if (item_count == m_ItemCount) return AP4_SUCCESS;
+
// check for a reduction in the number of items
- if(item_count < m_ItemCount)
- {
+ if (item_count < m_ItemCount) {
// destruct the items that are no longer needed
- for(unsigned int i = item_count; i < m_ItemCount; i++)
- {
+ for (unsigned int i=item_count; i<m_ItemCount; i++) {
m_Items[i].~T();
}
m_ItemCount = item_count;
return AP4_SUCCESS;
}
-
+
// grow the list
AP4_Result result = EnsureCapacity(item_count);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// construct the new items
- for(unsigned int i = m_ItemCount; i < item_count; i++)
- {
- new((void*)&m_Items[i]) T();
+ for (unsigned int i=m_ItemCount; i<item_count; i++) {
+ new ((void*)&m_Items[i]) T();
}
m_ItemCount = item_count;
return AP4_SUCCESS;
@@ -200,13 +183,10 @@ template <typename T>
AP4_Result
AP4_Array<T>::RemoveLast()
{
- if(m_ItemCount)
- {
+ if (m_ItemCount) {
m_Items[--m_ItemCount].~T();
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_OUT_OF_RANGE;
}
}
@@ -219,21 +199,20 @@ AP4_Result
AP4_Array<T>::Append(const T& item)
{
// ensure that we have enough space
- if(m_AllocatedCount < m_ItemCount + 1)
- {
+ if (m_AllocatedCount < m_ItemCount+1) {
// try double the size, with a minimum
- unsigned long new_count = m_AllocatedCount ? 2 * m_AllocatedCount : AP4_ARRAY_INITIAL_COUNT;
+ unsigned long new_count = m_AllocatedCount?2*m_AllocatedCount:AP4_ARRAY_INITIAL_COUNT;
// if that's still not enough, just ask for what we need
- if(new_count < m_ItemCount + 1) new_count = m_ItemCount + 1;
-
+ if (new_count < m_ItemCount+1) new_count = m_ItemCount+1;
+
// reserve the space
AP4_Result result = EnsureCapacity(new_count);
- if(result != AP4_SUCCESS) return result;
+ if (result != AP4_SUCCESS) return result;
}
-
+
// store the item
- new((void*)&m_Items[m_ItemCount++]) T(item);
+ new ((void*)&m_Items[m_ItemCount++]) T(item);
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.cpp
index a8876c1a8..a9bd81e6b 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - Atoms
+| AP4 - Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -57,16 +57,16 @@ AP4_Atom::Type
AP4_Atom::TypeFromString(const char* s)
{
// convert the name into an atom type
- return ((AP4_UI32)s[0]) << 24 |
- ((AP4_UI32)s[1]) << 16 |
- ((AP4_UI32)s[2]) << 8 |
+ return ((AP4_UI32)s[0])<<24 |
+ ((AP4_UI32)s[1])<<16 |
+ ((AP4_UI32)s[2])<< 8 |
((AP4_UI32)s[3]);
}
/*----------------------------------------------------------------------
| AP4_Atom::AP4_Atom
+---------------------------------------------------------------------*/
-AP4_Atom::AP4_Atom(Type type, AP4_UI32 size /* = AP4_ATOM_HEADER_SIZE */) :
+AP4_Atom::AP4_Atom(Type type, AP4_UI32 size /* = AP4_ATOM_HEADER_SIZE */) :
m_Type(type),
m_Size32(size),
m_Size64(0),
@@ -80,7 +80,7 @@ AP4_Atom::AP4_Atom(Type type, AP4_UI32 size /* = AP4_ATOM_HEADER_SIZE */) :
/*----------------------------------------------------------------------
| AP4_Atom::AP4_Atom
+---------------------------------------------------------------------*/
-AP4_Atom::AP4_Atom(Type type, AP4_UI64 size, bool force_64) :
+AP4_Atom::AP4_Atom(Type type, AP4_UI64 size, bool force_64) :
m_Type(type),
m_Size32(0),
m_Size64(0),
@@ -95,9 +95,9 @@ AP4_Atom::AP4_Atom(Type type, AP4_UI64 size, bool force_64) :
/*----------------------------------------------------------------------
| AP4_Atom::AP4_Atom
+---------------------------------------------------------------------*/
-AP4_Atom::AP4_Atom(Type type,
- AP4_UI32 size,
- AP4_UI32 version,
+AP4_Atom::AP4_Atom(Type type,
+ AP4_UI32 size,
+ AP4_UI32 version,
AP4_UI32 flags) :
m_Type(type),
m_Size32(size),
@@ -112,10 +112,10 @@ AP4_Atom::AP4_Atom(Type type,
/*----------------------------------------------------------------------
| AP4_Atom::AP4_Atom
+---------------------------------------------------------------------*/
-AP4_Atom::AP4_Atom(Type type,
+AP4_Atom::AP4_Atom(Type type,
AP4_UI64 size,
bool force_64,
- AP4_UI32 version,
+ AP4_UI32 version,
AP4_UI32 flags) :
m_Type(type),
m_Size32(0),
@@ -132,14 +132,14 @@ AP4_Atom::AP4_Atom(Type type,
| AP4_Atom::ReadFullHeader
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Atom::ReadFullHeader(AP4_ByteStream& stream,
- AP4_UI32& version,
+AP4_Atom::ReadFullHeader(AP4_ByteStream& stream,
+ AP4_UI32& version,
AP4_UI32& flags)
{
AP4_UI32 header;
AP4_CHECK(stream.ReadUI32(header));
- version = (header >> 24) & 0x000000FF;
- flags = (header) & 0x00FFFFFF;
+ version = (header>>24)&0x000000FF;
+ flags = (header )&0x00FFFFFF;
return AP4_SUCCESS;
}
@@ -150,22 +150,17 @@ AP4_Atom::ReadFullHeader(AP4_ByteStream& stream,
void
AP4_Atom::SetSize(AP4_UI64 size, bool force_64)
{
- if(!force_64)
- {
+ if (!force_64) {
// see if we need to implicitely force 64-bit encoding
- if(m_Size32 == 1 && m_Size64 <= 0xFFFFFFFF)
- {
+ if (m_Size32 == 1 && m_Size64 <= 0xFFFFFFFF) {
// we have a forced 64-bit encoding
force_64 = true;
}
}
- if((size >> 32) == 0 && !force_64)
- {
+ if ((size >> 32) == 0 && !force_64) {
m_Size32 = (AP4_UI32)size;
m_Size64 = 0;
- }
- else
- {
+ } else {
m_Size32 = 1;
m_Size64 = size;
}
@@ -177,7 +172,7 @@ AP4_Atom::SetSize(AP4_UI64 size, bool force_64)
AP4_Size
AP4_Atom::GetHeaderSize() const
{
- return (m_IsFull ? AP4_FULL_ATOM_HEADER_SIZE : AP4_ATOM_HEADER_SIZE) + (m_Size32 == 1 ? 8 : 0);
+ return (m_IsFull ? AP4_FULL_ATOM_HEADER_SIZE : AP4_ATOM_HEADER_SIZE)+(m_Size32==1?8:0);
}
/*----------------------------------------------------------------------
@@ -190,26 +185,24 @@ AP4_Atom::WriteHeader(AP4_ByteStream& stream)
// write the size
result = stream.WriteUI32(m_Size32);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// write the type
result = stream.WriteUI32(m_Type);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// handle 64-bit sizes
- if(m_Size32 == 1)
- {
+ if (m_Size32 == 1) {
result = stream.WriteUI64(m_Size64);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// for full atoms, write version and flags
- if(m_IsFull)
- {
+ if (m_IsFull) {
result = stream.WriteUI08(m_Version);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI24(m_Flags);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return AP4_SUCCESS;
@@ -230,23 +223,21 @@ AP4_Atom::Write(AP4_ByteStream& stream)
// write the header
result = WriteHeader(stream);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// write the fields
result = WriteFields(stream);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
#if defined(AP4_DEBUG)
AP4_Position after;
stream.Tell(after);
AP4_UI64 atom_size = GetSize();
- if(after - before != atom_size)
- {
+ if (after-before != atom_size) {
AP4_Debug("ERROR: atom size mismatch (declared size=%d, actual size=%d)\n",
- (AP4_UI32)atom_size, (AP4_UI32)(after - before));
+ (AP4_UI32)atom_size, (AP4_UI32)(after-before));
AP4_Atom* atom = this;
- while(atom)
- {
+ while (atom) {
char name[7];
name[0] = '[';
AP4_FormatFourCharsPrintable(&name[1], atom->GetType());
@@ -255,7 +246,7 @@ AP4_Atom::Write(AP4_ByteStream& stream)
AP4_Debug(" while writing %s\n", name);
atom = AP4_DYNAMIC_CAST(AP4_Atom, atom->GetParent());
}
- AP4_ASSERT(after - before == atom_size);
+ AP4_ASSERT(after-before == atom_size);
}
#endif
@@ -289,32 +280,26 @@ AP4_Atom::InspectHeader(AP4_AtomInspector& inspector)
name[6] = '\0';
char header[128];
char extra[32] = "";
- if(m_IsFull)
- {
- if(m_Version && m_Flags)
- {
- AP4_FormatString(extra, sizeof(extra),
+ if (m_IsFull) {
+ if (m_Version && m_Flags) {
+ AP4_FormatString(extra, sizeof(extra),
", version=%d, flags=%x",
m_Version,
m_Flags);
- }
- else if(m_Version)
- {
- AP4_FormatString(extra, sizeof(extra),
+ } else if (m_Version) {
+ AP4_FormatString(extra, sizeof(extra),
", version=%d",
m_Version);
- }
- else if(m_Flags)
- {
- AP4_FormatString(extra, sizeof(extra),
+ } else if (m_Flags) {
+ AP4_FormatString(extra, sizeof(extra),
", flags=%x",
m_Flags);
}
}
- AP4_FormatString(header, sizeof(header),
- "size=%ld+%lld%s",
- GetHeaderSize(),
- GetSize() - GetHeaderSize(),
+ AP4_FormatString(header, sizeof(header),
+ "size=%ld+%lld%s",
+ GetHeaderSize(),
+ GetSize()-GetHeaderSize(),
extra);
inspector.StartElement(name, header);
@@ -325,14 +310,11 @@ AP4_Atom::InspectHeader(AP4_AtomInspector& inspector)
| AP4_Atom::Detach
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Atom::Detach()
+AP4_Atom::Detach()
{
- if(m_Parent)
- {
+ if (m_Parent) {
return m_Parent->RemoveChild(this);
- }
- else
- {
+ } else {
return AP4_SUCCESS;
}
}
@@ -344,21 +326,21 @@ AP4_Atom*
AP4_Atom::Clone()
{
AP4_Atom* clone = NULL;
-
+
// check the size (refuse to clone atoms that are too large)
AP4_LargeSize size = GetSize();
- if(size > AP4_ATOM_MAX_CLONE_SIZE) return NULL;
+ if (size > AP4_ATOM_MAX_CLONE_SIZE) return NULL;
// create a memory byte stream to which we can serialize
AP4_MemoryByteStream* mbs = new AP4_MemoryByteStream((AP4_Size)GetSize());
-
+
// serialize to memory
- if(AP4_FAILED(Write(*mbs))) goto end;
-
+ if (AP4_FAILED(Write(*mbs))) goto end;
+
// create the clone for the serialized form
mbs->Seek(0);
AP4_DefaultAtomFactory::Instance.CreateAtomFromStream(*mbs, clone);
-
+
end:
// release the memory stream
mbs->Release();
@@ -369,41 +351,35 @@ end:
/*----------------------------------------------------------------------
| AP4_UnknownAtom::AP4_UnknownAtom
+---------------------------------------------------------------------*/
-AP4_UnknownAtom::AP4_UnknownAtom(Type type,
+AP4_UnknownAtom::AP4_UnknownAtom(Type type,
AP4_UI64 size,
- AP4_ByteStream& stream) :
+ AP4_ByteStream& stream) :
AP4_Atom(type, size),
m_SourceStream(&stream)
{
- if(size <= AP4_UNKNOWN_ATOM_MAX_LOCAL_PAYLOAD_SIZE &&
- type != AP4_ATOM_TYPE_MDAT)
- {
+ if (size <= AP4_UNKNOWN_ATOM_MAX_LOCAL_PAYLOAD_SIZE &&
+ type != AP4_ATOM_TYPE_MDAT) {
m_SourcePosition = 0;
m_SourceStream = NULL;
- AP4_UI32 payload_size = (AP4_UI32)size - GetHeaderSize();
+ AP4_UI32 payload_size = (AP4_UI32)size-GetHeaderSize();
m_Payload.SetDataSize(payload_size);
stream.Read(m_Payload.UseData(), payload_size);
return;
}
-
+
// store source stream position
stream.Tell(m_SourcePosition);
// clamp to the file size
AP4_UI64 file_size;
- if(AP4_SUCCEEDED(stream.GetSize(file_size)))
- {
- if(m_SourcePosition - GetHeaderSize() + size > file_size)
- {
- if(m_Size32 == 1)
- {
+ if (AP4_SUCCEEDED(stream.GetSize(file_size))) {
+ if (m_SourcePosition-GetHeaderSize()+size > file_size) {
+ if (m_Size32 == 1) {
// size is encoded as a large size
- m_Size64 = file_size - m_SourcePosition;
- }
- else
- {
+ m_Size64 = file_size-m_SourcePosition;
+ } else {
AP4_ASSERT(size <= 0xFFFFFFFF);
- m_Size32 = (AP4_UI32)(file_size - m_SourcePosition);
+ m_Size32 = (AP4_UI32)(file_size-m_SourcePosition);
}
}
}
@@ -415,10 +391,10 @@ AP4_UnknownAtom::AP4_UnknownAtom(Type type,
/*----------------------------------------------------------------------
| AP4_UnknownAtom::AP4_UnknownAtom
+---------------------------------------------------------------------*/
-AP4_UnknownAtom::AP4_UnknownAtom(Type type,
+AP4_UnknownAtom::AP4_UnknownAtom(Type type,
const AP4_UI08* payload,
AP4_Size payload_size) :
- AP4_Atom(type, AP4_ATOM_HEADER_SIZE + payload_size, false),
+ AP4_Atom(type, AP4_ATOM_HEADER_SIZE+payload_size, false),
m_SourceStream(NULL),
m_SourcePosition(0)
{
@@ -436,8 +412,7 @@ AP4_UnknownAtom::AP4_UnknownAtom(const AP4_UnknownAtom& other) :
{
m_Size32 = other.m_Size32;
m_Size64 = other.m_Size64;
- if(m_SourceStream)
- {
+ if (m_SourceStream) {
m_SourceStream->AddReference();
}
}
@@ -448,8 +423,7 @@ AP4_UnknownAtom::AP4_UnknownAtom(const AP4_UnknownAtom& other) :
AP4_UnknownAtom::~AP4_UnknownAtom()
{
// release the source stream reference
- if(m_SourceStream)
- {
+ if (m_SourceStream) {
m_SourceStream->Release();
}
}
@@ -463,23 +437,22 @@ AP4_UnknownAtom::WriteFields(AP4_ByteStream& stream)
AP4_Result result;
// if we don't have a source, write from the buffered payload
- if(m_SourceStream == NULL)
- {
+ if (m_SourceStream == NULL) {
return stream.Write(m_Payload.GetData(), m_Payload.GetDataSize());
}
-
+
// remember the source position
AP4_Position position;
m_SourceStream->Tell(position);
// seek into the source at the stored offset
result = m_SourceStream->Seek(m_SourcePosition);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// copy the source stream to the output
- AP4_UI64 payload_size = GetSize() - GetHeaderSize();
+ AP4_UI64 payload_size = GetSize()-GetHeaderSize();
result = m_SourceStream->CopyTo(stream, payload_size);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// restore the original stream position
m_SourceStream->Seek(position);
@@ -490,7 +463,7 @@ AP4_UnknownAtom::WriteFields(AP4_ByteStream& stream)
/*----------------------------------------------------------------------
| AP4_UnknownAtom::Clone
+---------------------------------------------------------------------*/
-AP4_Atom*
+AP4_Atom*
AP4_UnknownAtom::Clone()
{
return new AP4_UnknownAtom(*this);
@@ -503,18 +476,18 @@ AP4_NullTerminatedStringAtom::AP4_NullTerminatedStringAtom(AP4_Atom::Type type,
AP4_Atom(type, AP4_ATOM_HEADER_SIZE),
m_Value(value)
{
- m_Size32 += m_Value.GetLength() + 1;
+ m_Size32 += m_Value.GetLength()+1;
}
/*----------------------------------------------------------------------
| AP4_NullTerminatedStringAtom::AP4_NullTerminatedStringAtom
+---------------------------------------------------------------------*/
-AP4_NullTerminatedStringAtom::AP4_NullTerminatedStringAtom(AP4_Atom::Type type,
- AP4_UI64 size,
- AP4_ByteStream& stream) :
+AP4_NullTerminatedStringAtom::AP4_NullTerminatedStringAtom(AP4_Atom::Type type,
+ AP4_UI64 size,
+ AP4_ByteStream& stream) :
AP4_Atom(type, size)
{
- AP4_Size str_size = (AP4_Size)size - AP4_ATOM_HEADER_SIZE;
+ AP4_Size str_size = (AP4_Size)size-AP4_ATOM_HEADER_SIZE;
char* str = new char[str_size];
stream.Read(str, str_size);
str[str_size-1] = '\0'; // force null-termination
@@ -527,14 +500,13 @@ AP4_NullTerminatedStringAtom::AP4_NullTerminatedStringAtom(AP4_Atom::Type type,
AP4_Result
AP4_NullTerminatedStringAtom::WriteFields(AP4_ByteStream& stream)
{
- if(m_Size32 > AP4_ATOM_HEADER_SIZE)
- {
- AP4_Result result = stream.Write(m_Value.GetChars(), m_Value.GetLength() + 1);
- if(AP4_FAILED(result)) return result;
+ if (m_Size32 > AP4_ATOM_HEADER_SIZE) {
+ AP4_Result result = stream.Write(m_Value.GetChars(), m_Value.GetLength()+1);
+ if (AP4_FAILED(result)) return result;
// pad with zeros if necessary
- AP4_Size padding = m_Size32 - (AP4_ATOM_HEADER_SIZE + m_Value.GetLength() + 1);
- while(padding--) stream.WriteUI08(0);
+ AP4_Size padding = m_Size32-(AP4_ATOM_HEADER_SIZE+m_Value.GetLength()+1);
+ while (padding--) stream.WriteUI08(0);
}
return AP4_SUCCESS;
@@ -566,39 +538,30 @@ AP4_Result
AP4_AtomParent::AddChild(AP4_Atom* child, int position)
{
// check that the child does not already have a parent
- if(child->GetParent() != NULL) return AP4_ERROR_INVALID_PARAMETERS;
+ if (child->GetParent() != NULL) return AP4_ERROR_INVALID_PARAMETERS;
// attach the child
AP4_Result result;
- if(position == -1)
- {
+ if (position == -1) {
// insert at the tail
result = m_Children.Add(child);
- }
- else if(position == 0)
- {
+ } else if (position == 0) {
// insert at the head
result = m_Children.Insert(NULL, child);
- }
- else
- {
+ } else {
// insert after <n-1>
AP4_List<AP4_Atom>::Item* insertion_point = m_Children.FirstItem();
unsigned int count = position;
- while(insertion_point && --count)
- {
+ while (insertion_point && --count) {
insertion_point = insertion_point->GetNext();
}
- if(insertion_point)
- {
+ if (insertion_point) {
result = m_Children.Insert(insertion_point, child);
- }
- else
- {
+ } else {
result = AP4_ERROR_OUT_OF_RANGE;
}
}
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// notify the child of its parent
child->SetParent(this);
@@ -616,11 +579,11 @@ AP4_Result
AP4_AtomParent::RemoveChild(AP4_Atom* child)
{
// check that this is our child
- if(child->GetParent() != this) return AP4_ERROR_INVALID_PARAMETERS;
+ if (child->GetParent() != this) return AP4_ERROR_INVALID_PARAMETERS;
// remove the child
AP4_Result result = m_Children.Remove(child);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// notify that child that it is orphaned
child->SetParent(NULL);
@@ -639,11 +602,11 @@ AP4_AtomParent::DeleteChild(AP4_Atom::Type type, AP4_Ordinal index /* = 0 */)
{
// find the child
AP4_Atom* child = GetChild(type, index);
- if(child == NULL) return AP4_FAILURE;
+ if (child == NULL) return AP4_FAILURE;
// remove the child
AP4_Result result = RemoveChild(child);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// delete the child
delete child;
@@ -659,12 +622,9 @@ AP4_AtomParent::GetChild(AP4_Atom::Type type, AP4_Ordinal index /* = 0 */) const
{
AP4_Atom* atom;
AP4_Result result = m_Children.Find(AP4_AtomFinder(type, index), atom);
- if(AP4_SUCCEEDED(result))
- {
+ if (AP4_SUCCEEDED(result)) {
return atom;
- }
- else
- {
+ } else {
return NULL;
}
}
@@ -675,17 +635,14 @@ AP4_AtomParent::GetChild(AP4_Atom::Type type, AP4_Ordinal index /* = 0 */) const
AP4_Atom*
AP4_AtomParent::GetChild(const AP4_UI08* uuid, AP4_Ordinal index /* = 0 */) const
{
- for(AP4_List<AP4_Atom>::Item* item = m_Children.FirstItem();
- item;
- item = item->GetNext())
- {
+ for (AP4_List<AP4_Atom>::Item* item = m_Children.FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
- if(atom->GetType() == AP4_ATOM_TYPE_UUID)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_UUID) {
AP4_UuidAtom* uuid_atom = AP4_DYNAMIC_CAST(AP4_UuidAtom, atom);
- if(AP4_CompareMemory(uuid_atom->GetUuid(), uuid, 16) == 0)
- {
- if(index == 0) return atom;
+ if (AP4_CompareMemory(uuid_atom->GetUuid(), uuid, 16) == 0) {
+ if (index == 0) return atom;
--index;
}
}
@@ -697,7 +654,7 @@ AP4_AtomParent::GetChild(const AP4_UI08* uuid, AP4_Ordinal index /* = 0 */) cons
| AP4_AtomParent::FindChild
+---------------------------------------------------------------------*/
AP4_Atom*
-AP4_AtomParent::FindChild(const char* path,
+AP4_AtomParent::FindChild(const char* path,
bool auto_create,
bool auto_create_full)
{
@@ -705,83 +662,58 @@ AP4_AtomParent::FindChild(const char* path,
AP4_AtomParent* parent = this;
// walk the path
- while(path[0] && path[1] && path[2] && path[3])
- {
+ while (path[0] && path[1] && path[2] && path[3]) {
// we have 4 valid chars
const char* tail;
int index = 0;
- if(path[4] == '\0')
- {
+ if (path[4] == '\0') {
tail = NULL;
- }
- else if(path[4] == '/')
- {
+ } else if (path[4] == '/') {
// separator
tail = &path[5];
- }
- else if(path[4] == '[')
- {
+ } else if (path[4] == '[') {
const char* x = &path[5];
- while(*x >= '0' && *x <= '9')
- {
- index = 10 * index + (*x++ - '0');
+ while (*x >= '0' && *x <= '9') {
+ index = 10*index+(*x++ - '0');
}
- if(x[0] == ']')
- {
- if(x[1] == '\0')
- {
+ if (x[0] == ']') {
+ if (x[1] == '\0') {
tail = NULL;
+ } else {
+ tail = x+2;
}
- else
- {
- tail = x + 2;
- }
- }
- else
- {
+ } else {
// malformed path
return NULL;
}
- }
- else
- {
+ } else {
// malformed path
return NULL;
}
// look for this atom in the current list
- AP4_Atom::Type type = AP4_ATOM_TYPE(path[0], path[1], path[2], path[3]);
+ AP4_Atom::Type type = AP4_ATOM_TYPE(path[0], path[1], path[2], path[3]);
AP4_Atom* atom = parent->GetChild(type, index);
- if(atom == NULL)
- {
+ if (atom == NULL) {
// not found
- if(auto_create && (index == 0))
- {
- if(auto_create_full)
- {
+ if (auto_create && (index == 0)) {
+ if (auto_create_full) {
atom = new AP4_ContainerAtom(type, (AP4_UI32)0, (AP4_UI32)0);
- }
- else
- {
+ } else {
atom = new AP4_ContainerAtom(type);
}
parent->AddChild(atom);
- }
- else
- {
+ } else {
return NULL;
}
}
- if(tail)
- {
+ if (tail) {
path = tail;
// if this atom is an atom parent, recurse
parent = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
- if(parent == NULL) return NULL;
- }
- else
- {
+ if (parent == NULL) return NULL;
+ } else {
return atom;
}
}
@@ -793,7 +725,7 @@ AP4_AtomParent::FindChild(const char* path,
/*----------------------------------------------------------------------
| AP4_AtomListWriter::Action
+---------------------------------------------------------------------*/
-const unsigned int AP4_ATOM_LIST_WRITER_MAX_PADDING = 1024;
+const unsigned int AP4_ATOM_LIST_WRITER_MAX_PADDING=1024;
AP4_Result
AP4_AtomListWriter::Action(AP4_Atom* atom) const
@@ -806,21 +738,16 @@ AP4_AtomListWriter::Action(AP4_Atom* atom) const
AP4_Position after;
m_Stream.Tell(after);
- AP4_UI64 bytes_written = after - before;
+ AP4_UI64 bytes_written = after-before;
AP4_ASSERT(bytes_written <= atom->GetSize());
- if(bytes_written < atom->GetSize())
- {
+ if (bytes_written < atom->GetSize()) {
AP4_Debug("WARNING: atom serialized to fewer bytes than declared size\n");
- AP4_UI64 padding = atom->GetSize() - bytes_written;
- if(padding > AP4_ATOM_LIST_WRITER_MAX_PADDING)
- {
+ AP4_UI64 padding = atom->GetSize()-bytes_written;
+ if (padding > AP4_ATOM_LIST_WRITER_MAX_PADDING) {
AP4_Debug("WARNING: padding would be too large\n");
return AP4_FAILURE;
- }
- else
- {
- for(unsigned int i = 0; i < padding; i++)
- {
+ } else {
+ for (unsigned int i=0; i<padding; i++) {
m_Stream.WriteUI08(0);
}
}
@@ -835,19 +762,18 @@ AP4_AtomListWriter::Action(AP4_Atom* atom) const
static void
AP4_MakePrefixString(unsigned int indent, char* prefix, AP4_Size size)
{
- if(size == 0) return;
- if(indent >= size - 1) indent = size - 1;
- for(unsigned int i = 0; i < indent; i++)
- {
+ if (size == 0) return;
+ if (indent >= size-1) indent = size-1;
+ for (unsigned int i=0; i<indent; i++) {
prefix[i] = ' ';
}
- prefix[indent] = '\0';
+ prefix[indent] = '\0';
}
/*----------------------------------------------------------------------
| AP4_PrintInspector::AP4_PrintInspector
+---------------------------------------------------------------------*/
-AP4_PrintInspector::AP4_PrintInspector(AP4_ByteStream& stream, AP4_Cardinal indent) :
+ AP4_PrintInspector::AP4_PrintInspector(AP4_ByteStream& stream, AP4_Cardinal indent) :
m_Stream(&stream),
m_Indent(indent)
{
@@ -872,8 +798,7 @@ AP4_PrintInspector::StartElement(const char* name, const char* info)
AP4_MakePrefixString(m_Indent, prefix, sizeof(prefix));
m_Stream->WriteString(prefix);
m_Stream->WriteString(name);
- if(info)
- {
+ if (info) {
m_Stream->Write(" ", 1);
m_Stream->WriteString(info);
}
@@ -900,7 +825,7 @@ AP4_PrintInspector::AddField(const char* name, const char* value, FormatHint)
char prefix[256];
AP4_MakePrefixString(m_Indent, prefix, sizeof(prefix));
m_Stream->WriteString(prefix);
-
+
m_Stream->WriteString(name);
m_Stream->WriteString(" = ");
m_Stream->WriteString(value);
@@ -918,8 +843,8 @@ AP4_PrintInspector::AddField(const char* name, AP4_UI64 value, FormatHint hint)
m_Stream->WriteString(prefix);
char str[32];
- AP4_FormatString(str, sizeof(str),
- hint == HINT_HEX ? "%llx" : "%lld",
+ AP4_FormatString(str, sizeof(str),
+ hint == HINT_HEX ? "%llx":"%lld",
value);
m_Stream->WriteString(name);
m_Stream->WriteString(" = ");
@@ -938,8 +863,8 @@ AP4_PrintInspector::AddFieldF(const char* name, float value, FormatHint /*hint*/
m_Stream->WriteString(prefix);
char str[32];
- AP4_FormatString(str, sizeof(str),
- "%f",
+ AP4_FormatString(str, sizeof(str),
+ "%f",
value);
m_Stream->WriteString(name);
m_Stream->WriteString(" = ");
@@ -951,8 +876,8 @@ AP4_PrintInspector::AddFieldF(const char* name, float value, FormatHint /*hint*/
| AP4_PrintInspector::AddField
+---------------------------------------------------------------------*/
void
-AP4_PrintInspector::AddField(const char* name,
- const unsigned char* bytes,
+AP4_PrintInspector::AddField(const char* name,
+ const unsigned char* bytes,
AP4_Size byte_count,
FormatHint /* hint */)
{
@@ -964,10 +889,9 @@ AP4_PrintInspector::AddField(const char* name,
m_Stream->WriteString(" = [");
unsigned int offset = 1;
char byte[4];
- for(unsigned int i = 0; i < byte_count; i++)
- {
+ for (unsigned int i=0; i<byte_count; i++) {
AP4_FormatString(byte, 4, " %02x", bytes[i]);
- m_Stream->Write(&byte[offset], 3 - offset);
+ m_Stream->Write(&byte[offset], 3-offset);
offset = 0;
}
m_Stream->Write("]\n", 2);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.h
index 9685547ac..7301821a3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Atom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - Atoms
+| AP4 - Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -26,7 +26,7 @@
|
****************************************************************/
/**
-* @file
+* @file
* @brief Atoms
*/
@@ -72,14 +72,12 @@ class AP4_AtomParent;
+---------------------------------------------------------------------*/
/**
* Class used in a visitor pattern to walk all the atoms in a tree of
- * #AP4_Atom objects.
+ * #AP4_Atom objects.
*/
-class AP4_AtomInspector
-{
+class AP4_AtomInspector {
public:
// types
- typedef enum
- {
+ typedef enum {
HINT_NONE = 0,
HINT_HEX = 1,
HINT_BOOLEAN = 2
@@ -90,45 +88,35 @@ public:
virtual ~AP4_AtomInspector() {}
// methods
- void SetVerbosity(AP4_Ordinal verbosity)
- {
- m_Verbosity = verbosity;
- }
- AP4_Ordinal GetVerbosity()
- {
- return m_Verbosity;
- }
-
+ void SetVerbosity(AP4_Ordinal verbosity) { m_Verbosity = verbosity; }
+ AP4_Ordinal GetVerbosity() { return m_Verbosity; }
+
// virtual methods
- virtual void StartElement(const char* /* name */,
+ virtual void StartElement(const char* /* name */,
const char* /* extra = NULL */) {}
virtual void EndElement() {}
- virtual void AddField(const char* /* name */,
- AP4_UI64 /* value */,
- FormatHint hint = HINT_NONE)
- {
+ virtual void AddField(const char* /* name */,
+ AP4_UI64 /* value */,
+ FormatHint hint = HINT_NONE) {
(void)hint; // gcc warning
}
- virtual void AddFieldF(const char* /* name */,
- float /* value */,
- FormatHint hint = HINT_NONE)
- {
+ virtual void AddFieldF(const char* /* name */,
+ float /* value */,
+ FormatHint hint = HINT_NONE) {
(void)hint; // gcc warning
}
- virtual void AddField(const char* /* name */,
- const char* /* value */,
- FormatHint hint = HINT_NONE)
- {
- (void)hint; // gcc warning
+ virtual void AddField(const char* /* name */,
+ const char* /* value */,
+ FormatHint hint = HINT_NONE) {
+ (void)hint; // gcc warning
}
- virtual void AddField(const char* /* name */,
- const unsigned char* /* bytes */,
- AP4_Size /* byte_count */,
- FormatHint hint = HINT_NONE)
- {
- (void)hint; // gcc warning
+ virtual void AddField(const char* /* name */,
+ const unsigned char* /* bytes */,
+ AP4_Size /* byte_count */,
+ FormatHint hint = HINT_NONE) {
+ (void)hint; // gcc warning
}
-
+
protected:
AP4_Ordinal m_Verbosity;
};
@@ -136,10 +124,9 @@ protected:
/*----------------------------------------------------------------------
| AP4_PrintInspector
+---------------------------------------------------------------------*/
-class AP4_PrintInspector : public AP4_AtomInspector
-{
+class AP4_PrintInspector : public AP4_AtomInspector {
public:
- AP4_PrintInspector(AP4_ByteStream& stream, AP4_Cardinal indent = 0);
+ AP4_PrintInspector(AP4_ByteStream& stream, AP4_Cardinal indent=0);
~AP4_PrintInspector();
// methods
@@ -162,18 +149,17 @@ private:
/**
* Abstract base class for all atom types.
*/
-class AP4_Atom
-{
+class AP4_Atom {
public:
- AP4_IMPLEMENT_DYNAMIC_CAST(AP4_Atom)
+ AP4_IMPLEMENT_DYNAMIC_CAST(AP4_Atom)
- // types
+ // types
typedef AP4_UI32 Type;
// class methods
static Type TypeFromString(const char* four_cc);
- static AP4_Result ReadFullHeader(AP4_ByteStream& stream,
- AP4_UI32& version,
+ static AP4_Result ReadFullHeader(AP4_ByteStream& stream,
+ AP4_UI32& version,
AP4_UI32& flags);
// constructors
@@ -185,87 +171,55 @@ public:
/**
* Create a simple atom with a specified type and 64-bit size.
*/
- explicit AP4_Atom(Type type, AP4_UI64 size, bool force_64 = false);
+ explicit AP4_Atom(Type type, AP4_UI64 size, bool force_64=false);
/**
* Create a full atom with a specified type, 32-bit size, version and flags.
*/
- explicit AP4_Atom(Type type,
+ explicit AP4_Atom(Type type,
AP4_UI32 size,
- AP4_UI32 version,
+ AP4_UI32 version,
AP4_UI32 flags);
/**
* Create a full atom with a specified type, 64-bit size, version and flags.
*/
- explicit AP4_Atom(Type type,
+ explicit AP4_Atom(Type type,
AP4_UI64 size,
bool force_64,
- AP4_UI32 version,
+ AP4_UI32 version,
AP4_UI32 flags);
// destructor
virtual ~AP4_Atom() {}
-
+
// methods
- AP4_UI32 GetFlags() const
- {
- return m_Flags;
- }
- void SetFlags(AP4_UI32 flags)
- {
- m_Flags = flags;
- }
- Type GetType() const
- {
- return m_Type;
- }
- void SetType(Type type)
- {
- m_Type = type;
- }
+ AP4_UI32 GetFlags() const { return m_Flags; }
+ void SetFlags(AP4_UI32 flags) { m_Flags = flags; }
+ Type GetType() const { return m_Type; }
+ void SetType(Type type) { m_Type = type; }
virtual AP4_Size GetHeaderSize() const;
- AP4_UI64 GetSize() const
- {
- return m_Size32 == 1 ? m_Size64 : m_Size32;
- }
+ AP4_UI64 GetSize() const { return m_Size32 == 1?m_Size64:m_Size32; }
void SetSize(AP4_UI64 size, bool force_64 = false);
- AP4_UI32 GetSize32() const
- {
- return m_Size32;
- }
- void SetSize32(AP4_UI32 size)
- {
- m_Size32 = size;
- }
- AP4_UI64 GetSize64() const
- {
- return m_Size64;
- }
- void SetSize64(AP4_UI64 size)
- {
- m_Size64 = size;
- }
+ AP4_UI32 GetSize32() const { return m_Size32; }
+ void SetSize32(AP4_UI32 size) { m_Size32 = size; }
+ AP4_UI64 GetSize64() const { return m_Size64; }
+ void SetSize64(AP4_UI64 size) { m_Size64 = size; }
virtual AP4_Result Write(AP4_ByteStream& stream);
virtual AP4_Result WriteHeader(AP4_ByteStream& stream);
virtual AP4_Result WriteFields(AP4_ByteStream& stream) = 0;
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
virtual AP4_Result InspectHeader(AP4_AtomInspector& inspector);
- virtual AP4_Result InspectFields(AP4_AtomInspector& /* inspector */)
- {
- return AP4_SUCCESS;
+ virtual AP4_Result InspectFields(AP4_AtomInspector& /* inspector */) {
+ return AP4_SUCCESS;
}
// parent/child relationship methods
- virtual AP4_Result SetParent(AP4_AtomParent* parent)
- {
+ virtual AP4_Result SetParent(AP4_AtomParent* parent) {
m_Parent = parent;
return AP4_SUCCESS;
}
- virtual AP4_AtomParent* GetParent()
- {
- return m_Parent;
- }
+ virtual AP4_AtomParent* GetParent() { return m_Parent; }
virtual AP4_Result Detach();
/**
@@ -274,15 +228,15 @@ public:
* the atom cannot be cloned.
* Override this if your want to make an atom cloneable in a more
* efficient way than the default implementation.
- */
+ */
virtual AP4_Atom* Clone();
-protected:
+ protected:
// members
Type m_Type;
- AP4_UI32 m_Size32;
+ AP4_UI32 m_Size32;
AP4_UI64 m_Size64; // this is 0 if m_Size is not 1 (encoded in 32-bits)
- // and non-zero only if m_Size is 1 (encoded in 64-bits)
+ // and non-zero only if m_Size is 1 (encoded in 64-bits)
bool m_IsFull;
AP4_UI32 m_Version;
AP4_UI32 m_Flags;
@@ -296,23 +250,19 @@ protected:
* Base class for containers of atoms.
* This class also implements the logic for finding descendents by name.
*/
-class AP4_AtomParent
-{
+class AP4_AtomParent {
public:
AP4_IMPLEMENT_DYNAMIC_CAST(AP4_AtomParent)
// base methods
virtual ~AP4_AtomParent();
- AP4_List<AP4_Atom>& GetChildren()
- {
- return m_Children;
- }
+ AP4_List<AP4_Atom>& GetChildren() { return m_Children; }
virtual AP4_Result AddChild(AP4_Atom* child, int position = -1);
virtual AP4_Result RemoveChild(AP4_Atom* child);
virtual AP4_Result DeleteChild(AP4_Atom::Type type, AP4_Ordinal index = 0);
virtual AP4_Atom* GetChild(AP4_Atom::Type type, AP4_Ordinal index = 0) const;
virtual AP4_Atom* GetChild(const AP4_UI08* uuid, AP4_Ordinal index = 0) const;
- virtual AP4_Atom* FindChild(const char* path,
+ virtual AP4_Atom* FindChild(const char* path,
bool auto_create = false,
bool auto_create_full = false);
@@ -331,18 +281,17 @@ protected:
+---------------------------------------------------------------------*/
/**
* Class that represents atoms for which there is no specific support.
- * Instances of this class keep a reference to the stream from which
+ * Instances of this class keep a reference to the stream from which
* the atom is parsed, so that it can read the atom's payload when it
* is serialized.
- * If the atom is small, its payload is actually read and stored in
+ * If the atom is small, its payload is actually read and stored in
* a data buffer, so no reference to the source stream is kept
*/
-class AP4_UnknownAtom : public AP4_Atom
-{
+class AP4_UnknownAtom : public AP4_Atom {
public:
// constructor and destructor
- AP4_UnknownAtom(AP4_Atom::Type type,
- AP4_UI64 size,
+ AP4_UnknownAtom(AP4_Atom::Type type,
+ AP4_UI64 size,
AP4_ByteStream& stream);
AP4_UnknownAtom(AP4_Atom::Type type, const AP4_UI08* payload, AP4_Size payload_size);
AP4_UnknownAtom(const AP4_UnknownAtom& other);
@@ -376,11 +325,8 @@ public:
AP4_NullTerminatedStringAtom(AP4_Atom::Type type, const char* value);
// accessors
- const AP4_String& GetValue()
- {
- return m_Value;
- }
-
+ const AP4_String& GetValue() { return m_Value; }
+
// methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
@@ -393,133 +339,133 @@ private:
/*----------------------------------------------------------------------
| atom types
+---------------------------------------------------------------------*/
-const AP4_Atom::Type AP4_ATOM_TYPE_UDTA = AP4_ATOM_TYPE('u', 'd', 't', 'a');
-const AP4_Atom::Type AP4_ATOM_TYPE_URL = AP4_ATOM_TYPE('u', 'r', 'l', ' ');
-const AP4_Atom::Type AP4_ATOM_TYPE_TRAK = AP4_ATOM_TYPE('t', 'r', 'a', 'k');
-const AP4_Atom::Type AP4_ATOM_TYPE_TRAF = AP4_ATOM_TYPE('t', 'r', 'a', 'f');
-const AP4_Atom::Type AP4_ATOM_TYPE_TKHD = AP4_ATOM_TYPE('t', 'k', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_TFHD = AP4_ATOM_TYPE('t', 'f', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_TRUN = AP4_ATOM_TYPE('t', 'r', 'u', 'n');
-const AP4_Atom::Type AP4_ATOM_TYPE_STTS = AP4_ATOM_TYPE('s', 't', 't', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_STSZ = AP4_ATOM_TYPE('s', 't', 's', 'z');
-const AP4_Atom::Type AP4_ATOM_TYPE_STSS = AP4_ATOM_TYPE('s', 't', 's', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_STSD = AP4_ATOM_TYPE('s', 't', 's', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_STSC = AP4_ATOM_TYPE('s', 't', 's', 'c');
-const AP4_Atom::Type AP4_ATOM_TYPE_STCO = AP4_ATOM_TYPE('s', 't', 'c', 'o');
-const AP4_Atom::Type AP4_ATOM_TYPE_CO64 = AP4_ATOM_TYPE('c', 'o', '6', '4');
-const AP4_Atom::Type AP4_ATOM_TYPE_STBL = AP4_ATOM_TYPE('s', 't', 'b', 'l');
-const AP4_Atom::Type AP4_ATOM_TYPE_SINF = AP4_ATOM_TYPE('s', 'i', 'n', 'f');
-const AP4_Atom::Type AP4_ATOM_TYPE_SCHM = AP4_ATOM_TYPE('s', 'c', 'h', 'm');
-const AP4_Atom::Type AP4_ATOM_TYPE_SCHI = AP4_ATOM_TYPE('s', 'c', 'h', 'i');
-const AP4_Atom::Type AP4_ATOM_TYPE_MVHD = AP4_ATOM_TYPE('m', 'v', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_MEHD = AP4_ATOM_TYPE('m', 'e', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_MP4S = AP4_ATOM_TYPE('m', 'p', '4', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_MP4A = AP4_ATOM_TYPE('m', 'p', '4', 'a');
-const AP4_Atom::Type AP4_ATOM_TYPE_MP4V = AP4_ATOM_TYPE('m', 'p', '4', 'v');
-const AP4_Atom::Type AP4_ATOM_TYPE_AVC1 = AP4_ATOM_TYPE('a', 'v', 'c', '1');
-const AP4_Atom::Type AP4_ATOM_TYPE_ALAC = AP4_ATOM_TYPE('a', 'l', 'a', 'c');
-const AP4_Atom::Type AP4_ATOM_TYPE_ENCA = AP4_ATOM_TYPE('e', 'n', 'c', 'a');
-const AP4_Atom::Type AP4_ATOM_TYPE_ENCV = AP4_ATOM_TYPE('e', 'n', 'c', 'v');
-const AP4_Atom::Type AP4_ATOM_TYPE_MOOV = AP4_ATOM_TYPE('m', 'o', 'o', 'v');
-const AP4_Atom::Type AP4_ATOM_TYPE_MOOF = AP4_ATOM_TYPE('m', 'o', 'o', 'f');
-const AP4_Atom::Type AP4_ATOM_TYPE_MVEX = AP4_ATOM_TYPE('m', 'v', 'e', 'x');
-const AP4_Atom::Type AP4_ATOM_TYPE_TREX = AP4_ATOM_TYPE('t', 'r', 'e', 'x');
-const AP4_Atom::Type AP4_ATOM_TYPE_MINF = AP4_ATOM_TYPE('m', 'i', 'n', 'f');
-const AP4_Atom::Type AP4_ATOM_TYPE_META = AP4_ATOM_TYPE('m', 'e', 't', 'a');
-const AP4_Atom::Type AP4_ATOM_TYPE_MDHD = AP4_ATOM_TYPE('m', 'd', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_MFHD = AP4_ATOM_TYPE('m', 'f', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_ILST = AP4_ATOM_TYPE('i', 'l', 's', 't');
-const AP4_Atom::Type AP4_ATOM_TYPE_HDLR = AP4_ATOM_TYPE('h', 'd', 'l', 'r');
-const AP4_Atom::Type AP4_ATOM_TYPE_FTYP = AP4_ATOM_TYPE('f', 't', 'y', 'p');
-const AP4_Atom::Type AP4_ATOM_TYPE_IODS = AP4_ATOM_TYPE('i', 'o', 'd', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_ESDS = AP4_ATOM_TYPE('e', 's', 'd', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_EDTS = AP4_ATOM_TYPE('e', 'd', 't', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_DRMS = AP4_ATOM_TYPE('d', 'r', 'm', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_DRMI = AP4_ATOM_TYPE('d', 'r', 'm', 'i');
-const AP4_Atom::Type AP4_ATOM_TYPE_DREF = AP4_ATOM_TYPE('d', 'r', 'e', 'f');
-const AP4_Atom::Type AP4_ATOM_TYPE_DINF = AP4_ATOM_TYPE('d', 'i', 'n', 'f');
-const AP4_Atom::Type AP4_ATOM_TYPE_CTTS = AP4_ATOM_TYPE('c', 't', 't', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_MDIA = AP4_ATOM_TYPE('m', 'd', 'i', 'a');
-const AP4_Atom::Type AP4_ATOM_TYPE_ELST = AP4_ATOM_TYPE('e', 'l', 's', 't');
-const AP4_Atom::Type AP4_ATOM_TYPE_VMHD = AP4_ATOM_TYPE('v', 'm', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_SMHD = AP4_ATOM_TYPE('s', 'm', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_NMHD = AP4_ATOM_TYPE('n', 'm', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_HMHD = AP4_ATOM_TYPE('h', 'm', 'h', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_FRMA = AP4_ATOM_TYPE('f', 'r', 'm', 'a');
-const AP4_Atom::Type AP4_ATOM_TYPE_MDAT = AP4_ATOM_TYPE('m', 'd', 'a', 't');
-const AP4_Atom::Type AP4_ATOM_TYPE_FREE = AP4_ATOM_TYPE('f', 'r', 'e', 'e');
-const AP4_Atom::Type AP4_ATOM_TYPE_TIMS = AP4_ATOM_TYPE('t', 'i', 'm', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_RTP_ = AP4_ATOM_TYPE('r', 't', 'p', ' ');
-const AP4_Atom::Type AP4_ATOM_TYPE_HNTI = AP4_ATOM_TYPE('h', 'n', 't', 'i');
-const AP4_Atom::Type AP4_ATOM_TYPE_SDP_ = AP4_ATOM_TYPE('s', 'd', 'p', ' ');
-const AP4_Atom::Type AP4_ATOM_TYPE_IKMS = AP4_ATOM_TYPE('i', 'K', 'M', 'S');
-const AP4_Atom::Type AP4_ATOM_TYPE_ISFM = AP4_ATOM_TYPE('i', 'S', 'F', 'M');
-const AP4_Atom::Type AP4_ATOM_TYPE_ISLT = AP4_ATOM_TYPE('i', 'S', 'L', 'T');
-const AP4_Atom::Type AP4_ATOM_TYPE_TREF = AP4_ATOM_TYPE('t', 'r', 'e', 'f');
-const AP4_Atom::Type AP4_ATOM_TYPE_HINT = AP4_ATOM_TYPE('h', 'i', 'n', 't');
-const AP4_Atom::Type AP4_ATOM_TYPE_CDSC = AP4_ATOM_TYPE('c', 'd', 's', 'c');
-const AP4_Atom::Type AP4_ATOM_TYPE_MPOD = AP4_ATOM_TYPE('m', 'p', 'o', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_IPIR = AP4_ATOM_TYPE('i', 'p', 'i', 'r');
-const AP4_Atom::Type AP4_ATOM_TYPE_CHAP = AP4_ATOM_TYPE('c', 'h', 'a', 'p');
-const AP4_Atom::Type AP4_ATOM_TYPE_ALIS = AP4_ATOM_TYPE('a', 'l', 'i', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_SYNC = AP4_ATOM_TYPE('s', 'y', 'n', 'c');
-const AP4_Atom::Type AP4_ATOM_TYPE_DPND = AP4_ATOM_TYPE('d', 'p', 'n', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_ODRM = AP4_ATOM_TYPE('o', 'd', 'r', 'm');
-const AP4_Atom::Type AP4_ATOM_TYPE_ODKM = AP4_ATOM_TYPE('o', 'd', 'k', 'm');
-const AP4_Atom::Type AP4_ATOM_TYPE_OHDR = AP4_ATOM_TYPE('o', 'h', 'd', 'r');
-const AP4_Atom::Type AP4_ATOM_TYPE_ODDA = AP4_ATOM_TYPE('o', 'd', 'd', 'a');
-const AP4_Atom::Type AP4_ATOM_TYPE_ODHE = AP4_ATOM_TYPE('o', 'd', 'h', 'e');
-const AP4_Atom::Type AP4_ATOM_TYPE_ODAF = AP4_ATOM_TYPE('o', 'd', 'a', 'f');
-const AP4_Atom::Type AP4_ATOM_TYPE_GRPI = AP4_ATOM_TYPE('g', 'r', 'p', 'i');
-const AP4_Atom::Type AP4_ATOM_TYPE_IPRO = AP4_ATOM_TYPE('i', 'p', 'r', 'o');
-const AP4_Atom::Type AP4_ATOM_TYPE_MDRI = AP4_ATOM_TYPE('m', 'd', 'r', 'i');
-const AP4_Atom::Type AP4_ATOM_TYPE_AVCC = AP4_ATOM_TYPE('a', 'v', 'c', 'C');
-const AP4_Atom::Type AP4_ATOM_TYPE_WAVE = AP4_ATOM_TYPE('w', 'a', 'v', 'e');
-const AP4_Atom::Type AP4_ATOM_TYPE_WIDE = AP4_ATOM_TYPE('w', 'i', 'd', 'e');
-const AP4_Atom::Type AP4_ATOM_TYPE_UUID = AP4_ATOM_TYPE('u', 'u', 'i', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_8ID_ = AP4_ATOM_TYPE('8', 'i', 'd', ' ');
-const AP4_Atom::Type AP4_ATOM_TYPE_8BDL = AP4_ATOM_TYPE('8', 'b', 'd', 'l');
-const AP4_Atom::Type AP4_ATOM_TYPE_AC_3 = AP4_ATOM_TYPE('a', 'c', '-', '3');
-const AP4_Atom::Type AP4_ATOM_TYPE_EC_3 = AP4_ATOM_TYPE('e', 'c', '-', '3');
-const AP4_Atom::Type AP4_ATOM_TYPE_MFRA = AP4_ATOM_TYPE('m', 'f', 'r', 'a');
-const AP4_Atom::Type AP4_ATOM_TYPE_TFRA = AP4_ATOM_TYPE('t', 'f', 'r', 'a');
-const AP4_Atom::Type AP4_ATOM_TYPE_MFRO = AP4_ATOM_TYPE('m', 'f', 'r', 'o');
+const AP4_Atom::Type AP4_ATOM_TYPE_UDTA = AP4_ATOM_TYPE('u','d','t','a');
+const AP4_Atom::Type AP4_ATOM_TYPE_URL = AP4_ATOM_TYPE('u','r','l',' ');
+const AP4_Atom::Type AP4_ATOM_TYPE_TRAK = AP4_ATOM_TYPE('t','r','a','k');
+const AP4_Atom::Type AP4_ATOM_TYPE_TRAF = AP4_ATOM_TYPE('t','r','a','f');
+const AP4_Atom::Type AP4_ATOM_TYPE_TKHD = AP4_ATOM_TYPE('t','k','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_TFHD = AP4_ATOM_TYPE('t','f','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_TRUN = AP4_ATOM_TYPE('t','r','u','n');
+const AP4_Atom::Type AP4_ATOM_TYPE_STTS = AP4_ATOM_TYPE('s','t','t','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_STSZ = AP4_ATOM_TYPE('s','t','s','z');
+const AP4_Atom::Type AP4_ATOM_TYPE_STSS = AP4_ATOM_TYPE('s','t','s','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_STSD = AP4_ATOM_TYPE('s','t','s','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_STSC = AP4_ATOM_TYPE('s','t','s','c');
+const AP4_Atom::Type AP4_ATOM_TYPE_STCO = AP4_ATOM_TYPE('s','t','c','o');
+const AP4_Atom::Type AP4_ATOM_TYPE_CO64 = AP4_ATOM_TYPE('c','o','6','4');
+const AP4_Atom::Type AP4_ATOM_TYPE_STBL = AP4_ATOM_TYPE('s','t','b','l');
+const AP4_Atom::Type AP4_ATOM_TYPE_SINF = AP4_ATOM_TYPE('s','i','n','f');
+const AP4_Atom::Type AP4_ATOM_TYPE_SCHM = AP4_ATOM_TYPE('s','c','h','m');
+const AP4_Atom::Type AP4_ATOM_TYPE_SCHI = AP4_ATOM_TYPE('s','c','h','i');
+const AP4_Atom::Type AP4_ATOM_TYPE_MVHD = AP4_ATOM_TYPE('m','v','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_MEHD = AP4_ATOM_TYPE('m','e','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_MP4S = AP4_ATOM_TYPE('m','p','4','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_MP4A = AP4_ATOM_TYPE('m','p','4','a');
+const AP4_Atom::Type AP4_ATOM_TYPE_MP4V = AP4_ATOM_TYPE('m','p','4','v');
+const AP4_Atom::Type AP4_ATOM_TYPE_AVC1 = AP4_ATOM_TYPE('a','v','c','1');
+const AP4_Atom::Type AP4_ATOM_TYPE_ALAC = AP4_ATOM_TYPE('a','l','a','c');
+const AP4_Atom::Type AP4_ATOM_TYPE_ENCA = AP4_ATOM_TYPE('e','n','c','a');
+const AP4_Atom::Type AP4_ATOM_TYPE_ENCV = AP4_ATOM_TYPE('e','n','c','v');
+const AP4_Atom::Type AP4_ATOM_TYPE_MOOV = AP4_ATOM_TYPE('m','o','o','v');
+const AP4_Atom::Type AP4_ATOM_TYPE_MOOF = AP4_ATOM_TYPE('m','o','o','f');
+const AP4_Atom::Type AP4_ATOM_TYPE_MVEX = AP4_ATOM_TYPE('m','v','e','x');
+const AP4_Atom::Type AP4_ATOM_TYPE_TREX = AP4_ATOM_TYPE('t','r','e','x');
+const AP4_Atom::Type AP4_ATOM_TYPE_MINF = AP4_ATOM_TYPE('m','i','n','f');
+const AP4_Atom::Type AP4_ATOM_TYPE_META = AP4_ATOM_TYPE('m','e','t','a');
+const AP4_Atom::Type AP4_ATOM_TYPE_MDHD = AP4_ATOM_TYPE('m','d','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_MFHD = AP4_ATOM_TYPE('m','f','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_ILST = AP4_ATOM_TYPE('i','l','s','t');
+const AP4_Atom::Type AP4_ATOM_TYPE_HDLR = AP4_ATOM_TYPE('h','d','l','r');
+const AP4_Atom::Type AP4_ATOM_TYPE_FTYP = AP4_ATOM_TYPE('f','t','y','p');
+const AP4_Atom::Type AP4_ATOM_TYPE_IODS = AP4_ATOM_TYPE('i','o','d','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_ESDS = AP4_ATOM_TYPE('e','s','d','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_EDTS = AP4_ATOM_TYPE('e','d','t','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_DRMS = AP4_ATOM_TYPE('d','r','m','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_DRMI = AP4_ATOM_TYPE('d','r','m','i');
+const AP4_Atom::Type AP4_ATOM_TYPE_DREF = AP4_ATOM_TYPE('d','r','e','f');
+const AP4_Atom::Type AP4_ATOM_TYPE_DINF = AP4_ATOM_TYPE('d','i','n','f');
+const AP4_Atom::Type AP4_ATOM_TYPE_CTTS = AP4_ATOM_TYPE('c','t','t','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_MDIA = AP4_ATOM_TYPE('m','d','i','a');
+const AP4_Atom::Type AP4_ATOM_TYPE_ELST = AP4_ATOM_TYPE('e','l','s','t');
+const AP4_Atom::Type AP4_ATOM_TYPE_VMHD = AP4_ATOM_TYPE('v','m','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_SMHD = AP4_ATOM_TYPE('s','m','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_NMHD = AP4_ATOM_TYPE('n','m','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_HMHD = AP4_ATOM_TYPE('h','m','h','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_FRMA = AP4_ATOM_TYPE('f','r','m','a');
+const AP4_Atom::Type AP4_ATOM_TYPE_MDAT = AP4_ATOM_TYPE('m','d','a','t');
+const AP4_Atom::Type AP4_ATOM_TYPE_FREE = AP4_ATOM_TYPE('f','r','e','e');
+const AP4_Atom::Type AP4_ATOM_TYPE_TIMS = AP4_ATOM_TYPE('t','i','m','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_RTP_ = AP4_ATOM_TYPE('r','t','p',' ');
+const AP4_Atom::Type AP4_ATOM_TYPE_HNTI = AP4_ATOM_TYPE('h','n','t','i');
+const AP4_Atom::Type AP4_ATOM_TYPE_SDP_ = AP4_ATOM_TYPE('s','d','p',' ');
+const AP4_Atom::Type AP4_ATOM_TYPE_IKMS = AP4_ATOM_TYPE('i','K','M','S');
+const AP4_Atom::Type AP4_ATOM_TYPE_ISFM = AP4_ATOM_TYPE('i','S','F','M');
+const AP4_Atom::Type AP4_ATOM_TYPE_ISLT = AP4_ATOM_TYPE('i','S','L','T');
+const AP4_Atom::Type AP4_ATOM_TYPE_TREF = AP4_ATOM_TYPE('t','r','e','f');
+const AP4_Atom::Type AP4_ATOM_TYPE_HINT = AP4_ATOM_TYPE('h','i','n','t');
+const AP4_Atom::Type AP4_ATOM_TYPE_CDSC = AP4_ATOM_TYPE('c','d','s','c');
+const AP4_Atom::Type AP4_ATOM_TYPE_MPOD = AP4_ATOM_TYPE('m','p','o','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_IPIR = AP4_ATOM_TYPE('i','p','i','r');
+const AP4_Atom::Type AP4_ATOM_TYPE_CHAP = AP4_ATOM_TYPE('c','h','a','p');
+const AP4_Atom::Type AP4_ATOM_TYPE_ALIS = AP4_ATOM_TYPE('a','l','i','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_SYNC = AP4_ATOM_TYPE('s','y','n','c');
+const AP4_Atom::Type AP4_ATOM_TYPE_DPND = AP4_ATOM_TYPE('d','p','n','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_ODRM = AP4_ATOM_TYPE('o','d','r','m');
+const AP4_Atom::Type AP4_ATOM_TYPE_ODKM = AP4_ATOM_TYPE('o','d','k','m');
+const AP4_Atom::Type AP4_ATOM_TYPE_OHDR = AP4_ATOM_TYPE('o','h','d','r');
+const AP4_Atom::Type AP4_ATOM_TYPE_ODDA = AP4_ATOM_TYPE('o','d','d','a');
+const AP4_Atom::Type AP4_ATOM_TYPE_ODHE = AP4_ATOM_TYPE('o','d','h','e');
+const AP4_Atom::Type AP4_ATOM_TYPE_ODAF = AP4_ATOM_TYPE('o','d','a','f');
+const AP4_Atom::Type AP4_ATOM_TYPE_GRPI = AP4_ATOM_TYPE('g','r','p','i');
+const AP4_Atom::Type AP4_ATOM_TYPE_IPRO = AP4_ATOM_TYPE('i','p','r','o');
+const AP4_Atom::Type AP4_ATOM_TYPE_MDRI = AP4_ATOM_TYPE('m','d','r','i');
+const AP4_Atom::Type AP4_ATOM_TYPE_AVCC = AP4_ATOM_TYPE('a','v','c','C');
+const AP4_Atom::Type AP4_ATOM_TYPE_WAVE = AP4_ATOM_TYPE('w','a','v','e');
+const AP4_Atom::Type AP4_ATOM_TYPE_WIDE = AP4_ATOM_TYPE('w','i','d','e');
+const AP4_Atom::Type AP4_ATOM_TYPE_UUID = AP4_ATOM_TYPE('u','u','i','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_8ID_ = AP4_ATOM_TYPE('8','i','d',' ');
+const AP4_Atom::Type AP4_ATOM_TYPE_8BDL = AP4_ATOM_TYPE('8','b','d','l');
+const AP4_Atom::Type AP4_ATOM_TYPE_AC_3 = AP4_ATOM_TYPE('a','c','-','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_EC_3 = AP4_ATOM_TYPE('e','c','-','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_MFRA = AP4_ATOM_TYPE('m','f','r','a');
+const AP4_Atom::Type AP4_ATOM_TYPE_TFRA = AP4_ATOM_TYPE('t','f','r','a');
+const AP4_Atom::Type AP4_ATOM_TYPE_MFRO = AP4_ATOM_TYPE('m','f','r','o');
// ==> Start patch MPC
-const AP4_Atom::Type AP4_ATOM_TYPE_FTAB = AP4_ATOM_TYPE('f', 't', 'a', 'b');
-const AP4_Atom::Type AP4_ATOM_TYPE_CHPL = AP4_ATOM_TYPE('c', 'h', 'p', 'l');
-const AP4_Atom::Type AP4_ATOM_TYPE_SAC3 = AP4_ATOM_TYPE('s', 'a', 'c', '3');
-const AP4_Atom::Type AP4_ATOM_TYPE_DTSC = AP4_ATOM_TYPE('d', 't', 's', 'c');
-const AP4_Atom::Type AP4_ATOM_TYPE_NAM = AP4_ATOM_TYPE(169, 'n', 'a', 'm');
-
-const AP4_Atom::Type AP4_ATOM_TYPE_ART = AP4_ATOM_TYPE(169, 'A', 'R', 'T');
-const AP4_Atom::Type AP4_ATOM_TYPE_WRT = AP4_ATOM_TYPE(169, 'w', 'r', 't');
-const AP4_Atom::Type AP4_ATOM_TYPE_ALB = AP4_ATOM_TYPE(169, 'a', 'l', 'b');
-const AP4_Atom::Type AP4_ATOM_TYPE_DAY = AP4_ATOM_TYPE(169, 'd', 'a', 'y');
-const AP4_Atom::Type AP4_ATOM_TYPE_TOO = AP4_ATOM_TYPE(169, 't', 'o', 'o');
-const AP4_Atom::Type AP4_ATOM_TYPE_CMT = AP4_ATOM_TYPE(169, 'c', 'm', 't');
-const AP4_Atom::Type AP4_ATOM_TYPE_GEN = AP4_ATOM_TYPE(169, 'g', 'e', 'n');
-
-const AP4_Atom::Type AP4_ATOM_TYPE_TEXT = AP4_ATOM_TYPE('t', 'e', 'x', 't');
-const AP4_Atom::Type AP4_ATOM_TYPE_TX3G = AP4_ATOM_TYPE('t', 'x', '3', 'g');
-const AP4_Atom::Type AP4_ATOM_TYPE_CVID = AP4_ATOM_TYPE('c', 'v', 'i', 'd');
-const AP4_Atom::Type AP4_ATOM_TYPE_SVQ1 = AP4_ATOM_TYPE('S', 'V', 'Q', '1');
-const AP4_Atom::Type AP4_ATOM_TYPE_SVQ2 = AP4_ATOM_TYPE('S', 'V', 'Q', '2');
-const AP4_Atom::Type AP4_ATOM_TYPE_SVQ3 = AP4_ATOM_TYPE('S', 'V', 'Q', '3');
-const AP4_Atom::Type AP4_ATOM_TYPE_H263 = AP4_ATOM_TYPE('h', '2', '6', '3');
-const AP4_Atom::Type AP4_ATOM_TYPE_S263 = AP4_ATOM_TYPE('s', '2', '6', '3');
-
-const AP4_Atom::Type AP4_ATOM_TYPE_SAMR = AP4_ATOM_TYPE('s', 'a', 'm', 'r');
-const AP4_Atom::Type AP4_ATOM_TYPE__MP3 = AP4_ATOM_TYPE('.', 'm', 'p', '3');
-const AP4_Atom::Type AP4_ATOM_TYPE_IMA4 = AP4_ATOM_TYPE('i', 'm', 'a', '4');
-const AP4_Atom::Type AP4_ATOM_TYPE_QDMC = AP4_ATOM_TYPE('Q', 'D', 'M', 'C');
-const AP4_Atom::Type AP4_ATOM_TYPE_QDM2 = AP4_ATOM_TYPE('Q', 'D', 'M', '2');
-const AP4_Atom::Type AP4_ATOM_TYPE_TWOS = AP4_ATOM_TYPE('t', 'w', 'o', 's');
-const AP4_Atom::Type AP4_ATOM_TYPE_SOWT = AP4_ATOM_TYPE('s', 'o', 'w', 't');
-
-const AP4_Atom::Type AP4_ATOM_TYPE_CMOV = AP4_ATOM_TYPE('c', 'm', 'o', 'v');
-const AP4_Atom::Type AP4_ATOM_TYPE_DCOM = AP4_ATOM_TYPE('d', 'c', 'o', 'm');
-const AP4_Atom::Type AP4_ATOM_TYPE_CMVD = AP4_ATOM_TYPE('c', 'm', 'v', 'd');
+const AP4_Atom::Type AP4_ATOM_TYPE_FTAB = AP4_ATOM_TYPE('f','t','a','b');
+const AP4_Atom::Type AP4_ATOM_TYPE_CHPL = AP4_ATOM_TYPE('c','h','p','l');
+const AP4_Atom::Type AP4_ATOM_TYPE_SAC3 = AP4_ATOM_TYPE('s','a','c','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_DTSC = AP4_ATOM_TYPE('d','t','s','c');
+const AP4_Atom::Type AP4_ATOM_TYPE_NAM = AP4_ATOM_TYPE(169,'n','a','m');
+
+const AP4_Atom::Type AP4_ATOM_TYPE_ART = AP4_ATOM_TYPE(169,'A','R','T');
+const AP4_Atom::Type AP4_ATOM_TYPE_WRT = AP4_ATOM_TYPE(169,'w','r','t');
+const AP4_Atom::Type AP4_ATOM_TYPE_ALB = AP4_ATOM_TYPE(169,'a','l','b');
+const AP4_Atom::Type AP4_ATOM_TYPE_DAY = AP4_ATOM_TYPE(169,'d','a','y');
+const AP4_Atom::Type AP4_ATOM_TYPE_TOO = AP4_ATOM_TYPE(169,'t','o','o');
+const AP4_Atom::Type AP4_ATOM_TYPE_CMT = AP4_ATOM_TYPE(169,'c','m','t');
+const AP4_Atom::Type AP4_ATOM_TYPE_GEN = AP4_ATOM_TYPE(169,'g','e','n');
+
+const AP4_Atom::Type AP4_ATOM_TYPE_TEXT = AP4_ATOM_TYPE('t','e','x','t');
+const AP4_Atom::Type AP4_ATOM_TYPE_TX3G = AP4_ATOM_TYPE('t','x','3','g');
+const AP4_Atom::Type AP4_ATOM_TYPE_CVID = AP4_ATOM_TYPE('c','v','i','d');
+const AP4_Atom::Type AP4_ATOM_TYPE_SVQ1 = AP4_ATOM_TYPE('S','V','Q','1');
+const AP4_Atom::Type AP4_ATOM_TYPE_SVQ2 = AP4_ATOM_TYPE('S','V','Q','2');
+const AP4_Atom::Type AP4_ATOM_TYPE_SVQ3 = AP4_ATOM_TYPE('S','V','Q','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_H263 = AP4_ATOM_TYPE('h','2','6','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_S263 = AP4_ATOM_TYPE('s','2','6','3');
+
+const AP4_Atom::Type AP4_ATOM_TYPE_SAMR = AP4_ATOM_TYPE('s','a','m','r');
+const AP4_Atom::Type AP4_ATOM_TYPE__MP3 = AP4_ATOM_TYPE('.','m','p','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_IMA4 = AP4_ATOM_TYPE('i','m','a','4');
+const AP4_Atom::Type AP4_ATOM_TYPE_QDMC = AP4_ATOM_TYPE('Q','D','M','C');
+const AP4_Atom::Type AP4_ATOM_TYPE_QDM2 = AP4_ATOM_TYPE('Q','D','M','2');
+const AP4_Atom::Type AP4_ATOM_TYPE_TWOS = AP4_ATOM_TYPE('t','w','o','s');
+const AP4_Atom::Type AP4_ATOM_TYPE_SOWT = AP4_ATOM_TYPE('s','o','w','t');
+
+const AP4_Atom::Type AP4_ATOM_TYPE_CMOV = AP4_ATOM_TYPE('c','m','o','v');
+const AP4_Atom::Type AP4_ATOM_TYPE_DCOM = AP4_ATOM_TYPE('d','c','o','m');
+const AP4_Atom::Type AP4_ATOM_TYPE_CMVD = AP4_ATOM_TYPE('c','m','v','d');
// <== End patch MPC
@@ -528,16 +474,15 @@ const AP4_Atom::Type AP4_ATOM_TYPE_CMVD = AP4_ATOM_TYPE('c', 'm', 'v', 'd');
+---------------------------------------------------------------------*/
class AP4_AtomListInspector : public AP4_List<AP4_Atom>::Item::Operator
{
-public:
+ public:
AP4_AtomListInspector(AP4_AtomInspector& inspector) :
m_Inspector(inspector) {}
- AP4_Result Action(AP4_Atom* atom) const
- {
+ AP4_Result Action(AP4_Atom* atom) const {
atom->Inspect(m_Inspector);
return AP4_SUCCESS;
}
-private:
+ private:
AP4_AtomInspector& m_Inspector;
};
@@ -546,12 +491,12 @@ private:
+---------------------------------------------------------------------*/
class AP4_AtomListWriter : public AP4_List<AP4_Atom>::Item::Operator
{
-public:
+ public:
AP4_AtomListWriter(AP4_ByteStream& stream) :
m_Stream(stream) {}
AP4_Result Action(AP4_Atom* atom) const;
-private:
+ private:
AP4_ByteStream& m_Stream;
};
@@ -560,28 +505,21 @@ private:
+---------------------------------------------------------------------*/
class AP4_AtomFinder : public AP4_List<AP4_Atom>::Item::Finder
{
-public:
- AP4_AtomFinder(AP4_Atom::Type type, AP4_Ordinal index = 0) :
- m_Type(type), m_Index(index) {}
- AP4_Result Test(AP4_Atom* atom) const
- {
- if(atom->GetType() == m_Type)
- {
- if(m_Index-- == 0)
- {
+ public:
+ AP4_AtomFinder(AP4_Atom::Type type, AP4_Ordinal index = 0) :
+ m_Type(type), m_Index(index) {}
+ AP4_Result Test(AP4_Atom* atom) const {
+ if (atom->GetType() == m_Type) {
+ if (m_Index-- == 0) {
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_FAILURE;
}
- }
- else
- {
+ } else {
return AP4_FAILURE;
}
}
-private:
+ private:
AP4_Atom::Type m_Type;
mutable AP4_Ordinal m_Index;
};
@@ -589,14 +527,12 @@ private:
/*----------------------------------------------------------------------
| AP4_AtomSizeAdder
+---------------------------------------------------------------------*/
-class AP4_AtomSizeAdder : public AP4_List<AP4_Atom>::Item::Operator
-{
+class AP4_AtomSizeAdder : public AP4_List<AP4_Atom>::Item::Operator {
public:
AP4_AtomSizeAdder(AP4_UI64& size) : m_Size(size) {}
private:
- AP4_Result Action(AP4_Atom* atom) const
- {
+ AP4_Result Action(AP4_Atom* atom) const {
m_Size += atom->GetSize();
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.cpp
index 97527d3d7..04158c4aa 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.cpp
@@ -125,18 +125,17 @@ AP4_AtomFactory::RemoveTypeHandler(TypeHandler* handler)
| AP4_AtomFactory::CreateAtomFromStream
+---------------------------------------------------------------------*/
AP4_Result
-AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
+AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
AP4_Atom*& atom)
{
AP4_LargeSize stream_size = 0;
AP4_Position stream_position = 0;
AP4_LargeSize bytes_available = (AP4_LargeSize)(-1);
- if(AP4_SUCCEEDED(stream.GetSize(stream_size)) &&
- stream_size != 0 &&
- AP4_SUCCEEDED(stream.Tell(stream_position)) &&
- stream_position <= stream_size)
- {
- bytes_available = stream_size - stream_position;
+ if (AP4_SUCCEEDED(stream.GetSize(stream_size)) &&
+ stream_size != 0 &&
+ AP4_SUCCEEDED(stream.Tell(stream_position)) &&
+ stream_position <= stream_size) {
+ bytes_available = stream_size-stream_position;
}
return CreateAtomFromStream(stream, bytes_available, atom);
}
@@ -145,7 +144,7 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
| AP4_AtomFactory::CreateAtomFromStream
+---------------------------------------------------------------------*/
AP4_Result
-AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
+AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
AP4_LargeSize& bytes_available,
AP4_Atom*& atom)
{
@@ -155,7 +154,7 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
atom = NULL;
// check that there are enough bytes for at least a header
- if(bytes_available < 8) return AP4_ERROR_EOS;
+ if (bytes_available < 8) return AP4_ERROR_EOS;
// remember current stream offset
AP4_Position start;
@@ -164,8 +163,7 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
// read atom size
AP4_UI32 size_32;
result = stream.ReadUI32(size_32);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
stream.Seek(start);
return result;
}
@@ -174,8 +172,7 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
// read atom type
AP4_Atom::Type type;
result = stream.ReadUI32(type);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
stream.Seek(start);
return result;
}
@@ -183,524 +180,499 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
// handle special size values
bool atom_is_large = false;
bool force_64 = false;
- if(size == 0)
- {
+ if (size == 0) {
// atom extends to end of file
AP4_LargeSize stream_size = 0;
stream.GetSize(stream_size);
- if(stream_size >= start)
- {
+ if (stream_size >= start) {
size = stream_size - start;
}
- }
- else if(size == 1)
- {
+ } else if (size == 1) {
// 64-bit size
atom_is_large = true;
- if(bytes_available < 16)
- {
+ if (bytes_available < 16) {
stream.Seek(start);
return AP4_ERROR_INVALID_FORMAT;
}
stream.ReadUI64(size);
- if(size <= 0xFFFFFFFF)
- {
+ if (size <= 0xFFFFFFFF) {
force_64 = true;
}
}
// check the size
- if((size > 0 && size < 8) || size > bytes_available)
- {
+ if ((size > 0 && size < 8) || size > bytes_available) {
stream.Seek(start);
return AP4_ERROR_INVALID_FORMAT;
}
// create the atom
- if(GetContext() == AP4_ATOM_TYPE_STSD)
- {
+ if (GetContext() == AP4_ATOM_TYPE_STSD) {
// sample entry
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
- switch(type)
- {
- case AP4_ATOM_TYPE_MP4A:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ switch (type) {
+ case AP4_ATOM_TYPE_MP4A:
atom = new AP4_Mp4aSampleEntry(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_MP4V:
+ case AP4_ATOM_TYPE_MP4V:
atom = new AP4_Mp4vSampleEntry(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_MP4S:
+ case AP4_ATOM_TYPE_MP4S:
atom = new AP4_Mp4sSampleEntry(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_ENCA:
+ case AP4_ATOM_TYPE_ENCA:
atom = new AP4_EncaSampleEntry(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_ENCV:
+ case AP4_ATOM_TYPE_ENCV:
atom = new AP4_EncvSampleEntry(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_DRMS:
+ case AP4_ATOM_TYPE_DRMS:
atom = new AP4_DrmsSampleEntry(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_DRMI:
+ case AP4_ATOM_TYPE_DRMI:
atom = new AP4_DrmiSampleEntry(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_AVC1:
+ case AP4_ATOM_TYPE_AVC1:
atom = new AP4_Avc1SampleEntry(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_ALAC:
- // ==> Start patch MPC
+ case AP4_ATOM_TYPE_ALAC:
+ // ==> Start patch MPC
// case AP4_ATOM_TYPE_AC_3:
- // <== End patch MPC
- case AP4_ATOM_TYPE_EC_3:
+ // <== End patch MPC
+ case AP4_ATOM_TYPE_EC_3:
atom = new AP4_AudioSampleEntry(type, size_32, stream, *this);
break;
- // ==> Start patch MPC
- case AP4_ATOM_TYPE_TEXT:
- atom = new AP4_TextSampleEntry((unsigned long)size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_TX3G:
- atom = new AP4_Tx3gSampleEntry((unsigned long)size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_FTAB:
- atom = new AP4_FtabAtom((unsigned long)size, stream);
- break;
-
- case AP4_ATOM_TYPE_CHPL:
- atom = new AP4_ChplAtom((unsigned long)size, stream);
- break;
-
- case AP4_ATOM_TYPE_CVID:
- case AP4_ATOM_TYPE_SVQ1:
- case AP4_ATOM_TYPE_SVQ2:
- case AP4_ATOM_TYPE_SVQ3:
- case AP4_ATOM_TYPE_H263:
- case AP4_ATOM_TYPE_S263:
- atom = new AP4_VisualSampleEntry(type, (unsigned long)size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_SAMR:
- case AP4_ATOM_TYPE__MP3:
- case AP4_ATOM_TYPE_IMA4:
- case AP4_ATOM_TYPE_QDMC:
- case AP4_ATOM_TYPE_QDM2:
- case AP4_ATOM_TYPE_TWOS:
- case AP4_ATOM_TYPE_SOWT:
- atom = new AP4_AudioSampleEntry(type, (unsigned long)size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_AC_3: // AC3-in-MP4 from ISO Standard
- case AP4_ATOM_TYPE_SAC3: // AC3-in-MP4 from Nero Stuff >.<
- atom = new AP4_AC3SampleEntry(type, (unsigned long)size, stream, *this);
- break;
- // <== End patch MPC
-
- case AP4_ATOM_TYPE_RTP_:
+ // ==> Start patch MPC
+ case AP4_ATOM_TYPE_TEXT:
+ atom = new AP4_TextSampleEntry((unsigned long)size, stream, *this);
+ break;
+
+ case AP4_ATOM_TYPE_TX3G:
+ atom = new AP4_Tx3gSampleEntry((unsigned long)size, stream, *this);
+ break;
+
+ case AP4_ATOM_TYPE_FTAB:
+ atom = new AP4_FtabAtom((unsigned long)size, stream);
+ break;
+
+ case AP4_ATOM_TYPE_CHPL:
+ atom = new AP4_ChplAtom((unsigned long)size, stream);
+ break;
+
+ case AP4_ATOM_TYPE_CVID:
+ case AP4_ATOM_TYPE_SVQ1:
+ case AP4_ATOM_TYPE_SVQ2:
+ case AP4_ATOM_TYPE_SVQ3:
+ case AP4_ATOM_TYPE_H263:
+ case AP4_ATOM_TYPE_S263:
+ atom = new AP4_VisualSampleEntry(type, (unsigned long)size, stream, *this);
+ break;
+
+ case AP4_ATOM_TYPE_SAMR:
+ case AP4_ATOM_TYPE__MP3:
+ case AP4_ATOM_TYPE_IMA4:
+ case AP4_ATOM_TYPE_QDMC:
+ case AP4_ATOM_TYPE_QDM2:
+ case AP4_ATOM_TYPE_TWOS:
+ case AP4_ATOM_TYPE_SOWT:
+ atom = new AP4_AudioSampleEntry(type, (unsigned long)size, stream, *this);
+ break;
+
+ case AP4_ATOM_TYPE_AC_3: // AC3-in-MP4 from ISO Standard
+ case AP4_ATOM_TYPE_SAC3: // AC3-in-MP4 from Nero Stuff >.<
+ atom = new AP4_AC3SampleEntry(type, (unsigned long)size, stream, *this);
+ break;
+ // <== End patch MPC
+
+ case AP4_ATOM_TYPE_RTP_:
atom = new AP4_RtpHintSampleEntry(size_32, stream, *this);
break;
- default:
- {
- // try all the external type handlers
- AP4_List<TypeHandler>::Item* handler_item = m_TypeHandlers.FirstItem();
- while(handler_item)
+ default:
{
- TypeHandler* handler = handler_item->GetData();
- if(AP4_SUCCEEDED(handler->CreateAtom(type, size_32, stream, GetContext(), atom)))
- {
- break;
+ // try all the external type handlers
+ AP4_List<TypeHandler>::Item* handler_item = m_TypeHandlers.FirstItem();
+ while (handler_item) {
+ TypeHandler* handler = handler_item->GetData();
+ if (AP4_SUCCEEDED(handler->CreateAtom(type, size_32, stream, GetContext(), atom))) {
+ break;
+ }
+ handler_item = handler_item->GetNext();
}
- handler_item = handler_item->GetNext();
+
+ // no custom handler, create a generic entry
+ atom = new AP4_UnknownSampleEntry(type, (AP4_Size)size, stream);
}
-
- // no custom handler, create a generic entry
- atom = new AP4_UnknownSampleEntry(type, (AP4_Size)size, stream);
- }
- break;
+ break;
}
- }
- else
- {
+ } else {
// regular atom
- switch(type)
- {
- case AP4_ATOM_TYPE_MOOV:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ switch (type) {
+ case AP4_ATOM_TYPE_MOOV:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_MoovAtom::Create(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_MVHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_MVHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_MvhdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_MEHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_MEHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_MehdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_MFHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_MFHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_MfhdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_TRAK:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_TRAK:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_TrakAtom::Create(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_TREX:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_TREX:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_TrexAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_HDLR:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_HDLR:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_HdlrAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_TKHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_TKHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_TkhdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_TFHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_TFHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_TfhdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_TRUN:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_TRUN:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_TrunAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_TFRA:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_TFRA:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_TfraAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_MFRO:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_MFRO:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_MfroAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_MDHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_MDHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_MdhdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_STSD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_STSD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_StsdAtom::Create(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_STSC:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_STSC:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_StscAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_STCO:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_STCO:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_StcoAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_CO64:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_CO64:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_Co64Atom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_STSZ:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_STSZ:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_StszAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_STTS:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_STTS:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_SttsAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_CTTS:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_CTTS:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_CttsAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_STSS:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_STSS:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_StssAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_IODS:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_IODS:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_IodsAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_ESDS:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_ESDS:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_EsdsAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_AVCC:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_AVCC:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_AvccAtom::Create(size_32, stream);
break;
-
-#if !defined(AP4_CONFIG_MINI_BUILD)
- case AP4_ATOM_TYPE_UUID:
- {
- AP4_UI08 uuid[16];
- result = stream.Read(uuid, 16);
- if(AP4_FAILED(result)) return result;
-
- if(AP4_CompareMemory(uuid, AP4_UUID_PIFF_TRACK_ENCRYPTION_ATOM, 16) == 0)
- {
- atom = AP4_PiffTrackEncryptionAtom::Create((AP4_Size)size, stream);
- }
- else if(AP4_CompareMemory(uuid, AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM, 16) == 0)
- {
- atom = AP4_PiffSampleEncryptionAtom::Create((AP4_Size)size, stream);
- }
- else
- {
- atom = new AP4_UnknownUuidAtom(size, uuid, stream);
- }
- break;
- }
-
- case AP4_ATOM_TYPE_8ID_:
+
+ #if !defined(AP4_CONFIG_MINI_BUILD)
+ case AP4_ATOM_TYPE_UUID: {
+ AP4_UI08 uuid[16];
+ result = stream.Read(uuid, 16);
+ if (AP4_FAILED(result)) return result;
+
+ if (AP4_CompareMemory(uuid, AP4_UUID_PIFF_TRACK_ENCRYPTION_ATOM, 16) == 0) {
+ atom = AP4_PiffTrackEncryptionAtom::Create((AP4_Size)size, stream);
+ } else if (AP4_CompareMemory(uuid, AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM, 16) == 0) {
+ atom = AP4_PiffSampleEncryptionAtom::Create((AP4_Size)size, stream);
+ } else {
+ atom = new AP4_UnknownUuidAtom(size, uuid, stream);
+ }
+ break;
+ }
+
+ case AP4_ATOM_TYPE_8ID_:
atom = new AP4_NullTerminatedStringAtom(type, size, stream);
break;
- case AP4_ATOM_TYPE_8BDL:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_8BDL:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_8bdlAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_DREF:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_DREF:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_DrefAtom::Create(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_URL:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_URL:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_UrlAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_ELST:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_ELST:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_ElstAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_VMHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_VMHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_VmhdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_SMHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_SMHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_SmhdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_NMHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_NMHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_NmhdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_HMHD:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_HMHD:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_HmhdAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_FRMA:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_FRMA:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_FrmaAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_SCHM:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_SCHM:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_SchmAtom::Create(size_32, &m_ContextStack, stream);
break;
- case AP4_ATOM_TYPE_FTYP:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_FTYP:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_FtypAtom::Create(size_32, stream);
break;
-
- case AP4_ATOM_TYPE_TIMS:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+
+ case AP4_ATOM_TYPE_TIMS:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_TimsAtom::Create(size_32, stream);
break;
-
- case AP4_ATOM_TYPE_SDP_:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+
+ case AP4_ATOM_TYPE_SDP_:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_SdpAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_IKMS:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_IKMS:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_IkmsAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_ISFM:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_ISFM:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_IsfmAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_ISLT:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_ISLT:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_IsltAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_ODHE:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_ODHE:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_OdheAtom::Create(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_OHDR:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_OHDR:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_OhdrAtom::Create(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_ODDA:
+ case AP4_ATOM_TYPE_ODDA:
atom = AP4_OddaAtom::Create(size, stream);
break;
- case AP4_ATOM_TYPE_ODAF:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_ODAF:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_OdafAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_GRPI:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_GRPI:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_GrpiAtom::Create(size_32, stream);
break;
- case AP4_ATOM_TYPE_IPRO:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_IPRO:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_IproAtom::Create(size_32, stream, *this);
break;
- case AP4_ATOM_TYPE_RTP_:
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_ATOM_TYPE_RTP_:
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_RtpAtom::Create(size_32, stream);
break;
- // track ref types
- case AP4_ATOM_TYPE_HINT:
- case AP4_ATOM_TYPE_CDSC:
- case AP4_ATOM_TYPE_SYNC:
- case AP4_ATOM_TYPE_MPOD:
- case AP4_ATOM_TYPE_DPND:
- case AP4_ATOM_TYPE_IPIR:
- case AP4_ATOM_TYPE_ALIS:
- case AP4_ATOM_TYPE_CHAP:
- if(GetContext() == AP4_ATOM_TYPE_TREF)
- {
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ // track ref types
+ case AP4_ATOM_TYPE_HINT:
+ case AP4_ATOM_TYPE_CDSC:
+ case AP4_ATOM_TYPE_SYNC:
+ case AP4_ATOM_TYPE_MPOD:
+ case AP4_ATOM_TYPE_DPND:
+ case AP4_ATOM_TYPE_IPIR:
+ case AP4_ATOM_TYPE_ALIS:
+ case AP4_ATOM_TYPE_CHAP:
+ if (GetContext() == AP4_ATOM_TYPE_TREF) {
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_TrefTypeAtom::Create(type, size_32, stream);
}
break;
-#endif // AP4_CONFIG_MINI_BUILD
-
- // container atoms
- case AP4_ATOM_TYPE_MOOF:
- case AP4_ATOM_TYPE_MVEX:
- case AP4_ATOM_TYPE_TRAF:
- case AP4_ATOM_TYPE_TREF:
- case AP4_ATOM_TYPE_MFRA:
- case AP4_ATOM_TYPE_HNTI:
- case AP4_ATOM_TYPE_STBL:
- case AP4_ATOM_TYPE_MDIA:
- case AP4_ATOM_TYPE_DINF:
- case AP4_ATOM_TYPE_MINF:
- case AP4_ATOM_TYPE_SCHI:
- case AP4_ATOM_TYPE_SINF:
- case AP4_ATOM_TYPE_UDTA:
- case AP4_ATOM_TYPE_ILST:
- case AP4_ATOM_TYPE_EDTS:
- case AP4_ATOM_TYPE_MDRI:
- case AP4_ATOM_TYPE_WAVE:
-
- // ==> Start patch MPC
- case AP4_ATOM_TYPE_ART:
- case AP4_ATOM_TYPE_WRT:
- case AP4_ATOM_TYPE_ALB:
- case AP4_ATOM_TYPE_DAY:
- case AP4_ATOM_TYPE_TOO:
- case AP4_ATOM_TYPE_CMT:
- case AP4_ATOM_TYPE_GEN:
- case AP4_ATOM_TYPE_CMOV:
- // <== End patch MPC
-
- if(atom_is_large) return AP4_ERROR_INVALID_FORMAT;
+ #endif // AP4_CONFIG_MINI_BUILD
+
+ // container atoms
+ case AP4_ATOM_TYPE_MOOF:
+ case AP4_ATOM_TYPE_MVEX:
+ case AP4_ATOM_TYPE_TRAF:
+ case AP4_ATOM_TYPE_TREF:
+ case AP4_ATOM_TYPE_MFRA:
+ case AP4_ATOM_TYPE_HNTI:
+ case AP4_ATOM_TYPE_STBL:
+ case AP4_ATOM_TYPE_MDIA:
+ case AP4_ATOM_TYPE_DINF:
+ case AP4_ATOM_TYPE_MINF:
+ case AP4_ATOM_TYPE_SCHI:
+ case AP4_ATOM_TYPE_SINF:
+ case AP4_ATOM_TYPE_UDTA:
+ case AP4_ATOM_TYPE_ILST:
+ case AP4_ATOM_TYPE_EDTS:
+ case AP4_ATOM_TYPE_MDRI:
+ case AP4_ATOM_TYPE_WAVE:
+
+ // ==> Start patch MPC
+ case AP4_ATOM_TYPE_ART:
+ case AP4_ATOM_TYPE_WRT:
+ case AP4_ATOM_TYPE_ALB:
+ case AP4_ATOM_TYPE_DAY:
+ case AP4_ATOM_TYPE_TOO:
+ case AP4_ATOM_TYPE_CMT:
+ case AP4_ATOM_TYPE_GEN:
+ case AP4_ATOM_TYPE_CMOV:
+ // <== End patch MPC
+
+ if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
atom = AP4_ContainerAtom::Create(type, size, false, force_64, stream, *this);
break;
- // full container atoms
- case AP4_ATOM_TYPE_META:
- case AP4_ATOM_TYPE_ODRM:
- case AP4_ATOM_TYPE_ODKM:
+ // full container atoms
+ case AP4_ATOM_TYPE_META:
+ case AP4_ATOM_TYPE_ODRM:
+ case AP4_ATOM_TYPE_ODKM:
atom = AP4_ContainerAtom::Create(type, size, true, force_64, stream, *this);
break;
- case AP4_ATOM_TYPE_FREE:
- case AP4_ATOM_TYPE_WIDE:
- case AP4_ATOM_TYPE_MDAT:
+ case AP4_ATOM_TYPE_FREE:
+ case AP4_ATOM_TYPE_WIDE:
+ case AP4_ATOM_TYPE_MDAT:
// generic atoms
break;
-
- // ==> Start patch MPC
- case AP4_ATOM_TYPE_DCOM:
- atom = AP4_DcomAtom::Create((unsigned long)size, stream);
- break;
- case AP4_ATOM_TYPE_CMVD:
- atom = AP4_CmvdAtom::Create((unsigned long)size, stream, *this);
- break;
- // <== End patch MPC
-
- default:
+
+ // ==> Start patch MPC
+ case AP4_ATOM_TYPE_DCOM:
+ atom = AP4_DcomAtom::Create((unsigned long)size, stream);
+ break;
+ case AP4_ATOM_TYPE_CMVD:
+ atom = AP4_CmvdAtom::Create((unsigned long)size, stream, *this);
+ break;
+ // <== End patch MPC
+
+ default:
// try all the external type handlers
- {
- AP4_List<TypeHandler>::Item* handler_item = m_TypeHandlers.FirstItem();
- while(handler_item)
{
- TypeHandler* handler = handler_item->GetData();
- if(AP4_SUCCEEDED(handler->CreateAtom(type, size_32, stream, GetContext(), atom)))
- {
- break;
+ AP4_List<TypeHandler>::Item* handler_item = m_TypeHandlers.FirstItem();
+ while (handler_item) {
+ TypeHandler* handler = handler_item->GetData();
+ if (AP4_SUCCEEDED(handler->CreateAtom(type, size_32, stream, GetContext(), atom))) {
+ break;
+ }
+ handler_item = handler_item->GetNext();
}
- handler_item = handler_item->GetNext();
- }
- break;
- }
+ break;
+ }
}
}
-
+
// if we failed to create an atom, use a generic version
- if(atom == NULL)
- {
+ if (atom == NULL) {
unsigned int payload_offset = 8;
- if(atom_is_large) payload_offset += 8;
- stream.Seek(start + payload_offset);
+ if (atom_is_large) payload_offset += 8;
+ stream.Seek(start+payload_offset);
atom = new AP4_UnknownAtom(type, size, stream);
}
// special case: if the atom is poorly encoded and has a 64-bit
// size header but an actual size that fits on 32-bit, adjust the
// object to reflect that.
- if(force_64)
- {
+ if (force_64) {
atom->SetSize32(1);
atom->SetSize64(size);
}
@@ -709,14 +681,13 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
bytes_available -= size;
// skip to the end of the atom
- result = stream.Seek(start + size);
- if(AP4_FAILED(result))
- {
+ result = stream.Seek(start+size);
+ if (AP4_FAILED(result)) {
delete atom;
atom = NULL;
return result;
}
-
+
return AP4_SUCCESS;
}
@@ -724,18 +695,17 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
| AP4_AtomFactory::CreateAtomsFromStream
+---------------------------------------------------------------------*/
AP4_Result
-AP4_AtomFactory::CreateAtomsFromStream(AP4_ByteStream& stream,
+AP4_AtomFactory::CreateAtomsFromStream(AP4_ByteStream& stream,
AP4_AtomParent& atoms)
{
AP4_LargeSize stream_size = 0;
AP4_Position stream_position = 0;
AP4_LargeSize bytes_available = (AP4_LargeSize)(-1);
- if(AP4_SUCCEEDED(stream.GetSize(stream_size)) &&
- stream_size != 0 &&
- AP4_SUCCEEDED(stream.Tell(stream_position)) &&
- stream_position <= stream_size)
- {
- bytes_available = stream_size - stream_position;
+ if (AP4_SUCCEEDED(stream.GetSize(stream_size)) &&
+ stream_size != 0 &&
+ AP4_SUCCEEDED(stream.Tell(stream_position)) &&
+ stream_position <= stream_size) {
+ bytes_available = stream_size-stream_position;
}
return CreateAtomsFromStream(stream, bytes_available, atoms);
}
@@ -744,22 +714,19 @@ AP4_AtomFactory::CreateAtomsFromStream(AP4_ByteStream& stream,
| AP4_AtomFactory::CreateAtomsFromStream
+---------------------------------------------------------------------*/
AP4_Result
-AP4_AtomFactory::CreateAtomsFromStream(AP4_ByteStream& stream,
+AP4_AtomFactory::CreateAtomsFromStream(AP4_ByteStream& stream,
AP4_LargeSize bytes_available,
AP4_AtomParent& atoms)
{
AP4_Result result;
- do
- {
+ do {
AP4_Atom* atom = NULL;
result = CreateAtomFromStream(stream, bytes_available, atom);
- if(AP4_SUCCEEDED(result) && atom != NULL)
- {
+ if (AP4_SUCCEEDED(result) && atom != NULL) {
atoms.AddChild(atom);
}
- }
- while(AP4_SUCCEEDED(result));
-
+ } while (AP4_SUCCEEDED(result));
+
return AP4_SUCCESS;
}
@@ -767,7 +734,7 @@ AP4_AtomFactory::CreateAtomsFromStream(AP4_ByteStream& stream,
| AP4_AtomFactory::PushContext
+---------------------------------------------------------------------*/
void
-AP4_AtomFactory::PushContext(AP4_Atom::Type context)
+AP4_AtomFactory::PushContext(AP4_Atom::Type context)
{
m_ContextStack.Append(context);
}
@@ -776,7 +743,7 @@ AP4_AtomFactory::PushContext(AP4_Atom::Type context)
| AP4_AtomFactory::PopContext
+---------------------------------------------------------------------*/
void
-AP4_AtomFactory::PopContext()
+AP4_AtomFactory::PopContext()
{
m_ContextStack.RemoveLast();
}
@@ -785,10 +752,10 @@ AP4_AtomFactory::PopContext()
| AP4_AtomFactory::GetContext
+---------------------------------------------------------------------*/
AP4_Atom::Type
-AP4_AtomFactory::GetContext(AP4_Ordinal depth)
+AP4_AtomFactory::GetContext(AP4_Ordinal depth)
{
AP4_Ordinal available = m_ContextStack.ItemCount();
- if(depth >= available) return 0;
+ if (depth >= available) return 0;
return m_ContextStack[available-depth-1];
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.h
index 8f2ac116a..3c7486a7c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomFactory.h
@@ -44,19 +44,17 @@ class AP4_ByteStream;
/*----------------------------------------------------------------------
| AP4_AtomFactory
+---------------------------------------------------------------------*/
-class AP4_AtomFactory
-{
-public:
+class AP4_AtomFactory {
+ public:
// types
- class TypeHandler
- {
- public:
- virtual ~TypeHandler() {};
- virtual AP4_Result CreateAtom(AP4_Atom::Type type,
- AP4_UI32 size,
- AP4_ByteStream& stream,
- AP4_Atom::Type context,
- AP4_Atom*& atom) = 0;
+ class TypeHandler {
+ public:
+ virtual ~TypeHandler() {};
+ virtual AP4_Result CreateAtom(AP4_Atom::Type type,
+ AP4_UI32 size,
+ AP4_ByteStream& stream,
+ AP4_Atom::Type context,
+ AP4_Atom*& atom) = 0;
};
// constructor
@@ -82,7 +80,7 @@ public:
// context
void PushContext(AP4_Atom::Type context);
void PopContext();
- AP4_Atom::Type GetContext(AP4_Ordinal depth = 0);
+ AP4_Atom::Type GetContext(AP4_Ordinal depth=0);
private:
// members
@@ -93,8 +91,7 @@ private:
/*----------------------------------------------------------------------
| AP4_DefaultAtomFactory
+---------------------------------------------------------------------*/
-class AP4_DefaultAtomFactory : public AP4_AtomFactory
-{
+class AP4_DefaultAtomFactory : public AP4_AtomFactory {
public:
// class members
static AP4_DefaultAtomFactory Instance;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.cpp
index cd4eb4c7f..732ca2ef2 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.cpp
@@ -49,8 +49,8 @@
/*----------------------------------------------------------------------
| AP4_AtomSampleTable::AP4_AtomSampleTable
+---------------------------------------------------------------------*/
-AP4_AtomSampleTable::AP4_AtomSampleTable(AP4_ContainerAtom* stbl,
- AP4_ByteStream& sample_stream) :
+AP4_AtomSampleTable::AP4_AtomSampleTable(AP4_ContainerAtom* stbl,
+ AP4_ByteStream& sample_stream) :
m_SampleStream(sample_stream)
{
m_StscAtom = AP4_DYNAMIC_CAST(AP4_StscAtom, stbl->GetChild(AP4_ATOM_TYPE_STSC));
@@ -65,44 +65,44 @@ AP4_AtomSampleTable::AP4_AtomSampleTable(AP4_ContainerAtom* stbl,
// keep a reference to the sample stream
m_SampleStream.AddReference();
- // ==> Start patch MPC
- if(m_StsdAtom && m_StszAtom && m_StscAtom && m_SttsAtom
- && m_StszAtom->m_SampleSize == 1)
- {
- // fix mov files
- for(AP4_List<AP4_Atom>::Item* item = m_StsdAtom->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
- AP4_Atom* atom = item->GetData();
-
- if(AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom))
- {
- AP4_UI32 SamplesPerPacket = ase->GetSamplesPerPacket();
- AP4_UI32 BytesPerFrame = ase->GetBytesPerFrame();
-
- if(SamplesPerPacket > 0 && BytesPerFrame > 0)
- {
- for(int i = 0, j = m_StscAtom->m_Entries.ItemCount(); i < j; i++)
- {
- AP4_StscTableEntry& e = m_StscAtom->m_Entries[i];
- AP4_ASSERT(e.m_SamplesPerChunk % SamplesPerPacket == 0);
- e.m_SamplesPerChunk = e.m_SamplesPerChunk / SamplesPerPacket;
- e.m_FirstSample = (e.m_FirstSample - 1) / SamplesPerPacket + 1;
- }
-
- AP4_ASSERT(m_StszAtom->m_SampleCount % SamplesPerPacket == 0);
- m_StszAtom->m_SampleCount = m_StszAtom->m_SampleCount / SamplesPerPacket;
- m_StszAtom->m_SampleSize = BytesPerFrame;
-
- AP4_ASSERT(m_SttsAtom->m_Entries.ItemCount() == 1);
- m_SttsAtom->m_Entries[0].m_SampleCount = m_StszAtom->m_SampleCount;
- m_SttsAtom->m_Entries[0].m_SampleDuration = SamplesPerPacket;
- }
- }
- }
- }
- // <== End patch MPC
+ // ==> Start patch MPC
+ if(m_StsdAtom && m_StszAtom && m_StscAtom && m_SttsAtom
+ && m_StszAtom->m_SampleSize == 1)
+ {
+ // fix mov files
+ for(AP4_List<AP4_Atom>::Item* item = m_StsdAtom->GetChildren().FirstItem();
+ item;
+ item = item->GetNext())
+ {
+ AP4_Atom* atom = item->GetData();
+
+ if(AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom))
+ {
+ AP4_UI32 SamplesPerPacket = ase->GetSamplesPerPacket();
+ AP4_UI32 BytesPerFrame = ase->GetBytesPerFrame();
+
+ if(SamplesPerPacket > 0 && BytesPerFrame > 0)
+ {
+ for(int i = 0, j = m_StscAtom->m_Entries.ItemCount(); i < j; i++)
+ {
+ AP4_StscTableEntry& e = m_StscAtom->m_Entries[i];
+ AP4_ASSERT(e.m_SamplesPerChunk % SamplesPerPacket == 0);
+ e.m_SamplesPerChunk = e.m_SamplesPerChunk / SamplesPerPacket;
+ e.m_FirstSample = (e.m_FirstSample-1) / SamplesPerPacket + 1;
+ }
+
+ AP4_ASSERT(m_StszAtom->m_SampleCount % SamplesPerPacket == 0);
+ m_StszAtom->m_SampleCount = m_StszAtom->m_SampleCount / SamplesPerPacket;
+ m_StszAtom->m_SampleSize = BytesPerFrame;
+
+ AP4_ASSERT(m_SttsAtom->m_Entries.ItemCount() == 1);
+ m_SttsAtom->m_Entries[0].m_SampleCount = m_StszAtom->m_SampleCount;
+ m_SttsAtom->m_Entries[0].m_SampleDuration = SamplesPerPacket;
+ }
+ }
+ }
+ }
+ // <== End patch MPC
}
@@ -118,14 +118,13 @@ AP4_AtomSampleTable::~AP4_AtomSampleTable()
| AP4_AtomSampleTable::GetSample
+---------------------------------------------------------------------*/
AP4_Result
-AP4_AtomSampleTable::GetSample(AP4_Ordinal index,
+AP4_AtomSampleTable::GetSample(AP4_Ordinal index,
AP4_Sample& sample)
{
AP4_Result result;
// check that we have a chunk offset table
- if(m_StcoAtom == NULL && m_Co64Atom == NULL)
- {
+ if (m_StcoAtom == NULL && m_Co64Atom == NULL) {
return AP4_ERROR_INVALID_FORMAT;
}
@@ -135,69 +134,59 @@ AP4_AtomSampleTable::GetSample(AP4_Ordinal index,
// find out in which chunk this sample is located
AP4_Ordinal chunk, skip, desc;
result = m_StscAtom->GetChunkForSample(index, chunk, skip, desc);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// check that the result is within bounds
- if(skip > index) return AP4_ERROR_INTERNAL;
+ if (skip > index) return AP4_ERROR_INTERNAL;
// get the atom offset for this chunk
AP4_UI64 offset;
- if(m_StcoAtom)
- {
+ if (m_StcoAtom) {
AP4_UI32 offset_32;
result = m_StcoAtom->GetChunkOffset(chunk, offset_32);
offset = offset_32;
- }
- else
- {
+ } else {
result = m_Co64Atom->GetChunkOffset(chunk, offset);
}
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// compute the additional offset inside the chunk
- for(unsigned int i = index - skip; i < index; i++)
- {
+ for (unsigned int i = index-skip; i < index; i++) {
AP4_Size size;
- result = m_StszAtom->GetSampleSize(i, size);
- if(AP4_FAILED(result)) return result;
+ result = m_StszAtom->GetSampleSize(i, size);
+ if (AP4_FAILED(result)) return result;
offset += size;
}
// set the description index
- sample.SetDescriptionIndex(desc - 1); // adjust for 0-based indexes
+ sample.SetDescriptionIndex(desc-1); // adjust for 0-based indexes
// set the dts and cts
AP4_UI32 cts_offset = 0;
AP4_UI64 dts = 0;
AP4_UI32 duration = 0;
result = m_SttsAtom->GetDts(index, dts, &duration);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
sample.SetDuration(duration);
sample.SetDts(dts);
- if(m_CttsAtom == NULL)
- {
+ if (m_CttsAtom == NULL) {
sample.SetCts(dts);
- }
- else
- {
- result = m_CttsAtom->GetCtsOffset(index, cts_offset);
- if(AP4_FAILED(result)) return result;
+ } else {
+ result = m_CttsAtom->GetCtsOffset(index, cts_offset);
+ if (AP4_FAILED(result)) return result;
sample.SetCtsDelta(cts_offset);
- }
+ }
// set the size
AP4_Size sample_size;
result = m_StszAtom->GetSampleSize(index, sample_size);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
sample.SetSize(sample_size);
// set the sync flag
- if(m_StssAtom == NULL)
- {
+ if (m_StssAtom == NULL) {
sample.SetSync(true);
- }
- else
- {
+ } else {
sample.SetSync(m_StssAtom->IsSampleSync(index));
}
@@ -241,26 +230,26 @@ AP4_AtomSampleTable::GetSampleDescriptionCount()
/*----------------------------------------------------------------------
| AP4_AtomSampleTable::GetSampleChunkPosition
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::GetSampleChunkPosition(AP4_Ordinal sample_index,
- AP4_Ordinal& chunk_index,
- AP4_Ordinal& position_in_chunk)
+AP4_Result
+AP4_AtomSampleTable::GetSampleChunkPosition(AP4_Ordinal sample_index,
+ AP4_Ordinal& chunk_index,
+ AP4_Ordinal& position_in_chunk)
{
// default values
chunk_index = 0;
position_in_chunk = 0;
-
+
AP4_Ordinal sample_description_index;
- return GetChunkForSample(sample_index,
- chunk_index,
- position_in_chunk,
+ return GetChunkForSample(sample_index,
+ chunk_index,
+ position_in_chunk,
sample_description_index);
}
/*----------------------------------------------------------------------
| AP4_AtomSampleTable::GetChunkForSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_AtomSampleTable::GetChunkForSample(AP4_Ordinal sample_index,
AP4_Ordinal& chunk_index,
AP4_Ordinal& position_in_chunk,
@@ -272,50 +261,42 @@ AP4_AtomSampleTable::GetChunkForSample(AP4_Ordinal sample_index,
sample_description_index = 0;
// check that we an stsc atom
- if(m_StscAtom == NULL) return AP4_ERROR_INVALID_STATE;
-
+ if (m_StscAtom == NULL) return AP4_ERROR_INVALID_STATE;
+
// get the chunk info from the stsc atom
AP4_Ordinal chunk = 0;
- AP4_Result result = m_StscAtom->GetChunkForSample(sample_index + 1, // the atom API is 1-based
- chunk,
- position_in_chunk,
- sample_description_index);
- if(AP4_FAILED(result)) return result;
- if(chunk == 0) return AP4_ERROR_INTERNAL;
+ AP4_Result result = m_StscAtom->GetChunkForSample(sample_index+1, // the atom API is 1-based
+ chunk,
+ position_in_chunk,
+ sample_description_index);
+ if (AP4_FAILED(result)) return result;
+ if (chunk == 0) return AP4_ERROR_INTERNAL;
// the atom sample and chunk indexes are 1-based, so we need to translate
- chunk_index = chunk - 1;
-
+ chunk_index = chunk-1;
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_AtomSampleTable::GetChunkOffset
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::GetChunkOffset(AP4_Ordinal chunk_index,
+AP4_Result
+AP4_AtomSampleTable::GetChunkOffset(AP4_Ordinal chunk_index,
AP4_Position& offset)
{
- if(m_StcoAtom)
- {
+ if (m_StcoAtom) {
AP4_UI32 offset_32;
- AP4_Result result = m_StcoAtom->GetChunkOffset(chunk_index + 1, offset_32);
- if(AP4_SUCCEEDED(result))
- {
+ AP4_Result result = m_StcoAtom->GetChunkOffset(chunk_index+1, offset_32);
+ if (AP4_SUCCEEDED(result)) {
offset = offset_32;
- }
- else
- {
+ } else {
offset = 0;
}
return result;
- }
- else if(m_Co64Atom)
- {
- return m_Co64Atom->GetChunkOffset(chunk_index + 1, offset);
- }
- else
- {
+ } else if (m_Co64Atom) {
+ return m_Co64Atom->GetChunkOffset(chunk_index+1, offset);
+ } else {
offset = 0;
return AP4_FAILURE;
}
@@ -324,21 +305,16 @@ AP4_AtomSampleTable::GetChunkOffset(AP4_Ordinal chunk_index,
/*----------------------------------------------------------------------
| AP4_AtomSampleTable::SetChunkOffset
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::SetChunkOffset(AP4_Ordinal chunk_index,
+AP4_Result
+AP4_AtomSampleTable::SetChunkOffset(AP4_Ordinal chunk_index,
AP4_Position offset)
{
- if(m_StcoAtom)
- {
- if((offset >> 32) != 0) return AP4_ERROR_OUT_OF_RANGE;
- return m_StcoAtom->SetChunkOffset(chunk_index + 1, (AP4_UI32)offset);
- }
- else if(m_Co64Atom)
- {
- return m_Co64Atom->SetChunkOffset(chunk_index + 1, offset);
- }
- else
- {
+ if (m_StcoAtom) {
+ if ((offset >> 32) != 0) return AP4_ERROR_OUT_OF_RANGE;
+ return m_StcoAtom->SetChunkOffset(chunk_index+1, (AP4_UI32)offset);
+ } else if (m_Co64Atom) {
+ return m_Co64Atom->SetChunkOffset(chunk_index+1, offset);
+ } else {
return AP4_FAILURE;
}
}
@@ -346,53 +322,47 @@ AP4_AtomSampleTable::SetChunkOffset(AP4_Ordinal chunk_index,
/*----------------------------------------------------------------------
| AP4_AtomSampleTable::SetSampleSize
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_AtomSampleTable::SetSampleSize(AP4_Ordinal sample_index, AP4_Size size)
{
- return m_StszAtom ? m_StszAtom->SetSampleSize(sample_index + 1, size) : AP4_FAILURE;
+ return m_StszAtom ? m_StszAtom->SetSampleSize(sample_index+1, size) : AP4_FAILURE;
}
/*----------------------------------------------------------------------
| AP4_AtomSampleTable::GetSampleIndexForTimeStamp
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::GetSampleIndexForTimeStamp(AP4_UI64 ts,
- AP4_Ordinal& sample_index)
+AP4_Result
+AP4_AtomSampleTable::GetSampleIndexForTimeStamp(AP4_UI64 ts,
+ AP4_Ordinal& sample_index)
{
- return m_SttsAtom ? m_SttsAtom->GetSampleIndexForTimeStamp(ts, sample_index)
- : AP4_FAILURE;
+ return m_SttsAtom ? m_SttsAtom->GetSampleIndexForTimeStamp(ts, sample_index)
+ : AP4_FAILURE;
}
/*----------------------------------------------------------------------
| AP4_AtomSampleTable::GetNearestSyncSampleIndex
+---------------------------------------------------------------------*/
-AP4_Ordinal
+AP4_Ordinal
AP4_AtomSampleTable::GetNearestSyncSampleIndex(AP4_Ordinal sample_index, bool before)
{
// if we don't have an stss table, all samples match
- if(m_StssAtom == NULL) return sample_index;
-
+ if (m_StssAtom == NULL) return sample_index;
+
sample_index += 1; // the table is 1-based
AP4_Cardinal entry_count = m_StssAtom->GetEntries().ItemCount();
- if(before)
- {
- AP4_Ordinal cursor = 0;
- for(unsigned int i = 0; i < entry_count; i++)
- {
- if(m_StssAtom->GetEntries()[i] >= sample_index) return cursor;
- if(m_StssAtom->GetEntries()[i]) cursor = m_StssAtom->GetEntries()[i] - 1;
+ if (before) {
+ AP4_Ordinal cursor = 0;
+ for (unsigned int i=0; i<entry_count; i++) {
+ if (m_StssAtom->GetEntries()[i] >= sample_index) return cursor;
+ if (m_StssAtom->GetEntries()[i]) cursor = m_StssAtom->GetEntries()[i]-1;
}
// not found?
return cursor;
- }
- else
- {
- for(unsigned int i = 0; i < entry_count; i++)
- {
- if(m_StssAtom->GetEntries()[i] >= sample_index)
- {
- return m_StssAtom->GetEntries()[i] ? m_StssAtom->GetEntries()[i] - 1 : sample_index - 1;
+ } else {
+ for (unsigned int i=0; i<entry_count; i++) {
+ if (m_StssAtom->GetEntries()[i] >= sample_index) {
+ return m_StssAtom->GetEntries()[i]?m_StssAtom->GetEntries()[i]-1:sample_index-1;
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.h
index e90bd9cc1..aaecbf917 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AtomSampleTable.h
@@ -54,10 +54,10 @@ class AP4_Co64Atom;
+---------------------------------------------------------------------*/
class AP4_AtomSampleTable : public AP4_SampleTable
{
-public:
+ public:
// methods
- AP4_AtomSampleTable(AP4_ContainerAtom* stbl_atom,
- AP4_ByteStream& sample_stream);
+ AP4_AtomSampleTable(AP4_ContainerAtom* stbl_atom,
+ AP4_ByteStream& sample_stream);
virtual ~AP4_AtomSampleTable();
// AP4_SampleTable methods
@@ -65,11 +65,11 @@ public:
virtual AP4_Cardinal GetSampleCount();
virtual AP4_SampleDescription* GetSampleDescription(AP4_Ordinal sd_index);
virtual AP4_Cardinal GetSampleDescriptionCount();
- virtual AP4_Result GetSampleChunkPosition(AP4_Ordinal sample_index,
- AP4_Ordinal& chunk_index,
- AP4_Ordinal& position_in_chunk);
+ virtual AP4_Result GetSampleChunkPosition(AP4_Ordinal sample_index,
+ AP4_Ordinal& chunk_index,
+ AP4_Ordinal& position_in_chunk);
virtual AP4_Result GetSampleIndexForTimeStamp(AP4_UI64 ts, AP4_Ordinal& sample_index);
- virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal index, bool before = true);
+ virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal index, bool before=true);
// local methods
virtual AP4_Result GetChunkForSample(AP4_Ordinal sample_index,
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.cpp
index bca60cfe2..ac227203d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - avcC Atoms
+| AP4 - avcC Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -45,22 +45,14 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_AvccAtom)
const char*
AP4_AvccAtom::GetProfileName(AP4_UI08 profile)
{
- switch(profile)
- {
- case AP4_AVC_PROFILE_BASELINE:
- return "Baseline";
- case AP4_AVC_PROFILE_MAIN:
- return "Main";
- case AP4_AVC_PROFILE_EXTENDED:
- return "Extended";
- case AP4_AVC_PROFILE_HIGH:
- return "High";
- case AP4_AVC_PROFILE_HIGH_10:
- return "High 10";
- case AP4_AVC_PROFILE_HIGH_422:
- return "High 4:2:2";
- case AP4_AVC_PROFILE_HIGH_444:
- return "High 4:4:4";
+ switch (profile) {
+ case AP4_AVC_PROFILE_BASELINE: return "Baseline";
+ case AP4_AVC_PROFILE_MAIN: return "Main";
+ case AP4_AVC_PROFILE_EXTENDED: return "Extended";
+ case AP4_AVC_PROFILE_HIGH: return "High";
+ case AP4_AVC_PROFILE_HIGH_10: return "High 10";
+ case AP4_AVC_PROFILE_HIGH_422: return "High 4:2:2";
+ case AP4_AVC_PROFILE_HIGH_444: return "High 4:4:4";
}
return NULL;
@@ -69,39 +61,36 @@ AP4_AvccAtom::GetProfileName(AP4_UI08 profile)
/*----------------------------------------------------------------------
| AP4_AvccAtom::Create
+---------------------------------------------------------------------*/
-AP4_AvccAtom*
+AP4_AvccAtom*
AP4_AvccAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
// read the raw bytes in a buffer
- unsigned int payload_size = size - AP4_ATOM_HEADER_SIZE;
+ unsigned int payload_size = size-AP4_ATOM_HEADER_SIZE;
AP4_DataBuffer payload_data(payload_size);
AP4_Result result = stream.Read(payload_data.UseData(), payload_size);
- if(AP4_FAILED(result)) return NULL;
-
+ if (AP4_FAILED(result)) return NULL;
+
// check the version
const AP4_UI08* payload = payload_data.GetData();
- if(payload[0] != 1)
- {
+ if (payload[0] != 1) {
return NULL;
}
// check the size
- if(payload_size < 6) return NULL;
- unsigned int num_seq_params = payload[5] & 31;
+ if (payload_size < 6) return NULL;
+ unsigned int num_seq_params = payload[5]&31;
unsigned int cursor = 6;
- for(unsigned int i = 0; i < num_seq_params; i++)
- {
- if(cursor + 2 > payload_size) return NULL;
- cursor += 2 + AP4_BytesToInt16BE(&payload[cursor]);
- if(cursor > payload_size) return NULL;
+ for (unsigned int i=0; i<num_seq_params; i++) {
+ if (cursor+2 > payload_size) return NULL;
+ cursor += 2+AP4_BytesToInt16BE(&payload[cursor]);
+ if (cursor > payload_size) return NULL;
}
unsigned int num_pic_params = payload[cursor++];
- if(cursor > payload_size) return NULL;
- for(unsigned int i = 0; i < num_pic_params; i++)
- {
- if(cursor + 2 > payload_size) return NULL;
- cursor += 2 + AP4_BytesToInt16BE(&payload[cursor]);
- if(cursor > payload_size) return NULL;
+ if (cursor > payload_size) return NULL;
+ for (unsigned int i=0; i<num_pic_params; i++) {
+ if (cursor+2 > payload_size) return NULL;
+ cursor += 2+AP4_BytesToInt16BE(&payload[cursor]);
+ if (cursor > payload_size) return NULL;
}
return new AP4_AvccAtom(size, payload);
}
@@ -135,14 +124,12 @@ AP4_AvccAtom::AP4_AvccAtom(const AP4_AvccAtom& other) :
{
// deep copy of the parameters
unsigned int i = 0;
- for(i = 0; i < other.m_SequenceParameters.ItemCount(); i++)
- {
+ for (i=0; i<other.m_SequenceParameters.ItemCount(); i++) {
m_SequenceParameters.Append(other.m_SequenceParameters[i]);
}
- for(i = 0; i < other.m_PictureParameters.ItemCount(); i++)
- {
+ for (i=0; i<other.m_PictureParameters.ItemCount(); i++) {
m_PictureParameters.Append(other.m_PictureParameters[i]);
- }
+ }
}
/*----------------------------------------------------------------------
@@ -152,7 +139,7 @@ AP4_AvccAtom::AP4_AvccAtom(AP4_UI32 size, const AP4_UI08* payload) :
AP4_Atom(AP4_ATOM_TYPE_AVCC, size)
{
// make a copy of our configuration bytes
- unsigned int payload_size = size - AP4_ATOM_HEADER_SIZE;
+ unsigned int payload_size = size-AP4_ATOM_HEADER_SIZE;
m_RawBytes.SetData(payload, payload_size);
// parse the payload
@@ -160,25 +147,23 @@ AP4_AvccAtom::AP4_AvccAtom(AP4_UI32 size, const AP4_UI08* payload) :
m_Profile = payload[1];
m_ProfileCompatibility = payload[2];
m_Level = payload[3];
- m_NaluLengthSize = 1 + (payload[4] & 3);
- AP4_UI08 num_seq_params = payload[5] & 31;
+ m_NaluLengthSize = 1+(payload[4]&3);
+ AP4_UI08 num_seq_params = payload[5]&31;
m_SequenceParameters.EnsureCapacity(num_seq_params);
unsigned int cursor = 6;
- for(unsigned int i = 0; i < num_seq_params; i++)
- {
+ for (unsigned int i=0; i<num_seq_params; i++) {
m_SequenceParameters.Append(AP4_DataBuffer());
AP4_UI16 param_length = AP4_BytesToInt16BE(&payload[cursor]);
- m_SequenceParameters[i].SetData(&payload[cursor] + 2, param_length);
- cursor += 2 + param_length;
+ m_SequenceParameters[i].SetData(&payload[cursor]+2, param_length);
+ cursor += 2+param_length;
}
AP4_UI08 num_pic_params = payload[cursor++];
m_PictureParameters.EnsureCapacity(num_pic_params);
- for(unsigned int i = 0; i < num_pic_params; i++)
- {
+ for (unsigned int i=0; i<num_pic_params; i++) {
m_PictureParameters.Append(AP4_DataBuffer());
AP4_UI16 param_length = AP4_BytesToInt16BE(&payload[cursor]);
- m_PictureParameters[i].SetData(&payload[cursor] + 2, param_length);
- cursor += 2 + param_length;
+ m_PictureParameters[i].SetData(&payload[cursor]+2, param_length);
+ cursor += 2+param_length;
}
}
@@ -186,11 +171,11 @@ AP4_AvccAtom::AP4_AvccAtom(AP4_UI32 size, const AP4_UI08* payload) :
/*----------------------------------------------------------------------
| AP4_AvccAtom::AP4_AvccAtom
+---------------------------------------------------------------------*/
-AP4_AvccAtom::AP4_AvccAtom(AP4_UI08 profile,
- AP4_UI08 level,
- AP4_UI08 profile_compatibility,
- AP4_UI08 length_size,
- const AP4_Array<AP4_DataBuffer>& sequence_parameters,
+AP4_AvccAtom::AP4_AvccAtom(AP4_UI08 profile,
+ AP4_UI08 level,
+ AP4_UI08 profile_compatibility,
+ AP4_UI08 length_size,
+ const AP4_Array<AP4_DataBuffer>& sequence_parameters,
const AP4_Array<AP4_DataBuffer>& picture_parameters) :
AP4_Atom(AP4_ATOM_TYPE_AVCC, AP4_ATOM_HEADER_SIZE),
m_ConfigurationVersion(1),
@@ -201,14 +186,12 @@ AP4_AvccAtom::AP4_AvccAtom(AP4_UI08 profile,
{
// deep copy of the parameters
unsigned int i = 0;
- for(i = 0; i < sequence_parameters.ItemCount(); i++)
- {
+ for (i=0; i<sequence_parameters.ItemCount(); i++) {
m_SequenceParameters.Append(sequence_parameters[i]);
}
- for(i = 0; i < picture_parameters.ItemCount(); i++)
- {
+ for (i=0; i<picture_parameters.ItemCount(); i++) {
m_PictureParameters.Append(picture_parameters[i]);
- }
+ }
// compute the raw bytes
UpdateRawBytes();
@@ -224,15 +207,13 @@ void
AP4_AvccAtom::UpdateRawBytes()
{
// compute the payload size
- unsigned int payload_size = 6;
- for(unsigned int i = 0; i < m_SequenceParameters.ItemCount(); i++)
- {
- payload_size += 2 + m_SequenceParameters[i].GetDataSize();
+ unsigned int payload_size = 6;
+ for (unsigned int i=0; i<m_SequenceParameters.ItemCount(); i++) {
+ payload_size += 2+m_SequenceParameters[i].GetDataSize();
}
++payload_size;
- for(unsigned int i = 0; i < m_PictureParameters.ItemCount(); i++)
- {
- payload_size += 2 + m_PictureParameters[i].GetDataSize();
+ for (unsigned int i=0; i<m_PictureParameters.ItemCount(); i++) {
+ payload_size += 2+m_PictureParameters[i].GetDataSize();
}
m_RawBytes.SetDataSize(payload_size);
AP4_UI08* payload = m_RawBytes.UseData();
@@ -241,11 +222,10 @@ AP4_AvccAtom::UpdateRawBytes()
payload[1] = m_Profile;
payload[2] = m_ProfileCompatibility;
payload[3] = m_Level;
- payload[4] = 0xFC | (m_NaluLengthSize - 1);
+ payload[4] = 0xFC | (m_NaluLengthSize-1);
payload[5] = 0xE0 | m_SequenceParameters.ItemCount();
unsigned int cursor = 6;
- for(unsigned int i = 0; i < m_SequenceParameters.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<m_SequenceParameters.ItemCount(); i++) {
AP4_UI16 param_length = (AP4_UI16)m_SequenceParameters[i].GetDataSize();
AP4_BytesFromUInt16BE(&payload[cursor], param_length);
cursor += 2;
@@ -253,8 +233,7 @@ AP4_AvccAtom::UpdateRawBytes()
cursor += param_length;
}
payload[cursor++] = m_PictureParameters.ItemCount();
- for(unsigned int i = 0; i < m_PictureParameters.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<m_PictureParameters.ItemCount(); i++) {
AP4_UI16 param_length = (AP4_UI16)m_PictureParameters[i].GetDataSize();
AP4_BytesFromUInt16BE(&payload[cursor], param_length);
cursor += 2;
@@ -280,23 +259,18 @@ AP4_AvccAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("Configuration Version", m_ConfigurationVersion);
const char* profile_name = GetProfileName(m_Profile);
- if(profile_name)
- {
+ if (profile_name) {
inspector.AddField("Profile", profile_name);
- }
- else
- {
+ } else {
inspector.AddField("Profile", m_Profile);
}
inspector.AddField("Profile Compatibility", m_ProfileCompatibility, AP4_AtomInspector::HINT_HEX);
inspector.AddField("Level", m_Level);
inspector.AddField("NALU Length Size", m_NaluLengthSize);
- for(unsigned int i = 0; i < m_SequenceParameters.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<m_SequenceParameters.ItemCount(); i++) {
inspector.AddField("Sequence Parameter", m_SequenceParameters[i].GetData(), m_SequenceParameters[i].GetDataSize());
}
- for(unsigned int i = 0; i < m_SequenceParameters.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<m_SequenceParameters.ItemCount(); i++) {
inspector.AddField("Picture Parameter", m_PictureParameters[i].GetData(), m_PictureParameters[i].GetDataSize());
}
return AP4_SUCCESS;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.h
index c2c790759..b3b300853 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4AvcCAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - avcC Atoms
+| AP4 - avcC Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -68,50 +68,26 @@ public:
const AP4_Array<AP4_DataBuffer>& sequence_parameters,
const AP4_Array<AP4_DataBuffer>& picture_parameters);
AP4_AvccAtom(const AP4_AvccAtom& other); // copy construtor
-
+
// methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- AP4_UI08 GetConfigurationVersion() const
- {
- return m_ConfigurationVersion;
- }
- AP4_UI08 GetProfile() const
- {
- return m_Profile;
- }
- AP4_UI08 GetLevel() const
- {
- return m_Level;
- }
- AP4_UI08 GetProfileCompatibility() const
- {
- return m_ProfileCompatibility;
- }
- AP4_UI08 GetNaluLengthSize() const
- {
- return m_NaluLengthSize;
- }
- AP4_Array<AP4_DataBuffer>& GetSequenceParameters()
- {
- return m_SequenceParameters;
- }
- AP4_Array<AP4_DataBuffer>& GetPictureParameters()
- {
- return m_PictureParameters;
- }
- const AP4_DataBuffer& GetRawBytes() const
- {
- return m_RawBytes;
- }
+ AP4_UI08 GetConfigurationVersion() const { return m_ConfigurationVersion; }
+ AP4_UI08 GetProfile() const { return m_Profile; }
+ AP4_UI08 GetLevel() const { return m_Level; }
+ AP4_UI08 GetProfileCompatibility() const { return m_ProfileCompatibility; }
+ AP4_UI08 GetNaluLengthSize() const { return m_NaluLengthSize; }
+ AP4_Array<AP4_DataBuffer>& GetSequenceParameters() { return m_SequenceParameters; }
+ AP4_Array<AP4_DataBuffer>& GetPictureParameters() { return m_PictureParameters; }
+ const AP4_DataBuffer& GetRawBytes() const { return m_RawBytes; }
private:
// methods
AP4_AvccAtom(AP4_UI32 size, const AP4_UI08* payload);
void UpdateRawBytes();
-
+
// members
AP4_UI08 m_ConfigurationVersion;
AP4_UI08 m_Profile;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.cpp
index 462eaf88a..e5c33d319 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.cpp
@@ -22,7 +22,7 @@
| You should have received a copy of the GNU General Public License
| along with Bento4|GPL; see the file COPYING. If not, write to the
| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
+| 02111-1307, USA.
|
****************************************************************/
@@ -46,22 +46,21 @@ AP4_Result
AP4_ByteStream::Read(void* buffer, AP4_Size bytes_to_read)
{
// shortcut
- if(bytes_to_read == 0) return AP4_SUCCESS;
-
+ if (bytes_to_read == 0) return AP4_SUCCESS;
+
// read until failure
AP4_Size bytes_read;
- while(bytes_to_read)
- {
+ while (bytes_to_read) {
AP4_Result result = ReadPartial(buffer, bytes_to_read, bytes_read);
- if(AP4_FAILED(result)) return result;
- if(bytes_read == 0) return AP4_ERROR_INTERNAL;
+ if (AP4_FAILED(result)) return result;
+ if (bytes_read == 0) return AP4_ERROR_INTERNAL;
AP4_ASSERT(bytes_read <= bytes_to_read);
bytes_to_read -= bytes_read;
- buffer = (void*)(((AP4_Byte*)buffer) + bytes_read);
+ buffer = (void*)(((AP4_Byte*)buffer)+bytes_read);
}
-
+
return AP4_SUCCESS;
-}
+}
/*----------------------------------------------------------------------
| AP4_Stream::Write
@@ -70,20 +69,19 @@ AP4_Result
AP4_ByteStream::Write(const void* buffer, AP4_Size bytes_to_write)
{
// shortcut
- if(bytes_to_write == 0) return AP4_SUCCESS;
-
+ if (bytes_to_write == 0) return AP4_SUCCESS;
+
// write until failure
AP4_Size bytes_written;
- while(bytes_to_write)
- {
+ while (bytes_to_write) {
AP4_Result result = WritePartial(buffer, bytes_to_write, bytes_written);
- if(AP4_FAILED(result)) return result;
- if(bytes_written == 0) return AP4_ERROR_INTERNAL;
+ if (AP4_FAILED(result)) return result;
+ if (bytes_written == 0) return AP4_ERROR_INTERNAL;
AP4_ASSERT(bytes_written <= bytes_to_write);
bytes_to_write -= bytes_written;
- buffer = (const void*)(((const AP4_Byte*)buffer) + bytes_written);
+ buffer = (const void*)(((const AP4_Byte*)buffer)+bytes_written);
}
-
+
return AP4_SUCCESS;
}
@@ -96,7 +94,7 @@ AP4_ByteStream::WriteString(const char* buffer)
AP4_Size string_length = static_cast<AP4_Size>(strlen(buffer));
// shortcut
- if((buffer == NULL) || (string_length == 0)) return AP4_SUCCESS;
+ if ((buffer == NULL) || (string_length == 0)) return AP4_SUCCESS;
// write the string
return Write((const void*)buffer, string_length);
@@ -197,15 +195,14 @@ AP4_ByteStream::ReadUI64(AP4_UI64& value)
// read bytes from the stream
AP4_Result result;
result = Read((void*)buffer, 8);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
value = 0;
return result;
}
// convert bytes to value
value = AP4_BytesToUInt64BE(buffer);
-
+
return AP4_SUCCESS;
}
@@ -220,15 +217,14 @@ AP4_ByteStream::ReadDouble(double& value)
// read bytes from the stream
AP4_Result result;
result = Read((void*)buffer, 8);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
value = 0;
return result;
}
// convert bytes to value
value = AP4_BytesToDoubleBE(buffer);
-
+
return AP4_SUCCESS;
}
@@ -243,15 +239,14 @@ AP4_ByteStream::ReadUI32(AP4_UI32& value)
// read bytes from the stream
AP4_Result result;
result = Read((void*)buffer, 4);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
value = 0;
return result;
}
// convert bytes to value
value = AP4_BytesToUInt32BE(buffer);
-
+
return AP4_SUCCESS;
}
@@ -266,15 +261,14 @@ AP4_ByteStream::ReadUI24(AP4_UI32& value)
// read bytes from the stream
AP4_Result result;
result = Read((void*)buffer, 3);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
value = 0;
return result;
}
// convert bytes to value
value = AP4_BytesToUInt24BE(buffer);
-
+
return AP4_SUCCESS;
}
@@ -289,15 +283,14 @@ AP4_ByteStream::ReadUI16(AP4_UI16& value)
// read bytes from the stream
AP4_Result result;
result = Read((void*)buffer, 2);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
value = 0;
return result;
}
// convert bytes to value
value = AP4_BytesToUInt16BE(buffer);
-
+
return AP4_SUCCESS;
}
@@ -312,15 +305,14 @@ AP4_ByteStream::ReadUI08(AP4_UI08& value)
// read bytes from the stream
AP4_Result result;
result = Read((void*)buffer, 1);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
value = 0;
return result;
}
// convert bytes to value
value = buffer[0];
-
+
return AP4_SUCCESS;
}
@@ -330,23 +322,19 @@ AP4_ByteStream::ReadUI08(AP4_UI08& value)
AP4_Result
AP4_ByteStream::ReadString(char* buffer, AP4_Size size)
{
- if(buffer == NULL || size == 0)
- {
+ if (buffer == NULL || size == 0) {
return AP4_ERROR_INVALID_PARAMETERS;
}
AP4_Size bytes_read = 0;
- while(bytes_read < size - 1)
- {
+ while (bytes_read < size-1) {
AP4_Result result;
result = Read(&buffer[bytes_read], 1);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
buffer[bytes_read] = '\0';
return result;
}
- if(buffer[bytes_read] == '\0')
- {
+ if (buffer[bytes_read] == '\0') {
// end of string
return AP4_SUCCESS;
}
@@ -365,31 +353,26 @@ AP4_Result
AP4_ByteStream::CopyTo(AP4_ByteStream& stream, AP4_LargeSize size)
{
unsigned char buffer[AP4_BYTE_STREAM_COPY_BUFFER_SIZE];
- while(size)
- {
+ while (size) {
AP4_Size bytes_read;
AP4_Size bytes_to_read;
AP4_Result result;
// decide how much to read
- if(size >= sizeof(buffer))
- {
+ if (size >= sizeof(buffer)) {
bytes_to_read = sizeof(buffer);
- }
- else
- {
+ } else {
bytes_to_read = (AP4_Size)size;
}
// read up to one buffer full
result = ReadPartial(buffer, bytes_to_read, bytes_read);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// copy to destination
- if(bytes_read != 0)
- {
+ if (bytes_read != 0) {
result = stream.Write(buffer, bytes_read);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// update the size
@@ -402,8 +385,8 @@ AP4_ByteStream::CopyTo(AP4_ByteStream& stream, AP4_LargeSize size)
/*----------------------------------------------------------------------
| AP4_SubStream::AP4_SubStream
+---------------------------------------------------------------------*/
-AP4_SubStream::AP4_SubStream(AP4_ByteStream& container,
- AP4_Position offset,
+AP4_SubStream::AP4_SubStream(AP4_ByteStream& container,
+ AP4_Position offset,
AP4_LargeSize size) :
m_Container(container),
m_Offset(offset),
@@ -425,44 +408,39 @@ AP4_SubStream::~AP4_SubStream()
/*----------------------------------------------------------------------
| AP4_SubStream::ReadPartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SubStream::ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+AP4_Result
+AP4_SubStream::ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read)
{
// default values
bytes_read = 0;
// shortcut
- if(bytes_to_read == 0)
- {
+ if (bytes_to_read == 0) {
return AP4_SUCCESS;
}
// clamp to range
- if(m_Position + bytes_to_read > m_Size)
- {
+ if (m_Position+bytes_to_read > m_Size) {
bytes_to_read = (AP4_Size)(m_Size - m_Position);
}
// check for end of substream
- if(bytes_to_read == 0)
- {
+ if (bytes_to_read == 0) {
return AP4_ERROR_EOS;
}
// seek inside container
AP4_Result result;
- result = m_Container.Seek(m_Offset + m_Position);
- if(AP4_FAILED(result))
- {
+ result = m_Container.Seek(m_Offset+m_Position);
+ if (AP4_FAILED(result)) {
return result;
}
// read from the container
result = m_Container.ReadPartial(buffer, bytes_to_read, bytes_read);
- if(AP4_SUCCEEDED(result))
- {
+ if (AP4_SUCCEEDED(result)) {
m_Position += bytes_read;
}
return result;
@@ -471,41 +449,37 @@ AP4_SubStream::ReadPartial(void* buffer,
/*----------------------------------------------------------------------
| AP4_SubStream::WritePartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SubStream::WritePartial(const void* buffer,
- AP4_Size bytes_to_write,
+AP4_Result
+AP4_SubStream::WritePartial(const void* buffer,
+ AP4_Size bytes_to_write,
AP4_Size& bytes_written)
{
// default values
bytes_written = 0;
// shortcut
- if(bytes_to_write == 0)
- {
+ if (bytes_to_write == 0) {
return AP4_SUCCESS;
}
// clamp to range
- if(m_Position + bytes_to_write > m_Size)
- {
+ if (m_Position+bytes_to_write > m_Size) {
bytes_to_write = (AP4_Size)(m_Size - m_Position);
}
// check for en of substream
- if(bytes_to_write == 0)
- {
+ if (bytes_to_write == 0) {
return AP4_ERROR_EOS;
}
// seek inside container
AP4_Result result;
- result = m_Container.Seek(m_Offset + m_Position);
- if(AP4_FAILED(result)) return result;
+ result = m_Container.Seek(m_Offset+m_Position);
+ if (AP4_FAILED(result)) return result;
// write to container
result = m_Container.WritePartial(buffer, bytes_to_write, bytes_written);
- if(AP4_SUCCEEDED(result))
- {
+ if (AP4_SUCCEEDED(result)) {
m_Position += bytes_written;
}
return result;
@@ -514,11 +488,11 @@ AP4_SubStream::WritePartial(const void* buffer,
/*----------------------------------------------------------------------
| AP4_SubStream::Seek
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_SubStream::Seek(AP4_Position position)
{
- if(position == m_Position) return AP4_SUCCESS;
- if(position > m_Size) return AP4_FAILURE;
+ if (position == m_Position) return AP4_SUCCESS;
+ if (position > m_Size) return AP4_FAILURE;
m_Position = position;
return AP4_SUCCESS;
}
@@ -538,8 +512,7 @@ AP4_SubStream::AddReference()
void
AP4_SubStream::Release()
{
- if(--m_ReferenceCount == 0)
- {
+ if (--m_ReferenceCount == 0) {
delete this;
}
}
@@ -584,8 +557,7 @@ AP4_MemoryByteStream::AP4_MemoryByteStream(AP4_DataBuffer& data_buffer) :
+---------------------------------------------------------------------*/
AP4_MemoryByteStream::~AP4_MemoryByteStream()
{
- if(m_BufferIsLocal)
- {
+ if (m_BufferIsLocal) {
delete m_Buffer;
}
}
@@ -593,34 +565,31 @@ AP4_MemoryByteStream::~AP4_MemoryByteStream()
/*----------------------------------------------------------------------
| AP4_MemoryByteStream::ReadPartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MemoryByteStream::ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+AP4_Result
+AP4_MemoryByteStream::ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read)
{
// default values
bytes_read = 0;
// shortcut
- if(bytes_to_read == 0)
- {
+ if (bytes_to_read == 0) {
return AP4_SUCCESS;
}
// clamp to range
- if(m_Position + bytes_to_read > m_Buffer->GetDataSize())
- {
+ if (m_Position+bytes_to_read > m_Buffer->GetDataSize()) {
bytes_to_read = (AP4_Size)(m_Buffer->GetDataSize() - m_Position);
}
// check for end of stream
- if(bytes_to_read == 0)
- {
+ if (bytes_to_read == 0) {
return AP4_ERROR_EOS;
}
// read from the memory
- AP4_CopyMemory(buffer, m_Buffer->GetData() + m_Position, bytes_to_read);
+ AP4_CopyMemory(buffer, m_Buffer->GetData()+m_Position, bytes_to_read);
m_Position += bytes_to_read;
bytes_read = bytes_to_read;
@@ -631,50 +600,43 @@ AP4_MemoryByteStream::ReadPartial(void* buffer,
/*----------------------------------------------------------------------
| AP4_MemoryByteStream::WritePartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MemoryByteStream::WritePartial(const void* buffer,
- AP4_Size bytes_to_write,
+AP4_Result
+AP4_MemoryByteStream::WritePartial(const void* buffer,
+ AP4_Size bytes_to_write,
AP4_Size& bytes_written)
{
// default values
bytes_written = 0;
// shortcut
- if(bytes_to_write == 0)
- {
+ if (bytes_to_write == 0) {
return AP4_SUCCESS;
}
// check that we don't exceed the max
- if(m_Position + bytes_to_write > (AP4_Position)AP4_MEMORY_BYTE_STREAM_MAX_SIZE)
- {
+ if (m_Position+bytes_to_write > (AP4_Position)AP4_MEMORY_BYTE_STREAM_MAX_SIZE) {
return AP4_ERROR_OUT_OF_RANGE;
}
// reserve space in the buffer
- AP4_Result result = m_Buffer->Reserve((AP4_Size)(m_Position + bytes_to_write));
- if(AP4_SUCCEEDED(result))
- {
- m_Buffer->SetDataSize((AP4_Size)(m_Position + bytes_to_write));
- }
- else
- {
+ AP4_Result result = m_Buffer->Reserve((AP4_Size)(m_Position+bytes_to_write));
+ if (AP4_SUCCEEDED(result)) {
+ m_Buffer->SetDataSize((AP4_Size)(m_Position+bytes_to_write));
+ } else {
// failed to reserve, most likely caused by a buffer that has
// external storage
- if(m_Position + bytes_to_write > m_Buffer->GetDataSize())
- {
+ if (m_Position+bytes_to_write > m_Buffer->GetDataSize()) {
bytes_to_write = (AP4_Size)(m_Buffer->GetDataSize() - m_Position);
}
- }
+ }
// check for en of stream
- if(bytes_to_write == 0)
- {
+ if (bytes_to_write == 0) {
return AP4_ERROR_EOS;
}
// write to memory
- AP4_CopyMemory((void*)(m_Buffer->UseData() + m_Position), buffer, bytes_to_write);
+ AP4_CopyMemory((void*)(m_Buffer->UseData()+m_Position), buffer, bytes_to_write);
m_Position += bytes_to_write;
bytes_written = bytes_to_write;
@@ -685,10 +647,10 @@ AP4_MemoryByteStream::WritePartial(const void* buffer,
/*----------------------------------------------------------------------
| AP4_MemoryByteStream::Seek
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MemoryByteStream::Seek(AP4_Position position)
{
- if(position > m_Buffer->GetDataSize()) return AP4_FAILURE;
+ if (position > m_Buffer->GetDataSize()) return AP4_FAILURE;
m_Position = position;
return AP4_SUCCESS;
}
@@ -708,8 +670,7 @@ AP4_MemoryByteStream::AddReference()
void
AP4_MemoryByteStream::Release()
{
- if(--m_ReferenceCount == 0)
- {
+ if (--m_ReferenceCount == 0) {
delete this;
}
}
@@ -717,9 +678,9 @@ AP4_MemoryByteStream::Release()
/*----------------------------------------------------------------------
| AP4_BufferedInputStream::AP4_BufferedInputStream
+---------------------------------------------------------------------*/
-AP4_BufferedInputStream::AP4_BufferedInputStream(AP4_ByteStream& source,
- AP4_Size buffer_size,
- AP4_Size seek_as_read_threshold) :
+AP4_BufferedInputStream::AP4_BufferedInputStream(AP4_ByteStream& source,
+ AP4_Size buffer_size,
+ AP4_Size seek_as_read_threshold) :
m_Buffer(buffer_size),
m_BufferPosition(0),
m_Source(source),
@@ -733,77 +694,73 @@ AP4_BufferedInputStream::AP4_BufferedInputStream(AP4_ByteStream& source,
/*----------------------------------------------------------------------
| AP4_BufferedInputStream::Refill
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_BufferedInputStream::Refill()
{
m_BufferPosition = 0;
AP4_Size bytes_read = 0;
- AP4_Result result = m_Source.ReadPartial(m_Buffer.UseData(),
- m_Buffer.GetBufferSize(),
- bytes_read);
- if(AP4_FAILED(result))
- {
+ AP4_Result result = m_Source.ReadPartial(m_Buffer.UseData(),
+ m_Buffer.GetBufferSize(),
+ bytes_read);
+ if (AP4_FAILED(result)) {
m_Buffer.SetDataSize(0);
return result;
}
assert(bytes_read);
m_Buffer.SetDataSize(bytes_read);
m_SourcePosition += bytes_read;
-
+
return AP4_SUCCESS;
-}
+}
/*----------------------------------------------------------------------
| AP4_BufferedInputStream::ReadPartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_BufferedInputStream::ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+AP4_Result
+AP4_BufferedInputStream::ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read)
{
// check for shortcut
- if(bytes_to_read == 0)
- {
+ if (bytes_to_read == 0) {
bytes_read = 0;
return AP4_SUCCESS;
}
-
+
// compute how much data is available in the buffer
assert(m_BufferPosition <= m_Buffer.GetDataSize());
- AP4_Size available = m_Buffer.GetDataSize() - m_BufferPosition;
-
+ AP4_Size available = m_Buffer.GetDataSize()-m_BufferPosition;
+
// refill the buffer if it is empty
- if(available == 0)
- {
+ if (available == 0) {
AP4_Result result = Refill();
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
bytes_read = 0;
return result;
}
assert(m_BufferPosition == 0);
assert(m_Buffer.GetDataSize() != 0);
- available = m_Buffer.GetDataSize() - m_BufferPosition;
+ available = m_Buffer.GetDataSize()-m_BufferPosition;
}
-
+
// clamp the number of bytes to read to what's available
- if(bytes_to_read > available) bytes_to_read = available;
+ if (bytes_to_read > available) bytes_to_read = available;
bytes_read = bytes_to_read;
-
+
// copy the buffered data
- AP4_CopyMemory(buffer, m_Buffer.GetData() + m_BufferPosition, bytes_to_read);
+ AP4_CopyMemory(buffer, m_Buffer.GetData()+m_BufferPosition, bytes_to_read);
m_BufferPosition += bytes_to_read;
assert(m_BufferPosition <= m_Buffer.GetDataSize());
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_BufferedInputStream::WritePartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_BufferedInputStream::WritePartial(const void* /*buffer*/,
- AP4_Size /*bytes_to_write*/,
+AP4_Result
+AP4_BufferedInputStream::WritePartial(const void* /*buffer*/,
+ AP4_Size /*bytes_to_write*/,
AP4_Size& /*bytes_written*/)
{
return AP4_ERROR_NOT_SUPPORTED;
@@ -812,30 +769,26 @@ AP4_BufferedInputStream::WritePartial(const void* /*buffer*/,
/*----------------------------------------------------------------------
| AP4_BufferedInputStream::Seek
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_BufferedInputStream::Seek(AP4_Position position)
{
assert(m_SourcePosition >= m_Buffer.GetDataSize());
assert(m_BufferPosition <= m_Buffer.GetDataSize());
- if(position < m_SourcePosition - m_Buffer.GetDataSize() ||
- position > m_SourcePosition)
- {
+ if (position < m_SourcePosition-m_Buffer.GetDataSize() ||
+ position > m_SourcePosition) {
// out of buffer
m_BufferPosition = 0;
m_Buffer.SetDataSize(0);
-
+
// seek in the source
- if(position > m_SourcePosition && (position - m_SourcePosition <= m_SeekAsReadThreshold))
- {
+ if (position > m_SourcePosition && (position-m_SourcePosition <= m_SeekAsReadThreshold)) {
char* discard = new char[4096];
- AP4_Size to_skip = (AP4_Size)(position - m_SourcePosition);
- while(to_skip)
- {
+ AP4_Size to_skip = (AP4_Size)(position-m_SourcePosition);
+ while (to_skip) {
AP4_Size chunk = 4096;
- if(chunk > to_skip) chunk = to_skip;
+ if (chunk > to_skip) chunk = to_skip;
AP4_Result result = m_Source.Read(discard, chunk);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
delete[] discard;
return result;
}
@@ -844,29 +797,27 @@ AP4_BufferedInputStream::Seek(AP4_Position position)
}
delete[] discard;
return AP4_SUCCESS;
- }
- else
- {
+ } else {
m_SourcePosition = position;
return m_Source.Seek(position);
}
}
-
+
// compute the buffer position
- m_BufferPosition = (AP4_Size)(position - (m_SourcePosition - m_Buffer.GetDataSize()));
-
+ m_BufferPosition = (AP4_Size)(position-(m_SourcePosition-m_Buffer.GetDataSize()));
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_BufferedInputStream::Tell
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_BufferedInputStream::Tell(AP4_Position& position)
{
assert(m_SourcePosition >= m_Buffer.GetDataSize());
assert(m_BufferPosition <= m_Buffer.GetDataSize());
- position = m_SourcePosition - m_Buffer.GetDataSize() + m_BufferPosition;
+ position = m_SourcePosition-m_Buffer.GetDataSize()+m_BufferPosition;
return AP4_SUCCESS;
}
@@ -885,8 +836,7 @@ AP4_BufferedInputStream::AddReference()
void
AP4_BufferedInputStream::Release()
{
- if(--m_ReferenceCount == 0)
- {
+ if (--m_ReferenceCount == 0) {
delete this;
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.h
index 2d69d54d7..3eaf2d803 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ByteStream.h
@@ -42,10 +42,10 @@
+---------------------------------------------------------------------*/
class AP4_ByteStream : public AP4_Referenceable
{
-public:
+ public:
// methods
- virtual AP4_Result ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+ virtual AP4_Result ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read) = 0;
AP4_Result Read(void* buffer, AP4_Size bytes_to_read);
AP4_Result ReadDouble(double& value);
@@ -55,8 +55,8 @@ public:
AP4_Result ReadUI16(AP4_UI16& value);
AP4_Result ReadUI08(AP4_UI08& value);
AP4_Result ReadString(char* buffer, AP4_Size size);
- virtual AP4_Result WritePartial(const void* buffer,
- AP4_Size bytes_to_write,
+ virtual AP4_Result WritePartial(const void* buffer,
+ AP4_Size bytes_to_write,
AP4_Size& bytes_written) = 0;
AP4_Result Write(const void* buffer, AP4_Size bytes_to_write);
AP4_Result WriteString(const char* string_buffer);
@@ -70,10 +70,7 @@ public:
virtual AP4_Result Tell(AP4_Position& position) = 0;
virtual AP4_Result GetSize(AP4_LargeSize& size) = 0;
virtual AP4_Result CopyTo(AP4_ByteStream& stream, AP4_LargeSize size);
- virtual AP4_Result Flush()
- {
- return AP4_SUCCESS;
- }
+ virtual AP4_Result Flush() { return AP4_SUCCESS; }
};
/*----------------------------------------------------------------------
@@ -81,26 +78,24 @@ public:
+---------------------------------------------------------------------*/
class AP4_SubStream : public AP4_ByteStream
{
-public:
- AP4_SubStream(AP4_ByteStream& container,
- AP4_Position position,
+ public:
+ AP4_SubStream(AP4_ByteStream& container,
+ AP4_Position position,
AP4_LargeSize size);
// AP4_ByteStream methods
- AP4_Result ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+ AP4_Result ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read);
- AP4_Result WritePartial(const void* buffer,
- AP4_Size bytes_to_write,
+ AP4_Result WritePartial(const void* buffer,
+ AP4_Size bytes_to_write,
AP4_Size& bytes_written);
AP4_Result Seek(AP4_Position position);
- AP4_Result Tell(AP4_Position& position)
- {
+ AP4_Result Tell(AP4_Position& position) {
position = m_Position;
return AP4_SUCCESS;
}
- AP4_Result GetSize(AP4_LargeSize& size)
- {
+ AP4_Result GetSize(AP4_LargeSize& size) {
size = m_Size;
return AP4_SUCCESS;
}
@@ -109,10 +104,10 @@ public:
void AddReference();
void Release();
-protected:
+ protected:
virtual ~AP4_SubStream();
-private:
+ private:
AP4_ByteStream& m_Container;
AP4_Position m_Offset;
AP4_LargeSize m_Size;
@@ -131,20 +126,18 @@ public:
AP4_MemoryByteStream(AP4_DataBuffer& data_buffer); // data is read/written from/to supplied buffer
// AP4_ByteStream methods
- AP4_Result ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+ AP4_Result ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read);
- AP4_Result WritePartial(const void* buffer,
- AP4_Size bytes_to_write,
+ AP4_Result WritePartial(const void* buffer,
+ AP4_Size bytes_to_write,
AP4_Size& bytes_written);
AP4_Result Seek(AP4_Position position);
- AP4_Result Tell(AP4_Position& position)
- {
+ AP4_Result Tell(AP4_Position& position) {
position = m_Position;
return AP4_SUCCESS;
}
- AP4_Result GetSize(AP4_LargeSize& size)
- {
+ AP4_Result GetSize(AP4_LargeSize& size) {
size = m_Buffer->GetDataSize();
return AP4_SUCCESS;
}
@@ -154,18 +147,9 @@ public:
void Release();
// methods
- const AP4_UI08* GetData()
- {
- return m_Buffer->GetData();
- }
- AP4_UI08* UseData()
- {
- return m_Buffer->UseData();
- }
- AP4_Size GetDataSize()
- {
- return m_Buffer->GetDataSize();
- }
+ const AP4_UI08* GetData() { return m_Buffer->GetData(); }
+ AP4_UI08* UseData() { return m_Buffer->UseData(); }
+ AP4_Size GetDataSize() { return m_Buffer->GetDataSize(); }
protected:
virtual ~AP4_MemoryByteStream();
@@ -183,35 +167,29 @@ private:
class AP4_BufferedInputStream : public AP4_ByteStream
{
public:
- AP4_BufferedInputStream(AP4_ByteStream& source,
- AP4_Size buffer_size = 4096,
- AP4_Size seek_as_read_threshold = 1024 * 128);
+ AP4_BufferedInputStream(AP4_ByteStream& source,
+ AP4_Size buffer_size=4096,
+ AP4_Size seek_as_read_threshold=1024*128);
// AP4_ByteStream methods
- AP4_Result ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+ AP4_Result ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read);
- AP4_Result WritePartial(const void* buffer,
- AP4_Size bytes_to_write,
+ AP4_Result WritePartial(const void* buffer,
+ AP4_Size bytes_to_write,
AP4_Size& bytes_written);
AP4_Result Seek(AP4_Position position);
AP4_Result Tell(AP4_Position& position);
- AP4_Result GetSize(AP4_LargeSize& size)
- {
- return m_Source.GetSize(size);
- }
+ AP4_Result GetSize(AP4_LargeSize& size) { return m_Source.GetSize(size); }
// AP4_Referenceable methods
void AddReference();
void Release();
protected:
- ~AP4_BufferedInputStream()
- {
- m_Source.Release();
- }
+ ~AP4_BufferedInputStream() { m_Source.Release(); }
AP4_Result Refill();
-
+
private:
AP4_DataBuffer m_Buffer;
AP4_Size m_BufferPosition;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.cpp
index 87864cf2c..2c5c195a3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.cpp
@@ -38,34 +38,34 @@
AP4_ChplAtom::AP4_ChplAtom(AP4_UI32 size,
AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_CHPL, size)
+ : AP4_Atom(AP4_ATOM_TYPE_CHPL, size)
{
- size -= AP4_FULL_ATOM_HEADER_SIZE;
+ size -= AP4_FULL_ATOM_HEADER_SIZE;
- stream.ReadUI32(m_Reserved);
+ stream.ReadUI32(m_Reserved);
- AP4_UI08 cnt = 0;
- stream.ReadUI08(cnt);
+ AP4_UI08 cnt = 0;
+ stream.ReadUI08(cnt);
- size -= 5;
+ size -= 5;
- while(size > 0 && cnt-- > 0)
- {
- AP4_Chapter chapter;
+ while(size > 0 && cnt-- > 0)
+ {
+ AP4_Chapter chapter;
- // time
- stream.ReadUI64(chapter.Time);
+ // time
+ stream.ReadUI64(chapter.Time);
- // name
- AP4_UI08 len = 0;
- char buff[256];
- stream.ReadUI08(len);
- stream.Read(buff, len);
- buff[len] = 0;
- chapter.Name = buff;
+ // name
+ AP4_UI08 len = 0;
+ char buff[256];
+ stream.ReadUI08(len);
+ stream.Read(buff, len);
+ buff[len] = 0;
+ chapter.Name = buff;
- m_Chapters.Append(chapter);
+ m_Chapters.Append(chapter);
- size -= 8 + 1 + len;
- }
+ size -= 8+1+len;
+ }
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.h
index fad2ef2a2..d1fa4327b 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ChplAtom.h
@@ -43,30 +43,20 @@
class AP4_ChplAtom : public AP4_Atom
{
public:
- AP4_ChplAtom(AP4_UI32 size,
+ AP4_ChplAtom(AP4_UI32 size,
AP4_ByteStream& stream);
- AP4_Result WriteFields(AP4_ByteStream& stream)
- {
- return AP4_FAILURE;
- }
+ AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
- struct AP4_Chapter
- {
- AP4_UI64 Time;
- AP4_String Name;
- };
+ struct AP4_Chapter {AP4_UI64 Time; AP4_String Name;};
- AP4_Array<AP4_Chapter>& GetChapters()
- {
- return m_Chapters;
- }
+ AP4_Array<AP4_Chapter>& GetChapters() { return m_Chapters; }
private:
- // members
- AP4_UI32 m_Reserved;
- AP4_Array<AP4_Chapter> m_Chapters;
+ // members
+ AP4_UI32 m_Reserved;
+ AP4_Array<AP4_Chapter> m_Chapters;
};
#endif // _AP4_CHPL_ATOM_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.cpp
index 539587bcc..8b4760524 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - cmvd Atoms
+| AP4 - cmvd Atoms
|
| Copyright 2002 Gilles Boccon-Gibod
|
@@ -34,10 +34,10 @@
#include "Ap4AtomFactory.h"
#include "Ap4ContainerAtom.h"
-AP4_CmvdAtom*
-AP4_CmvdAtom::Create(AP4_Size size, AP4_ByteStream& stream, AP4_AtomFactory& atom_factory)
-{
- return new AP4_CmvdAtom(size, stream, atom_factory);
+AP4_CmvdAtom*
+AP4_CmvdAtom::Create(AP4_Size size, AP4_ByteStream& stream, AP4_AtomFactory& atom_factory)
+{
+ return new AP4_CmvdAtom(size, stream, atom_factory);
}
/*----------------------------------------------------------------------
@@ -48,26 +48,26 @@ AP4_CmvdAtom::AP4_CmvdAtom(AP4_Size size,
AP4_AtomFactory& atom_factory) :
AP4_ContainerAtom(AP4_ATOM_TYPE_CMVD)
{
- size -= AP4_ATOM_HEADER_SIZE;
+ size -= AP4_ATOM_HEADER_SIZE;
stream.ReadUI32(m_MovieResourceSize);
- size -= 4;
+ size -= 4;
- m_Data.SetDataSize(size);
- stream.Read(m_Data.UseData(), size);
+ m_Data.SetDataSize(size);
+ stream.Read(m_Data.UseData(), size);
- /*
- // read children
- AP4_Size bytes_available = size-AP4_FULL_ATOM_HEADER_SIZE-4;
- while (entry_count--) {
- AP4_Atom* atom;
- while (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
- bytes_available,
- atom,
- this))) {
- m_Children.Add(atom);
- }
+/*
+ // read children
+ AP4_Size bytes_available = size-AP4_FULL_ATOM_HEADER_SIZE-4;
+ while (entry_count--) {
+ AP4_Atom* atom;
+ while (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
+ bytes_available,
+ atom,
+ this))) {
+ m_Children.Add(atom);
}
- */
+ }
+*/
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.h
index 9d768fc88..51e2ca843 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CmvdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - cmvd Atoms
+| AP4 - cmvd Atoms
|
| Copyright 2002 Gilles Boccon-Gibod
|
@@ -46,31 +46,22 @@
class AP4_CmvdAtom : public AP4_ContainerAtom
{
public:
- // class methods
- static AP4_CmvdAtom* Create(AP4_Size size, AP4_ByteStream& stream, AP4_AtomFactory& atom_factory);
+ // class methods
+ static AP4_CmvdAtom* Create(AP4_Size size, AP4_ByteStream& stream, AP4_AtomFactory& atom_factory);
- // methods
+ // methods
AP4_CmvdAtom(AP4_Size size,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream)
- {
- return AP4_FAILURE;
- }
+ virtual AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
- AP4_UI32 GetMovieResourceSize() const
- {
- return m_MovieResourceSize;
- }
- const AP4_DataBuffer& GetDataBuffer()
- {
- return m_Data;
- }
+ AP4_UI32 GetMovieResourceSize() const { return m_MovieResourceSize; }
+ const AP4_DataBuffer& GetDataBuffer() { return m_Data; }
private:
- AP4_UI32 m_MovieResourceSize;
- AP4_DataBuffer m_Data;
+ AP4_UI32 m_MovieResourceSize;
+ AP4_DataBuffer m_Data;
};
#endif // _AP4_CMVD_ATOM_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.cpp
index df097449c..3dea98337 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - co64 Atoms
+| AP4 - co64 Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_Co64Atom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_Co64Atom(size, version, flags, stream);
}
@@ -55,32 +55,30 @@ AP4_Co64Atom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_Co64Atom::AP4_Co64Atom
+---------------------------------------------------------------------*/
AP4_Co64Atom::AP4_Co64Atom(AP4_UI64* entries, AP4_UI32 entry_count) :
- AP4_Atom(AP4_ATOM_TYPE_CO64,
- AP4_FULL_ATOM_HEADER_SIZE + 4 + entry_count * 8,
- 0, 0),
- m_Entries(new AP4_UI64[entry_count]),
- m_EntryCount(entry_count)
+AP4_Atom(AP4_ATOM_TYPE_CO64,
+ AP4_FULL_ATOM_HEADER_SIZE+4+entry_count*8,
+ 0, 0),
+ m_Entries(new AP4_UI64[entry_count]),
+ m_EntryCount(entry_count)
{
- AP4_CopyMemory(m_Entries, entries, m_EntryCount * 8);
+ AP4_CopyMemory(m_Entries, entries, m_EntryCount*8);
}
/*----------------------------------------------------------------------
| AP4_Co64Atom::AP4_Co64Atom
+---------------------------------------------------------------------*/
-AP4_Co64Atom::AP4_Co64Atom(AP4_UI32 size,
+AP4_Co64Atom::AP4_Co64Atom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_CO64, size, version, flags)
{
stream.ReadUI32(m_EntryCount);
- if(m_EntryCount > (size - AP4_FULL_ATOM_HEADER_SIZE - 4) / 8)
- {
- m_EntryCount = (size - AP4_FULL_ATOM_HEADER_SIZE - 4) / 8;
+ if (m_EntryCount > (size-AP4_FULL_ATOM_HEADER_SIZE-4)/8) {
+ m_EntryCount = (size-AP4_FULL_ATOM_HEADER_SIZE-4)/8;
}
m_Entries = new AP4_UI64[m_EntryCount];
- for(AP4_Ordinal i = 0; i < m_EntryCount; i++)
- {
+ for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
stream.ReadUI64(m_Entries[i]);
}
}
@@ -100,8 +98,7 @@ AP4_Result
AP4_Co64Atom::GetChunkOffset(AP4_Ordinal chunk, AP4_UI64& chunk_offset)
{
// check the bounds
- if(chunk > m_EntryCount || chunk == 0)
- {
+ if (chunk > m_EntryCount || chunk == 0) {
return AP4_ERROR_OUT_OF_RANGE;
}
@@ -118,8 +115,7 @@ AP4_Result
AP4_Co64Atom::SetChunkOffset(AP4_Ordinal chunk, AP4_UI64 chunk_offset)
{
// check the bounds
- if(chunk > m_EntryCount || chunk == 0)
- {
+ if (chunk > m_EntryCount || chunk == 0) {
return AP4_ERROR_OUT_OF_RANGE;
}
@@ -135,8 +131,7 @@ AP4_Co64Atom::SetChunkOffset(AP4_Ordinal chunk, AP4_UI64 chunk_offset)
AP4_Result
AP4_Co64Atom::AdjustChunkOffsets(AP4_SI64 delta)
{
- for(AP4_Ordinal i = 0; i < m_EntryCount; i++)
- {
+ for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
m_Entries[i] += delta;
}
@@ -153,13 +148,12 @@ AP4_Co64Atom::WriteFields(AP4_ByteStream& stream)
// entry count
result = stream.WriteUI32(m_EntryCount);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// entries
- for(AP4_Ordinal i = 0; i < m_EntryCount; i++)
- {
+ for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
result = stream.WriteUI64(m_Entries[i]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return result;
@@ -172,11 +166,9 @@ AP4_Result
AP4_Co64Atom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("entry_count", m_EntryCount);
- if(inspector.GetVerbosity() >= 1)
- {
+ if (inspector.GetVerbosity() >= 1) {
char header[32];
- for(AP4_Ordinal i = 0; i < m_EntryCount; i++)
- {
+ for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
AP4_FormatString(header, sizeof(header), "entry %8d", i);
inspector.AddField(header, m_Entries[i]);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.h
index eb79a09e5..bdfeb4736 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Co64Atom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - co64 Atoms
+| AP4 - co64 Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -51,21 +51,15 @@ public:
~AP4_Co64Atom();
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_Cardinal GetChunkCount()
- {
- return m_EntryCount;
- }
- AP4_UI64* GetChunkOffsets()
- {
- return m_Entries;
- }
+ AP4_Cardinal GetChunkCount() { return m_EntryCount; }
+ AP4_UI64* GetChunkOffsets() { return m_Entries; }
AP4_Result GetChunkOffset(AP4_Ordinal chunk, AP4_UI64& chunk_offset);
AP4_Result SetChunkOffset(AP4_Ordinal chunk, AP4_UI64 chunk_offset);
AP4_Result AdjustChunkOffsets(AP4_SI64 delta);
private:
// methods
- AP4_Co64Atom(AP4_UI32 size,
+ AP4_Co64Atom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.cpp
index 0e9a4b0c8..1dc6958f5 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.cpp
@@ -66,7 +66,7 @@ AP4_UnknownCommand::AP4_UnknownCommand(AP4_ByteStream& stream,
AP4_Command(tag, header_size, payload_size)
{
m_Data.SetDataSize(payload_size);
- stream.Read(m_Data.UseData(), payload_size);
+ stream.Read(m_Data.UseData(), payload_size);
}
/*----------------------------------------------------------------------
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.h
index aff51bd2f..50cf8d736 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Command.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - Commands
+| AP4 - Commands
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -52,8 +52,8 @@ const AP4_UI08 AP4_COMMAND_TAG_OBJECT_DESCRIPTOR_EXECUTE = 0x08;
+---------------------------------------------------------------------*/
class AP4_Command : public AP4_Expandable
{
-public:
- AP4_IMPLEMENT_DYNAMIC_CAST(AP4_Command)
+ public:
+ AP4_IMPLEMENT_DYNAMIC_CAST(AP4_Command)
// constructor
AP4_Command(AP4_UI08 tag, AP4_Size header_size, AP4_Size payload_size) :
@@ -63,10 +63,7 @@ public:
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
// methods
- AP4_UI08 GetTag()
- {
- return (AP4_UI08)m_ClassId;
- }
+ AP4_UI08 GetTag() { return (AP4_UI08)m_ClassId; }
};
/*----------------------------------------------------------------------
@@ -76,11 +73,11 @@ class AP4_UnknownCommand : public AP4_Command
{
public:
// contrusctor
- AP4_UnknownCommand(AP4_ByteStream& stream,
+ AP4_UnknownCommand(AP4_ByteStream& stream,
AP4_UI08 tag,
AP4_Size header_size,
AP4_Size payload_size);
-
+
// AP4_Expandable methods
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.cpp
index 1b66191fc..f41312bda 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.cpp
@@ -38,8 +38,8 @@
| AP4_CommandFactory::CreateCommandFromStream
+---------------------------------------------------------------------*/
AP4_Result
-AP4_CommandFactory::CreateCommandFromStream(AP4_ByteStream& stream,
- AP4_Command*& command)
+AP4_CommandFactory::CreateCommandFromStream(AP4_ByteStream& stream,
+ AP4_Command*& command)
{
AP4_Result result;
@@ -53,45 +53,40 @@ AP4_CommandFactory::CreateCommandFromStream(AP4_ByteStream& stream,
// read descriptor tag
unsigned char tag;
result = stream.ReadUI08(tag);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
stream.Seek(offset);
return result;
}
-
+
// read descriptor size
unsigned long payload_size = 0;
unsigned int header_size = 1;
unsigned int max = 4;
unsigned char ext = 0;
- do
- {
+ do {
header_size++;
result = stream.ReadUI08(ext);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
stream.Seek(offset);
return result;
}
- payload_size = (payload_size << 7) + (ext & 0x7F);
- }
- while(--max && (ext & 0x80));
+ payload_size = (payload_size<<7) + (ext&0x7F);
+ } while (--max && (ext&0x80));
// create the command
- switch(tag)
- {
- case AP4_COMMAND_TAG_OBJECT_DESCRIPTOR_UPDATE:
- case AP4_COMMAND_TAG_IPMP_DESCRIPTOR_UPDATE:
+ switch (tag) {
+ case AP4_COMMAND_TAG_OBJECT_DESCRIPTOR_UPDATE:
+ case AP4_COMMAND_TAG_IPMP_DESCRIPTOR_UPDATE:
command = new AP4_DescriptorUpdateCommand(stream, tag, header_size, payload_size);
break;
- default:
+ default:
command = new AP4_UnknownCommand(stream, tag, header_size, payload_size);
break;
}
// skip to the end of the descriptor
- stream.Seek(offset + header_size + payload_size);
+ stream.Seek(offset+header_size+payload_size);
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.h
index 34bd347a2..133b35020 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CommandFactory.h
@@ -43,12 +43,12 @@ class AP4_ByteStream;
/*----------------------------------------------------------------------
| AP4_CommandFactory
+---------------------------------------------------------------------*/
-class AP4_CommandFactory
+class AP4_CommandFactory
{
-public:
+ public:
// class methods
static AP4_Result CreateCommandFromStream(AP4_ByteStream& stream,
- AP4_Command*& command);
+ AP4_Command*& command);
};
#endif // _AP4_COMMAND_FACTORY_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.cpp
index 7677a2005..deee12653 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.cpp
@@ -44,47 +44,41 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_ContainerAtom)
| AP4_ContainerAtom::AP4_ContainerAtom
+---------------------------------------------------------------------*/
AP4_ContainerAtom*
-AP4_ContainerAtom::Create(Type type,
+AP4_ContainerAtom::Create(Type type,
AP4_UI64 size,
bool is_full,
bool force_64,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory)
{
- if(is_full)
- {
+ if (is_full) {
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
-
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+
// special case for 'meta' atoms, because Apple sometimes creates them as
// regular (non-full) atoms. This is bogus, but we can try to detect it
- if(type == AP4_ATOM_TYPE_META)
- {
- AP4_UI32 phantom_size = (version << 24) | flags;
- if(phantom_size >= 8 && size >= 16)
- {
+ if (type == AP4_ATOM_TYPE_META) {
+ AP4_UI32 phantom_size = (version<<24)|flags;
+ if (phantom_size >= 8 && size >= 16) {
// version+flags looks like a size. read the next 4 bytes just
// to be sure it is a hdlr atom
AP4_UI32 peek;
- if(AP4_FAILED(stream.ReadUI32(peek))) return NULL;
- if(peek == AP4_ATOM_TYPE_HDLR)
- {
+ if (AP4_FAILED(stream.ReadUI32(peek))) return NULL;
+ if (peek == AP4_ATOM_TYPE_HDLR) {
// rewind the stream by 8 bytes
AP4_Position position;
stream.Tell(position);
- stream.Seek(position - 8);
-
+ stream.Seek(position-8);
+
// create a non-full container
return new AP4_ContainerAtom(type, size, force_64, stream, atom_factory);
}
}
}
-
+
return new AP4_ContainerAtom(type, size, force_64, version, flags, stream, atom_factory);
- }
- else
- {
+ } else {
return new AP4_ContainerAtom(type, size, force_64, stream, atom_factory);
}
}
@@ -116,10 +110,10 @@ AP4_ContainerAtom::AP4_ContainerAtom(Type type, AP4_UI64 size, bool force_64) :
/*----------------------------------------------------------------------
| AP4_ContainerAtom::AP4_ContainerAtom
+---------------------------------------------------------------------*/
-AP4_ContainerAtom::AP4_ContainerAtom(Type type,
+AP4_ContainerAtom::AP4_ContainerAtom(Type type,
AP4_UI64 size,
bool force_64,
- AP4_UI32 version,
+ AP4_UI32 version,
AP4_UI32 flags) :
AP4_Atom(type, size, force_64, version, flags)
{
@@ -129,20 +123,20 @@ AP4_ContainerAtom::AP4_ContainerAtom(Type type,
/*----------------------------------------------------------------------
| AP4_ContainerAtom::AP4_ContainerAtom
+---------------------------------------------------------------------*/
-AP4_ContainerAtom::AP4_ContainerAtom(Type type,
+AP4_ContainerAtom::AP4_ContainerAtom(Type type,
AP4_UI64 size,
bool force_64,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory) :
AP4_Atom(type, size, force_64)
{
- ReadChildren(atom_factory, stream, size - GetHeaderSize());
+ ReadChildren(atom_factory, stream, size-GetHeaderSize());
}
/*----------------------------------------------------------------------
| AP4_ContainerAtom::AP4_ContainerAtom
+---------------------------------------------------------------------*/
-AP4_ContainerAtom::AP4_ContainerAtom(Type type,
+AP4_ContainerAtom::AP4_ContainerAtom(Type type,
AP4_UI64 size,
bool force_64,
AP4_UI32 version,
@@ -151,30 +145,26 @@ AP4_ContainerAtom::AP4_ContainerAtom(Type type,
AP4_AtomFactory& atom_factory) :
AP4_Atom(type, size, force_64, version, flags)
{
- ReadChildren(atom_factory, stream, size - GetHeaderSize());
+ ReadChildren(atom_factory, stream, size-GetHeaderSize());
}
/*----------------------------------------------------------------------
| AP4_ContainerAtom::Clone
+---------------------------------------------------------------------*/
-AP4_Atom*
+AP4_Atom*
AP4_ContainerAtom::Clone()
{
AP4_ContainerAtom* clone;
- if(m_IsFull)
- {
+ if (m_IsFull) {
clone = new AP4_ContainerAtom(m_Type, m_Version, m_Flags);
- }
- else
- {
+ } else {
clone = new AP4_ContainerAtom(m_Type);
}
AP4_List<AP4_Atom>::Item* child_item = m_Children.FirstItem();
- while(child_item)
- {
+ while (child_item) {
AP4_Atom* child_clone = child_item->GetData()->Clone();
- if(child_clone) clone->AddChild(child_clone);
+ if (child_clone) clone->AddChild(child_clone);
child_item = child_item->GetNext();
}
@@ -186,7 +176,7 @@ AP4_ContainerAtom::Clone()
+---------------------------------------------------------------------*/
void
AP4_ContainerAtom::ReadChildren(AP4_AtomFactory& atom_factory,
- AP4_ByteStream& stream,
+ AP4_ByteStream& stream,
AP4_UI64 size)
{
AP4_Atom* atom;
@@ -195,9 +185,8 @@ AP4_ContainerAtom::ReadChildren(AP4_AtomFactory& atom_factory,
// save and switch the factory's context
atom_factory.PushContext(m_Type);
- while(AP4_SUCCEEDED(
- atom_factory.CreateAtomFromStream(stream, bytes_available, atom)))
- {
+ while (AP4_SUCCEEDED(
+ atom_factory.CreateAtomFromStream(stream, bytes_available, atom))) {
atom->SetParent(this);
m_Children.Add(atom);
}
@@ -249,7 +238,7 @@ AP4_ContainerAtom::OnChildChanged(AP4_Atom*)
SetSize(size);
// update our parent
- if(m_Parent) m_Parent->OnChildChanged(this);
+ if (m_Parent) m_Parent->OnChildChanged(this);
}
/*----------------------------------------------------------------------
@@ -259,10 +248,10 @@ void
AP4_ContainerAtom::OnChildAdded(AP4_Atom* child)
{
// update our size
- SetSize(GetSize() + child->GetSize());
+ SetSize(GetSize()+child->GetSize());
// update our parent
- if(m_Parent) m_Parent->OnChildChanged(this);
+ if (m_Parent) m_Parent->OnChildChanged(this);
}
/*----------------------------------------------------------------------
@@ -272,8 +261,8 @@ void
AP4_ContainerAtom::OnChildRemoved(AP4_Atom* child)
{
// update our size
- SetSize(GetSize() - child->GetSize());
+ SetSize(GetSize()-child->GetSize());
// update our parent
- if(m_Parent) m_Parent->OnChildChanged(this);
+ if (m_Parent) m_Parent->OnChildChanged(this);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.h
index e23fabfa6..b19e18637 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ContainerAtom.h
@@ -45,14 +45,14 @@ class AP4_AtomFactory;
/*----------------------------------------------------------------------
| AP4_ContainerAtom
+---------------------------------------------------------------------*/
-class AP4_ContainerAtom : public AP4_Atom, public AP4_AtomParent
+class AP4_ContainerAtom : public AP4_Atom, public AP4_AtomParent
{
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D2(AP4_ContainerAtom, AP4_Atom, AP4_AtomParent)
// class methods
- static AP4_ContainerAtom* Create(Type type,
- AP4_UI64 size,
+ static AP4_ContainerAtom* Create(Type type,
+ AP4_UI64 size,
bool is_full,
bool force_64,
AP4_ByteStream& stream,
@@ -60,13 +60,10 @@ public:
// methods
explicit AP4_ContainerAtom(Type type);
- explicit AP4_ContainerAtom(Type type, AP4_UI32 version, AP4_UI32 flags);
+ explicit AP4_ContainerAtom(Type type, AP4_UI32 version, AP4_UI32 flags);
explicit AP4_ContainerAtom(Type type, AP4_UI64 size, bool force_64);
explicit AP4_ContainerAtom(Type type, AP4_UI64 size, bool force_64, AP4_UI32 version, AP4_UI32 flags);
- AP4_List<AP4_Atom>& GetChildren()
- {
- return m_Children;
- }
+ AP4_List<AP4_Atom>& GetChildren() { return m_Children; }
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result InspectChildren(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
@@ -79,22 +76,22 @@ public:
protected:
// constructors
- AP4_ContainerAtom(Type type,
- AP4_UI64 size,
+ AP4_ContainerAtom(Type type,
+ AP4_UI64 size,
bool force_64,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
- AP4_ContainerAtom(Type type,
- AP4_UI64 size,
+ AP4_ContainerAtom(Type type,
+ AP4_UI64 size,
bool force_64,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
// methods
void ReadChildren(AP4_AtomFactory& atom_factory,
- AP4_ByteStream& stream,
+ AP4_ByteStream& stream,
AP4_UI64 size);
};
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.cpp
index b483be5b3..fc431825a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - ctts Atoms
+| AP4 - ctts Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_CttsAtom::Create(AP4_UI32 size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_CttsAtom(size, version, flags, stream);
}
@@ -55,7 +55,7 @@ AP4_CttsAtom::Create(AP4_UI32 size, AP4_ByteStream& stream)
| AP4_CttsAtom::AP4_CttsAtom
+---------------------------------------------------------------------*/
AP4_CttsAtom::AP4_CttsAtom() :
- AP4_Atom(AP4_ATOM_TYPE_CTTS, AP4_FULL_ATOM_HEADER_SIZE + 4, 0, 0)
+ AP4_Atom(AP4_ATOM_TYPE_CTTS, AP4_FULL_ATOM_HEADER_SIZE+4, 0, 0)
{
m_LookupCache.sample = 0;
m_LookupCache.entry_index = 0;
@@ -64,7 +64,7 @@ AP4_CttsAtom::AP4_CttsAtom() :
/*----------------------------------------------------------------------
| AP4_CttsAtom::AP4_CttsAtom
+---------------------------------------------------------------------*/
-AP4_CttsAtom::AP4_CttsAtom(AP4_UI32 size,
+AP4_CttsAtom::AP4_CttsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -77,16 +77,14 @@ AP4_CttsAtom::AP4_CttsAtom(AP4_UI32 size,
stream.ReadUI32(entry_count);
m_Entries.SetItemCount(entry_count);
unsigned char* buffer = new unsigned char[entry_count*8];
- AP4_Result result = stream.Read(buffer, entry_count * 8);
- if(AP4_FAILED(result))
- {
+ AP4_Result result = stream.Read(buffer, entry_count*8);
+ if (AP4_FAILED(result)) {
delete[] buffer;
return;
}
//bool use_quicktime_format = false;
//AP4_SI32 quicktime_min_offset = 0;
- for(unsigned i = 0; i < entry_count; i++)
- {
+ for (unsigned i=0; i<entry_count; i++) {
m_Entries[i].m_SampleCount = AP4_BytesToUInt32BE(&buffer[i*8 ]);
AP4_UI32 offset = AP4_BytesToUInt32BE(&buffer[i*8+4]);
//if (offset & 0x80000000) {
@@ -97,7 +95,7 @@ AP4_CttsAtom::AP4_CttsAtom(AP4_UI32 size,
m_Entries[i].m_SampleOffset = offset;
}
delete[] buffer;
-
+
// in the quicktime format, the offsets can be positive or negative, so
// we need to adjust for them here
//if (use_quicktime_format) {
@@ -126,27 +124,24 @@ AP4_CttsAtom::GetCtsOffset(AP4_Ordinal sample, AP4_UI32& cts_offset)
{
// default value
cts_offset = 0;
-
+
// sample indexes start at 1
- if(sample == 0) return AP4_ERROR_OUT_OF_RANGE;
-
+ if (sample == 0) return AP4_ERROR_OUT_OF_RANGE;
+
// check the lookup cache
AP4_Ordinal lookup_start = 0;
AP4_Ordinal sample_start = 0;
- if(sample >= m_LookupCache.sample)
- {
+ if (sample >= m_LookupCache.sample) {
// start from the cached entry
lookup_start = m_LookupCache.entry_index;
sample_start = m_LookupCache.sample;
}
- for(AP4_Ordinal i = lookup_start; i < m_Entries.ItemCount(); i++)
- {
+ for (AP4_Ordinal i = lookup_start; i < m_Entries.ItemCount(); i++) {
AP4_CttsTableEntry& entry = m_Entries[i];
// check if we have reached the sample
- if(sample <= sample_start + entry.m_SampleCount)
- {
+ if (sample <= sample_start+entry.m_SampleCount) {
// we are within the sample range for the current entry
cts_offset = entry.m_SampleOffset;
@@ -158,7 +153,7 @@ AP4_CttsAtom::GetCtsOffset(AP4_Ordinal sample, AP4_UI32& cts_offset)
}
// update the upper bound
- sample_start += entry.m_SampleCount;
+ sample_start += entry.m_SampleCount;
}
// sample is greater than the number of samples
@@ -176,18 +171,17 @@ AP4_CttsAtom::WriteFields(AP4_ByteStream& stream)
// write the entry count
AP4_Cardinal entry_count = m_Entries.ItemCount();
result = stream.WriteUI32(entry_count);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// write the entries
- for(AP4_Ordinal i = 0; i < entry_count; i++)
- {
+ for (AP4_Ordinal i=0; i<entry_count; i++) {
// sample count
result = stream.WriteUI32(m_Entries[i].m_SampleCount);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// time offset
result = stream.WriteUI32(m_Entries[i].m_SampleOffset);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return AP4_SUCCESS;
@@ -201,15 +195,13 @@ AP4_CttsAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("entry_count", m_Entries.ItemCount());
- if(inspector.GetVerbosity() >= 2)
- {
+ if (inspector.GetVerbosity() >= 2) {
char header[32];
char value[64];
- for(AP4_Ordinal i = 0; i < m_Entries.ItemCount(); i++)
- {
+ for (AP4_Ordinal i=0; i<m_Entries.ItemCount(); i++) {
AP4_FormatString(header, sizeof(header), "entry %8d", i);
- AP4_FormatString(value, sizeof(value), "count=%d, offset=%d",
- m_Entries[i].m_SampleCount,
+ AP4_FormatString(value, sizeof(value), "count=%d, offset=%d",
+ m_Entries[i].m_SampleCount,
m_Entries[i].m_SampleOffset);
inspector.AddField(header, value);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.h
index d853a5d99..0f86c8399 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4CttsAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - ctts Atoms
+| AP4 - ctts Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -44,11 +44,10 @@ class AP4_ByteStream;
/*----------------------------------------------------------------------
| AP4_CttsTableEntry
+---------------------------------------------------------------------*/
-class AP4_CttsTableEntry
-{
-public:
- AP4_CttsTableEntry() :
- m_SampleCount(0),
+class AP4_CttsTableEntry {
+ public:
+ AP4_CttsTableEntry() :
+ m_SampleCount(0),
m_SampleOffset(0) {}
AP4_CttsTableEntry(AP4_UI32 sample_count,
AP4_UI32 sample_offset) :
@@ -72,7 +71,7 @@ public:
// constructor
AP4_CttsAtom();
-
+
// methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
@@ -81,15 +80,14 @@ public:
private:
// methods
- AP4_CttsAtom(AP4_UI32 size,
+ AP4_CttsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
// members
AP4_Array<AP4_CttsTableEntry> m_Entries;
- struct
- {
+ struct {
AP4_Ordinal sample;
AP4_Ordinal entry_index;
} m_LookupCache;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.cpp
index a82f2d57c..5cd837d3c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.cpp
@@ -64,8 +64,7 @@ AP4_DataBuffer::AP4_DataBuffer(const void* data, AP4_Size data_size) :
m_BufferSize(data_size),
m_DataSize(data_size)
{
- if(data && data_size)
- {
+ if (data && data_size) {
m_Buffer = new AP4_Byte[data_size];
AP4_CopyMemory(m_Buffer, data, data_size);
}
@@ -89,8 +88,7 @@ AP4_DataBuffer::AP4_DataBuffer(const AP4_DataBuffer& other) :
+---------------------------------------------------------------------*/
AP4_DataBuffer::~AP4_DataBuffer()
{
- if(m_BufferIsLocal)
- {
+ if (m_BufferIsLocal) {
delete[] m_Buffer;
}
}
@@ -101,11 +99,11 @@ AP4_DataBuffer::~AP4_DataBuffer()
AP4_Result
AP4_DataBuffer::Reserve(AP4_Size size)
{
- if(size <= m_BufferSize) return AP4_SUCCESS;
+ if (size <= m_BufferSize) return AP4_SUCCESS;
// try doubling the buffer to accomodate for the new size
- AP4_Size new_size = m_BufferSize * 2 + 1024;
- if(new_size < size) new_size = size;
+ AP4_Size new_size = m_BufferSize*2+1024;
+ if (new_size < size) new_size = size;
return SetBufferSize(new_size);
}
@@ -115,8 +113,7 @@ AP4_DataBuffer::Reserve(AP4_Size size)
AP4_Result
AP4_DataBuffer::SetBuffer(AP4_Byte* buffer, AP4_Size buffer_size)
{
- if(m_BufferIsLocal)
- {
+ if (m_BufferIsLocal) {
// destroy the local buffer
delete[] m_Buffer;
}
@@ -135,14 +132,11 @@ AP4_DataBuffer::SetBuffer(AP4_Byte* buffer, AP4_Size buffer_size)
AP4_Result
AP4_DataBuffer::SetBufferSize(AP4_Size buffer_size)
{
- if(m_BufferIsLocal)
- {
+ if (m_BufferIsLocal) {
return ReallocateBuffer(buffer_size);
- }
- else
- {
+ } else {
return AP4_FAILURE; // you cannot change the
- // buffer management mode
+ // buffer management mode
}
}
@@ -152,15 +146,11 @@ AP4_DataBuffer::SetBufferSize(AP4_Size buffer_size)
AP4_Result
AP4_DataBuffer::SetDataSize(AP4_Size size)
{
- if(size > m_BufferSize)
- {
- if(m_BufferIsLocal)
- {
+ if (size > m_BufferSize) {
+ if (m_BufferIsLocal) {
AP4_Result result = ReallocateBuffer(size);
- if(AP4_FAILED(result)) return result;
- }
- else
- {
+ if (AP4_FAILED(result)) return result;
+ } else {
return AP4_FAILURE;
}
}
@@ -174,15 +164,11 @@ AP4_DataBuffer::SetDataSize(AP4_Size size)
AP4_Result
AP4_DataBuffer::SetData(const AP4_Byte* data, AP4_Size size)
{
- if(size > m_BufferSize)
- {
- if(m_BufferIsLocal)
- {
+ if (size > m_BufferSize) {
+ if (m_BufferIsLocal) {
AP4_Result result = ReallocateBuffer(size);
- if(AP4_FAILED(result)) return result;
- }
- else
- {
+ if (AP4_FAILED(result)) return result;
+ } else {
return AP4_FAILURE;
}
}
@@ -200,16 +186,15 @@ AP4_Result
AP4_DataBuffer::ReallocateBuffer(AP4_Size size)
{
// check that the existing data fits
- if(m_DataSize > size) return AP4_FAILURE;
+ if (m_DataSize > size) return AP4_FAILURE;
// allocate a new buffer
AP4_Byte* new_buffer = new AP4_Byte[size];
// copy the contents of the previous buffer ,is any
- if(m_Buffer && m_DataSize)
- {
- AP4_CopyMemory(new_buffer, m_Buffer, m_DataSize);
- }
+ if (m_Buffer && m_DataSize) {
+ AP4_CopyMemory(new_buffer, m_Buffer, m_DataSize);
+ }
// destroy the previous buffer
delete[] m_Buffer;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.h
index 4ecdac62b..64e89f981 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DataBuffer.h
@@ -37,11 +37,11 @@
/*----------------------------------------------------------------------
| AP4_DataBuffer
+---------------------------------------------------------------------*/
-class AP4_DataBuffer
+class AP4_DataBuffer
{
-public:
+ public:
// constructors & destructor
- AP4_DataBuffer();
+ AP4_DataBuffer();
AP4_DataBuffer(AP4_Size size);
AP4_DataBuffer(const void* data, AP4_Size data_size);
AP4_DataBuffer(const AP4_DataBuffer& other);
@@ -50,31 +50,19 @@ public:
// data buffer handling methods
AP4_Result SetBuffer(AP4_Byte* buffer, AP4_Size buffer_size);
AP4_Result SetBufferSize(AP4_Size buffer_size);
- AP4_Size GetBufferSize() const
- {
- return m_BufferSize;
- }
+ AP4_Size GetBufferSize() const { return m_BufferSize; }
// data handling methods
- const AP4_Byte* GetData() const
- {
- return m_Buffer;
- }
- AP4_Byte* UseData()
- {
- return m_Buffer;
- };
- AP4_Size GetDataSize() const
- {
- return m_DataSize;
- }
+ const AP4_Byte* GetData() const { return m_Buffer; }
+ AP4_Byte* UseData() { return m_Buffer; };
+ AP4_Size GetDataSize() const { return m_DataSize; }
AP4_Result SetDataSize(AP4_Size size);
AP4_Result SetData(const AP4_Byte* data, AP4_Size data_size);
// memory management
AP4_Result Reserve(AP4_Size size);
-protected:
+ protected:
// members
bool m_BufferIsLocal;
AP4_Byte* m_Buffer;
@@ -88,6 +76,6 @@ private:
// forbid this
AP4_DataBuffer& operator=(const AP4_DataBuffer& other);
};
-
+
#endif // _AP4_DATA_BUFFER_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.cpp
index 688e6fc4c..9d0bcb0dc 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.cpp
@@ -36,18 +36,18 @@
| AP4_DcomAtom::AP4_DcomAtom
+---------------------------------------------------------------------*/
-AP4_DcomAtom*
-AP4_DcomAtom::Create(AP4_Size size, AP4_ByteStream& stream)
-{
- return new AP4_DcomAtom(size, stream);
-}
+AP4_DcomAtom*
+AP4_DcomAtom::Create(AP4_Size size, AP4_ByteStream& stream)
+{
+ return new AP4_DcomAtom(size, stream);
+}
AP4_DcomAtom::AP4_DcomAtom(AP4_Size size,
AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_DCOM)
+ : AP4_Atom(AP4_ATOM_TYPE_DCOM)
{
- size -= AP4_ATOM_HEADER_SIZE;
+ size -= AP4_ATOM_HEADER_SIZE;
stream.ReadUI32(m_CompressorSubType);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.h
index 20b82f342..4f0e1e8a8 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DcomAtom.h
@@ -40,25 +40,19 @@
class AP4_DcomAtom : public AP4_Atom
{
public:
- // class methods
- static AP4_DcomAtom* Create(AP4_Size size, AP4_ByteStream& stream);
-
- // methods
- AP4_DcomAtom(AP4_Size size,
+ // class methods
+ static AP4_DcomAtom* Create(AP4_Size size, AP4_ByteStream& stream);
+
+ // methods
+ AP4_DcomAtom(AP4_Size size,
AP4_ByteStream& stream);
- AP4_Result WriteFields(AP4_ByteStream& stream)
- {
- return AP4_FAILURE;
- }
+ AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
- AP4_Atom::Type GetCompressorSubType() const
- {
- return m_CompressorSubType;
- }
+ AP4_Atom::Type GetCompressorSubType() const { return m_CompressorSubType; }
private:
- AP4_Atom::Type m_CompressorSubType;
+ AP4_Atom::Type m_CompressorSubType;
};
#endif // _AP4_DCOM_ATOM_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Debug.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Debug.cpp
index 98925d01c..ee09ae84d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Debug.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Debug.cpp
@@ -58,7 +58,7 @@ void
AP4_Debug(const char* format, ...)
{
va_list args;
-
+
va_start(args, format);
char buffer[AP4_DEBUG_MAX_BUFFER];
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.cpp
index 787abad31..45b348f2d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.cpp
@@ -58,8 +58,7 @@ AP4_DecoderConfigDescriptor::AP4_DecoderConfigDescriptor(
m_MaxBitrate(max_bitrate),
m_AverageBitrate(avg_bitrate)
{
- if(dsi)
- {
+ if (dsi) {
m_SubDescriptors.Add(dsi);
m_PayloadSize += dsi->GetSize();
m_HeaderSize = MinHeaderSize(m_PayloadSize);
@@ -71,8 +70,8 @@ AP4_DecoderConfigDescriptor::AP4_DecoderConfigDescriptor(
+---------------------------------------------------------------------*/
AP4_DecoderConfigDescriptor::AP4_DecoderConfigDescriptor(
AP4_ByteStream& stream, AP4_Size header_size, AP4_Size payload_size) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_CONFIG,
- header_size,
+ AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_CONFIG,
+ header_size,
payload_size)
{
// record the start position
@@ -83,19 +82,18 @@ AP4_DecoderConfigDescriptor::AP4_DecoderConfigDescriptor(
stream.ReadUI08(m_ObjectTypeIndication);
unsigned char bits;
stream.ReadUI08(bits);
- m_StreamType = (bits >> 2) & 0x3F;
- m_UpStream = bits & 2 ? true : false;
+ m_StreamType = (bits>>2)&0x3F;
+ m_UpStream = bits&2 ? true:false;
stream.ReadUI24(m_BufferSize);
stream.ReadUI32(m_MaxBitrate);
stream.ReadUI32(m_AverageBitrate);
// read other descriptors
- AP4_SubStream* substream = new AP4_SubStream(stream, start + 13, payload_size - 13);
+ AP4_SubStream* substream = new AP4_SubStream(stream, start+13, payload_size-13);
AP4_Descriptor* descriptor = NULL;
- while(AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
- descriptor)
- == AP4_SUCCESS)
- {
+ while (AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
+ descriptor)
+ == AP4_SUCCESS) {
m_SubDescriptors.Add(descriptor);
}
substream->Release();
@@ -116,7 +114,7 @@ AP4_Result
AP4_DecoderConfigDescriptor::WriteFields(AP4_ByteStream& stream)
{
stream.WriteUI08(m_ObjectTypeIndication);
- AP4_UI08 bits = (m_StreamType << 2) | (m_UpStream ? 2 : 0) | 1;
+ AP4_UI08 bits = (m_StreamType<<2) | (m_UpStream? 2 : 0) | 1;
stream.WriteUI08(bits);
stream.WriteUI24(m_BufferSize);
stream.WriteUI32(m_MaxBitrate);
@@ -134,9 +132,9 @@ AP4_Result
AP4_DecoderConfigDescriptor::Inspect(AP4_AtomInspector& inspector)
{
char info[64];
- AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(),
- m_PayloadSize);
+ AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
+ GetHeaderSize(),
+ m_PayloadSize);
inspector.StartElement("[DecoderConfig]", info);
inspector.AddField("stream_type", m_StreamType);
inspector.AddField("object_type", m_ObjectTypeIndication);
@@ -161,17 +159,14 @@ AP4_DecoderConfigDescriptor::GetDecoderSpecificInfoDescriptor() const
{
// find the decoder specific info
AP4_Descriptor* descriptor = NULL;
- AP4_Result result =
+ AP4_Result result =
m_SubDescriptors.Find(AP4_DescriptorFinder(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO),
descriptor);
-
+
// return it
- if(AP4_SUCCEEDED(result))
- {
+ if (AP4_SUCCEEDED(result)) {
return AP4_DYNAMIC_CAST(AP4_DecoderSpecificInfoDescriptor, descriptor);
- }
- else
- {
+ } else {
return NULL;
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.h
index 2b3298407..831bbf9e5 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderConfigDescriptor.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - DecoderConfig Descriptor
+| AP4 - DecoderConfig Descriptor
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -52,7 +52,7 @@ const AP4_UI08 AP4_DESCRIPTOR_TAG_DECODER_CONFIG = 0x04;
+---------------------------------------------------------------------*/
class AP4_DecoderConfigDescriptor : public AP4_Descriptor
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_DecoderConfigDescriptor, AP4_Descriptor)
// methods
@@ -62,38 +62,25 @@ public:
AP4_UI32 max_bitrate,
AP4_UI32 avg_bitrate,
AP4_DecoderSpecificInfoDescriptor* dsi);
- AP4_DecoderConfigDescriptor(AP4_ByteStream& stream,
+ AP4_DecoderConfigDescriptor(AP4_ByteStream& stream,
AP4_Size header_size,
AP4_Size payload_size);
virtual ~AP4_DecoderConfigDescriptor();
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
-
+
// accessors
virtual const AP4_DecoderSpecificInfoDescriptor*
- GetDecoderSpecificInfoDescriptor() const;
- virtual AP4_UI08 GetObjectTypeIndication() const
- {
- return m_ObjectTypeIndication;
- }
- virtual AP4_UI08 GetStreamType() const
- {
- return m_StreamType;
- }
- virtual AP4_UI32 GetBufferSize() const
- {
- return m_BufferSize;
+ GetDecoderSpecificInfoDescriptor() const;
+ virtual AP4_UI08 GetObjectTypeIndication() const {
+ return m_ObjectTypeIndication;
}
- virtual AP4_UI32 GetMaxBitrate() const
- {
- return m_MaxBitrate;
- }
- virtual AP4_UI32 GetAvgBitrate() const
- {
- return m_AverageBitrate;
- }
-
-private:
+ virtual AP4_UI08 GetStreamType() const { return m_StreamType; }
+ virtual AP4_UI32 GetBufferSize() const { return m_BufferSize; }
+ virtual AP4_UI32 GetMaxBitrate() const { return m_MaxBitrate; }
+ virtual AP4_UI32 GetAvgBitrate() const { return m_AverageBitrate; }
+
+ private:
// members
AP4_UI08 m_StreamType;
AP4_UI08 m_ObjectTypeIndication;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.cpp
index 68892c1c5..8c755964f 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.cpp
@@ -45,8 +45,8 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_DecoderSpecificInfoDescriptor)
+---------------------------------------------------------------------*/
AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor(
const AP4_DataBuffer& data) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO,
- MinHeaderSize(data.GetDataSize()),
+ AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO,
+ MinHeaderSize(data.GetDataSize()),
data.GetDataSize()),
m_Info(data)
{
@@ -57,11 +57,11 @@ AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor(
+---------------------------------------------------------------------*/
AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor(
AP4_ByteStream& stream, AP4_Size header_size, AP4_Size payload_size) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO,
+ AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO,
header_size, payload_size)
{
m_Info.SetDataSize(payload_size);
- stream.Read(m_Info.UseData(), payload_size);
+ stream.Read(m_Info.UseData(), payload_size);
}
/*----------------------------------------------------------------------
@@ -78,8 +78,7 @@ AP4_Result
AP4_DecoderSpecificInfoDescriptor::WriteFields(AP4_ByteStream& stream)
{
// write the info buffer
- if(m_PayloadSize && m_Info.GetDataSize())
- {
+ if (m_PayloadSize && m_Info.GetDataSize()) {
stream.Write(m_Info.GetData(), m_Info.GetDataSize());
}
@@ -93,10 +92,9 @@ AP4_Result
AP4_DecoderSpecificInfoDescriptor::Inspect(AP4_AtomInspector& inspector)
{
char* info = new char[m_Info.GetDataSize()*3+1];
- for(unsigned int i = 0; i < m_Info.GetDataSize(); i++)
- {
- AP4_FormatString(&info[i*3], 4, "%02x ", m_Info.UseData()[i]);
- }
+ for (unsigned int i=0; i<m_Info.GetDataSize(); i++) {
+ AP4_FormatString(&info[i*3], 4, "%02x ", m_Info.UseData()[i]);
+ }
info[m_Info.GetDataSize()*3] = '\0';
inspector.AddField("[DecoderSpecificInfo]", info);
delete[] info;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.h
index b20648053..8f0611c12 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DecoderSpecificInfoDescriptor.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - DecoderSpecificInfo Descriptor
+| AP4 - DecoderSpecificInfo Descriptor
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -57,16 +57,13 @@ public:
// methods
AP4_DecoderSpecificInfoDescriptor(const AP4_DataBuffer& data);
- AP4_DecoderSpecificInfoDescriptor(AP4_ByteStream& stream,
+ AP4_DecoderSpecificInfoDescriptor(AP4_ByteStream& stream,
AP4_Size header_size,
AP4_Size payload_size);
virtual ~AP4_DecoderSpecificInfoDescriptor();
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
- virtual const AP4_DataBuffer& GetDecoderSpecificInfo() const
- {
- return m_Info;
- }
+ virtual const AP4_DataBuffer& GetDecoderSpecificInfo() const { return m_Info; }
private:
// members
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.cpp
index 699c7f9f3..38fb28988 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.cpp
@@ -61,13 +61,13 @@ AP4_Descriptor::Inspect(AP4_AtomInspector& inspector)
| AP4_UnknownDescriptor::AP4_UnknownDescriptor
+---------------------------------------------------------------------*/
AP4_UnknownDescriptor::AP4_UnknownDescriptor(AP4_ByteStream& stream,
- AP4_UI08 tag,
- AP4_Size header_size,
- AP4_Size payload_size) :
+ AP4_UI08 tag,
+ AP4_Size header_size,
+ AP4_Size payload_size) :
AP4_Descriptor(tag, header_size, payload_size)
{
m_Data.SetDataSize(payload_size);
- stream.Read(m_Data.UseData(), payload_size);
+ stream.Read(m_Data.UseData(), payload_size);
}
/*----------------------------------------------------------------------
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.h
index d66daa2bb..7fe0717a1 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Descriptor.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - Descriptors
+| AP4 - Descriptors
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -47,9 +47,9 @@ class AP4_AtomInspector;
+---------------------------------------------------------------------*/
class AP4_Descriptor : public AP4_Expandable
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST(AP4_Descriptor)
-
+
// constructor
AP4_Descriptor(AP4_UI08 tag, AP4_Size header_size, AP4_Size payload_size) :
AP4_Expandable(tag, CLASS_ID_SIZE_08, header_size, payload_size) {}
@@ -58,10 +58,7 @@ public:
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
// methods
- AP4_UI08 GetTag()
- {
- return (AP4_UI08)m_ClassId;
- }
+ AP4_UI08 GetTag() { return (AP4_UI08)m_ClassId; }
};
/*----------------------------------------------------------------------
@@ -71,14 +68,14 @@ class AP4_UnknownDescriptor : public AP4_Descriptor
{
public:
// contrusctor
- AP4_UnknownDescriptor(AP4_ByteStream& stream,
+ AP4_UnknownDescriptor(AP4_ByteStream& stream,
AP4_UI08 tag,
AP4_Size header_size,
AP4_Size payload_size);
-
+
// AP4_Expandable methods
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
private:
// members
AP4_DataBuffer m_Data;
@@ -89,14 +86,13 @@ private:
+---------------------------------------------------------------------*/
class AP4_DescriptorFinder : public AP4_List<AP4_Descriptor>::Item::Finder
{
-public:
+ public:
AP4_DescriptorFinder(AP4_UI08 tag) : m_Tag(tag) {}
- AP4_Result Test(AP4_Descriptor* descriptor) const
- {
+ AP4_Result Test(AP4_Descriptor* descriptor) const {
return descriptor->GetTag() == m_Tag ? AP4_SUCCESS : AP4_FAILURE;
}
-
-private:
+
+ private:
AP4_UI08 m_Tag;
};
@@ -107,9 +103,8 @@ class AP4_DescriptorListWriter : public AP4_List<AP4_Descriptor>::Item::Operator
{
public:
AP4_DescriptorListWriter(AP4_ByteStream& stream) :
- m_Stream(stream) {}
- AP4_Result Action(AP4_Descriptor* descriptor) const
- {
+ m_Stream(stream) {}
+ AP4_Result Action(AP4_Descriptor* descriptor) const {
return descriptor->Write(m_Stream);
}
@@ -122,16 +117,15 @@ private:
+---------------------------------------------------------------------*/
class AP4_DescriptorListInspector : public AP4_List<AP4_Descriptor>::Item::Operator
{
-public:
+ public:
AP4_DescriptorListInspector(AP4_AtomInspector& inspector) :
m_Inspector(inspector) {}
- AP4_Result Action(AP4_Descriptor* descriptor) const
- {
+ AP4_Result Action(AP4_Descriptor* descriptor) const {
descriptor->Inspect(m_Inspector);
return AP4_SUCCESS;
}
-private:
+ private:
AP4_AtomInspector& m_Inspector;
};
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.cpp
index a36f16f60..331a2bc23 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.cpp
@@ -42,8 +42,8 @@
| AP4_DescriptorFactory::CreateDescriptorFromStream
+---------------------------------------------------------------------*/
AP4_Result
-AP4_DescriptorFactory::CreateDescriptorFromStream(AP4_ByteStream& stream,
- AP4_Descriptor*& descriptor)
+AP4_DescriptorFactory::CreateDescriptorFromStream(AP4_ByteStream& stream,
+ AP4_Descriptor*& descriptor)
{
AP4_Result result;
@@ -57,83 +57,78 @@ AP4_DescriptorFactory::CreateDescriptorFromStream(AP4_ByteStream& stream,
// read descriptor tag
unsigned char tag;
result = stream.ReadUI08(tag);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
stream.Seek(offset);
return result;
}
-
+
// read descriptor size
unsigned long payload_size = 0;
unsigned int header_size = 1;
unsigned int max = 4;
unsigned char ext = 0;
- do
- {
+ do {
header_size++;
result = stream.ReadUI08(ext);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
stream.Seek(offset);
return result;
}
- payload_size = (payload_size << 7) + (ext & 0x7F);
- }
- while(--max && (ext & 0x80));
+ payload_size = (payload_size<<7) + (ext&0x7F);
+ } while (--max && (ext&0x80));
// create the descriptor
- switch(tag)
- {
- case AP4_DESCRIPTOR_TAG_OD:
- case AP4_DESCRIPTOR_TAG_MP4_OD:
+ switch (tag) {
+ case AP4_DESCRIPTOR_TAG_OD:
+ case AP4_DESCRIPTOR_TAG_MP4_OD:
descriptor = new AP4_ObjectDescriptor(stream, tag, header_size, payload_size);
break;
- case AP4_DESCRIPTOR_TAG_IOD:
- case AP4_DESCRIPTOR_TAG_MP4_IOD:
+ case AP4_DESCRIPTOR_TAG_IOD:
+ case AP4_DESCRIPTOR_TAG_MP4_IOD:
descriptor = new AP4_InitialObjectDescriptor(stream, tag, header_size, payload_size);
break;
- case AP4_DESCRIPTOR_TAG_ES_ID_INC:
+ case AP4_DESCRIPTOR_TAG_ES_ID_INC:
descriptor = new AP4_EsIdIncDescriptor(stream, header_size, payload_size);
break;
- case AP4_DESCRIPTOR_TAG_ES_ID_REF:
+ case AP4_DESCRIPTOR_TAG_ES_ID_REF:
descriptor = new AP4_EsIdRefDescriptor(stream, header_size, payload_size);
break;
-
- case AP4_DESCRIPTOR_TAG_ES:
+
+ case AP4_DESCRIPTOR_TAG_ES:
descriptor = new AP4_EsDescriptor(stream, header_size, payload_size);
break;
- case AP4_DESCRIPTOR_TAG_DECODER_CONFIG:
+ case AP4_DESCRIPTOR_TAG_DECODER_CONFIG:
descriptor = new AP4_DecoderConfigDescriptor(stream, header_size, payload_size);
break;
- case AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO:
- descriptor = new AP4_DecoderSpecificInfoDescriptor(stream, header_size, payload_size);
- break;
-
- case AP4_DESCRIPTOR_TAG_SL_CONFIG:
- if(payload_size != 1) return AP4_ERROR_INVALID_FORMAT;
+ case AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO:
+ descriptor = new AP4_DecoderSpecificInfoDescriptor(stream, header_size, payload_size);
+ break;
+
+ case AP4_DESCRIPTOR_TAG_SL_CONFIG:
+ if (payload_size != 1) return AP4_ERROR_INVALID_FORMAT;
descriptor = new AP4_SLConfigDescriptor(header_size);
break;
- case AP4_DESCRIPTOR_TAG_IPMP_DESCRIPTOR_POINTER:
+ case AP4_DESCRIPTOR_TAG_IPMP_DESCRIPTOR_POINTER:
descriptor = new AP4_IpmpDescriptorPointer(stream, header_size, payload_size);
break;
-
- case AP4_DESCRIPTOR_TAG_IPMP_DESCRIPTOR:
+
+ case AP4_DESCRIPTOR_TAG_IPMP_DESCRIPTOR:
descriptor = new AP4_IpmpDescriptor(stream, header_size, payload_size);
break;
- default:
+ default:
descriptor = new AP4_UnknownDescriptor(stream, tag, header_size, payload_size);
break;
}
// skip to the end of the descriptor
- stream.Seek(offset + header_size + payload_size);
+ stream.Seek(offset+header_size+payload_size);
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.h
index f76b2fbf5..9fe8bd0c8 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DescriptorFactory.h
@@ -43,12 +43,12 @@ class AP4_Descriptor;
/*----------------------------------------------------------------------
| AP4_DescriptorFactory
+---------------------------------------------------------------------*/
-class AP4_DescriptorFactory
+class AP4_DescriptorFactory
{
-public:
+ public:
// class methods
static AP4_Result CreateDescriptorFromStream(AP4_ByteStream& stream,
- AP4_Descriptor*& descriptor);
+ AP4_Descriptor*& descriptor);
};
#endif // _AP4_DESCRIPTOR_FACTORY_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.cpp
index f8fd54bc1..df83ecc1e 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - dref Atoms
+| AP4 - dref Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -37,15 +37,15 @@
/*----------------------------------------------------------------------
| AP4_DrefAtom::Create
+---------------------------------------------------------------------*/
-AP4_DrefAtom*
+AP4_DrefAtom*
AP4_DrefAtom::Create(AP4_UI32 size,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_DrefAtom(size, version, flags, stream, atom_factory);
}
@@ -56,8 +56,7 @@ AP4_DrefAtom::AP4_DrefAtom(AP4_Atom** refs, AP4_Cardinal refs_count) :
AP4_ContainerAtom(AP4_ATOM_TYPE_DREF, (AP4_UI32)0, (AP4_UI32)0)
{
m_Size32 += 4;
- for(unsigned i = 0; i < refs_count; i++)
- {
+ for (unsigned i=0; i<refs_count; i++) {
m_Children.Add(refs[i]);
m_Size32 += (AP4_UI32)refs[i]->GetSize();
}
@@ -78,14 +77,12 @@ AP4_DrefAtom::AP4_DrefAtom(AP4_UI32 size,
stream.ReadUI32(entry_count);
// read children
- AP4_LargeSize bytes_available = size - AP4_FULL_ATOM_HEADER_SIZE - 4;
- while(entry_count--)
- {
- AP4_Atom* atom;
- while(AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
- bytes_available,
- atom)))
- {
+ AP4_LargeSize bytes_available = size-AP4_FULL_ATOM_HEADER_SIZE-4;
+ while (entry_count--) {
+ AP4_Atom* atom;
+ while (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
+ bytes_available,
+ atom))) {
m_Children.Add(atom);
}
}
@@ -101,7 +98,7 @@ AP4_DrefAtom::WriteFields(AP4_ByteStream& stream)
// write the number of entries
result = stream.WriteUI32(m_Children.ItemCount());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// write the children
return m_Children.Apply(AP4_AtomListWriter(stream));
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.h
index 8a248bc93..092e959db 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4DrefAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - dref Atoms
+| AP4 - dref Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.cpp
index 2d8f4ff81..73a2c0920 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - elst Atoms
+| AP4 - elst Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -40,15 +40,15 @@ AP4_ElstAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version > 1) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version > 1) return NULL;
return new AP4_ElstAtom(size, version, flags, stream);
}
/*----------------------------------------------------------------------
| AP4_ElstAtom::AP4_ElstAtom
+---------------------------------------------------------------------*/
-AP4_ElstAtom::AP4_ElstAtom(AP4_UI32 size,
+AP4_ElstAtom::AP4_ElstAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -57,12 +57,10 @@ AP4_ElstAtom::AP4_ElstAtom(AP4_UI32 size,
AP4_UI32 entry_count;
stream.ReadUI32(entry_count);
m_Entries.EnsureCapacity(entry_count);
- for(AP4_UI32 i = 0; i < entry_count; i++)
- {
+ for (AP4_UI32 i=0; i<entry_count; i++) {
AP4_UI16 media_rate;
AP4_UI16 zero;
- if(version == 0)
- {
+ if (version == 0) {
AP4_UI32 segment_duration;
AP4_UI32 media_time;
stream.ReadUI32(segment_duration);
@@ -70,9 +68,7 @@ AP4_ElstAtom::AP4_ElstAtom(AP4_UI32 size,
stream.ReadUI16(media_rate);
stream.ReadUI16(zero);
m_Entries.Append(AP4_ElstEntry(segment_duration, media_time, media_rate));
- }
- else
- {
+ } else {
AP4_UI64 segment_duration;
AP4_UI64 media_time;
stream.ReadUI64(segment_duration);
@@ -91,29 +87,25 @@ AP4_Result
AP4_ElstAtom::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
+
result = stream.WriteUI32(m_Entries.ItemCount());
- if(AP4_FAILED(result)) return result;
- for(AP4_Ordinal i = 0; i < m_Entries.ItemCount(); i++)
- {
- if(m_Version == 0)
- {
+ if (AP4_FAILED(result)) return result;
+ for (AP4_Ordinal i=0; i<m_Entries.ItemCount(); i++) {
+ if (m_Version == 0) {
result = stream.WriteUI32((AP4_UI32)m_Entries[i].m_SegmentDuration);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32((AP4_UI32)m_Entries[i].m_MediaTime);
- if(AP4_FAILED(result)) return result;
- }
- else
- {
+ if (AP4_FAILED(result)) return result;
+ } else {
result = stream.WriteUI64(m_Entries[i].m_SegmentDuration);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI64(m_Entries[i].m_MediaTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
result = stream.WriteUI16(m_Entries[i].m_MediaRate);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI16(0);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return AP4_SUCCESS;
@@ -126,8 +118,7 @@ AP4_Result
AP4_ElstAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("entry count", m_Entries.ItemCount());
- for(AP4_Ordinal i = 0; i < m_Entries.ItemCount(); i++)
- {
+ for (AP4_Ordinal i=0; i<m_Entries.ItemCount(); i++) {
inspector.AddField("entry/segment duration", (AP4_UI32)m_Entries[i].m_SegmentDuration);
inspector.AddField("entry/media time", (AP4_SI32)m_Entries[i].m_MediaTime);
inspector.AddField("entry/media rate", (AP4_UI16)m_Entries[i].m_MediaRate);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.h
index 7c1c76670..d613bf6bd 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ElstAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - elst Atoms
+| AP4 - elst Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -44,13 +44,12 @@ class AP4_ByteStream;
/*----------------------------------------------------------------------
| AP4_ElstAtom
+---------------------------------------------------------------------*/
-class AP4_ElstEntry
-{
+class AP4_ElstEntry {
public:
AP4_ElstEntry(AP4_UI64 segment_duration = 0, AP4_SI64 media_time = 0, AP4_UI16 media_rate = 1) :
- m_SegmentDuration(segment_duration),
- m_MediaTime(media_time),
- m_MediaRate(media_rate) {}
+ m_SegmentDuration(segment_duration),
+ m_MediaTime(media_time),
+ m_MediaRate(media_rate) {}
AP4_UI64 m_SegmentDuration;
AP4_SI64 m_MediaTime;
@@ -66,12 +65,12 @@ public:
// methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
private:
// methods
- AP4_ElstAtom(AP4_UI32 size,
- AP4_UI32 version,
- AP4_UI32 flags,
+ AP4_ElstAtom(AP4_UI32 size,
+ AP4_UI32 version,
+ AP4_UI32 flags,
AP4_ByteStream& stream);
// members
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.cpp
index 04bff732d..065d6f513 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.cpp
@@ -46,7 +46,7 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_EsIdRefDescriptor)
| AP4_EsDescriptor::AP4_EsDescriptor
+---------------------------------------------------------------------*/
AP4_EsDescriptor::AP4_EsDescriptor(AP4_UI16 es_id) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_ES, 2, 2 + 1),
+ AP4_Descriptor(AP4_DESCRIPTOR_TAG_ES, 2, 2+1),
m_EsId(es_id),
m_OcrEsId(0),
m_Flags(0),
@@ -58,7 +58,7 @@ AP4_EsDescriptor::AP4_EsDescriptor(AP4_UI16 es_id) :
/*----------------------------------------------------------------------
| AP4_EsDescriptor::AP4_EsDescriptor
+---------------------------------------------------------------------*/
-AP4_EsDescriptor::AP4_EsDescriptor(AP4_ByteStream& stream,
+AP4_EsDescriptor::AP4_EsDescriptor(AP4_ByteStream& stream,
AP4_Size header_size,
AP4_Size payload_size) :
AP4_Descriptor(AP4_DESCRIPTOR_TAG_ES, header_size, payload_size)
@@ -70,25 +70,19 @@ AP4_EsDescriptor::AP4_EsDescriptor(AP4_ByteStream& stream,
stream.ReadUI16(m_EsId);
unsigned char bits;
stream.ReadUI08(bits);
- m_Flags = (bits >> 5) & 7;
- m_StreamPriority = bits & 0x1F;
- if(m_Flags & AP4_ES_DESCRIPTOR_FLAG_STREAM_DEPENDENCY)
- {
+ m_Flags = (bits>>5)&7;
+ m_StreamPriority = bits&0x1F;
+ if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_STREAM_DEPENDENCY) {
stream.ReadUI16(m_DependsOn);
- }
- else
- {
+ } else {
m_DependsOn = 0;
}
- if(m_Flags & AP4_ES_DESCRIPTOR_FLAG_URL)
- {
+ if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_URL) {
unsigned char url_length;
stream.ReadUI08(url_length);
- if(url_length)
- {
+ if (url_length) {
char* url = new char[url_length+1];
- if(url)
- {
+ if (url) {
stream.Read(url, url_length);
url[url_length] = '\0';
m_Url = url;
@@ -96,25 +90,21 @@ AP4_EsDescriptor::AP4_EsDescriptor(AP4_ByteStream& stream,
}
}
}
- if(m_Flags & AP4_ES_DESCRIPTOR_FLAG_URL)
- {
+ if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_URL) {
stream.ReadUI16(m_OcrEsId);
- }
- else
- {
+ } else {
m_OcrEsId = 0;
}
// read other descriptors
AP4_Position offset;
stream.Tell(offset);
- AP4_SubStream* substream = new AP4_SubStream(stream, offset,
- payload_size - AP4_Size(offset - start));
+ AP4_SubStream* substream = new AP4_SubStream(stream, offset,
+ payload_size-AP4_Size(offset-start));
AP4_Descriptor* descriptor = NULL;
- while(AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
- descriptor)
- == AP4_SUCCESS)
- {
+ while (AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
+ descriptor)
+ == AP4_SUCCESS) {
m_SubDescriptors.Add(descriptor);
}
substream->Release();
@@ -138,32 +128,29 @@ AP4_EsDescriptor::WriteFields(AP4_ByteStream& stream)
// es id
result = stream.WriteUI16(m_EsId);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// flags and other bits
- AP4_UI08 bits = m_StreamPriority | (AP4_UI08)(m_Flags << 5);
+ AP4_UI08 bits = m_StreamPriority | (AP4_UI08)(m_Flags<<5);
result = stream.WriteUI08(bits);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// optional fields
- if(m_Flags & AP4_ES_DESCRIPTOR_FLAG_STREAM_DEPENDENCY)
- {
+ if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_STREAM_DEPENDENCY) {
result = stream.WriteUI16(m_DependsOn);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_ES_DESCRIPTOR_FLAG_URL)
- {
+ if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_URL) {
result = stream.WriteUI08((AP4_UI08)m_Url.GetLength());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteString(m_Url.GetChars());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI08(0);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_ES_DESCRIPTOR_FLAG_OCR_STREAM)
- {
+ if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_OCR_STREAM) {
result = stream.WriteUI16(m_OcrEsId);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// write the sub descriptors
@@ -179,8 +166,8 @@ AP4_Result
AP4_EsDescriptor::Inspect(AP4_AtomInspector& inspector)
{
char info[64];
- AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(), m_PayloadSize);
+ AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
+ GetHeaderSize(),m_PayloadSize);
inspector.StartElement("[ESDescriptor]", info);
inspector.AddField("es_id", m_EsId);
inspector.AddField("stream_priority", m_StreamPriority);
@@ -213,17 +200,14 @@ AP4_EsDescriptor::GetDecoderConfigDescriptor() const
{
// find the decoder config descriptor
AP4_Descriptor* descriptor = NULL;
- AP4_Result result =
+ AP4_Result result =
m_SubDescriptors.Find(AP4_DescriptorFinder(AP4_DESCRIPTOR_TAG_DECODER_CONFIG),
descriptor);
-
+
// return it
- if(AP4_SUCCEEDED(result))
- {
+ if (AP4_SUCCEEDED(result)) {
return AP4_DYNAMIC_CAST(AP4_DecoderConfigDescriptor, descriptor);
- }
- else
- {
+ } else {
return NULL;
}
}
@@ -240,9 +224,9 @@ AP4_EsIdIncDescriptor::AP4_EsIdIncDescriptor(AP4_UI32 track_id) :
/*----------------------------------------------------------------------
| AP4_EsIdIncDescriptor::AP4_EsIdIncDescriptor
+---------------------------------------------------------------------*/
-AP4_EsIdIncDescriptor::AP4_EsIdIncDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
- AP4_Size payload_size) :
+AP4_EsIdIncDescriptor::AP4_EsIdIncDescriptor(AP4_ByteStream& stream,
+ AP4_Size header_size,
+ AP4_Size payload_size) :
AP4_Descriptor(AP4_DESCRIPTOR_TAG_ES_ID_INC, header_size, payload_size)
{
// read the track id
@@ -266,12 +250,12 @@ AP4_Result
AP4_EsIdIncDescriptor::Inspect(AP4_AtomInspector& inspector)
{
char info[64];
- AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(), m_PayloadSize);
+ AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
+ GetHeaderSize(),m_PayloadSize);
inspector.StartElement("[ES_ID_Inc]", info);
inspector.AddField("track_id", m_TrackId);
inspector.EndElement();
-
+
return AP4_SUCCESS;
}
@@ -287,9 +271,9 @@ AP4_EsIdRefDescriptor::AP4_EsIdRefDescriptor(AP4_UI16 ref_index) :
/*----------------------------------------------------------------------
| AP4_EsIdRefDescriptor::AP4_EsIdRefDescriptor
+---------------------------------------------------------------------*/
-AP4_EsIdRefDescriptor::AP4_EsIdRefDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
- AP4_Size payload_size) :
+AP4_EsIdRefDescriptor::AP4_EsIdRefDescriptor(AP4_ByteStream& stream,
+ AP4_Size header_size,
+ AP4_Size payload_size) :
AP4_Descriptor(AP4_DESCRIPTOR_TAG_ES_ID_REF, header_size, payload_size)
{
// read the ref index
@@ -313,11 +297,11 @@ AP4_Result
AP4_EsIdRefDescriptor::Inspect(AP4_AtomInspector& inspector)
{
char info[64];
- AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(), m_PayloadSize);
+ AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
+ GetHeaderSize(),m_PayloadSize);
inspector.StartElement("[ES_ID_Ref]", info);
inspector.AddField("ref_index", m_RefIndex);
inspector.EndElement();
-
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.h
index 584d79a60..d971e7e05 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsDescriptor.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - ES Descriptor
+| AP4 - ES Descriptor
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -58,21 +58,21 @@ const int AP4_ES_DESCRIPTOR_FLAG_OCR_STREAM = 4;
+---------------------------------------------------------------------*/
class AP4_EsDescriptor : public AP4_Descriptor
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_EsDescriptor, AP4_Descriptor)
// methods
AP4_EsDescriptor(AP4_UI16 es_id);
- AP4_EsDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
+ AP4_EsDescriptor(AP4_ByteStream& stream,
+ AP4_Size header_size,
AP4_Size payload_size);
~AP4_EsDescriptor();
virtual AP4_Result AddSubDescriptor(AP4_Descriptor* descriptor);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
- virtual const AP4_DecoderConfigDescriptor* GetDecoderConfigDescriptor() const;
+ virtual const AP4_DecoderConfigDescriptor* GetDecoderConfigDescriptor() const;
-private:
+ private:
// members
unsigned short m_EsId;
unsigned short m_OcrEsId;
@@ -88,24 +88,21 @@ private:
+---------------------------------------------------------------------*/
class AP4_EsIdIncDescriptor : public AP4_Descriptor
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_EsIdIncDescriptor, AP4_Descriptor)
// methods
AP4_EsIdIncDescriptor(AP4_UI32 track_id);
- AP4_EsIdIncDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
+ AP4_EsIdIncDescriptor(AP4_ByteStream& stream,
+ AP4_Size header_size,
AP4_Size payload_size);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
// accessors
- AP4_UI32 GetTrackId() const
- {
- return m_TrackId;
- }
-
-private:
+ AP4_UI32 GetTrackId() const { return m_TrackId; }
+
+ private:
// members
AP4_UI32 m_TrackId;
};
@@ -115,24 +112,21 @@ private:
+---------------------------------------------------------------------*/
class AP4_EsIdRefDescriptor : public AP4_Descriptor
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_EsIdRefDescriptor, AP4_Descriptor)
// methods
AP4_EsIdRefDescriptor(AP4_UI16 ref_index);
- AP4_EsIdRefDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
+ AP4_EsIdRefDescriptor(AP4_ByteStream& stream,
+ AP4_Size header_size,
AP4_Size payload_size);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
// accessors
- AP4_UI16 GetRefIndex() const
- {
- return m_RefIndex;
- }
-
-private:
+ AP4_UI16 GetRefIndex() const { return m_RefIndex; }
+
+ private:
// members
AP4_UI16 m_RefIndex;
};
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.cpp
index c2937eef6..b03e73a91 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - esds Atoms
+| AP4 - esds Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_EsdsAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_EsdsAtom(size, version, flags, stream);
}
@@ -58,13 +58,13 @@ AP4_EsdsAtom::AP4_EsdsAtom(AP4_EsDescriptor* descriptor) :
AP4_Atom(AP4_ATOM_TYPE_ESDS, AP4_FULL_ATOM_HEADER_SIZE, 0, 0),
m_EsDescriptor(descriptor)
{
- if(m_EsDescriptor) m_Size32 += m_EsDescriptor->GetSize();
+ if (m_EsDescriptor) m_Size32 += m_EsDescriptor->GetSize();
}
/*----------------------------------------------------------------------
| AP4_EsdsAtom::AP4_EsdsAtom
+---------------------------------------------------------------------*/
-AP4_EsdsAtom::AP4_EsdsAtom(AP4_UI32 size,
+AP4_EsdsAtom::AP4_EsdsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -72,13 +72,10 @@ AP4_EsdsAtom::AP4_EsdsAtom(AP4_UI32 size,
{
// read descriptor
AP4_Descriptor* descriptor = NULL;
- if(AP4_DescriptorFactory::CreateDescriptorFromStream(stream, descriptor)
- == AP4_SUCCESS)
- {
+ if (AP4_DescriptorFactory::CreateDescriptorFromStream(stream, descriptor)
+ == AP4_SUCCESS) {
m_EsDescriptor = AP4_DYNAMIC_CAST(AP4_EsDescriptor, descriptor);
- }
- else
- {
+ } else {
m_EsDescriptor = NULL;
}
}
@@ -98,7 +95,7 @@ AP4_Result
AP4_EsdsAtom::WriteFields(AP4_ByteStream& stream)
{
// write the es descriptor
- if(m_EsDescriptor) return m_EsDescriptor->Write(stream);
+ if (m_EsDescriptor) return m_EsDescriptor->Write(stream);
return AP4_SUCCESS;
}
@@ -110,8 +107,7 @@ AP4_Result
AP4_EsdsAtom::InspectFields(AP4_AtomInspector& inspector)
{
// inspect descriptor
- if(m_EsDescriptor)
- {
+ if (m_EsDescriptor) {
m_EsDescriptor->Inspect(inspector);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.h
index 2eeff20a8..962f9e2c3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4EsdsAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - esds Atoms
+| AP4 - esds Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -54,17 +54,14 @@ public:
// methods
AP4_EsdsAtom(AP4_EsDescriptor* descriptor);
- ~AP4_EsdsAtom();
+ ~AP4_EsdsAtom();
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- const AP4_EsDescriptor* GetEsDescriptor() const
- {
- return m_EsDescriptor;
- }
+ const AP4_EsDescriptor* GetEsDescriptor() const { return m_EsDescriptor; }
private:
// methods
- AP4_EsdsAtom(AP4_UI32 size,
+ AP4_EsdsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.cpp
index d6a5d1373..a0fa39601 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.cpp
@@ -42,23 +42,23 @@ AP4_Expandable::MinHeaderSize(AP4_Size payload_size)
{
// compute how many bytes are needed to encode the payload size
// plus tag
- return 2 + (payload_size / 128);
+ return 2+(payload_size/128);
}
/*----------------------------------------------------------------------
| AP4_Expandable::AP4_Expandable
+---------------------------------------------------------------------*/
AP4_Expandable::AP4_Expandable(AP4_UI32 class_id,
- ClassIdSize class_id_size,
- AP4_Size header_size,
+ ClassIdSize class_id_size,
+ AP4_Size header_size,
AP4_Size payload_size) :
m_ClassId(class_id),
m_ClassIdSize(class_id_size),
m_HeaderSize(header_size),
m_PayloadSize(payload_size)
{
- AP4_ASSERT(header_size >= 1 + 1);
- AP4_ASSERT(header_size <= 1 + 4);
+ AP4_ASSERT(header_size >= 1+1);
+ AP4_ASSERT(header_size <= 1+4);
}
/*----------------------------------------------------------------------
@@ -70,38 +70,36 @@ AP4_Expandable::Write(AP4_ByteStream& stream)
AP4_Result result;
// write the class id
- switch(m_ClassIdSize)
- {
- case CLASS_ID_SIZE_08:
- result = stream.WriteUI08((AP4_UI08)m_ClassId);
- if(AP4_FAILED(result)) return result;
- break;
-
- default:
- return AP4_ERROR_INTERNAL;
+ switch (m_ClassIdSize) {
+ case CLASS_ID_SIZE_08:
+ result = stream.WriteUI08((AP4_UI08)m_ClassId);
+ if (AP4_FAILED(result)) return result;
+ break;
+
+ default:
+ return AP4_ERROR_INTERNAL;
}
-
+
// write the size
- AP4_ASSERT(m_HeaderSize - 1 <= 8);
+ AP4_ASSERT(m_HeaderSize-1 <= 8);
AP4_ASSERT(m_HeaderSize >= 2);
unsigned int size = m_PayloadSize;
unsigned char bytes[8];
// last bytes of the encoded size
- bytes[m_HeaderSize-2] = size & 0x7F;
+ bytes[m_HeaderSize-2] = size&0x7F;
// leading bytes of the encoded size
- for(int i = m_HeaderSize - 3; i >= 0; i--)
- {
+ for (int i=m_HeaderSize-3; i>=0; i--) {
// move to the next 7 bits
size >>= 7;
// output a byte with a top bit marker
- bytes[i] = (size & 0x7F) | 0x80;
+ bytes[i] = (size&0x7F) | 0x80;
}
- result = stream.Write(bytes, m_HeaderSize - 1);
- if(AP4_FAILED(result)) return result;
+ result = stream.Write(bytes, m_HeaderSize-1);
+ if (AP4_FAILED(result)) return result;
// write the fields
WriteFields(stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.h
index beba263f0..63949eeb5 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Expandable.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - Expandable base class
+| AP4 - Expandable base class
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,39 +46,29 @@ class AP4_AtomInspector;
+---------------------------------------------------------------------*/
class AP4_Expandable
{
-public:
+ public:
// types
- enum ClassIdSize
- {
+ enum ClassIdSize {
CLASS_ID_SIZE_08
};
-
+
// class methods
static AP4_Size MinHeaderSize(AP4_Size payload_size);
// methods
- AP4_Expandable(AP4_UI32 class_id,
- ClassIdSize class_id_size,
- AP4_Size header_size,
+ AP4_Expandable(AP4_UI32 class_id,
+ ClassIdSize class_id_size,
+ AP4_Size header_size,
AP4_Size payload_size);
virtual ~AP4_Expandable() {}
- AP4_UI32 GetClassId()
- {
- return m_ClassId;
- }
- AP4_Size GetSize()
- {
- return m_PayloadSize + m_HeaderSize;
- }
- AP4_Size GetHeaderSize()
- {
- return m_HeaderSize;
- }
+ AP4_UI32 GetClassId() { return m_ClassId; }
+ AP4_Size GetSize() { return m_PayloadSize+m_HeaderSize; }
+ AP4_Size GetHeaderSize() { return m_HeaderSize; }
virtual AP4_Result Write(AP4_ByteStream& stream);
virtual AP4_Result WriteFields(AP4_ByteStream& stream) = 0;
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
-protected:
+ protected:
// members
AP4_UI32 m_ClassId;
ClassIdSize m_ClassIdSize;
@@ -89,17 +79,17 @@ protected:
/*----------------------------------------------------------------------
| AP4_UnknownExpandable
+---------------------------------------------------------------------*/
-class AP4_UnknownExpandable : public AP4_Expandable
+class AP4_UnknownExpandable : public AP4_Expandable
{
public:
// methods
- AP4_UnknownExpandable(AP4_ByteStream& stream,
+ AP4_UnknownExpandable(AP4_ByteStream& stream,
AP4_UI32 class_id,
ClassIdSize class_id_size,
AP4_Size header_size,
AP4_Size payload_size);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
private:
// members
AP4_DataBuffer m_Data;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.cpp
index d8bfe3ddc..baedd893a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.cpp
@@ -53,7 +53,7 @@ AP4_File::AP4_File(AP4_Movie* movie) :
/*----------------------------------------------------------------------
| AP4_File::AP4_File
+---------------------------------------------------------------------*/
-AP4_File::AP4_File(AP4_ByteStream& stream,
+AP4_File::AP4_File(AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory,
bool moov_only) :
m_Movie(NULL),
@@ -65,30 +65,28 @@ AP4_File::AP4_File(AP4_ByteStream& stream,
AP4_Atom* atom;
AP4_Position stream_position;
bool keep_parsing = true;
- while(keep_parsing &&
- AP4_SUCCEEDED(stream.Tell(stream_position)) &&
- AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream, atom)))
- {
+ while (keep_parsing &&
+ AP4_SUCCEEDED(stream.Tell(stream_position)) &&
+ AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream, atom))) {
AddChild(atom);
- switch(atom->GetType())
- {
- case AP4_ATOM_TYPE_MOOV:
- m_Movie = new AP4_Movie(AP4_DYNAMIC_CAST(AP4_MoovAtom, atom), stream, false);
- if(moov_only) keep_parsing = false;
- break;
+ switch (atom->GetType()) {
+ case AP4_ATOM_TYPE_MOOV:
+ m_Movie = new AP4_Movie(AP4_DYNAMIC_CAST(AP4_MoovAtom, atom), stream, false);
+ if (moov_only) keep_parsing = false;
+ break;
- case AP4_ATOM_TYPE_FTYP:
- m_FileType = AP4_DYNAMIC_CAST(AP4_FtypAtom, atom);
- break;
+ case AP4_ATOM_TYPE_FTYP:
+ m_FileType = AP4_DYNAMIC_CAST(AP4_FtypAtom, atom);
+ break;
- case AP4_ATOM_TYPE_MDAT:
- // see if we are before the moov atom
- if(m_Movie == NULL) m_MoovIsBeforeMdat = false;
- break;
+ case AP4_ATOM_TYPE_MDAT:
+ // see if we are before the moov atom
+ if (m_Movie == NULL) m_MoovIsBeforeMdat = false;
+ break;
}
}
}
-
+
/*----------------------------------------------------------------------
| AP4_File::~AP4_File
+---------------------------------------------------------------------*/
@@ -105,7 +103,7 @@ AP4_Result
AP4_File::Inspect(AP4_AtomInspector& inspector)
{
// dump the moov atom first
- if(m_Movie) m_Movie->Inspect(inspector);
+ if (m_Movie) m_Movie->Inspect(inspector);
// dump the other atoms
m_Children.Apply(AP4_AtomListInspector(inspector));
@@ -122,17 +120,16 @@ AP4_File::SetFileType(AP4_UI32 major_brand,
AP4_UI32* compatible_brands,
AP4_Cardinal compatible_brand_count)
{
- if(m_FileType)
- {
+ if (m_FileType) {
RemoveChild(m_FileType);
delete m_FileType;
}
- m_FileType = new AP4_FtypAtom(major_brand,
+ m_FileType = new AP4_FtypAtom(major_brand,
minor_version,
compatible_brands,
compatible_brand_count);
AddChild(m_FileType, 0);
-
+
return AP4_SUCCESS;
}
@@ -142,8 +139,7 @@ AP4_File::SetFileType(AP4_UI32 major_brand,
const AP4_MetaData*
AP4_File::GetMetaData()
{
- if(m_MetaData == NULL)
- {
+ if (m_MetaData == NULL) {
m_MetaData = new AP4_MetaData(this);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.h
index 94364e968..180c31819 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4File.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - File
+| AP4 - File
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -48,20 +48,20 @@ class AP4_MetaData;
/*----------------------------------------------------------------------
| file type/brands
+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_FILE_BRAND_QT__ = AP4_ATOM_TYPE('q', 't', ' ', ' ');
-const AP4_UI32 AP4_FILE_BRAND_ISOM = AP4_ATOM_TYPE('i', 's', 'o', 'm');
-const AP4_UI32 AP4_FILE_BRAND_MP41 = AP4_ATOM_TYPE('m', 'p', '4', '1');
-const AP4_UI32 AP4_FILE_BRAND_MP42 = AP4_ATOM_TYPE('m', 'p', '4', '2');
-const AP4_UI32 AP4_FILE_BRAND_3GP1 = AP4_ATOM_TYPE('3', 'g', 'p', '1');
-const AP4_UI32 AP4_FILE_BRAND_3GP2 = AP4_ATOM_TYPE('3', 'g', 'p', '2');
-const AP4_UI32 AP4_FILE_BRAND_3GP3 = AP4_ATOM_TYPE('3', 'g', 'p', '3');
-const AP4_UI32 AP4_FILE_BRAND_3GP4 = AP4_ATOM_TYPE('3', 'g', 'p', '4');
-const AP4_UI32 AP4_FILE_BRAND_3GP5 = AP4_ATOM_TYPE('3', 'g', 'p', '5');
-const AP4_UI32 AP4_FILE_BRAND_3G2A = AP4_ATOM_TYPE('3', 'g', '2', 'a');
-const AP4_UI32 AP4_FILE_BRAND_MMP4 = AP4_ATOM_TYPE('m', 'm', 'p', '4');
-const AP4_UI32 AP4_FILE_BRAND_M4A_ = AP4_ATOM_TYPE('M', '4', 'A', ' ');
-const AP4_UI32 AP4_FILE_BRAND_M4P_ = AP4_ATOM_TYPE('M', '4', 'P', ' ');
-const AP4_UI32 AP4_FILE_BRAND_MJP2 = AP4_ATOM_TYPE('m', 'j', 'p', '2');
+const AP4_UI32 AP4_FILE_BRAND_QT__ = AP4_ATOM_TYPE('q','t',' ',' ');
+const AP4_UI32 AP4_FILE_BRAND_ISOM = AP4_ATOM_TYPE('i','s','o','m');
+const AP4_UI32 AP4_FILE_BRAND_MP41 = AP4_ATOM_TYPE('m','p','4','1');
+const AP4_UI32 AP4_FILE_BRAND_MP42 = AP4_ATOM_TYPE('m','p','4','2');
+const AP4_UI32 AP4_FILE_BRAND_3GP1 = AP4_ATOM_TYPE('3','g','p','1');
+const AP4_UI32 AP4_FILE_BRAND_3GP2 = AP4_ATOM_TYPE('3','g','p','2');
+const AP4_UI32 AP4_FILE_BRAND_3GP3 = AP4_ATOM_TYPE('3','g','p','3');
+const AP4_UI32 AP4_FILE_BRAND_3GP4 = AP4_ATOM_TYPE('3','g','p','4');
+const AP4_UI32 AP4_FILE_BRAND_3GP5 = AP4_ATOM_TYPE('3','g','p','5');
+const AP4_UI32 AP4_FILE_BRAND_3G2A = AP4_ATOM_TYPE('3','g','2','a');
+const AP4_UI32 AP4_FILE_BRAND_MMP4 = AP4_ATOM_TYPE('m','m','p','4');
+const AP4_UI32 AP4_FILE_BRAND_M4A_ = AP4_ATOM_TYPE('M','4','A',' ');
+const AP4_UI32 AP4_FILE_BRAND_M4P_ = AP4_ATOM_TYPE('M','4','P',' ');
+const AP4_UI32 AP4_FILE_BRAND_MJP2 = AP4_ATOM_TYPE('m','j','p','2');
/*----------------------------------------------------------------------
| AP4_File
@@ -71,8 +71,7 @@ const AP4_UI32 AP4_FILE_BRAND_MJP2 = AP4_ATOM_TYPE('m', 'j', 'p', '2');
* The AP4_File object is the top level object for MP4 Files.
*/
-class AP4_File : public AP4_AtomParent
-{
+class AP4_File : public AP4_AtomParent {
public:
// constructors and destructor
/**
@@ -87,64 +86,52 @@ public:
* @param factory the atom factory that will be used to parse the stream
* @param moov_only indicates whether parsing of the atoms should stop
* when the moov atom is found or if all atoms should be parsed until the
- * end of the file.
+ * end of the file.
*/
- AP4_File(AP4_ByteStream& stream,
+ AP4_File(AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory = AP4_DefaultAtomFactory::Instance,
bool moov_only = false);
/**
- * Destroys the AP4_File instance
+ * Destroys the AP4_File instance
*/
virtual ~AP4_File();
-
+
/**
* Get the top level atoms of the file
*/
- AP4_List<AP4_Atom>& GetTopLevelAtoms()
- {
- return m_Children;
- }
+ AP4_List<AP4_Atom>& GetTopLevelAtoms() { return m_Children; }
- /**
+ /**
* Get the AP4_Movie object of this file
*/
- AP4_Movie* GetMovie()
- {
- return m_Movie;
- }
-
+ AP4_Movie* GetMovie() { return m_Movie; }
+
/**
* Get the file type atom of this file
*/
- AP4_FtypAtom* GetFileType()
- {
- return m_FileType;
- }
+ AP4_FtypAtom* GetFileType() { return m_FileType; }
/**
- * Set the file type. Will internally create an AP4_Ftyp atom
- * and attach it to the file
+ * Set the file type. Will internally create an AP4_Ftyp atom
+ * and attach it to the file
*/
AP4_Result SetFileType(AP4_UI32 major_brand,
AP4_UI32 minor_version,
AP4_UI32* compatible_brands = NULL,
AP4_Cardinal compatible_brand_count = 0);
- /**
+ /**
* Ask whether the moov atom appears before the first mdat atom
*/
- bool IsMoovBeforeMdat() const
- {
- return m_MoovIsBeforeMdat;
- }
-
- /**
+ bool IsMoovBeforeMdat() const { return m_MoovIsBeforeMdat; }
+
+ /**
* Get the file's metadata description
*/
const AP4_MetaData* GetMetaData();
-
+
/**
* Inspect the content of the file with an AP4_AtomInspector
*/
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileByteStream.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileByteStream.h
index 4a43e008c..f7d82706e 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileByteStream.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileByteStream.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - FileByteStream
+| AP4 - FileByteStream
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -43,8 +43,7 @@ class AP4_FileByteStream: public AP4_ByteStream
{
public:
// types
- typedef enum
- {
+ typedef enum {
STREAM_MODE_READ = 0,
STREAM_MODE_WRITE = 1,
STREAM_MODE_READ_WRITE = 2
@@ -61,10 +60,10 @@ public:
* it cannot
*/
static AP4_Result Create(const char* name, Mode mode, AP4_ByteStream*& stream);
-
+
// constructors
AP4_FileByteStream(AP4_ByteStream* delegate) : m_Delegate(delegate) {}
-
+
#if !defined(AP4_CONFIG_NO_EXCEPTIONS)
/**
* @deprecated
@@ -73,49 +72,28 @@ public:
#endif
// AP4_ByteStream methods
- AP4_Result ReadPartial(void* buffer,
- AP4_Size bytesToRead,
- AP4_Size& bytesRead)
- {
+ AP4_Result ReadPartial(void* buffer,
+ AP4_Size bytesToRead,
+ AP4_Size& bytesRead) {
return m_Delegate->ReadPartial(buffer, bytesToRead, bytesRead);
}
- AP4_Result WritePartial(const void* buffer,
- AP4_Size bytesToWrite,
- AP4_Size& bytesWritten)
- {
+ AP4_Result WritePartial(const void* buffer,
+ AP4_Size bytesToWrite,
+ AP4_Size& bytesWritten) {
return m_Delegate->WritePartial(buffer, bytesToWrite, bytesWritten);
}
- AP4_Result Seek(AP4_Position position)
- {
- return m_Delegate->Seek(position);
- }
- AP4_Result Tell(AP4_Position& position)
- {
- return m_Delegate->Tell(position);
- }
- AP4_Result GetSize(AP4_LargeSize& size)
- {
- return m_Delegate->GetSize(size);
- }
- AP4_Result Flush()
- {
- return m_Delegate->Flush();
- }
+ AP4_Result Seek(AP4_Position position) { return m_Delegate->Seek(position); }
+ AP4_Result Tell(AP4_Position& position) { return m_Delegate->Tell(position); }
+ AP4_Result GetSize(AP4_LargeSize& size) { return m_Delegate->GetSize(size); }
+ AP4_Result Flush() { return m_Delegate->Flush(); }
// AP4_Referenceable methods
- void AddReference()
- {
- m_Delegate->AddReference();
- }
- void Release()
- {
- m_Delegate->Release();
- }
+ void AddReference() { m_Delegate->AddReference(); }
+ void Release() { m_Delegate->Release(); }
protected:
// methods
- virtual ~AP4_FileByteStream()
- {
+ virtual ~AP4_FileByteStream() {
delete m_Delegate;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.cpp
index fdb90f82a..626763539 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.cpp
@@ -42,10 +42,9 @@ AP4_Result
AP4_FileCopier::Write(AP4_File& file, AP4_ByteStream& stream)
{
// write the top-level atoms
- for(AP4_List<AP4_Atom>::Item* item = file.GetTopLevelAtoms().FirstItem();
- item;
- item = item->GetNext())
- {
+ for (AP4_List<AP4_Atom>::Item* item = file.GetTopLevelAtoms().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
atom->Write(stream);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.h
index d6be4c3ff..320177eaf 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileCopier.h
@@ -43,8 +43,7 @@ class AP4_File;
/*----------------------------------------------------------------------
| AP4_FileCopier
+---------------------------------------------------------------------*/
-class AP4_FileCopier
-{
+class AP4_FileCopier {
public:
// class methods
static AP4_Result Write(AP4_File& file, AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.cpp
index 48ce0bcc1..c7e8090cc 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.cpp
@@ -50,90 +50,84 @@ AP4_FileWriter::Write(AP4_File& file, AP4_ByteStream& stream, Interleaving /* in
AP4_FtypAtom* file_type = file.GetFileType();
// write the ftyp atom (always first)
- if(file_type) file_type->Write(stream);
+ if (file_type) file_type->Write(stream);
// write the top-level atoms, except for ftyp, moov and mdat
- for(AP4_List<AP4_Atom>::Item* atom_item = file.GetChildren().FirstItem();
- atom_item;
- atom_item = atom_item->GetNext())
- {
+ for (AP4_List<AP4_Atom>::Item* atom_item = file.GetChildren().FirstItem();
+ atom_item;
+ atom_item = atom_item->GetNext()) {
AP4_Atom* atom = atom_item->GetData();
- if(atom->GetType() != AP4_ATOM_TYPE_MDAT &&
- atom->GetType() != AP4_ATOM_TYPE_FTYP &&
- atom->GetType() != AP4_ATOM_TYPE_MOOV)
- {
+ if (atom->GetType() != AP4_ATOM_TYPE_MDAT &&
+ atom->GetType() != AP4_ATOM_TYPE_FTYP &&
+ atom->GetType() != AP4_ATOM_TYPE_MOOV) {
atom->Write(stream);
}
}
-
+
// get the movie object (and stop if there isn't any)
AP4_Movie* movie = file.GetMovie();
- if(movie == NULL) return AP4_SUCCESS;
+ if (movie == NULL) return AP4_SUCCESS;
// see how much we've written so far
AP4_Position position;
stream.Tell(position);
-
+
// backup and recompute all the chunk offsets
- unsigned int t = 0;
+ unsigned int t=0;
AP4_Result result = AP4_SUCCESS;
AP4_UI64 mdat_size = AP4_ATOM_HEADER_SIZE;
- AP4_UI64 mdat_position = position + movie->GetMoovAtom()->GetSize();
+ AP4_UI64 mdat_position = position+movie->GetMoovAtom()->GetSize();
AP4_Array<AP4_Array<AP4_UI64>*> trak_chunk_offsets_backup;
AP4_Array<AP4_UI64> chunk_offsets;
- for(AP4_List<AP4_Track>::Item* track_item = movie->GetTracks().FirstItem();
- track_item;
- track_item = track_item->GetNext())
- {
+ for (AP4_List<AP4_Track>::Item* track_item = movie->GetTracks().FirstItem();
+ track_item;
+ track_item = track_item->GetNext()) {
AP4_Track* track = track_item->GetData();
AP4_TrakAtom* trak = track->GetTrakAtom();
-
+
// backup the chunk offsets
AP4_Array<AP4_UI64>* chunk_offsets_backup = new AP4_Array<AP4_UI64>();
trak_chunk_offsets_backup.Append(chunk_offsets_backup);
result = trak->GetChunkOffsets(*chunk_offsets_backup);
- if(AP4_FAILED(result)) goto end;
+ if (AP4_FAILED(result)) goto end;
// allocate space for the new chunk offsets
chunk_offsets.SetItemCount(chunk_offsets_backup->ItemCount());
-
+
// compute the new chunk offsets
AP4_Cardinal sample_count = track->GetSampleCount();
AP4_SampleTable* sample_table = track->GetSampleTable();
AP4_Sample sample;
- for(AP4_Ordinal i = 0; i < sample_count; i++)
- {
+ for (AP4_Ordinal i=0; i<sample_count; i++) {
AP4_Ordinal chunk_index = 0;
AP4_Ordinal position_in_chunk = 0;
sample_table->GetSampleChunkPosition(i, chunk_index, position_in_chunk);
sample_table->GetSample(i, sample);
- if(position_in_chunk == 0)
- {
+ if (position_in_chunk == 0) {
// this sample is the first sample in a chunk, so this is the start of a chunk
- if(chunk_index >= chunk_offsets.ItemCount()) return AP4_ERROR_INTERNAL;
- chunk_offsets[chunk_index] = mdat_position + mdat_size;
+ if (chunk_index >= chunk_offsets.ItemCount()) return AP4_ERROR_INTERNAL;
+ chunk_offsets[chunk_index] = mdat_position+mdat_size;
}
mdat_size += sample.GetSize();
- }
+ }
result = trak->SetChunkOffsets(chunk_offsets);
}
-
+
// write the moov atom
movie->GetMoovAtom()->Write(stream);
-
+
// create and write the media data (mdat)
// FIXME: this only supports 32-bit mdat size
stream.WriteUI32((AP4_UI32)mdat_size);
stream.WriteUI32(AP4_ATOM_TYPE_MDAT);
-
+
// write all tracks and restore the chunk offsets to their backed-up values
- for(AP4_List<AP4_Track>::Item* track_item = movie->GetTracks().FirstItem();
- track_item;
- track_item = track_item->GetNext(), ++t)
- {
+ for (AP4_List<AP4_Track>::Item* track_item = movie->GetTracks().FirstItem();
+ track_item;
+ track_item = track_item->GetNext(), ++t) {
AP4_Track* track = track_item->GetData();
AP4_TrakAtom* trak = track->GetTrakAtom();
-
+
// restore the backed-up chunk offsets
result = trak->SetChunkOffsets(*trak_chunk_offsets_backup[t]);
@@ -141,18 +135,16 @@ AP4_FileWriter::Write(AP4_File& file, AP4_ByteStream& stream, Interleaving /* in
AP4_Cardinal sample_count = track->GetSampleCount();
AP4_Sample sample;
AP4_DataBuffer sample_data;
- for(AP4_Ordinal i = 0; i < sample_count; i++)
- {
+ for (AP4_Ordinal i=0; i<sample_count; i++) {
track->ReadSample(i, sample, sample_data);
stream.Write(sample_data.GetData(), sample_data.GetDataSize());
}
}
end:
- for(unsigned int i = 0; i < trak_chunk_offsets_backup.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<trak_chunk_offsets_backup.ItemCount(); i++) {
delete trak_chunk_offsets_backup[i];
}
-
+
return result;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.h
index d5d34dd20..4c5c75391 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FileWriter.h
@@ -43,20 +43,18 @@ class AP4_File;
/*----------------------------------------------------------------------
| AP4_FileWriter
+---------------------------------------------------------------------*/
-class AP4_FileWriter
-{
+class AP4_FileWriter {
public:
// types
- typedef enum
- {
+ typedef enum {
INTERLEAVING_SEQUENTIAL
} Interleaving;
-
+
// class methods
- static AP4_Result Write(AP4_File& file,
- AP4_ByteStream& stream,
+ static AP4_Result Write(AP4_File& file,
+ AP4_ByteStream& stream,
Interleaving interleaving = INTERLEAVING_SEQUENTIAL);
-
+
private:
// don't instantiate this class
AP4_FileWriter() {}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.cpp
index b77e00bf7..ce862f388 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.cpp
@@ -41,50 +41,46 @@
/*----------------------------------------------------------------------
| AP4_FragmentSampleTable::AP4_FragmentSampleTable
+---------------------------------------------------------------------*/
-AP4_FragmentSampleTable::AP4_FragmentSampleTable(AP4_ContainerAtom* traf,
- AP4_TrexAtom* trex,
- AP4_ByteStream* sample_stream,
- AP4_Position moof_offset,
- AP4_Position mdat_payload_offset,
- AP4_UI64 dts_origin)
+AP4_FragmentSampleTable::AP4_FragmentSampleTable(AP4_ContainerAtom* traf,
+ AP4_TrexAtom* trex,
+ AP4_ByteStream* sample_stream,
+ AP4_Position moof_offset,
+ AP4_Position mdat_payload_offset,
+ AP4_UI64 dts_origin)
{
AP4_TfhdAtom* tfhd = AP4_DYNAMIC_CAST(AP4_TfhdAtom, traf->GetChild(AP4_ATOM_TYPE_TFHD));
- if(tfhd == NULL) return;
-
+ if (tfhd == NULL) return;
+
// count all the samples and reserve space for them
unsigned int sample_count = 0;
- for(AP4_List<AP4_Atom>::Item* item = traf->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
+ for (AP4_List<AP4_Atom>::Item* item = traf->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
- if(atom->GetType() == AP4_ATOM_TYPE_TRUN)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_TRUN) {
AP4_TrunAtom* trun = AP4_DYNAMIC_CAST(AP4_TrunAtom, atom);
sample_count += trun->GetEntries().ItemCount();
}
- }
+ }
m_Samples.EnsureCapacity(sample_count);
-
+
// process all the trun atoms
- for(AP4_List<AP4_Atom>::Item* item = traf->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
+ for (AP4_List<AP4_Atom>::Item* item = traf->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
- if(atom->GetType() == AP4_ATOM_TYPE_TRUN)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_TRUN) {
AP4_TrunAtom* trun = AP4_DYNAMIC_CAST(AP4_TrunAtom, atom);
- AP4_Result result = AddTrun(trun,
- tfhd,
- trex,
- sample_stream,
+ AP4_Result result = AddTrun(trun,
+ tfhd,
+ trex,
+ sample_stream,
moof_offset,
mdat_payload_offset,
dts_origin);
- if(AP4_FAILED(result)) return;
+ if (AP4_FAILED(result)) return;
}
- }
+ }
}
/*----------------------------------------------------------------------
@@ -98,8 +94,8 @@ AP4_FragmentSampleTable::~AP4_FragmentSampleTable()
| AP4_FragmentSampleTable::AddTrun
+---------------------------------------------------------------------*/
AP4_Result
-AP4_FragmentSampleTable::AddTrun(AP4_TrunAtom* trun,
- AP4_TfhdAtom* tfhd,
+AP4_FragmentSampleTable::AddTrun(AP4_TrunAtom* trun,
+ AP4_TfhdAtom* tfhd,
AP4_TrexAtom* trex,
AP4_ByteStream* sample_stream,
AP4_Position moof_offset,
@@ -108,155 +104,120 @@ AP4_FragmentSampleTable::AddTrun(AP4_TrunAtom* trun,
{
AP4_Flags tfhd_flags = tfhd->GetFlags();
AP4_Flags trun_flags = trun->GetFlags();
-
+
// update the number of samples
unsigned int start = m_Samples.ItemCount();
m_Samples.SetItemCount(start + trun->GetEntries().ItemCount());
-
+
// base data offset
AP4_Position data_offset = 0;
- if(tfhd_flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT)
- {
+ if (tfhd_flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT) {
data_offset = tfhd->GetBaseDataOffset();
- }
- else
- {
+ } else {
data_offset = moof_offset;
}
- if(trun_flags & AP4_TRUN_FLAG_DATA_OFFSET_PRESENT)
- {
+ if (trun_flags & AP4_TRUN_FLAG_DATA_OFFSET_PRESENT) {
data_offset += trun->GetDataOffset();
- }
+ }
// MS hack
- if(data_offset == moof_offset)
- {
+ if (data_offset == moof_offset) {
data_offset = payload_offset;
- }
- else
- {
+ } else {
payload_offset = data_offset;
}
-
+
// sample description index
AP4_UI32 sample_description_index = 0;
- if(tfhd_flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT)
- {
+ if (tfhd_flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT) {
sample_description_index = tfhd->GetSampleDescriptionIndex();
- }
- else if(trex)
- {
+ } else if (trex) {
sample_description_index = trex->GetDefaultSampleDescriptionIndex();
- }
-
+ }
+
// default sample size
AP4_UI32 default_sample_size = 0;
- if(tfhd_flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT)
- {
+ if (tfhd_flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT) {
default_sample_size = tfhd->GetDefaultSampleSize();
- }
- else if(trex)
- {
+ } else if (trex) {
default_sample_size = trex->GetDefaultSampleSize();
}
-
+
// default sample duration
AP4_UI32 default_sample_duration = 0;
- if(tfhd_flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT)
- {
+ if (tfhd_flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT) {
default_sample_duration = tfhd->GetDefaultSampleDuration();
- }
- else if(trex)
- {
+ } else if (trex) {
default_sample_duration = trex->GetDefaultSampleDuration();
}
-
+
// default sample flags
AP4_UI32 default_sample_flags = 0;
- if(tfhd_flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT)
- {
+ if (tfhd_flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT) {
default_sample_flags = tfhd->GetDefaultSampleFlags();
- }
- else if(trex)
- {
+ } else if (trex) {
default_sample_flags = trex->GetDefaultSampleFlags();
}
// parse all trun entries to setup the samples
AP4_UI64 dts = dts_origin;
- for(unsigned int i = 0; i < trun->GetEntries().ItemCount(); i++)
- {
+ for (unsigned int i=0; i<trun->GetEntries().ItemCount(); i++) {
const AP4_TrunAtom::Entry& entry = trun->GetEntries()[i];
AP4_Sample& sample = m_Samples[start+i];
-
+
// sample size
- if(trun_flags & AP4_TRUN_FLAG_SAMPLE_SIZE_PRESENT)
- {
+ if (trun_flags & AP4_TRUN_FLAG_SAMPLE_SIZE_PRESENT) {
sample.SetSize(entry.sample_size);
- }
- else
- {
+ } else {
sample.SetSize(default_sample_size);
}
payload_offset += sample.GetSize(); // update the payload offset
-
+
// sample duration
- if(trun_flags & AP4_TRUN_FLAG_SAMPLE_DURATION_PRESENT)
- {
+ if (trun_flags & AP4_TRUN_FLAG_SAMPLE_DURATION_PRESENT) {
sample.SetDuration(entry.sample_duration);
- }
- else
- {
+ } else {
sample.SetDuration(default_sample_duration);
}
// sample flags
AP4_UI32 sample_flags = default_sample_flags;
- if(i == 0 && (trun_flags & AP4_TRUN_FLAG_FIRST_SAMPLE_FLAGS_PRESENT))
- {
+ if (i==0 && (trun_flags & AP4_TRUN_FLAG_FIRST_SAMPLE_FLAGS_PRESENT)) {
sample_flags = trun->GetFirstSampleFlags();
- }
- else if(trun_flags & AP4_TRUN_FLAG_SAMPLE_FLAGS_PRESENT)
- {
+ } else if (trun_flags & AP4_TRUN_FLAG_SAMPLE_FLAGS_PRESENT) {
sample_flags = entry.sample_flags;
}
- if((sample_flags & AP4_FRAG_FLAG_SAMPLE_IS_DIFFERENCE) == 0)
- {
+ if ((sample_flags & AP4_FRAG_FLAG_SAMPLE_IS_DIFFERENCE) == 0) {
sample.SetSync(true);
- }
- else
- {
+ } else {
sample.SetSync(false);
}
-
+
// sample description index
sample.SetDescriptionIndex(sample_description_index);
-
+
// data stream
- if(sample_stream) sample.SetDataStream(*sample_stream);
-
+ if (sample_stream) sample.SetDataStream(*sample_stream);
+
// data offset
sample.SetOffset(data_offset);
data_offset += sample.GetSize();
-
+
// dts and cts
sample.SetDts(dts);
- if(trun_flags & AP4_TRUN_FLAG_SAMPLE_COMPOSITION_TIME_OFFSET_PRESENT)
- {
- sample.SetCts(dts + entry.sample_composition_time_offset);
- }
- else
- {
+ if (trun_flags & AP4_TRUN_FLAG_SAMPLE_COMPOSITION_TIME_OFFSET_PRESENT) {
+ sample.SetCts(dts+entry.sample_composition_time_offset);
+ } else {
sample.SetCts(dts);
}
-
+
// update the counters
dts += sample.GetDuration();
m_Duration += sample.GetDuration();
}
-
+
// update the dts
dts_origin = dts;
-
+
return AP4_SUCCESS;
}
@@ -264,10 +225,10 @@ AP4_FragmentSampleTable::AddTrun(AP4_TrunAtom* trun,
| AP4_FragmentSampleTable::GetSample
+---------------------------------------------------------------------*/
AP4_Result
-AP4_FragmentSampleTable::GetSample(AP4_Ordinal index,
+AP4_FragmentSampleTable::GetSample(AP4_Ordinal index,
AP4_Sample& sample)
{
- if(index >= m_Samples.ItemCount()) return AP4_ERROR_OUT_OF_RANGE;
+ if (index >= m_Samples.ItemCount()) return AP4_ERROR_OUT_OF_RANGE;
// copy the sample
sample = m_Samples[index];
@@ -305,23 +266,23 @@ AP4_FragmentSampleTable::GetSampleDescriptionCount()
/*----------------------------------------------------------------------
| AP4_AtomSampleTable::GetSampleChunkPosition
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_FragmentSampleTable::GetSampleChunkPosition(AP4_Ordinal sample_index,
- AP4_Ordinal& chunk_index,
- AP4_Ordinal& position_in_chunk)
+AP4_Result
+AP4_FragmentSampleTable::GetSampleChunkPosition(AP4_Ordinal sample_index,
+ AP4_Ordinal& chunk_index,
+ AP4_Ordinal& position_in_chunk)
{
chunk_index = 0;
position_in_chunk = sample_index;
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_FragmentSampleTable::GetSampleIndexForTimeStamp
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_FragmentSampleTable::GetSampleIndexForTimeStamp(AP4_UI64 /*ts*/,
- AP4_Ordinal& sample_index)
+AP4_Result
+AP4_FragmentSampleTable::GetSampleIndexForTimeStamp(AP4_UI64 /*ts*/,
+ AP4_Ordinal& sample_index)
{
sample_index = 0; // FIXME
return AP4_SUCCESS;
@@ -330,7 +291,7 @@ AP4_FragmentSampleTable::GetSampleIndexForTimeStamp(AP4_UI64 /*ts*/,
/*----------------------------------------------------------------------
| AP4_FragmentSampleTable::GetNearestSyncSampleIndex
+---------------------------------------------------------------------*/
-AP4_Ordinal
+AP4_Ordinal
AP4_FragmentSampleTable::GetNearestSyncSampleIndex(AP4_Ordinal /*sample_index*/, bool /*before*/)
{
return 0; // FIXME
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.h
index 3c16eb60a..0c626bcb5 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FragmentSampleTable.h
@@ -50,14 +50,14 @@ class AP4_TfhdAtom;
+---------------------------------------------------------------------*/
class AP4_FragmentSampleTable : public AP4_SampleTable
{
-public:
+ public:
// methods
- AP4_FragmentSampleTable(AP4_ContainerAtom* traf,
- AP4_TrexAtom* trex,
- AP4_ByteStream* sample_stream,
- AP4_Position moof_offset,
- AP4_Position mdat_payload_offset, // hack because MS doesn't implement the spec correctly
- AP4_UI64 dts_origin = 0);
+ AP4_FragmentSampleTable(AP4_ContainerAtom* traf,
+ AP4_TrexAtom* trex,
+ AP4_ByteStream* sample_stream,
+ AP4_Position moof_offset,
+ AP4_Position mdat_payload_offset, // hack because MS doesn't implement the spec correctly
+ AP4_UI64 dts_origin=0);
virtual ~AP4_FragmentSampleTable();
// AP4_SampleTable methods
@@ -65,28 +65,25 @@ public:
virtual AP4_Cardinal GetSampleCount();
virtual AP4_SampleDescription* GetSampleDescription(AP4_Ordinal sd_index);
virtual AP4_Cardinal GetSampleDescriptionCount();
- virtual AP4_Result GetSampleChunkPosition(AP4_Ordinal sample_index,
- AP4_Ordinal& chunk_index,
- AP4_Ordinal& position_in_chunk);
+ virtual AP4_Result GetSampleChunkPosition(AP4_Ordinal sample_index,
+ AP4_Ordinal& chunk_index,
+ AP4_Ordinal& position_in_chunk);
virtual AP4_Result GetSampleIndexForTimeStamp(AP4_UI64 ts, AP4_Ordinal& sample_index);
- virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal index, bool before = true);
+ virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal index, bool before=true);
// methods
- AP4_UI64 GetDuration()
- {
- return m_Duration;
- }
-
+ AP4_UI64 GetDuration() { return m_Duration; }
+
private:
// members
AP4_TrunAtom* m_TrunAtom;
AP4_Array<AP4_Sample> m_Samples;
AP4_UI64 m_Duration;
-
+
// methods
- AP4_Result AddTrun(AP4_TrunAtom* trun,
- AP4_TfhdAtom* tfhd,
- AP4_TrexAtom* trex,
+ AP4_Result AddTrun(AP4_TrunAtom* trun,
+ AP4_TfhdAtom* tfhd,
+ AP4_TrexAtom* trex,
AP4_ByteStream* sample_stream,
AP4_Position moof_offset,
AP4_Position& payload_offset,
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.cpp
index 8b8fbef11..cfaef69b3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - frma Atoms
+| AP4 - frma Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -37,7 +37,7 @@
| AP4_FrmaAtom::AP4_FrmaAtom
+---------------------------------------------------------------------*/
AP4_FrmaAtom::AP4_FrmaAtom(AP4_UI32 original_format) :
- AP4_Atom(AP4_ATOM_TYPE_FRMA, AP4_ATOM_HEADER_SIZE + 4),
+ AP4_Atom(AP4_ATOM_TYPE_FRMA, AP4_ATOM_HEADER_SIZE+4),
m_OriginalFormat(original_format)
{
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.h
index 3542ab234..c6ea77a08 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FrmaAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - frma Atoms
+| AP4 - frma Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -47,21 +47,17 @@ class AP4_FrmaAtom : public AP4_Atom
{
public:
// class methods
- static AP4_FrmaAtom* Create(AP4_Size size, AP4_ByteStream& stream)
- {
+ static AP4_FrmaAtom* Create(AP4_Size size, AP4_ByteStream& stream) {
return new AP4_FrmaAtom(size, stream);
}
- // constructors
+ // constructors
AP4_FrmaAtom(AP4_UI32 original_format);
// methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_UI32 GetOriginalFormat()
- {
- return m_OriginalFormat;
- }
+ AP4_UI32 GetOriginalFormat() { return m_OriginalFormat; }
private:
// methods
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.cpp
index 96cfe24b4..287238ebd 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.cpp
@@ -38,27 +38,27 @@
AP4_FtabAtom::AP4_FtabAtom(AP4_Size size,
AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_FTAB)
+ : AP4_Atom(AP4_ATOM_TYPE_FTAB)
{
- AP4_UI16 entryCount;
+ AP4_UI16 entryCount;
stream.ReadUI16(entryCount);
- m_FontRecords.EnsureCapacity(entryCount);
+ m_FontRecords.EnsureCapacity(entryCount);
- while(entryCount--)
- {
- AP4_Tx3gFontRecord fontRecord;
+ while(entryCount--)
+ {
+ AP4_Tx3gFontRecord fontRecord;
- stream.ReadUI16(fontRecord.Id);
+ stream.ReadUI16(fontRecord.Id);
- AP4_UI08 len;
- stream.ReadUI08(len);
+ AP4_UI08 len;
+ stream.ReadUI08(len);
- char buff[256];
- stream.ReadString(buff, len + 1);
+ char buff[256];
+ stream.ReadString(buff, len+1);
- fontRecord.Name = buff;
+ fontRecord.Name = buff;
- m_FontRecords.Append(fontRecord);
- }
+ m_FontRecords.Append(fontRecord);
+ }
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.h
index 78b2b65ae..0845347d5 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtabAtom.h
@@ -42,43 +42,37 @@
class AP4_FtabAtom : public AP4_Atom
{
public:
- AP4_FtabAtom(AP4_Size size,
+ AP4_FtabAtom(AP4_Size size,
AP4_ByteStream& stream);
- AP4_Result WriteFields(AP4_ByteStream& stream)
- {
- return AP4_FAILURE;
- }
+ AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
- struct AP4_Tx3gFontRecord
- {
- AP4_UI16 Id;
- AP4_String Name;
- };
+ struct AP4_Tx3gFontRecord
+ {
+ AP4_UI16 Id;
+ AP4_String Name;
+ };
- AP4_Array<AP4_Tx3gFontRecord>& GetFontRecords()
- {
- return m_FontRecords;
- }
+ AP4_Array<AP4_Tx3gFontRecord>& GetFontRecords() { return m_FontRecords; }
- AP4_Result LookupFont(AP4_UI16 Id, AP4_String& Name)
- {
- for(unsigned long i = 0; i < m_FontRecords.ItemCount(); i++)
- {
- if(m_FontRecords[i].Id == Id)
- {
- Name = m_FontRecords[i].Name;
- return AP4_SUCCESS;
- }
- }
+ AP4_Result LookupFont(AP4_UI16 Id, AP4_String& Name)
+ {
+ for(unsigned long i = 0; i < m_FontRecords.ItemCount(); i++)
+ {
+ if(m_FontRecords[i].Id == Id)
+ {
+ Name = m_FontRecords[i].Name;
+ return AP4_SUCCESS;
+ }
+ }
- return AP4_FAILURE;
- }
+ return AP4_FAILURE;
+ }
private:
- // members
- AP4_Array<AP4_Tx3gFontRecord> m_FontRecords;
+ // members
+ AP4_Array<AP4_Tx3gFontRecord> m_FontRecords;
};
#endif // _AP4_FTAB_ATOM_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.cpp
index 511827cca..8bd20f0cc 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - ftyp Atoms
+| AP4 - ftyp Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -47,8 +47,7 @@ AP4_FtypAtom::AP4_FtypAtom(AP4_UI32 size, AP4_ByteStream& stream) :
stream.ReadUI32(m_MajorBrand);
stream.ReadUI32(m_MinorVersion);
size -= 16;
- while(size)
- {
+ while (size) {
AP4_UI32 compatible_brand;
stream.ReadUI32(compatible_brand);
m_CompatibleBrands.Append(compatible_brand);
@@ -63,7 +62,7 @@ AP4_FtypAtom::AP4_FtypAtom(AP4_UI32 major_brand,
AP4_UI32 minor_version,
AP4_UI32* compatible_brands,
AP4_Cardinal compatible_brand_count) :
- AP4_Atom(AP4_ATOM_TYPE_FTYP, AP4_ATOM_HEADER_SIZE + 8 + 4 * compatible_brand_count),
+ AP4_Atom(AP4_ATOM_TYPE_FTYP, AP4_ATOM_HEADER_SIZE+8+4*compatible_brand_count),
m_MajorBrand(major_brand),
m_MinorVersion(minor_version),
m_CompatibleBrands(compatible_brands, compatible_brand_count)
@@ -76,9 +75,8 @@ AP4_FtypAtom::AP4_FtypAtom(AP4_UI32 major_brand,
bool
AP4_FtypAtom::HasCompatibleBrand(AP4_UI32 brand)
{
- for(unsigned int i = 0; i < m_CompatibleBrands.ItemCount(); i++)
- {
- if(m_CompatibleBrands[i] == brand) return true;
+ for (unsigned int i=0; i<m_CompatibleBrands.ItemCount(); i++) {
+ if (m_CompatibleBrands[i] == brand) return true;
}
return false;
@@ -91,21 +89,20 @@ AP4_Result
AP4_FtypAtom::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
+
// major brand
result = stream.WriteUI32(m_MajorBrand);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// minor version
result = stream.WriteUI32(m_MinorVersion);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// compatible brands
AP4_Cardinal compat_brand_count = m_CompatibleBrands.ItemCount();
- for(AP4_Ordinal i = 0; i < compat_brand_count; i++)
- {
+ for (AP4_Ordinal i=0; i<compat_brand_count; i++) {
result = stream.WriteUI32(m_CompatibleBrands[i]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return result;
@@ -123,8 +120,7 @@ AP4_FtypAtom::InspectFields(AP4_AtomInspector& inspector)
inspector.AddField("minor_version", m_MinorVersion, AP4_AtomInspector::HINT_HEX);
// compatible brands
- for(unsigned int i = 0; i < m_CompatibleBrands.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<m_CompatibleBrands.ItemCount(); i++) {
AP4_UI32 cb = m_CompatibleBrands[i];
AP4_FormatFourChars(name, cb);
inspector.AddField("compatible_brand", name);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.h
index 8e9149476..fe6e2c0f4 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4FtypAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - ftyp Atoms
+| AP4 - ftyp Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -44,7 +44,7 @@ class AP4_ByteStream;
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_FTYP_BRAND_ISOM = AP4_ATOM_TYPE('i', 's', 'o', 'm');
+const AP4_UI32 AP4_FTYP_BRAND_ISOM = AP4_ATOM_TYPE('i','s','o','m');
/*----------------------------------------------------------------------
| AP4_FtypAtom
@@ -55,8 +55,7 @@ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_FtypAtom, AP4_Atom)
// class methods
- static AP4_FtypAtom* Create(AP4_Size size, AP4_ByteStream& stream)
- {
+ static AP4_FtypAtom* Create(AP4_Size size, AP4_ByteStream& stream) {
return new AP4_FtypAtom(size, stream);
}
@@ -67,19 +66,12 @@ public:
AP4_Cardinal compatible_brand_count = 0);
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
// accessors
- AP4_UI32 GetMajorBrand()
- {
- return m_MajorBrand;
- }
- AP4_UI32 GetMinorVersion()
- {
- return m_MinorVersion;
- }
- AP4_Array<AP4_UI32>& GetCompatibleBrands()
- {
- return m_CompatibleBrands;
+ AP4_UI32 GetMajorBrand() { return m_MajorBrand; }
+ AP4_UI32 GetMinorVersion() { return m_MinorVersion; }
+ AP4_Array<AP4_UI32>& GetCompatibleBrands() {
+ return m_CompatibleBrands;
}
bool HasCompatibleBrand(AP4_UI32 brand);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.cpp
index d839d8511..f75764a14 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - ohdr Atoms
+| AP4 - ohdr Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -45,15 +45,15 @@ AP4_GrpiAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_GrpiAtom(size, version, flags, stream);
}
/*----------------------------------------------------------------------
| AP4_GrpiAtom::AP4_GrpiAtom
+---------------------------------------------------------------------*/
-AP4_GrpiAtom::AP4_GrpiAtom(AP4_UI08 key_encryption_method,
+AP4_GrpiAtom::AP4_GrpiAtom(AP4_UI08 key_encryption_method,
const char* group_id,
const AP4_UI08* group_key,
AP4_Size group_key_length) :
@@ -62,13 +62,13 @@ AP4_GrpiAtom::AP4_GrpiAtom(AP4_UI08 key_encryption_method,
m_GroupId(group_id),
m_GroupKey(group_key, group_key_length)
{
- m_Size32 += 2 + 1 + 2 + m_GroupId.GetLength() + group_key_length;
+ m_Size32 += 2+1+2+m_GroupId.GetLength()+group_key_length;
}
/*----------------------------------------------------------------------
| AP4_GrpiAtom::AP4_GrpiAtom
+---------------------------------------------------------------------*/
-AP4_GrpiAtom::AP4_GrpiAtom(AP4_UI32 size,
+AP4_GrpiAtom::AP4_GrpiAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -80,7 +80,7 @@ AP4_GrpiAtom::AP4_GrpiAtom(AP4_UI32 size,
// encryption method
stream.ReadUI08(m_KeyEncryptionMethod);
-
+
// group key length
AP4_UI16 group_key_length = 0;
stream.ReadUI16(group_key_length);
@@ -107,7 +107,7 @@ AP4_GrpiAtom::WriteFields(AP4_ByteStream& stream)
AP4_CHECK(stream.WriteUI16((AP4_UI16)m_GroupKey.GetDataSize()));
AP4_CHECK(stream.Write(m_GroupId.GetChars(), m_GroupId.GetLength()));
AP4_CHECK(stream.Write(m_GroupKey.GetData(), m_GroupKey.GetDataSize()));
-
+
return AP4_SUCCESS;
}
@@ -119,15 +119,15 @@ AP4_GrpiAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("key encryption method", m_KeyEncryptionMethod);
inspector.AddField("group id", m_GroupId.GetChars());
- inspector.AddField("group key", m_GroupKey.GetData(),
- m_GroupKey.GetDataSize());
+ inspector.AddField("group key", m_GroupKey.GetData(),
+ m_GroupKey.GetDataSize());
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_GrpiAtom::Clone
+---------------------------------------------------------------------*/
-AP4_Atom*
+AP4_Atom*
AP4_GrpiAtom::Clone()
{
return new AP4_GrpiAtom(m_KeyEncryptionMethod,
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.h
index 9ac2868cd..80aeae6c2 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4GrpiAtom.h
@@ -46,47 +46,35 @@ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_GrpiAtom, AP4_Atom)
// class methods
- static AP4_GrpiAtom* Create(AP4_Size size,
+ static AP4_GrpiAtom* Create(AP4_Size size,
AP4_ByteStream& stream);
// constructor
- AP4_GrpiAtom(AP4_UI08 key_encryption_method,
+ AP4_GrpiAtom(AP4_UI08 key_encryption_method,
const char* group_id,
const AP4_UI08* group_key,
AP4_Size group_key_length);
-
+
// methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Atom* Clone();
// accessors
- AP4_UI08 GetKeyEncryptionMethod() const
- {
- return m_KeyEncryptionMethod;
- }
- void SetKeyEncryptionMethod(AP4_UI08 encryption_method)
- {
- m_KeyEncryptionMethod = encryption_method;
- }
- const AP4_String& GetGroupId() const
- {
- return m_GroupId;
- }
- const AP4_DataBuffer& GetGroupKey() const
- {
- return m_GroupKey;
- }
-
+ AP4_UI08 GetKeyEncryptionMethod() const { return m_KeyEncryptionMethod; }
+ void SetKeyEncryptionMethod(AP4_UI08 encryption_method) { m_KeyEncryptionMethod = encryption_method; }
+ const AP4_String& GetGroupId() const { return m_GroupId; }
+ const AP4_DataBuffer& GetGroupKey() const { return m_GroupKey; }
+
private:
// methods
- AP4_GrpiAtom(AP4_UI32 size,
+ AP4_GrpiAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
// members
- AP4_UI08 m_KeyEncryptionMethod;
+ AP4_UI08 m_KeyEncryptionMethod;
AP4_String m_GroupId;
AP4_DataBuffer m_GroupKey;
};
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.cpp
index c8150ccb7..9a25e3ed3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - hdlr Atoms
+| AP4 - hdlr Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_HdlrAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_HdlrAtom(size, version, flags, stream);
}
@@ -59,14 +59,14 @@ AP4_HdlrAtom::AP4_HdlrAtom(AP4_Atom::Type hdlr_type, const char* hdlr_name) :
m_HandlerType(hdlr_type),
m_HandlerName(hdlr_name)
{
- m_Size32 += 20 + m_HandlerName.GetLength() + 1;
+ m_Size32 += 20+m_HandlerName.GetLength()+1;
m_Reserved[0] = m_Reserved[1] = m_Reserved[2] = 0;
}
/*----------------------------------------------------------------------
| AP4_HdlrAtom::AP4_HdlrAtom
+---------------------------------------------------------------------*/
-AP4_HdlrAtom::AP4_HdlrAtom(AP4_UI32 size,
+AP4_HdlrAtom::AP4_HdlrAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -78,22 +78,19 @@ AP4_HdlrAtom::AP4_HdlrAtom(AP4_UI32 size,
stream.ReadUI32(m_Reserved[0]);
stream.ReadUI32(m_Reserved[1]);
stream.ReadUI32(m_Reserved[2]);
-
+
// read the name unless it is empty
- int name_size = size - (AP4_FULL_ATOM_HEADER_SIZE + 20);
- if(name_size == 0) return;
+ int name_size = size-(AP4_FULL_ATOM_HEADER_SIZE+20);
+ if (name_size == 0) return;
char* name = new char[name_size+1];
stream.Read(name, name_size);
name[name_size] = '\0'; // force a null termination
// handle a special case: the Quicktime files have a pascal
// string here, but ISO MP4 files have a C string.
// we try to detect a pascal encoding and correct it.
- if(name[0] == name_size - 1)
- {
- m_HandlerName = name + 1;
- }
- else
- {
+ if (name[0] == name_size-1) {
+ m_HandlerName = name+1;
+ } else {
m_HandlerName = name;
}
delete[] name;
@@ -109,29 +106,27 @@ AP4_HdlrAtom::WriteFields(AP4_ByteStream& stream)
// write the data
result = stream.WriteUI32(0); // predefined
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_HandlerType);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_Reserved[0]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_Reserved[1]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_Reserved[2]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
AP4_UI08 name_size = (AP4_UI08)m_HandlerName.GetLength();
- if(AP4_FULL_ATOM_HEADER_SIZE + 20 + name_size > m_Size32)
- {
- name_size = m_Size32 - AP4_FULL_ATOM_HEADER_SIZE + 20;
+ if (AP4_FULL_ATOM_HEADER_SIZE+20+name_size > m_Size32) {
+ name_size = m_Size32-AP4_FULL_ATOM_HEADER_SIZE+20;
}
- if(name_size)
- {
+ if (name_size) {
result = stream.Write(m_HandlerName.GetChars(), name_size);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// pad with zeros if necessary
- AP4_Size padding = m_Size32 - (AP4_FULL_ATOM_HEADER_SIZE + 20 + name_size);
- while(padding--) stream.WriteUI08(0);
+ AP4_Size padding = m_Size32-(AP4_FULL_ATOM_HEADER_SIZE+20+name_size);
+ while (padding--) stream.WriteUI08(0);
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.h
index 63080dbcb..c5b1bf135 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HdlrAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - hdlr Atoms
+| AP4 - hdlr Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -43,17 +43,17 @@ class AP4_ByteStream;
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_HANDLER_TYPE_SOUN = AP4_ATOM_TYPE('s', 'o', 'u', 'n');
-const AP4_UI32 AP4_HANDLER_TYPE_VIDE = AP4_ATOM_TYPE('v', 'i', 'd', 'e');
-const AP4_UI32 AP4_HANDLER_TYPE_HINT = AP4_ATOM_TYPE('h', 'i', 'n', 't');
-const AP4_UI32 AP4_HANDLER_TYPE_MDIR = AP4_ATOM_TYPE('m', 'd', 'i', 'r');
-const AP4_UI32 AP4_HANDLER_TYPE_TEXT = AP4_ATOM_TYPE('t', 'e', 'x', 't');
-const AP4_UI32 AP4_HANDLER_TYPE_TX3G = AP4_ATOM_TYPE('t', 'x', '3', 'g');
-const AP4_UI32 AP4_HANDLER_TYPE_JPEG = AP4_ATOM_TYPE('j', 'p', 'e', 'g');
-const AP4_UI32 AP4_HANDLER_TYPE_ODSM = AP4_ATOM_TYPE('o', 'd', 's', 'm');
-const AP4_UI32 AP4_HANDLER_TYPE_SDSM = AP4_ATOM_TYPE('s', 'd', 's', 'm');
+const AP4_UI32 AP4_HANDLER_TYPE_SOUN = AP4_ATOM_TYPE('s','o','u','n');
+const AP4_UI32 AP4_HANDLER_TYPE_VIDE = AP4_ATOM_TYPE('v','i','d','e');
+const AP4_UI32 AP4_HANDLER_TYPE_HINT = AP4_ATOM_TYPE('h','i','n','t');
+const AP4_UI32 AP4_HANDLER_TYPE_MDIR = AP4_ATOM_TYPE('m','d','i','r');
+const AP4_UI32 AP4_HANDLER_TYPE_TEXT = AP4_ATOM_TYPE('t','e','x','t');
+const AP4_UI32 AP4_HANDLER_TYPE_TX3G = AP4_ATOM_TYPE('t','x','3','g');
+const AP4_UI32 AP4_HANDLER_TYPE_JPEG = AP4_ATOM_TYPE('j','p','e','g');
+const AP4_UI32 AP4_HANDLER_TYPE_ODSM = AP4_ATOM_TYPE('o','d','s','m');
+const AP4_UI32 AP4_HANDLER_TYPE_SDSM = AP4_ATOM_TYPE('s','d','s','m');
// ==> Start patch MPC
-const AP4_UI32 AP4_HANDLER_TYPE_SUBP = AP4_ATOM_TYPE('s', 'u', 'b', 'p');
+const AP4_UI32 AP4_HANDLER_TYPE_SUBP = AP4_ATOM_TYPE('s','u','b','p');
// <== End patch MPC
/*----------------------------------------------------------------------
@@ -72,18 +72,12 @@ public:
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_UI32 GetHandlerType()
- {
- return m_HandlerType;
- }
- AP4_String GetHandlerName()
- {
- return m_HandlerName;
- }
+ AP4_UI32 GetHandlerType() { return m_HandlerType; }
+ AP4_String GetHandlerName() { return m_HandlerName; }
private:
// methods
- AP4_HdlrAtom(AP4_UI32 size,
+ AP4_HdlrAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.cpp
index 626e18d32..3e35131cb 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.cpp
@@ -45,9 +45,9 @@
/*----------------------------------------------------------------------
| AP4_HintTrackReader::AP4_HintTrackReader
+---------------------------------------------------------------------*/
-AP4_HintTrackReader::AP4_HintTrackReader(AP4_Track& hint_track,
- AP4_Movie& movie,
- AP4_UI32 ssrc) :
+AP4_HintTrackReader::AP4_HintTrackReader(AP4_Track& hint_track,
+ AP4_Movie& movie,
+ AP4_UI32 ssrc) :
m_HintTrack(hint_track),
m_MediaTrack(NULL),
m_MediaTimeScale(0),
@@ -62,8 +62,7 @@ AP4_HintTrackReader::AP4_HintTrackReader(AP4_Track& hint_track,
// get the media track
AP4_TrakAtom* hint_trak_atom = hint_track.GetTrakAtom();
AP4_Atom* atom = hint_trak_atom->FindChild("tref/hint");
- if(atom != NULL)
- {
+ if (atom != NULL) {
AP4_UI32 media_track_id = ((AP4_TrefTypeAtom*) atom)->GetTrackIds()[0];
m_MediaTrack = movie.GetTrack(media_track_id);
@@ -82,15 +81,13 @@ AP4_HintTrackReader::AP4_HintTrackReader(AP4_Track& hint_track,
// rtp time scale
atom = hint_trak_atom->FindChild("mdia/minf/stbl/rtp /tims");
- if(atom)
- {
+ if (atom) {
AP4_TimsAtom* tims = (AP4_TimsAtom*)atom;
m_RtpTimeScale = tims->GetTimeScale();
}
// generate a random ssrc if = 0
- if(m_Ssrc == 0)
- {
+ if (m_Ssrc == 0) {
m_Ssrc = rand();
}
@@ -102,23 +99,22 @@ AP4_HintTrackReader::AP4_HintTrackReader(AP4_Track& hint_track,
| AP4_HintTrackReader::Create
+---------------------------------------------------------------------*/
AP4_Result
-AP4_HintTrackReader::Create(AP4_Track& hint_track,
- AP4_Movie& movie,
+AP4_HintTrackReader::Create(AP4_Track& hint_track,
+ AP4_Movie& movie,
AP4_UI32 ssrc,
AP4_HintTrackReader*& reader)
{
// default value
reader = NULL;
-
+
// check the type
- if(hint_track.GetType() != AP4_Track::TYPE_HINT)
- {
+ if (hint_track.GetType() != AP4_Track::TYPE_HINT) {
return AP4_ERROR_INVALID_TRACK_TYPE;
}
-
+
// create a new object
reader = new AP4_HintTrackReader(hint_track, movie, ssrc);
-
+
return AP4_SUCCESS;
}
@@ -138,7 +134,7 @@ AP4_HintTrackReader::GetRtpSample(AP4_Ordinal index)
{
// get the sample
AP4_Result result = m_HintTrack.GetSample(index, m_CurrentHintSample);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// renew the sample data
delete m_RtpSampleData;
@@ -162,7 +158,7 @@ AP4_HintTrackReader::GetRtpSample(AP4_Ordinal index)
AP4_UI32
AP4_HintTrackReader::GetCurrentTimeStampMs()
{
- return (AP4_UI32)AP4_ConvertTime(m_CurrentHintSample.GetCts(),
+ return (AP4_UI32)AP4_ConvertTime(m_CurrentHintSample.GetCts(),
m_HintTrack.GetMediaTimeScale(),
1000);
}
@@ -184,10 +180,10 @@ AP4_Result
AP4_HintTrackReader::GetSdpText(AP4_String& sdp_text)
{
AP4_Atom* sdp_atom = m_HintTrack.GetTrakAtom()->FindChild("udta/hnti/sdp ");
- if(sdp_atom == NULL) return AP4_FAILURE;
+ if (sdp_atom == NULL) return AP4_FAILURE;
// C cast is OK because we know the type of the atom
- sdp_text = ((AP4_SdpAtom*) sdp_atom)->GetSdpText();
+ sdp_text = ((AP4_SdpAtom*) sdp_atom)->GetSdpText();
return AP4_SUCCESS;
}
@@ -195,17 +191,17 @@ AP4_HintTrackReader::GetSdpText(AP4_String& sdp_text)
| AP4_HintTrackReader::SeekToTimeStampMs
+---------------------------------------------------------------------*/
AP4_Result
-AP4_HintTrackReader::SeekToTimeStampMs(AP4_UI32 desired_ts_ms,
+AP4_HintTrackReader::SeekToTimeStampMs(AP4_UI32 desired_ts_ms,
AP4_UI32& actual_ts_ms)
{
// get the sample index
AP4_Cardinal index;
AP4_Result result = m_HintTrack.GetSampleIndexForTimeStampMs(desired_ts_ms, index);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// get the current sample based on the index and renew the sample data
result = GetRtpSample(index);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// set the actual ts
actual_ts_ms = GetCurrentTimeStampMs();
@@ -216,28 +212,27 @@ AP4_HintTrackReader::SeekToTimeStampMs(AP4_UI32 desired_ts_ms,
| AP4_HintTrackReader::GetNextPacket
+---------------------------------------------------------------------*/
AP4_Result
-AP4_HintTrackReader::GetNextPacket(AP4_DataBuffer& packet_data,
+AP4_HintTrackReader::GetNextPacket(AP4_DataBuffer& packet_data,
AP4_UI32& ts_ms)
{
AP4_Result result = AP4_SUCCESS;
// get the next rtp sample if needed
AP4_List<AP4_RtpPacket>* packets = &m_RtpSampleData->GetPackets();
- while(m_PacketIndex == packets->ItemCount()) // while: handle the 0 packet case
- {
+ while (m_PacketIndex == packets->ItemCount()) { // while: handle the 0 packet case
result = GetRtpSample(++m_SampleIndex);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
packets = &m_RtpSampleData->GetPackets();
}
// get the packet
AP4_RtpPacket* packet;
result = packets->Get(m_PacketIndex++, packet);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// build it
result = BuildRtpPacket(packet, packet_data);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// set the time stamp
ts_ms = GetCurrentTimeStampMs();
@@ -249,15 +244,15 @@ AP4_HintTrackReader::GetNextPacket(AP4_DataBuffer& packet_data,
| AP4_HintTrackReader::BuildRtpPacket
+---------------------------------------------------------------------*/
AP4_Result
-AP4_HintTrackReader::BuildRtpPacket(AP4_RtpPacket* packet,
+AP4_HintTrackReader::BuildRtpPacket(AP4_RtpPacket* packet,
AP4_DataBuffer& packet_data)
{
// set the data size
AP4_Result result = packet_data.SetDataSize(packet->GetConstructedDataSize());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// now write
- AP4_ByteStream* stream = new AP4_MemoryByteStream(packet_data);
+ AP4_ByteStream* stream = new AP4_MemoryByteStream(packet_data);
// header + ssrc
stream->WriteUI08(0x80 | (packet->GetPBit() << 5) | (packet->GetXBit() << 4));
@@ -266,33 +261,31 @@ AP4_HintTrackReader::BuildRtpPacket(AP4_RtpPacket* packet,
stream->WriteUI32(m_RtpTimeStampStart + (AP4_UI32)m_CurrentHintSample.GetCts() + packet->GetTimeStampOffset());
stream->WriteUI32(m_Ssrc);
- AP4_List<AP4_RtpConstructor>::Item* constructors_it
- = packet->GetConstructors().FirstItem();
- while(constructors_it != NULL)
- {
+ AP4_List<AP4_RtpConstructor>::Item* constructors_it
+ = packet->GetConstructors().FirstItem();
+ while (constructors_it != NULL) {
AP4_RtpConstructor* constructor = constructors_it->GetData();
// add data to the packet according to the constructor
- switch(constructor->GetType())
- {
- case AP4_RTP_CONSTRUCTOR_TYPE_NOOP:
- // nothing to do here
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_IMMEDIATE:
- result = WriteImmediateRtpData(
- (AP4_ImmediateRtpConstructor*) constructor, stream);
- if(AP4_FAILED(result)) return result;
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE:
- result = WriteSampleRtpData(
- (AP4_SampleRtpConstructor*) constructor, stream);
- if(AP4_FAILED(result)) return result;
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC:
- return AP4_ERROR_NOT_SUPPORTED;
- default:
- // unknown constructor type
- return AP4_FAILURE;
+ switch (constructor->GetType()) {
+ case AP4_RTP_CONSTRUCTOR_TYPE_NOOP:
+ // nothing to do here
+ break;
+ case AP4_RTP_CONSTRUCTOR_TYPE_IMMEDIATE:
+ result = WriteImmediateRtpData(
+ (AP4_ImmediateRtpConstructor*) constructor, stream);
+ if (AP4_FAILED(result)) return result;
+ break;
+ case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE:
+ result = WriteSampleRtpData(
+ (AP4_SampleRtpConstructor*) constructor, stream);
+ if (AP4_FAILED(result)) return result;
+ break;
+ case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC:
+ return AP4_ERROR_NOT_SUPPORTED;
+ default:
+ // unknown constructor type
+ return AP4_FAILURE;
}
// iterate
@@ -309,8 +302,8 @@ AP4_HintTrackReader::BuildRtpPacket(AP4_RtpPacket* packet,
| AP4_HintTrackReader::WriteImmediateRtpData
+---------------------------------------------------------------------*/
AP4_Result
-AP4_HintTrackReader::WriteImmediateRtpData(AP4_ImmediateRtpConstructor* constructor,
- AP4_ByteStream* data_stream)
+AP4_HintTrackReader::WriteImmediateRtpData(AP4_ImmediateRtpConstructor* constructor,
+ AP4_ByteStream* data_stream)
{
const AP4_DataBuffer& data_buffer = constructor->GetData();
return data_stream->Write(data_buffer.GetData(), data_buffer.GetDataSize());
@@ -320,30 +313,27 @@ AP4_HintTrackReader::WriteImmediateRtpData(AP4_ImmediateRtpConstructor* construc
| AP4_HintTrackReader::WriteSampleRtpData
+---------------------------------------------------------------------*/
AP4_Result
-AP4_HintTrackReader::WriteSampleRtpData(AP4_SampleRtpConstructor* constructor,
+AP4_HintTrackReader::WriteSampleRtpData(AP4_SampleRtpConstructor* constructor,
AP4_ByteStream* data_stream)
{
AP4_Track* referenced_track = NULL;
- if(constructor->GetTrackRefIndex() == 0xFF)
- {
+ if (constructor->GetTrackRefIndex() == 0xFF) {
// data is in the hint track
referenced_track = &m_HintTrack;
- }
- else
- {
+ } else {
// check if we have a media track
- if(m_MediaTrack == NULL) return AP4_FAILURE;
+ if (m_MediaTrack == NULL) return AP4_FAILURE;
referenced_track = m_MediaTrack;
}
// write the sample data
AP4_Sample sample;
- AP4_Result result = referenced_track->GetSample(constructor->GetSampleNum() - 1, // adjust
- sample);
+ AP4_Result result = referenced_track->GetSample(constructor->GetSampleNum()-1, // adjust
+ sample);
AP4_DataBuffer buffer(constructor->GetLength());
result = sample.ReadData(
- buffer, constructor->GetLength(), constructor->GetSampleOffset());
- if(AP4_FAILED(result)) return result;
+ buffer, constructor->GetLength(), constructor->GetSampleOffset());
+ if (AP4_FAILED(result)) return result;
// write the data
return data_stream->Write(buffer.GetData(), buffer.GetDataSize());
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.h
index 0f4e0ef3e..71b2aebaa 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HintTrackReader.h
@@ -54,34 +54,31 @@ class AP4_HintTrackReader
{
public:
// constructor and destructor
- static AP4_Result Create(AP4_Track& hint_track,
- AP4_Movie& movie,
+ static AP4_Result Create(AP4_Track& hint_track,
+ AP4_Movie& movie,
AP4_UI32 ssrc, // if 0, a random value is chosen
AP4_HintTrackReader*& reader);
~AP4_HintTrackReader();
// methods
- AP4_Result GetNextPacket(AP4_DataBuffer& packet,
+ AP4_Result GetNextPacket(AP4_DataBuffer& packet,
AP4_UI32& ts_ms);
AP4_Result SeekToTimeStampMs(AP4_UI32 desired_ts_ms,
AP4_UI32& actual_ts_ms);
AP4_UI32 GetCurrentTimeStampMs();
AP4_Result Rewind();
AP4_Result GetSdpText(AP4_String& sdp);
- AP4_Track* GetMediaTrack()
- {
- return m_MediaTrack;
- }
-
+ AP4_Track* GetMediaTrack() { return m_MediaTrack; }
+
private:
// use the factory instead of the constructor
- AP4_HintTrackReader(AP4_Track& hint_track,
- AP4_Movie& movie,
+ AP4_HintTrackReader(AP4_Track& hint_track,
+ AP4_Movie& movie,
AP4_UI32 ssrc);
-
+
// methods
AP4_Result GetRtpSample(AP4_Ordinal index);
- AP4_Result BuildRtpPacket(AP4_RtpPacket* packet,
+ AP4_Result BuildRtpPacket(AP4_RtpPacket* packet,
AP4_DataBuffer& packet_data);
AP4_Result WriteImmediateRtpData(AP4_ImmediateRtpConstructor* constructor,
AP4_ByteStream* data_stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.cpp
index 5fcdab9da..4864e260a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - hmhd Atoms
+| AP4 - hmhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -41,15 +41,15 @@ AP4_HmhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_HmhdAtom(size, version, flags, stream);
}
/*----------------------------------------------------------------------
| AP4_HmhdAtom::AP4_HmhdAtom
+---------------------------------------------------------------------*/
-AP4_HmhdAtom::AP4_HmhdAtom(AP4_UI32 size,
+AP4_HmhdAtom::AP4_HmhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -72,23 +72,23 @@ AP4_HmhdAtom::WriteFields(AP4_ByteStream& stream)
// max pdu size
result = stream.WriteUI16(m_MaxPduSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// avg pdu size
result = stream.WriteUI16(m_AvgPduSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// max bitrate
result = stream.WriteUI32(m_MaxBitrate);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// avg bitrate
result = stream.WriteUI32(m_AvgBitrate);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// reserved
result = stream.WriteUI32(m_Reserved);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.h
index 69e68efa0..c26417dc7 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4HmhdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - hmhd Atoms
+| AP4 - hmhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -55,7 +55,7 @@ public:
private:
// methods
- AP4_HmhdAtom(AP4_UI32 size,
+ AP4_HmhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.cpp
index 4910f51cd..8e2df2fb2 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - iKMS Atoms
+| AP4 - iKMS Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -45,8 +45,8 @@ AP4_IkmsAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version > 1) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version > 1) return NULL;
return new AP4_IkmsAtom(size, version, flags, stream);
}
@@ -61,32 +61,28 @@ AP4_IkmsAtom::AP4_IkmsAtom(const char* kms_uri,
m_KmsId(kms_id),
m_KmsVersion(kms_version)
{
- m_Size32 += m_KmsUri.GetLength() + 1;
+ m_Size32 += m_KmsUri.GetLength()+1;
}
/*----------------------------------------------------------------------
| AP4_IkmsAtom::AP4_IkmsAtom
+---------------------------------------------------------------------*/
-AP4_IkmsAtom::AP4_IkmsAtom(AP4_UI32 size,
+AP4_IkmsAtom::AP4_IkmsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_IKMS, size, version, flags)
{
- AP4_Size string_size = size - AP4_FULL_ATOM_HEADER_SIZE;
- if(m_Version == 1 && string_size >= 8)
- {
+ AP4_Size string_size = size-AP4_FULL_ATOM_HEADER_SIZE;
+ if (m_Version == 1 && string_size >= 8) {
string_size -= 8;
stream.ReadUI32(m_KmsId);
stream.ReadUI32(m_KmsVersion);
- }
- else
- {
+ } else {
m_KmsId = 0;
m_KmsVersion = 0;
}
- if(string_size)
- {
+ if (string_size) {
char* str = new char[string_size];
stream.Read(str, string_size);
str[string_size-1] = '\0'; // force null-termination
@@ -98,7 +94,7 @@ AP4_IkmsAtom::AP4_IkmsAtom(AP4_UI32 size,
/*----------------------------------------------------------------------
| AP4_IkmsAtom::Clone
+---------------------------------------------------------------------*/
-AP4_Atom*
+AP4_Atom*
AP4_IkmsAtom::Clone()
{
return new AP4_IkmsAtom(m_KmsUri.GetChars(), m_KmsId, m_KmsVersion);
@@ -111,21 +107,20 @@ AP4_Result
AP4_IkmsAtom::WriteFields(AP4_ByteStream& stream)
{
// handler version 1
- if(m_Version == 1)
- {
+ if (m_Version == 1) {
stream.WriteUI32(m_KmsId);
stream.WriteUI32(m_KmsVersion);
}
// kms uri
- AP4_Result result = stream.Write(m_KmsUri.GetChars(), m_KmsUri.GetLength() + 1);
- if(AP4_FAILED(result)) return result;
+ AP4_Result result = stream.Write(m_KmsUri.GetChars(), m_KmsUri.GetLength()+1);
+ if (AP4_FAILED(result)) return result;
// pad with zeros if necessary
- AP4_Size padding = m_Size32 - (AP4_FULL_ATOM_HEADER_SIZE + m_KmsUri.GetLength() + 1);
- if(m_Version == 1) padding -= 8;
- while(padding--) stream.WriteUI08(0);
-
+ AP4_Size padding = m_Size32-(AP4_FULL_ATOM_HEADER_SIZE+m_KmsUri.GetLength()+1);
+ if (m_Version == 1) padding-=8;
+ while (padding--) stream.WriteUI08(0);
+
return AP4_SUCCESS;
}
@@ -135,8 +130,7 @@ AP4_IkmsAtom::WriteFields(AP4_ByteStream& stream)
AP4_Result
AP4_IkmsAtom::InspectFields(AP4_AtomInspector& inspector)
{
- if(m_Version == 1)
- {
+ if (m_Version == 1) {
char id[5];
AP4_FormatFourChars(id, m_KmsId);
inspector.AddField("kms_id", id);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.h
index 2e2756757..7097b84bd 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IkmsAtom.h
@@ -56,22 +56,13 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- const AP4_String& GetKmsUri()
- {
- return m_KmsUri;
- }
- AP4_UI32 GetKmsId()
- {
- return m_KmsId;
- }
- AP4_UI32 GetKmsVersion()
- {
- return m_KmsVersion;
- }
+ const AP4_String& GetKmsUri() { return m_KmsUri; }
+ AP4_UI32 GetKmsId() { return m_KmsId; }
+ AP4_UI32 GetKmsVersion() { return m_KmsVersion; }
private:
// methods
- AP4_IkmsAtom(AP4_UI32 size,
+ AP4_IkmsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Interfaces.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Interfaces.h
index 462bfe2d8..56502dab6 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Interfaces.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Interfaces.h
@@ -60,7 +60,7 @@ public:
+---------------------------------------------------------------------*/
class AP4_Referenceable
{
-public:
+ public:
// methods
virtual ~AP4_Referenceable() {}
virtual void AddReference() = 0;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.cpp
index 2d6822540..4baab3ce7 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.cpp
@@ -46,8 +46,8 @@ AP4_IodsAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_IodsAtom(size, version, flags, stream);
}
@@ -58,13 +58,13 @@ AP4_IodsAtom::AP4_IodsAtom(AP4_ObjectDescriptor* descriptor) :
AP4_Atom(AP4_ATOM_TYPE_IODS, AP4_FULL_ATOM_HEADER_SIZE, 0, 0),
m_ObjectDescriptor(descriptor)
{
- if(m_ObjectDescriptor) m_Size32 += m_ObjectDescriptor->GetSize();
+ if (m_ObjectDescriptor) m_Size32 += m_ObjectDescriptor->GetSize();
}
/*----------------------------------------------------------------------
| AP4_IodsAtom::AP4_IodsAtom
+---------------------------------------------------------------------*/
-AP4_IodsAtom::AP4_IodsAtom(AP4_UI32 size,
+AP4_IodsAtom::AP4_IodsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -72,13 +72,10 @@ AP4_IodsAtom::AP4_IodsAtom(AP4_UI32 size,
{
// read the descriptor
AP4_Descriptor* descriptor = NULL;
- if(AP4_DescriptorFactory::CreateDescriptorFromStream(stream, descriptor) == AP4_SUCCESS)
- {
+ if (AP4_DescriptorFactory::CreateDescriptorFromStream(stream, descriptor) == AP4_SUCCESS) {
m_ObjectDescriptor = AP4_DYNAMIC_CAST(AP4_ObjectDescriptor, descriptor);
- if(m_ObjectDescriptor == NULL) delete descriptor;
- }
- else
- {
+ if (m_ObjectDescriptor == NULL) delete descriptor;
+ } else {
m_ObjectDescriptor = NULL;
}
}
@@ -98,7 +95,7 @@ AP4_Result
AP4_IodsAtom::WriteFields(AP4_ByteStream& stream)
{
// write the es descriptor
- if(m_ObjectDescriptor) return m_ObjectDescriptor->Write(stream);
+ if (m_ObjectDescriptor) return m_ObjectDescriptor->Write(stream);
return AP4_SUCCESS;
}
@@ -110,8 +107,7 @@ AP4_Result
AP4_IodsAtom::InspectFields(AP4_AtomInspector& inspector)
{
// inspect descriptor
- if(m_ObjectDescriptor)
- {
+ if (m_ObjectDescriptor) {
m_ObjectDescriptor->Inspect(inspector);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.h
index fb7c1a67a..41c6c4cf0 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IodsAtom.h
@@ -54,17 +54,14 @@ public:
// methods
AP4_IodsAtom(AP4_ObjectDescriptor* descriptor); // ownership of 'descriptor' is transfered
- ~AP4_IodsAtom();
+ ~AP4_IodsAtom();
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- const AP4_ObjectDescriptor* GetObjectDescriptor() const
- {
- return m_ObjectDescriptor;
- }
-
+ const AP4_ObjectDescriptor* GetObjectDescriptor() const { return m_ObjectDescriptor; }
+
private:
// methods
- AP4_IodsAtom(AP4_UI32 size,
+ AP4_IodsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.cpp
index 2d2256d4b..c3e057ae1 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.cpp
@@ -52,14 +52,13 @@ AP4_IpmpDescriptorPointer::AP4_IpmpDescriptorPointer(AP4_UI08 descriptor_id) :
/*----------------------------------------------------------------------
| AP4_IpmpDescriptorPointer::AP4_IpmpDescriptorPointer
+---------------------------------------------------------------------*/
-AP4_IpmpDescriptorPointer::AP4_IpmpDescriptorPointer(AP4_ByteStream& stream,
- AP4_Size header_size,
- AP4_Size payload_size) :
+AP4_IpmpDescriptorPointer::AP4_IpmpDescriptorPointer(AP4_ByteStream& stream,
+ AP4_Size header_size,
+ AP4_Size payload_size) :
AP4_Descriptor(AP4_DESCRIPTOR_TAG_IPMP_DESCRIPTOR_POINTER, header_size, payload_size)
{
stream.ReadUI08(m_DescriptorId);
- if(m_DescriptorId == 0xFF && payload_size >= 5)
- {
+ if (m_DescriptorId == 0xFF && payload_size >= 5) {
stream.ReadUI16(m_DescriptorIdEx);
stream.ReadUI16(m_EsId);
}
@@ -72,8 +71,7 @@ AP4_Result
AP4_IpmpDescriptorPointer::WriteFields(AP4_ByteStream& stream)
{
stream.WriteUI08(m_DescriptorId);
- if(m_DescriptorId == 0xFF)
- {
+ if (m_DescriptorId == 0xFF) {
stream.WriteUI16(m_DescriptorIdEx);
stream.WriteUI16(m_EsId);
}
@@ -87,12 +85,11 @@ AP4_Result
AP4_IpmpDescriptorPointer::Inspect(AP4_AtomInspector& inspector)
{
char info[64];
- AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(), m_PayloadSize);
+ AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
+ GetHeaderSize(),m_PayloadSize);
inspector.StartElement("[IPMP_DescriptorPointer]", info);
inspector.AddField("IPMP_DescriptorID", m_DescriptorId);
- if(m_DescriptorId == 0xFF)
- {
+ if (m_DescriptorId == 0xFF) {
inspector.AddField("IPMP_DescriptorIDEx", m_DescriptorIdEx);
inspector.AddField("IPMP_ES_ID", m_EsId);
}
@@ -119,7 +116,7 @@ AP4_IpmpDescriptor::AP4_IpmpDescriptor(AP4_UI08 descriptor_id, AP4_UI16 ipmps_ty
/*----------------------------------------------------------------------
| AP4_IpmpDescriptor::AP4_IpmpDescriptor
+---------------------------------------------------------------------*/
-AP4_IpmpDescriptor::AP4_IpmpDescriptor(AP4_ByteStream& stream,
+AP4_IpmpDescriptor::AP4_IpmpDescriptor(AP4_ByteStream& stream,
AP4_Size header_size,
AP4_Size payload_size) :
AP4_Descriptor(AP4_DESCRIPTOR_TAG_IPMP_DESCRIPTOR, header_size, payload_size),
@@ -130,40 +127,31 @@ AP4_IpmpDescriptor::AP4_IpmpDescriptor(AP4_ByteStream& stream,
stream.ReadUI08(m_DescriptorId);
stream.ReadUI16(m_IpmpsType);
AP4_SetMemory(m_ToolId, 0, sizeof(m_ToolId));
- if(m_DescriptorId == 0xFF && m_IpmpsType == 0xFFFF)
- {
- AP4_Size fields_size = 3 + 3;
+ if (m_DescriptorId == 0xFF && m_IpmpsType == 0xFFFF) {
+ AP4_Size fields_size = 3+3;
stream.ReadUI16(m_DescriptorIdEx);
stream.Read(m_ToolId, 16);
stream.ReadUI08(m_ControlPointCode);
- if(m_ControlPointCode > 0)
- {
+ if (m_ControlPointCode > 0) {
stream.ReadUI08(m_SequenceCode);
++fields_size;
}
- if(fields_size < payload_size)
- {
- m_Data.SetDataSize(payload_size - fields_size);
- stream.Read(m_Data.UseData(), payload_size - fields_size);
+ if (fields_size < payload_size) {
+ m_Data.SetDataSize(payload_size-fields_size);
+ stream.Read(m_Data.UseData(), payload_size-fields_size);
}
- }
- else if(m_IpmpsType == 0)
- {
- if(payload_size > 3)
- {
+ } else if (m_IpmpsType == 0) {
+ if (payload_size > 3) {
char* buffer = new char[1+payload_size-3];
buffer[payload_size-3] = '\0';
- stream.Read(buffer, payload_size - 3);
- m_Url.Assign(buffer, payload_size - 3);
+ stream.Read(buffer, payload_size-3);
+ m_Url.Assign(buffer, payload_size-3);
delete[] buffer;
}
- }
- else
- {
- if(payload_size > 3)
- {
- m_Data.SetDataSize(payload_size - 3);
- stream.Read(m_Data.UseData(), payload_size - 3);
+ } else {
+ if (payload_size > 3) {
+ m_Data.SetDataSize(payload_size-3);
+ stream.Read(m_Data.UseData(), payload_size-3);
}
}
}
@@ -187,29 +175,22 @@ AP4_IpmpDescriptor::WriteFields(AP4_ByteStream& stream)
{
stream.WriteUI08(m_DescriptorId);
stream.WriteUI16(m_IpmpsType);
- if(m_DescriptorId == 0xFF && m_IpmpsType == 0xFFFF)
- {
+ if (m_DescriptorId == 0xFF && m_IpmpsType == 0xFFFF) {
stream.WriteUI16(m_DescriptorIdEx);
stream.Write(m_ToolId, 16);
stream.WriteUI08(m_ControlPointCode);
- if(m_ControlPointCode > 0)
- {
+ if (m_ControlPointCode > 0) {
stream.WriteUI08(m_SequenceCode);
}
- if(m_Data.GetDataSize())
- {
+ if (m_Data.GetDataSize()) {
stream.Write(m_Data.GetData(), m_Data.GetDataSize());
}
- }
- else if(m_IpmpsType == 0)
- {
- stream.Write(m_Url.GetChars(), m_Url.GetLength() + 1);
- }
- else
- {
+ } else if (m_IpmpsType == 0) {
+ stream.Write(m_Url.GetChars(), m_Url.GetLength()+1);
+ } else {
stream.Write(m_Data.GetData(), m_Data.GetDataSize());
}
-
+
return AP4_SUCCESS;
}
@@ -220,27 +201,21 @@ AP4_Result
AP4_IpmpDescriptor::Inspect(AP4_AtomInspector& inspector)
{
char info[64];
- AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(), m_PayloadSize);
+ AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
+ GetHeaderSize(),m_PayloadSize);
inspector.StartElement("[IPMP_Descriptor]", info);
inspector.AddField("IPMP_DescriptorID", m_DescriptorId);
inspector.AddField("IPMPS_Type", m_IpmpsType, AP4_AtomInspector::HINT_HEX);
- if(m_DescriptorId == 0xFF && m_IpmpsType == 0xFFFF)
- {
+ if (m_DescriptorId == 0xFF && m_IpmpsType == 0xFFFF) {
inspector.AddField("IPMP_DescriptorIDEx", m_DescriptorIdEx);
inspector.AddField("IPMP_ToolID", (const unsigned char*)(&m_ToolId[0]), 16, AP4_AtomInspector::HINT_HEX);
inspector.AddField("controlPointCode", m_ControlPointCode);
- if(m_ControlPointCode > 0)
- {
+ if (m_ControlPointCode > 0) {
inspector.AddField("sequenceCode", m_SequenceCode);
}
- }
- else if(m_IpmpsType == 0)
- {
+ } else if (m_IpmpsType == 0) {
inspector.AddField("URL", m_Url.GetChars());
- }
- else
- {
+ } else {
inspector.AddField("data size", m_Data.GetDataSize());
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.h
index c5c121f70..52370af6d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Ipmp.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - IPMP
+| AP4 - IPMP
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -45,96 +45,63 @@ const AP4_UI08 AP4_DESCRIPTOR_TAG_IPMP_DESCRIPTOR = 0x0B;
/*----------------------------------------------------------------------
| AP4_IpmpDescriptorPointer
+---------------------------------------------------------------------*/
-class AP4_IpmpDescriptorPointer : public AP4_Descriptor
+class AP4_IpmpDescriptorPointer : public AP4_Descriptor
{
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_IpmpDescriptorPointer, AP4_Descriptor)
// methods
AP4_IpmpDescriptorPointer(AP4_UI08 descriptor_id);
- AP4_IpmpDescriptorPointer(AP4_ByteStream& stream,
- AP4_Size header_size,
+ AP4_IpmpDescriptorPointer(AP4_ByteStream& stream,
+ AP4_Size header_size,
AP4_Size payload_size);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
// accessors
- AP4_UI08 GetDescriptorId() const
- {
- return m_DescriptorId;
- }
- AP4_UI16 GetDescriptorIdEx() const
- {
- return m_DescriptorIdEx;
- }
- AP4_UI16 GetEsId() const
- {
- return m_EsId;
- }
+ AP4_UI08 GetDescriptorId() const { return m_DescriptorId; }
+ AP4_UI16 GetDescriptorIdEx() const { return m_DescriptorIdEx; }
+ AP4_UI16 GetEsId() const { return m_EsId; }
private:
// members
- AP4_UI08 m_DescriptorId;
- AP4_UI16 m_DescriptorIdEx;
- AP4_UI16 m_EsId;
+ AP4_UI08 m_DescriptorId;
+ AP4_UI16 m_DescriptorIdEx;
+ AP4_UI16 m_EsId;
};
/*----------------------------------------------------------------------
| AP4_IpmpDescriptor
+---------------------------------------------------------------------*/
-class AP4_IpmpDescriptor : public AP4_Descriptor
-{
+class AP4_IpmpDescriptor : public AP4_Descriptor
+{
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_IpmpDescriptor, AP4_Descriptor)
// methods
AP4_IpmpDescriptor(AP4_UI08 descriptor_id, AP4_UI16 ipmps_type);
- AP4_IpmpDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
+ AP4_IpmpDescriptor(AP4_ByteStream& stream,
+ AP4_Size header_size,
AP4_Size payload_size);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
// accessors
- AP4_UI08 GetDescriptorId() const
- {
- return m_DescriptorId;
- }
- AP4_UI16 GetIpmpsType() const
- {
- return m_IpmpsType;
- }
- AP4_UI16 GetDescriptorIdEx() const
- {
- return m_DescriptorIdEx;
- }
- const AP4_UI08* GetToolId() const
- {
- return m_ToolId;
- }
- AP4_UI08 GetControlPointCode() const
- {
- return m_ControlPointCode;
- }
- AP4_UI08 GetSequenceCode() const
- {
- return m_SequenceCode;
- }
- const AP4_String& GetUrl() const
- {
- return m_Url;
- }
- const AP4_DataBuffer& GetData() const
- {
- return m_Data;
- }
+ AP4_UI08 GetDescriptorId() const { return m_DescriptorId; }
+ AP4_UI16 GetIpmpsType() const { return m_IpmpsType; }
+ AP4_UI16 GetDescriptorIdEx() const { return m_DescriptorIdEx; }
+ const AP4_UI08* GetToolId() const { return m_ToolId; }
+ AP4_UI08 GetControlPointCode() const { return m_ControlPointCode; }
+ AP4_UI08 GetSequenceCode() const { return m_SequenceCode; }
+ const AP4_String& GetUrl() const { return m_Url; }
+ const AP4_DataBuffer& GetData() const { return m_Data; }
void SetData(const unsigned char* data, AP4_Size data_size);
-
+
private:
// members
- AP4_UI08 m_DescriptorId;
+ AP4_UI08 m_DescriptorId;
AP4_UI16 m_IpmpsType;
- AP4_UI16 m_DescriptorIdEx;
+ AP4_UI16 m_DescriptorIdEx;
AP4_UI08 m_ToolId[16];
AP4_UI08 m_ControlPointCode;
AP4_UI08 m_SequenceCode;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.cpp
index 861ed9597..bf85194b1 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - ipro Atoms
+| AP4 - ipro Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -40,14 +40,14 @@
| AP4_IproAtom::Create
+---------------------------------------------------------------------*/
AP4_IproAtom*
-AP4_IproAtom::Create(AP4_Size size,
- AP4_ByteStream& stream,
+AP4_IproAtom::Create(AP4_Size size,
+ AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_IproAtom(size, version, flags, stream, atom_factory);
}
@@ -66,14 +66,12 @@ AP4_IproAtom::AP4_IproAtom(AP4_UI32 size,
stream.ReadUI16(entry_count);
// read all entries
- AP4_LargeSize bytes_available = size - AP4_FULL_ATOM_HEADER_SIZE - 2;
- for(unsigned int i = 0; i < entry_count; i++)
- {
+ AP4_LargeSize bytes_available = size-AP4_FULL_ATOM_HEADER_SIZE-2;
+ for (unsigned int i=0; i<entry_count; i++) {
AP4_Atom* atom;
- if(AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
- bytes_available,
- atom)))
- {
+ if (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
+ bytes_available,
+ atom))) {
atom->SetParent(this);
m_Children.Add(atom);
}
@@ -90,7 +88,7 @@ AP4_IproAtom::WriteFields(AP4_ByteStream& stream)
// entry count
result = stream.WriteUI16(m_Children.ItemCount());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// entries
return m_Children.Apply(AP4_AtomListWriter(stream));
@@ -103,7 +101,7 @@ AP4_Result
AP4_IproAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("entry-count", m_Children.ItemCount());
-
+
// inspect children
m_Children.Apply(AP4_AtomListInspector(inspector));
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.h
index a47724f37..a5c7d0d7f 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IproAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - ipro Atoms
+| AP4 - ipro Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.cpp
index 6f573852e..8cd839eae 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - iSFM Atoms
+| AP4 - iSFM Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -45,8 +45,8 @@ AP4_IsfmAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_IsfmAtom(size, version, flags, stream);
}
@@ -56,7 +56,7 @@ AP4_IsfmAtom::Create(AP4_Size size, AP4_ByteStream& stream)
AP4_IsfmAtom::AP4_IsfmAtom(bool selective_encryption,
AP4_UI08 key_length_indicator,
AP4_UI08 iv_length) :
- AP4_Atom(AP4_ATOM_TYPE_ISFM, AP4_FULL_ATOM_HEADER_SIZE + 3, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_ISFM, AP4_FULL_ATOM_HEADER_SIZE+3, 0, 0),
m_SelectiveEncryption(selective_encryption),
m_KeyIndicatorLength(key_length_indicator),
m_IvLength(iv_length)
@@ -66,7 +66,7 @@ AP4_IsfmAtom::AP4_IsfmAtom(bool selective_encryption,
/*----------------------------------------------------------------------
| AP4_IsfmAtom::AP4_IsfmAtom
+---------------------------------------------------------------------*/
-AP4_IsfmAtom::AP4_IsfmAtom(AP4_UI32 size,
+AP4_IsfmAtom::AP4_IsfmAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -74,7 +74,7 @@ AP4_IsfmAtom::AP4_IsfmAtom(AP4_UI32 size,
{
AP4_UI08 s;
stream.ReadUI08(s);
- m_SelectiveEncryption = ((s & 0x80) != 0);
+ m_SelectiveEncryption = ((s&0x80) != 0);
stream.ReadUI08(m_KeyIndicatorLength);
stream.ReadUI08(m_IvLength);
}
@@ -82,11 +82,11 @@ AP4_IsfmAtom::AP4_IsfmAtom(AP4_UI32 size,
/*----------------------------------------------------------------------
| AP4_IsfmAtom::Clone
+---------------------------------------------------------------------*/
-AP4_Atom*
+AP4_Atom*
AP4_IsfmAtom::Clone()
{
- return new AP4_IsfmAtom(m_SelectiveEncryption,
- m_KeyIndicatorLength,
+ return new AP4_IsfmAtom(m_SelectiveEncryption,
+ m_KeyIndicatorLength,
m_IvLength);
}
@@ -100,15 +100,15 @@ AP4_IsfmAtom::WriteFields(AP4_ByteStream& stream)
// selective encryption
result = stream.WriteUI08(m_SelectiveEncryption ? 0x80 : 0);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// key indicator length
result = stream.WriteUI08(m_KeyIndicatorLength);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// IV length
result = stream.WriteUI08(m_IvLength);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.h
index a1070e6aa..be6ab8382 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsfmAtom.h
@@ -55,22 +55,13 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- bool GetSelectiveEncryption()
- {
- return m_SelectiveEncryption;
- }
- AP4_UI08 GetKeyIndicatorLength()
- {
- return m_KeyIndicatorLength;
- }
- AP4_UI08 GetIvLength()
- {
- return m_IvLength;
- }
+ bool GetSelectiveEncryption() { return m_SelectiveEncryption; }
+ AP4_UI08 GetKeyIndicatorLength() { return m_KeyIndicatorLength; }
+ AP4_UI08 GetIvLength() { return m_IvLength; }
private:
// methods
- AP4_IsfmAtom(AP4_UI32 size,
+ AP4_IsfmAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.cpp
index e10bec51e..686e68e00 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - iSLT Atom
+| AP4 - iSLT Atom
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -41,10 +41,9 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_IsltAtom)
| AP4_IsltAtom::AP4_IsltAtom
+---------------------------------------------------------------------*/
AP4_IsltAtom::AP4_IsltAtom(const AP4_UI08* salt) :
- AP4_Atom(AP4_ATOM_TYPE_ISLT, AP4_ATOM_HEADER_SIZE + 8)
+ AP4_Atom(AP4_ATOM_TYPE_ISLT, AP4_ATOM_HEADER_SIZE+8)
{
- for(unsigned int i = 0; i < 8; i++)
- {
+ for (unsigned int i=0; i<8; i++) {
m_Salt[i] = salt[i];
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.h
index bafe15018..949251acb 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsltAtom.h
@@ -44,9 +44,8 @@ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_IsltAtom, AP4_Atom)
// class methods
- static AP4_IsltAtom* Create(AP4_Size size, AP4_ByteStream& stream)
- {
- if(size != AP4_ATOM_HEADER_SIZE + 8) return NULL;
+ static AP4_IsltAtom* Create(AP4_Size size, AP4_ByteStream& stream) {
+ if (size != AP4_ATOM_HEADER_SIZE+8) return NULL;
return new AP4_IsltAtom(size, stream);
}
@@ -56,10 +55,7 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- const AP4_UI08* GetSalt()
- {
- return m_Salt;
- }
+ const AP4_UI08* GetSalt() { return m_Salt; }
private:
// methods
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.cpp
index 9ceffbc55..569ca4951 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.cpp
@@ -47,15 +47,14 @@
| AP4_IsmaCipher::CreateSampleDecrypter
+---------------------------------------------------------------------*/
AP4_Result
-AP4_IsmaCipher::CreateSampleDecrypter(AP4_ProtectedSampleDescription* sample_description,
- const AP4_UI08* key,
+AP4_IsmaCipher::CreateSampleDecrypter(AP4_ProtectedSampleDescription* sample_description,
+ const AP4_UI08* key,
AP4_Size key_size,
AP4_BlockCipherFactory* block_cipher_factory,
AP4_IsmaCipher*& decrypter)
{
// check parameters
- if(key == NULL || block_cipher_factory == NULL)
- {
+ if (key == NULL || block_cipher_factory == NULL) {
return AP4_ERROR_INVALID_PARAMETERS;
}
decrypter = NULL;
@@ -63,26 +62,26 @@ AP4_IsmaCipher::CreateSampleDecrypter(AP4_ProtectedSampleDescription* sample_des
// create the cipher
AP4_BlockCipher* block_cipher = NULL;
AP4_Result result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::ENCRYPT,
- key,
- key_size,
- block_cipher);
- if(AP4_FAILED(result)) return result;
+ AP4_BlockCipher::ENCRYPT,
+ key,
+ key_size,
+ block_cipher);
+ if (AP4_FAILED(result)) return result;
// get the scheme info atom
AP4_ContainerAtom* schi = sample_description->GetSchemeInfo()->GetSchiAtom();
- if(schi == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (schi == NULL) return AP4_ERROR_INVALID_FORMAT;
// get the cipher params
AP4_IsfmAtom* isfm = AP4_DYNAMIC_CAST(AP4_IsfmAtom, schi->FindChild("iSFM"));
- if(isfm == NULL) return AP4_ERROR_INVALID_FORMAT;
-
+ if (isfm == NULL) return AP4_ERROR_INVALID_FORMAT;
+
// get the salt
AP4_IsltAtom* salt = AP4_DYNAMIC_CAST(AP4_IsltAtom, schi->FindChild("iSLT"));
// instantiate the decrypter
- decrypter = new AP4_IsmaCipher(block_cipher,
- salt ? salt->GetSalt() : NULL,
+ decrypter = new AP4_IsmaCipher(block_cipher,
+ salt?salt->GetSalt():NULL,
isfm->GetIvLength(),
isfm->GetKeyIndicatorLength(),
isfm->GetSelectiveEncryption());
@@ -92,10 +91,10 @@ AP4_IsmaCipher::CreateSampleDecrypter(AP4_ProtectedSampleDescription* sample_des
/*----------------------------------------------------------------------
| AP4_IsmaCrypCipher::AP4_IsmaCipher
+---------------------------------------------------------------------*/
-AP4_IsmaCipher::AP4_IsmaCipher(AP4_BlockCipher* block_cipher,
- const AP4_UI08* salt,
- AP4_UI08 iv_length,
- AP4_UI08 key_indicator_length,
+AP4_IsmaCipher::AP4_IsmaCipher(AP4_BlockCipher* block_cipher,
+ const AP4_UI08* salt,
+ AP4_UI08 iv_length,
+ AP4_UI08 key_indicator_length,
bool selective_encryption) :
m_IvLength(iv_length),
m_KeyIndicatorLength(key_indicator_length),
@@ -105,19 +104,16 @@ AP4_IsmaCipher::AP4_IsmaCipher(AP4_BlockCipher* block_cipher,
// left-align the salt
unsigned char salt_128[AP4_CIPHER_BLOCK_SIZE];
- unsigned int i = 0;
- if(salt)
- {
- for(; i < 8; i++)
- {
+ unsigned int i=0;
+ if (salt) {
+ for (; i<8; i++) {
salt_128[i] = salt[i];
}
}
- for(; i < AP4_CIPHER_BLOCK_SIZE; i++)
- {
+ for (; i<AP4_CIPHER_BLOCK_SIZE; i++) {
salt_128[i] = 0;
}
-
+
// create a cipher
m_Cipher = new AP4_CtrStreamCipher(block_cipher, salt_128, iv_length);
}
@@ -133,21 +129,20 @@ AP4_IsmaCipher::~AP4_IsmaCipher()
/*----------------------------------------------------------------------
| AP4_IsmaCipher::GetDecryptedSampleSize
+---------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_IsmaCipher::GetDecryptedSampleSize(AP4_Sample& sample)
{
AP4_Size isma_header_size = m_KeyIndicatorLength + m_IvLength;
- if(m_SelectiveEncryption)
- {
+ if (m_SelectiveEncryption) {
++isma_header_size;
}
- return sample.GetSize() - isma_header_size;
+ return sample.GetSize()-isma_header_size;
}
/*----------------------------------------------------------------------
| AP4_IsmaCipher::DecryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_IsmaCipher::DecryptSampleData(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out,
const AP4_UI08* /*iv*/)
@@ -157,57 +152,50 @@ AP4_IsmaCipher::DecryptSampleData(AP4_DataBuffer& data_in,
AP4_Size in_size = data_in.GetDataSize();
AP4_Size header_size;
- // default to 0 output
+ // default to 0 output
data_out.SetDataSize(0);
// check the selective encryption flag
- if(in_size < 1) return AP4_ERROR_INVALID_FORMAT;
- if(m_SelectiveEncryption)
- {
- is_encrypted = ((in[0] & 0x80) != 0);
+ if (in_size < 1) return AP4_ERROR_INVALID_FORMAT;
+ if (m_SelectiveEncryption) {
+ is_encrypted = ((in[0]&0x80)!=0);
in++;
}
// check the header size
- header_size = (m_SelectiveEncryption ? 1 : 0) +
- (is_encrypted ? m_KeyIndicatorLength + m_IvLength : 0);
- if(header_size > in_size) return AP4_ERROR_INVALID_FORMAT;
+ header_size = (m_SelectiveEncryption?1:0)+
+ (is_encrypted?m_KeyIndicatorLength+m_IvLength:0);
+ if (header_size > in_size) return AP4_ERROR_INVALID_FORMAT;
// process the sample data
- AP4_Size payload_size = in_size - header_size;
+ AP4_Size payload_size = in_size-header_size;
data_out.SetDataSize(payload_size);
AP4_UI08* out = data_out.UseData();
- if(is_encrypted)
- {
+ if (is_encrypted) {
// get the IV
const AP4_UI08* iv = in;
in += m_IvLength;
// get the key indicator (we only support up to 32 bits)
unsigned int to_read = m_KeyIndicatorLength;
- while(to_read > 4)
- {
+ while (to_read > 4) {
// skip anything above 4 bytes
to_read--;
in++;
}
AP4_UI32 key_indicator = 0;
- while(to_read--)
- {
- key_indicator = (key_indicator << 8) | *in++;
+ while (to_read--) {
+ key_indicator = (key_indicator<<8) | *in++;
header_size++;
}
// we only support key indicator = 0 for now... (TODO)
- if(key_indicator != 0)
- {
+ if (key_indicator != 0) {
return AP4_ERROR_NOT_SUPPORTED;
}
m_Cipher->SetIV(iv);
m_Cipher->ProcessBuffer(in, payload_size, out);
- }
- else
- {
+ } else {
AP4_CopyMemory(out, in, payload_size);
}
@@ -217,14 +205,14 @@ AP4_IsmaCipher::DecryptSampleData(AP4_DataBuffer& data_in,
/*----------------------------------------------------------------------
| AP4_IsmaCipher::EncryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_IsmaCipher::EncryptSampleData(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out,
AP4_UI32 iv)
{
// setup the buffers
const unsigned char* in = data_in.GetData();
- data_out.SetDataSize(data_in.GetDataSize() + 4);
+ data_out.SetDataSize(data_in.GetDataSize()+4);
unsigned char* out = data_out.UseData();
// IV on 4 bytes
@@ -233,7 +221,7 @@ AP4_IsmaCipher::EncryptSampleData(AP4_DataBuffer& data_in,
// encrypt the payload
m_Cipher->SetIV(out);
AP4_Size data_size = data_in.GetDataSize();
- m_Cipher->ProcessBuffer(in, data_size, out + 4);
+ m_Cipher->ProcessBuffer(in, data_size, out+4);
return AP4_SUCCESS;
}
@@ -242,7 +230,7 @@ AP4_IsmaCipher::EncryptSampleData(AP4_DataBuffer& data_in,
| AP4_IsmaTrackDecrypter::Create
+---------------------------------------------------------------------*/
AP4_Result
-AP4_IsmaTrackDecrypter::Create(const AP4_UI08* key,
+AP4_IsmaTrackDecrypter::Create(const AP4_UI08* key,
AP4_Size key_size,
AP4_ProtectedSampleDescription* sample_description,
AP4_SampleEntry* sample_entry,
@@ -253,15 +241,15 @@ AP4_IsmaTrackDecrypter::Create(const AP4_UI08* key,
AP4_IsmaCipher* cipher = NULL;
decrypter = NULL;
AP4_Result result = AP4_IsmaCipher::CreateSampleDecrypter(sample_description,
- key,
- key_size,
- block_cipher_factory,
- cipher);
- if(AP4_FAILED(result)) return result;
+ key,
+ key_size,
+ block_cipher_factory,
+ cipher);
+ if (AP4_FAILED(result)) return result;
// instanciate the object
- decrypter = new AP4_IsmaTrackDecrypter(cipher,
- sample_entry,
+ decrypter = new AP4_IsmaTrackDecrypter(cipher,
+ sample_entry,
sample_description->GetOriginalFormat());
return AP4_SUCCESS;
}
@@ -270,8 +258,8 @@ AP4_IsmaTrackDecrypter::Create(const AP4_UI08* key,
| AP4_IsmaTrackDecrypter::AP4_IsmaTrackDecrypter
+---------------------------------------------------------------------*/
AP4_IsmaTrackDecrypter::AP4_IsmaTrackDecrypter(AP4_IsmaCipher* cipher,
- AP4_SampleEntry* sample_entry,
- AP4_UI32 original_format) :
+ AP4_SampleEntry* sample_entry,
+ AP4_UI32 original_format) :
m_Cipher(cipher),
m_SampleEntry(sample_entry),
m_OriginalFormat(original_format)
@@ -289,7 +277,7 @@ AP4_IsmaTrackDecrypter::~AP4_IsmaTrackDecrypter()
/*----------------------------------------------------------------------
| AP4_IsmaTrackDecrypter::GetProcessedSampleSize
+---------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_IsmaTrackDecrypter::GetProcessedSampleSize(AP4_Sample& sample)
{
return m_Cipher->GetDecryptedSampleSize(sample);
@@ -298,7 +286,7 @@ AP4_IsmaTrackDecrypter::GetProcessedSampleSize(AP4_Sample& sample)
/*----------------------------------------------------------------------
| AP4_IsmaTrackDecrypter::ProcessTrack
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_IsmaTrackDecrypter::ProcessTrack()
{
m_SampleEntry->SetType(m_OriginalFormat);
@@ -309,7 +297,7 @@ AP4_IsmaTrackDecrypter::ProcessTrack()
/*----------------------------------------------------------------------
| AP4_IsmaDecrypter::ProcessSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_IsmaTrackDecrypter::ProcessSample(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out)
{
@@ -319,8 +307,7 @@ AP4_IsmaTrackDecrypter::ProcessSample(AP4_DataBuffer& data_in,
/*----------------------------------------------------------------------
| AP4_IsmaTrackEncrypter
+---------------------------------------------------------------------*/
-class AP4_IsmaTrackEncrypter : public AP4_Processor::TrackHandler
-{
+class AP4_IsmaTrackEncrypter : public AP4_Processor::TrackHandler {
public:
// constructor
AP4_IsmaTrackEncrypter(const char* kms_uri,
@@ -374,16 +361,16 @@ AP4_IsmaTrackEncrypter::~AP4_IsmaTrackEncrypter()
/*----------------------------------------------------------------------
| AP4_IsmaTrackEncrypter::GetProcessedSampleSize
+---------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_IsmaTrackEncrypter::GetProcessedSampleSize(AP4_Sample& sample)
{
- return sample.GetSize() + 4; //fixed header size for now
+ return sample.GetSize()+4; //fixed header size for now
}
/*----------------------------------------------------------------------
| AP4_IsmaTrackEncrypter::ProcessTrack
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_IsmaTrackEncrypter::ProcessTrack()
{
// sinf container
@@ -391,16 +378,16 @@ AP4_IsmaTrackEncrypter::ProcessTrack()
// original format
AP4_FrmaAtom* frma = new AP4_FrmaAtom(m_SampleEntry->GetType());
-
+
// scheme
AP4_SchmAtom* schm = new AP4_SchmAtom(AP4_PROTECTION_SCHEME_TYPE_IAEC, 1);
-
+
// scheme info
AP4_ContainerAtom* schi = new AP4_ContainerAtom(AP4_ATOM_TYPE_SCHI);
AP4_IkmsAtom* ikms = new AP4_IkmsAtom(m_KmsUri.GetChars());
- AP4_IsfmAtom* isfm = new AP4_IsfmAtom(m_Cipher->GetSelectiveEncryption(),
- m_Cipher->GetKeyIndicatorLength(),
- m_Cipher->GetIvLength());
+ AP4_IsfmAtom* isfm = new AP4_IsfmAtom(m_Cipher->GetSelectiveEncryption(),
+ m_Cipher->GetKeyIndicatorLength(),
+ m_Cipher->GetIvLength());
AP4_IsltAtom* islt = new AP4_IsltAtom(m_Cipher->GetCipher()->GetIV());
// populate the schi container
@@ -418,21 +405,21 @@ AP4_IsmaTrackEncrypter::ProcessTrack()
// change the atom type of the sample description
m_SampleEntry->SetType(m_Format);
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_IsmaTrackEncrypter::ProcessSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_IsmaTrackEncrypter::ProcessSample(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out)
{
AP4_Result result = m_Cipher->EncryptSampleData(data_in, data_out, m_Counter);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
- m_Counter += (data_in.GetDataSize() + AP4_CIPHER_BLOCK_SIZE - 1) / AP4_CIPHER_BLOCK_SIZE;
+ m_Counter += (data_in.GetDataSize()+AP4_CIPHER_BLOCK_SIZE-1)/AP4_CIPHER_BLOCK_SIZE;
return AP4_SUCCESS;
}
@@ -440,15 +427,12 @@ AP4_IsmaTrackEncrypter::ProcessSample(AP4_DataBuffer& data_in,
| AP4_IsmaEncryptingProcessor::AP4_IsmaEncryptingProcessor
+---------------------------------------------------------------------*/
AP4_IsmaEncryptingProcessor::AP4_IsmaEncryptingProcessor(const char* kms_uri,
- AP4_BlockCipherFactory* block_cipher_factory) :
+ AP4_BlockCipherFactory* block_cipher_factory) :
m_KmsUri(kms_uri)
{
- if(block_cipher_factory == NULL)
- {
+ if (block_cipher_factory == NULL) {
m_BlockCipherFactory = &AP4_DefaultBlockCipherFactory::Instance;
- }
- else
- {
+ } else {
m_BlockCipherFactory = block_cipher_factory;
}
}
@@ -456,72 +440,66 @@ AP4_IsmaEncryptingProcessor::AP4_IsmaEncryptingProcessor(const char*
/*----------------------------------------------------------------------
| AP4_IsmaEncryptingProcessor:CreateTrackHandler
+---------------------------------------------------------------------*/
-AP4_Processor::TrackHandler*
+AP4_Processor::TrackHandler*
AP4_IsmaEncryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
{
// find the stsd atom
AP4_StsdAtom* stsd = AP4_DYNAMIC_CAST(AP4_StsdAtom, trak->FindChild("mdia/minf/stbl/stsd"));
// avoid tracks with no stsd atom (should not happen)
- if(stsd == NULL) return NULL;
+ if (stsd == NULL) return NULL;
// only look at the first sample description
AP4_SampleEntry* entry = stsd->GetSampleEntry(0);
- if(entry == NULL) return NULL;
-
+ if (entry == NULL) return NULL;
+
// create a handler for this track if we have a key for it and we know
// how to map the type
const AP4_UI08* key;
const AP4_UI08* salt;
AP4_UI32 format = 0;
- if(AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, salt)))
- {
- switch(entry->GetType())
- {
- case AP4_ATOM_TYPE_MP4A:
- format = AP4_ATOM_TYPE_ENCA;
- break;
-
- case AP4_ATOM_TYPE_MP4V:
- case AP4_ATOM_TYPE_AVC1:
- format = AP4_ATOM_TYPE_ENCV;
- break;
-
- default:
- {
- // try to find if this is audio or video
- AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, trak->FindChild("mdia/hdlr"));
- if(hdlr)
- {
- switch(hdlr->GetHandlerType())
- {
- case AP4_HANDLER_TYPE_SOUN:
- format = AP4_ATOM_TYPE_ENCA;
- break;
-
- case AP4_HANDLER_TYPE_VIDE:
- format = AP4_ATOM_TYPE_ENCV;
- break;
+ if (AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, salt))) {
+ switch (entry->GetType()) {
+ case AP4_ATOM_TYPE_MP4A:
+ format = AP4_ATOM_TYPE_ENCA;
+ break;
+
+ case AP4_ATOM_TYPE_MP4V:
+ case AP4_ATOM_TYPE_AVC1:
+ format = AP4_ATOM_TYPE_ENCV;
+ break;
+
+ default: {
+ // try to find if this is audio or video
+ AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, trak->FindChild("mdia/hdlr"));
+ if (hdlr) {
+ switch (hdlr->GetHandlerType()) {
+ case AP4_HANDLER_TYPE_SOUN:
+ format = AP4_ATOM_TYPE_ENCA;
+ break;
+
+ case AP4_HANDLER_TYPE_VIDE:
+ format = AP4_ATOM_TYPE_ENCV;
+ break;
+ }
}
+ break;
}
- break;
- }
}
- if(format)
- {
+ if (format) {
// create the block cipher
AP4_BlockCipher* block_cipher = NULL;
- AP4_Result result = m_BlockCipherFactory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::ENCRYPT,
- key,
- AP4_CIPHER_BLOCK_SIZE,
- block_cipher);
- if(AP4_FAILED(result)) return NULL;
+ AP4_Result result = m_BlockCipherFactory->Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::ENCRYPT,
+ key,
+ AP4_CIPHER_BLOCK_SIZE,
+ block_cipher);
+ if (AP4_FAILED(result)) return NULL;
// create the encrypter
- return new AP4_IsmaTrackEncrypter(m_KmsUri.GetChars(),
- block_cipher,
- salt,
+ return new AP4_IsmaTrackEncrypter(m_KmsUri.GetChars(),
+ block_cipher,
+ salt,
entry,
format);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.h
index 703d3268d..34cde13d8 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4IsmaCryp.h
@@ -49,7 +49,7 @@ class AP4_IsfmAtom;
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_IAEC = AP4_ATOM_TYPE('i', 'A', 'E', 'C');
+const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_IAEC = AP4_ATOM_TYPE('i','A','E','C');
/*----------------------------------------------------------------------
| AP4_IsmaCipher
@@ -59,18 +59,18 @@ class AP4_IsmaCipher : public AP4_SampleDecrypter
public:
// factory
static AP4_Result CreateSampleDecrypter(AP4_ProtectedSampleDescription* sample_description,
- const AP4_UI08* key,
+ const AP4_UI08* key,
AP4_Size key_size,
AP4_BlockCipherFactory* block_cipher_factory,
AP4_IsmaCipher*& decrypter);
// constructor and destructor
- AP4_IsmaCipher(AP4_BlockCipher* block_cipher,
+ AP4_IsmaCipher(AP4_BlockCipher* block_cipher,
const AP4_UI08* salt,
AP4_UI08 iv_length,
AP4_UI08 key_indicator_length,
bool selective_encryption);
- ~AP4_IsmaCipher();
+ ~AP4_IsmaCipher();
AP4_Result EncryptSampleData(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out,
AP4_UI32 offset);
@@ -78,22 +78,10 @@ public:
AP4_DataBuffer& data_out,
const AP4_UI08* iv = NULL);
AP4_Size GetDecryptedSampleSize(AP4_Sample& sample);
- AP4_CtrStreamCipher* GetCipher()
- {
- return m_Cipher;
- }
- AP4_UI08 GetIvLength()
- {
- return m_IvLength;
- }
- AP4_UI08 GetKeyIndicatorLength()
- {
- return m_KeyIndicatorLength;
- }
- bool GetSelectiveEncryption()
- {
- return m_SelectiveEncryption;
- }
+ AP4_CtrStreamCipher* GetCipher() { return m_Cipher; }
+ AP4_UI08 GetIvLength() { return m_IvLength; }
+ AP4_UI08 GetKeyIndicatorLength() { return m_KeyIndicatorLength; }
+ bool GetSelectiveEncryption(){ return m_SelectiveEncryption;}
private:
// members
@@ -106,11 +94,10 @@ private:
/*----------------------------------------------------------------------
| AP4_IsmaTrackDecrypter
+---------------------------------------------------------------------*/
-class AP4_IsmaTrackDecrypter : public AP4_Processor::TrackHandler
-{
+class AP4_IsmaTrackDecrypter : public AP4_Processor::TrackHandler {
public:
// construction
- static AP4_Result Create(const AP4_UI08* key,
+ static AP4_Result Create(const AP4_UI08* key,
AP4_Size key_size,
AP4_ProtectedSampleDescription* sample_description,
AP4_SampleEntry* sample_entry,
@@ -148,10 +135,7 @@ public:
AP4_BlockCipherFactory* block_cipher_factory = NULL);
// accessors
- AP4_ProtectionKeyMap& GetKeyMap()
- {
- return m_KeyMap;
- }
+ AP4_ProtectionKeyMap& GetKeyMap() { return m_KeyMap; }
// methods
virtual AP4_Processor::TrackHandler* CreateTrackHandler(AP4_TrakAtom* trak);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.cpp
index d77329f0c..e8c32b558 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.cpp
@@ -48,8 +48,7 @@ AP4_LinearReader::AP4_LinearReader(AP4_Movie& movie, AP4_Size max_buffer) :
+---------------------------------------------------------------------*/
AP4_LinearReader::~AP4_LinearReader()
{
- for(unsigned int i = 0; i < m_Trackers.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<m_Trackers.ItemCount(); i++) {
delete m_Trackers[i];
}
}
@@ -57,16 +56,16 @@ AP4_LinearReader::~AP4_LinearReader()
/*----------------------------------------------------------------------
| AP4_LinearReader::EnableTrack
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_LinearReader::EnableTrack(AP4_UI32 track_id)
{
// check if we don't already have this
- if(FindTracker(track_id)) return AP4_SUCCESS;
+ if (FindTracker(track_id)) return AP4_SUCCESS;
// find the track in the movie
AP4_Track* track = m_Movie.GetTrack(track_id);
- if(track == NULL) return AP4_ERROR_NO_SUCH_ITEM;
-
+ if (track == NULL) return AP4_ERROR_NO_SUCH_ITEM;
+
// create a new entry for the track
return m_Trackers.Append(new Tracker(track));
}
@@ -74,32 +73,30 @@ AP4_LinearReader::EnableTrack(AP4_UI32 track_id)
/*----------------------------------------------------------------------
| AP4_LinearReader::SetSampleIndex
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_LinearReader::SetSampleIndex(AP4_UI32 track_id, AP4_UI32 sample_index)
{
Tracker* tracker = FindTracker(track_id);
- if(tracker == NULL) return AP4_ERROR_INVALID_PARAMETERS;
+ if (tracker == NULL) return AP4_ERROR_INVALID_PARAMETERS;
assert(tracker->m_Track);
delete tracker->m_NextSample;
tracker->m_NextSample = NULL;
- if(sample_index >= tracker->m_Track->GetSampleCount())
- {
+ if (sample_index >= tracker->m_Track->GetSampleCount()) {
return AP4_ERROR_OUT_OF_RANGE;
}
tracker->m_Eos = false;
tracker->m_NextSampleIndex = sample_index;
-
+
// empty any queued samples
- for(AP4_List<SampleBuffer>::Item* item = tracker->m_Samples.FirstItem();
- item;
- item = item->GetNext())
- {
+ for (AP4_List<SampleBuffer>::Item* item = tracker->m_Samples.FirstItem();
+ item;
+ item = item->GetNext()) {
SampleBuffer* buffer = item->GetData();
m_BufferFullness -= buffer->m_Sample->GetSize();
delete buffer;
}
tracker->m_Samples.Clear();
-
+
return AP4_SUCCESS;
}
@@ -110,30 +107,25 @@ AP4_Result
AP4_LinearReader::Advance()
{
// first, check if we have space to advance
- if(m_BufferFullness >= m_MaxBufferFullness)
- {
+ if (m_BufferFullness >= m_MaxBufferFullness) {
return AP4_ERROR_NOT_ENOUGH_SPACE;
}
-
+
AP4_UI64 min_offset = (AP4_UI64)(-1);
Tracker* next_tracker = NULL;
- for(unsigned int i = 0; i < m_Trackers.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<m_Trackers.ItemCount(); i++) {
Tracker* tracker = m_Trackers[i];
- if(tracker->m_Eos) continue;
-
+ if (tracker->m_Eos) continue;
+
// get the next sample unless we have it already
- if(tracker->m_NextSample == NULL)
- {
- if(tracker->m_NextSampleIndex >= tracker->m_Track->GetSampleCount())
- {
+ if (tracker->m_NextSample == NULL) {
+ if (tracker->m_NextSampleIndex >= tracker->m_Track->GetSampleCount()) {
tracker->m_Eos = true;
continue;
}
tracker->m_NextSample = new AP4_Sample();
AP4_Result result = tracker->m_Track->GetSample(tracker->m_NextSampleIndex, *tracker->m_NextSample);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
tracker->m_Eos = true;
delete tracker->m_NextSample;
tracker->m_NextSample = NULL;
@@ -141,49 +133,45 @@ AP4_LinearReader::Advance()
}
}
assert(tracker->m_NextSample);
-
+
AP4_UI64 offset = tracker->m_NextSample->GetOffset();
- if(offset < min_offset)
- {
+ if (offset < min_offset) {
min_offset = offset;
next_tracker = tracker;
}
}
-
- if(next_tracker)
- {
+
+ if (next_tracker) {
// read the sample into a buffer
assert(next_tracker->m_NextSample);
SampleBuffer* buffer = new SampleBuffer(next_tracker->m_NextSample);
AP4_Result result = buffer->m_Sample->ReadData(buffer->m_Data);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// add the buffer to the queue
next_tracker->m_Samples.Add(buffer);
m_BufferFullness += next_tracker->m_NextSample->GetSize();
- if(m_BufferFullness > m_BufferFullnessPeak)
- {
+ if (m_BufferFullness > m_BufferFullnessPeak) {
m_BufferFullnessPeak = m_BufferFullness;
}
next_tracker->m_NextSample = NULL;
next_tracker->m_NextSampleIndex++;
return AP4_SUCCESS;
- }
-
- return AP4_ERROR_EOS;
+ }
+
+ return AP4_ERROR_EOS;
}
/*----------------------------------------------------------------------
| AP4_LinearReader::PopSample
+---------------------------------------------------------------------*/
bool
-AP4_LinearReader::PopSample(Tracker* tracker,
- AP4_Sample& sample,
+AP4_LinearReader::PopSample(Tracker* tracker,
+ AP4_Sample& sample,
AP4_DataBuffer& sample_data)
{
SampleBuffer* head = NULL;
- if(AP4_SUCCEEDED(tracker->m_Samples.PopHead(head)))
- {
+ if (AP4_SUCCEEDED(tracker->m_Samples.PopHead(head))) {
assert(head->m_Sample);
sample = *head->m_Sample;
sample_data.SetData(head->m_Data.GetData(), head->m_Data.GetDataSize());
@@ -192,89 +180,81 @@ AP4_LinearReader::PopSample(Tracker* tracker,
delete head;
return true;
}
-
+
return false;
}
/*----------------------------------------------------------------------
| AP4_LinearReader::ReadNextSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_LinearReader::ReadNextSample(AP4_UI32 track_id,
AP4_Sample& sample,
AP4_DataBuffer& sample_data)
{
- if(m_Trackers.ItemCount() == 0)
- {
+ if (m_Trackers.ItemCount() == 0) {
return AP4_ERROR_NO_SUCH_ITEM;
}
-
+
// look for a sample from a specific track
Tracker* tracker = FindTracker(track_id);
- if(tracker == NULL) return AP4_ERROR_INVALID_PARAMETERS;
- for(;;)
- {
- if(tracker->m_Eos) return AP4_ERROR_EOS;
+ if (tracker == NULL) return AP4_ERROR_INVALID_PARAMETERS;
+ for(;;) {
+ if (tracker->m_Eos) return AP4_ERROR_EOS;
// pop a sample if we can
- if(PopSample(tracker, sample, sample_data)) return AP4_SUCCESS;
+ if (PopSample(tracker, sample, sample_data)) return AP4_SUCCESS;
AP4_Result result = Advance();
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
-
+
return AP4_ERROR_EOS;
}
/*----------------------------------------------------------------------
| AP4_LinearReader::ReadNextSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_LinearReader::ReadNextSample(AP4_Sample& sample,
AP4_DataBuffer& sample_data,
AP4_UI32& track_id)
{
- if(m_Trackers.ItemCount() == 0)
- {
+ if (m_Trackers.ItemCount() == 0) {
track_id = 0;
return AP4_ERROR_NO_SUCH_ITEM;
}
-
+
// return the oldest buffered sample, if any
AP4_UI64 min_offset = (AP4_UI64)(-1);
Tracker* next_tracker = NULL;
- for(;;)
- {
- for(unsigned int i = 0; i < m_Trackers.ItemCount(); i++)
- {
+ for (;;) {
+ for (unsigned int i=0; i<m_Trackers.ItemCount(); i++) {
Tracker* tracker = m_Trackers[i];
- if(tracker->m_Eos) continue;
-
+ if (tracker->m_Eos) continue;
+
AP4_List<SampleBuffer>::Item* item = tracker->m_Samples.FirstItem();
- if(item)
- {
+ if (item) {
AP4_UI64 offset = item->GetData()->m_Sample->GetOffset();
- if(offset < min_offset)
- {
+ if (offset < min_offset) {
min_offset = offset;
next_tracker = tracker;
}
}
}
-
+
// return the sample if we have found a tracker
- if(next_tracker)
- {
+ if (next_tracker) {
PopSample(next_tracker, sample, sample_data);
track_id = next_tracker->m_Track->GetId();
return AP4_SUCCESS;
}
-
+
// nothing found, read one more sample
AP4_Result result = Advance();
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
-
+
return AP4_ERROR_EOS;
}
@@ -284,11 +264,10 @@ AP4_LinearReader::ReadNextSample(AP4_Sample& sample,
AP4_LinearReader::Tracker*
AP4_LinearReader::FindTracker(AP4_UI32 track_id)
{
- for(unsigned int i = 0; i < m_Trackers.ItemCount(); i++)
- {
- if(m_Trackers[i]->m_Track->GetId() == track_id) return m_Trackers[i];
+ for (unsigned int i=0; i<m_Trackers.ItemCount(); i++) {
+ if (m_Trackers[i]->m_Track->GetId() == track_id) return m_Trackers[i];
}
-
+
// not found
return NULL;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.h
index d5dec5cb3..7ebeff4f7 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4LinearReader.h
@@ -48,81 +48,69 @@ class AP4_Track;
const unsigned int AP4_LINEAR_READER_INITIALIZED = 1;
const unsigned int AP4_LINEAR_READER_FLAG_EOS = 2;
-const unsigned int AP4_LINEAR_READER_DEFAULT_BUFFER_SIZE = 4096 * 1024;
+const unsigned int AP4_LINEAR_READER_DEFAULT_BUFFER_SIZE = 4096*1024;
/*----------------------------------------------------------------------
| AP4_LinearReader
+---------------------------------------------------------------------*/
-class AP4_LinearReader
-{
+class AP4_LinearReader {
public:
- AP4_LinearReader(AP4_Movie& movie, AP4_Size max_buffer = AP4_LINEAR_READER_DEFAULT_BUFFER_SIZE);
- ~AP4_LinearReader();
-
+ AP4_LinearReader(AP4_Movie& movie, AP4_Size max_buffer=AP4_LINEAR_READER_DEFAULT_BUFFER_SIZE);
+ ~AP4_LinearReader();
+
AP4_Result EnableTrack(AP4_UI32 track_id);
/**
* Read the next sample in storage order, from any track.
* track_id is updated to reflect the track from which the sample was read.
*/
- AP4_Result ReadNextSample(AP4_Sample& sample,
+ AP4_Result ReadNextSample(AP4_Sample& sample,
AP4_DataBuffer& sample_data,
AP4_UI32& track_id);
/**
* Read the next sample in storage order from a specific track.
*/
AP4_Result ReadNextSample(AP4_UI32 track_id,
- AP4_Sample& sample,
+ AP4_Sample& sample,
AP4_DataBuffer& sample_data);
-
+
AP4_Result SetSampleIndex(AP4_UI32 track_id, AP4_UI32 sample_index);
-
+
// accessors
- AP4_Size GetBufferFullness()
- {
- return m_BufferFullness;
- }
-
+ AP4_Size GetBufferFullness() { return m_BufferFullness; }
+
private:
- class SampleBuffer
- {
+ class SampleBuffer {
public:
SampleBuffer(AP4_Sample* sample) : m_Sample(sample) {}
- ~SampleBuffer()
- {
- delete m_Sample;
- }
+ ~SampleBuffer() { delete m_Sample; }
AP4_Sample* m_Sample;
AP4_DataBuffer m_Data;
};
- class Tracker
- {
+ class Tracker {
public:
Tracker(AP4_Track* track) :
m_Eos(false),
- m_Track(track),
+ m_Track(track),
m_NextSample(NULL),
m_NextSampleIndex(0) {}
- Tracker(const Tracker& other) :
+ Tracker(const Tracker& other) :
m_Eos(other.m_Eos),
m_Track(other.m_Track),
m_NextSample(NULL),
m_NextSampleIndex(other.m_NextSampleIndex) {} // don't copy samples
- ~Tracker()
- {
- m_Samples.DeleteReferences();
- }
+ ~Tracker() { m_Samples.DeleteReferences(); }
bool m_Eos;
AP4_Track* m_Track;
AP4_Sample* m_NextSample;
AP4_Ordinal m_NextSampleIndex;
AP4_List<SampleBuffer> m_Samples;
};
-
+
// methods
Tracker* FindTracker(AP4_UI32 track_id);
AP4_Result Advance();
bool PopSample(Tracker* tracker, AP4_Sample& sample, AP4_DataBuffer& sample_data);
-
+
// members
AP4_Movie& m_Movie;
AP4_Array<Tracker*> m_Trackers;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4List.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4List.h
index 84891b743..d6a28cc63 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4List.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4List.h
@@ -43,16 +43,16 @@ template <typename T> class AP4_List;
/*----------------------------------------------------------------------
| AP4_List
+---------------------------------------------------------------------*/
-template <typename T>
-class AP4_List
+template <typename T>
+class AP4_List
{
public:
// types
- class Item
+ class Item
{
public:
// types
- class Operator
+ class Operator
{
public:
// methods
@@ -60,7 +60,7 @@ public:
virtual AP4_Result Action(T* data) const = 0;
};
- class Finder
+ class Finder
{
public:
// methods
@@ -70,19 +70,10 @@ public:
// methods
Item(T* data) : m_Data(data), m_Next(0), m_Prev(0) {}
- ~Item() {}
- Item* GetNext()
- {
- return m_Next;
- }
- Item* GetPrev()
- {
- return m_Prev;
- }
- T* GetData()
- {
- return m_Data;
- }
+ ~Item() {}
+ Item* GetNext() { return m_Next; }
+ Item* GetPrev() { return m_Prev; }
+ T* GetData() { return m_Data; }
private:
// members
@@ -95,7 +86,7 @@ public:
};
// methods
- AP4_List<T>(): m_ItemCount(0), m_Head(0), m_Tail(0) {}
+ AP4_List<T>(): m_ItemCount(0), m_Head(0), m_Tail(0) {}
virtual ~AP4_List<T>();
AP4_Result Clear();
AP4_Result Add(T* data);
@@ -111,29 +102,20 @@ public:
AP4_Result Find(const typename Item::Finder& finder, T*& data) const;
AP4_Result ReverseFind(const typename Item::Finder& finder, T*& data) const;
AP4_Result DeleteReferences();
- AP4_Cardinal ItemCount() const
- {
- return m_ItemCount;
- }
- Item* FirstItem() const
- {
- return m_Head;
- }
- Item* LastItem() const
- {
- return m_Tail;
- }
-
+ AP4_Cardinal ItemCount() const { return m_ItemCount; }
+ Item* FirstItem() const { return m_Head; }
+ Item* LastItem() const { return m_Tail; }
+
protected:
// members
AP4_Cardinal m_ItemCount;
Item* m_Head;
Item* m_Tail;
-
+
private:
- // these cannot be used
+ // these cannot be used
AP4_List<T>(const AP4_List<T>&);
- AP4_List<T>& operator=(const AP4_List<T>&);
+ AP4_List<T>& operator=(const AP4_List<T>&);
};
/*----------------------------------------------------------------------
@@ -154,19 +136,18 @@ AP4_Result
AP4_List<T>::Clear()
{
Item* item = m_Head;
-
- while(item)
- {
+
+ while (item) {
Item* next = item->m_Next;
delete item;
item = next;
}
m_ItemCount = 0;
m_Head = m_Tail = NULL;
-
+
return AP4_SUCCESS;
}
-
+
/*----------------------------------------------------------------------
| AP4_List<T>::Add
+---------------------------------------------------------------------*/
@@ -186,15 +167,12 @@ AP4_Result
AP4_List<T>::Add(Item* item)
{
// add element at the tail
- if(m_Tail)
- {
+ if (m_Tail) {
item->m_Prev = m_Tail;
item->m_Next = NULL;
m_Tail->m_Next = item;
m_Tail = item;
- }
- else
- {
+ } else {
m_Head = item;
m_Tail = item;
item->m_Next = NULL;
@@ -203,7 +181,7 @@ AP4_List<T>::Add(Item* item)
// one more item in the list now
m_ItemCount++;
-
+
return AP4_SUCCESS;
}
@@ -216,38 +194,27 @@ AP4_List<T>::Remove(T* data)
{
Item* item = m_Head;
- while(item)
- {
- if(item->m_Data == data)
- {
+ while (item) {
+ if (item->m_Data == data) {
// delete item
- if(item->m_Prev)
- {
+ if (item->m_Prev) {
// item is not the head
- if(item->m_Next)
- {
+ if (item->m_Next) {
// item is not the tail
item->m_Next->m_Prev = item->m_Prev;
item->m_Prev->m_Next = item->m_Next;
- }
- else
- {
+ } else {
// item is the tail
m_Tail = item->m_Prev;
m_Tail->m_Next = NULL;
}
- }
- else
- {
+ } else {
// item is the head
m_Head = item->m_Next;
- if(m_Head)
- {
+ if (m_Head) {
// item is not the tail
m_Head->m_Prev = NULL;
- }
- else
- {
+ } else {
// item is also the tail
m_Tail = NULL;
}
@@ -263,7 +230,7 @@ AP4_List<T>::Remove(T* data)
}
item = item->m_Next;
}
-
+
return AP4_ERROR_NO_SUCH_ITEM;
}
@@ -276,36 +243,27 @@ AP4_List<T>::Insert(Item* where, T* data)
{
Item* item = new Item(data);
- if(where == NULL)
- {
+ if (where == NULL) {
// insert as the head
- if(m_Head)
- {
+ if (m_Head) {
// replace the current head
item->m_Prev = NULL;
item->m_Next = m_Head;
m_Head->m_Prev = item;
m_Head = item;
- }
- else
- {
+ } else {
// this item becomes the head and tail
m_Head = item;
m_Tail = item;
item->m_Next = NULL;
item->m_Prev = NULL;
}
- }
- else
- {
+ } else {
// insert after the 'where' item
- if(where == m_Tail)
- {
+ if (where == m_Tail) {
// add the item at the end
return Add(item);
- }
- else
- {
+ } else {
// update the links
item->m_Prev = where;
item->m_Next = where->m_Next;
@@ -329,14 +287,11 @@ AP4_List<T>::Get(AP4_Ordinal idx, T*& data) const
{
Item* item = m_Head;
- if(idx < m_ItemCount)
- {
- while(idx--) item = item->m_Next;
+ if (idx < m_ItemCount) {
+ while (idx--) item = item->m_Next;
data = item->m_Data;
return AP4_SUCCESS;
- }
- else
- {
+ } else {
data = NULL;
return AP4_ERROR_NO_SUCH_ITEM;
}
@@ -350,8 +305,7 @@ AP4_Result
AP4_List<T>::PopHead(T*& data)
{
// check that we have at least one item
- if(m_Head == NULL)
- {
+ if (m_Head == NULL) {
return AP4_ERROR_LIST_EMPTY;
}
@@ -359,12 +313,9 @@ AP4_List<T>::PopHead(T*& data)
data = m_Head->m_Data;
Item* head = m_Head;
m_Head = m_Head->m_Next;
- if(m_Head)
- {
+ if (m_Head) {
m_Head->m_Prev = NULL;
- }
- else
- {
+ } else {
m_Tail = NULL;
}
@@ -373,7 +324,7 @@ AP4_List<T>::PopHead(T*& data)
// one less item in the list now
m_ItemCount--;
-
+
return AP4_SUCCESS;
}
@@ -381,14 +332,13 @@ AP4_List<T>::PopHead(T*& data)
| AP4_List<T>::Apply
+---------------------------------------------------------------------*/
template <typename T>
-inline
+inline
AP4_Result
AP4_List<T>::Apply(const typename Item::Operator& op) const
{
Item* item = m_Head;
-
- while(item)
- {
+
+ while (item) {
op.Action(item->m_Data);
item = item->m_Next;
}
@@ -400,17 +350,16 @@ AP4_List<T>::Apply(const typename Item::Operator& op) const
| AP4_List<T>::ApplyUntilFailure
+---------------------------------------------------------------------*/
template <typename T>
-inline
+inline
AP4_Result
AP4_List<T>::ApplyUntilFailure(const typename Item::Operator& op) const
{
Item* item = m_Head;
-
- while(item)
- {
+
+ while (item) {
AP4_Result result;
result = op.Action(item->m_Data);
- if(result != AP4_SUCCESS) return result;
+ if (result != AP4_SUCCESS) return result;
item = item->m_Next;
}
@@ -421,17 +370,16 @@ AP4_List<T>::ApplyUntilFailure(const typename Item::Operator& op) const
| AP4_List<T>::ApplyUntilSuccess
+---------------------------------------------------------------------*/
template <typename T>
-inline
+inline
AP4_Result
AP4_List<T>::ApplyUntilSuccess(const typename Item::Operator& op) const
{
Item* item = m_Head;
-
- while(item)
- {
+
+ while (item) {
AP4_Result result;
result = op.Action(item->m_Data);
- if(result == AP4_SUCCESS) return AP4_SUCCESS;
+ if (result == AP4_SUCCESS) return AP4_SUCCESS;
item = item->m_Next;
}
@@ -442,16 +390,14 @@ AP4_List<T>::ApplyUntilSuccess(const typename Item::Operator& op) const
| AP4_List<T>::ReverseApply
+---------------------------------------------------------------------*/
template <typename T>
-inline
+inline
AP4_Result
AP4_List<T>::ReverseApply(const typename Item::Operator& op) const
{
Item* item = m_Tail;
-
- while(item)
- {
- if(op.Action(item->m_Data) != AP4_SUCCESS)
- {
+
+ while (item) {
+ if (op.Action(item->m_Data) != AP4_SUCCESS) {
return AP4_ERROR_LIST_OPERATION_ABORTED;
}
item = item->m_Prev;
@@ -464,16 +410,14 @@ AP4_List<T>::ReverseApply(const typename Item::Operator& op) const
| AP4_List<T>::Find
+---------------------------------------------------------------------*/
template <typename T>
-inline
+inline
AP4_Result
AP4_List<T>::Find(const typename Item::Finder& finder, T*& data) const
{
Item* item = m_Head;
-
- while(item)
- {
- if(finder.Test(item->m_Data) == AP4_SUCCESS)
- {
+
+ while (item) {
+ if (finder.Test(item->m_Data) == AP4_SUCCESS) {
data = item->m_Data;
return AP4_SUCCESS;
}
@@ -488,16 +432,14 @@ AP4_List<T>::Find(const typename Item::Finder& finder, T*& data) const
| AP4_List<T>::ReverseFind
+---------------------------------------------------------------------*/
template <typename T>
-inline
+inline
AP4_Result
AP4_List<T>::ReverseFind(const typename Item::Finder& finder, T*& data) const
{
Item* item = m_Tail;
-
- while(item)
- {
- if(finder.Test(item->m_Data) == AP4_SUCCESS)
- {
+
+ while (item) {
+ if (finder.Test(item->m_Data) == AP4_SUCCESS) {
data = item->m_Data;
return AP4_SUCCESS;
}
@@ -512,14 +454,13 @@ AP4_List<T>::ReverseFind(const typename Item::Finder& finder, T*& data) const
| AP4_List<T>::DeleteReferences
+---------------------------------------------------------------------*/
template <typename T>
-inline
+inline
AP4_Result
AP4_List<T>::DeleteReferences()
{
Item* item = m_Head;
-
- while(item)
- {
+
+ while (item) {
Item* next = item->m_Next;
delete item->m_Data;
delete item;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.cpp
index 86b197237..c4464f5df 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.cpp
@@ -60,12 +60,12 @@ class AP4_MarlinIpmpAtomTypeHandler : public AP4_AtomFactory::TypeHandler
public:
// constructor
AP4_MarlinIpmpAtomTypeHandler(AP4_AtomFactory* atom_factory) :
- m_AtomFactory(atom_factory) {}
- virtual AP4_Result CreateAtom(AP4_Atom::Type type,
- AP4_UI32 size,
- AP4_ByteStream& stream,
- AP4_Atom::Type context,
- AP4_Atom*& atom);
+ m_AtomFactory(atom_factory) {}
+ virtual AP4_Result CreateAtom(AP4_Atom::Type type,
+ AP4_UI32 size,
+ AP4_ByteStream& stream,
+ AP4_Atom::Type context,
+ AP4_Atom*& atom);
private:
// members
@@ -82,8 +82,7 @@ public:
static AP4_MarlinIpmpAtomFactory Instance;
// constructor
- AP4_MarlinIpmpAtomFactory()
- {
+ AP4_MarlinIpmpAtomFactory() {
AddTypeHandler(new AP4_MarlinIpmpAtomTypeHandler(this));
}
};
@@ -96,25 +95,24 @@ AP4_MarlinIpmpAtomFactory AP4_MarlinIpmpAtomFactory::Instance;
/*----------------------------------------------------------------------
| AP4_MarlinIpmpAtomTypeHandler::CreateAtom
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MarlinIpmpAtomTypeHandler::CreateAtom(AP4_Atom::Type type,
- AP4_UI32 size,
- AP4_ByteStream& stream,
- AP4_Atom::Type /*context*/,
- AP4_Atom*& atom)
+ AP4_UI32 size,
+ AP4_ByteStream& stream,
+ AP4_Atom::Type /*context*/,
+ AP4_Atom*& atom)
{
- switch(type)
- {
- case AP4_ATOM_TYPE_SATR:
- atom = AP4_ContainerAtom::Create(type, size, false, false, stream, *m_AtomFactory);
- break;
-
- case AP4_ATOM_TYPE_STYP:
- atom = new AP4_NullTerminatedStringAtom(type, size, stream);
- break;
+ switch (type) {
+ case AP4_ATOM_TYPE_SATR:
+ atom = AP4_ContainerAtom::Create(type, size, false, false, stream, *m_AtomFactory);
+ break;
+
+ case AP4_ATOM_TYPE_STYP:
+ atom = new AP4_NullTerminatedStringAtom(type, size, stream);
+ break;
- default:
- atom = NULL;
+ default:
+ atom = NULL;
}
return atom ? AP4_SUCCESS : AP4_FAILURE;
@@ -123,254 +121,222 @@ AP4_MarlinIpmpAtomTypeHandler::CreateAtom(AP4_Atom::Type type,
/*----------------------------------------------------------------------
| AP4_MarlinIpmpParser:Parse
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MarlinIpmpParser::Parse(AP4_AtomParent& top_level,
+AP4_Result
+AP4_MarlinIpmpParser::Parse(AP4_AtomParent& top_level,
AP4_ByteStream& stream,
AP4_List<SinfEntry>& sinf_entries,
bool remove_od_data)
{
// check the file type
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
- if(ftyp == NULL ||
- (ftyp->GetMajorBrand() != AP4_MARLIN_BRAND_MGSV && !ftyp->HasCompatibleBrand(AP4_MARLIN_BRAND_MGSV)))
- {
+ if (ftyp == NULL ||
+ (ftyp->GetMajorBrand() != AP4_MARLIN_BRAND_MGSV && !ftyp->HasCompatibleBrand(AP4_MARLIN_BRAND_MGSV))) {
return AP4_ERROR_INVALID_FORMAT;
}
-
+
// check the initial object descriptor and get the OD Track ID
AP4_IodsAtom* iods = AP4_DYNAMIC_CAST(AP4_IodsAtom, top_level.FindChild("moov/iods"));
AP4_UI32 od_track_id = 0;
- if(iods == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (iods == NULL) return AP4_ERROR_INVALID_FORMAT;
const AP4_ObjectDescriptor* od = iods->GetObjectDescriptor();
- if(od == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (od == NULL) return AP4_ERROR_INVALID_FORMAT;
AP4_EsIdIncDescriptor* es_id_inc = AP4_DYNAMIC_CAST(AP4_EsIdIncDescriptor, od->FindSubDescriptor(AP4_DESCRIPTOR_TAG_ES_ID_INC));
- if(es_id_inc == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (es_id_inc == NULL) return AP4_ERROR_INVALID_FORMAT;
od_track_id = es_id_inc->GetTrackId();
-
+
// find the track pointed to by the descriptor
AP4_MoovAtom* moov = AP4_DYNAMIC_CAST(AP4_MoovAtom, top_level.GetChild(AP4_ATOM_TYPE_MOOV));
- if(moov == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (moov == NULL) return AP4_ERROR_INVALID_FORMAT;
AP4_TrakAtom* od_trak = NULL;
- for(AP4_List<AP4_TrakAtom>::Item* trak_item = moov->GetTrakAtoms().FirstItem();
- trak_item;
- trak_item = trak_item->GetNext())
- {
+ for (AP4_List<AP4_TrakAtom>::Item* trak_item = moov->GetTrakAtoms().FirstItem();
+ trak_item;
+ trak_item = trak_item->GetNext()) {
AP4_TrakAtom* trak = trak_item->GetData();
- if(trak)
- {
- if(trak->GetId() == od_track_id)
- {
+ if (trak) {
+ if (trak->GetId() == od_track_id) {
od_trak = trak;
- }
- else
- {
+ } else {
sinf_entries.Add(new SinfEntry(trak->GetId(), NULL));
}
}
}
- // check that we have found the OD track
- if(od_trak == NULL) return AP4_ERROR_INVALID_FORMAT;
+ // check that we have found the OD track
+ if (od_trak == NULL) return AP4_ERROR_INVALID_FORMAT;
// look for the 'mpod' trak references
AP4_TrefTypeAtom* track_references;
track_references = AP4_DYNAMIC_CAST(AP4_TrefTypeAtom, od_trak->FindChild("tref/mpod"));
- if(track_references == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (track_references == NULL) return AP4_ERROR_INVALID_FORMAT;
// create an AP4_Track object from the trak atom and check that it has samples
AP4_Track* od_track = new AP4_Track(*od_trak, stream, 0);
- if(od_track->GetSampleCount() < 1)
- {
+ if (od_track->GetSampleCount() < 1) {
delete od_track;
return AP4_ERROR_INVALID_FORMAT;
}
-
+
// get the first sample (in this version, we only look at a single OD command)
AP4_Sample od_sample;
AP4_Result result = od_track->GetSample(0, od_sample);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
delete od_track;
return AP4_ERROR_INVALID_FORMAT;
}
-
+
// adapt the sample data into a byte stream for parsing
AP4_DataBuffer sample_data;
od_sample.ReadData(sample_data);
AP4_MemoryByteStream* sample_stream = new AP4_MemoryByteStream(sample_data);
-
- // look for one ObjectDescriptorUpdate command and
+
+ // look for one ObjectDescriptorUpdate command and
// one IPMP_DescriptorUpdate command
AP4_DescriptorUpdateCommand* od_update = NULL;
AP4_DescriptorUpdateCommand* ipmp_update = NULL;
- do
- {
+ do {
AP4_Command* command = NULL;
result = AP4_CommandFactory::CreateCommandFromStream(*sample_stream, command);
- if(AP4_SUCCEEDED(result))
- {
+ if (AP4_SUCCEEDED(result)) {
// found a command in the sample, check the type
- switch(command->GetTag())
- {
- case AP4_COMMAND_TAG_OBJECT_DESCRIPTOR_UPDATE:
- if(od_update == NULL)
- {
+ switch (command->GetTag()) {
+ case AP4_COMMAND_TAG_OBJECT_DESCRIPTOR_UPDATE:
+ if (od_update == NULL) {
od_update = AP4_DYNAMIC_CAST(AP4_DescriptorUpdateCommand, command);
}
break;
-
- case AP4_COMMAND_TAG_IPMP_DESCRIPTOR_UPDATE:
- if(ipmp_update == NULL)
- {
+
+ case AP4_COMMAND_TAG_IPMP_DESCRIPTOR_UPDATE:
+ if (ipmp_update == NULL) {
ipmp_update = AP4_DYNAMIC_CAST(AP4_DescriptorUpdateCommand, command);
}
break;
- default:
+ default:
break;
}
}
- }
- while(AP4_SUCCEEDED(result));
+ } while (AP4_SUCCEEDED(result));
sample_stream->Release();
sample_stream = NULL;
-
+
// check that we have what we need
- if(od_update == NULL || ipmp_update == NULL)
- {
+ if (od_update == NULL || ipmp_update == NULL) {
delete od_track;
return AP4_ERROR_INVALID_FORMAT;
}
-
+
// process all the object descriptors in the od update
- for(AP4_List<AP4_Descriptor>::Item* od_item = od_update->GetDescriptors().FirstItem();
- od_item;
- od_item = od_item->GetNext())
- {
+ for (AP4_List<AP4_Descriptor>::Item* od_item = od_update->GetDescriptors().FirstItem();
+ od_item;
+ od_item = od_item->GetNext()) {
od = AP4_DYNAMIC_CAST(AP4_ObjectDescriptor, od_item->GetData());
- if(od == NULL) continue;
+ if (od == NULL) continue;
// find which track this od references
AP4_EsIdRefDescriptor* es_id_ref;
es_id_ref = AP4_DYNAMIC_CAST(AP4_EsIdRefDescriptor, od->FindSubDescriptor(AP4_DESCRIPTOR_TAG_ES_ID_REF));
- if(es_id_ref == NULL ||
- es_id_ref->GetRefIndex() > track_references->GetTrackIds().ItemCount() ||
- es_id_ref->GetRefIndex() == 0)
- {
+ if (es_id_ref == NULL ||
+ es_id_ref->GetRefIndex() > track_references->GetTrackIds().ItemCount() ||
+ es_id_ref->GetRefIndex() == 0) {
continue;
}
AP4_UI32 track_id = track_references->GetTrackIds()[es_id_ref->GetRefIndex()-1];
SinfEntry* sinf_entry = NULL;
- for(AP4_List<SinfEntry>::Item* sinf_entry_item = sinf_entries.FirstItem();
- sinf_entry_item;
- sinf_entry_item = sinf_entry_item->GetNext())
- {
+ for (AP4_List<SinfEntry>::Item* sinf_entry_item = sinf_entries.FirstItem();
+ sinf_entry_item;
+ sinf_entry_item = sinf_entry_item->GetNext()) {
sinf_entry = sinf_entry_item->GetData();
- if(sinf_entry->m_TrackId == track_id)
- {
+ if (sinf_entry->m_TrackId == track_id) {
break; // match
- }
- else
- {
+ } else {
sinf_entry = NULL; // no match
}
}
- if(sinf_entry == NULL) continue; // no matching entry
- if(sinf_entry->m_Sinf != NULL) continue; // entry already populated
-
+ if (sinf_entry == NULL) continue; // no matching entry
+ if (sinf_entry->m_Sinf != NULL) continue; // entry already populated
+
// see what ipmp descriptor this od points to
AP4_IpmpDescriptorPointer* ipmpd_pointer;
ipmpd_pointer = AP4_DYNAMIC_CAST(AP4_IpmpDescriptorPointer, od->FindSubDescriptor(AP4_DESCRIPTOR_TAG_IPMP_DESCRIPTOR_POINTER));
- if(ipmpd_pointer == NULL) continue; // no pointer
+ if (ipmpd_pointer == NULL) continue; // no pointer
// find the ipmp descriptor referenced by the pointer
AP4_IpmpDescriptor* ipmpd = NULL;
- for(AP4_List<AP4_Descriptor>::Item* ipmpd_item = ipmp_update->GetDescriptors().FirstItem();
- ipmpd_item;
- ipmpd_item = ipmpd_item->GetNext())
- {
+ for (AP4_List<AP4_Descriptor>::Item* ipmpd_item = ipmp_update->GetDescriptors().FirstItem();
+ ipmpd_item;
+ ipmpd_item = ipmpd_item->GetNext()) {
// check that this descriptor is of the right type
ipmpd = AP4_DYNAMIC_CAST(AP4_IpmpDescriptor, ipmpd_item->GetData());
- if(ipmpd == NULL || ipmpd->GetIpmpsType() != AP4_MARLIN_IPMPS_TYPE_MGSV) continue;
-
+ if (ipmpd == NULL || ipmpd->GetIpmpsType() != AP4_MARLIN_IPMPS_TYPE_MGSV) continue;
+
// check the descriptor id
- if(ipmpd->GetDescriptorId() == ipmpd_pointer->GetDescriptorId())
- {
+ if (ipmpd->GetDescriptorId() == ipmpd_pointer->GetDescriptorId()) {
break; // match
- }
- else
- {
+ } else {
ipmpd = NULL; // no match
}
}
- if(ipmpd == NULL) continue; // no matching entry
-
+ if (ipmpd == NULL) continue; // no matching entry
+
// parse the ipmp data into one or more 'sinf' atoms, and keep the one with the
// right type
AP4_MemoryByteStream* data = new AP4_MemoryByteStream(ipmpd->GetData().GetData(),
- ipmpd->GetData().GetDataSize());
+ ipmpd->GetData().GetDataSize());
AP4_LargeSize bytes_available = ipmpd->GetData().GetDataSize();
- do
- {
+ do {
AP4_Atom* atom = NULL;
-
+
// setup the factory with a context so we can instantiate a 'schm'
// atom with a slightly different format than the standard 'schm'
AP4_AtomFactory* factory = &AP4_MarlinIpmpAtomFactory::Instance;
- factory->PushContext(AP4_ATOM_TYPE('m', 'r', 'l', 'n'));
-
- // parse the next atom in the stream
+ factory->PushContext(AP4_ATOM_TYPE('m','r','l','n'));
+
+ // parse the next atom in the stream
result = factory->CreateAtomFromStream(*data, bytes_available, atom);
factory->PopContext();
- if(AP4_FAILED(result) || atom == NULL) break;
-
+ if (AP4_FAILED(result) || atom == NULL) break;
+
// check that what we have parsed is indeed an 'sinf' of the right type
- if(atom->GetType() == AP4_ATOM_TYPE_SINF)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_SINF) {
AP4_ContainerAtom* sinf = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
AP4_SchmAtom* schm = AP4_DYNAMIC_CAST(AP4_SchmAtom, sinf->FindChild("schm"));
- if((schm->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACBC &&
- schm->GetSchemeVersion() == 0x0100) ||
- (schm->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACGK &&
- schm->GetSchemeVersion() == 0x0100))
- {
+ if ((schm->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACBC &&
+ schm->GetSchemeVersion() == 0x0100) ||
+ (schm->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACGK &&
+ schm->GetSchemeVersion() == 0x0100)) {
// store the sinf in the entry for that track
sinf_entry->m_Sinf = sinf;
break;
}
}
delete atom;
- }
- while(AP4_SUCCEEDED(result));
- data->Release();
+ } while (AP4_SUCCEEDED(result));
+ data->Release();
}
-
+
// get rid of entries that have no SINF
- for(AP4_List<SinfEntry>::Item* sinf_entry_item = sinf_entries.FirstItem();
- sinf_entry_item;
- sinf_entry_item = sinf_entry_item->GetNext())
- {
+ for (AP4_List<SinfEntry>::Item* sinf_entry_item = sinf_entries.FirstItem();
+ sinf_entry_item;
+ sinf_entry_item = sinf_entry_item->GetNext()) {
SinfEntry* sinf_entry = sinf_entry_item->GetData();
- if(sinf_entry->m_Sinf == NULL)
- {
+ if (sinf_entry->m_Sinf == NULL) {
sinf_entries.Remove(sinf_entry);
sinf_entry_item = sinf_entries.FirstItem();
continue;
}
}
-
+
// remove the iods atom and the OD track if required
- if(remove_od_data)
- {
+ if (remove_od_data) {
od_trak->Detach();
delete od_trak;
iods->Detach();
delete iods;
}
-
+
// cleanup
delete od_track;
-
+
return AP4_SUCCESS;
}
@@ -379,20 +345,15 @@ AP4_MarlinIpmpParser::Parse(AP4_AtomParent& top_level,
+---------------------------------------------------------------------*/
AP4_MarlinIpmpDecryptingProcessor::AP4_MarlinIpmpDecryptingProcessor(
const AP4_ProtectionKeyMap* key_map, /* = NULL */
- AP4_BlockCipherFactory* block_cipher_factory /* = NULL */)
-{
- if(key_map)
- {
+ AP4_BlockCipherFactory* block_cipher_factory /* = NULL */){
+ if (key_map) {
// copy the keys
m_KeyMap.SetKeys(*key_map);
}
-
- if(block_cipher_factory == NULL)
- {
+
+ if (block_cipher_factory == NULL) {
m_BlockCipherFactory = &AP4_DefaultBlockCipherFactory::Instance;
- }
- else
- {
+ } else {
m_BlockCipherFactory = block_cipher_factory;
}
}
@@ -408,10 +369,10 @@ AP4_MarlinIpmpDecryptingProcessor::~AP4_MarlinIpmpDecryptingProcessor()
/*----------------------------------------------------------------------
| AP4_MarlinIpmpDecryptingProcessor:Initialize
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MarlinIpmpDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
- AP4_ByteStream& stream,
- ProgressListener* /*listener*/)
+AP4_Result
+AP4_MarlinIpmpDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
+ AP4_ByteStream& stream,
+ ProgressListener* /*listener*/)
{
return AP4_MarlinIpmpParser::Parse(top_level, stream, m_SinfEntries, true);
}
@@ -419,44 +380,35 @@ AP4_MarlinIpmpDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
/*----------------------------------------------------------------------
| AP4_MarlinIpmpDecryptingProcessor:CreateTrackHandler
+---------------------------------------------------------------------*/
-AP4_Processor::TrackHandler*
+AP4_Processor::TrackHandler*
AP4_MarlinIpmpDecryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
{
// look for this track in the list of entries
AP4_MarlinIpmpParser::SinfEntry* sinf_entry = NULL;
- for(AP4_List<AP4_MarlinIpmpParser::SinfEntry>::Item* sinf_entry_item = m_SinfEntries.FirstItem();
- sinf_entry_item;
- sinf_entry_item = sinf_entry_item->GetNext())
- {
+ for (AP4_List<AP4_MarlinIpmpParser::SinfEntry>::Item* sinf_entry_item = m_SinfEntries.FirstItem();
+ sinf_entry_item;
+ sinf_entry_item = sinf_entry_item->GetNext()) {
sinf_entry = sinf_entry_item->GetData();
- if(sinf_entry->m_TrackId == trak->GetId())
- {
+ if (sinf_entry->m_TrackId == trak->GetId()) {
break; // match
- }
- else
- {
+ } else {
sinf_entry = NULL; // no match
}
}
- if(sinf_entry == NULL) return NULL; // no matching entry
+ if (sinf_entry == NULL) return NULL; // no matching entry
AP4_ContainerAtom* sinf = sinf_entry->m_Sinf;
-
+
// check the scheme
bool use_group_key;
AP4_SchmAtom* schm = AP4_DYNAMIC_CAST(AP4_SchmAtom, sinf->GetChild(AP4_ATOM_TYPE_SCHM));
- if(schm == NULL) return NULL; // no schm
- if(schm->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACBC &&
- schm->GetSchemeVersion() == 0x0100)
- {
+ if (schm == NULL) return NULL; // no schm
+ if (schm->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACBC &&
+ schm->GetSchemeVersion() == 0x0100) {
use_group_key = false;
- }
- else if(schm->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACGK &&
- schm->GetSchemeVersion() == 0x0100)
- {
+ } else if (schm->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACGK &&
+ schm->GetSchemeVersion() == 0x0100) {
use_group_key = true;
- }
- else
- {
+ } else {
// unsupported scheme
return NULL;
}
@@ -464,32 +416,29 @@ AP4_MarlinIpmpDecryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
// find the key
const AP4_UI08* key = NULL;
AP4_DataBuffer unwrapped_key;
- if(use_group_key)
- {
+ if (use_group_key) {
const AP4_UI08* group_key = m_KeyMap.GetKey(0);
- if(group_key == NULL) return NULL; // no group key
+ if (group_key == NULL) return NULL; // no group key
AP4_ContainerAtom* schi = AP4_DYNAMIC_CAST(AP4_ContainerAtom, sinf->GetChild(AP4_ATOM_TYPE_SCHI));
- if(schi == NULL) return NULL; // no schi
+ if (schi == NULL) return NULL; // no schi
AP4_Atom* gkey = schi->GetChild(AP4_ATOM_TYPE_GKEY);
- if(gkey == NULL) return NULL; // no gkey
+ if (gkey == NULL) return NULL; // no gkey
AP4_MemoryByteStream* gkey_data = new AP4_MemoryByteStream();
gkey->WriteFields(*gkey_data);
AP4_AesKeyUnwrap(group_key, gkey_data->GetData(), gkey_data->GetDataSize(), unwrapped_key);
key = unwrapped_key.GetData();
- gkey_data->Release();
- }
- else
- {
+ gkey_data->Release();
+ } else {
key = m_KeyMap.GetKey(sinf_entry->m_TrackId);
}
- if(key == NULL) return NULL;
+ if (key == NULL) return NULL;
// create the decrypter
AP4_MarlinIpmpTrackDecrypter* decrypter = NULL;
AP4_Result result = AP4_MarlinIpmpTrackDecrypter::Create(*m_BlockCipherFactory,
- key, decrypter);
- if(AP4_FAILED(result)) return NULL;
-
+ key, decrypter);
+ if (AP4_FAILED(result)) return NULL;
+
return decrypter;
}
@@ -503,22 +452,22 @@ AP4_MarlinIpmpTrackDecrypter::Create(AP4_BlockCipherFactory& cipher_facto
{
// default value
decrypter = NULL;
-
+
// create a block cipher for the decrypter
AP4_BlockCipher* block_cipher = NULL;
AP4_Result result = cipher_factory.Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::DECRYPT,
- key,
- AP4_AES_BLOCK_SIZE,
- block_cipher);
- if(AP4_FAILED(result)) return result;
-
+ AP4_BlockCipher::DECRYPT,
+ key,
+ AP4_AES_BLOCK_SIZE,
+ block_cipher);
+ if (AP4_FAILED(result)) return result;
+
// create a CBC cipher
AP4_CbcStreamCipher* cbc_cipher = new AP4_CbcStreamCipher(block_cipher, AP4_StreamCipher::DECRYPT);
-
+
// create the track decrypter
decrypter = new AP4_MarlinIpmpTrackDecrypter(cbc_cipher);
-
+
return AP4_SUCCESS;
}
@@ -533,72 +482,69 @@ AP4_MarlinIpmpTrackDecrypter::~AP4_MarlinIpmpTrackDecrypter()
/*----------------------------------------------------------------------
| AP4_MarlinIpmpTrackDecrypter:GetProcessedSampleSize
+---------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_MarlinIpmpTrackDecrypter::GetProcessedSampleSize(AP4_Sample& sample)
{
// with CBC, we need to decrypt the last block to know what the padding was
- AP4_Size encrypted_size = sample.GetSize() - AP4_AES_BLOCK_SIZE;
+ AP4_Size encrypted_size = sample.GetSize()-AP4_AES_BLOCK_SIZE;
AP4_DataBuffer encrypted;
AP4_DataBuffer decrypted;
AP4_Size decrypted_size = AP4_CIPHER_BLOCK_SIZE;
- if(sample.GetSize() < 2 * AP4_CIPHER_BLOCK_SIZE)
- {
+ if (sample.GetSize() < 2*AP4_CIPHER_BLOCK_SIZE) {
return 0;
}
- AP4_Size offset = sample.GetSize() - 2 * AP4_CIPHER_BLOCK_SIZE;
- if(AP4_FAILED(sample.ReadData(encrypted, 2 * AP4_CIPHER_BLOCK_SIZE, offset)))
- {
+ AP4_Size offset = sample.GetSize()-2*AP4_CIPHER_BLOCK_SIZE;
+ if (AP4_FAILED(sample.ReadData(encrypted, 2*AP4_CIPHER_BLOCK_SIZE, offset))) {
return 0;
}
decrypted.Reserve(decrypted_size);
m_Cipher->SetIV(encrypted.GetData());
- if(AP4_FAILED(m_Cipher->ProcessBuffer(encrypted.GetData() + AP4_CIPHER_BLOCK_SIZE,
- AP4_CIPHER_BLOCK_SIZE,
- decrypted.UseData(),
- &decrypted_size,
- true)))
- {
+ if (AP4_FAILED(m_Cipher->ProcessBuffer(encrypted.GetData()+AP4_CIPHER_BLOCK_SIZE,
+ AP4_CIPHER_BLOCK_SIZE,
+ decrypted.UseData(),
+ &decrypted_size,
+ true))) {
return 0;
}
- unsigned int padding_size = AP4_CIPHER_BLOCK_SIZE - decrypted_size;
- return encrypted_size - padding_size;
+ unsigned int padding_size = AP4_CIPHER_BLOCK_SIZE-decrypted_size;
+ return encrypted_size-padding_size;
}
/*----------------------------------------------------------------------
| AP4_MarlinIpmpTrackDecrypter:ProcessSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MarlinIpmpTrackDecrypter::ProcessSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out)
+ AP4_DataBuffer& data_out)
{
AP4_Result result;
-
+
const AP4_UI08* in = data_in.GetData();
AP4_Size in_size = data_in.GetDataSize();
- // default to 0 output
+ // default to 0 output
data_out.SetDataSize(0);
// check that we have at least the minimum size
- if(in_size < 2 * AP4_AES_BLOCK_SIZE) return AP4_ERROR_INVALID_FORMAT;
+ if (in_size < 2*AP4_AES_BLOCK_SIZE) return AP4_ERROR_INVALID_FORMAT;
// process the sample data
- AP4_Size out_size = in_size - AP4_AES_BLOCK_SIZE; // worst case
+ AP4_Size out_size = in_size-AP4_AES_BLOCK_SIZE; // worst case
data_out.SetDataSize(out_size);
AP4_UI08* out = data_out.UseData();
// decrypt the data
m_Cipher->SetIV(in);
- result = m_Cipher->ProcessBuffer(in + AP4_AES_BLOCK_SIZE,
- in_size - AP4_AES_BLOCK_SIZE,
+ result = m_Cipher->ProcessBuffer(in+AP4_AES_BLOCK_SIZE,
+ in_size-AP4_AES_BLOCK_SIZE,
out,
&out_size,
true);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// update the payload size
data_out.SetDataSize(out_size);
-
+
return AP4_SUCCESS;
}
@@ -611,18 +557,14 @@ AP4_MarlinIpmpEncryptingProcessor::AP4_MarlinIpmpEncryptingProcessor(
AP4_BlockCipherFactory* block_cipher_factory /* = NULL */) :
m_UseGroupKey(use_group_key)
{
- if(key_map)
- {
+ if (key_map) {
// copy the keys
m_KeyMap.SetKeys(*key_map);
}
-
- if(block_cipher_factory == NULL)
- {
+
+ if (block_cipher_factory == NULL) {
m_BlockCipherFactory = &AP4_DefaultBlockCipherFactory::Instance;
- }
- else
- {
+ } else {
m_BlockCipherFactory = block_cipher_factory;
}
}
@@ -630,7 +572,7 @@ AP4_MarlinIpmpEncryptingProcessor::AP4_MarlinIpmpEncryptingProcessor(
/*----------------------------------------------------------------------
| AP4_MarlinIpmpEncryptingProcessor::Initialize
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MarlinIpmpEncryptingProcessor::Initialize(
AP4_AtomParent& top_level,
AP4_ByteStream& /*stream*/,
@@ -638,84 +580,75 @@ AP4_MarlinIpmpEncryptingProcessor::Initialize(
{
// get the moov atom
AP4_MoovAtom* moov = AP4_DYNAMIC_CAST(AP4_MoovAtom, top_level.GetChild(AP4_ATOM_TYPE_MOOV));
- if(moov == NULL) return AP4_ERROR_INVALID_FORMAT;
-
+ if (moov == NULL) return AP4_ERROR_INVALID_FORMAT;
+
// deal with the file type
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
- if(ftyp)
- {
+ if (ftyp) {
// remove the atom, it will be replaced with a new one
top_level.RemoveChild(ftyp);
-
+
// keep the existing brand and compatible brands
AP4_Array<AP4_UI32> compatible_brands;
- compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount() + 1);
- for(unsigned int i = 0; i < ftyp->GetCompatibleBrands().ItemCount(); i++)
- {
+ compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount()+1);
+ for (unsigned int i=0; i<ftyp->GetCompatibleBrands().ItemCount(); i++) {
compatible_brands.Append(ftyp->GetCompatibleBrands()[i]);
}
-
+
// add the MGSV compatible brand if it is not already there
- if(!ftyp->HasCompatibleBrand(AP4_MARLIN_BRAND_MGSV))
- {
+ if (!ftyp->HasCompatibleBrand(AP4_MARLIN_BRAND_MGSV)) {
compatible_brands.Append(AP4_MARLIN_BRAND_MGSV);
}
// create a replacement for the major brand
AP4_FtypAtom* new_ftyp = new AP4_FtypAtom(AP4_MARLIN_BRAND_MGSV,
- 0x13c078c, //AP4_MARLIN_BRAND_MGSV_MAJOR_VERSION,
- &compatible_brands[0],
- compatible_brands.ItemCount());
+ 0x13c078c, //AP4_MARLIN_BRAND_MGSV_MAJOR_VERSION,
+ &compatible_brands[0],
+ compatible_brands.ItemCount());
delete ftyp;
ftyp = new_ftyp;
- }
- else
- {
+ } else {
AP4_UI32 isom = AP4_FTYP_BRAND_ISOM;
ftyp = new AP4_FtypAtom(AP4_MARLIN_BRAND_MGSV, 0, &isom, 1);
}
-
+
// insert the ftyp atom as the first child
top_level.AddChild(ftyp, 0);
// create and 'mpod' track reference atom
AP4_TrefTypeAtom* mpod = new AP4_TrefTypeAtom(AP4_ATOM_TYPE_MPOD);
-
+
// look for an available track ID, starting at 1
unsigned int od_track_id = 0;
unsigned int od_track_position = 0;
- for(AP4_List<AP4_TrakAtom>::Item* trak_item = moov->GetTrakAtoms().FirstItem();
- trak_item;
- trak_item = trak_item->GetNext())
- {
+ for (AP4_List<AP4_TrakAtom>::Item* trak_item = moov->GetTrakAtoms().FirstItem();
+ trak_item;
+ trak_item = trak_item->GetNext()) {
AP4_TrakAtom* trak = trak_item->GetData();
- if(trak)
- {
+ if (trak) {
od_track_position++;
- if(trak->GetId() >= od_track_id)
- {
- od_track_id = trak->GetId() + 1;
+ if (trak->GetId() >= od_track_id) {
+ od_track_id = trak->GetId()+1;
}
-
+
// if the track is encrypted, reference it in the mpod
- if(m_KeyMap.GetKey(trak->GetId()))
- {
+ if (m_KeyMap.GetKey(trak->GetId())) {
mpod->AddTrackId(trak->GetId());
}
-
+
//m_SinfEntries.Add(new SinfEntry(trak->GetId(), NULL));
- }
+ }
}
-
+
// check that there was at least one track in the file
- if(od_track_id == 0) return AP4_ERROR_INVALID_FORMAT;
-
+ if (od_track_id == 0) return AP4_ERROR_INVALID_FORMAT;
+
// create an initial object descriptor
- AP4_InitialObjectDescriptor* iod =
+ AP4_InitialObjectDescriptor* iod =
// FIXME: get real values from the property map
new AP4_InitialObjectDescriptor(AP4_DESCRIPTOR_TAG_MP4_IOD,
1022, // object descriptor id
- false,
+ false,
0xFE, // OD profile level (0xFE = No OD profile specified)
0xFF, // scene profile level
0xFE, // audio profile level
@@ -725,183 +658,160 @@ AP4_MarlinIpmpEncryptingProcessor::Initialize(
// create an ES_ID_Inc subdescriptor and add it to the initial object descriptor
AP4_EsIdIncDescriptor* es_id_inc = new AP4_EsIdIncDescriptor(od_track_id);
iod->AddSubDescriptor(es_id_inc);
-
+
// create an iods atom to hold the initial object descriptor
AP4_IodsAtom* iods = new AP4_IodsAtom(iod);
-
+
// add the iods atom to the moov atom (try to put it just after mvhd)
int iods_position = 0;
int item_position = 0;
- for(AP4_List<AP4_Atom>::Item* moov_item = moov->GetChildren().FirstItem();
- moov_item;
- moov_item = moov_item->GetNext())
- {
- ++item_position;
- if(moov_item->GetData()->GetType() == AP4_ATOM_TYPE_MVHD)
- {
+ for (AP4_List<AP4_Atom>::Item* moov_item = moov->GetChildren().FirstItem();
+ moov_item;
+ moov_item = moov_item->GetNext()) {
+ ++item_position;
+ if (moov_item->GetData()->GetType() == AP4_ATOM_TYPE_MVHD) {
iods_position = item_position;
break;
- }
+ }
}
AP4_Result result = moov->AddChild(iods, iods_position);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
delete iods;
return result;
}
-
+
// create a sample table for the OD track
AP4_SyntheticSampleTable* od_sample_table = new AP4_SyntheticSampleTable();
-
- // create the sample description for the OD track
+
+ // create the sample description for the OD track
AP4_MpegSystemSampleDescription* od_sample_description;
od_sample_description = new AP4_MpegSystemSampleDescription(AP4_STREAM_TYPE_OD,
- AP4_OTI_MPEG4_SYSTEM,
- NULL,
- 32768, // buffer size
- 1024, // max bitrate
- 512); // avg bitrate
+ AP4_OTI_MPEG4_SYSTEM,
+ NULL,
+ 32768, // buffer size
+ 1024, // max bitrate
+ 512); // avg bitrate
od_sample_table->AddSampleDescription(od_sample_description, true);
-
- // create the OD descriptor update
+
+ // create the OD descriptor update
AP4_DescriptorUpdateCommand od_update(AP4_COMMAND_TAG_OBJECT_DESCRIPTOR_UPDATE);
- for(unsigned int i = 0; i < mpod->GetTrackIds().ItemCount(); i++)
- {
- AP4_ObjectDescriptor* od = new AP4_ObjectDescriptor(AP4_DESCRIPTOR_TAG_MP4_OD, 256 + i); // descriptor id = 256+i
- od->AddSubDescriptor(new AP4_EsIdRefDescriptor(i + 1)); // index into mpod (1-based)
- od->AddSubDescriptor(new AP4_IpmpDescriptorPointer(i + 1)); // descriptor id = i+1
+ for (unsigned int i=0; i<mpod->GetTrackIds().ItemCount(); i++) {
+ AP4_ObjectDescriptor* od = new AP4_ObjectDescriptor(AP4_DESCRIPTOR_TAG_MP4_OD, 256+i); // descriptor id = 256+i
+ od->AddSubDescriptor(new AP4_EsIdRefDescriptor(i+1)); // index into mpod (1-based)
+ od->AddSubDescriptor(new AP4_IpmpDescriptorPointer(i+1)); // descriptor id = i+1
od_update.AddDescriptor(od);
}
-
- // create the IPMP descriptor update
+
+ // create the IPMP descriptor update
AP4_DescriptorUpdateCommand ipmp_update(AP4_COMMAND_TAG_IPMP_DESCRIPTOR_UPDATE);
- for(unsigned int i = 0; i < mpod->GetTrackIds().ItemCount(); i++)
- {
+ for (unsigned int i=0; i<mpod->GetTrackIds().ItemCount(); i++) {
// create the ipmp descriptor
- AP4_IpmpDescriptor* ipmp_descriptor = new AP4_IpmpDescriptor(i + 1, AP4_MARLIN_IPMPS_TYPE_MGSV);
+ AP4_IpmpDescriptor* ipmp_descriptor = new AP4_IpmpDescriptor(i+1, AP4_MARLIN_IPMPS_TYPE_MGSV);
// create the sinf container
AP4_ContainerAtom* sinf = new AP4_ContainerAtom(AP4_ATOM_TYPE_SINF);
// add the scheme type atom
- sinf->AddChild(new AP4_SchmAtom(m_UseGroupKey ?
- AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACGK :
- AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACBC,
+ sinf->AddChild(new AP4_SchmAtom(m_UseGroupKey?
+ AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACGK:
+ AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACBC,
0x0100, NULL, true));
// create the 'schi' container
AP4_ContainerAtom* schi = new AP4_ContainerAtom(AP4_ATOM_TYPE_SCHI);
- // add the content ID
+ // add the content ID
const char* content_id = m_PropertyMap.GetProperty(mpod->GetTrackIds()[i], "ContentId");
- if(content_id)
- {
+ if (content_id) {
// add the content ID (8id_)
schi->AddChild(new AP4_NullTerminatedStringAtom(AP4_ATOM_TYPE_8ID_, content_id));
}
-
+
// add the signed attributes, if any
const char* signed_attributes = m_PropertyMap.GetProperty(mpod->GetTrackIds()[i], "SignedAttributes");
- if(signed_attributes)
- {
+ if (signed_attributes) {
// decode the hex-encoded data
- unsigned int size = (unsigned int)AP4_StringLength(signed_attributes) / 2;
+ unsigned int size = (unsigned int)AP4_StringLength(signed_attributes)/2;
AP4_DataBuffer attributes_atoms;
attributes_atoms.SetDataSize(size);
- if(AP4_SUCCEEDED(AP4_ParseHex(signed_attributes, attributes_atoms.UseData(), size)))
- {
+ if (AP4_SUCCEEDED(AP4_ParseHex(signed_attributes, attributes_atoms.UseData(), size))) {
// parse all the atoms encoded in the data and add them to the 'schi' container
- AP4_MemoryByteStream* mbs = new AP4_MemoryByteStream(attributes_atoms.GetData(),
- attributes_atoms.GetDataSize());
- do
- {
+ AP4_MemoryByteStream* mbs = new AP4_MemoryByteStream(attributes_atoms.GetData(),
+ attributes_atoms.GetDataSize());
+ do {
AP4_Atom* atom = NULL;
result = AP4_DefaultAtomFactory::Instance.CreateAtomFromStream(*mbs, atom);
- if(AP4_SUCCEEDED(result) && atom)
- {
+ if (AP4_SUCCEEDED(result) && atom) {
schi->AddChild(atom);
}
- }
- while(AP4_SUCCEEDED(result));
+ } while (AP4_SUCCEEDED(result));
mbs->Release();
}
}
-
+
// find what the track type is (necessary for the next step) and the key
const AP4_UI08* key;
unsigned int key_size = 0;
AP4_Track::Type track_type = AP4_Track::TYPE_UNKNOWN;
- for(AP4_List<AP4_TrakAtom>::Item* trak_item = moov->GetTrakAtoms().FirstItem();
- trak_item;
- trak_item = trak_item->GetNext())
- {
+ for (AP4_List<AP4_TrakAtom>::Item* trak_item = moov->GetTrakAtoms().FirstItem();
+ trak_item;
+ trak_item = trak_item->GetNext()) {
AP4_TrakAtom* trak = trak_item->GetData();
- if(trak->GetId() == mpod->GetTrackIds()[i])
- {
+ if (trak->GetId() == mpod->GetTrackIds()[i]) {
// find the handler type
AP4_Atom* sub = trak->FindChild("mdia/hdlr");
- if(sub)
- {
+ if (sub) {
AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, sub);
- if(hdlr)
- {
+ if (hdlr) {
AP4_UI32 type = hdlr->GetHandlerType();
- if(type == AP4_HANDLER_TYPE_SOUN)
- {
+ if (type == AP4_HANDLER_TYPE_SOUN) {
track_type = AP4_Track::TYPE_AUDIO;
- }
- else if(type == AP4_HANDLER_TYPE_VIDE)
- {
+ } else if (type == AP4_HANDLER_TYPE_VIDE) {
track_type = AP4_Track::TYPE_VIDEO;
}
}
}
-
+
// find the key
const AP4_UI08* iv = NULL;
- if(AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, iv)))
- {
+ if (AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, iv))) {
key_size = 16;
}
break;
}
}
-
+
// group key
- if(m_UseGroupKey)
- {
+ if (m_UseGroupKey) {
// find the group key
const AP4_UI08* iv = NULL;
const AP4_UI08* group_key;
- if(AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(0, group_key, iv)))
- {
+ if (AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(0, group_key, iv))) {
AP4_DataBuffer wrapped_key;
result = AP4_AesKeyWrap(group_key, key, key_size, wrapped_key);
- if(AP4_FAILED(result)) return result;
- AP4_UnknownAtom* gkey = new AP4_UnknownAtom(AP4_ATOM_TYPE_GKEY,
- wrapped_key.GetData(),
- wrapped_key.GetDataSize());
+ if (AP4_FAILED(result)) return result;
+ AP4_UnknownAtom* gkey = new AP4_UnknownAtom(AP4_ATOM_TYPE_GKEY,
+ wrapped_key.GetData(),
+ wrapped_key.GetDataSize());
schi->AddChild(gkey);
}
}
-
+
// create and add the secure attributes (satr)
- if(track_type != AP4_Track::TYPE_UNKNOWN && key != NULL && key_size != 0)
- {
+ if (track_type != AP4_Track::TYPE_UNKNOWN && key != NULL && key_size != 0) {
AP4_ContainerAtom* satr = new AP4_ContainerAtom(AP4_ATOM_TYPE_SATR);
- switch(track_type)
- {
- case AP4_Track::TYPE_AUDIO:
- satr->AddChild(new AP4_NullTerminatedStringAtom(AP4_ATOM_TYPE_STYP, AP4_MARLIN_IPMP_STYP_AUDIO));
- break;
- case AP4_Track::TYPE_VIDEO:
- satr->AddChild(new AP4_NullTerminatedStringAtom(AP4_ATOM_TYPE_STYP, AP4_MARLIN_IPMP_STYP_VIDEO));
- break;
- default:
- break;
+ switch (track_type) {
+ case AP4_Track::TYPE_AUDIO:
+ satr->AddChild(new AP4_NullTerminatedStringAtom(AP4_ATOM_TYPE_STYP, AP4_MARLIN_IPMP_STYP_AUDIO));
+ break;
+ case AP4_Track::TYPE_VIDEO:
+ satr->AddChild(new AP4_NullTerminatedStringAtom(AP4_ATOM_TYPE_STYP, AP4_MARLIN_IPMP_STYP_VIDEO));
+ break;
+ default:
+ break;
}
-
+
// compute the hmac
AP4_MemoryByteStream* mbs = new AP4_MemoryByteStream();
satr->Write(*mbs);
@@ -911,74 +821,73 @@ AP4_MarlinIpmpEncryptingProcessor::Initialize(
AP4_DataBuffer hmac_value;
digester->Final(hmac_value);
AP4_Atom* hmac = new AP4_UnknownAtom(AP4_ATOM_TYPE_HMAC, hmac_value.GetData(), hmac_value.GetDataSize());
-
+
schi->AddChild(satr);
schi->AddChild(hmac);
-
+
mbs->Release();
}
-
+
sinf->AddChild(schi);
-
+
// serialize the sinf atom to a buffer and set it as the ipmp data
AP4_MemoryByteStream* sinf_data = new AP4_MemoryByteStream((AP4_Size)sinf->GetSize());
sinf->Write(*sinf_data);
ipmp_descriptor->SetData(sinf_data->GetData(), sinf_data->GetDataSize());
sinf_data->Release();
-
+
ipmp_update.AddDescriptor(ipmp_descriptor);
}
-
+
// add the sample with the descriptors and updates
AP4_MemoryByteStream* sample_data = new AP4_MemoryByteStream();
od_update.Write(*sample_data);
ipmp_update.Write(*sample_data);
od_sample_table->AddSample(*sample_data, 0, sample_data->GetDataSize(), 0, 0, 0, 0, true);
-
+
// create the OD track
AP4_TrakAtom* od_track = new AP4_TrakAtom(od_sample_table,
- AP4_HANDLER_TYPE_ODSM,
- "Bento4 Marlin OD Handler",
- od_track_id,
- 0, 0,
- 1, 1000, 1, 0, "und",
- 0, 0);
-
- // add an entry in the processor's stream table to indicate that the
+ AP4_HANDLER_TYPE_ODSM,
+ "Bento4 Marlin OD Handler",
+ od_track_id,
+ 0, 0,
+ 1, 1000, 1, 0, "und",
+ 0, 0);
+
+ // add an entry in the processor's stream table to indicate that the
// media data for the OD track is not in the file stream, but in our
// memory stream.
m_ExternalTrackData.Add(new ExternalTrackData(od_track_id, sample_data));
sample_data->Release();
-
+
// add a tref track reference atom
AP4_ContainerAtom* tref = new AP4_ContainerAtom(AP4_ATOM_TYPE_TREF);
tref->AddChild(mpod);
od_track->AddChild(tref, 1); // add after 'tkhd'
-
+
// add the track to the moov atoms (just after the last track)
moov->AddChild(od_track, od_track_position);
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_MarlinIpmpEncryptingProcessor::CreateTrackHandler
+---------------------------------------------------------------------*/
-AP4_Processor::TrackHandler*
+AP4_Processor::TrackHandler*
AP4_MarlinIpmpEncryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
{
// create a handler for this track if we have a key for it
const AP4_UI08* key;
const AP4_UI08* iv;
- if(AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, iv)))
- {
+ if (AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, iv))) {
// create the track handler
AP4_MarlinIpmpTrackEncrypter* handler = NULL;
AP4_Result result = AP4_MarlinIpmpTrackEncrypter::Create(*m_BlockCipherFactory, key, iv, handler);
- if(AP4_FAILED(result)) return NULL;
+ if (AP4_FAILED(result)) return NULL;
return handler;
}
-
+
// not encrypted
return NULL;
}
@@ -994,34 +903,34 @@ AP4_MarlinIpmpTrackEncrypter::Create(AP4_BlockCipherFactory& cipher_facto
{
// default value
encrypter = NULL;
-
+
// create a block cipher
AP4_BlockCipher* block_cipher = NULL;
- AP4_Result result = cipher_factory.Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::ENCRYPT,
- key,
- AP4_AES_BLOCK_SIZE,
- block_cipher);
- if(AP4_FAILED(result)) return result;
+ AP4_Result result = cipher_factory.Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::ENCRYPT,
+ key,
+ AP4_AES_BLOCK_SIZE,
+ block_cipher);
+ if (AP4_FAILED(result)) return result;
// create a CBC cipher
AP4_CbcStreamCipher* cbc_cipher = new AP4_CbcStreamCipher(block_cipher, AP4_StreamCipher::ENCRYPT);
-
+
// create the track encrypter
encrypter = new AP4_MarlinIpmpTrackEncrypter(cbc_cipher, iv);
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_MarlinIpmpTrackEncrypter::AP4_MarlinIpmpTrackEncrypter
+---------------------------------------------------------------------*/
-AP4_MarlinIpmpTrackEncrypter::AP4_MarlinIpmpTrackEncrypter(AP4_StreamCipher* cipher,
- const AP4_UI08* iv) :
+AP4_MarlinIpmpTrackEncrypter::AP4_MarlinIpmpTrackEncrypter(AP4_StreamCipher* cipher,
+ const AP4_UI08* iv) :
m_Cipher(cipher)
{
// copy the IV
- AP4_CopyMemory(m_IV, iv, AP4_AES_BLOCK_SIZE);
+ AP4_CopyMemory(m_IV, iv, AP4_AES_BLOCK_SIZE);
}
/*----------------------------------------------------------------------
@@ -1035,47 +944,47 @@ AP4_MarlinIpmpTrackEncrypter::~AP4_MarlinIpmpTrackEncrypter()
/*----------------------------------------------------------------------
| AP4_MarlinIpmpTrackEncrypter:GetProcessedSampleSize
+---------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_MarlinIpmpTrackEncrypter::GetProcessedSampleSize(AP4_Sample& sample)
{
- return AP4_CIPHER_BLOCK_SIZE * (2 + (sample.GetSize() / AP4_CIPHER_BLOCK_SIZE));
+ return AP4_CIPHER_BLOCK_SIZE*(2+(sample.GetSize()/AP4_CIPHER_BLOCK_SIZE));
}
/*----------------------------------------------------------------------
| AP4_MarlinIpmpTrackEncrypter:ProcessSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MarlinIpmpTrackEncrypter::ProcessSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out)
+ AP4_DataBuffer& data_out)
{
AP4_Result result;
-
+
const AP4_UI08* in = data_in.GetData();
AP4_Size in_size = data_in.GetDataSize();
- // default to 0 output
+ // default to 0 output
data_out.SetDataSize(0);
// process the sample data
- AP4_Size out_size = AP4_CIPHER_BLOCK_SIZE * (2 + (in_size / AP4_CIPHER_BLOCK_SIZE));
+ AP4_Size out_size = AP4_CIPHER_BLOCK_SIZE*(2+(in_size/AP4_CIPHER_BLOCK_SIZE));
data_out.SetDataSize(out_size);
AP4_UI08* out = data_out.UseData();
// write the IV
AP4_CopyMemory(out, m_IV, AP4_CIPHER_BLOCK_SIZE);
out_size -= AP4_CIPHER_BLOCK_SIZE;
-
+
// encrypt the data
m_Cipher->SetIV(m_IV);
- result = m_Cipher->ProcessBuffer(in,
- in_size,
- out + AP4_AES_BLOCK_SIZE,
+ result = m_Cipher->ProcessBuffer(in,
+ in_size,
+ out+AP4_AES_BLOCK_SIZE,
&out_size,
true);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// update the payload size
- data_out.SetDataSize(out_size + AP4_AES_BLOCK_SIZE);
-
+ data_out.SetDataSize(out_size+AP4_AES_BLOCK_SIZE);
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.h
index 52601c529..7e1b428d6 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Marlin.h
@@ -47,15 +47,15 @@
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_MARLIN_BRAND_MGSV = AP4_ATOM_TYPE('M', 'G', 'S', 'V');
+const AP4_UI32 AP4_MARLIN_BRAND_MGSV = AP4_ATOM_TYPE('M','G','S','V');
const AP4_UI16 AP4_MARLIN_IPMPS_TYPE_MGSV = 0xA551;
-const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACBC = AP4_ATOM_TYPE('A', 'C', 'B', 'C');
-const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACGK = AP4_ATOM_TYPE('A', 'C', 'G', 'K');
+const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACBC = AP4_ATOM_TYPE('A','C','B','C');
+const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_MARLIN_ACGK = AP4_ATOM_TYPE('A','C','G','K');
-const AP4_Atom::Type AP4_ATOM_TYPE_SATR = AP4_ATOM_TYPE('s', 'a', 't', 'r');
-const AP4_Atom::Type AP4_ATOM_TYPE_STYP = AP4_ATOM_TYPE('s', 't', 'y', 'p');
-const AP4_Atom::Type AP4_ATOM_TYPE_HMAC = AP4_ATOM_TYPE('h', 'm', 'a', 'c');
-const AP4_Atom::Type AP4_ATOM_TYPE_GKEY = AP4_ATOM_TYPE('g', 'k', 'e', 'y');
+const AP4_Atom::Type AP4_ATOM_TYPE_SATR = AP4_ATOM_TYPE('s','a','t','r');
+const AP4_Atom::Type AP4_ATOM_TYPE_STYP = AP4_ATOM_TYPE('s','t','y','p');
+const AP4_Atom::Type AP4_ATOM_TYPE_HMAC = AP4_ATOM_TYPE('h','m','a','c');
+const AP4_Atom::Type AP4_ATOM_TYPE_GKEY = AP4_ATOM_TYPE('g','k','e','y');
const char* const AP4_MARLIN_IPMP_STYP_VIDEO = "urn:marlin:organization:sne:content-type:video";
const char* const AP4_MARLIN_IPMP_STYP_AUDIO = "urn:marlin:organization:sne:content-type:audio";
@@ -67,24 +67,20 @@ class AP4_MarlinIpmpParser
{
public:
// types
- struct SinfEntry
- {
- SinfEntry(AP4_UI32 track_id, AP4_ContainerAtom* sinf) :
- m_TrackId(track_id), m_Sinf(sinf) {}
- ~SinfEntry()
- {
- delete m_Sinf;
- }
+ struct SinfEntry {
+ SinfEntry(AP4_UI32 track_id, AP4_ContainerAtom* sinf) :
+ m_TrackId(track_id), m_Sinf(sinf) {}
+ ~SinfEntry() { delete m_Sinf; }
AP4_UI32 m_TrackId;
AP4_ContainerAtom* m_Sinf;
};
-
+
// methods
- static AP4_Result Parse(AP4_AtomParent& top_level,
+ static AP4_Result Parse(AP4_AtomParent& top_level,
AP4_ByteStream& stream,
AP4_List<SinfEntry>& sinf_entries,
- bool remove_od_data = false);
-
+ bool remove_od_data=false);
+
private:
AP4_MarlinIpmpParser() {} // this class can't be instantiated
};
@@ -99,12 +95,9 @@ public:
AP4_MarlinIpmpDecryptingProcessor(const AP4_ProtectionKeyMap* key_map = NULL,
AP4_BlockCipherFactory* block_cipher_factory = NULL);
~AP4_MarlinIpmpDecryptingProcessor();
-
+
// accessors
- AP4_ProtectionKeyMap& GetKeyMap()
- {
- return m_KeyMap;
- }
+ AP4_ProtectionKeyMap& GetKeyMap() { return m_KeyMap; }
// methods
virtual AP4_Result Initialize(AP4_AtomParent& top_level,
@@ -113,7 +106,7 @@ public:
virtual AP4_Processor::TrackHandler* CreateTrackHandler(AP4_TrakAtom* trak);
private:
-
+
// members
AP4_BlockCipherFactory* m_BlockCipherFactory;
AP4_ProtectionKeyMap m_KeyMap;
@@ -130,10 +123,10 @@ public:
static AP4_Result Create(AP4_BlockCipherFactory& cipher_factory,
const AP4_UI08* key,
AP4_MarlinIpmpTrackDecrypter*& decrypter);
-
+
// destructor
~AP4_MarlinIpmpTrackDecrypter();
-
+
// AP4_Processor::TrackHandler methods
virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample);
virtual AP4_Result ProcessSample(AP4_DataBuffer& data_in,
@@ -160,14 +153,8 @@ public:
AP4_BlockCipherFactory* block_cipher_factory = NULL);
// accessors
- AP4_ProtectionKeyMap& GetKeyMap()
- {
- return m_KeyMap;
- }
- AP4_TrackPropertyMap& GetPropertyMap()
- {
- return m_PropertyMap;
- }
+ AP4_ProtectionKeyMap& GetKeyMap() { return m_KeyMap; }
+ AP4_TrackPropertyMap& GetPropertyMap() { return m_PropertyMap; }
// AP4_Processor methods
virtual AP4_Result Initialize(AP4_AtomParent& top_level,
@@ -194,10 +181,10 @@ public:
const AP4_UI08* key,
const AP4_UI08* iv,
AP4_MarlinIpmpTrackEncrypter*& encrypter);
-
+
// destructor
~AP4_MarlinIpmpTrackEncrypter();
-
+
// AP4_Processor::TrackHandler methods
virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample);
virtual AP4_Result ProcessSample(AP4_DataBuffer& data_in,
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.cpp
index 5ec6b401e..78bab0b3c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - mdhd Atoms
+| AP4 - mdhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_MdhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version > 1) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version > 1) return NULL;
return new AP4_MdhdAtom(size, version, flags, stream);
}
@@ -59,7 +59,7 @@ AP4_MdhdAtom::AP4_MdhdAtom(AP4_UI32 creation_time,
AP4_UI32 time_scale,
AP4_UI64 duration,
const char* language) :
- AP4_Atom(AP4_ATOM_TYPE_MDHD, AP4_FULL_ATOM_HEADER_SIZE + 20, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_MDHD, AP4_FULL_ATOM_HEADER_SIZE+20, 0, 0),
m_CreationTime(creation_time),
m_ModificationTime(modification_time),
m_TimeScale(time_scale),
@@ -71,14 +71,13 @@ AP4_MdhdAtom::AP4_MdhdAtom(AP4_UI32 creation_time,
/*----------------------------------------------------------------------
| AP4_MdhdAtom::AP4_MdhdAtom
+---------------------------------------------------------------------*/
-AP4_MdhdAtom::AP4_MdhdAtom(AP4_UI32 size,
+AP4_MdhdAtom::AP4_MdhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_MDHD, size, version, flags)
{
- if(m_Version == 0)
- {
+ if (m_Version == 0) {
AP4_UI32 creation_time;
stream.ReadUI32(creation_time);
m_CreationTime = creation_time;
@@ -89,27 +88,22 @@ AP4_MdhdAtom::AP4_MdhdAtom(AP4_UI32 size,
AP4_UI32 duration;
stream.ReadUI32(duration);
m_Duration = duration;
- }
- else
- {
+ } else {
stream.ReadUI64(m_CreationTime);
stream.ReadUI64(m_ModificationTime);
stream.ReadUI32(m_TimeScale);
stream.ReadUI64(m_Duration);
}
-
+
unsigned char lang[2];
stream.Read(lang, 2);
- char l0 = ((lang[0] >> 2) & 0x1F);
- char l1 = (((lang[0] & 0x3) << 3) | ((lang[1] >> 5) & 0x7));
- char l2 = ((lang[1] & 0x1F));
- if(l0 && l1 && l2)
- {
- char lang_str[3] = {l0 + 0x60, l1 + 0x60, l2 + 0x60};
+ char l0 = ((lang[0]>>2)&0x1F);
+ char l1 = (((lang[0]&0x3)<<3) | ((lang[1]>>5)&0x7));
+ char l2 = ((lang[1]&0x1F));
+ if (l0 && l1 && l2) {
+ char lang_str[3] = {l0+0x60, l1+0x60, l2+0x60};
m_Language.Assign(lang_str, 3);
- }
- else
- {
+ } else {
m_Language.Assign("```", 3);
}
}
@@ -122,37 +116,34 @@ AP4_MdhdAtom::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
- if(m_Version == 0)
- {
+ if (m_Version == 0) {
result = stream.WriteUI32((AP4_UI32)m_CreationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32((AP4_UI32)m_ModificationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_TimeScale);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32((AP4_UI32)m_Duration);
- if(AP4_FAILED(result)) return result;
- }
- else
- {
+ if (AP4_FAILED(result)) return result;
+ } else {
result = stream.WriteUI64(m_CreationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI64(m_ModificationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_TimeScale);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI64(m_Duration);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// write the language
- AP4_UI08 l0 = m_Language[0] - 0x60;
- AP4_UI08 l1 = m_Language[1] - 0x60;
- AP4_UI08 l2 = m_Language[2] - 0x60;
- result = stream.WriteUI08(l0 << 2 | l1 >> 3);
- if(AP4_FAILED(result)) return result;
- result = stream.WriteUI08(l1 << 5 | l2);
- if(AP4_FAILED(result)) return result;
+ AP4_UI08 l0 = m_Language[0]-0x60;
+ AP4_UI08 l1 = m_Language[1]-0x60;
+ AP4_UI08 l2 = m_Language[2]-0x60;
+ result = stream.WriteUI08(l0<<2 | l1>>3);
+ if (AP4_FAILED(result)) return result;
+ result = stream.WriteUI08(l1<<5 | l2);
+ if (AP4_FAILED(result)) return result;
// pre-defined
return stream.WriteUI16(0);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.h
index 4627a5fa8..f61ba9f6a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MdhdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - mdhd Atoms
+| AP4 - mdhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -62,30 +62,15 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
AP4_UI32 GetDurationMs();
- AP4_UI64 GetDuration()
- {
- return m_Duration;
- }
- void SetDuration(AP4_UI64 duration)
- {
- m_Duration = duration;
- }
- AP4_UI32 GetTimeScale()
- {
- return m_TimeScale;
- }
- void SetTimeScale(AP4_UI32 timescale)
- {
- m_TimeScale = timescale;
- }
- const AP4_String& GetLanguage()
- {
- return m_Language;
- }
+ AP4_UI64 GetDuration() { return m_Duration; }
+ void SetDuration(AP4_UI64 duration) { m_Duration = duration; }
+ AP4_UI32 GetTimeScale() { return m_TimeScale; }
+ void SetTimeScale(AP4_UI32 timescale) { m_TimeScale = timescale; }
+ const AP4_String& GetLanguage() { return m_Language; }
private:
// methods
- AP4_MdhdAtom(AP4_UI32 size,
+ AP4_MdhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.cpp
index 3d25a7b52..cf4ae40ca 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - mehd Atoms
+| AP4 - mehd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_MehdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version > 1) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version > 1) return NULL;
return new AP4_MehdAtom(size, version, flags, stream);
}
@@ -55,11 +55,10 @@ AP4_MehdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_MehdAtom::AP4_MehdAtom
+---------------------------------------------------------------------*/
AP4_MehdAtom::AP4_MehdAtom(AP4_UI64 duration) :
- AP4_Atom(AP4_ATOM_TYPE_MEHD, AP4_FULL_ATOM_HEADER_SIZE + 4, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_MEHD, AP4_FULL_ATOM_HEADER_SIZE+4, 0, 0),
m_Duration(duration)
{
- if(duration > 0xFFFFFFFF)
- {
+ if (duration > 0xFFFFFFFF) {
m_Version = 1;
m_Size32 += 4;
}
@@ -68,20 +67,17 @@ AP4_MehdAtom::AP4_MehdAtom(AP4_UI64 duration) :
/*----------------------------------------------------------------------
| AP4_MehdAtom::AP4_MehdAtom
+---------------------------------------------------------------------*/
-AP4_MehdAtom::AP4_MehdAtom(AP4_UI32 size,
+AP4_MehdAtom::AP4_MehdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_MEHD, size, version, flags)
{
- if(m_Version == 0)
- {
+ if (m_Version == 0) {
AP4_UI32 duration;
stream.ReadUI32(duration);
m_Duration = duration;
- }
- else
- {
+ } else {
stream.ReadUI64(m_Duration);
}
}
@@ -92,12 +88,9 @@ AP4_MehdAtom::AP4_MehdAtom(AP4_UI32 size,
AP4_Result
AP4_MehdAtom::WriteFields(AP4_ByteStream& stream)
{
- if(m_Version == 0)
- {
+ if (m_Version == 0) {
return stream.WriteUI32((AP4_UI32)m_Duration);
- }
- else
- {
+ } else {
return stream.WriteUI64(m_Duration);
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.h
index 211da83ca..5d0052920 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MehdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - mehd Atoms
+| AP4 - mehd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -50,21 +50,15 @@ public:
AP4_MehdAtom(AP4_UI64 duration);
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_UI64 GetDuration()
- {
- return m_Duration;
- }
- void SetDuration(AP4_UI64 duration)
- {
- m_Duration = duration;
- }
+ AP4_UI64 GetDuration() { return m_Duration; }
+ void SetDuration(AP4_UI64 duration) { m_Duration = duration;}
private:
// methods
- AP4_MehdAtom(AP4_UI32 size,
+ AP4_MehdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
- AP4_ByteStream& stream);
+ AP4_ByteStream& stream);
// members
AP4_UI64 m_Duration;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.cpp
index e2fe2a4c2..62294f74a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - mfhd Atoms
+| AP4 - mfhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_MfhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version > 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version > 0) return NULL;
return new AP4_MfhdAtom(size, version, flags, stream);
}
@@ -55,7 +55,7 @@ AP4_MfhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_MfhdAtom::AP4_MfhdAtom
+---------------------------------------------------------------------*/
AP4_MfhdAtom::AP4_MfhdAtom(AP4_UI32 sequence_number) :
- AP4_Atom(AP4_ATOM_TYPE_MFHD, AP4_FULL_ATOM_HEADER_SIZE + 4, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_MFHD, AP4_FULL_ATOM_HEADER_SIZE+4, 0, 0),
m_SequenceNumber(sequence_number)
{
}
@@ -63,7 +63,7 @@ AP4_MfhdAtom::AP4_MfhdAtom(AP4_UI32 sequence_number) :
/*----------------------------------------------------------------------
| AP4_MfhdAtom::AP4_MfhdAtom
+---------------------------------------------------------------------*/
-AP4_MfhdAtom::AP4_MfhdAtom(AP4_UI32 size,
+AP4_MfhdAtom::AP4_MfhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.h
index 619cac1cd..ecdaacb0d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfhdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - mfhd Atoms
+| AP4 - mfhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -50,18 +50,12 @@ public:
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_UI32 GetSequenceNumber()
- {
- return m_SequenceNumber;
- }
- void SetSequenceNumber(AP4_UI32 sequence_number)
- {
- m_SequenceNumber = sequence_number;
- }
+ AP4_UI32 GetSequenceNumber() { return m_SequenceNumber; }
+ void SetSequenceNumber(AP4_UI32 sequence_number) { m_SequenceNumber = sequence_number; }
private:
// methods
- AP4_MfhdAtom(AP4_UI32 size,
+ AP4_MfhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.cpp
index d9de9a6fe..7000bb529 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tfra Atoms
+| AP4 - tfra Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -36,14 +36,14 @@
/*----------------------------------------------------------------------
| AP4_MfroAtom::Create
+---------------------------------------------------------------------*/
-AP4_MfroAtom*
+AP4_MfroAtom*
AP4_MfroAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version = 0;
AP4_UI32 flags = 0;
AP4_Result result = ReadFullHeader(stream, version, flags);
- if(AP4_FAILED(result)) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(result)) return NULL;
+ if (version != 0) return NULL;
return new AP4_MfroAtom(size, version, flags, stream);
}
@@ -51,7 +51,7 @@ AP4_MfroAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_MfroAtom::AP4_MfroAtom
+---------------------------------------------------------------------*/
AP4_MfroAtom::AP4_MfroAtom(AP4_UI32 mfra_size) :
- AP4_Atom(AP4_ATOM_TYPE_MFRO, AP4_FULL_ATOM_HEADER_SIZE + 4),
+ AP4_Atom(AP4_ATOM_TYPE_MFRO, AP4_FULL_ATOM_HEADER_SIZE+4),
m_MfraSize(mfra_size)
{
}
@@ -59,9 +59,9 @@ AP4_MfroAtom::AP4_MfroAtom(AP4_UI32 mfra_size) :
/*----------------------------------------------------------------------
| AP4_MfroAtom::AP4_MfroAtom
+---------------------------------------------------------------------*/
-AP4_MfroAtom::AP4_MfroAtom(AP4_UI32 size,
- AP4_UI32 version,
- AP4_UI32 flags,
+AP4_MfroAtom::AP4_MfroAtom(AP4_UI32 size,
+ AP4_UI32 version,
+ AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_MFRO, size, version, flags)
{
@@ -84,6 +84,6 @@ AP4_Result
AP4_MfroAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("mfra_size", m_MfraSize);
-
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.h
index 53992aa30..82ab1d867 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MfroAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - mfro Atoms
+| AP4 - mfro Atoms
|
| Copyright 2002-2009 Axiomatic Systems, LLC
|
@@ -49,8 +49,8 @@ class AP4_MfroAtom : public AP4_Atom
public:
// class methods
static AP4_MfroAtom* Create(AP4_Size size, AP4_ByteStream& stream);
-
- // constructors
+
+ // constructors
AP4_MfroAtom(AP4_UI32 mfra_size);
// methods
@@ -58,11 +58,8 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- AP4_UI32 GetMfraSize()
- {
- return m_MfraSize;
- }
-
+ AP4_UI32 GetMfraSize() { return m_MfraSize; }
+
private:
// methods
AP4_MfroAtom(AP4_UI32 size, AP4_UI32 version, AP4_UI32 flags, AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.cpp
index b1f771e44..a50080cf1 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - moov Atoms
+| AP4 - moov Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -53,13 +53,10 @@ public:
AP4_TrakAtomCollector(AP4_List<AP4_TrakAtom>* track_atoms) :
m_TrakAtoms(track_atoms) {}
- AP4_Result Action(AP4_Atom* atom) const
- {
- if(atom->GetType() == AP4_ATOM_TYPE_TRAK)
- {
+ AP4_Result Action(AP4_Atom* atom) const {
+ if (atom->GetType() == AP4_ATOM_TYPE_TRAK) {
AP4_TrakAtom* trak = AP4_DYNAMIC_CAST(AP4_TrakAtom, atom);
- if(trak)
- {
+ if (trak) {
m_TrakAtoms->Add(trak);
}
}
@@ -88,98 +85,97 @@ AP4_MoovAtom::AP4_MoovAtom(AP4_UI32 size,
AP4_ContainerAtom(AP4_ATOM_TYPE_MOOV, size, false, stream, atom_factory),
m_TimeScale(0)
{
- // ==> Start patch MPC
- if(AP4_ContainerAtom* cmov = dynamic_cast<AP4_ContainerAtom*>(GetChild(AP4_ATOM_TYPE_CMOV)))
- {
- AP4_DcomAtom* dcom = dynamic_cast<AP4_DcomAtom*>(cmov->GetChild(AP4_ATOM_TYPE_DCOM));
- AP4_CmvdAtom* cmvd = dynamic_cast<AP4_CmvdAtom*>(cmov->GetChild(AP4_ATOM_TYPE_CMVD));
- if(dcom && dcom->GetCompressorSubType() == AP4_ATOM_TYPE('z', 'l', 'i', 'b') && cmvd)
- {
- const AP4_DataBuffer& data = cmvd->GetDataBuffer();
-
- z_stream d_stream;
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
-
- int res;
-
- if(Z_OK == (res = inflateInit(&d_stream)))
- {
- d_stream.next_in = (Bytef*)data.GetData();
- d_stream.avail_in = data.GetDataSize();
-
- unsigned char* dst = NULL;
- int n = 0;
-
- do
- {
- dst = (unsigned char*)realloc(dst, ++n * 1000);
- d_stream.next_out = &dst[(n-1)*1000];
- d_stream.avail_out = 1000;
-
- if(Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res)
- {
- free(dst);
- dst = NULL;
- break;
- }
- }
- while(0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
-
- inflateEnd(&d_stream);
-
- if(dst)
- {
- AP4_ByteStream* s = new AP4_MemoryByteStream(dst, d_stream.total_out);
- ReadChildren(atom_factory, *s, d_stream.total_out);
- s->Release();
- free(dst);
- }
-
- if(AP4_MoovAtom* moov = dynamic_cast<AP4_MoovAtom*>(GetChild(AP4_ATOM_TYPE_MOOV)))
- {
- AP4_List<AP4_Atom> Children;
-
- for(AP4_List<AP4_Atom>::Item* item = moov->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
- Children.Add(item->GetData());
- }
-
- for(AP4_List<AP4_Atom>::Item* item = Children.FirstItem();
- item;
- item = item->GetNext())
- {
- AP4_Atom* atom = item->GetData();
- atom->Detach();
- atom->SetParent(this);
- m_Children.Add(atom);
- }
-
- moov->Detach();
- delete moov;
- }
- }
- }
- }
- // <== End patch MPC
-
- // collect all trak atoms
- m_Children.Apply(AP4_TrakAtomCollector(&m_TrakAtoms));
+ // ==> Start patch MPC
+ if(AP4_ContainerAtom* cmov = dynamic_cast<AP4_ContainerAtom*>(GetChild(AP4_ATOM_TYPE_CMOV)))
+ {
+ AP4_DcomAtom* dcom = dynamic_cast<AP4_DcomAtom*>(cmov->GetChild(AP4_ATOM_TYPE_DCOM));
+ AP4_CmvdAtom* cmvd = dynamic_cast<AP4_CmvdAtom*>(cmov->GetChild(AP4_ATOM_TYPE_CMVD));
+ if(dcom && dcom->GetCompressorSubType() == AP4_ATOM_TYPE('z','l','i','b') && cmvd)
+ {
+ const AP4_DataBuffer& data = cmvd->GetDataBuffer();
+
+ z_stream d_stream;
+ d_stream.zalloc = (alloc_func)0;
+ d_stream.zfree = (free_func)0;
+ d_stream.opaque = (voidpf)0;
+
+ int res;
+
+ if(Z_OK == (res = inflateInit(&d_stream)))
+ {
+ d_stream.next_in = (Bytef*)data.GetData();
+ d_stream.avail_in = data.GetDataSize();
+
+ unsigned char* dst = NULL;
+ int n = 0;
+
+ do
+ {
+ dst = (unsigned char*)realloc(dst, ++n*1000);
+ d_stream.next_out = &dst[(n-1)*1000];
+ d_stream.avail_out = 1000;
+
+ if(Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res)
+ {
+ free(dst);
+ dst = NULL;
+ break;
+ }
+ }
+ while(0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
+
+ inflateEnd(&d_stream);
+
+ if(dst)
+ {
+ AP4_ByteStream* s = new AP4_MemoryByteStream(dst, d_stream.total_out);
+ ReadChildren(atom_factory, *s, d_stream.total_out);
+ s->Release();
+ free(dst);
+ }
+
+ if(AP4_MoovAtom* moov = dynamic_cast<AP4_MoovAtom*>(GetChild(AP4_ATOM_TYPE_MOOV)))
+ {
+ AP4_List<AP4_Atom> Children;
+
+ for(AP4_List<AP4_Atom>::Item* item = moov->GetChildren().FirstItem();
+ item;
+ item = item->GetNext())
+ {
+ Children.Add(item->GetData());
+ }
+
+ for(AP4_List<AP4_Atom>::Item* item = Children.FirstItem();
+ item;
+ item = item->GetNext())
+ {
+ AP4_Atom* atom = item->GetData();
+ atom->Detach();
+ atom->SetParent(this);
+ m_Children.Add(atom);
+ }
+
+ moov->Detach();
+ delete moov;
+ }
+ }
+ }
+ }
+ // <== End patch MPC
+
+ // collect all trak atoms
+ m_Children.Apply(AP4_TrakAtomCollector(&m_TrakAtoms));
}
/*----------------------------------------------------------------------
| AP4_MoovAtom::AdjustChunkOffsets
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MoovAtom::AdjustChunkOffsets(AP4_SI64 offset)
{
- for(AP4_List<AP4_TrakAtom>::Item* item = m_TrakAtoms.FirstItem();
- item;
- item = item->GetNext())
- {
+ for (AP4_List<AP4_TrakAtom>::Item* item = m_TrakAtoms.FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_TrakAtom* trak = item->GetData();
trak->AdjustChunkOffsets(offset);
}
@@ -194,11 +190,9 @@ void
AP4_MoovAtom::OnChildAdded(AP4_Atom* atom)
{
// keep the atom in the list of trak atoms
- if(atom->GetType() == AP4_ATOM_TYPE_TRAK)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_TRAK) {
AP4_TrakAtom* trak = AP4_DYNAMIC_CAST(AP4_TrakAtom, atom);
- if(trak)
- {
+ if (trak) {
m_TrakAtoms.Add(trak);
}
}
@@ -214,11 +208,9 @@ void
AP4_MoovAtom::OnChildRemoved(AP4_Atom* atom)
{
// remove the atom from the list of trak atoms
- if(atom->GetType() == AP4_ATOM_TYPE_TRAK)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_TRAK) {
AP4_TrakAtom* trak = AP4_DYNAMIC_CAST(AP4_TrakAtom, atom);
- if(trak)
- {
+ if (trak) {
m_TrakAtoms.Remove(trak);
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.h
index 8506e0a25..f06b2a137 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MoovAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - moov Atoms
+| AP4 - moov Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -52,23 +52,20 @@ public:
// class methods
static AP4_MoovAtom* Create(AP4_Size size,
AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory)
- {
+ AP4_AtomFactory& atom_factory) {
return new AP4_MoovAtom(size, stream, atom_factory);
}
// methods
AP4_MoovAtom();
- AP4_List<AP4_TrakAtom>& GetTrakAtoms()
- {
+ AP4_List<AP4_TrakAtom>& GetTrakAtoms() {
return m_TrakAtoms;
}
- AP4_UI32 GetTimeScale()
- {
+ AP4_UI32 GetTimeScale() {
return m_TimeScale;
}
AP4_Result AdjustChunkOffsets(AP4_SI64 offset);
-
+
// AP4_AtomParent methods
void OnChildAdded(AP4_Atom* atom);
void OnChildRemoved(AP4_Atom* atom);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.cpp
index bd6e24251..57c8c3c50 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.cpp
@@ -45,8 +45,7 @@ class AP4_TrackFinderById : public AP4_List<AP4_Track>::Item::Finder
{
public:
AP4_TrackFinderById(AP4_UI32 track_id) : m_TrackId(track_id) {}
- AP4_Result Test(AP4_Track* track) const
- {
+ AP4_Result Test(AP4_Track* track) const {
return track->GetId() == m_TrackId ? AP4_SUCCESS : AP4_FAILURE;
}
private:
@@ -59,16 +58,12 @@ private:
class AP4_TrackFinderByType : public AP4_List<AP4_Track>::Item::Finder
{
public:
- AP4_TrackFinderByType(AP4_Track::Type type, AP4_Ordinal index = 0) :
- m_Type(type), m_Index(index) {}
- AP4_Result Test(AP4_Track* track) const
- {
- if(track->GetType() == m_Type && m_Index-- == 0)
- {
+ AP4_TrackFinderByType(AP4_Track::Type type, AP4_Ordinal index = 0) :
+ m_Type(type), m_Index(index) {}
+ AP4_Result Test(AP4_Track* track) const {
+ if (track->GetType() == m_Type && m_Index-- == 0) {
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_FAILURE;
}
}
@@ -84,9 +79,9 @@ AP4_Movie::AP4_Movie(AP4_UI32 time_scale) :
m_MoovAtomIsOwned(true)
{
m_MoovAtom = new AP4_MoovAtom();
- m_MvhdAtom = new AP4_MvhdAtom(0, 0,
- time_scale,
- 0,
+ m_MvhdAtom = new AP4_MvhdAtom(0, 0,
+ time_scale,
+ 0,
0x00010000,
0x0100);
m_MoovAtom->AddChild(m_MvhdAtom);
@@ -100,17 +95,14 @@ AP4_Movie::AP4_Movie(AP4_MoovAtom* moov, AP4_ByteStream& sample_stream, bool tra
m_MoovAtomIsOwned(transfer_moov_ownership)
{
// ignore null atoms
- if(moov == NULL) return;
+ if (moov == NULL) return;
// get the time scale
AP4_UI32 time_scale;
m_MvhdAtom = AP4_DYNAMIC_CAST(AP4_MvhdAtom, moov->GetChild(AP4_ATOM_TYPE_MVHD));
- if(m_MvhdAtom)
- {
+ if (m_MvhdAtom) {
time_scale = m_MvhdAtom->GetTimeScale();
- }
- else
- {
+ } else {
time_scale = 0;
}
@@ -118,23 +110,22 @@ AP4_Movie::AP4_Movie(AP4_MoovAtom* moov, AP4_ByteStream& sample_stream, bool tra
AP4_List<AP4_TrakAtom>* trak_atoms;
trak_atoms = &moov->GetTrakAtoms();
AP4_List<AP4_TrakAtom>::Item* item = trak_atoms->FirstItem();
- while(item)
- {
- AP4_Track* track = new AP4_Track(*item->GetData(),
+ while (item) {
+ AP4_Track* track = new AP4_Track(*item->GetData(),
sample_stream,
time_scale);
m_Tracks.Add(track);
item = item->GetNext();
}
}
-
+
/*----------------------------------------------------------------------
| AP4_Movie::~AP4_Movie
+---------------------------------------------------------------------*/
AP4_Movie::~AP4_Movie()
{
m_Tracks.DeleteReferences();
- if(m_MoovAtomIsOwned) delete m_MoovAtom;
+ if (m_MoovAtomIsOwned) delete m_MoovAtom;
}
/*----------------------------------------------------------------------
@@ -154,12 +145,9 @@ AP4_Track*
AP4_Movie::GetTrack(AP4_UI32 track_id)
{
AP4_Track* track = NULL;
- if(AP4_SUCCEEDED(m_Tracks.Find(AP4_TrackFinderById(track_id), track)))
- {
+ if (AP4_SUCCEEDED(m_Tracks.Find(AP4_TrackFinderById(track_id), track))) {
return track;
- }
- else
- {
+ } else {
return NULL;
}
}
@@ -171,12 +159,9 @@ AP4_Track*
AP4_Movie::GetTrack(AP4_Track::Type track_type, AP4_Ordinal index)
{
AP4_Track* track = NULL;
- if(AP4_SUCCEEDED(m_Tracks.Find(AP4_TrackFinderByType(track_type, index), track)))
- {
+ if (AP4_SUCCEEDED(m_Tracks.Find(AP4_TrackFinderByType(track_type, index), track))) {
return track;
- }
- else
- {
+ } else {
return NULL;
}
}
@@ -188,14 +173,12 @@ AP4_Result
AP4_Movie::AddTrack(AP4_Track* track)
{
// assign an ID to the track unless it already has one
- if(track->GetId() == 0)
- {
- track->SetId(m_Tracks.ItemCount() + 1);
+ if (track->GetId() == 0) {
+ track->SetId(m_Tracks.ItemCount()+1);
}
// if we don't have a time scale, use the one from the track
- if(m_MvhdAtom->GetTimeScale() == 0)
- {
+ if (m_MvhdAtom->GetTimeScale() == 0) {
m_MvhdAtom->SetTimeScale(track->GetMediaTimeScale());
}
@@ -203,11 +186,10 @@ AP4_Movie::AddTrack(AP4_Track* track)
track->SetMovieTimeScale(m_MvhdAtom->GetTimeScale());
// update the movie duration
- if(m_MvhdAtom->GetDuration() < track->GetDuration())
- {
+ if (m_MvhdAtom->GetDuration() < track->GetDuration()) {
m_MvhdAtom->SetDuration(track->GetDuration());
}
-
+
// attach the track as a child
track->Attach(m_MoovAtom);
m_Tracks.Add(track);
@@ -221,12 +203,9 @@ AP4_Movie::AddTrack(AP4_Track* track)
AP4_UI32
AP4_Movie::GetTimeScale()
{
- if(m_MvhdAtom)
- {
+ if (m_MvhdAtom) {
return m_MvhdAtom->GetTimeScale();
- }
- else
- {
+ } else {
return 0;
}
}
@@ -237,12 +216,9 @@ AP4_Movie::GetTimeScale()
AP4_UI64
AP4_Movie::GetDuration()
{
- if(m_MvhdAtom)
- {
+ if (m_MvhdAtom) {
return m_MvhdAtom->GetDuration();
- }
- else
- {
+ } else {
return 0;
}
}
@@ -253,12 +229,9 @@ AP4_Movie::GetDuration()
AP4_UI32
AP4_Movie::GetDurationMs()
{
- if(m_MvhdAtom)
- {
+ if (m_MvhdAtom) {
return m_MvhdAtom->GetDurationMs();
- }
- else
- {
+ } else {
return 0;
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.h
index 8cea28a26..80d6cdb19 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Movie.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - Movie
+| AP4 - Movie
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -48,8 +48,7 @@ class AP4_MetaData;
/*----------------------------------------------------------------------
| AP4_Movie
+---------------------------------------------------------------------*/
-class AP4_Movie
-{
+class AP4_Movie {
public:
// methods
AP4_Movie(AP4_UI32 time_scale = 0);
@@ -57,25 +56,16 @@ public:
virtual ~AP4_Movie();
AP4_Result Inspect(AP4_AtomInspector& inspector);
- AP4_MoovAtom* GetMoovAtom()
- {
- return m_MoovAtom;
- }
- AP4_MvhdAtom* GetMvhdAtom()
- {
- return m_MvhdAtom;
- }
- AP4_List<AP4_Track>& GetTracks()
- {
- return m_Tracks;
- }
+ AP4_MoovAtom* GetMoovAtom() { return m_MoovAtom;}
+ AP4_MvhdAtom* GetMvhdAtom() { return m_MvhdAtom;}
+ AP4_List<AP4_Track>& GetTracks() { return m_Tracks; }
AP4_Track* GetTrack(AP4_UI32 track_id);
AP4_Track* GetTrack(AP4_Track::Type type, AP4_Ordinal index = 0);
AP4_Result AddTrack(AP4_Track* track);
AP4_UI32 GetTimeScale();
AP4_UI64 GetDuration();
AP4_UI32 GetDurationMs();
-
+
private:
// members
AP4_MoovAtom* m_MoovAtom;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.cpp
index 4d982d409..d85bc008b 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.cpp
@@ -47,7 +47,7 @@ AP4_MovieFragment::AP4_MovieFragment(AP4_ContainerAtom* moof) :
m_MoofAtom(moof),
m_MfhdAtom(NULL)
{
- if(moof) m_MfhdAtom = AP4_DYNAMIC_CAST(AP4_MfhdAtom, moof->GetChild(AP4_ATOM_TYPE_MFHD));
+ if (moof) m_MfhdAtom = AP4_DYNAMIC_CAST(AP4_MfhdAtom, moof->GetChild(AP4_ATOM_TYPE_MFHD));
}
/*----------------------------------------------------------------------
@@ -64,7 +64,7 @@ AP4_MovieFragment::~AP4_MovieFragment()
AP4_UI32
AP4_MovieFragment::GetSequenceNumber()
{
- return m_MfhdAtom ? m_MfhdAtom->GetSequenceNumber() : 0;
+ return m_MfhdAtom?m_MfhdAtom->GetSequenceNumber():0;
}
/*----------------------------------------------------------------------
@@ -75,51 +75,44 @@ AP4_MovieFragment::GetTrackIds(AP4_Array<AP4_UI32>& ids)
{
ids.Clear();
ids.EnsureCapacity(m_MoofAtom->GetChildren().ItemCount());
-
- for(AP4_List<AP4_Atom>::Item* item = m_MoofAtom->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
+
+ for (AP4_List<AP4_Atom>::Item* item = m_MoofAtom->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
- if(atom->GetType() == AP4_ATOM_TYPE_TRAF)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_TRAF) {
AP4_ContainerAtom* traf = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
- if(traf)
- {
+ if (traf) {
AP4_TfhdAtom* tfhd = AP4_DYNAMIC_CAST(AP4_TfhdAtom, traf->GetChild(AP4_ATOM_TYPE_TFHD));
- if(tfhd) ids.Append(tfhd->GetTrackId());
+ if (tfhd) ids.Append(tfhd->GetTrackId());
}
}
}
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_MovieFragment::GetTrafAtom
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MovieFragment::GetTrafAtom(AP4_UI32 track_id, AP4_ContainerAtom*& traf)
{
- for(AP4_List<AP4_Atom>::Item* item = m_MoofAtom->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
+ for (AP4_List<AP4_Atom>::Item* item = m_MoofAtom->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
- if(atom->GetType() == AP4_ATOM_TYPE_TRAF)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_TRAF) {
traf = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
- if(traf)
- {
+ if (traf) {
AP4_TfhdAtom* tfhd = AP4_DYNAMIC_CAST(AP4_TfhdAtom, traf->GetChild(AP4_ATOM_TYPE_TFHD));
- if(tfhd && tfhd->GetTrackId() == track_id)
- {
+ if (tfhd && tfhd->GetTrackId() == track_id) {
return AP4_SUCCESS;
}
}
}
}
-
+
// not found
traf = NULL;
return AP4_ERROR_NO_SUCH_ITEM;
@@ -128,9 +121,9 @@ AP4_MovieFragment::GetTrafAtom(AP4_UI32 track_id, AP4_ContainerAtom*& traf)
/*----------------------------------------------------------------------
| AP4_MovieFragment::CreateSampleTable
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MovieFragment::CreateSampleTable(AP4_MoovAtom* moov,
- AP4_UI32 track_id,
+ AP4_UI32 track_id,
AP4_ByteStream* sample_stream,
AP4_Position moof_offset,
AP4_Position mdat_payload_offset,
@@ -138,54 +131,49 @@ AP4_MovieFragment::CreateSampleTable(AP4_MoovAtom* moov,
{
// default value
sample_table = NULL;
-
+
// find a trex for this track, if any
AP4_ContainerAtom* mvex = NULL;
AP4_TrexAtom* trex = NULL;
- if(moov)
- {
+ if (moov) {
mvex = AP4_DYNAMIC_CAST(AP4_ContainerAtom, moov->GetChild(AP4_ATOM_TYPE_MVEX));
}
- if(mvex)
- {
- for(AP4_List<AP4_Atom>::Item* item = mvex->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
+ if (mvex) {
+ for (AP4_List<AP4_Atom>::Item* item = mvex->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
- if(atom->GetType() == AP4_ATOM_TYPE_TREX)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_TREX) {
trex = AP4_DYNAMIC_CAST(AP4_TrexAtom, atom);
- if(trex && trex->GetTrackId() == track_id) break;
+ if (trex && trex->GetTrackId() == track_id) break;
trex = NULL;
}
}
}
AP4_ContainerAtom* traf = NULL;
- if(AP4_SUCCEEDED(GetTrafAtom(track_id, traf)))
- {
- sample_table = new AP4_FragmentSampleTable(traf,
- trex,
- sample_stream,
- moof_offset,
- mdat_payload_offset);
+ if (AP4_SUCCEEDED(GetTrafAtom(track_id, traf))) {
+ sample_table = new AP4_FragmentSampleTable(traf,
+ trex,
+ sample_stream,
+ moof_offset,
+ mdat_payload_offset);
return AP4_SUCCESS;
}
-
+
return AP4_ERROR_NO_SUCH_ITEM;
}
/*----------------------------------------------------------------------
| AP4_MovieFragment::CreateSampleTable
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MovieFragment::CreateSampleTable(AP4_Movie* movie,
- AP4_UI32 track_id,
+ AP4_UI32 track_id,
AP4_ByteStream* sample_stream,
AP4_Position moof_offset,
AP4_Position mdat_payload_offset,
AP4_FragmentSampleTable*& sample_table)
{
- AP4_MoovAtom* moov = movie ? movie->GetMoovAtom() : NULL;
+ AP4_MoovAtom* moov = movie?movie->GetMoovAtom():NULL;
return CreateSampleTable(moov, track_id, sample_stream, moof_offset, mdat_payload_offset, sample_table);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.h
index 92b2c6de3..6ff5aae9a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MovieFragment.h
@@ -53,38 +53,31 @@ const AP4_UI32 AP4_FRAG_FLAG_SAMPLE_IS_DIFFERENCE = 0x00010000;
/*----------------------------------------------------------------------
| AP4_MovieFragment
+---------------------------------------------------------------------*/
-class AP4_MovieFragment
-{
+class AP4_MovieFragment {
public:
// this constructor transfers the ownership of the moof atom to the
// newly constructed object
AP4_MovieFragment(AP4_ContainerAtom* moof);
virtual ~AP4_MovieFragment();
- AP4_ContainerAtom* GetMoofAtom()
- {
- return m_MoofAtom;
- }
- AP4_MfhdAtom* GetMfhdAtom()
- {
- return m_MfhdAtom;
- }
+ AP4_ContainerAtom* GetMoofAtom() { return m_MoofAtom;}
+ AP4_MfhdAtom* GetMfhdAtom() { return m_MfhdAtom;}
AP4_UI32 GetSequenceNumber();
AP4_Result GetTrackIds(AP4_Array<AP4_UI32>& ids);
AP4_Result GetTrafAtom(AP4_UI32 track_id, AP4_ContainerAtom*& traf);
AP4_Result CreateSampleTable(AP4_MoovAtom* moov,
- AP4_UI32 track_id,
+ AP4_UI32 track_id,
AP4_ByteStream* sample_stream,
AP4_Position moof_offset,
AP4_Position mdat_payload_offset, // hack because MS doesn't implement the spec properly
AP4_FragmentSampleTable*& sample_table);
AP4_Result CreateSampleTable(AP4_Movie* movie,
- AP4_UI32 track_id,
+ AP4_UI32 track_id,
AP4_ByteStream* sample_stream,
AP4_Position moof_offset,
AP4_Position mdat_payload_offset, // hack because MS doesn't implement the spec properly
AP4_FragmentSampleTable*& sample_table);
-
+
private:
// members
AP4_ContainerAtom* m_MoofAtom;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.cpp
index 8078a6d05..dbb5f5982 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.cpp
@@ -43,30 +43,30 @@ const unsigned int AP4_MPEG2TS_PACKET_PAYLOAD_SIZE = 184;
const unsigned int AP4_MPEG2TS_SYNC_BYTE = 0x47;
const unsigned int AP4_MPEG2TS_PCR_ADAPTATION_SIZE = 6;
-static unsigned char const StuffingBytes[AP4_MPEG2TS_PACKET_SIZE] =
+static unsigned char const StuffingBytes[AP4_MPEG2TS_PACKET_SIZE] =
{
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF
};
@@ -77,36 +77,21 @@ static unsigned char const StuffingBytes[AP4_MPEG2TS_PACKET_SIZE] =
static unsigned int
GetSamplingFrequencyIndex(unsigned int sampling_frequency)
{
- switch(sampling_frequency)
- {
- case 96000:
- return 0;
- case 88200:
- return 1;
- case 64000:
- return 2;
- case 48000:
- return 3;
- case 44100:
- return 4;
- case 32000:
- return 5;
- case 24000:
- return 6;
- case 22050:
- return 7;
- case 16000:
- return 8;
- case 12000:
- return 9;
- case 11025:
- return 10;
- case 8000:
- return 11;
- case 7350:
- return 12;
- default:
- return 0;
+ switch (sampling_frequency) {
+ case 96000: return 0;
+ case 88200: return 1;
+ case 64000: return 2;
+ case 48000: return 3;
+ case 44100: return 4;
+ case 32000: return 5;
+ case 24000: return 6;
+ case 22050: return 7;
+ case 16000: return 8;
+ case 12000: return 9;
+ case 11025: return 10;
+ case 8000: return 11;
+ case 7350: return 12;
+ default: return 0;
}
}
@@ -114,49 +99,48 @@ GetSamplingFrequencyIndex(unsigned int sampling_frequency)
| MakeAdtsHeader
+---------------------------------------------------------------------*/
static void
-MakeAdtsHeader(unsigned char bits[7],
+MakeAdtsHeader(unsigned char bits[7],
unsigned int frame_size,
unsigned int sampling_frequency_index,
unsigned int channel_configuration)
{
- bits[0] = 0xFF;
- bits[1] = 0xF1; // 0xF9 (MPEG2)
- bits[2] = 0x40 | (sampling_frequency_index << 2) | (channel_configuration >> 2);
- bits[3] = ((channel_configuration & 0x3) << 6) | ((frame_size + 7) >> 11);
- bits[4] = ((frame_size + 7) >> 3) & 0xFF;
- bits[5] = (((frame_size + 7) << 5) & 0xFF) | 0x1F;
- bits[6] = 0xFC;
-
- /*
- 0: syncword 12 always: '111111111111'
- 12: ID 1 0: MPEG-4, 1: MPEG-2
- 13: layer 2 always: '00'
- 15: protection_absent 1
- 16: profile 2
- 18: sampling_frequency_index 4
- 22: private_bit 1
- 23: channel_configuration 3
- 26: original/copy 1
- 27: home 1
- 28: emphasis 2 only if ID == 0
-
- ADTS Variable header: these can change from frame to frame
- 28: copyright_identification_bit 1
- 29: copyright_identification_start 1
- 30: aac_frame_length 13 length of the frame including header (in bytes)
- 43: adts_buffer_fullness 11 0x7FF indicates VBR
- 54: no_raw_data_blocks_in_frame 2
- ADTS Error check
- crc_check 16 only if protection_absent == 0
+ bits[0] = 0xFF;
+ bits[1] = 0xF1; // 0xF9 (MPEG2)
+ bits[2] = 0x40 | (sampling_frequency_index << 2) | (channel_configuration >> 2);
+ bits[3] = ((channel_configuration&0x3)<<6) | ((frame_size+7) >> 11);
+ bits[4] = ((frame_size+7) >> 3)&0xFF;
+ bits[5] = (((frame_size+7) << 5)&0xFF) | 0x1F;
+ bits[6] = 0xFC;
+
+ /*
+ 0: syncword 12 always: '111111111111'
+ 12: ID 1 0: MPEG-4, 1: MPEG-2
+ 13: layer 2 always: '00'
+ 15: protection_absent 1
+ 16: profile 2
+ 18: sampling_frequency_index 4
+ 22: private_bit 1
+ 23: channel_configuration 3
+ 26: original/copy 1
+ 27: home 1
+ 28: emphasis 2 only if ID == 0
+
+ ADTS Variable header: these can change from frame to frame
+ 28: copyright_identification_bit 1
+ 29: copyright_identification_start 1
+ 30: aac_frame_length 13 length of the frame including header (in bytes)
+ 43: adts_buffer_fullness 11 0x7FF indicates VBR
+ 54: no_raw_data_blocks_in_frame 2
+ ADTS Error check
+ crc_check 16 only if protection_absent == 0
*/
}
/*----------------------------------------------------------------------
| CRC_Table
+---------------------------------------------------------------------*/
-static AP4_UI32
-const CRC_Table[256] =
-{
+static AP4_UI32
+const CRC_Table[256] = {
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
@@ -209,12 +193,11 @@ static AP4_UI32
ComputeCRC(const unsigned char* data, unsigned int data_size)
{
AP4_UI32 crc = 0xFFFFFFFF;
-
- for(unsigned int i = 0; i < data_size; i++)
- {
+
+ for (unsigned int i=0; i<data_size; i++) {
crc = (crc << 8) ^ CRC_Table[((crc >> 24) ^ *data++) & 0xFF];
}
-
+
return crc;
}
@@ -222,242 +205,226 @@ ComputeCRC(const unsigned char* data, unsigned int data_size)
| AP4_Mpeg2TsWriter::Stream::WritePacketHeader
+---------------------------------------------------------------------*/
void
-AP4_Mpeg2TsWriter::Stream::WritePacketHeader(bool payload_start,
- unsigned int& payload_size,
- bool with_pcr,
- AP4_UI64 pcr,
- AP4_ByteStream& output)
+AP4_Mpeg2TsWriter::Stream::WritePacketHeader(bool payload_start,
+ unsigned int& payload_size,
+ bool with_pcr,
+ AP4_UI64 pcr,
+ AP4_ByteStream& output)
{
unsigned char header[4];
header[0] = AP4_MPEG2TS_SYNC_BYTE;
- header[1] = ((payload_start ? 1 : 0) << 6) | (m_PID >> 8);
+ header[1] = ((payload_start?1:0)<<6) | (m_PID >> 8);
header[2] = m_PID & 0xFF;
-
+
unsigned int adaptation_field_size = 0;
- if(with_pcr) adaptation_field_size += 2 + AP4_MPEG2TS_PCR_ADAPTATION_SIZE;
-
+ if (with_pcr) adaptation_field_size += 2+AP4_MPEG2TS_PCR_ADAPTATION_SIZE;
+
// clamp the payload size
- if(payload_size + adaptation_field_size > AP4_MPEG2TS_PACKET_PAYLOAD_SIZE)
- {
- payload_size = AP4_MPEG2TS_PACKET_PAYLOAD_SIZE - adaptation_field_size;
+ if (payload_size+adaptation_field_size > AP4_MPEG2TS_PACKET_PAYLOAD_SIZE) {
+ payload_size = AP4_MPEG2TS_PACKET_PAYLOAD_SIZE-adaptation_field_size;
}
-
+
// adjust the adaptation field to include stuffing if necessary
- if(adaptation_field_size + payload_size < AP4_MPEG2TS_PACKET_PAYLOAD_SIZE)
- {
- adaptation_field_size = AP4_MPEG2TS_PACKET_PAYLOAD_SIZE - payload_size;
+ if (adaptation_field_size+payload_size < AP4_MPEG2TS_PACKET_PAYLOAD_SIZE) {
+ adaptation_field_size = AP4_MPEG2TS_PACKET_PAYLOAD_SIZE-payload_size;
}
-
- if(adaptation_field_size == 0)
- {
+
+ if (adaptation_field_size == 0) {
// no adaptation field
- header[3] = (1 << 4) | ((m_ContinuityCounter++) & 0x0F);
+ header[3] = (1<<4) | ((m_ContinuityCounter++)&0x0F);
output.Write(header, 4);
- }
- else
- {
+ } else {
// adaptation field present
- header[3] = (3 << 4) | ((m_ContinuityCounter++) & 0x0F);
+ header[3] = (3<<4) | ((m_ContinuityCounter++)&0x0F);
output.Write(header, 4);
-
- if(adaptation_field_size == 1)
- {
+
+ if (adaptation_field_size == 1) {
// just one byte (stuffing)
output.WriteUI08(0);
- }
- else
- {
+ } else {
// two or more bytes (stuffing and/or PCR)
- output.WriteUI08(adaptation_field_size - 1);
- output.WriteUI08(with_pcr ? (1 << 4) : 0);
+ output.WriteUI08(adaptation_field_size-1);
+ output.WriteUI08(with_pcr?(1<<4):0);
unsigned int pcr_size = 0;
- if(with_pcr)
- {
+ if (with_pcr) {
pcr_size = AP4_MPEG2TS_PCR_ADAPTATION_SIZE;
- AP4_UI64 pcr_base = pcr / 300;
- AP4_UI32 pcr_ext = (AP4_UI32)(pcr % 300);
+ AP4_UI64 pcr_base = pcr/300;
+ AP4_UI32 pcr_ext = (AP4_UI32)(pcr%300);
AP4_BitWriter writer(pcr_size);
- writer.Write((AP4_UI32)(pcr_base >> 32), 1);
+ writer.Write((AP4_UI32)(pcr_base>>32), 1);
writer.Write((AP4_UI32)pcr_base, 32);
writer.Write(0x3F, 6);
writer.Write(pcr_ext, 9);
output.Write(writer.GetData(), pcr_size);
- }
- if(adaptation_field_size > 2)
- {
- output.Write(StuffingBytes, adaptation_field_size - pcr_size - 2);
+ }
+ if (adaptation_field_size > 2) {
+ output.Write(StuffingBytes, adaptation_field_size-pcr_size-2);
}
}
}
-}
+}
/*----------------------------------------------------------------------
| AP4_Mpeg2TsWriter::SampleStream::WritePES
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Mpeg2TsWriter::SampleStream::WritePES(const unsigned char* data,
- unsigned int data_size,
- AP4_UI64 dts,
- bool with_dts,
- AP4_UI64 pts,
- bool with_pcr,
- AP4_ByteStream& output)
+AP4_Mpeg2TsWriter::SampleStream::WritePES(const unsigned char* data,
+ unsigned int data_size,
+ AP4_UI64 dts,
+ bool with_dts,
+ AP4_UI64 pts,
+ bool with_pcr,
+ AP4_ByteStream& output)
{
- unsigned int pes_header_size = 14 + (with_dts ? 5 : 0);
+ unsigned int pes_header_size = 14+(with_dts?5:0);
AP4_BitWriter pes_header(pes_header_size);
-
+
pes_header.Write(0x000001, 24); // packet_start_code_prefix
pes_header.Write(m_StreamId, 8); // stream_id
- pes_header.Write(m_StreamId == AP4_MPEG2_TS_DEFAULT_STREAM_ID_VIDEO ? 0 : (data_size + pes_header_size - 6), 16); // PES_packet_length
+ pes_header.Write(m_StreamId == AP4_MPEG2_TS_DEFAULT_STREAM_ID_VIDEO?0:(data_size+pes_header_size-6), 16); // PES_packet_length
pes_header.Write(2, 2); // '01'
pes_header.Write(0, 2); // PES_scrambling_control
pes_header.Write(0, 1); // PES_priority
pes_header.Write(1, 1); // data_alignment_indicator
pes_header.Write(0, 1); // copyright
pes_header.Write(0, 1); // original_or_copy
- pes_header.Write(with_dts ? 3 : 2, 2); // PTS_DTS_flags
+ pes_header.Write(with_dts?3:2, 2); // PTS_DTS_flags
pes_header.Write(0, 1); // ESCR_flag
pes_header.Write(0, 1); // ES_rate_flag
pes_header.Write(0, 1); // DSM_trick_mode_flag
pes_header.Write(0, 1); // additional_copy_info_flag
pes_header.Write(0, 1); // PES_CRC_flag
pes_header.Write(0, 1); // PES_extension_flag
- pes_header.Write(pes_header_size - 9, 8); // PES_header_data_length
-
- pes_header.Write(with_dts ? 3 : 2, 4); // '0010' or '0011'
- pes_header.Write((AP4_UI32)(pts >> 30), 3); // PTS[32..30]
+ pes_header.Write(pes_header_size-9, 8);// PES_header_data_length
+
+ pes_header.Write(with_dts?3:2, 4); // '0010' or '0011'
+ pes_header.Write((AP4_UI32)(pts>>30), 3); // PTS[32..30]
pes_header.Write(1, 1); // marker_bit
- pes_header.Write((AP4_UI32)(pts >> 15), 15); // PTS[29..15]
+ pes_header.Write((AP4_UI32)(pts>>15), 15); // PTS[29..15]
pes_header.Write(1, 1); // marker_bit
pes_header.Write((AP4_UI32)pts, 15); // PTS[14..0]
pes_header.Write(1, 1); // market_bit
-
- if(with_dts)
- {
+
+ if (with_dts) {
pes_header.Write(1, 4); // '0001'
- pes_header.Write((AP4_UI32)(dts >> 30), 3); // DTS[32..30]
+ pes_header.Write((AP4_UI32)(dts>>30), 3); // DTS[32..30]
pes_header.Write(1, 1); // marker_bit
- pes_header.Write((AP4_UI32)(dts >> 15), 15); // DTS[29..15]
+ pes_header.Write((AP4_UI32)(dts>>15), 15); // DTS[29..15]
pes_header.Write(1, 1); // marker_bit
pes_header.Write((AP4_UI32)dts, 15); // DTS[14..0]
pes_header.Write(1, 1); // market_bit
}
-
+
bool first_packet = true;
data_size += pes_header_size; // add size of PES header
- while(data_size)
- {
+ while (data_size) {
unsigned int payload_size = data_size;
- if(payload_size > AP4_MPEG2TS_PACKET_PAYLOAD_SIZE) payload_size = AP4_MPEG2TS_PACKET_PAYLOAD_SIZE;
-
- if(first_packet)
- {
- WritePacketHeader(first_packet, payload_size, with_pcr, (with_dts ? dts : pts) * 300, output);
+ if (payload_size > AP4_MPEG2TS_PACKET_PAYLOAD_SIZE) payload_size = AP4_MPEG2TS_PACKET_PAYLOAD_SIZE;
+
+ if (first_packet) {
+ WritePacketHeader(first_packet, payload_size, with_pcr, (with_dts?dts:pts)*300, output);
first_packet = false;
output.Write(pes_header.GetData(), pes_header_size);
- output.Write(data, payload_size - pes_header_size);
- data += payload_size - pes_header_size;
- }
- else
- {
+ output.Write(data, payload_size-pes_header_size);
+ data += payload_size-pes_header_size;
+ } else {
WritePacketHeader(first_packet, payload_size, false, 0, output);
output.Write(data, payload_size);
data += payload_size;
}
data_size -= payload_size;
}
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_Mpeg2TsAudioSampleStream
+---------------------------------------------------------------------*/
-class AP4_Mpeg2TsAudioSampleStream : public AP4_Mpeg2TsWriter::SampleStream
+class AP4_Mpeg2TsAudioSampleStream : public AP4_Mpeg2TsWriter::SampleStream
{
public:
- static AP4_Result Create(AP4_UI16 pid,
- AP4_UI32 timescale,
+ static AP4_Result Create(AP4_UI16 pid,
+ AP4_UI32 timescale,
AP4_Mpeg2TsWriter::SampleStream*& stream);
- AP4_Result WriteSample(AP4_Sample& sample,
+ AP4_Result WriteSample(AP4_Sample& sample,
AP4_SampleDescription* sample_description,
- bool with_pcr,
+ bool with_pcr,
AP4_ByteStream& output);
-
+
private:
- AP4_Mpeg2TsAudioSampleStream(AP4_UI16 pid, AP4_UI32 timescale) :
- AP4_Mpeg2TsWriter::SampleStream(pid,
- AP4_MPEG2_TS_DEFAULT_STREAM_ID_AUDIO,
- AP4_MPEG2_STREAM_TYPE_ISO_IEC_13818_7,
- timescale) {}
+ AP4_Mpeg2TsAudioSampleStream(AP4_UI16 pid, AP4_UI32 timescale) :
+ AP4_Mpeg2TsWriter::SampleStream(pid,
+ AP4_MPEG2_TS_DEFAULT_STREAM_ID_AUDIO,
+ AP4_MPEG2_STREAM_TYPE_ISO_IEC_13818_7,
+ timescale) {}
};
/*----------------------------------------------------------------------
| AP4_Mpeg2TsAudioSampleStream::Create
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Mpeg2TsAudioSampleStream::Create(AP4_UI16 pid,
- AP4_UI32 timescale,
+AP4_Result
+AP4_Mpeg2TsAudioSampleStream::Create(AP4_UI16 pid,
+ AP4_UI32 timescale,
AP4_Mpeg2TsWriter::SampleStream*& stream)
{
stream = new AP4_Mpeg2TsAudioSampleStream(pid, timescale);
return AP4_SUCCESS;
}
-
+
/*----------------------------------------------------------------------
| AP4_Mpeg2TsAudioSampleStream::WriteSample
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Mpeg2TsAudioSampleStream::WriteSample(AP4_Sample& sample,
- AP4_SampleDescription* sample_description,
- bool with_pcr,
- AP4_ByteStream& output)
+AP4_Mpeg2TsAudioSampleStream::WriteSample(AP4_Sample& sample,
+ AP4_SampleDescription* sample_description,
+ bool with_pcr,
+ AP4_ByteStream& output)
{
// check the sample description
AP4_MpegAudioSampleDescription* audio_desc = AP4_DYNAMIC_CAST(AP4_MpegAudioSampleDescription, sample_description);
- if(audio_desc == NULL) return AP4_ERROR_NOT_SUPPORTED;
- if(audio_desc->GetMpeg4AudioObjectType() != AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LC) return AP4_ERROR_NOT_SUPPORTED;
+ if (audio_desc == NULL) return AP4_ERROR_NOT_SUPPORTED;
+ if (audio_desc->GetMpeg4AudioObjectType() != AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LC) return AP4_ERROR_NOT_SUPPORTED;
unsigned int sampling_frequency_index = GetSamplingFrequencyIndex(audio_desc->GetSampleRate());
unsigned int channel_configuration = audio_desc->GetChannelCount();
AP4_DataBuffer data;
- if(AP4_SUCCEEDED(sample.ReadData(data)))
- {
+ if (AP4_SUCCEEDED(sample.ReadData(data))) {
unsigned char* buffer = new unsigned char[7+sample.GetSize()];
MakeAdtsHeader(buffer, sample.GetSize(), sampling_frequency_index, channel_configuration);
- AP4_CopyMemory(buffer + 7, data.GetData(), data.GetDataSize());
+ AP4_CopyMemory(buffer+7, data.GetData(), data.GetDataSize());
AP4_UI64 ts = AP4_ConvertTime(sample.GetDts(), m_TimeScale, 90000);
- WritePES(buffer, 7 + sample.GetSize(), ts, false, ts, with_pcr, output);
+ WritePES(buffer, 7+sample.GetSize(), ts, false, ts, with_pcr, output);
delete[] buffer;
}
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_Mpeg2TsVideoSampleStream
+---------------------------------------------------------------------*/
-class AP4_Mpeg2TsVideoSampleStream : public AP4_Mpeg2TsWriter::SampleStream
+class AP4_Mpeg2TsVideoSampleStream : public AP4_Mpeg2TsWriter::SampleStream
{
public:
- static AP4_Result Create(AP4_UI16 pid,
- AP4_UI32 timescale,
+ static AP4_Result Create(AP4_UI16 pid,
+ AP4_UI32 timescale,
AP4_Mpeg2TsWriter::SampleStream*& stream);
- AP4_Result WriteSample(AP4_Sample& sample,
+ AP4_Result WriteSample(AP4_Sample& sample,
AP4_SampleDescription* sample_description,
- bool with_pcr,
+ bool with_pcr,
AP4_ByteStream& output);
-
+
private:
AP4_Mpeg2TsVideoSampleStream(AP4_UI16 pid, AP4_UI32 timescale) :
- AP4_Mpeg2TsWriter::SampleStream(pid,
- AP4_MPEG2_TS_DEFAULT_STREAM_ID_VIDEO,
+ AP4_Mpeg2TsWriter::SampleStream(pid,
+ AP4_MPEG2_TS_DEFAULT_STREAM_ID_VIDEO,
AP4_MPEG2_STREAM_TYPE_AVC,
timescale),
- m_SampleDescriptionIndex(-1),
- m_NaluLengthSize(0) {}
-
+ m_SampleDescriptionIndex(-1),
+ m_NaluLengthSize(0) {}
+
int m_SampleDescriptionIndex;
AP4_DataBuffer m_Prefix;
unsigned int m_NaluLengthSize;
@@ -467,12 +434,12 @@ private:
| AP4_Mpeg2TsVideoSampleStream::AP4_Mpeg2TsVideoSampleStream
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Mpeg2TsVideoSampleStream::Create(AP4_UI16 pid,
- AP4_UI32 timescale,
+AP4_Mpeg2TsVideoSampleStream::Create(AP4_UI16 pid,
+ AP4_UI32 timescale,
AP4_Mpeg2TsWriter::SampleStream*& stream)
{
// create the stream object
- stream = new AP4_Mpeg2TsVideoSampleStream(pid, timescale);
+ stream = new AP4_Mpeg2TsVideoSampleStream(pid, timescale);
return AP4_SUCCESS;
}
@@ -480,40 +447,37 @@ AP4_Mpeg2TsVideoSampleStream::Create(AP4_UI16 pid,
| AP4_Mpeg2TsVideoSampleStream::WriteSample
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Mpeg2TsVideoSampleStream::WriteSample(AP4_Sample& sample,
- AP4_SampleDescription* sample_description,
- bool with_pcr,
- AP4_ByteStream& output)
+AP4_Mpeg2TsVideoSampleStream::WriteSample(AP4_Sample& sample,
+ AP4_SampleDescription* sample_description,
+ bool with_pcr,
+ AP4_ByteStream& output)
{
// check the sample description
AP4_AvcSampleDescription* avc_desc = AP4_DYNAMIC_CAST(AP4_AvcSampleDescription, sample_description);
- if(avc_desc == NULL) return AP4_ERROR_NOT_SUPPORTED;
-
- if((int)sample.GetDescriptionIndex() != m_SampleDescriptionIndex)
- {
+ if (avc_desc == NULL) return AP4_ERROR_NOT_SUPPORTED;
+
+ if ((int)sample.GetDescriptionIndex() != m_SampleDescriptionIndex) {
m_SampleDescriptionIndex = sample.GetDescriptionIndex();
// make the SPS/PPS prefix
m_NaluLengthSize = avc_desc->GetNaluLengthSize();
m_Prefix.SetDataSize(0);
- for(unsigned int i = 0; i < avc_desc->GetSequenceParameters().ItemCount(); i++)
- {
+ for (unsigned int i=0; i<avc_desc->GetSequenceParameters().ItemCount(); i++) {
AP4_DataBuffer& buffer = avc_desc->GetSequenceParameters()[i];
unsigned int prefix_size = m_Prefix.GetDataSize();
- m_Prefix.SetDataSize(prefix_size + 4 + buffer.GetDataSize());
- unsigned char* p = m_Prefix.UseData() + prefix_size;
+ m_Prefix.SetDataSize(prefix_size+4+buffer.GetDataSize());
+ unsigned char* p = m_Prefix.UseData()+prefix_size;
*p++ = 0;
*p++ = 0;
*p++ = 0;
*p++ = 1;
AP4_CopyMemory(p, buffer.GetData(), buffer.GetDataSize());
}
- for(unsigned int i = 0; i < avc_desc->GetPictureParameters().ItemCount(); i++)
- {
+ for (unsigned int i=0; i<avc_desc->GetPictureParameters().ItemCount(); i++) {
AP4_DataBuffer& buffer = avc_desc->GetPictureParameters()[i];
unsigned int prefix_size = m_Prefix.GetDataSize();
- m_Prefix.SetDataSize(prefix_size + 4 + buffer.GetDataSize());
- unsigned char* p = m_Prefix.UseData() + prefix_size;
+ m_Prefix.SetDataSize(prefix_size+4+buffer.GetDataSize());
+ unsigned char* p = m_Prefix.UseData()+prefix_size;
*p++ = 0;
*p++ = 0;
*p++ = 0;
@@ -521,16 +485,16 @@ AP4_Mpeg2TsVideoSampleStream::WriteSample(AP4_Sample& sample,
AP4_CopyMemory(p, buffer.GetData(), buffer.GetDataSize());
}
}
-
+
// read the sample data
AP4_DataBuffer sample_data;
AP4_CHECK(sample.ReadData(sample_data));
-
+
// allocate a buffer for the PES packet
AP4_DataBuffer pes_data;
- pes_data.SetDataSize(6 + m_Prefix.GetDataSize());
+ pes_data.SetDataSize(6+m_Prefix.GetDataSize());
unsigned char* pes_buffer = pes_data.UseData();
-
+
// start of access unit
pes_buffer[0] = 0;
pes_buffer[1] = 0;
@@ -538,62 +502,54 @@ AP4_Mpeg2TsVideoSampleStream::WriteSample(AP4_Sample& sample,
pes_buffer[3] = 1;
pes_buffer[4] = 9; // NAL type = Access Unit Delimiter;
pes_buffer[5] = 0xE0; // Slice types = ANY
-
+
// copy the prefix
- AP4_CopyMemory(pes_buffer + 6, m_Prefix.GetData(), m_Prefix.GetDataSize());
-
+ AP4_CopyMemory(pes_buffer+6, m_Prefix.GetData(), m_Prefix.GetDataSize());
+
// write the NAL units
const unsigned char* data = sample_data.GetData();
unsigned int data_size = sample_data.GetDataSize();
-
- while(data_size)
- {
+
+ while (data_size) {
// sanity check
- if(data_size < m_NaluLengthSize) break;
-
+ if (data_size < m_NaluLengthSize) break;
+
// get the next NAL unit
AP4_UI32 nalu_size;
- if(m_NaluLengthSize == 1)
- {
+ if (m_NaluLengthSize == 1) {
nalu_size = *data++;
data_size--;
- }
- else if(m_NaluLengthSize == 2)
- {
+ } else if (m_NaluLengthSize == 2) {
nalu_size = AP4_BytesToInt16BE(data);
data += 2;
data_size -= 2;
- }
- else if(m_NaluLengthSize == 4)
- {
+ } else if (m_NaluLengthSize == 4) {
nalu_size = AP4_BytesToInt32BE(data);
data += 4;
data_size -= 4;
- }
- else
- {
+ } else {
break;
}
- if(nalu_size > data_size) break;
-
+ if (nalu_size > data_size) break;
+
// add a start code before the NAL unit
- unsigned int offset = pes_data.GetDataSize();
- pes_data.SetDataSize(offset + 3 + nalu_size);
- pes_buffer = pes_data.UseData() + offset;
+ unsigned int offset = pes_data.GetDataSize();
+ pes_data.SetDataSize(offset+3+nalu_size);
+ pes_buffer = pes_data.UseData()+offset;
pes_buffer[0] = 0;
pes_buffer[1] = 0;
pes_buffer[2] = 1;
- AP4_CopyMemory(pes_buffer + 3, data, nalu_size);
-
+ AP4_CopyMemory(pes_buffer+3, data, nalu_size);
+
// move to the next NAL unit
data += nalu_size;
data_size -= nalu_size;
- }
-
+ }
+
// compute the timestamp
AP4_UI64 dts = AP4_ConvertTime(sample.GetDts(), m_TimeScale, 90000);
AP4_UI64 pts = AP4_ConvertTime(sample.GetCts(), m_TimeScale, 90000);
-
+
// write the packet
return WritePES(pes_data.GetData(), pes_data.GetDataSize(), dts, true, pts, with_pcr, output);
}
@@ -629,9 +585,9 @@ AP4_Mpeg2TsWriter::WritePAT(AP4_ByteStream& output)
{
unsigned int payload_size = AP4_MPEG2TS_PACKET_PAYLOAD_SIZE;
m_PAT->WritePacketHeader(true, payload_size, false, 0, output);
-
+
AP4_BitWriter writer(1024);
-
+
writer.Write(0, 8); // pointer
writer.Write(0, 8); // table_id
writer.Write(1, 1); // section_syntax_indicator
@@ -647,12 +603,12 @@ AP4_Mpeg2TsWriter::WritePAT(AP4_ByteStream& output)
writer.Write(1, 16); // program number
writer.Write(7, 3); // reserved
writer.Write(m_PMT->GetPID(), 13); // program_map_PID
- writer.Write(ComputeCRC(writer.GetData() + 1, 17 - 1 - 4), 32);
-
+ writer.Write(ComputeCRC(writer.GetData()+1, 17-1-4), 32);
+
output.Write(writer.GetData(), 17);
-
- output.Write(StuffingBytes, AP4_MPEG2TS_PACKET_PAYLOAD_SIZE - 17);
-
+
+ output.Write(StuffingBytes, AP4_MPEG2TS_PACKET_PAYLOAD_SIZE-17);
+
return AP4_SUCCESS;
}
@@ -663,25 +619,22 @@ AP4_Result
AP4_Mpeg2TsWriter::WritePMT(AP4_ByteStream& output)
{
// check that we have at least one media stream
- if(m_Audio == NULL && m_Video == NULL)
- {
+ if (m_Audio == NULL && m_Video == NULL) {
return AP4_ERROR_INVALID_STATE;
}
-
+
unsigned int payload_size = AP4_MPEG2TS_PACKET_PAYLOAD_SIZE;
m_PMT->WritePacketHeader(true, payload_size, false, 0, output);
-
+
AP4_BitWriter writer(1024);
-
+
unsigned int section_length = 13;
unsigned int pcr_pid = 0;
- if(m_Audio)
- {
+ if (m_Audio) {
section_length += 5;
pcr_pid = m_Audio->GetPID();
- }
- if(m_Video)
- {
+ }
+ if (m_Video) {
section_length += 5;
pcr_pid = m_Video->GetPID();
}
@@ -702,46 +655,44 @@ AP4_Mpeg2TsWriter::WritePMT(AP4_ByteStream& output)
writer.Write(pcr_pid, 13); // PCD_PID
writer.Write(0xF, 4); // reserved
writer.Write(0, 12); // program_info_length
-
- if(m_Audio)
- {
- writer.Write(m_Audio->m_StreamType, 8); // stream_type
+
+ if (m_Audio) {
+ writer.Write(m_Audio->m_StreamType, 8); // stream_type
writer.Write(0x7, 3); // reserved
writer.Write(m_Audio->GetPID(), 13); // elementary_PID
writer.Write(0xF, 4); // reserved
writer.Write(0, 12); // ES_info_length
}
-
- if(m_Video)
- {
+
+ if (m_Video) {
writer.Write(m_Video->m_StreamType, 8); // stream_type
writer.Write(0x7, 3); // reserved
writer.Write(m_Video->GetPID(), 13); // elementary_PID
writer.Write(0xF, 4); // reserved
writer.Write(0, 12); // ES_info_length
}
-
- writer.Write(ComputeCRC(writer.GetData() + 1, section_length - 1), 32); // CRC
-
- output.Write(writer.GetData(), section_length + 4);
- output.Write(StuffingBytes, AP4_MPEG2TS_PACKET_PAYLOAD_SIZE - (section_length + 4));
-
+
+ writer.Write(ComputeCRC(writer.GetData()+1, section_length-1), 32); // CRC
+
+ output.Write(writer.GetData(), section_length+4);
+ output.Write(StuffingBytes, AP4_MPEG2TS_PACKET_PAYLOAD_SIZE-(section_length+4));
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_Mpeg2TsWriter::SetAudioStream
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_Mpeg2TsWriter::SetAudioStream(AP4_UI32 timescale, SampleStream*& stream)
{
// default
stream = NULL;
-
+
AP4_Result result = AP4_Mpeg2TsAudioSampleStream::Create(AP4_MPEG2_TS_DEFAULT_PID_AUDIO,
- timescale,
- m_Audio);
- if(AP4_FAILED(result)) return result;
+ timescale,
+ m_Audio);
+ if (AP4_FAILED(result)) return result;
stream = m_Audio;
return AP4_SUCCESS;
}
@@ -749,16 +700,16 @@ AP4_Mpeg2TsWriter::SetAudioStream(AP4_UI32 timescale, SampleStream*& stream)
/*----------------------------------------------------------------------
| AP4_Mpeg2TsWriter::SetVideoStream
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_Mpeg2TsWriter::SetVideoStream(AP4_UI32 timescale, SampleStream*& stream)
{
// default
stream = NULL;
-
- AP4_Result result = AP4_Mpeg2TsVideoSampleStream::Create(AP4_MPEG2_TS_DEFAULT_PID_VIDEO,
- timescale,
- m_Video);
- if(AP4_FAILED(result)) return result;
+
+ AP4_Result result = AP4_Mpeg2TsVideoSampleStream::Create(AP4_MPEG2_TS_DEFAULT_PID_VIDEO,
+ timescale,
+ m_Video);
+ if (AP4_FAILED(result)) return result;
stream = m_Video;
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.h
index c0173aa78..0f898b952 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Mpeg2Ts.h
@@ -57,7 +57,7 @@ const AP4_UI08 AP4_MPEG2_STREAM_TYPE_AVC = 0x1B;
| AP4_Mpeg2TsWriter
+---------------------------------------------------------------------*/
/**
- * This class is a simple implementation of a converter that can
+ * This class is a simple implementation of a converter that can
* convert MP4 audio and video access units into an MPEG2 transport
* stream.
* It currently only supports one audio tracks with MPEG4 AAC LC, and one
@@ -67,70 +67,59 @@ class AP4_Mpeg2TsWriter
{
public:
// classes
- class Stream
- {
+ class Stream {
public:
Stream(AP4_UI16 pid) : m_PID(pid), m_ContinuityCounter(0) {}
virtual ~Stream() {}
-
- AP4_UI16 GetPID()
- {
- return m_PID;
- }
- void WritePacketHeader(bool payload_start,
+
+ AP4_UI16 GetPID() { return m_PID; }
+ void WritePacketHeader(bool payload_start,
unsigned int& payload_size,
bool with_pcr,
AP4_UI64 pcr,
AP4_ByteStream& output);
-
+
private:
unsigned int m_PID;
unsigned int m_ContinuityCounter;
};
-
- class SampleStream : public Stream
- {
+
+ class SampleStream : public Stream {
public:
SampleStream(AP4_UI16 pid, AP4_UI16 stream_id, AP4_UI08 stream_type, AP4_UI32 timescale) :
- Stream(pid),
+ Stream(pid),
m_StreamId(stream_id),
m_StreamType(stream_type),
m_TimeScale(timescale) {}
-
- virtual AP4_Result WritePES(const unsigned char* data,
- unsigned int data_size,
- AP4_UI64 dts,
- bool with_dts,
- AP4_UI64 pts,
- bool with_pcr,
+
+ virtual AP4_Result WritePES(const unsigned char* data,
+ unsigned int data_size,
+ AP4_UI64 dts,
+ bool with_dts,
+ AP4_UI64 pts,
+ bool with_pcr,
AP4_ByteStream& output);
- virtual AP4_Result WriteSample(AP4_Sample& sample,
+ virtual AP4_Result WriteSample(AP4_Sample& sample,
AP4_SampleDescription* sample_description,
- bool with_pcr,
+ bool with_pcr,
AP4_ByteStream& output) = 0;
-
+
unsigned int m_StreamId;
AP4_UI08 m_StreamType;
AP4_UI32 m_TimeScale;
};
-
+
// constructor
AP4_Mpeg2TsWriter();
~AP4_Mpeg2TsWriter();
-
- Stream* GetPAT()
- {
- return m_PAT;
- }
- Stream* GetPMT()
- {
- return m_PMT;
- }
+
+ Stream* GetPAT() { return m_PAT; }
+ Stream* GetPMT() { return m_PMT; }
AP4_Result WritePAT(AP4_ByteStream& output);
AP4_Result WritePMT(AP4_ByteStream& output);
AP4_Result SetAudioStream(AP4_UI32 timescale, SampleStream*& stream);
AP4_Result SetVideoStream(AP4_UI32 timescale, SampleStream*& stream);
-
+
private:
Stream* m_PAT;
Stream* m_PMT;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.cpp
index 66fd9f82a..3a4e3059a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - mvhd Atoms
+| AP4 - mvhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_MvhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version > 1) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version > 1) return NULL;
return new AP4_MvhdAtom(size, version, flags, stream);
}
@@ -60,7 +60,7 @@ AP4_MvhdAtom::AP4_MvhdAtom(AP4_UI32 creation_time,
AP4_UI32 duration,
AP4_UI32 rate,
AP4_UI16 volume) :
- AP4_Atom(AP4_ATOM_TYPE_MVHD, AP4_FULL_ATOM_HEADER_SIZE + 96, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_MVHD, AP4_FULL_ATOM_HEADER_SIZE+96, 0, 0),
m_CreationTime(creation_time),
m_ModificationTime(modification_time),
m_TimeScale(time_scale),
@@ -87,14 +87,13 @@ AP4_MvhdAtom::AP4_MvhdAtom(AP4_UI32 creation_time,
/*----------------------------------------------------------------------
| AP4_MvhdAtom::AP4_MvhdAtom
+---------------------------------------------------------------------*/
-AP4_MvhdAtom::AP4_MvhdAtom(AP4_UI32 size,
+AP4_MvhdAtom::AP4_MvhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_MVHD, size, version, flags)
{
- if(m_Version == 0)
- {
+ if (m_Version == 0) {
AP4_UI32 creation_time;
stream.ReadUI32(creation_time);
m_CreationTime = creation_time;
@@ -105,9 +104,7 @@ AP4_MvhdAtom::AP4_MvhdAtom(AP4_UI32 size,
AP4_UI32 duration;
stream.ReadUI32(duration);
m_Duration = duration;
- }
- else
- {
+ } else {
stream.ReadUI64(m_CreationTime);
stream.ReadUI64(m_ModificationTime);
stream.ReadUI32(m_TimeScale);
@@ -118,8 +115,7 @@ AP4_MvhdAtom::AP4_MvhdAtom(AP4_UI32 size,
stream.ReadUI16(m_Volume);
stream.Read(m_Reserved1, sizeof(m_Reserved1));
stream.Read(m_Reserved2, sizeof(m_Reserved2));
- for(int i = 0; i < 9; i++)
- {
+ for (int i=0; i<9; i++) {
stream.ReadUI32(m_Matrix[i]);
}
stream.Read(m_Predefined, sizeof(m_Predefined));
@@ -133,51 +129,47 @@ AP4_Result
AP4_MvhdAtom::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
- if(m_Version == 0)
- {
+
+ if (m_Version == 0) {
result = stream.WriteUI32((AP4_UI32)m_CreationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32((AP4_UI32)m_ModificationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_TimeScale);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32((AP4_UI32)m_Duration);
- }
- else
- {
+ } else {
result = stream.WriteUI64(m_CreationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI64(m_ModificationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_TimeScale);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI64(m_Duration);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// rate & volume
result = stream.WriteUI32(m_Rate);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI16(m_Volume);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// reserved
result = stream.Write(m_Reserved1, sizeof(m_Reserved1));
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.Write(m_Reserved2, sizeof(m_Reserved2));
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// matrix
- for(int i = 0; i < 9; i++)
- {
+ for (int i=0; i<9; i++) {
result = stream.WriteUI32(m_Matrix[i]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// pre-defined
result = stream.Write(m_Predefined, sizeof(m_Predefined));
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// next track id
return stream.WriteUI32(m_NextTrackId);
@@ -189,12 +181,9 @@ AP4_MvhdAtom::WriteFields(AP4_ByteStream& stream)
AP4_UI32
AP4_MvhdAtom::GetDurationMs()
{
- if(m_TimeScale)
- {
+ if (m_TimeScale) {
return (AP4_UI32)AP4_ConvertTime(m_Duration, m_TimeScale, 1000);
- }
- else
- {
+ } else {
return 0;
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.h
index 1c8bf6c83..b3d4de11d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4MvhdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - mvhd Atoms
+| AP4 - mvhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -55,31 +55,21 @@ public:
AP4_UI16 volume);
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_UI64 GetDuration()
- {
- return m_Duration;
- }
- void SetDuration(AP4_UI64 duration)
- {
- m_Duration = duration;
- }
+ AP4_UI64 GetDuration() { return m_Duration; }
+ void SetDuration(AP4_UI64 duration) { m_Duration = duration;}
AP4_UI32 GetDurationMs();
- AP4_UI32 GetTimeScale()
- {
- return m_TimeScale;
- }
- AP4_Result SetTimeScale(AP4_UI32 time_scale)
- {
+ AP4_UI32 GetTimeScale() { return m_TimeScale; }
+ AP4_Result SetTimeScale(AP4_UI32 time_scale) {
m_TimeScale = time_scale;
return AP4_SUCCESS;
}
private:
// methods
- AP4_MvhdAtom(AP4_UI32 size,
+ AP4_MvhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
- AP4_ByteStream& stream);
+ AP4_ByteStream& stream);
// members
AP4_UI64 m_CreationTime;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.cpp
index aba085197..d6a660962 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - nmhd Atoms
+| AP4 - nmhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -41,8 +41,8 @@ AP4_NmhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_NmhdAtom(size, version, flags, stream);
}
@@ -57,7 +57,7 @@ AP4_NmhdAtom::AP4_NmhdAtom() :
/*----------------------------------------------------------------------
| AP4_NmhdAtom::AP4_NmhdAtom
+---------------------------------------------------------------------*/
-AP4_NmhdAtom::AP4_NmhdAtom(AP4_UI32 size,
+AP4_NmhdAtom::AP4_NmhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& /* stream */) :
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.h
index f566db625..8c2efd336 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4NmhdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - nmhd Atoms
+| AP4 - nmhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -49,7 +49,7 @@ public:
private:
// methods
- AP4_NmhdAtom(AP4_UI32 size,
+ AP4_NmhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.cpp
index a3a73f023..1b74261d9 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.cpp
@@ -44,8 +44,8 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_DescriptorUpdateCommand)
| AP4_ObjectDescriptor::AP4_ObjectDescriptor
+---------------------------------------------------------------------*/
AP4_ObjectDescriptor::AP4_ObjectDescriptor(AP4_UI08 tag,
- AP4_Size header_size,
- AP4_Size payload_size) :
+ AP4_Size header_size,
+ AP4_Size payload_size) :
AP4_Descriptor(tag, header_size, payload_size),
m_UrlFlag(false)
{
@@ -55,7 +55,7 @@ AP4_ObjectDescriptor::AP4_ObjectDescriptor(AP4_UI08 tag,
| AP4_ObjectDescriptor::AP4_ObjectDescriptor
+---------------------------------------------------------------------*/
AP4_ObjectDescriptor::AP4_ObjectDescriptor(AP4_UI08 tag, AP4_UI16 id) :
- AP4_Descriptor(tag, 3, 2),
+ AP4_Descriptor(tag, 3, 2),
m_ObjectDescriptorId(id),
m_UrlFlag(false)
{
@@ -64,10 +64,10 @@ AP4_ObjectDescriptor::AP4_ObjectDescriptor(AP4_UI08 tag, AP4_UI16 id) :
/*----------------------------------------------------------------------
| AP4_ObjectDescriptor::AP4_ObjectDescriptor
+---------------------------------------------------------------------*/
-AP4_ObjectDescriptor::AP4_ObjectDescriptor(AP4_ByteStream& stream,
- AP4_UI08 tag,
- AP4_Size header_size,
- AP4_Size payload_size) :
+AP4_ObjectDescriptor::AP4_ObjectDescriptor(AP4_ByteStream& stream,
+ AP4_UI08 tag,
+ AP4_Size header_size,
+ AP4_Size payload_size) :
AP4_Descriptor(tag, header_size, payload_size)
{
AP4_Position start;
@@ -76,11 +76,10 @@ AP4_ObjectDescriptor::AP4_ObjectDescriptor(AP4_ByteStream& stream,
// read descriptor fields
unsigned short bits;
stream.ReadUI16(bits);
- m_ObjectDescriptorId = (bits >> 6);
- m_UrlFlag = ((bits & (1 << 5)) != 0);
-
- if(m_UrlFlag)
- {
+ m_ObjectDescriptorId = (bits>>6);
+ m_UrlFlag = ((bits&(1<<5))!=0);
+
+ if (m_UrlFlag) {
unsigned char url_length;
stream.ReadUI08(url_length);
char url[256];
@@ -92,13 +91,12 @@ AP4_ObjectDescriptor::AP4_ObjectDescriptor(AP4_ByteStream& stream,
// read other descriptors
AP4_Position offset;
stream.Tell(offset);
- AP4_SubStream* substream = new AP4_SubStream(stream, offset,
- payload_size - AP4_Size(offset - start));
+ AP4_SubStream* substream = new AP4_SubStream(stream, offset,
+ payload_size-AP4_Size(offset-start));
AP4_Descriptor* descriptor = NULL;
- while(AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
- descriptor)
- == AP4_SUCCESS)
- {
+ while (AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
+ descriptor)
+ == AP4_SUCCESS) {
m_SubDescriptors.Add(descriptor);
}
substream->Release();
@@ -115,13 +113,13 @@ AP4_ObjectDescriptor::~AP4_ObjectDescriptor()
/*----------------------------------------------------------------------
| AP4_ObjectDescriptor::FindSubDescriptor
+---------------------------------------------------------------------*/
-AP4_Descriptor*
+AP4_Descriptor*
AP4_ObjectDescriptor::FindSubDescriptor(AP4_UI08 tag) const
{
AP4_Descriptor* descriptor = NULL;
AP4_Result result = m_SubDescriptors.Find(AP4_DescriptorFinder(tag), descriptor);
- if(AP4_FAILED(result)) return NULL;
-
+ if (AP4_FAILED(result)) return NULL;
+
return descriptor;
}
@@ -134,17 +132,16 @@ AP4_ObjectDescriptor::WriteFields(AP4_ByteStream& stream)
AP4_Result result;
// id and flag
- unsigned short bits = (m_ObjectDescriptorId << 6) | (m_UrlFlag ? (1 << 5) : 0) | 0x1F;
+ unsigned short bits = (m_ObjectDescriptorId<<6)|(m_UrlFlag?(1<<5):0)|0x1F;
result = stream.WriteUI16(bits);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// optional url
- if(m_UrlFlag)
- {
+ if (m_UrlFlag) {
stream.WriteUI08((AP4_UI08)m_Url.GetLength());
stream.Write(m_Url.GetChars(), m_Url.GetLength());
}
-
+
// write the sub descriptors
m_SubDescriptors.Apply(AP4_DescriptorListWriter(stream));
@@ -158,15 +155,14 @@ AP4_Result
AP4_ObjectDescriptor::Inspect(AP4_AtomInspector& inspector)
{
char info[64];
- AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(), m_PayloadSize);
+ AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
+ GetHeaderSize(),m_PayloadSize);
inspector.StartElement("[ObjectDescriptor]", info);
inspector.AddField("id", m_ObjectDescriptorId);
- if(m_UrlFlag)
- {
+ if (m_UrlFlag) {
inspector.AddField("url", m_Url.GetChars());
}
-
+
// inspect children
m_SubDescriptors.Apply(AP4_DescriptorListInspector(inspector));
@@ -187,8 +183,8 @@ AP4_ObjectDescriptor::AddSubDescriptor(AP4_Descriptor* descriptor)
// check that the header is still large enough to encode the payload
// length
unsigned int min_header_size = MinHeaderSize(m_PayloadSize);
- if(min_header_size > m_HeaderSize) m_HeaderSize = min_header_size;
-
+ if (min_header_size > m_HeaderSize) m_HeaderSize = min_header_size;
+
return AP4_SUCCESS;
}
@@ -218,10 +214,10 @@ AP4_InitialObjectDescriptor::AP4_InitialObjectDescriptor(
/*----------------------------------------------------------------------
| AP4_InitialObjectDescriptor::AP4_InitialObjectDescriptor
+---------------------------------------------------------------------*/
-AP4_InitialObjectDescriptor::AP4_InitialObjectDescriptor(AP4_ByteStream& stream,
- AP4_UI08 tag,
- AP4_Size header_size,
- AP4_Size payload_size) :
+AP4_InitialObjectDescriptor::AP4_InitialObjectDescriptor(AP4_ByteStream& stream,
+ AP4_UI08 tag,
+ AP4_Size header_size,
+ AP4_Size payload_size) :
AP4_ObjectDescriptor(tag, header_size, payload_size),
m_OdProfileLevelIndication(0),
m_SceneProfileLevelIndication(0),
@@ -235,38 +231,34 @@ AP4_InitialObjectDescriptor::AP4_InitialObjectDescriptor(AP4_ByteStream& stream,
// read descriptor fields
unsigned short bits;
stream.ReadUI16(bits);
- m_ObjectDescriptorId = (bits >> 6);
- m_UrlFlag = ((bits & (1 << 5)) != 0);
- m_IncludeInlineProfileLevelFlag = ((bits & (1 << 4)) != 0);
-
- if(m_UrlFlag)
- {
+ m_ObjectDescriptorId = (bits>>6);
+ m_UrlFlag = ((bits&(1<<5))!=0);
+ m_IncludeInlineProfileLevelFlag = ((bits&(1<<4))!=0);
+
+ if (m_UrlFlag) {
unsigned char url_length;
stream.ReadUI08(url_length);
char url[256];
stream.Read(url, url_length);
url[url_length] = '\0';
m_Url = url;
+ } else {
+ stream.ReadUI08(m_OdProfileLevelIndication);
+ stream.ReadUI08(m_SceneProfileLevelIndication);
+ stream.ReadUI08(m_AudioProfileLevelIndication);
+ stream.ReadUI08(m_VisualProfileLevelIndication);
+ stream.ReadUI08(m_GraphicsProfileLevelIndication);
}
- else
- {
- stream.ReadUI08(m_OdProfileLevelIndication);
- stream.ReadUI08(m_SceneProfileLevelIndication);
- stream.ReadUI08(m_AudioProfileLevelIndication);
- stream.ReadUI08(m_VisualProfileLevelIndication);
- stream.ReadUI08(m_GraphicsProfileLevelIndication);
- }
-
+
// read other descriptors
AP4_Position offset;
stream.Tell(offset);
- AP4_SubStream* substream = new AP4_SubStream(stream, offset,
- payload_size - AP4_Size(offset - start));
+ AP4_SubStream* substream = new AP4_SubStream(stream, offset,
+ payload_size-AP4_Size(offset-start));
AP4_Descriptor* descriptor = NULL;
- while(AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
- descriptor)
- == AP4_SUCCESS)
- {
+ while (AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
+ descriptor)
+ == AP4_SUCCESS) {
m_SubDescriptors.Add(descriptor);
}
substream->Release();
@@ -281,28 +273,25 @@ AP4_InitialObjectDescriptor::WriteFields(AP4_ByteStream& stream)
AP4_Result result;
// id and flags
- unsigned short bits = (m_ObjectDescriptorId << 6) |
- (m_UrlFlag ? (1 << 5) : 0) |
- (m_IncludeInlineProfileLevelFlag ? (1 << 4) : 0) |
+ unsigned short bits = (m_ObjectDescriptorId<<6) |
+ (m_UrlFlag?(1<<5):0) |
+ (m_IncludeInlineProfileLevelFlag?(1<<4):0)|
0xF;
result = stream.WriteUI16(bits);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// optional url
- if(m_UrlFlag)
- {
+ if (m_UrlFlag) {
stream.WriteUI08((AP4_UI08)m_Url.GetLength());
stream.Write(m_Url.GetChars(), m_Url.GetLength());
+ } else {
+ stream.WriteUI08(m_OdProfileLevelIndication);
+ stream.WriteUI08(m_SceneProfileLevelIndication);
+ stream.WriteUI08(m_AudioProfileLevelIndication);
+ stream.WriteUI08(m_VisualProfileLevelIndication);
+ stream.WriteUI08(m_GraphicsProfileLevelIndication);
}
- else
- {
- stream.WriteUI08(m_OdProfileLevelIndication);
- stream.WriteUI08(m_SceneProfileLevelIndication);
- stream.WriteUI08(m_AudioProfileLevelIndication);
- stream.WriteUI08(m_VisualProfileLevelIndication);
- stream.WriteUI08(m_GraphicsProfileLevelIndication);
- }
-
+
// write the sub descriptors
m_SubDescriptors.Apply(AP4_DescriptorListWriter(stream));
@@ -316,26 +305,23 @@ AP4_Result
AP4_InitialObjectDescriptor::Inspect(AP4_AtomInspector& inspector)
{
char info[64];
- AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(), m_PayloadSize);
+ AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
+ GetHeaderSize(),m_PayloadSize);
inspector.StartElement("[InitialObjectDescriptor]", info);
inspector.AddField("id", m_ObjectDescriptorId);
- if(m_UrlFlag)
- {
+ if (m_UrlFlag) {
inspector.AddField("url", m_Url.GetChars());
- }
- else
- {
- inspector.AddField("include inline profile level flag",
- m_IncludeInlineProfileLevelFlag,
+ } else {
+ inspector.AddField("include inline profile level flag",
+ m_IncludeInlineProfileLevelFlag,
AP4_AtomInspector::HINT_BOOLEAN);
- inspector.AddField("OD profile level", m_OdProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
- inspector.AddField("scene profile level", m_SceneProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
- inspector.AddField("audio profile level", m_AudioProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
- inspector.AddField("visual profile level", m_VisualProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
- inspector.AddField("graphics profile level", m_GraphicsProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
+ inspector.AddField("OD profile level", m_OdProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
+ inspector.AddField("scene profile level", m_SceneProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
+ inspector.AddField("audio profile level", m_AudioProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
+ inspector.AddField("visual profile level", m_VisualProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
+ inspector.AddField("graphics profile level", m_GraphicsProfileLevelIndication, AP4_AtomInspector::HINT_HEX);
}
-
+
// inspect children
m_SubDescriptors.Apply(AP4_DescriptorListInspector(inspector));
@@ -356,7 +342,7 @@ AP4_DescriptorUpdateCommand::AP4_DescriptorUpdateCommand(AP4_UI08 tag) :
| AP4_DescriptorUpdateCommand::AP4_DescriptorUpdateCommand
+---------------------------------------------------------------------*/
AP4_DescriptorUpdateCommand::AP4_DescriptorUpdateCommand(
- AP4_ByteStream& stream,
+ AP4_ByteStream& stream,
AP4_UI08 tag,
AP4_Size header_size,
AP4_Size payload_size) :
@@ -365,11 +351,10 @@ AP4_DescriptorUpdateCommand::AP4_DescriptorUpdateCommand(
// read the descriptors
AP4_Position offset;
stream.Tell(offset);
- AP4_SubStream* substream = new AP4_SubStream(stream, offset,
- payload_size);
+ AP4_SubStream* substream = new AP4_SubStream(stream, offset,
+ payload_size);
AP4_Descriptor* descriptor = NULL;
- while(AP4_DescriptorFactory::CreateDescriptorFromStream(*substream, descriptor) == AP4_SUCCESS)
- {
+ while (AP4_DescriptorFactory::CreateDescriptorFromStream(*substream, descriptor) == AP4_SUCCESS) {
m_Descriptors.Add(descriptor);
}
substream->Release();
@@ -402,23 +387,22 @@ AP4_Result
AP4_DescriptorUpdateCommand::Inspect(AP4_AtomInspector& inspector)
{
char info[64];
- AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(), m_PayloadSize);
- switch(GetTag())
- {
- case AP4_COMMAND_TAG_OBJECT_DESCRIPTOR_UPDATE:
- inspector.StartElement("[ObjectDescriptorUpdate]", info);
- break;
-
- case AP4_COMMAND_TAG_IPMP_DESCRIPTOR_UPDATE:
- inspector.StartElement("[IPMP_DescriptorUpdate]", info);
- break;
-
- default:
- inspector.StartElement("[DescriptorUpdate]", info);
- break;
+ AP4_FormatString(info, sizeof(info), "size=%ld+%ld",
+ GetHeaderSize(),m_PayloadSize);
+ switch (GetTag()) {
+ case AP4_COMMAND_TAG_OBJECT_DESCRIPTOR_UPDATE:
+ inspector.StartElement("[ObjectDescriptorUpdate]", info);
+ break;
+
+ case AP4_COMMAND_TAG_IPMP_DESCRIPTOR_UPDATE:
+ inspector.StartElement("[IPMP_DescriptorUpdate]", info);
+ break;
+
+ default:
+ inspector.StartElement("[DescriptorUpdate]", info);
+ break;
}
-
+
// inspect children
m_Descriptors.Apply(AP4_DescriptorListInspector(inspector));
@@ -439,7 +423,7 @@ AP4_DescriptorUpdateCommand::AddDescriptor(AP4_Descriptor* descriptor)
// check that the header is still large enough to encode the payload
// length
unsigned int min_header_size = MinHeaderSize(m_PayloadSize);
- if(min_header_size > m_HeaderSize) m_HeaderSize = min_header_size;
+ if (min_header_size > m_HeaderSize) m_HeaderSize = min_header_size;
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.h
index f71d0b8e5..8b29c609c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4ObjectDescriptor.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - Object Descriptor
+| AP4 - Object Descriptor
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -55,45 +55,36 @@ const AP4_UI08 AP4_DESCRIPTOR_TAG_MP4_IOD = 0x10;
+---------------------------------------------------------------------*/
class AP4_ObjectDescriptor : public AP4_Descriptor
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_ObjectDescriptor, AP4_Descriptor)
// methods
- AP4_ObjectDescriptor(AP4_ByteStream& stream,
+ AP4_ObjectDescriptor(AP4_ByteStream& stream,
AP4_UI08 tag,
- AP4_Size header_size,
+ AP4_Size header_size,
AP4_Size payload_size);
AP4_ObjectDescriptor(AP4_UI08 tag, AP4_UI16 id);
virtual ~AP4_ObjectDescriptor();
-
+
/**
- * Add a sub-descriptor.
+ * Add a sub-descriptor.
* Ownership of the sub-descriptor object is transfered.
- */
+ */
virtual AP4_Result AddSubDescriptor(AP4_Descriptor* descriptor);
-
+
virtual AP4_Descriptor* FindSubDescriptor(AP4_UI08 tag) const;
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
// accessors
- AP4_UI16 GetObjectDescriptorId() const
- {
- return m_ObjectDescriptorId;
- }
- bool GetUrlFlag() const
- {
- return m_UrlFlag;
- }
- const AP4_String& GetUrl() const
- {
- return m_Url;
- }
+ AP4_UI16 GetObjectDescriptorId() const { return m_ObjectDescriptorId; }
+ bool GetUrlFlag() const { return m_UrlFlag; }
+ const AP4_String& GetUrl() const { return m_Url;}
-protected:
+ protected:
// constructor
AP4_ObjectDescriptor(AP4_UI08 tag, AP4_Size header_size, AP4_Size payload_size);
-
+
// members
AP4_UI16 m_ObjectDescriptorId;
bool m_UrlFlag;
@@ -106,11 +97,11 @@ protected:
+---------------------------------------------------------------------*/
class AP4_InitialObjectDescriptor : public AP4_ObjectDescriptor
{
-public:
+ public:
// methods
- AP4_InitialObjectDescriptor(AP4_ByteStream& stream,
+ AP4_InitialObjectDescriptor(AP4_ByteStream& stream,
AP4_UI08 tag,
- AP4_Size header_size,
+ AP4_Size header_size,
AP4_Size payload_size);
AP4_InitialObjectDescriptor(AP4_UI08 tag, // should be AP4_DESCRIPTOR_TAG_IOD or AP4_DESCRIPTOR_TAG_MP4_IOD
AP4_UI16 object_descriptor_id,
@@ -123,41 +114,23 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
-
+
// accessors
- bool GetIncludeProfileLevelFlag() const
- {
- return m_IncludeInlineProfileLevelFlag;
- }
- AP4_UI08 GetOdProfileLevelIndication() const
- {
- return m_OdProfileLevelIndication;
- }
- AP4_UI08 GetSceneProfileLevelIndication() const
- {
- return m_SceneProfileLevelIndication;
- }
- AP4_UI08 GetAudioProfileLevelIndication() const
- {
- return m_AudioProfileLevelIndication;
- }
- AP4_UI08 GetVisualProfileLevelIndication() const
- {
- return m_VisualProfileLevelIndication;
- }
- AP4_UI08 GetGraphicsProfileLevelIndication() const
- {
- return m_GraphicsProfileLevelIndication;
- }
-
-private:
+ bool GetIncludeProfileLevelFlag() const { return m_IncludeInlineProfileLevelFlag; }
+ AP4_UI08 GetOdProfileLevelIndication() const { return m_OdProfileLevelIndication; }
+ AP4_UI08 GetSceneProfileLevelIndication() const { return m_SceneProfileLevelIndication; }
+ AP4_UI08 GetAudioProfileLevelIndication() const { return m_AudioProfileLevelIndication; }
+ AP4_UI08 GetVisualProfileLevelIndication() const { return m_VisualProfileLevelIndication; }
+ AP4_UI08 GetGraphicsProfileLevelIndication() const { return m_GraphicsProfileLevelIndication; }
+
+ private:
// members
bool m_IncludeInlineProfileLevelFlag;
- AP4_UI08 m_OdProfileLevelIndication;
- AP4_UI08 m_SceneProfileLevelIndication;
- AP4_UI08 m_AudioProfileLevelIndication;
- AP4_UI08 m_VisualProfileLevelIndication;
- AP4_UI08 m_GraphicsProfileLevelIndication;
+ AP4_UI08 m_OdProfileLevelIndication;
+ AP4_UI08 m_SceneProfileLevelIndication;
+ AP4_UI08 m_AudioProfileLevelIndication;
+ AP4_UI08 m_VisualProfileLevelIndication;
+ AP4_UI08 m_GraphicsProfileLevelIndication;
};
/*----------------------------------------------------------------------
@@ -169,14 +142,14 @@ private:
*/
class AP4_DescriptorUpdateCommand : public AP4_Command
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_DescriptorUpdateCommand, AP4_Command)
// methods
AP4_DescriptorUpdateCommand(AP4_UI08 tag);
- AP4_DescriptorUpdateCommand(AP4_ByteStream& stream,
+ AP4_DescriptorUpdateCommand(AP4_ByteStream& stream,
AP4_UI08 tag,
- AP4_Size header_size,
+ AP4_Size header_size,
AP4_Size payload_size);
virtual ~AP4_DescriptorUpdateCommand();
virtual AP4_Result AddDescriptor(AP4_Descriptor* descriptor);
@@ -184,12 +157,9 @@ public:
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
// accessors
- const AP4_List<AP4_Descriptor>& GetDescriptors()
- {
- return m_Descriptors;
- }
-
-protected:
+ const AP4_List<AP4_Descriptor>& GetDescriptors() { return m_Descriptors; }
+
+ protected:
// members
mutable AP4_List<AP4_Descriptor> m_Descriptors;
};
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.cpp
index 8b4d8cea8..28805ecef 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - odaf Atoms
+| AP4 - odaf Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -45,8 +45,8 @@ AP4_OdafAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_OdafAtom(size, version, flags, stream);
}
@@ -56,7 +56,7 @@ AP4_OdafAtom::Create(AP4_Size size, AP4_ByteStream& stream)
AP4_OdafAtom::AP4_OdafAtom(bool selective_encryption,
AP4_UI08 key_length_indicator,
AP4_UI08 iv_length) :
- AP4_Atom(AP4_ATOM_TYPE_ODAF, AP4_FULL_ATOM_HEADER_SIZE + 3, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_ODAF, AP4_FULL_ATOM_HEADER_SIZE+3, 0, 0),
m_SelectiveEncryption(selective_encryption),
m_KeyIndicatorLength(key_length_indicator),
m_IvLength(iv_length)
@@ -66,7 +66,7 @@ AP4_OdafAtom::AP4_OdafAtom(bool selective_encryption,
/*----------------------------------------------------------------------
| AP4_OdafAtom::AP4_OdafAtom
+---------------------------------------------------------------------*/
-AP4_OdafAtom::AP4_OdafAtom(AP4_UI32 size,
+AP4_OdafAtom::AP4_OdafAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -74,7 +74,7 @@ AP4_OdafAtom::AP4_OdafAtom(AP4_UI32 size,
{
AP4_UI08 s;
stream.ReadUI08(s);
- m_SelectiveEncryption = ((s & 0x80) != 0);
+ m_SelectiveEncryption = ((s&0x80) != 0);
stream.ReadUI08(m_KeyIndicatorLength);
stream.ReadUI08(m_IvLength);
}
@@ -89,15 +89,15 @@ AP4_OdafAtom::WriteFields(AP4_ByteStream& stream)
// selective encryption
result = stream.WriteUI08(m_SelectiveEncryption ? 0x80 : 0);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// key indicator length
result = stream.WriteUI08(m_KeyIndicatorLength);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// IV length
result = stream.WriteUI08(m_IvLength);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.h
index 669ab6efe..22ba860ee 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdafAtom.h
@@ -54,22 +54,13 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- bool GetSelectiveEncryption()
- {
- return m_SelectiveEncryption;
- }
- AP4_UI08 GetKeyIndicatorLength()
- {
- return m_KeyIndicatorLength;
- }
- AP4_UI08 GetIvLength()
- {
- return m_IvLength;
- }
+ bool GetSelectiveEncryption() { return m_SelectiveEncryption; }
+ AP4_UI08 GetKeyIndicatorLength() { return m_KeyIndicatorLength; }
+ AP4_UI08 GetIvLength() { return m_IvLength; }
private:
// methods
- AP4_OdafAtom(AP4_UI32 size,
+ AP4_OdafAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.cpp
index 57c50c464..d7a08796a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - odda Atoms
+| AP4 - odda Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -41,20 +41,20 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_OddaAtom)
| AP4_OddaAtom::Create
+---------------------------------------------------------------------*/
AP4_OddaAtom*
-AP4_OddaAtom::Create(AP4_UI64 size,
+AP4_OddaAtom::Create(AP4_UI64 size,
AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_OddaAtom(size, version, flags, stream);
}
/*----------------------------------------------------------------------
| AP4_OddaAtom::AP4_OddaAtom
+---------------------------------------------------------------------*/
-AP4_OddaAtom::AP4_OddaAtom(AP4_UI64 size,
+AP4_OddaAtom::AP4_OddaAtom(AP4_UI64 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -64,14 +64,14 @@ AP4_OddaAtom::AP4_OddaAtom(AP4_UI64 size,
stream.ReadUI64(m_EncryptedDataLength);
// get the source stream position
- AP4_Position position;
+ AP4_Position position;
stream.Tell(position);
// create a substream to represent the payload
m_EncryptedPayload = new AP4_SubStream(stream, position, m_EncryptedDataLength);
-
+
// seek to the end
- stream.Seek(position + m_EncryptedDataLength);
+ stream.Seek(position+m_EncryptedDataLength);
}
/*----------------------------------------------------------------------
@@ -82,10 +82,10 @@ AP4_OddaAtom::AP4_OddaAtom(AP4_ByteStream& encrypted_payload) :
{
// encrypted data length
encrypted_payload.GetSize(m_EncryptedDataLength);
-
- // update our size
- SetSize(AP4_FULL_ATOM_HEADER_SIZE_64 + 8 + m_EncryptedDataLength, true);
-
+
+ // update our size
+ SetSize(AP4_FULL_ATOM_HEADER_SIZE_64+8+m_EncryptedDataLength, true);
+
// keep a reference to the encrypted payload
m_EncryptedPayload = &encrypted_payload;
m_EncryptedPayload->AddReference();
@@ -96,7 +96,7 @@ AP4_OddaAtom::AP4_OddaAtom(AP4_ByteStream& encrypted_payload) :
+---------------------------------------------------------------------*/
AP4_OddaAtom::~AP4_OddaAtom()
{
- if(m_EncryptedPayload) m_EncryptedPayload->Release();
+ if (m_EncryptedPayload) m_EncryptedPayload->Release();
}
@@ -107,18 +107,17 @@ AP4_Result
AP4_OddaAtom::SetEncryptedPayload(AP4_ByteStream& stream, AP4_LargeSize length)
{
// keep a reference to the stream
- if(m_EncryptedPayload)
- {
+ if (m_EncryptedPayload) {
m_EncryptedPayload->Release();
}
m_EncryptedPayload = &stream;
m_EncryptedPayload->AddReference();
-
+
// update the size
m_EncryptedDataLength = length;
SetSize(AP4_FULL_ATOM_HEADER_SIZE_64 + 8 + length, true);
- if(m_Parent) m_Parent->OnChildChanged(this);
-
+ if (m_Parent) m_Parent->OnChildChanged(this);
+
return AP4_SUCCESS;
}
@@ -131,8 +130,8 @@ AP4_OddaAtom::SetEncryptedPayload(AP4_ByteStream& stream)
// the new encrypted data length is the size of the stream
AP4_LargeSize length;
AP4_Result result = stream.GetSize(length);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
return SetEncryptedPayload(stream, length);
}
@@ -147,8 +146,7 @@ AP4_OddaAtom::WriteFields(AP4_ByteStream& stream)
// check that we have a source stream
// and a normal size
- if(m_EncryptedPayload == NULL || GetSize() < 8)
- {
+ if (m_EncryptedPayload == NULL || GetSize() < 8) {
return AP4_FAILURE;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.h
index 9acde6c14..58a402ce5 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OddaAtom.h
@@ -45,24 +45,21 @@ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_OddaAtom, AP4_Atom)
// class methods
- static AP4_OddaAtom* Create(AP4_UI64 size,
+ static AP4_OddaAtom* Create(AP4_UI64 size,
AP4_ByteStream& stream);
// constructor
AP4_OddaAtom(AP4_ByteStream& encrypted_payload);
-
+
// destructor
~AP4_OddaAtom();
// methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
// accessors
- AP4_UI64 GetEncryptedDataLength()
- {
- return m_EncryptedDataLength;
- }
+ AP4_UI64 GetEncryptedDataLength() { return m_EncryptedDataLength; }
/**
* Sets the encrypted payload stream (and releases any existing stream references)
@@ -73,14 +70,11 @@ public:
/**
* Returns a reference to the encrypted payload stream (does not increment the reference counter)
*/
- AP4_ByteStream& GetEncryptedPayload()
- {
- return *m_EncryptedPayload;
- }
+ AP4_ByteStream& GetEncryptedPayload() { return *m_EncryptedPayload; }
private:
// methods
- AP4_OddaAtom(AP4_UI64 size,
+ AP4_OddaAtom(AP4_UI64 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.cpp
index 69c70ac2f..f4e2bf5c8 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - odhe Atoms
+| AP4 - odhe Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -42,21 +42,21 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_OdheAtom)
| AP4_OdheAtom::Create
+---------------------------------------------------------------------*/
AP4_OdheAtom*
-AP4_OdheAtom::Create(AP4_Size size,
+AP4_OdheAtom::Create(AP4_Size size,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_OdheAtom(size, version, flags, stream, atom_factory);
}
/*----------------------------------------------------------------------
| AP4_OdheAtom::AP4_OdheAtom
+---------------------------------------------------------------------*/
-AP4_OdheAtom::AP4_OdheAtom(AP4_UI32 size,
+AP4_OdheAtom::AP4_OdheAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream,
@@ -71,7 +71,7 @@ AP4_OdheAtom::AP4_OdheAtom(AP4_UI32 size,
m_ContentType.Assign(content_type, content_type_length);
// read the children
- AP4_Size bytes_available = size - (AP4_FULL_ATOM_HEADER_SIZE + 1 + content_type_length);
+ AP4_Size bytes_available = size-(AP4_FULL_ATOM_HEADER_SIZE+1+content_type_length);
ReadChildren(atom_factory, stream, bytes_available);
}
@@ -83,7 +83,7 @@ AP4_OdheAtom::AP4_OdheAtom(const char* content_type,
AP4_ContainerAtom(AP4_ATOM_TYPE_ODHE, (AP4_UI32)0, (AP4_UI32)0),
m_ContentType(content_type)
{
- m_Size32 += 1 + m_ContentType.GetLength();
+ m_Size32 += 1+m_ContentType.GetLength();
AddChild(ohdr);
}
@@ -95,8 +95,7 @@ AP4_OdheAtom::WriteFields(AP4_ByteStream& stream)
{
// write the content type
AP4_CHECK(stream.WriteUI08((AP4_UI08)m_ContentType.GetLength()));
- if(m_ContentType.GetLength())
- {
+ if (m_ContentType.GetLength()) {
AP4_CHECK(stream.Write(m_ContentType.GetChars(), m_ContentType.GetLength()));
}
@@ -121,11 +120,11 @@ void
AP4_OdheAtom::OnChildChanged(AP4_Atom*)
{
// remcompute our size
- AP4_UI64 size = GetHeaderSize() + 1 + m_ContentType.GetLength();
+ AP4_UI64 size = GetHeaderSize()+1+m_ContentType.GetLength();
m_Children.Apply(AP4_AtomSizeAdder(size));
SetSize(size);
// update our parent
- if(m_Parent) m_Parent->OnChildChanged(this);
+ if (m_Parent) m_Parent->OnChildChanged(this);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.h
index a3e944805..44477ae13 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OdheAtom.h
@@ -51,8 +51,8 @@ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_OdheAtom, AP4_ContainerAtom)
// class methods
- static AP4_OdheAtom* Create(AP4_Size size,
- AP4_ByteStream& stream,
+ static AP4_OdheAtom* Create(AP4_Size size,
+ AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
// constructor
@@ -60,23 +60,20 @@ public:
* @param: ohdr ohdr atom passed with transfer of ownership semantics
*/
AP4_OdheAtom(const char* content_type, AP4_OhdrAtom* ohdr);
-
+
// AP4_Atom methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
// AP4_AtomParent methods
virtual void OnChildChanged(AP4_Atom* child);
-
+
// methods
- const AP4_String& GetContentType()
- {
- return m_ContentType;
- }
-
+ const AP4_String& GetContentType() { return m_ContentType; }
+
private:
// methods
- AP4_OdheAtom(AP4_UI32 size,
+ AP4_OdheAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream,
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.cpp
index eea8b08c5..f74e0d8f5 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - ohdr Atoms
+| AP4 - ohdr Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -41,21 +41,21 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_OhdrAtom)
| AP4_OhdrAtom::Create
+---------------------------------------------------------------------*/
AP4_OhdrAtom*
-AP4_OhdrAtom::Create(AP4_Size size,
+AP4_OhdrAtom::Create(AP4_Size size,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_OhdrAtom(size, version, flags, stream, atom_factory);
}
/*----------------------------------------------------------------------
| AP4_OhdrAtom::AP4_OhdrAtom
+---------------------------------------------------------------------*/
-AP4_OhdrAtom::AP4_OhdrAtom(AP4_UI08 encryption_method,
+AP4_OhdrAtom::AP4_OhdrAtom(AP4_UI08 encryption_method,
AP4_UI08 padding_scheme,
AP4_UI64 plaintext_length,
const char* content_id,
@@ -70,13 +70,13 @@ AP4_OhdrAtom::AP4_OhdrAtom(AP4_UI08 encryption_method,
m_RightsIssuerUrl(rights_issuer_url),
m_TextualHeaders(textual_headers, textual_headers_size)
{
- m_Size32 += 1 + 1 + 8 + 2 + 2 + 2 + m_ContentId.GetLength() + m_RightsIssuerUrl.GetLength() + textual_headers_size;
+ m_Size32 += 1+1+8+2+2+2+m_ContentId.GetLength()+m_RightsIssuerUrl.GetLength()+textual_headers_size;
}
/*----------------------------------------------------------------------
| AP4_OhdrAtom::AP4_OhdrAtom
+---------------------------------------------------------------------*/
-AP4_OhdrAtom::AP4_OhdrAtom(AP4_UI32 size,
+AP4_OhdrAtom::AP4_OhdrAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream,
@@ -85,7 +85,7 @@ AP4_OhdrAtom::AP4_OhdrAtom(AP4_UI32 size,
{
// encryption method
stream.ReadUI08(m_EncryptionMethod);
-
+
// padding scheme
stream.ReadUI08(m_PaddingScheme);
@@ -119,10 +119,9 @@ AP4_OhdrAtom::AP4_OhdrAtom(AP4_UI32 size,
delete[] buffer;
// read the children
- AP4_Size bytes_used = AP4_FULL_ATOM_HEADER_SIZE + 1 + 1 + 8 + 2 + 2 + 2 + content_id_length + rights_issuer_url_length + textual_headers_length;
- if(bytes_used <= size)
- {
- ReadChildren(atom_factory, stream, size - bytes_used);
+ AP4_Size bytes_used = AP4_FULL_ATOM_HEADER_SIZE+1+1+8+2+2+2+content_id_length+rights_issuer_url_length+textual_headers_length;
+ if (bytes_used <= size) {
+ ReadChildren(atom_factory, stream, size-bytes_used);
}
}
@@ -154,24 +153,21 @@ AP4_OhdrAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("encryption_method", m_EncryptionMethod);
inspector.AddField("padding_scheme", m_PaddingScheme);
- inspector.AddField("plaintext_length", (AP4_UI32)m_PlaintextLength);
+ inspector.AddField("plaintext_length", (AP4_UI32)m_PlaintextLength);
inspector.AddField("content_id", m_ContentId.GetChars());
inspector.AddField("rights_issuer_url", m_RightsIssuerUrl.GetChars());
{
- AP4_DataBuffer output_buffer;
+ AP4_DataBuffer output_buffer;
AP4_Result result;
- result = output_buffer.Reserve(1 + m_TextualHeaders.GetDataSize());
- if(AP4_FAILED(result))
- {
- inspector.AddField("textual_headers",
- m_TextualHeaders.UseData(),
- m_TextualHeaders.GetDataSize(),
- AP4_AtomInspector::HINT_HEX);
- }
- else
- {
+ result = output_buffer.Reserve(1+m_TextualHeaders.GetDataSize());
+ if (AP4_FAILED(result)) {
+ inspector.AddField("textual_headers",
+ m_TextualHeaders.UseData(),
+ m_TextualHeaders.GetDataSize(),
+ AP4_AtomInspector::HINT_HEX);
+ } else {
AP4_Size data_len = m_TextualHeaders.GetDataSize();
AP4_Byte* textual_headers_string;
AP4_Byte* curr;
@@ -179,16 +175,14 @@ AP4_OhdrAtom::InspectFields(AP4_AtomInspector& inspector)
output_buffer.SetData((const AP4_Byte*)m_TextualHeaders.GetData(), m_TextualHeaders.GetDataSize());
curr = textual_headers_string = output_buffer.UseData();
textual_headers_string[m_TextualHeaders.GetDataSize()] = '\0';
- while(curr < textual_headers_string + data_len)
- {
- if('\0' == *curr)
- {
+ while(curr < textual_headers_string+data_len) {
+ if ('\0' == *curr) {
*curr = '\n';
}
curr++;
}
inspector.AddField("textual_headers", (const char*) textual_headers_string);
- }
+ }
}
return InspectChildren(inspector);
@@ -197,7 +191,7 @@ AP4_OhdrAtom::InspectFields(AP4_AtomInspector& inspector)
/*----------------------------------------------------------------------
| AP4_OhdrAtom::Clone
+---------------------------------------------------------------------*/
-AP4_Atom*
+AP4_Atom*
AP4_OhdrAtom::Clone()
{
AP4_OhdrAtom* clone;
@@ -210,10 +204,9 @@ AP4_OhdrAtom::Clone()
m_TextualHeaders.GetDataSize());
AP4_List<AP4_Atom>::Item* child_item = m_Children.FirstItem();
- while(child_item)
- {
+ while (child_item) {
AP4_Atom* child_clone = child_item->GetData()->Clone();
- if(child_clone) clone->AddChild(child_clone);
+ if (child_clone) clone->AddChild(child_clone);
child_item = child_item->GetNext();
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.h
index a06905216..afee7f5fb 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OhdrAtom.h
@@ -56,12 +56,12 @@ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_OhdrAtom, AP4_ContainerAtom)
// class methods
- static AP4_OhdrAtom* Create(AP4_Size size,
- AP4_ByteStream& stream,
+ static AP4_OhdrAtom* Create(AP4_Size size,
+ AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
// constructor
- AP4_OhdrAtom(AP4_UI08 encryption_method,
+ AP4_OhdrAtom(AP4_UI08 encryption_method,
AP4_UI08 padding_scheme,
AP4_UI64 plaintext_length,
const char* content_id,
@@ -75,49 +75,25 @@ public:
virtual AP4_Atom* Clone();
// accessors
- AP4_UI08 GetEncryptionMethod() const
- {
- return m_EncryptionMethod;
- }
- void SetEncryptionMethod(AP4_UI08 encryption_method)
- {
- m_EncryptionMethod = encryption_method;
- }
- AP4_UI08 GetPaddingScheme() const
- {
- return m_PaddingScheme;
- }
- void SetPaddingScheme(AP4_UI08 padding_scheme)
- {
- m_PaddingScheme = padding_scheme;
- }
- AP4_UI64 GetPlaintextLength() const
- {
- return m_PlaintextLength;
- }
- const AP4_String& GetContentId() const
- {
- return m_ContentId;
- }
- const AP4_String& GetRightsIssuerUrl() const
- {
- return m_RightsIssuerUrl;
- }
- const AP4_DataBuffer& GetTextualHeaders() const
- {
- return m_TextualHeaders;
- }
+ AP4_UI08 GetEncryptionMethod() const { return m_EncryptionMethod; }
+ void SetEncryptionMethod(AP4_UI08 encryption_method) { m_EncryptionMethod = encryption_method; }
+ AP4_UI08 GetPaddingScheme() const { return m_PaddingScheme; }
+ void SetPaddingScheme(AP4_UI08 padding_scheme) { m_PaddingScheme = padding_scheme; }
+ AP4_UI64 GetPlaintextLength() const { return m_PlaintextLength; }
+ const AP4_String& GetContentId() const { return m_ContentId; }
+ const AP4_String& GetRightsIssuerUrl() const { return m_RightsIssuerUrl; }
+ const AP4_DataBuffer& GetTextualHeaders() const { return m_TextualHeaders; }
private:
// methods
- AP4_OhdrAtom(AP4_UI32 size,
+ AP4_OhdrAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
// members
- AP4_UI08 m_EncryptionMethod;
+ AP4_UI08 m_EncryptionMethod;
AP4_UI08 m_PaddingScheme;
AP4_UI64 m_PlaintextLength;
AP4_String m_ContentId;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.cpp
index bfd3a32c8..a224ab14d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.cpp
@@ -53,48 +53,45 @@
| AP4_OmaDcfAtomDecrypter::DecryptAtoms
+---------------------------------------------------------------------*/
AP4_Result
-AP4_OmaDcfAtomDecrypter::DecryptAtoms(AP4_AtomParent& atoms,
+AP4_OmaDcfAtomDecrypter::DecryptAtoms(AP4_AtomParent& atoms,
AP4_Processor::ProgressListener* /*listener*/,
AP4_BlockCipherFactory* block_cipher_factory,
AP4_ProtectionKeyMap& key_map)
{
unsigned int index = 1;
- for(AP4_List<AP4_Atom>::Item* item = atoms.GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
+ for (AP4_List<AP4_Atom>::Item* item = atoms.GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
- if(atom->GetType() != AP4_ATOM_TYPE_ODRM) continue;
+ if (atom->GetType() != AP4_ATOM_TYPE_ODRM) continue;
// check that we have the key
const AP4_UI08* key = key_map.GetKey(index++);
- if(key == NULL) return AP4_ERROR_INVALID_PARAMETERS;
-
+ if (key == NULL) return AP4_ERROR_INVALID_PARAMETERS;
+
// check that we have all the atoms we need
AP4_ContainerAtom* odrm = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
- if(odrm == NULL) continue; // not enough info
+ if (odrm == NULL) continue; // not enough info
AP4_OdheAtom* odhe = AP4_DYNAMIC_CAST(AP4_OdheAtom, odrm->GetChild(AP4_ATOM_TYPE_ODHE));
- if(odhe == NULL) continue; // not enough info
+ if (odhe == NULL) continue; // not enough info
AP4_OddaAtom* odda = AP4_DYNAMIC_CAST(AP4_OddaAtom, odrm->GetChild(AP4_ATOM_TYPE_ODDA));
- if(odda == NULL) continue; // not enough info
+ if (odda == NULL) continue; // not enough info
AP4_OhdrAtom* ohdr = AP4_DYNAMIC_CAST(AP4_OhdrAtom, odhe->GetChild(AP4_ATOM_TYPE_OHDR));
- if(ohdr == NULL) continue; // not enough info
+ if (ohdr == NULL) continue; // not enough info
// do nothing if the atom is not encrypted
- if(ohdr->GetEncryptionMethod() == AP4_OMA_DCF_ENCRYPTION_METHOD_NULL)
- {
+ if (ohdr->GetEncryptionMethod() == AP4_OMA_DCF_ENCRYPTION_METHOD_NULL) {
continue;
}
-
+
// create the byte stream
AP4_ByteStream* cipher_stream = NULL;
- AP4_Result result = CreateDecryptingStream(*odrm,
- key,
- 16,
- block_cipher_factory,
- cipher_stream);
- if(AP4_SUCCEEDED(result))
- {
+ AP4_Result result = CreateDecryptingStream(*odrm,
+ key,
+ 16,
+ block_cipher_factory,
+ cipher_stream);
+ if (AP4_SUCCEEDED(result)) {
// replace the odda atom's payload with the decrypted stream
odda->SetEncryptedPayload(*cipher_stream, ohdr->GetPlaintextLength());
cipher_stream->Release();
@@ -111,7 +108,7 @@ AP4_OmaDcfAtomDecrypter::DecryptAtoms(AP4_AtomParent& atoms,
/*----------------------------------------------------------------------
| AP4_OmaDcfAtomDecrypter::CreateDecryptingStream
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfAtomDecrypter::CreateDecryptingStream(
AP4_ContainerAtom& odrm,
const AP4_UI08* key,
@@ -121,111 +118,105 @@ AP4_OmaDcfAtomDecrypter::CreateDecryptingStream(
{
// default return values
stream = NULL;
-
+
AP4_OdheAtom* odhe = AP4_DYNAMIC_CAST(AP4_OdheAtom, odrm.GetChild(AP4_ATOM_TYPE_ODHE));
- if(odhe == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (odhe == NULL) return AP4_ERROR_INVALID_FORMAT;
AP4_OddaAtom* odda = AP4_DYNAMIC_CAST(AP4_OddaAtom, odrm.GetChild(AP4_ATOM_TYPE_ODDA));
- if(odda == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (odda == NULL) return AP4_ERROR_INVALID_FORMAT;
AP4_OhdrAtom* ohdr = AP4_DYNAMIC_CAST(AP4_OhdrAtom, odhe->GetChild(AP4_ATOM_TYPE_OHDR));
- if(ohdr == NULL) return AP4_ERROR_INVALID_FORMAT;
-
+ if (ohdr == NULL) return AP4_ERROR_INVALID_FORMAT;
+
// shortcut for non-encrypted files
- if(ohdr->GetEncryptionMethod() == AP4_OMA_DCF_ENCRYPTION_METHOD_NULL)
- {
+ if (ohdr->GetEncryptionMethod() == AP4_OMA_DCF_ENCRYPTION_METHOD_NULL) {
stream = &odda->GetEncryptedPayload();
stream->AddReference();
return AP4_SUCCESS;
}
-
+
// if this is part of a group, use the group key to obtain the content
// key (note that the field called GroupKey in the spec is actually not
// the group key but the content key encrypted with the group key...
AP4_GrpiAtom* grpi = AP4_DYNAMIC_CAST(AP4_GrpiAtom, ohdr->GetChild(AP4_ATOM_TYPE_GRPI));
AP4_UI08* key_buffer = NULL;
- if(grpi)
- {
+ if (grpi) {
// sanity check on the encrypted key size
- if(grpi->GetGroupKey().GetDataSize() < 32)
- {
+ if (grpi->GetGroupKey().GetDataSize() < 32) {
return AP4_ERROR_INVALID_FORMAT;
}
-
+
// create a block cipher to decrypt the content key
AP4_BlockCipher* block_cipher = NULL;
AP4_Result result;
-
+
// create a stream cipher from the block cipher
- AP4_StreamCipher* stream_cipher = NULL;
- switch(ohdr->GetEncryptionMethod())
- {
- case AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CBC:
- result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::DECRYPT,
- key,
- key_size,
- block_cipher);
- if(AP4_FAILED(result)) return result;
- stream_cipher = new AP4_CbcStreamCipher(block_cipher, AP4_CbcStreamCipher::DECRYPT);
- break;
-
- case AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CTR:
- result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::ENCRYPT,
- key,
- key_size,
- block_cipher);
- if(AP4_FAILED(result)) return result;
- stream_cipher = new AP4_CtrStreamCipher(block_cipher, NULL, 16);
- break;
-
- default:
- return AP4_ERROR_NOT_SUPPORTED;
+ AP4_StreamCipher* stream_cipher = NULL;
+ switch (ohdr->GetEncryptionMethod()) {
+ case AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CBC:
+ result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::DECRYPT,
+ key,
+ key_size,
+ block_cipher);
+ if (AP4_FAILED(result)) return result;
+ stream_cipher = new AP4_CbcStreamCipher(block_cipher, AP4_CbcStreamCipher::DECRYPT);
+ break;
+
+ case AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CTR:
+ result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::ENCRYPT,
+ key,
+ key_size,
+ block_cipher);
+ if (AP4_FAILED(result)) return result;
+ stream_cipher = new AP4_CtrStreamCipher(block_cipher, NULL, 16);
+ break;
+
+ default:
+ return AP4_ERROR_NOT_SUPPORTED;
}
// set the IV
stream_cipher->SetIV(grpi->GetGroupKey().GetData());
-
+
// decrypt the content key
AP4_Size key_buffer_size = grpi->GetGroupKey().GetDataSize(); // worst case
key_buffer = new AP4_UI08[key_buffer_size];
- result = stream_cipher->ProcessBuffer(grpi->GetGroupKey().GetData() + 16,
- grpi->GetGroupKey().GetDataSize() - 16,
- key_buffer,
- &key_buffer_size,
+ result = stream_cipher->ProcessBuffer(grpi->GetGroupKey().GetData()+16,
+ grpi->GetGroupKey().GetDataSize()-16,
+ key_buffer,
+ &key_buffer_size,
true);
delete stream_cipher; // this will also delete the block cipher
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
delete[] key_buffer;
return result;
}
-
+
// point to the new key value
key = key_buffer;
key_size = key_buffer_size;
}
-
+
AP4_OmaDcfCipherMode mode;
- switch(ohdr->GetEncryptionMethod())
- {
- case AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CBC:
- mode = AP4_OMA_DCF_CIPHER_MODE_CBC;
- break;
- case AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CTR:
- mode = AP4_OMA_DCF_CIPHER_MODE_CTR;
- break;
- default:
- return AP4_ERROR_NOT_SUPPORTED;
+ switch (ohdr->GetEncryptionMethod()) {
+ case AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CBC:
+ mode = AP4_OMA_DCF_CIPHER_MODE_CBC;
+ break;
+ case AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CTR:
+ mode = AP4_OMA_DCF_CIPHER_MODE_CTR;
+ break;
+ default:
+ return AP4_ERROR_NOT_SUPPORTED;
}
-
+
AP4_Result result;
result = CreateDecryptingStream(mode,
- odda->GetEncryptedPayload(),
- ohdr->GetPlaintextLength(),
- key, key_size,
+ odda->GetEncryptedPayload(),
+ ohdr->GetPlaintextLength(),
+ key, key_size,
block_cipher_factory,
stream);
-
+
// cleanup
delete[] key_buffer;
@@ -235,7 +226,7 @@ AP4_OmaDcfAtomDecrypter::CreateDecryptingStream(
/*----------------------------------------------------------------------
| AP4_OmaDcfAtomDecrypter::CreateDecryptingStream
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfAtomDecrypter::CreateDecryptingStream(
AP4_OmaDcfCipherMode mode,
AP4_ByteStream& encrypted_stream,
@@ -243,52 +234,45 @@ AP4_OmaDcfAtomDecrypter::CreateDecryptingStream(
const AP4_UI08* key,
AP4_Size key_size,
AP4_BlockCipherFactory* block_cipher_factory,
- AP4_ByteStream*& stream)
+ AP4_ByteStream*& stream)
{
// default return value
stream = NULL;
-
+
// get the encrypted size (includes IV and padding)
AP4_LargeSize encrypted_size = 0;
AP4_Result result = encrypted_stream.GetSize(encrypted_size);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// check that the encrypted size is consistent with the cipher mode
AP4_DecryptingStream::CipherMode cipher_mode;
- if(mode == AP4_OMA_DCF_CIPHER_MODE_CBC)
- {
+ if (mode == AP4_OMA_DCF_CIPHER_MODE_CBC) {
// we need at least 16 bytes of IV and 32 bytes of data+padding
// we also need a multiple of the block size
- if(encrypted_size < 48 || ((encrypted_size % 16) != 0))
- {
+ if (encrypted_size < 48 || ((encrypted_size % 16) != 0)) {
return AP4_ERROR_INVALID_FORMAT;
}
cipher_mode = AP4_DecryptingStream::CIPHER_MODE_CBC;
- }
- else if(mode == AP4_OMA_DCF_CIPHER_MODE_CTR)
- {
+ } else if (mode == AP4_OMA_DCF_CIPHER_MODE_CTR) {
// we need at least 16 bytes of IV
- if(encrypted_size < 16)
- {
+ if (encrypted_size < 16) {
return AP4_ERROR_INVALID_FORMAT;
}
cipher_mode = AP4_DecryptingStream::CIPHER_MODE_CTR;
- }
- else
- {
+ } else {
return AP4_ERROR_NOT_SUPPORTED;
}
// read the IV
AP4_UI08 iv[16];
result = encrypted_stream.Seek(0);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = encrypted_stream.Read(iv, 16);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// create a sub stream with just the encrypted payload without the IV
- AP4_ByteStream* sub_stream = new AP4_SubStream(encrypted_stream, 16, encrypted_size - 16);
-
+ AP4_ByteStream* sub_stream = new AP4_SubStream(encrypted_stream, 16, encrypted_size-16);
+
// create the decrypting cipher
result = AP4_DecryptingStream::Create(cipher_mode,
*sub_stream,
@@ -302,7 +286,7 @@ AP4_OmaDcfAtomDecrypter::CreateDecryptingStream(
// we don't keep our own reference to the sub stream
sub_stream->Release();
-
+
return result;
}
@@ -310,89 +294,80 @@ AP4_OmaDcfAtomDecrypter::CreateDecryptingStream(
| AP4_OmaDcfSampleDecrypter::Create
+---------------------------------------------------------------------*/
AP4_Result
-AP4_OmaDcfSampleDecrypter::Create(AP4_ProtectedSampleDescription* sample_description,
- const AP4_UI08* key,
+AP4_OmaDcfSampleDecrypter::Create(AP4_ProtectedSampleDescription* sample_description,
+ const AP4_UI08* key,
AP4_Size key_size,
AP4_BlockCipherFactory* block_cipher_factory,
AP4_OmaDcfSampleDecrypter*& cipher)
{
// check the parameters
- if(key == NULL || block_cipher_factory == NULL)
- {
+ if (key == NULL || block_cipher_factory == NULL) {
return AP4_ERROR_INVALID_PARAMETERS;
}
-
+
// default return value
cipher = NULL;
// get the scheme info atom
AP4_ContainerAtom* schi = sample_description->GetSchemeInfo()->GetSchiAtom();
- if(schi == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (schi == NULL) return AP4_ERROR_INVALID_FORMAT;
// get and check the cipher params
- // NOTE: we only support an IV Length less than or equal to the cipher block size,
+ // NOTE: we only support an IV Length less than or equal to the cipher block size,
// and we don't know how to deal with a key indicator length != 0
AP4_OdafAtom* odaf = AP4_DYNAMIC_CAST(AP4_OdafAtom, schi->FindChild("odkm/odaf"));
- if(odaf)
- {
- if(odaf->GetIvLength() > AP4_CIPHER_BLOCK_SIZE) return AP4_ERROR_INVALID_FORMAT;
- if(odaf->GetKeyIndicatorLength() != 0) return AP4_ERROR_INVALID_FORMAT;
+ if (odaf) {
+ if (odaf->GetIvLength() > AP4_CIPHER_BLOCK_SIZE) return AP4_ERROR_INVALID_FORMAT;
+ if (odaf->GetKeyIndicatorLength() != 0) return AP4_ERROR_INVALID_FORMAT;
}
// check the scheme details and create the cipher
AP4_OhdrAtom* ohdr = AP4_DYNAMIC_CAST(AP4_OhdrAtom, schi->FindChild("odkm/ohdr"));
- if(ohdr == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (ohdr == NULL) return AP4_ERROR_INVALID_FORMAT;
AP4_UI08 encryption_method = ohdr->GetEncryptionMethod();
- if(encryption_method == AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CBC)
- {
+ if (encryption_method == AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CBC) {
// in CBC mode, we only support IVs of the same size as the cipher block size
- if(odaf->GetIvLength() != AP4_CIPHER_BLOCK_SIZE) return AP4_ERROR_INVALID_FORMAT;
+ if (odaf->GetIvLength() != AP4_CIPHER_BLOCK_SIZE) return AP4_ERROR_INVALID_FORMAT;
// require RFC_2630 padding
- if(ohdr->GetPaddingScheme() != AP4_OMA_DCF_PADDING_SCHEME_RFC_2630)
- {
+ if (ohdr->GetPaddingScheme() != AP4_OMA_DCF_PADDING_SCHEME_RFC_2630) {
return AP4_ERROR_NOT_SUPPORTED;
}
// create the block cipher
AP4_BlockCipher* block_cipher = NULL;
- AP4_Result result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::DECRYPT,
- key,
- key_size,
- block_cipher);
- if(AP4_FAILED(result)) return result;
+ AP4_Result result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::DECRYPT,
+ key,
+ key_size,
+ block_cipher);
+ if (AP4_FAILED(result)) return result;
// create the cipher
- cipher = new AP4_OmaDcfCbcSampleDecrypter(block_cipher,
- odaf->GetSelectiveEncryption());
+ cipher = new AP4_OmaDcfCbcSampleDecrypter(block_cipher,
+ odaf->GetSelectiveEncryption());
return AP4_SUCCESS;
- }
- else if(encryption_method == AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CTR)
- {
+ } else if (encryption_method == AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CTR) {
// require NONE padding
- if(ohdr->GetPaddingScheme() != AP4_OMA_DCF_PADDING_SCHEME_NONE)
- {
+ if (ohdr->GetPaddingScheme() != AP4_OMA_DCF_PADDING_SCHEME_NONE) {
return AP4_ERROR_INVALID_FORMAT;
}
// create the block cipher
AP4_BlockCipher* block_cipher = NULL;
- AP4_Result result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::ENCRYPT,
- key,
- key_size,
- block_cipher);
- if(AP4_FAILED(result)) return result;
+ AP4_Result result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::ENCRYPT,
+ key,
+ key_size,
+ block_cipher);
+ if (AP4_FAILED(result)) return result;
// create the cipher
- cipher = new AP4_OmaDcfCtrSampleDecrypter(block_cipher,
- odaf->GetIvLength(),
- odaf->GetSelectiveEncryption());
+ cipher = new AP4_OmaDcfCtrSampleDecrypter(block_cipher,
+ odaf->GetIvLength(),
+ odaf->GetSelectiveEncryption());
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_NOT_SUPPORTED;
}
}
@@ -420,48 +395,44 @@ AP4_OmaDcfCtrSampleDecrypter::~AP4_OmaDcfCtrSampleDecrypter()
/*----------------------------------------------------------------------
| AP4_OmaDcfCtrSampleDecrypter::DecryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfCtrSampleDecrypter::DecryptSampleData(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out,
- const AP4_UI08* /*iv*/)
-{
+ AP4_DataBuffer& data_out,
+ const AP4_UI08* /*iv*/)
+{
bool is_encrypted = true;
const unsigned char* in = data_in.GetData();
AP4_Size in_size = data_in.GetDataSize();
- // default to 0 output
+ // default to 0 output
AP4_CHECK(data_out.SetDataSize(0));
// check the selective encryption flag
- if(m_SelectiveEncryption)
- {
- if(in_size < 1) return AP4_ERROR_INVALID_FORMAT;
- is_encrypted = ((in[0] & 0x80) != 0);
+ if (m_SelectiveEncryption) {
+ if (in_size < 1) return AP4_ERROR_INVALID_FORMAT;
+ is_encrypted = ((in[0]&0x80)!=0);
in++;
}
// check the size
- unsigned int header_size = (m_SelectiveEncryption ? 1 : 0) + (is_encrypted ? m_IvLength : 0);
- if(header_size > in_size) return AP4_ERROR_INVALID_FORMAT;
+ unsigned int header_size = (m_SelectiveEncryption?1:0)+(is_encrypted?m_IvLength:0);
+ if (header_size > in_size) return AP4_ERROR_INVALID_FORMAT;
// process the sample data
- AP4_Size payload_size = in_size - header_size;
+ AP4_Size payload_size = in_size-header_size;
AP4_CHECK(data_out.Reserve(payload_size));
unsigned char* out = data_out.UseData();
- if(is_encrypted)
- {
+ if (is_encrypted) {
// set the IV
m_Cipher->SetIV(in);
- AP4_CHECK(m_Cipher->ProcessBuffer(in + m_IvLength,
- payload_size,
+ AP4_CHECK(m_Cipher->ProcessBuffer(in+m_IvLength,
+ payload_size,
out));
- }
- else
- {
+ } else {
AP4_CopyMemory(out, in, payload_size);
}
AP4_CHECK(data_out.SetDataSize(payload_size));
-
+
return AP4_SUCCESS;
}
@@ -471,26 +442,23 @@ AP4_OmaDcfCtrSampleDecrypter::DecryptSampleData(AP4_DataBuffer& data_in,
AP4_Size
AP4_OmaDcfCtrSampleDecrypter::GetDecryptedSampleSize(AP4_Sample& sample)
{
- if(m_Cipher == NULL) return 0;
+ if (m_Cipher == NULL) return 0;
// decide if this sample is encrypted or not
bool is_encrypted;
- if(m_SelectiveEncryption)
- {
+ if (m_SelectiveEncryption) {
// read the first byte to see if the sample is encrypted or not
AP4_Byte h;
AP4_DataBuffer peek_buffer;
peek_buffer.SetBuffer(&h, 1);
sample.ReadData(peek_buffer, 1);
- is_encrypted = ((h & 0x80) != 0);
- }
- else
- {
+ is_encrypted = ((h&0x80)!=0);
+ } else {
is_encrypted = true;
}
- AP4_Size crypto_header_size = (m_SelectiveEncryption ? 1 : 0) + (is_encrypted ? m_IvLength : 0);
- return sample.GetSize() - crypto_header_size;
+ AP4_Size crypto_header_size = (m_SelectiveEncryption?1:0)+(is_encrypted?m_IvLength:0);
+ return sample.GetSize()-crypto_header_size;
}
/*----------------------------------------------------------------------
@@ -515,37 +483,35 @@ AP4_OmaDcfCbcSampleDecrypter::~AP4_OmaDcfCbcSampleDecrypter()
/*----------------------------------------------------------------------
| AP4_OmaDbcCbcSampleDecrypter::DecryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfCbcSampleDecrypter::DecryptSampleData(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out,
- const AP4_UI08* /*iv*/)
-{
+ AP4_DataBuffer& data_out,
+ const AP4_UI08* /*iv*/)
+{
bool is_encrypted = true;
const unsigned char* in = data_in.GetData();
AP4_Size in_size = data_in.GetDataSize();
AP4_Size out_size;
- // default to 0 output
+ // default to 0 output
AP4_CHECK(data_out.SetDataSize(0));
// check the selective encryption flag
- if(m_SelectiveEncryption)
- {
- if(in_size < 1) return AP4_ERROR_INVALID_FORMAT;
- is_encrypted = ((in[0] & 0x80) != 0);
+ if (m_SelectiveEncryption) {
+ if (in_size < 1) return AP4_ERROR_INVALID_FORMAT;
+ is_encrypted = ((in[0]&0x80)!=0);
in++;
}
// check the size
- unsigned int header_size = (m_SelectiveEncryption ? 1 : 0) + (is_encrypted ? m_IvLength : 0);
- if(header_size > in_size) return AP4_ERROR_INVALID_FORMAT;
+ unsigned int header_size = (m_SelectiveEncryption?1:0)+(is_encrypted?m_IvLength:0);
+ if (header_size > in_size) return AP4_ERROR_INVALID_FORMAT;
// process the sample data
- unsigned int payload_size = in_size - header_size;
+ unsigned int payload_size = in_size-header_size;
data_out.Reserve(payload_size);
unsigned char* out = data_out.UseData();
- if(is_encrypted)
- {
+ if (is_encrypted) {
// get the IV
const AP4_UI08* iv = (const AP4_UI08*)in;
in += AP4_CIPHER_BLOCK_SIZE;
@@ -553,9 +519,7 @@ AP4_OmaDcfCbcSampleDecrypter::DecryptSampleData(AP4_DataBuffer& data_in,
m_Cipher->SetIV(iv);
out_size = payload_size;
AP4_CHECK(m_Cipher->ProcessBuffer(in, payload_size, out, &out_size, true));
- }
- else
- {
+ } else {
AP4_CopyMemory(out, in, payload_size);
out_size = payload_size;
}
@@ -571,57 +535,48 @@ AP4_OmaDcfCbcSampleDecrypter::DecryptSampleData(AP4_DataBuffer& data_in,
AP4_Size
AP4_OmaDcfCbcSampleDecrypter::GetDecryptedSampleSize(AP4_Sample& sample)
{
- if(m_Cipher == NULL) return 0;
+ if (m_Cipher == NULL) return 0;
// decide if this sample is encrypted or not
bool is_encrypted;
- if(m_SelectiveEncryption)
- {
+ if (m_SelectiveEncryption) {
// read the first byte to see if the sample is encrypted or not
AP4_Byte h;
AP4_DataBuffer peek_buffer;
peek_buffer.SetBuffer(&h, 1);
sample.ReadData(peek_buffer, 1);
- is_encrypted = ((h & 0x80) != 0);
- }
- else
- {
+ is_encrypted = ((h&0x80)!=0);
+ } else {
is_encrypted = true;
}
- if(is_encrypted)
- {
+ if (is_encrypted) {
// with CBC, we need to decrypt the last block to know what the padding was
- AP4_Size crypto_header_size = (m_SelectiveEncryption ? 1 : 0) + m_IvLength;
- AP4_Size encrypted_size = sample.GetSize() - crypto_header_size;
+ AP4_Size crypto_header_size = (m_SelectiveEncryption?1:0)+m_IvLength;
+ AP4_Size encrypted_size = sample.GetSize()-crypto_header_size;
AP4_DataBuffer encrypted;
AP4_DataBuffer decrypted;
AP4_Size decrypted_size = AP4_CIPHER_BLOCK_SIZE;
- if(sample.GetSize() < crypto_header_size + AP4_CIPHER_BLOCK_SIZE)
- {
+ if (sample.GetSize() < crypto_header_size+AP4_CIPHER_BLOCK_SIZE) {
return 0;
}
- AP4_Size offset = sample.GetSize() - 2 * AP4_CIPHER_BLOCK_SIZE;
- if(AP4_FAILED(sample.ReadData(encrypted, 2 * AP4_CIPHER_BLOCK_SIZE, offset)))
- {
+ AP4_Size offset = sample.GetSize()-2*AP4_CIPHER_BLOCK_SIZE;
+ if (AP4_FAILED(sample.ReadData(encrypted, 2*AP4_CIPHER_BLOCK_SIZE, offset))) {
return 0;
}
decrypted.Reserve(decrypted_size);
m_Cipher->SetIV(encrypted.GetData());
- if(AP4_FAILED(m_Cipher->ProcessBuffer(encrypted.GetData() + AP4_CIPHER_BLOCK_SIZE,
- AP4_CIPHER_BLOCK_SIZE,
- decrypted.UseData(),
- &decrypted_size,
- true)))
- {
+ if (AP4_FAILED(m_Cipher->ProcessBuffer(encrypted.GetData()+AP4_CIPHER_BLOCK_SIZE,
+ AP4_CIPHER_BLOCK_SIZE,
+ decrypted.UseData(),
+ &decrypted_size,
+ true))) {
return 0;
}
- unsigned int padding_size = AP4_CIPHER_BLOCK_SIZE - decrypted_size;
- return encrypted_size - padding_size;
- }
- else
- {
- return sample.GetSize() - (m_SelectiveEncryption ? 1 : 0);
+ unsigned int padding_size = AP4_CIPHER_BLOCK_SIZE-decrypted_size;
+ return encrypted_size-padding_size;
+ } else {
+ return sample.GetSize()-(m_SelectiveEncryption?1:0);
}
}
@@ -631,16 +586,13 @@ AP4_OmaDcfCbcSampleDecrypter::GetDecryptedSampleSize(AP4_Sample& sample)
AP4_OmaDcfSampleEncrypter::AP4_OmaDcfSampleEncrypter(const AP4_UI08* salt)
{
// left-align the salt
- unsigned int i = 0;
- if(salt)
- {
- for(; i < 8; i++)
- {
+ unsigned int i=0;
+ if (salt) {
+ for (; i<8; i++) {
m_Salt[i] = salt[i];
}
}
- for(; i < sizeof(m_Salt) / sizeof(m_Salt[0]); i++)
- {
+ for (; i<sizeof(m_Salt)/sizeof(m_Salt[0]); i++) {
m_Salt[i] = 0;
}
}
@@ -649,8 +601,8 @@ AP4_OmaDcfSampleEncrypter::AP4_OmaDcfSampleEncrypter(const AP4_UI08* salt)
| AP4_OmaDcfCtrSampleEncrypter::AP4_OmaDcfCtrSampleEncrypter
+---------------------------------------------------------------------*/
AP4_OmaDcfCtrSampleEncrypter::AP4_OmaDcfCtrSampleEncrypter(AP4_BlockCipher* block_cipher,
- const AP4_UI08* salt) :
- AP4_OmaDcfSampleEncrypter(salt)
+ const AP4_UI08* salt) :
+ AP4_OmaDcfSampleEncrypter(salt)
{
m_Cipher = new AP4_CtrStreamCipher(block_cipher, m_Salt, 8);
}
@@ -666,15 +618,15 @@ AP4_OmaDcfCtrSampleEncrypter::~AP4_OmaDcfCtrSampleEncrypter()
/*----------------------------------------------------------------------
| AP4_OmaDcfCtrSampleEncrypter::EncryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfCtrSampleEncrypter::EncryptSampleData(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out,
- AP4_UI64 counter,
- bool /*skip_encryption*/)
+ AP4_DataBuffer& data_out,
+ AP4_UI64 counter,
+ bool /*skip_encryption*/)
{
// setup the buffers
const unsigned char* in = data_in.GetData();
- AP4_CHECK(data_out.SetDataSize(data_in.GetDataSize() + AP4_CIPHER_BLOCK_SIZE + 1));
+ AP4_CHECK(data_out.SetDataSize(data_in.GetDataSize()+AP4_CIPHER_BLOCK_SIZE+1));
unsigned char* out = data_out.UseData();
// selective encryption flag
@@ -688,8 +640,8 @@ AP4_OmaDcfCtrSampleEncrypter::EncryptSampleData(AP4_DataBuffer& data_in,
// encrypt the payload
AP4_Size data_size = data_in.GetDataSize();
- m_Cipher->SetIV(out + 8);
- m_Cipher->ProcessBuffer(in, data_size, out + AP4_CIPHER_BLOCK_SIZE);
+ m_Cipher->SetIV(out+8);
+ m_Cipher->ProcessBuffer(in, data_size, out+AP4_CIPHER_BLOCK_SIZE);
return AP4_SUCCESS;
}
@@ -697,18 +649,18 @@ AP4_OmaDcfCtrSampleEncrypter::EncryptSampleData(AP4_DataBuffer& data_in,
/*----------------------------------------------------------------------
| AP4_OmaDcfCtrSampleEncrypter::GetEncryptedSampleSize
+---------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_OmaDcfCtrSampleEncrypter::GetEncryptedSampleSize(AP4_Sample& sample)
{
- return sample.GetSize() + AP4_CIPHER_BLOCK_SIZE + 1;
+ return sample.GetSize()+AP4_CIPHER_BLOCK_SIZE+1;
}
/*----------------------------------------------------------------------
| AP4_OmaDcfCbcSampleEncrypter::AP4_OmaDcfCbcSampleEncrypter
+---------------------------------------------------------------------*/
AP4_OmaDcfCbcSampleEncrypter::AP4_OmaDcfCbcSampleEncrypter(AP4_BlockCipher* block_cipher,
- const AP4_UI08* salt) :
- AP4_OmaDcfSampleEncrypter(salt)
+ const AP4_UI08* salt) :
+ AP4_OmaDcfSampleEncrypter(salt)
{
m_Cipher = new AP4_CbcStreamCipher(block_cipher, AP4_CbcStreamCipher::ENCRYPT);
}
@@ -724,17 +676,17 @@ AP4_OmaDcfCbcSampleEncrypter::~AP4_OmaDcfCbcSampleEncrypter()
/*----------------------------------------------------------------------
| AP4_OmaDcfCbcSampleEncrypter::EncryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfCbcSampleEncrypter::EncryptSampleData(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out,
- AP4_UI64 counter,
- bool /*skip_encryption*/)
+ AP4_DataBuffer& data_out,
+ AP4_UI64 counter,
+ bool /*skip_encryption*/)
{
// make sure there is enough space in the output buffer
- data_out.Reserve(data_in.GetDataSize() + 2 * AP4_CIPHER_BLOCK_SIZE + 1);
+ data_out.Reserve(data_in.GetDataSize()+2*AP4_CIPHER_BLOCK_SIZE+1);
// setup the buffers
- AP4_Size out_size = data_in.GetDataSize() + AP4_CIPHER_BLOCK_SIZE;
+ AP4_Size out_size = data_in.GetDataSize()+AP4_CIPHER_BLOCK_SIZE;
unsigned char* out = data_out.UseData();
// selective encryption flag
@@ -748,12 +700,12 @@ AP4_OmaDcfCbcSampleEncrypter::EncryptSampleData(AP4_DataBuffer& data_in,
// encrypt the payload
m_Cipher->SetIV(out);
- m_Cipher->ProcessBuffer(data_in.GetData(),
+ m_Cipher->ProcessBuffer(data_in.GetData(),
data_in.GetDataSize(),
- out + AP4_CIPHER_BLOCK_SIZE,
+ out+AP4_CIPHER_BLOCK_SIZE,
&out_size,
true);
- AP4_CHECK(data_out.SetDataSize(out_size + AP4_CIPHER_BLOCK_SIZE + 1));
+ AP4_CHECK(data_out.SetDataSize(out_size+AP4_CIPHER_BLOCK_SIZE+1));
return AP4_SUCCESS;
}
@@ -765,8 +717,8 @@ AP4_Size
AP4_OmaDcfCbcSampleEncrypter::GetEncryptedSampleSize(AP4_Sample& sample)
{
AP4_Size sample_size = sample.GetSize();
- AP4_Size padding_size = AP4_CIPHER_BLOCK_SIZE - (sample_size % AP4_CIPHER_BLOCK_SIZE);
- return sample_size + padding_size + AP4_CIPHER_BLOCK_SIZE + 1;
+ AP4_Size padding_size = AP4_CIPHER_BLOCK_SIZE-(sample_size%AP4_CIPHER_BLOCK_SIZE);
+ return sample_size+padding_size+AP4_CIPHER_BLOCK_SIZE+1;
}
/*----------------------------------------------------------------------
@@ -782,29 +734,27 @@ AP4_OmaDcfTrackDecrypter::Create(
AP4_OmaDcfTrackDecrypter*& decrypter)
{
// check and set defaults
- if(key == NULL)
- {
+ if (key == NULL) {
return AP4_ERROR_INVALID_PARAMETERS;
}
- if(block_cipher_factory == NULL)
- {
+ if (block_cipher_factory == NULL) {
block_cipher_factory = &AP4_DefaultBlockCipherFactory::Instance;
}
decrypter = NULL;
// create the cipher
AP4_OmaDcfSampleDecrypter* cipher = NULL;
- AP4_Result result = AP4_OmaDcfSampleDecrypter::Create(sample_description,
- key,
- key_size,
- block_cipher_factory,
- cipher);
- if(AP4_FAILED(result)) return result;
+ AP4_Result result = AP4_OmaDcfSampleDecrypter::Create(sample_description,
+ key,
+ key_size,
+ block_cipher_factory,
+ cipher);
+ if (AP4_FAILED(result)) return result;
// instantiate the object
- decrypter = new AP4_OmaDcfTrackDecrypter(cipher,
- sample_entry,
- sample_description->GetOriginalFormat());
+ decrypter = new AP4_OmaDcfTrackDecrypter(cipher,
+ sample_entry,
+ sample_description->GetOriginalFormat());
return AP4_SUCCESS;
}
@@ -812,8 +762,8 @@ AP4_OmaDcfTrackDecrypter::Create(
| AP4_OmaDcfTrackDecrypter::AP4_OmaDcfTrackDecrypter
+---------------------------------------------------------------------*/
AP4_OmaDcfTrackDecrypter::AP4_OmaDcfTrackDecrypter(AP4_OmaDcfSampleDecrypter* cipher,
- AP4_SampleEntry* sample_entry,
- AP4_UI32 original_format) :
+ AP4_SampleEntry* sample_entry,
+ AP4_UI32 original_format) :
m_Cipher(cipher),
m_SampleEntry(sample_entry),
m_OriginalFormat(original_format)
@@ -831,17 +781,17 @@ AP4_OmaDcfTrackDecrypter::~AP4_OmaDcfTrackDecrypter()
/*----------------------------------------------------------------------
| AP4_OmaDcfTrackDecrypter::GetProcessedSampleSize
+---------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_OmaDcfTrackDecrypter::GetProcessedSampleSize(AP4_Sample& sample)
{
- if(m_Cipher == NULL) return 0;
+ if (m_Cipher == NULL) return 0;
return m_Cipher->GetDecryptedSampleSize(sample);
}
/*----------------------------------------------------------------------
| AP4_OmaDcfTrackDecrypter::ProcessTrack
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfTrackDecrypter::ProcessTrack()
{
m_SampleEntry->SetType(m_OriginalFormat);
@@ -852,7 +802,7 @@ AP4_OmaDcfTrackDecrypter::ProcessTrack()
/*----------------------------------------------------------------------
| AP4_OmaDcfDecrypter::ProcessSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfTrackDecrypter::ProcessSample(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out)
{
@@ -862,8 +812,7 @@ AP4_OmaDcfTrackDecrypter::ProcessSample(AP4_DataBuffer& data_in,
/*----------------------------------------------------------------------
| AP4_OmaDcfTrackEncrypter
+---------------------------------------------------------------------*/
-class AP4_OmaDcfTrackEncrypter : public AP4_Processor::TrackHandler
-{
+class AP4_OmaDcfTrackEncrypter : public AP4_Processor::TrackHandler {
public:
// constructor
AP4_OmaDcfTrackEncrypter(AP4_OmaDcfCipherMode cipher_mode,
@@ -873,7 +822,7 @@ public:
AP4_UI32 format,
const char* content_id,
const char* rights_issuer_url,
- const AP4_Byte* textual_headers,
+ const AP4_Byte* textual_headers,
AP4_Size textual_headers_size);
virtual ~AP4_OmaDcfTrackEncrypter();
@@ -907,7 +856,7 @@ AP4_OmaDcfTrackEncrypter::AP4_OmaDcfTrackEncrypter(
AP4_UI32 format,
const char* content_id,
const char* rights_issuer_url,
- const AP4_Byte* textual_headers,
+ const AP4_Byte* textual_headers,
AP4_Size textual_headers_size) :
m_SampleEntry(sample_entry),
m_Format(format),
@@ -917,14 +866,11 @@ AP4_OmaDcfTrackEncrypter::AP4_OmaDcfTrackEncrypter(
m_Counter(0)
{
// instantiate the cipher (fixed params for now)
- if(cipher_mode == AP4_OMA_DCF_CIPHER_MODE_CBC)
- {
+ if (cipher_mode == AP4_OMA_DCF_CIPHER_MODE_CBC) {
m_Cipher = new AP4_OmaDcfCbcSampleEncrypter(block_cipher, salt);
m_CipherMode = AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CBC;
m_CipherPadding = AP4_OMA_DCF_PADDING_SCHEME_RFC_2630;
- }
- else
- {
+ } else {
m_Cipher = new AP4_OmaDcfCtrSampleEncrypter(block_cipher, salt);
m_CipherMode = AP4_OMA_DCF_ENCRYPTION_METHOD_AES_CTR;
m_CipherPadding = AP4_OMA_DCF_PADDING_SCHEME_NONE;
@@ -942,7 +888,7 @@ AP4_OmaDcfTrackEncrypter::~AP4_OmaDcfTrackEncrypter()
/*----------------------------------------------------------------------
| AP4_OmaDcfTrackEncrypter::GetProcessedSampleSize
+---------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_OmaDcfTrackEncrypter::GetProcessedSampleSize(AP4_Sample& sample)
{
return m_Cipher->GetEncryptedSampleSize(sample);
@@ -951,7 +897,7 @@ AP4_OmaDcfTrackEncrypter::GetProcessedSampleSize(AP4_Sample& sample)
/*----------------------------------------------------------------------
| AP4_OmaDcfTrackEncrypter::ProcessTrack
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfTrackEncrypter::ProcessTrack()
{
// sinf container
@@ -959,20 +905,20 @@ AP4_OmaDcfTrackEncrypter::ProcessTrack()
// original format
AP4_FrmaAtom* frma = new AP4_FrmaAtom(m_SampleEntry->GetType());
-
+
// scheme info
AP4_ContainerAtom* schi = new AP4_ContainerAtom(AP4_ATOM_TYPE_SCHI);
AP4_OdafAtom* odaf = new AP4_OdafAtom(true, 0, AP4_CIPHER_BLOCK_SIZE);
AP4_OhdrAtom* ohdr = new AP4_OhdrAtom(m_CipherMode,
- m_CipherPadding,
- 0,
- m_ContentId.GetChars(),
- m_RightsIssuerUrl.GetChars(),
- m_TextualHeaders.GetData(),
- m_TextualHeaders.GetDataSize());
+ m_CipherPadding,
+ 0,
+ m_ContentId.GetChars(),
+ m_RightsIssuerUrl.GetChars(),
+ m_TextualHeaders.GetData(),
+ m_TextualHeaders.GetDataSize());
AP4_ContainerAtom* odkm = new AP4_ContainerAtom(AP4_ATOM_TYPE_ODKM, (AP4_UI32)0, (AP4_UI32)0);
- AP4_SchmAtom* schm = new AP4_SchmAtom(AP4_PROTECTION_SCHEME_TYPE_OMA,
- AP4_PROTECTION_SCHEME_VERSION_OMA_20);
+ AP4_SchmAtom* schm = new AP4_SchmAtom(AP4_PROTECTION_SCHEME_TYPE_OMA,
+ AP4_PROTECTION_SCHEME_VERSION_OMA_20);
odkm->AddChild(odaf);
odkm->AddChild(ohdr);
@@ -989,24 +935,24 @@ AP4_OmaDcfTrackEncrypter::ProcessTrack()
// change the atom type of the sample description
m_SampleEntry->SetType(m_Format);
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_OmaDcfTrackEncrypter::ProcessSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfTrackEncrypter::ProcessSample(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out)
{
- AP4_Result result = m_Cipher->EncryptSampleData(data_in,
- data_out,
- m_Counter,
- false);
- if(AP4_FAILED(result)) return result;
+ AP4_Result result = m_Cipher->EncryptSampleData(data_in,
+ data_out,
+ m_Counter,
+ false);
+ if (AP4_FAILED(result)) return result;
- m_Counter += (data_in.GetDataSize() + AP4_CIPHER_BLOCK_SIZE - 1) / AP4_CIPHER_BLOCK_SIZE;
+ m_Counter += (data_in.GetDataSize()+AP4_CIPHER_BLOCK_SIZE-1)/AP4_CIPHER_BLOCK_SIZE;
return AP4_SUCCESS;
}
@@ -1017,18 +963,14 @@ AP4_OmaDcfDecryptingProcessor::AP4_OmaDcfDecryptingProcessor(
const AP4_ProtectionKeyMap* key_map /* = NULL */,
AP4_BlockCipherFactory* block_cipher_factory /* = NULL */)
{
- if(key_map)
- {
+ if (key_map) {
// copy the keys
m_KeyMap.SetKeys(*key_map);
}
-
- if(block_cipher_factory == NULL)
- {
+
+ if (block_cipher_factory == NULL) {
m_BlockCipherFactory = &AP4_DefaultBlockCipherFactory::Instance;
- }
- else
- {
+ } else {
m_BlockCipherFactory = block_cipher_factory;
}
}
@@ -1036,26 +978,20 @@ AP4_OmaDcfDecryptingProcessor::AP4_OmaDcfDecryptingProcessor(
/*----------------------------------------------------------------------
| AP4_OmaDcfDecryptingProcessor:Initialize
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_OmaDcfDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
- AP4_ByteStream& /* stream */,
- ProgressListener* listener)
+AP4_Result
+AP4_OmaDcfDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
+ AP4_ByteStream& /* stream */,
+ ProgressListener* listener)
{
// decide which processor to instantiate based on the file type
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
- if(ftyp)
- {
- if(ftyp->GetMajorBrand() == AP4_OMA_DCF_BRAND_ODCF || ftyp->HasCompatibleBrand(AP4_OMA_DCF_BRAND_ODCF))
- {
+ if (ftyp) {
+ if (ftyp->GetMajorBrand() == AP4_OMA_DCF_BRAND_ODCF || ftyp->HasCompatibleBrand(AP4_OMA_DCF_BRAND_ODCF)) {
return AP4_OmaDcfAtomDecrypter::DecryptAtoms(top_level, listener, m_BlockCipherFactory, m_KeyMap);
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_FORMAT;
}
- }
- else
- {
+ } else {
return AP4_SUCCESS;
}
}
@@ -1064,15 +1000,12 @@ AP4_OmaDcfDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
| AP4_OmaDcfEncryptingProcessor:AP4_OmaDcfEncryptingProcessor
+---------------------------------------------------------------------*/
AP4_OmaDcfEncryptingProcessor::AP4_OmaDcfEncryptingProcessor(AP4_OmaDcfCipherMode cipher_mode,
- AP4_BlockCipherFactory* block_cipher_factory) :
+ AP4_BlockCipherFactory* block_cipher_factory) :
m_CipherMode(cipher_mode)
{
- if(block_cipher_factory == NULL)
- {
+ if (block_cipher_factory == NULL) {
m_BlockCipherFactory = &AP4_DefaultBlockCipherFactory::Instance;
- }
- else
- {
+ } else {
m_BlockCipherFactory = block_cipher_factory;
}
}
@@ -1080,45 +1013,40 @@ AP4_OmaDcfEncryptingProcessor::AP4_OmaDcfEncryptingProcessor(AP4_OmaDcfCipherMod
/*----------------------------------------------------------------------
| AP4_OmaDcfEncryptingProcessor::Initialize
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_OmaDcfEncryptingProcessor::Initialize(AP4_AtomParent& top_level,
- AP4_ByteStream& /*stream*/,
- AP4_Processor::ProgressListener* /*listener*/)
+ AP4_ByteStream& /*stream*/,
+ AP4_Processor::ProgressListener* /*listener*/)
{
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
- if(ftyp)
- {
+ if (ftyp) {
// remove the atom, it will be replaced with a new one
top_level.RemoveChild(ftyp);
-
+
// keep the existing brand and compatible brands
AP4_Array<AP4_UI32> compatible_brands;
- compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount() + 1);
- for(unsigned int i = 0; i < ftyp->GetCompatibleBrands().ItemCount(); i++)
- {
+ compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount()+1);
+ for (unsigned int i=0; i<ftyp->GetCompatibleBrands().ItemCount(); i++) {
compatible_brands.Append(ftyp->GetCompatibleBrands()[i]);
}
-
+
// add the OMA compatible brand if it is not already there
- if(!ftyp->HasCompatibleBrand(AP4_OMA_DCF_BRAND_OPF2))
- {
+ if (!ftyp->HasCompatibleBrand(AP4_OMA_DCF_BRAND_OPF2)) {
compatible_brands.Append(AP4_OMA_DCF_BRAND_OPF2);
}
// create a replacement
AP4_FtypAtom* new_ftyp = new AP4_FtypAtom(ftyp->GetMajorBrand(),
- ftyp->GetMinorVersion(),
- &compatible_brands[0],
- compatible_brands.ItemCount());
+ ftyp->GetMinorVersion(),
+ &compatible_brands[0],
+ compatible_brands.ItemCount());
delete ftyp;
ftyp = new_ftyp;
- }
- else
- {
+ } else {
AP4_UI32 opf2 = AP4_OMA_DCF_BRAND_OPF2;
ftyp = new AP4_FtypAtom(AP4_FTYP_BRAND_ISOM, 0, &opf2, 1);
}
-
+
// insert the ftyp atom as the first child
return top_level.AddChild(ftyp, 0);
}
@@ -1126,79 +1054,73 @@ AP4_OmaDcfEncryptingProcessor::Initialize(AP4_AtomParent& top_l
/*----------------------------------------------------------------------
| AP4_OmaDcfEncryptingProcessor:CreateTrackHandler
+---------------------------------------------------------------------*/
-AP4_Processor::TrackHandler*
+AP4_Processor::TrackHandler*
AP4_OmaDcfEncryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
{
// find the stsd atom
AP4_StsdAtom* stsd = AP4_DYNAMIC_CAST(AP4_StsdAtom, trak->FindChild("mdia/minf/stbl/stsd"));
// avoid tracks with no stsd atom (should not happen)
- if(stsd == NULL) return NULL;
+ if (stsd == NULL) return NULL;
// only look at the first sample description
AP4_SampleEntry* entry = stsd->GetSampleEntry(0);
- if(entry == NULL) return NULL;
-
+ if (entry == NULL) return NULL;
+
// create a handler for this track if we have a key for it and we know
// how to map the type
const AP4_UI08* key;
const AP4_UI08* iv;
AP4_UI32 format = 0;
- if(AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, iv)))
- {
- switch(entry->GetType())
- {
- case AP4_ATOM_TYPE_MP4A:
- format = AP4_ATOM_TYPE_ENCA;
- break;
-
- case AP4_ATOM_TYPE_MP4V:
- case AP4_ATOM_TYPE_AVC1:
- format = AP4_ATOM_TYPE_ENCV;
- break;
-
- default:
- {
- // try to find if this is audio or video
- AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, trak->FindChild("mdia/hdlr"));
- if(hdlr)
- {
- switch(hdlr->GetHandlerType())
- {
- case AP4_HANDLER_TYPE_SOUN:
- format = AP4_ATOM_TYPE_ENCA;
- break;
-
- case AP4_HANDLER_TYPE_VIDE:
- format = AP4_ATOM_TYPE_ENCV;
- break;
+ if (AP4_SUCCEEDED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, iv))) {
+ switch (entry->GetType()) {
+ case AP4_ATOM_TYPE_MP4A:
+ format = AP4_ATOM_TYPE_ENCA;
+ break;
+
+ case AP4_ATOM_TYPE_MP4V:
+ case AP4_ATOM_TYPE_AVC1:
+ format = AP4_ATOM_TYPE_ENCV;
+ break;
+
+ default: {
+ // try to find if this is audio or video
+ AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, trak->FindChild("mdia/hdlr"));
+ if (hdlr) {
+ switch (hdlr->GetHandlerType()) {
+ case AP4_HANDLER_TYPE_SOUN:
+ format = AP4_ATOM_TYPE_ENCA;
+ break;
+
+ case AP4_HANDLER_TYPE_VIDE:
+ format = AP4_ATOM_TYPE_ENCV;
+ break;
+ }
}
+ break;
}
- break;
}
- }
- if(format)
- {
+ if (format) {
const char* content_id = m_PropertyMap.GetProperty(trak->GetId(), "ContentId");
const char* rights_issuer_url = m_PropertyMap.GetProperty(trak->GetId(), "RightsIssuerUrl");
AP4_DataBuffer textual_headers;
AP4_Result result = m_PropertyMap.GetTextualHeaders(trak->GetId(), textual_headers);
- if(AP4_FAILED(result)) textual_headers.SetDataSize(0);
-
+ if (AP4_FAILED(result)) textual_headers.SetDataSize(0);
+
// create the block cipher
AP4_BlockCipher* block_cipher = NULL;
- result = m_BlockCipherFactory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::ENCRYPT,
- key,
- AP4_CIPHER_BLOCK_SIZE,
+ result = m_BlockCipherFactory->Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::ENCRYPT,
+ key,
+ AP4_CIPHER_BLOCK_SIZE,
block_cipher);
- if(AP4_FAILED(result)) return NULL;
- return new AP4_OmaDcfTrackEncrypter(m_CipherMode,
- block_cipher,
- iv,
- entry,
- format,
- content_id,
+ if (AP4_FAILED(result)) return NULL;
+ return new AP4_OmaDcfTrackEncrypter(m_CipherMode,
+ block_cipher,
+ iv,
+ entry,
+ format,
+ content_id,
rights_issuer_url,
textual_headers.GetData(),
textual_headers.GetDataSize());
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.h
index 038296c5c..806f6f0db 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4OmaDcf.h
@@ -51,13 +51,12 @@ class AP4_CtrStreamCipher;
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_OMA = AP4_ATOM_TYPE('o', 'd', 'k', 'm');
+const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_OMA = AP4_ATOM_TYPE('o','d','k','m');
const AP4_UI32 AP4_PROTECTION_SCHEME_VERSION_OMA_20 = 0x00000200;
-const AP4_UI32 AP4_OMA_DCF_BRAND_ODCF = AP4_ATOM_TYPE('o', 'd', 'c', 'f');
-const AP4_UI32 AP4_OMA_DCF_BRAND_OPF2 = AP4_ATOM_TYPE('o', 'p', 'f', '2');
+const AP4_UI32 AP4_OMA_DCF_BRAND_ODCF = AP4_ATOM_TYPE('o','d','c','f');
+const AP4_UI32 AP4_OMA_DCF_BRAND_OPF2 = AP4_ATOM_TYPE('o','p','f','2');
-typedef enum
-{
+typedef enum {
AP4_OMA_DCF_CIPHER_MODE_CTR,
AP4_OMA_DCF_CIPHER_MODE_CBC
} AP4_OmaDcfCipherMode;
@@ -65,11 +64,10 @@ typedef enum
/*----------------------------------------------------------------------
| AP4_OmaDcfAtomDecrypter
+---------------------------------------------------------------------*/
-class AP4_OmaDcfAtomDecrypter
-{
+class AP4_OmaDcfAtomDecrypter {
public:
// class methods
- static AP4_Result DecryptAtoms(AP4_AtomParent& atoms,
+ static AP4_Result DecryptAtoms(AP4_AtomParent& atoms,
AP4_Processor::ProgressListener* listener,
AP4_BlockCipherFactory* block_cipher_factory,
AP4_ProtectionKeyMap& key_map);
@@ -77,22 +75,22 @@ public:
// Returns a byte stream that will produce the decrypted data found
// in the 'odda' child atom of an 'odrm' atom
static AP4_Result CreateDecryptingStream(AP4_ContainerAtom& odrm_atom,
- const AP4_UI08* key,
- AP4_Size key_size,
- AP4_BlockCipherFactory* block_cipher_factory,
- AP4_ByteStream*& stream);
+ const AP4_UI08* key,
+ AP4_Size key_size,
+ AP4_BlockCipherFactory* block_cipher_factory,
+ AP4_ByteStream*& stream);
// Returns a byte stream that will produce the decrypted data from
// an encrypted stream where the IV follows the encrypted bytes.
- // This method is normally not called directly: most callers will call
+ // This method is normally not called directly: most callers will call
// the stream factory that takes an 'odrm' atom as an input parameter
static AP4_Result CreateDecryptingStream(AP4_OmaDcfCipherMode mode,
- AP4_ByteStream& encrypted_stream,
- AP4_LargeSize cleartext_size,
- const AP4_UI08* key,
- AP4_Size key_size,
- AP4_BlockCipherFactory* block_cipher_factory,
- AP4_ByteStream*& stream);
+ AP4_ByteStream& encrypted_stream,
+ AP4_LargeSize cleartext_size,
+ const AP4_UI08* key,
+ AP4_Size key_size,
+ AP4_BlockCipherFactory* block_cipher_factory,
+ AP4_ByteStream*& stream);
};
/*----------------------------------------------------------------------
@@ -102,8 +100,8 @@ class AP4_OmaDcfSampleDecrypter : public AP4_SampleDecrypter
{
public:
// factory
- static AP4_Result Create(AP4_ProtectedSampleDescription* sample_description,
- const AP4_UI08* key,
+ static AP4_Result Create(AP4_ProtectedSampleDescription* sample_description,
+ const AP4_UI08* key,
AP4_Size key_size,
AP4_BlockCipherFactory* block_cipher_factory,
AP4_OmaDcfSampleDecrypter*& cipher);
@@ -168,8 +166,7 @@ private:
/*----------------------------------------------------------------------
| AP4_OmaDcfTrackDecrypter
+---------------------------------------------------------------------*/
-class AP4_OmaDcfTrackDecrypter : public AP4_Processor::TrackHandler
-{
+class AP4_OmaDcfTrackDecrypter : public AP4_Processor::TrackHandler {
public:
// constructor
static AP4_Result Create(const AP4_UI08* key,
@@ -265,12 +262,12 @@ private:
// members
AP4_CbcStreamCipher* m_Cipher;
};
-
+
/*----------------------------------------------------------------------
| AP4_OmaDcfDecryptingProcessor
+---------------------------------------------------------------------*/
/**
- * Use for DCF only, not PDCF. For PDCF, use the
+ * Use for DCF only, not PDCF. For PDCF, use the
* AP4_StandardDecryptingProcessor class
*/
class AP4_OmaDcfDecryptingProcessor : public AP4_Processor
@@ -281,10 +278,7 @@ public:
AP4_BlockCipherFactory* block_cipher_factory = NULL);
// accessors
- AP4_ProtectionKeyMap& GetKeyMap()
- {
- return m_KeyMap;
- }
+ AP4_ProtectionKeyMap& GetKeyMap() { return m_KeyMap; }
// methods
virtual AP4_Result Initialize(AP4_AtomParent& top_level,
@@ -308,14 +302,8 @@ public:
AP4_BlockCipherFactory* block_cipher_factory = NULL);
// accessors
- AP4_ProtectionKeyMap& GetKeyMap()
- {
- return m_KeyMap;
- }
- AP4_TrackPropertyMap& GetPropertyMap()
- {
- return m_PropertyMap;
- }
+ AP4_ProtectionKeyMap& GetKeyMap() { return m_KeyMap; }
+ AP4_TrackPropertyMap& GetPropertyMap() { return m_PropertyMap; }
// AP4_Processor methods
virtual AP4_Result Initialize(AP4_AtomParent& top_level,
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.cpp
index a400b4073..f442658ff 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.cpp
@@ -49,12 +49,10 @@
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-AP4_UI08 const AP4_UUID_PIFF_TRACK_ENCRYPTION_ATOM[16] =
-{
+AP4_UI08 const AP4_UUID_PIFF_TRACK_ENCRYPTION_ATOM[16] = {
0x89, 0x74, 0xdb, 0xce, 0x7b, 0xe7, 0x4c, 0x51, 0x84, 0xf9, 0x71, 0x48, 0xf9, 0x88, 0x25, 0x54
};
-AP4_UI08 const AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM[16] =
-{
+AP4_UI08 const AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM[16] = {
0xA2, 0x39, 0x4F, 0x52, 0x5A, 0x9B, 0x4f, 0x14, 0xA2, 0x44, 0x6C, 0x42, 0x7C, 0x64, 0x8D, 0xF4
};
@@ -69,9 +67,9 @@ AP4_PiffCtrSampleEncrypter::AP4_PiffCtrSampleEncrypter(AP4_BlockCipher* block_ci
/*----------------------------------------------------------------------
| AP4_PiffCtrSampleEncrypter::EncryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffCtrSampleEncrypter::EncryptSampleData(AP4_DataBuffer& /*data_in */,
- AP4_DataBuffer& /*data_out*/)
+ AP4_DataBuffer& /*data_out*/)
{
return AP4_ERROR_NOT_SUPPORTED; // FIXME: not implemented yet
}
@@ -87,9 +85,9 @@ AP4_PiffCtrSampleEncrypter::~AP4_PiffCtrSampleEncrypter()
/*----------------------------------------------------------------------
| AP4_PiffAvcCtrSampleEncrypter::EncryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffAvcCtrSampleEncrypter::EncryptSampleData(AP4_DataBuffer& /*data_in */,
- AP4_DataBuffer& /*data_out*/)
+ AP4_DataBuffer& /*data_out*/)
{
return AP4_ERROR_NOT_SUPPORTED; // FIXME: not implemented yet
}
@@ -105,9 +103,9 @@ AP4_PiffCbcSampleEncrypter::AP4_PiffCbcSampleEncrypter(AP4_BlockCipher* block_ci
/*----------------------------------------------------------------------
| AP4_PiffCbcSampleEncrypter::EncryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffCbcSampleEncrypter::EncryptSampleData(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out)
+ AP4_DataBuffer& data_out)
{
// the output has the same size as the input
data_out.SetDataSize(data_in.GetDataSize());
@@ -115,28 +113,26 @@ AP4_PiffCbcSampleEncrypter::EncryptSampleData(AP4_DataBuffer& data_in,
// setup direct pointers to the buffers
const AP4_UI08* in = data_in.GetData();
AP4_UI08* out = data_out.UseData();
-
+
// setup the IV
m_Cipher->SetIV(m_Iv);
// process the sample data
- unsigned int block_count = data_in.GetDataSize() / 16;
- if(block_count)
- {
+ unsigned int block_count = data_in.GetDataSize()/16;
+ if (block_count) {
AP4_Size out_size = data_out.GetDataSize();
- AP4_Result result = m_Cipher->ProcessBuffer(in, block_count * 16, out, &out_size, false);
- if(AP4_FAILED(result)) return result;
- in += block_count * 16;
- out += block_count * 16;
-
+ AP4_Result result = m_Cipher->ProcessBuffer(in, block_count*16, out, &out_size, false);
+ if (AP4_FAILED(result)) return result;
+ in += block_count*16;
+ out += block_count*16;
+
// update the IV (last cipherblock emitted)
- AP4_CopyMemory(m_Iv, out - 16, 16);
+ AP4_CopyMemory(m_Iv, out-16, 16);
}
-
+
// any partial block at the end remains in the clear
- unsigned int partial = data_in.GetDataSize() % 16;
- if(partial)
- {
+ unsigned int partial = data_in.GetDataSize()%16;
+ if (partial) {
AP4_CopyMemory(out, in, partial);
}
return AP4_SUCCESS;
@@ -153,66 +149,62 @@ AP4_PiffCbcSampleEncrypter::~AP4_PiffCbcSampleEncrypter()
/*----------------------------------------------------------------------
| AP4_PiffAvcCbcSampleEncrypter::EncryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffAvcCbcSampleEncrypter::EncryptSampleData(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out)
-{
+ AP4_DataBuffer& data_out)
+{
// the output has the same size as the input
data_out.SetDataSize(data_in.GetDataSize());
// check some basics
- if(data_in.GetDataSize() == 0) return AP4_SUCCESS;
+ if (data_in.GetDataSize() == 0) return AP4_SUCCESS;
// setup direct pointers to the buffers
const AP4_UI08* in = data_in.GetData();
AP4_UI08* out = data_out.UseData();
-
+
// setup the IV
m_Cipher->SetIV(m_Iv);
// process the sample data, one NALU at a time
- const AP4_UI08* in_end = data_in.GetData() + data_in.GetDataSize();
- while((AP4_Size)(in_end - in) > 1 + m_NaluLengthSize)
- {
+ const AP4_UI08* in_end = data_in.GetData()+data_in.GetDataSize();
+ while ((AP4_Size)(in_end-in) > 1+m_NaluLengthSize) {
unsigned int nalu_length;
- switch(m_NaluLengthSize)
- {
- case 1:
- nalu_length = *in;
- break;
-
- case 2:
- nalu_length = AP4_BytesToUInt16BE(in);
- break;
-
- case 4:
- nalu_length = AP4_BytesToUInt32BE(in);
- break;
-
- default:
- return AP4_ERROR_INVALID_FORMAT;
+ switch (m_NaluLengthSize) {
+ case 1:
+ nalu_length = *in;
+ break;
+
+ case 2:
+ nalu_length = AP4_BytesToUInt16BE(in);
+ break;
+
+ case 4:
+ nalu_length = AP4_BytesToUInt32BE(in);
+ break;
+
+ default:
+ return AP4_ERROR_INVALID_FORMAT;
}
- unsigned int chunk_size = m_NaluLengthSize + nalu_length;
- unsigned int cleartext_size = chunk_size % 16;
- unsigned int block_count = chunk_size / 16;
- if(cleartext_size < m_NaluLengthSize + 1)
- {
+ unsigned int chunk_size = m_NaluLengthSize+nalu_length;
+ unsigned int cleartext_size = chunk_size%16;
+ unsigned int block_count = chunk_size/16;
+ if (cleartext_size < m_NaluLengthSize+1) {
AP4_ASSERT(block_count);
--block_count;
cleartext_size += 16;
}
-
+
// copy the cleartext portion
AP4_CopyMemory(out, in, cleartext_size);
-
+
// encrypt the rest
- if(block_count)
- {
- AP4_Size out_size = block_count * 16;
- m_Cipher->ProcessBuffer(in + cleartext_size, block_count * 16, out + cleartext_size, &out_size, false);
+ if (block_count) {
+ AP4_Size out_size = block_count*16;
+ m_Cipher->ProcessBuffer(in+cleartext_size, block_count*16, out+cleartext_size, &out_size, false);
}
-
+
// move the pointers
in += chunk_size;
out += chunk_size;
@@ -223,8 +215,7 @@ AP4_PiffAvcCbcSampleEncrypter::EncryptSampleData(AP4_DataBuffer& data_in,
/*----------------------------------------------------------------------
| AP4_PiffTrackEncrypter
+---------------------------------------------------------------------*/
-class AP4_PiffTrackEncrypter : public AP4_Processor::TrackHandler
-{
+class AP4_PiffTrackEncrypter : public AP4_Processor::TrackHandler {
public:
// constructor
AP4_PiffTrackEncrypter(AP4_UI32 default_algorithm_id,
@@ -268,7 +259,7 @@ AP4_PiffTrackEncrypter::AP4_PiffTrackEncrypter(
/*----------------------------------------------------------------------
| AP4_PiffTrackEncrypter::ProcessTrack
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffTrackEncrypter::ProcessTrack()
{
// sinf container
@@ -276,17 +267,17 @@ AP4_PiffTrackEncrypter::ProcessTrack()
// original format
AP4_FrmaAtom* frma = new AP4_FrmaAtom(m_SampleEntry->GetType());
-
+
// scheme info
AP4_ContainerAtom* schi = new AP4_ContainerAtom(AP4_ATOM_TYPE_SCHI);
- AP4_SchmAtom* schm = new AP4_SchmAtom(AP4_PROTECTION_SCHEME_TYPE_PIFF,
- AP4_PROTECTION_SCHEME_VERSION_PIFF_10);
- AP4_PiffTrackEncryptionAtom* piff_enc =
- new AP4_PiffTrackEncryptionAtom(m_DefaultAlgorithmId,
- m_DefaultIvSize,
+ AP4_SchmAtom* schm = new AP4_SchmAtom(AP4_PROTECTION_SCHEME_TYPE_PIFF,
+ AP4_PROTECTION_SCHEME_VERSION_PIFF_10);
+ AP4_PiffTrackEncryptionAtom* piff_enc =
+ new AP4_PiffTrackEncryptionAtom(m_DefaultAlgorithmId,
+ m_DefaultIvSize,
m_DefaultKid);
schi->AddChild(piff_enc);
-
+
// populate the sinf container
sinf->AddChild(frma);
sinf->AddChild(schm);
@@ -297,14 +288,14 @@ AP4_PiffTrackEncrypter::ProcessTrack()
// change the atom type of the sample description
m_SampleEntry->SetType(m_Format);
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_PiffTrackEncrypter::ProcessSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffTrackEncrypter::ProcessSample(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out)
{
@@ -314,8 +305,7 @@ AP4_PiffTrackEncrypter::ProcessSample(AP4_DataBuffer& data_in,
/*----------------------------------------------------------------------
| AP4_PiffFragmentEncrypter
+---------------------------------------------------------------------*/
-class AP4_PiffFragmentEncrypter : public AP4_Processor::FragmentHandler
-{
+class AP4_PiffFragmentEncrypter : public AP4_Processor::FragmentHandler {
public:
// constructor
AP4_PiffFragmentEncrypter(AP4_ContainerAtom* traf,
@@ -339,7 +329,7 @@ private:
| AP4_PiffFragmentEncrypter::AP4_PiffFragmentEncrypter
+---------------------------------------------------------------------*/
AP4_PiffFragmentEncrypter::AP4_PiffFragmentEncrypter(AP4_ContainerAtom* traf,
- AP4_PiffEncryptingProcessor::Encrypter* encrypter) :
+ AP4_PiffEncryptingProcessor::Encrypter* encrypter) :
m_Traf(traf),
m_SampleEncryptionAtom(NULL),
m_Encrypter(encrypter),
@@ -350,39 +340,36 @@ AP4_PiffFragmentEncrypter::AP4_PiffFragmentEncrypter(AP4_ContainerAtom*
/*----------------------------------------------------------------------
| AP4_PiffFragmentEncrypter::ProcessFragment
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffFragmentEncrypter::ProcessFragment()
{
// count the number of samples and create IVs
unsigned int sample_count = 0;
- for(AP4_List<AP4_Atom>::Item* item = m_Traf->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
+ for (AP4_List<AP4_Atom>::Item* item = m_Traf->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* child = item->GetData();
- if(child->GetType() == AP4_ATOM_TYPE_TRUN)
- {
+ if (child->GetType() == AP4_ATOM_TYPE_TRUN) {
AP4_TrunAtom* trun = AP4_DYNAMIC_CAST(AP4_TrunAtom, child);
- if(trun)
- {
+ if (trun) {
sample_count += trun->GetEntries().ItemCount();
}
}
}
-
+
// create a sample encryption atom
m_SampleEncryptionAtom = new AP4_PiffSampleEncryptionAtom(sample_count);
// add the atom to the traf container
m_Traf->AddChild(m_SampleEncryptionAtom);
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_PiffFragmentEncrypter::FinishFragment
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffFragmentEncrypter::FinishFragment()
{
return AP4_SUCCESS;
@@ -391,13 +378,13 @@ AP4_PiffFragmentEncrypter::FinishFragment()
/*----------------------------------------------------------------------
| AP4_PiffFragmentEncrypter::ProcessSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffFragmentEncrypter::ProcessSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out)
+ AP4_DataBuffer& data_out)
{
// store the IV for this sample
m_SampleEncryptionAtom->SetIv(m_IvIndex++, m_Encrypter->m_SampleEncrypter->GetIv());
-
+
// encrypt the sample
AP4_Result result = m_Encrypter->m_SampleEncrypter->EncryptSampleData(data_in, data_out);
return result;
@@ -407,16 +394,13 @@ AP4_PiffFragmentEncrypter::ProcessSample(AP4_DataBuffer& data_in,
| AP4_PiffEncryptingProcessor:AP4_PiffEncryptingProcessor
+---------------------------------------------------------------------*/
AP4_PiffEncryptingProcessor::AP4_PiffEncryptingProcessor(AP4_PiffCipherMode cipher_mode,
- AP4_BlockCipherFactory* block_cipher_factory) :
+ AP4_BlockCipherFactory* block_cipher_factory) :
m_CipherMode(cipher_mode)
{
// create a block cipher factory if none is given
- if(block_cipher_factory == NULL)
- {
+ if (block_cipher_factory == NULL) {
m_BlockCipherFactory = &AP4_DefaultBlockCipherFactory::Instance;
- }
- else
- {
+ } else {
m_BlockCipherFactory = block_cipher_factory;
}
}
@@ -432,45 +416,40 @@ AP4_PiffEncryptingProcessor::~AP4_PiffEncryptingProcessor()
/*----------------------------------------------------------------------
| AP4_PiffEncryptingProcessor::Initialize
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffEncryptingProcessor::Initialize(AP4_AtomParent& top_level,
AP4_ByteStream& /*stream*/,
AP4_Processor::ProgressListener* /*listener*/)
{
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
- if(ftyp)
- {
+ if (ftyp) {
// remove the atom, it will be replaced with a new one
top_level.RemoveChild(ftyp);
-
+
// keep the existing brand and compatible brands
AP4_Array<AP4_UI32> compatible_brands;
- compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount() + 1);
- for(unsigned int i = 0; i < ftyp->GetCompatibleBrands().ItemCount(); i++)
- {
+ compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount()+1);
+ for (unsigned int i=0; i<ftyp->GetCompatibleBrands().ItemCount(); i++) {
compatible_brands.Append(ftyp->GetCompatibleBrands()[i]);
}
-
+
// add the OMA compatible brand if it is not already there
- if(!ftyp->HasCompatibleBrand(AP4_PIFF_BRAND))
- {
+ if (!ftyp->HasCompatibleBrand(AP4_PIFF_BRAND)) {
compatible_brands.Append(AP4_PIFF_BRAND);
}
// create a replacement
AP4_FtypAtom* new_ftyp = new AP4_FtypAtom(ftyp->GetMajorBrand(),
- ftyp->GetMinorVersion(),
- &compatible_brands[0],
- compatible_brands.ItemCount());
+ ftyp->GetMinorVersion(),
+ &compatible_brands[0],
+ compatible_brands.ItemCount());
delete ftyp;
ftyp = new_ftyp;
- }
- else
- {
+ } else {
AP4_UI32 piff = AP4_PIFF_BRAND;
ftyp = new AP4_FtypAtom(AP4_FTYP_BRAND_ISOM, 0, &piff, 1);
}
-
+
// insert the ftyp atom as the first child
return top_level.AddChild(ftyp, 0);
}
@@ -478,116 +457,103 @@ AP4_PiffEncryptingProcessor::Initialize(AP4_AtomParent& top_lev
/*----------------------------------------------------------------------
| AP4_PiffEncryptingProcessor:CreateTrackHandler
+---------------------------------------------------------------------*/
-AP4_Processor::TrackHandler*
+AP4_Processor::TrackHandler*
AP4_PiffEncryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
{
// find the stsd atom
AP4_StsdAtom* stsd = AP4_DYNAMIC_CAST(AP4_StsdAtom, trak->FindChild("mdia/minf/stbl/stsd"));
// avoid tracks with no stsd atom (should not happen)
- if(stsd == NULL) return NULL;
+ if (stsd == NULL) return NULL;
// only look at the first sample description
AP4_SampleEntry* entry = stsd->GetSampleEntry(0);
- if(entry == NULL) return NULL;
-
+ if (entry == NULL) return NULL;
+
// create a handler for this track if we have a key for it and we know
// how to map the type
const AP4_UI08* key;
const AP4_UI08* iv;
- if(AP4_FAILED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, iv)))
- {
+ if (AP4_FAILED(m_KeyMap.GetKeyAndIv(trak->GetId(), key, iv))) {
return NULL;
}
-
+
AP4_UI32 format = 0;
- switch(entry->GetType())
- {
- case AP4_ATOM_TYPE_MP4A:
- format = AP4_ATOM_TYPE_ENCA;
- break;
-
- case AP4_ATOM_TYPE_MP4V:
- case AP4_ATOM_TYPE_AVC1:
- format = AP4_ATOM_TYPE_ENCV;
- break;
-
- default:
- {
- // try to find if this is audio or video
- AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, trak->FindChild("mdia/hdlr"));
- if(hdlr)
- {
- switch(hdlr->GetHandlerType())
- {
- case AP4_HANDLER_TYPE_SOUN:
- format = AP4_ATOM_TYPE_ENCA;
- break;
+ switch (entry->GetType()) {
+ case AP4_ATOM_TYPE_MP4A:
+ format = AP4_ATOM_TYPE_ENCA;
+ break;
- case AP4_HANDLER_TYPE_VIDE:
- format = AP4_ATOM_TYPE_ENCV;
- break;
+ case AP4_ATOM_TYPE_MP4V:
+ case AP4_ATOM_TYPE_AVC1:
+ format = AP4_ATOM_TYPE_ENCV;
+ break;
+
+ default: {
+ // try to find if this is audio or video
+ AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, trak->FindChild("mdia/hdlr"));
+ if (hdlr) {
+ switch (hdlr->GetHandlerType()) {
+ case AP4_HANDLER_TYPE_SOUN:
+ format = AP4_ATOM_TYPE_ENCA;
+ break;
+
+ case AP4_HANDLER_TYPE_VIDE:
+ format = AP4_ATOM_TYPE_ENCV;
+ break;
+ }
}
+ break;
}
- break;
}
- }
- if(format == 0) return NULL;
-
+ if (format == 0) return NULL;
+
// get the track properties
- AP4_UI08 kid[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ AP4_UI08 kid[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
const char* kid_hex = m_PropertyMap.GetProperty(trak->GetId(), "KID");
- if(kid_hex && AP4_StringLength(kid_hex) == 32)
- {
+ if (kid_hex && AP4_StringLength(kid_hex) == 32) {
AP4_ParseHex(kid_hex, kid, 16);
}
-
+
// create the encrypter
AP4_Processor::TrackHandler* track_encrypter;
- track_encrypter = new AP4_PiffTrackEncrypter(m_CipherMode == AP4_PIFF_CIPHER_MODE_CBC ? AP4_PIFF_ALGORITHM_ID_CBC : AP4_PIFF_ALGORITHM_ID_CTR,
- 16,
- kid,
- entry,
- format);
-
+ track_encrypter = new AP4_PiffTrackEncrypter(m_CipherMode == AP4_PIFF_CIPHER_MODE_CBC?AP4_PIFF_ALGORITHM_ID_CBC:AP4_PIFF_ALGORITHM_ID_CTR,
+ 16,
+ kid,
+ entry,
+ format);
+
// create a block cipher
AP4_BlockCipher* block_cipher = NULL;
- AP4_Result result = m_BlockCipherFactory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::ENCRYPT,
- key,
- 16,
- block_cipher);
- if(AP4_FAILED(result)) return NULL;
-
+ AP4_Result result = m_BlockCipherFactory->Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::ENCRYPT,
+ key,
+ 16,
+ block_cipher);
+ if (AP4_FAILED(result)) return NULL;
+
// add a new cipher state for this track
AP4_PiffSampleEncrypter* sample_encrypter = NULL;
- switch(m_CipherMode)
- {
- case AP4_PIFF_CIPHER_MODE_CBC:
- if(entry->GetType() == AP4_ATOM_TYPE_AVC1)
- {
- AP4_AvccAtom* avcc = AP4_DYNAMIC_CAST(AP4_AvccAtom, entry->GetChild(AP4_ATOM_TYPE_AVCC));
- if(avcc == NULL) return NULL;
- sample_encrypter = new AP4_PiffAvcCbcSampleEncrypter(block_cipher, avcc->GetNaluLengthSize());
- }
- else
- {
- sample_encrypter = new AP4_PiffCbcSampleEncrypter(block_cipher);
- }
- break;
-
- case AP4_PIFF_CIPHER_MODE_CTR:
- if(entry->GetType() == AP4_ATOM_TYPE_AVC1)
- {
- AP4_AvccAtom* avcc = AP4_DYNAMIC_CAST(AP4_AvccAtom, entry->GetChild(AP4_ATOM_TYPE_AVCC));
- if(avcc == NULL) return NULL;
- sample_encrypter = new AP4_PiffAvcCtrSampleEncrypter(block_cipher, avcc->GetNaluLengthSize());
- }
- else
- {
- sample_encrypter = new AP4_PiffCtrSampleEncrypter(block_cipher);
- }
- break;
+ switch (m_CipherMode) {
+ case AP4_PIFF_CIPHER_MODE_CBC:
+ if (entry->GetType() == AP4_ATOM_TYPE_AVC1) {
+ AP4_AvccAtom* avcc = AP4_DYNAMIC_CAST(AP4_AvccAtom, entry->GetChild(AP4_ATOM_TYPE_AVCC));
+ if (avcc == NULL) return NULL;
+ sample_encrypter = new AP4_PiffAvcCbcSampleEncrypter(block_cipher, avcc->GetNaluLengthSize());
+ } else {
+ sample_encrypter = new AP4_PiffCbcSampleEncrypter(block_cipher);
+ }
+ break;
+
+ case AP4_PIFF_CIPHER_MODE_CTR:
+ if (entry->GetType() == AP4_ATOM_TYPE_AVC1) {
+ AP4_AvccAtom* avcc = AP4_DYNAMIC_CAST(AP4_AvccAtom, entry->GetChild(AP4_ATOM_TYPE_AVCC));
+ if (avcc == NULL) return NULL;
+ sample_encrypter = new AP4_PiffAvcCtrSampleEncrypter(block_cipher, avcc->GetNaluLengthSize());
+ } else {
+ sample_encrypter = new AP4_PiffCtrSampleEncrypter(block_cipher);
+ }
+ break;
}
sample_encrypter->SetIv(iv);
m_Encrypters.Add(new Encrypter(trak->GetId(), sample_encrypter));
@@ -598,184 +564,160 @@ AP4_PiffEncryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
/*----------------------------------------------------------------------
| AP4_PiffEncryptingProcessor:CreateFragmentHandler
+---------------------------------------------------------------------*/
-AP4_Processor::FragmentHandler*
+AP4_Processor::FragmentHandler*
AP4_PiffEncryptingProcessor::CreateFragmentHandler(AP4_ContainerAtom* traf)
{
// get the traf header (tfhd) for this track fragment so we can get the track ID
AP4_TfhdAtom* tfhd = AP4_DYNAMIC_CAST(AP4_TfhdAtom, traf->GetChild(AP4_ATOM_TYPE_TFHD));
- if(tfhd == NULL) return NULL;
-
+ if (tfhd == NULL) return NULL;
+
// lookup the encrypter for this track
Encrypter* encrypter = NULL;
- for(AP4_List<Encrypter>::Item* item = m_Encrypters.FirstItem();
- item;
- item = item->GetNext())
- {
- if(item->GetData()->m_TrackId == tfhd->GetTrackId())
- {
+ for (AP4_List<Encrypter>::Item* item = m_Encrypters.FirstItem();
+ item;
+ item = item->GetNext()) {
+ if (item->GetData()->m_TrackId == tfhd->GetTrackId()) {
encrypter = item->GetData();
break;
}
}
- if(encrypter == NULL) return NULL;
+ if (encrypter == NULL) return NULL;
return new AP4_PiffFragmentEncrypter(traf, encrypter);
}
/*----------------------------------------------------------------------
| AP4_PiffSampleDecrypter::Create
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_PiffSampleDecrypter::Create(AP4_ProtectedSampleDescription* sample_description,
+AP4_Result
+AP4_PiffSampleDecrypter::Create(AP4_ProtectedSampleDescription* sample_description,
AP4_ContainerAtom* traf,
- const AP4_UI08* key,
+ const AP4_UI08* key,
AP4_Size key_size,
AP4_BlockCipherFactory* block_cipher_factory,
AP4_PiffSampleDecrypter*& decrypter)
{
// check the parameters
- if(key == NULL || block_cipher_factory == NULL)
- {
+ if (key == NULL || block_cipher_factory == NULL) {
return AP4_ERROR_INVALID_PARAMETERS;
}
// default return value
decrypter = NULL;
-
- // check the sample description
- if(sample_description->GetSchemeType() != AP4_PROTECTION_SCHEME_TYPE_PIFF)
- {
+
+ // check the sample description
+ if (sample_description->GetSchemeType() != AP4_PROTECTION_SCHEME_TYPE_PIFF) {
return AP4_ERROR_INVALID_PARAMETERS;
}
-
+
// get the scheme info atom
AP4_ContainerAtom* schi = sample_description->GetSchemeInfo()->GetSchiAtom();
- if(schi == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (schi == NULL) return AP4_ERROR_INVALID_FORMAT;
// look for a track encryption atom
- AP4_PiffTrackEncryptionAtom* track_encryption_atom =
+ AP4_PiffTrackEncryptionAtom* track_encryption_atom =
AP4_DYNAMIC_CAST(AP4_PiffTrackEncryptionAtom, schi->GetChild(AP4_UUID_PIFF_TRACK_ENCRYPTION_ATOM));
-
+
// look for a sample encryption atom
AP4_PiffSampleEncryptionAtom* sample_encryption_atom = NULL;
- if(traf)
- {
+ if (traf) {
sample_encryption_atom = AP4_DYNAMIC_CAST(AP4_PiffSampleEncryptionAtom, traf->GetChild(AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM));
- if(sample_encryption_atom == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (sample_encryption_atom == NULL) return AP4_ERROR_INVALID_FORMAT;
}
// create the block cipher needed to decrypt the samples
AP4_UI32 algorithm_id;
unsigned int iv_size;
- if(sample_encryption_atom &&
- sample_encryption_atom->GetFlags() & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS)
- {
+ if (sample_encryption_atom &&
+ sample_encryption_atom->GetFlags() & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS) {
algorithm_id = sample_encryption_atom->GetAlgorithmId();
iv_size = sample_encryption_atom->GetIvSize();
- }
- else
- {
- if(track_encryption_atom == NULL) return AP4_ERROR_INVALID_FORMAT;
+ } else {
+ if (track_encryption_atom == NULL) return AP4_ERROR_INVALID_FORMAT;
algorithm_id = track_encryption_atom->GetDefaultAlgorithmId();
iv_size = track_encryption_atom->GetDefaultIvSize();
}
- switch(algorithm_id)
- {
- case AP4_PIFF_ALGORITHM_ID_NONE:
- decrypter = new AP4_PiffNullSampleDecrypter();
- break;
-
- case AP4_PIFF_ALGORITHM_ID_CTR:
- if(iv_size != 8 && iv_size != 16)
- {
- return AP4_ERROR_INVALID_FORMAT;
- }
- else
- {
- // create the block cipher
- AP4_BlockCipher* block_cipher = NULL;
- AP4_Result result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::ENCRYPT,
- key,
- key_size,
- block_cipher);
- if(AP4_FAILED(result)) return result;
-
- // create the decrypter
- if(sample_description->GetOriginalFormat() == AP4_ATOM_TYPE_AVC1)
- {
- AP4_AvcSampleDescription* avc_desc = AP4_DYNAMIC_CAST(AP4_AvcSampleDescription, sample_description->GetOriginalSampleDescription());
- if(avc_desc == NULL)
- {
- return AP4_ERROR_INVALID_FORMAT;
+ switch (algorithm_id) {
+ case AP4_PIFF_ALGORITHM_ID_NONE:
+ decrypter = new AP4_PiffNullSampleDecrypter();
+ break;
+
+ case AP4_PIFF_ALGORITHM_ID_CTR:
+ if (iv_size != 8 && iv_size != 16) {
+ return AP4_ERROR_INVALID_FORMAT;
+ } else {
+ // create the block cipher
+ AP4_BlockCipher* block_cipher = NULL;
+ AP4_Result result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::ENCRYPT,
+ key,
+ key_size,
+ block_cipher);
+ if (AP4_FAILED(result)) return result;
+
+ // create the decrypter
+ if (sample_description->GetOriginalFormat() == AP4_ATOM_TYPE_AVC1) {
+ AP4_AvcSampleDescription* avc_desc = AP4_DYNAMIC_CAST(AP4_AvcSampleDescription, sample_description->GetOriginalSampleDescription());
+ if (avc_desc == NULL) {
+ return AP4_ERROR_INVALID_FORMAT;
+ }
+ decrypter = new AP4_PiffAvcCbcSampleDecrypter(block_cipher,
+ sample_encryption_atom,
+ avc_desc->GetNaluLengthSize());
+
+ } else {
+ decrypter = new AP4_PiffCbcSampleDecrypter(block_cipher,
+ sample_encryption_atom);
}
- decrypter = new AP4_PiffAvcCbcSampleDecrypter(block_cipher,
- sample_encryption_atom,
- avc_desc->GetNaluLengthSize());
-
}
- else
- {
- decrypter = new AP4_PiffCbcSampleDecrypter(block_cipher,
- sample_encryption_atom);
- }
- }
- break;
-
- case AP4_PIFF_ALGORITHM_ID_CBC:
- if(iv_size != 16)
- {
- return AP4_ERROR_INVALID_FORMAT;
- }
- else
- {
- // create the block cipher
- AP4_BlockCipher* block_cipher = NULL;
- AP4_Result result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
- AP4_BlockCipher::DECRYPT,
- key,
- key_size,
- block_cipher);
- if(AP4_FAILED(result)) return result;
-
- // create the decrypter
- if(sample_description->GetOriginalFormat() == AP4_ATOM_TYPE_AVC1)
- {
- AP4_AvcSampleDescription* avc_desc = AP4_DYNAMIC_CAST(AP4_AvcSampleDescription, sample_description->GetOriginalSampleDescription());
- if(avc_desc == NULL)
- {
- return AP4_ERROR_INVALID_FORMAT;
+ break;
+
+ case AP4_PIFF_ALGORITHM_ID_CBC:
+ if (iv_size != 16) {
+ return AP4_ERROR_INVALID_FORMAT;
+ } else {
+ // create the block cipher
+ AP4_BlockCipher* block_cipher = NULL;
+ AP4_Result result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
+ AP4_BlockCipher::DECRYPT,
+ key,
+ key_size,
+ block_cipher);
+ if (AP4_FAILED(result)) return result;
+
+ // create the decrypter
+ if (sample_description->GetOriginalFormat() == AP4_ATOM_TYPE_AVC1) {
+ AP4_AvcSampleDescription* avc_desc = AP4_DYNAMIC_CAST(AP4_AvcSampleDescription, sample_description->GetOriginalSampleDescription());
+ if (avc_desc == NULL) {
+ return AP4_ERROR_INVALID_FORMAT;
+ }
+ decrypter = new AP4_PiffAvcCbcSampleDecrypter(block_cipher,
+ sample_encryption_atom,
+ avc_desc->GetNaluLengthSize());
+ } else {
+ decrypter = new AP4_PiffCbcSampleDecrypter(block_cipher,
+ sample_encryption_atom);
}
- decrypter = new AP4_PiffAvcCbcSampleDecrypter(block_cipher,
- sample_encryption_atom,
- avc_desc->GetNaluLengthSize());
}
- else
- {
- decrypter = new AP4_PiffCbcSampleDecrypter(block_cipher,
- sample_encryption_atom);
- }
- }
- break;
-
- default:
- return AP4_ERROR_NOT_SUPPORTED;
+ break;
+
+ default:
+ return AP4_ERROR_NOT_SUPPORTED;
}
return AP4_SUCCESS;
}
-
+
/*----------------------------------------------------------------------
| AP4_PiffSampleDecrypter::SetSampleIndex
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffSampleDecrypter::SetSampleIndex(AP4_Ordinal sample_index)
{
- if(sample_index < m_SampleEncryptionAtom->GetIvCount())
- {
+ if (sample_index < m_SampleEncryptionAtom->GetIvCount()) {
return AP4_ERROR_OUT_OF_RANGE;
}
m_SampleIndex = sample_index;
-
+
return AP4_SUCCESS;
}
@@ -803,10 +745,10 @@ AP4_PiffCtrSampleDecrypter::~AP4_PiffCtrSampleDecrypter()
/*----------------------------------------------------------------------
| AP4_PiffCtrSampleDecrypter::DecryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffCtrSampleDecrypter::DecryptSampleData(AP4_DataBuffer& /*data_in */,
- AP4_DataBuffer& /*data_out*/,
- const AP4_UI08* /*iv */)
+ AP4_DataBuffer& /*data_out*/,
+ const AP4_UI08* /*iv */)
{
return AP4_ERROR_NOT_SUPPORTED; // FIXME: not implemented yet
}
@@ -814,10 +756,10 @@ AP4_PiffCtrSampleDecrypter::DecryptSampleData(AP4_DataBuffer& /*data_in */,
/*----------------------------------------------------------------------
| AP4_PiffAvcCtrSampleDecrypter::DecryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffAvcCtrSampleDecrypter::DecryptSampleData(AP4_DataBuffer& /*data_in */,
- AP4_DataBuffer& /*data_out*/,
- const AP4_UI08* /*iv */)
+ AP4_DataBuffer& /*data_out*/,
+ const AP4_UI08* /*iv */)
{
return AP4_ERROR_NOT_SUPPORTED; // FIXME: not implemented yet
}
@@ -844,10 +786,10 @@ AP4_PiffCbcSampleDecrypter::~AP4_PiffCbcSampleDecrypter()
/*----------------------------------------------------------------------
| AP4_PiffCbcSampleDecrypter::DecryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffCbcSampleDecrypter::DecryptSampleData(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out,
- const AP4_UI08* iv)
+ AP4_DataBuffer& data_out,
+ const AP4_UI08* iv)
{
// the output has the same size as the input
data_out.SetDataSize(data_in.GetDataSize());
@@ -857,46 +799,43 @@ AP4_PiffCbcSampleDecrypter::DecryptSampleData(AP4_DataBuffer& data_in,
AP4_UI08* out = data_out.UseData();
// setup the IV
- if(iv == NULL)
- {
- if(m_SampleEncryptionAtom == NULL) return AP4_ERROR_INVALID_PARAMETERS;
+ if (iv == NULL) {
+ if (m_SampleEncryptionAtom == NULL) return AP4_ERROR_INVALID_PARAMETERS;
iv = m_SampleEncryptionAtom->GetIv(m_SampleIndex);
- if(iv == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (iv == NULL) return AP4_ERROR_INVALID_FORMAT;
}
m_Cipher->SetIV(iv);
-
+
// process the sample data
- unsigned int block_count = data_in.GetDataSize() / 16;
- if(block_count)
- {
+ unsigned int block_count = data_in.GetDataSize()/16;
+ if (block_count) {
AP4_Size out_size = data_out.GetDataSize();
- AP4_Result result = m_Cipher->ProcessBuffer(in, block_count * 16, out, &out_size, false);
- if(AP4_FAILED(result)) return result;
- AP4_ASSERT(out_size == block_count * 16);
- in += block_count * 16;
- out += block_count * 16;
+ AP4_Result result = m_Cipher->ProcessBuffer(in, block_count*16, out, &out_size, false);
+ if (AP4_FAILED(result)) return result;
+ AP4_ASSERT(out_size == block_count*16);
+ in += block_count*16;
+ out += block_count*16;
}
-
+
// any partial block at the end remains in the clear
- unsigned int partial = data_in.GetDataSize() % 16;
- if(partial)
- {
+ unsigned int partial = data_in.GetDataSize()%16;
+ if (partial) {
AP4_CopyMemory(out, in, partial);
}
-
+
// move on to the next sample
++m_SampleIndex;
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_PiffAvcCbcSampleDecrypter::DecryptSampleData
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffAvcCbcSampleDecrypter::DecryptSampleData(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out,
- const AP4_UI08* iv)
+ AP4_DataBuffer& data_out,
+ const AP4_UI08* iv)
{
// the output has the same size as the input
data_out.SetDataSize(data_in.GetDataSize());
@@ -906,103 +845,98 @@ AP4_PiffAvcCbcSampleDecrypter::DecryptSampleData(AP4_DataBuffer& data_in,
AP4_UI08* out = data_out.UseData();
// setup the IV
- if(iv == NULL)
- {
- if(m_SampleEncryptionAtom == NULL) return AP4_ERROR_INVALID_PARAMETERS;
+ if (iv == NULL) {
+ if (m_SampleEncryptionAtom == NULL) return AP4_ERROR_INVALID_PARAMETERS;
iv = m_SampleEncryptionAtom->GetIv(m_SampleIndex);
- if(iv == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (iv == NULL) return AP4_ERROR_INVALID_FORMAT;
}
m_Cipher->SetIV(iv);
// process the sample data, one NALU at a time
- const AP4_UI08* in_end = data_in.GetData() + data_in.GetDataSize();
- while((AP4_Size)(in_end - in) > 1 + m_NaluLengthSize)
- {
+ const AP4_UI08* in_end = data_in.GetData()+data_in.GetDataSize();
+ while ((AP4_Size)(in_end-in) > 1+m_NaluLengthSize) {
unsigned int nalu_length;
- switch(m_NaluLengthSize)
- {
- case 1:
- nalu_length = *in;
- break;
-
- case 2:
- nalu_length = AP4_BytesToUInt16BE(in);
- break;
-
- case 4:
- nalu_length = AP4_BytesToUInt32BE(in);
- break;
-
- default:
- return AP4_ERROR_INVALID_FORMAT;
+ switch (m_NaluLengthSize) {
+ case 1:
+ nalu_length = *in;
+ break;
+
+ case 2:
+ nalu_length = AP4_BytesToUInt16BE(in);
+ break;
+
+ case 4:
+ nalu_length = AP4_BytesToUInt32BE(in);
+ break;
+
+ default:
+ return AP4_ERROR_INVALID_FORMAT;
}
- unsigned int chunk_size = m_NaluLengthSize + nalu_length;
- unsigned int cleartext_size = chunk_size % 16;
- unsigned int block_count = chunk_size / 16;
- if(cleartext_size < m_NaluLengthSize + 1)
- {
+ unsigned int chunk_size = m_NaluLengthSize+nalu_length;
+ unsigned int cleartext_size = chunk_size%16;
+ unsigned int block_count = chunk_size/16;
+ if (cleartext_size < m_NaluLengthSize+1) {
AP4_ASSERT(block_count);
--block_count;
cleartext_size += 16;
}
-
+
// copy the cleartext portion
AP4_CopyMemory(out, in, cleartext_size);
-
+
// encrypt the rest
- if(block_count)
- {
- AP4_Size out_size = block_count * 16;
- m_Cipher->ProcessBuffer(in + cleartext_size, block_count * 16, out + cleartext_size, &out_size, false);
+ if (block_count) {
+ AP4_Size out_size = block_count*16;
+ m_Cipher->ProcessBuffer(in+cleartext_size, block_count*16, out+cleartext_size, &out_size, false);
}
-
+
// move the pointers
in += chunk_size;
out += chunk_size;
}
-
+
// move on to the next sample
++m_SampleIndex;
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_PiffTrackEncryptionAtom::Create
+---------------------------------------------------------------------*/
-AP4_PiffTrackEncryptionAtom*
+AP4_PiffTrackEncryptionAtom*
AP4_PiffTrackEncryptionAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version = 0;
AP4_UI32 flags = 0;
AP4_Result result = ReadFullHeader(stream, version, flags);
- if(AP4_FAILED(result)) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(result)) return NULL;
+ if (version != 0) return NULL;
return new AP4_PiffTrackEncryptionAtom(size, version, flags, stream);
}
/*----------------------------------------------------------------------
| AP4_PiffTrackEncryptionAtom::AP4_PiffTrackEncryptionAtom
+---------------------------------------------------------------------*/
-AP4_PiffTrackEncryptionAtom::AP4_PiffTrackEncryptionAtom(AP4_UI32 size,
- AP4_UI32 version,
- AP4_UI32 flags,
- AP4_ByteStream& stream) :
+AP4_PiffTrackEncryptionAtom::AP4_PiffTrackEncryptionAtom(AP4_UI32 size,
+ AP4_UI32 version,
+ AP4_UI32 flags,
+ AP4_ByteStream& stream) :
AP4_UuidAtom(size, AP4_UUID_PIFF_TRACK_ENCRYPTION_ATOM, version, flags)
{
stream.ReadUI24(m_DefaultAlgorithmId);
stream.ReadUI08(m_DefaultIvSize);
- stream.Read(m_DefaultKid, 16);
+ stream.Read (m_DefaultKid, 16);
}
/*----------------------------------------------------------------------
| AP4_PiffTrackEncryptionAtom::AP4_PiffTrackEncryptionAtom
+---------------------------------------------------------------------*/
AP4_PiffTrackEncryptionAtom::AP4_PiffTrackEncryptionAtom(AP4_UI32 default_algorithm_id,
- AP4_UI08 default_iv_size,
- const AP4_UI08* default_kid) :
- AP4_UuidAtom(AP4_FULL_UUID_ATOM_HEADER_SIZE + 20, AP4_UUID_PIFF_TRACK_ENCRYPTION_ATOM, 0, 0),
+ AP4_UI08 default_iv_size,
+ const AP4_UI08* default_kid) :
+ AP4_UuidAtom(AP4_FULL_UUID_ATOM_HEADER_SIZE+20, AP4_UUID_PIFF_TRACK_ENCRYPTION_ATOM, 0, 0),
m_DefaultAlgorithmId(default_algorithm_id),
m_DefaultIvSize(default_iv_size)
{
@@ -1012,31 +946,31 @@ AP4_PiffTrackEncryptionAtom::AP4_PiffTrackEncryptionAtom(AP4_UI32 default
/*----------------------------------------------------------------------
| AP4_PiffTrackEncryptionAtom::InspectFields
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffTrackEncryptionAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("default_AlgorithmID", m_DefaultAlgorithmId);
inspector.AddField("default_IV_size", m_DefaultIvSize);
inspector.AddField("default_KID", m_DefaultKid, 16);
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_PiffTrackEncryptionAtom::WriteFields
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffTrackEncryptionAtom::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
- // write the fields
+
+ // write the fields
result = stream.WriteUI24(m_DefaultAlgorithmId);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI08(m_DefaultIvSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.Write(m_DefaultKid, 16);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return AP4_SUCCESS;
}
@@ -1044,50 +978,45 @@ AP4_PiffTrackEncryptionAtom::WriteFields(AP4_ByteStream& stream)
/*----------------------------------------------------------------------
| AP4_PiffSampleEncryptionAtom::Create
+---------------------------------------------------------------------*/
-AP4_PiffSampleEncryptionAtom*
+AP4_PiffSampleEncryptionAtom*
AP4_PiffSampleEncryptionAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version = 0;
AP4_UI32 flags = 0;
AP4_Result result = ReadFullHeader(stream, version, flags);
- if(AP4_FAILED(result)) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(result)) return NULL;
+ if (version != 0) return NULL;
return new AP4_PiffSampleEncryptionAtom(size, version, flags, stream);
}
/*----------------------------------------------------------------------
| AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom
+---------------------------------------------------------------------*/
-AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom(AP4_UI32 size,
- AP4_UI32 version,
- AP4_UI32 flags,
- AP4_ByteStream& stream) :
+AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom(AP4_UI32 size,
+ AP4_UI32 version,
+ AP4_UI32 flags,
+ AP4_ByteStream& stream) :
AP4_UuidAtom(size, AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM, version, flags)
{
- if(flags & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS)
- {
+ if (flags & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS) {
stream.ReadUI24(m_AlgorithmId);
stream.ReadUI08(m_IvSize);
- stream.Read(m_Kid, 16);
- }
- else
- {
+ stream.Read (m_Kid, 16);
+ } else {
m_AlgorithmId = 0;
m_IvSize = 0;
AP4_SetMemory(m_Kid, 0, 16);
}
-
+
stream.ReadUI32(m_IvCount);
// NOTE: the problem here is that we don't know the IV size when flags==0
// So what we do is read the whole atom and assume that there's nothing
// else after the table.
- AP4_Size payload_size = size - GetHeaderSize() - 4;
- if((flags & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS) == 0)
- {
- if(m_IvCount)
- {
- m_IvSize = (AP4_UI08)(payload_size / m_IvCount);
+ AP4_Size payload_size = size-GetHeaderSize()-4;
+ if ((flags & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS) == 0) {
+ if (m_IvCount) {
+ m_IvSize = (AP4_UI08)(payload_size/m_IvCount);
}
}
m_Ivs.SetDataSize(payload_size);
@@ -1098,7 +1027,7 @@ AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom(AP4_UI32 size,
| AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom
+---------------------------------------------------------------------*/
AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom(AP4_Cardinal sample_count) :
- AP4_UuidAtom(AP4_FULL_UUID_ATOM_HEADER_SIZE + 4 + sample_count * 16, AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM, 0, 0),
+ AP4_UuidAtom(AP4_FULL_UUID_ATOM_HEADER_SIZE+4+sample_count*16, AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM, 0, 0),
m_AlgorithmId(0),
m_IvSize(16),
m_IvCount(sample_count)
@@ -1106,7 +1035,7 @@ AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom(AP4_Cardinal sample_c
AP4_SetMemory(m_Kid, 0, 16);
// initialize the IVs to 0s
- m_Ivs.SetDataSize(sample_count * m_IvSize);
+ m_Ivs.SetDataSize(sample_count*m_IvSize);
AP4_SetMemory(m_Ivs.UseData(), 0, m_Ivs.GetDataSize());
}
@@ -1114,10 +1043,10 @@ AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom(AP4_Cardinal sample_c
| AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom
+---------------------------------------------------------------------*/
AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom(AP4_UI32 algorithm_id,
- AP4_UI08 iv_size,
- const AP4_UI08* kid,
- AP4_Cardinal sample_count) :
- AP4_UuidAtom(AP4_FULL_UUID_ATOM_HEADER_SIZE + 20 + 4, AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM, 0,
+ AP4_UI08 iv_size,
+ const AP4_UI08* kid,
+ AP4_Cardinal sample_count) :
+ AP4_UuidAtom(AP4_FULL_UUID_ATOM_HEADER_SIZE+20+4, AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM, 0,
AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS),
m_AlgorithmId(algorithm_id),
m_IvSize(iv_size),
@@ -1126,7 +1055,7 @@ AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom(AP4_UI32 algor
AP4_CopyMemory(m_Kid, kid, 16);
// initialize the IVs to 0s
- m_Ivs.SetDataSize(sample_count * m_IvSize);
+ m_Ivs.SetDataSize(sample_count*m_IvSize);
AP4_SetMemory(m_Ivs.UseData(), 0, m_Ivs.GetDataSize());
}
@@ -1136,86 +1065,80 @@ AP4_PiffSampleEncryptionAtom::AP4_PiffSampleEncryptionAtom(AP4_UI32 algor
const AP4_UI08*
AP4_PiffSampleEncryptionAtom::GetIv(AP4_Ordinal indx)
{
- if(m_IvSize == 0) return NULL;
- unsigned int offset = indx * m_IvSize;
- if(offset + m_IvSize > m_Ivs.GetDataSize()) return NULL;
- return m_Ivs.GetData() + offset;
+ if (m_IvSize == 0) return NULL;
+ unsigned int offset = indx*m_IvSize;
+ if (offset+m_IvSize > m_Ivs.GetDataSize()) return NULL;
+ return m_Ivs.GetData()+offset;
}
/*----------------------------------------------------------------------
| AP4_PiffSampleEncryptionAtom::SetIv
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffSampleEncryptionAtom::SetIv(AP4_Ordinal indx, const AP4_UI08* iv)
{
- if(m_IvSize == 0) return AP4_ERROR_INVALID_STATE;
- if(indx >= m_IvCount)
- {
+ if (m_IvSize == 0) return AP4_ERROR_INVALID_STATE;
+ if (indx >= m_IvCount) {
return AP4_ERROR_OUT_OF_RANGE;
}
- AP4_CopyMemory(m_Ivs.UseData() + indx * m_IvSize, iv, m_IvSize);
-
+ AP4_CopyMemory(m_Ivs.UseData()+indx*m_IvSize, iv, m_IvSize);
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_PiffSampleEncryptionAtom::InspectFields
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffSampleEncryptionAtom::InspectFields(AP4_AtomInspector& inspector)
{
- if(m_Flags & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS)
- {
+ if (m_Flags & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS) {
inspector.AddField("AlgorithmID", m_AlgorithmId);
inspector.AddField("IV_size", m_IvSize);
inspector.AddField("KID", m_Kid, 16);
}
-
- if(m_IvSize > 0 && m_IvSize <= 16 && inspector.GetVerbosity() >= 1)
- {
- unsigned int sample_count = m_Ivs.GetDataSize() / m_IvSize;
- for(unsigned int i = 0; i < sample_count; i++)
- {
+
+ if (m_IvSize > 0 && m_IvSize <= 16 && inspector.GetVerbosity() >= 1) {
+ unsigned int sample_count = m_Ivs.GetDataSize()/m_IvSize;
+ for (unsigned int i=0; i<sample_count; i++) {
char header[32];
char hex[33];
hex[32] = '\0';
- AP4_FormatString(header, sizeof(header), "IV %4d", i);
- AP4_FormatHex(m_Ivs.GetData() + i * m_IvSize, m_IvSize, hex);
+ AP4_FormatString(header, sizeof(header), "IV %4d", i);
+ AP4_FormatHex(m_Ivs.GetData()+i*m_IvSize, m_IvSize, hex);
inspector.AddField(header, hex);
}
}
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_PiffSampleEncryptionAtom::WriteFields
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_PiffSampleEncryptionAtom::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
+
// optional fields
- if(m_Flags & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS)
- {
+ if (m_Flags & AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS) {
result = stream.WriteUI24(m_AlgorithmId);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI08(m_IvSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.Write(m_Kid, 16);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
-
+
// IVs
result = stream.WriteUI32(m_IvCount);
- if(AP4_FAILED(result)) return result;
- if(m_Ivs.GetDataSize())
- {
+ if (AP4_FAILED(result)) return result;
+ if (m_Ivs.GetDataSize()) {
stream.Write(m_Ivs.GetData(), m_Ivs.GetDataSize());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
-
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.h
index 3724befbc..73ad5659c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Piff.h
@@ -52,24 +52,23 @@ class AP4_PiffSampleEncryptionAtom;
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_PIFF = AP4_ATOM_TYPE('p', 'i', 'f', 'f');
+const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_PIFF = AP4_ATOM_TYPE('p','i','f','f');
const AP4_UI32 AP4_PROTECTION_SCHEME_VERSION_PIFF_10 = 0x00010000;
-const AP4_UI32 AP4_PIFF_BRAND = AP4_ATOM_TYPE('p', 'i', 'f', 'f');
-const AP4_UI32 AP4_PIFF_ALGORITHM_ID_NONE = 0;
-const AP4_UI32 AP4_PIFF_ALGORITHM_ID_CTR = 1;
-const AP4_UI32 AP4_PIFF_ALGORITHM_ID_CBC = 2;
+const AP4_UI32 AP4_PIFF_BRAND = AP4_ATOM_TYPE('p','i','f','f');
+const AP4_UI32 AP4_PIFF_ALGORITHM_ID_NONE = 0;
+const AP4_UI32 AP4_PIFF_ALGORITHM_ID_CTR = 1;
+const AP4_UI32 AP4_PIFF_ALGORITHM_ID_CBC = 2;
extern AP4_UI08 const AP4_UUID_PIFF_TRACK_ENCRYPTION_ATOM[16];
extern AP4_UI08 const AP4_UUID_PIFF_SAMPLE_ENCRYPTION_ATOM[16];
const unsigned int AP4_PIFF_SAMPLE_ENCRYPTION_FLAG_OVERRIDE_TRACK_ENCRYPTION_DEFAULTS = 1;
-typedef enum
-{
+typedef enum {
AP4_PIFF_CIPHER_MODE_CTR,
AP4_PIFF_CIPHER_MODE_CBC
} AP4_PiffCipherMode;
-
+
/*----------------------------------------------------------------------
| AP4_PiffSampleEncrypter
+---------------------------------------------------------------------*/
@@ -77,25 +76,16 @@ class AP4_PiffSampleEncrypter
{
public:
// constructor and destructor
- AP4_PiffSampleEncrypter()
- {
- AP4_SetMemory(m_Iv, 0, 16);
- };
+ AP4_PiffSampleEncrypter() { AP4_SetMemory(m_Iv, 0, 16); };
virtual ~AP4_PiffSampleEncrypter() {}
// methods
virtual AP4_Result EncryptSampleData(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out) = 0;
-
- void SetIv(const AP4_UI08* iv)
- {
- AP4_CopyMemory(m_Iv, iv, 16);
- }
- const AP4_UI08* GetIv()
- {
- return m_Iv;
- }
+ AP4_DataBuffer& data_out) = 0;
+ void SetIv(const AP4_UI08* iv) { AP4_CopyMemory(m_Iv, iv, 16); }
+ const AP4_UI08* GetIv() { return m_Iv; }
+
protected:
AP4_UI08 m_Iv[16];
};
@@ -113,7 +103,7 @@ public:
// methods
virtual AP4_Result EncryptSampleData(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out);
-
+
protected:
// members
AP4_CtrStreamCipher* m_Cipher;
@@ -134,7 +124,7 @@ public:
// methods
virtual AP4_Result EncryptSampleData(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out);
-
+
private:
// members
AP4_Size m_NaluLengthSize;
@@ -187,15 +177,11 @@ class AP4_PiffEncryptingProcessor : public AP4_Processor
{
public:
// types
- struct Encrypter
- {
+ struct Encrypter {
Encrypter(AP4_UI32 track_id, AP4_PiffSampleEncrypter* sample_encrypter) :
m_TrackId(track_id),
m_SampleEncrypter(sample_encrypter) {}
- Encrypter()
- {
- delete m_SampleEncrypter;
- }
+ Encrypter() { delete m_SampleEncrypter; }
AP4_UI32 m_TrackId;
AP4_PiffSampleEncrypter* m_SampleEncrypter;
};
@@ -206,14 +192,8 @@ public:
~AP4_PiffEncryptingProcessor();
// accessors
- AP4_ProtectionKeyMap& GetKeyMap()
- {
- return m_KeyMap;
- }
- AP4_TrackPropertyMap& GetPropertyMap()
- {
- return m_PropertyMap;
- }
+ AP4_ProtectionKeyMap& GetKeyMap() { return m_KeyMap; }
+ AP4_TrackPropertyMap& GetPropertyMap() { return m_PropertyMap; }
// AP4_Processor methods
virtual AP4_Result Initialize(AP4_AtomParent& top_level,
@@ -221,8 +201,8 @@ public:
AP4_Processor::ProgressListener* listener = NULL);
virtual AP4_Processor::TrackHandler* CreateTrackHandler(AP4_TrakAtom* trak);
virtual AP4_Processor::FragmentHandler* CreateFragmentHandler(AP4_ContainerAtom* traf);
-
-protected:
+
+protected:
// members
AP4_PiffCipherMode m_CipherMode;
AP4_BlockCipherFactory* m_BlockCipherFactory;
@@ -238,9 +218,9 @@ class AP4_PiffSampleDecrypter : public AP4_SampleDecrypter
{
public:
// factory
- static AP4_Result Create(AP4_ProtectedSampleDescription* sample_description,
+ static AP4_Result Create(AP4_ProtectedSampleDescription* sample_description,
AP4_ContainerAtom* traf,
- const AP4_UI08* key,
+ const AP4_UI08* key,
AP4_Size key_size,
AP4_BlockCipherFactory* block_cipher_factory,
AP4_PiffSampleDecrypter*& decrypter);
@@ -264,12 +244,11 @@ class AP4_PiffNullSampleDecrypter : public AP4_PiffSampleDecrypter
public:
// constructor
AP4_PiffNullSampleDecrypter() : AP4_PiffSampleDecrypter(NULL) {}
-
+
// methods
virtual AP4_Result DecryptSampleData(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out,
- const AP4_UI08* /*iv = NULL*/)
- {
+ const AP4_UI08* /*iv = NULL*/) {
data_out.SetData(data_in.GetData(), data_in.GetDataSize());
return AP4_SUCCESS;
}
@@ -373,8 +352,8 @@ class AP4_PiffTrackEncryptionAtom : public AP4_UuidAtom
{
public:
// class methods
- static AP4_PiffTrackEncryptionAtom* Create(AP4_Size size,
- AP4_ByteStream& stream);
+ static AP4_PiffTrackEncryptionAtom* Create(AP4_Size size,
+ AP4_ByteStream& stream);
// constructors
AP4_PiffTrackEncryptionAtom(AP4_UI32 default_algorithm_id,
@@ -386,22 +365,13 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- AP4_UI32 GetDefaultAlgorithmId()
- {
- return m_DefaultAlgorithmId;
- }
- AP4_UI08 GetDefaultIvSize()
- {
- return m_DefaultIvSize;
- }
- const AP4_UI08* GetDefaultKid()
- {
- return m_DefaultKid;
- }
+ AP4_UI32 GetDefaultAlgorithmId() { return m_DefaultAlgorithmId; }
+ AP4_UI08 GetDefaultIvSize() { return m_DefaultIvSize; }
+ const AP4_UI08* GetDefaultKid() { return m_DefaultKid; }
private:
// methods
- AP4_PiffTrackEncryptionAtom(AP4_UI32 size,
+ AP4_PiffTrackEncryptionAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
@@ -419,8 +389,8 @@ class AP4_PiffSampleEncryptionAtom : public AP4_UuidAtom
{
public:
// class methods
- static AP4_PiffSampleEncryptionAtom* Create(AP4_Size size,
- AP4_ByteStream& stream);
+ static AP4_PiffSampleEncryptionAtom* Create(AP4_Size size,
+ AP4_ByteStream& stream);
// constructors
AP4_PiffSampleEncryptionAtom(AP4_Cardinal sample_count);
@@ -434,29 +404,17 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- AP4_UI32 GetAlgorithmId()
- {
- return m_AlgorithmId;
- }
- AP4_UI08 GetIvSize()
- {
- return m_IvSize;
- }
+ AP4_UI32 GetAlgorithmId() { return m_AlgorithmId; }
+ AP4_UI08 GetIvSize() { return m_IvSize; }
AP4_Result SetIvSize(AP4_UI08 iv_size);
- const AP4_UI08* GetKid()
- {
- return m_Kid;
- }
- AP4_Cardinal GetIvCount()
- {
- return m_IvCount;
- }
+ const AP4_UI08* GetKid() { return m_Kid; }
+ AP4_Cardinal GetIvCount() { return m_IvCount; }
const AP4_UI08* GetIv(AP4_Ordinal indx);
AP4_Result SetIv(AP4_Ordinal indx, const AP4_UI08* iv);
private:
// methods
- AP4_PiffSampleEncryptionAtom(AP4_UI32 size,
+ AP4_PiffSampleEncryptionAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.cpp
index 433209466..129989b1e 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.cpp
@@ -46,12 +46,11 @@
/*----------------------------------------------------------------------
| types
+---------------------------------------------------------------------*/
-struct AP4_SampleLocator
-{
- AP4_SampleLocator() :
- m_TrakIndex(0),
- m_SampleTable(NULL),
- m_SampleIndex(0),
+struct AP4_SampleLocator {
+ AP4_SampleLocator() :
+ m_TrakIndex(0),
+ m_SampleTable(NULL),
+ m_SampleIndex(0),
m_ChunkIndex(0) {}
AP4_Ordinal m_TrakIndex;
AP4_AtomSampleTable* m_SampleTable;
@@ -60,16 +59,14 @@ struct AP4_SampleLocator
AP4_Sample m_Sample;
};
-struct AP4_SampleCursor
-{
+struct AP4_SampleCursor {
AP4_SampleCursor() : m_EndReached(false) {}
AP4_SampleLocator m_Locator;
bool m_EndReached;
};
-struct AP4_MoofLocator
-{
- AP4_MoofLocator(AP4_ContainerAtom* moof, AP4_UI64 offset) :
+struct AP4_MoofLocator {
+ AP4_MoofLocator(AP4_ContainerAtom* moof, AP4_UI64 offset) :
m_Moof(moof),
m_Offset(offset) {}
AP4_ContainerAtom* m_Moof;
@@ -80,147 +77,132 @@ struct AP4_MoofLocator
| AP4_Processor::ProcessFragments
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Processor::ProcessFragments(AP4_MoovAtom* moov,
- AP4_List<AP4_MoofLocator>& moofs,
+AP4_Processor::ProcessFragments(AP4_MoovAtom* moov,
+ AP4_List<AP4_MoofLocator>& moofs,
AP4_ContainerAtom* mfra,
- AP4_ByteStream& input,
+ AP4_ByteStream& input,
AP4_ByteStream& output)
{
- // FIXME: this only works for non-changing moofs
-
- for(AP4_List<AP4_MoofLocator>::Item* item = moofs.FirstItem();
- item;
- item = item->GetNext())
- {
+ // FIXME: this only works for non-changing moofs
+
+ for (AP4_List<AP4_MoofLocator>::Item* item = moofs.FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_MoofLocator* locator = item->GetData();
AP4_ContainerAtom* moof = locator->m_Moof;
AP4_UI64 moof_offset = locator->m_Offset;
- AP4_UI64 mdat_payload_offset = moof_offset + moof->GetSize() + 8;
+ AP4_UI64 mdat_payload_offset = moof_offset+moof->GetSize()+8;
AP4_MovieFragment* fragment = new AP4_MovieFragment(moof);
AP4_Sample sample;
AP4_DataBuffer sample_data_in;
AP4_DataBuffer sample_data_out;
AP4_Result result;
-
+
// process all the traf atoms
AP4_Array<AP4_Processor::FragmentHandler*> handlers;
- for(; AP4_Atom* atom = moof->GetChild(AP4_ATOM_TYPE_TRAF, handlers.ItemCount());)
- {
+ for (;AP4_Atom* atom = moof->GetChild(AP4_ATOM_TYPE_TRAF, handlers.ItemCount());) {
AP4_ContainerAtom* traf = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
AP4_Processor::FragmentHandler* handler = CreateFragmentHandler(traf);
- if(handler) result = handler->ProcessFragment();
+ if (handler) result = handler->ProcessFragment();
handlers.Append(handler);
}
-
+
// write the moof
AP4_UI64 moof_out_start = 0;
output.Tell(moof_out_start);
bool moof_has_changed = false;
moof->Write(output);
-
+
// process all track runs
- for(unsigned int i = 0; i < handlers.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<handlers.ItemCount(); i++) {
AP4_FragmentSampleTable* sample_table = NULL;
AP4_Processor::FragmentHandler* handler = handlers[i];
// get the track ID
AP4_ContainerAtom* traf = AP4_DYNAMIC_CAST(AP4_ContainerAtom, moof->GetChild(AP4_ATOM_TYPE_TRAF, i));
AP4_TfhdAtom* tfhd = AP4_DYNAMIC_CAST(AP4_TfhdAtom, traf->GetChild(AP4_ATOM_TYPE_TFHD, i));
-
+
// create a sample table object so we can read the sample data
result = fragment->CreateSampleTable(moov, tfhd->GetTrackId(), &input, moof_offset, mdat_payload_offset, sample_table);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// compute the mdat size
AP4_UI64 mdat_size = 0;
- for(unsigned int j = 0; j < sample_table->GetSampleCount(); j++)
- {
+ for (unsigned int j=0; j<sample_table->GetSampleCount(); j++) {
result = sample_table->GetSample(j, sample);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
mdat_size += sample.GetSize();
}
-
+
// write an mdat header
- if(mdat_size > 0xFFFFFFFF - 8)
- {
+ if (mdat_size > 0xFFFFFFFF-8) {
// we don't support large mdat fragments
return AP4_ERROR_OUT_OF_RANGE;
}
- if(mdat_size)
- {
- output.WriteUI32((AP4_UI32)(8 + mdat_size));
+ if (mdat_size) {
+ output.WriteUI32((AP4_UI32)(8+mdat_size));
output.WriteUI32(AP4_ATOM_TYPE_MDAT);
}
-
+
#if defined(AP4_DEBUG)
AP4_Position before;
output.Tell(before);
#endif
-
+
// write the mdat
- for(unsigned int j = 0; j < sample_table->GetSampleCount(); j++)
- {
+ for (unsigned int j=0; j<sample_table->GetSampleCount(); j++) {
result = sample_table->GetSample(j, sample);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
sample.ReadData(sample_data_in);
-
+
// process the sample data
- if(handler)
- {
+ if (handler) {
result = handler->ProcessSample(sample_data_in, sample_data_out);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// write the sample data
result = output.Write(sample_data_out.GetData(), sample_data_out.GetDataSize());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// give the handler a chance to update the atoms
result = handler->FinishFragment();
- if(AP4_SUCCEEDED(result)) moof_has_changed = true;
- }
- else
- {
+ if (AP4_SUCCEEDED(result)) moof_has_changed = true;
+ } else {
// write the sample data (unmodified)
result = output.Write(sample_data_in.GetData(), sample_data_in.GetDataSize());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
}
-
+
#if defined(AP4_DEBUG)
AP4_Position after;
output.Tell(after);
- AP4_ASSERT(after - before == mdat_size);
+ AP4_ASSERT(after-before == mdat_size);
#endif
delete sample_table;
}
-
+
// update the moof if needed
AP4_UI64 mdat_out_end = 0;
output.Tell(mdat_out_end);
- if(moof_has_changed)
- {
+ if (moof_has_changed) {
output.Seek(moof_out_start);
moof->Write(output);
output.Seek(mdat_out_end);
}
-
+
// update the mfra if we have one
- if(mfra)
- {
- for(AP4_List<AP4_Atom>::Item* mfra_item = mfra->GetChildren().FirstItem();
- mfra_item;
- mfra_item = mfra_item->GetNext())
- {
- if(mfra_item->GetData()->GetType() != AP4_ATOM_TYPE_TFRA) continue;
+ if (mfra) {
+ for (AP4_List<AP4_Atom>::Item* mfra_item = mfra->GetChildren().FirstItem();
+ mfra_item;
+ mfra_item = mfra_item->GetNext()) {
+ if (mfra_item->GetData()->GetType() != AP4_ATOM_TYPE_TFRA) continue;
AP4_TfraAtom* tfra = AP4_DYNAMIC_CAST(AP4_TfraAtom, mfra_item->GetData());
- if(tfra == NULL) continue;
+ if (tfra == NULL) continue;
AP4_Array<AP4_TfraAtom::Entry>& entries = tfra->GetEntries();
AP4_Cardinal entry_count = entries.ItemCount();
- for(unsigned int i = 0; i < entry_count; i++)
- {
- if(entries[i].m_MoofOffset == locator->m_Offset)
- {
+ for (unsigned int i=0; i<entry_count; i++) {
+ if (entries[i].m_MoofOffset == locator->m_Offset) {
entries[i].m_MoofOffset = moof_out_start;
}
}
@@ -229,7 +211,7 @@ AP4_Processor::ProcessFragments(AP4_MoovAtom* moov,
delete fragment;
}
-
+
return AP4_SUCCESS;
}
@@ -237,7 +219,7 @@ AP4_Processor::ProcessFragments(AP4_MoovAtom* moov,
| AP4_Processor::Process
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Processor::Process(AP4_ByteStream& input,
+AP4_Processor::Process(AP4_ByteStream& input,
AP4_ByteStream& output,
ProgressListener* listener,
AP4_AtomFactory& atom_factory)
@@ -251,29 +233,20 @@ AP4_Processor::Process(AP4_ByteStream& input,
AP4_ContainerAtom* mfra = NULL;
AP4_List<AP4_MoofLocator> moofs;
AP4_UI64 stream_offset = 0;
- for(AP4_Atom* atom = NULL;
+ for (AP4_Atom* atom = NULL;
AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(input, atom));
- input.Tell(stream_offset))
- {
- if(atom->GetType() == AP4_ATOM_TYPE_MDAT)
- {
+ input.Tell(stream_offset)) {
+ if (atom->GetType() == AP4_ATOM_TYPE_MDAT) {
continue;
- }
- else if(atom->GetType() == AP4_ATOM_TYPE_MOOV)
- {
+ } else if (atom->GetType() == AP4_ATOM_TYPE_MOOV) {
moov = (AP4_MoovAtom*)atom;
- }
- else if(atom->GetType() == AP4_ATOM_TYPE_MOOF)
- {
+ } else if (atom->GetType() == AP4_ATOM_TYPE_MOOF) {
AP4_ContainerAtom* moof = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
- if(moof)
- {
+ if (moof) {
moofs.Add(new AP4_MoofLocator(moof, stream_offset));
}
continue;
- }
- else if(atom->GetType() == AP4_ATOM_TYPE_MFRA)
- {
+ } else if (atom->GetType() == AP4_ATOM_TYPE_MFRA) {
mfra = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
continue;
}
@@ -282,7 +255,7 @@ AP4_Processor::Process(AP4_ByteStream& input,
// initialize the processor
AP4_Result result = Initialize(top_level, input);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// process the tracks if we have a moov atom
AP4_Array<AP4_SampleLocator> locators;
@@ -291,75 +264,64 @@ AP4_Processor::Process(AP4_ByteStream& input,
AP4_LargeSize mdat_payload_size = 0;
TrackHandler** handlers = NULL;
AP4_SampleCursor* cursors = NULL;
- if(moov)
- {
+ if (moov) {
// build an array of track sample locators
trak_atoms = &moov->GetTrakAtoms();
track_count = trak_atoms->ItemCount();
cursors = new AP4_SampleCursor[track_count];
handlers = new TrackHandler*[track_count];
- for(AP4_Ordinal i = 0; i < track_count; i++)
- {
+ for (AP4_Ordinal i=0; i<track_count; i++) {
handlers[i] = NULL;
}
-
+
unsigned int index = 0;
- for(AP4_List<AP4_TrakAtom>::Item* item = trak_atoms->FirstItem(); item; item = item->GetNext())
- {
+ for (AP4_List<AP4_TrakAtom>::Item* item = trak_atoms->FirstItem(); item; item=item->GetNext()) {
AP4_TrakAtom* trak = item->GetData();
// find the stsd atom
AP4_ContainerAtom* stbl = AP4_DYNAMIC_CAST(AP4_ContainerAtom, trak->FindChild("mdia/minf/stbl"));
- if(stbl == NULL) continue;
-
+ if (stbl == NULL) continue;
+
// see if there's an external data source for this track
AP4_ByteStream* trak_data_stream = &input;
- for(AP4_List<ExternalTrackData>::Item* ditem = m_ExternalTrackData.FirstItem(); ditem; ditem = ditem->GetNext())
- {
+ for (AP4_List<ExternalTrackData>::Item* ditem = m_ExternalTrackData.FirstItem(); ditem; ditem=ditem->GetNext()) {
ExternalTrackData* tdata = ditem->GetData();
- if(tdata->m_TrackId == trak->GetId())
- {
+ if (tdata->m_TrackId == trak->GetId()) {
trak_data_stream = tdata->m_MediaData;
break;
}
}
- // create the track handler
+ // create the track handler
handlers[index] = CreateTrackHandler(trak);
cursors[index].m_Locator.m_TrakIndex = index;
cursors[index].m_Locator.m_SampleTable = new AP4_AtomSampleTable(stbl, *trak_data_stream);
cursors[index].m_Locator.m_SampleIndex = 0;
cursors[index].m_Locator.m_ChunkIndex = 0;
- if(cursors[index].m_Locator.m_SampleTable->GetSampleCount())
- {
+ if (cursors[index].m_Locator.m_SampleTable->GetSampleCount()) {
cursors[index].m_Locator.m_SampleTable->GetSample(0, cursors[index].m_Locator.m_Sample);
- }
- else
- {
+ } else {
cursors[index].m_EndReached = true;
}
- index++;
+ index++;
}
// figure out the layout of the chunks
- for(;;)
- {
+ for (;;) {
// see which is the next sample to write
AP4_UI64 min_offset = (AP4_UI64)(-1);
int cursor = -1;
- for(unsigned int i = 0; i < track_count; i++)
- {
- if(!cursors[i].m_EndReached &&
- cursors[i].m_Locator.m_Sample.GetOffset() <= min_offset)
- {
+ for (unsigned int i=0; i<track_count; i++) {
+ if (!cursors[i].m_EndReached &&
+ cursors[i].m_Locator.m_Sample.GetOffset() <= min_offset) {
min_offset = cursors[i].m_Locator.m_Sample.GetOffset();
cursor = i;
}
}
// stop if all cursors are exhausted
- if(cursor == -1) break;
+ if (cursor == -1) break;
// append this locator to the layout list
AP4_SampleLocator& locator = cursors[cursor].m_Locator;
@@ -367,19 +329,16 @@ AP4_Processor::Process(AP4_ByteStream& input,
// move the cursor to the next sample
locator.m_SampleIndex++;
- if(locator.m_SampleIndex == locator.m_SampleTable->GetSampleCount())
- {
+ if (locator.m_SampleIndex == locator.m_SampleTable->GetSampleCount()) {
// mark this track as completed
cursors[cursor].m_EndReached = true;
- }
- else
- {
+ } else {
// get the next sample info
locator.m_SampleTable->GetSample(locator.m_SampleIndex, locator.m_Sample);
AP4_Ordinal skip, sdesc;
locator.m_SampleTable->GetChunkForSample(locator.m_SampleIndex,
- locator.m_ChunkIndex,
- skip, sdesc);
+ locator.m_ChunkIndex,
+ skip, sdesc);
}
}
@@ -388,28 +347,23 @@ AP4_Processor::Process(AP4_ByteStream& input,
int current_chunk = -1;
AP4_Position current_chunk_offset = 0;
AP4_Size current_chunk_size = 0;
- for(AP4_Ordinal i = 0; i < locators.ItemCount(); i++)
- {
+ for (AP4_Ordinal i=0; i<locators.ItemCount(); i++) {
AP4_SampleLocator& locator = locators[i];
- if((int)locator.m_TrakIndex != current_track ||
- (int)locator.m_ChunkIndex != current_chunk)
- {
+ if ((int)locator.m_TrakIndex != current_track ||
+ (int)locator.m_ChunkIndex != current_chunk) {
// start a new chunk for this track
current_chunk_offset += current_chunk_size;
current_chunk_size = 0;
current_track = locator.m_TrakIndex;
current_chunk = locator.m_ChunkIndex;
locator.m_SampleTable->SetChunkOffset(locator.m_ChunkIndex, current_chunk_offset);
- }
+ }
AP4_Size sample_size;
TrackHandler* handler = handlers[locator.m_TrakIndex];
- if(handler)
- {
+ if (handler) {
sample_size = handler->GetProcessedSampleSize(locator.m_Sample);
locator.m_SampleTable->SetSampleSize(locator.m_SampleIndex, sample_size);
- }
- else
- {
+ } else {
sample_size = locator.m_Sample.GetSize();
}
current_chunk_size += sample_size;
@@ -417,10 +371,9 @@ AP4_Processor::Process(AP4_ByteStream& input,
}
// process the tracks (ex: sample descriptions processing)
- for(AP4_Ordinal i = 0; i < track_count; i++)
- {
+ for (AP4_Ordinal i=0; i<track_count; i++) {
TrackHandler* handler = handlers[i];
- if(handler) handler->ProcessTrack();
+ if (handler) handler->ProcessTrack();
}
}
@@ -433,78 +386,65 @@ AP4_Processor::Process(AP4_ByteStream& input,
// see if we need a 64-bit or 32-bit mdat
AP4_Size mdat_header_size = AP4_ATOM_HEADER_SIZE;
- if(mdat_payload_size + mdat_header_size > 0xFFFFFFFF)
- {
+ if (mdat_payload_size+mdat_header_size > 0xFFFFFFFF) {
// we need a 64-bit size
mdat_header_size += 8;
}
-
+
// adjust the chunk offsets
- for(AP4_Ordinal i = 0; i < track_count; i++)
- {
+ for (AP4_Ordinal i=0; i<track_count; i++) {
AP4_TrakAtom* trak;
trak_atoms->Get(i, trak);
- trak->AdjustChunkOffsets(atoms_size + mdat_header_size);
+ trak->AdjustChunkOffsets(atoms_size+mdat_header_size);
}
// write all atoms
top_level.GetChildren().Apply(AP4_AtomListWriter(output));
// write mdat header
- if(mdat_payload_size)
- {
- if(mdat_header_size == AP4_ATOM_HEADER_SIZE)
- {
+ if (mdat_payload_size) {
+ if (mdat_header_size == AP4_ATOM_HEADER_SIZE) {
// 32-bit size
- output.WriteUI32((AP4_UI32)(mdat_header_size + mdat_payload_size));
+ output.WriteUI32((AP4_UI32)(mdat_header_size+mdat_payload_size));
output.WriteUI32(AP4_ATOM_TYPE_MDAT);
- }
- else
- {
+ } else {
// 64-bit size
output.WriteUI32(1);
output.WriteUI32(AP4_ATOM_TYPE_MDAT);
- output.WriteUI64(mdat_header_size + mdat_payload_size);
+ output.WriteUI64(mdat_header_size+mdat_payload_size);
}
}
-
+
#if defined(AP4_DEBUG)
AP4_Position before;
output.Tell(before);
#endif
// write the samples
- if(moov)
- {
+ if (moov) {
AP4_Sample sample;
AP4_DataBuffer data_in;
AP4_DataBuffer data_out;
- for(unsigned int i = 0; i < locators.ItemCount(); i++)
- {
+ for (unsigned int i=0; i<locators.ItemCount(); i++) {
AP4_SampleLocator& locator = locators[i];
locator.m_Sample.ReadData(data_in);
TrackHandler* handler = handlers[locator.m_TrakIndex];
- if(handler)
- {
+ if (handler) {
result = handler->ProcessSample(data_in, data_out);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
output.Write(data_out.GetData(), data_out.GetDataSize());
- }
- else
- {
- output.Write(data_in.GetData(), data_in.GetDataSize());
+ } else {
+ output.Write(data_in.GetData(), data_in.GetDataSize());
}
// notify the progress listener
- if(listener)
- {
- listener->OnProgress(i + 1, locators.ItemCount());
+ if (listener) {
+ listener->OnProgress(i+1, locators.ItemCount());
}
}
// cleanup
- for(AP4_Ordinal i = 0; i < track_count; i++)
- {
+ for (AP4_Ordinal i=0; i<track_count; i++) {
delete cursors[i].m_Locator.m_SampleTable;
delete handlers[i];
}
@@ -515,30 +455,29 @@ AP4_Processor::Process(AP4_ByteStream& input,
#if defined(AP4_DEBUG)
AP4_Position after;
output.Tell(after);
- AP4_ASSERT(after - before == mdat_payload_size);
+ AP4_ASSERT(after-before == mdat_payload_size);
#endif
// process the fragments, if any
result = ProcessFragments(moov, moofs, mfra, input, output);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// write the mfra atom at the end if we have one
- if(mfra)
- {
+ if (mfra) {
mfra->Write(output);
}
-
+
// cleanup
moofs.DeleteReferences();
delete mfra;
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_Processor:Initialize
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_Processor::Initialize(AP4_AtomParent& /* top_level */,
AP4_ByteStream& /* stream */,
ProgressListener* /* listener */)
@@ -550,9 +489,9 @@ AP4_Processor::Initialize(AP4_AtomParent& /* top_level */,
/*----------------------------------------------------------------------
| AP4_Processor:Finalize
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_Processor::Finalize(AP4_AtomParent& /* top_level */,
- ProgressListener* /* listener */)
+ ProgressListener* /* listener */ )
{
// default implementation: do nothing
return AP4_SUCCESS;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.h
index 0cac374ae..2e7b4186d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Processor.h
@@ -50,40 +50,37 @@ struct AP4_MoofLocator;
/*----------------------------------------------------------------------
| AP4_Processor
+---------------------------------------------------------------------*/
-class AP4_Processor
-{
+class AP4_Processor {
public:
/**
* Abstract class that defines the interface implemented by progress
* listeners. A progress listener is called during the AP4_Processor::Process()
* method to notify of progres information.
*/
- class ProgressListener
- {
+ class ProgressListener {
public:
virtual ~ProgressListener() {}
/**
* This method is called during the call to AP4_Processor::Process() to
- * notify of the progress of the operation. If this method returns an
+ * notify of the progress of the operation. If this method returns an
* error result, processing is aborted.
* @param step Ordinal of the current progress step.
* @param total Total number of steps.
- * @return A result code. If this method returns AP4_SUCCESS, the
+ * @return A result code. If this method returns AP4_SUCCESS, the
* processing continues. If an error code is returned, the processing
* is aborted.
*/
- virtual AP4_Result OnProgress(unsigned int step,
+ virtual AP4_Result OnProgress(unsigned int step,
unsigned int total) = 0;
};
/**
* Abstract class that defines the interface implemented by concrete
- * track handlers. A track handler is responsible for processing a
+ * track handlers. A track handler is responsible for processing a
* track and its media samples.
*/
- class TrackHandler
- {
+ class TrackHandler {
public:
/**
* Default destructor.
@@ -94,20 +91,14 @@ public:
* A track handler may override this method if it needs to modify
* the track atoms before processing the track samples.
*/
- virtual AP4_Result ProcessTrack()
- {
- return AP4_SUCCESS;
- }
+ virtual AP4_Result ProcessTrack() { return AP4_SUCCESS; }
/**
* Returns the size of a sample after processing.
* @param sample Sample of which the processed size is requested.
* @return Size of the sample data after processing.
*/
- virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample)
- {
- return sample.GetSize();
- }
+ virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample) { return sample.GetSize(); }
/**
* Process the data of one sample.
@@ -121,11 +112,10 @@ public:
/**
* Abstract class that defines the interface implemented by concrete
- * fragment handlers. A fragment handler is responsible for processing a
+ * fragment handlers. A fragment handler is responsible for processing a
* fragment and its media samples.
*/
- class FragmentHandler
- {
+ class FragmentHandler {
public:
/**
* Default destructor.
@@ -136,30 +126,21 @@ public:
* A fragment handler may override this method if it needs to modify
* the fragment atoms before processing the fragment samples.
*/
- virtual AP4_Result ProcessFragment()
- {
- return AP4_SUCCESS;
- }
+ virtual AP4_Result ProcessFragment() { return AP4_SUCCESS; }
/**
* A fragment handler may override this method if it needs to modify
* the fragment atoms after processing the fragment samples.
* NOTE: this method MUST NOT change the size of any of the atoms.
*/
- virtual AP4_Result FinishFragment()
- {
- return AP4_ERROR_NOT_SUPPORTED;
- }
+ virtual AP4_Result FinishFragment() { return AP4_ERROR_NOT_SUPPORTED; }
/**
* Returns the size of a sample after processing.
* @param sample Sample of which the processed size is requested.
* @return Size of the sample data after processing.
*/
- virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample)
- {
- return sample.GetSize();
- }
+ virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample) { return sample.GetSize(); }
/**
* Process the data of one sample.
@@ -174,10 +155,7 @@ public:
/**
* Default destructor
*/
- virtual ~AP4_Processor()
- {
- m_ExternalTrackData.DeleteReferences();
- }
+ virtual ~AP4_Processor() { m_ExternalTrackData.DeleteReferences(); }
/**
* Process the input stream into an output stream.
@@ -185,13 +163,13 @@ public:
* @param output Output stream to which the processed input
* will be written.
* @param listener Pointer to a listener, or NULL. The listener
- * will be called one or more times before this method returns,
+ * will be called one or more times before this method returns,
* with progress information.
*/
- AP4_Result Process(AP4_ByteStream& input,
+ AP4_Result Process(AP4_ByteStream& input,
AP4_ByteStream& output,
ProgressListener* listener = NULL,
- AP4_AtomFactory& atom_factory =
+ AP4_AtomFactory& atom_factory =
AP4_DefaultAtomFactory::Instance);
/**
@@ -199,7 +177,7 @@ public:
* It is called just after the input stream has been parsed into
* an atom tree, before the processing of the tracks.
* @param top_level Container atom containing all the atoms parsed
- * from the input stream. Note that this atom does not actually
+ * from the input stream. Note that this atom does not actually
* exist in the file; it is a synthetised container created for the
* purpose of holding together all the input's top-level atoms.
*/
@@ -218,52 +196,41 @@ public:
* This method can be overridden by concrete subclasses.
* It is called once for each track in the input file.
* @param track Pointer to the track for which a handler should be
- * created.
- * @return A pointer to a track handler, or NULL if no handler
+ * created.
+ * @return A pointer to a track handler, or NULL if no handler
* needs to be created for that track.
*/
- virtual TrackHandler* CreateTrackHandler(AP4_TrakAtom* /*trak*/)
- {
- return NULL;
- }
+ virtual TrackHandler* CreateTrackHandler(AP4_TrakAtom* /*trak*/) { return NULL; }
/**
* This method can be overridden by concrete subclasses.
* It is called once for each fragment in the input file.
* @param track Pointer to the fragment for which a handler should be
- * created.
- * @return A pointer to a fragment handler, or NULL if no handler
+ * created.
+ * @return A pointer to a fragment handler, or NULL if no handler
* needs to be created for that fragment.
*/
- virtual FragmentHandler* CreateFragmentHandler(AP4_ContainerAtom* /*traf*/)
- {
- return NULL;
- }
-
+ virtual FragmentHandler* CreateFragmentHandler(AP4_ContainerAtom* /*traf*/) { return NULL; }
+
protected:
- class ExternalTrackData
- {
+ class ExternalTrackData {
public:
ExternalTrackData(unsigned int track_id, AP4_ByteStream* media_data) :
- m_TrackId(track_id), m_MediaData(media_data)
- {
+ m_TrackId(track_id), m_MediaData(media_data) {
media_data->AddReference();
}
- ~ExternalTrackData()
- {
- m_MediaData->Release();
- }
+ ~ExternalTrackData() { m_MediaData->Release(); }
unsigned int m_TrackId;
AP4_ByteStream* m_MediaData;
};
- AP4_Result ProcessFragments(AP4_MoovAtom* moov,
- AP4_List<AP4_MoofLocator>& moofs,
+ AP4_Result ProcessFragments(AP4_MoovAtom* moov,
+ AP4_List<AP4_MoofLocator>& moofs,
AP4_ContainerAtom* mfra,
- AP4_ByteStream& input,
+ AP4_ByteStream& input,
AP4_ByteStream& output);
-
-
+
+
AP4_List<ExternalTrackData> m_ExternalTrackData;
};
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.cpp
index d7b6a7f14..cf918b3f9 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.cpp
@@ -57,9 +57,9 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_ProtectedSampleDescription)
| AP4_EncaSampleEntry::AP4_EncaSampleEntry
+---------------------------------------------------------------------*/
AP4_EncaSampleEntry::AP4_EncaSampleEntry(AP4_UI32 type,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_Size size,
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_AudioSampleEntry(type, size, stream, atom_factory)
{
}
@@ -68,8 +68,8 @@ AP4_EncaSampleEntry::AP4_EncaSampleEntry(AP4_UI32 type,
| AP4_EncaSampleEntry::AP4_EncaSampleEntry
+---------------------------------------------------------------------*/
AP4_EncaSampleEntry::AP4_EncaSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_AudioSampleEntry(AP4_ATOM_TYPE_ENCA, size, stream, atom_factory)
{
}
@@ -89,34 +89,30 @@ AP4_EncaSampleEntry::ToSampleDescription()
// get the scheme info
AP4_SchmAtom* schm = (AP4_SchmAtom*)FindChild("sinf/schm");
- AP4_UI32 original_format = frma ? frma->GetOriginalFormat() : AP4_ATOM_TYPE_MP4A;
- if(schm)
- {
+ AP4_UI32 original_format = frma?frma->GetOriginalFormat():AP4_ATOM_TYPE_MP4A;
+ if (schm) {
// create the original sample description
return new AP4_ProtectedSampleDescription(
- m_Type,
- ToTargetSampleDescription(original_format),
- original_format,
- schm->GetSchemeType(),
- schm->GetSchemeVersion(),
- schm->GetSchemeUri().GetChars(),
- schi);
- }
- else if(schi)
- {
+ m_Type,
+ ToTargetSampleDescription(original_format),
+ original_format,
+ schm->GetSchemeType(),
+ schm->GetSchemeVersion(),
+ schm->GetSchemeUri().GetChars(),
+ schi);
+ } else if (schi) {
// try to see if we can guess the protection scheme from the 'schi' contents
AP4_Atom* odkm = schi->GetChild(AP4_ATOM_TYPE_ODKM);
- if(odkm)
- {
+ if (odkm) {
// create the original sample description
return new AP4_ProtectedSampleDescription(
- m_Type,
- ToTargetSampleDescription(original_format),
- original_format,
- AP4_PROTECTION_SCHEME_TYPE_OMA,
- AP4_PROTECTION_SCHEME_VERSION_OMA_20,
- NULL,
- schi);
+ m_Type,
+ ToTargetSampleDescription(original_format),
+ original_format,
+ AP4_PROTECTION_SCHEME_TYPE_OMA,
+ AP4_PROTECTION_SCHEME_VERSION_OMA_20,
+ NULL,
+ schi);
}
}
@@ -130,33 +126,29 @@ AP4_EncaSampleEntry::ToSampleDescription()
AP4_SampleDescription*
AP4_EncaSampleEntry::ToTargetSampleDescription(AP4_UI32 format)
{
- switch(format)
- {
- case AP4_ATOM_TYPE_MP4A:
- {
- AP4_EsdsAtom* esds = AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS));
- if(esds == NULL)
- {
- // check if this is a quicktime style sample description
- if(m_QtVersion > 0)
- {
- esds = AP4_DYNAMIC_CAST(AP4_EsdsAtom, FindChild("wave/esds"));
+ switch (format) {
+ case AP4_ATOM_TYPE_MP4A: {
+ AP4_EsdsAtom* esds = AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS));
+ if (esds == NULL) {
+ // check if this is a quicktime style sample description
+ if (m_QtVersion > 0) {
+ esds = AP4_DYNAMIC_CAST(AP4_EsdsAtom, FindChild("wave/esds"));
+ }
}
+ return new AP4_MpegAudioSampleDescription(
+ GetSampleRate(),
+ GetSampleSize(),
+ GetChannelCount(),
+ esds);
}
- return new AP4_MpegAudioSampleDescription(
- GetSampleRate(),
- GetSampleSize(),
- GetChannelCount(),
- esds);
- }
-
- default:
- return new AP4_GenericAudioSampleDescription(
- format,
- GetSampleRate(),
- GetSampleSize(),
- GetChannelCount(),
- this);
+
+ default:
+ return new AP4_GenericAudioSampleDescription(
+ format,
+ GetSampleRate(),
+ GetSampleSize(),
+ GetChannelCount(),
+ this);
}
}
@@ -164,9 +156,9 @@ AP4_EncaSampleEntry::ToTargetSampleDescription(AP4_UI32 format)
| AP4_EncvSampleEntry::AP4_EncvSampleEntry
+---------------------------------------------------------------------*/
AP4_EncvSampleEntry::AP4_EncvSampleEntry(AP4_UI32 type,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_Size size,
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_VisualSampleEntry(type, size, stream, atom_factory)
{
}
@@ -175,8 +167,8 @@ AP4_EncvSampleEntry::AP4_EncvSampleEntry(AP4_UI32 type,
| AP4_EncvSampleEntry::AP4_EncvSampleEntry
+---------------------------------------------------------------------*/
AP4_EncvSampleEntry::AP4_EncvSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_VisualSampleEntry(AP4_ATOM_TYPE_ENCV, size, stream, atom_factory)
{
}
@@ -196,34 +188,30 @@ AP4_EncvSampleEntry::ToSampleDescription()
// get the scheme info
AP4_SchmAtom* schm = (AP4_SchmAtom*)FindChild("sinf/schm");
- AP4_UI32 original_format = frma ? frma->GetOriginalFormat() : AP4_ATOM_TYPE_MP4V;
- if(schm)
- {
+ AP4_UI32 original_format = frma?frma->GetOriginalFormat():AP4_ATOM_TYPE_MP4V;
+ if (schm) {
// create the sample description
return new AP4_ProtectedSampleDescription(
- m_Type,
- ToTargetSampleDescription(original_format),
- original_format,
- schm->GetSchemeType(),
- schm->GetSchemeVersion(),
- schm->GetSchemeUri().GetChars(),
- schi);
- }
- else if(schi)
- {
+ m_Type,
+ ToTargetSampleDescription(original_format),
+ original_format,
+ schm->GetSchemeType(),
+ schm->GetSchemeVersion(),
+ schm->GetSchemeUri().GetChars(),
+ schi);
+ } else if (schi) {
// try to see if we can guess the protection scheme from the 'schi' contents
AP4_Atom* odkm = schi->GetChild(AP4_ATOM_TYPE_ODKM);
- if(odkm)
- {
+ if (odkm) {
// create the original sample description
return new AP4_ProtectedSampleDescription(
- m_Type,
- ToTargetSampleDescription(original_format),
- original_format,
- AP4_PROTECTION_SCHEME_TYPE_OMA,
- AP4_PROTECTION_SCHEME_VERSION_OMA_20,
- NULL,
- schi);
+ m_Type,
+ ToTargetSampleDescription(original_format),
+ original_format,
+ AP4_PROTECTION_SCHEME_TYPE_OMA,
+ AP4_PROTECTION_SCHEME_VERSION_OMA_20,
+ NULL,
+ schi);
}
}
@@ -238,32 +226,31 @@ AP4_EncvSampleEntry::ToSampleDescription()
AP4_SampleDescription*
AP4_EncvSampleEntry::ToTargetSampleDescription(AP4_UI32 format)
{
- switch(format)
- {
- case AP4_ATOM_TYPE_AVC1:
- return new AP4_AvcSampleDescription(
- m_Width,
- m_Height,
- m_Depth,
- m_CompressorName.GetChars(),
- this);
-
- case AP4_ATOM_TYPE_MP4V:
- return new AP4_MpegVideoSampleDescription(
- m_Width,
- m_Height,
- m_Depth,
- m_CompressorName.GetChars(),
- AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS)));
-
- default:
- return new AP4_GenericVideoSampleDescription(
- format,
- m_Width,
- m_Height,
- m_Depth,
- m_CompressorName.GetChars(),
- this);
+ switch (format) {
+ case AP4_ATOM_TYPE_AVC1:
+ return new AP4_AvcSampleDescription(
+ m_Width,
+ m_Height,
+ m_Depth,
+ m_CompressorName.GetChars(),
+ this);
+
+ case AP4_ATOM_TYPE_MP4V:
+ return new AP4_MpegVideoSampleDescription(
+ m_Width,
+ m_Height,
+ m_Depth,
+ m_CompressorName.GetChars(),
+ AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS)));
+
+ default:
+ return new AP4_GenericVideoSampleDescription(
+ format,
+ m_Width,
+ m_Height,
+ m_Depth,
+ m_CompressorName.GetChars(),
+ this);
}
}
@@ -271,8 +258,8 @@ AP4_EncvSampleEntry::ToTargetSampleDescription(AP4_UI32 format)
| AP4_DrmsSampleEntry::AP4_DrmsSampleEntry
+---------------------------------------------------------------------*/
AP4_DrmsSampleEntry::AP4_DrmsSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_EncaSampleEntry(AP4_ATOM_TYPE_DRMS, size, stream, atom_factory)
{
}
@@ -281,8 +268,8 @@ AP4_DrmsSampleEntry::AP4_DrmsSampleEntry(AP4_Size size,
| AP4_DrmiSampleEntry::AP4_DrmiSampleEntry
+---------------------------------------------------------------------*/
AP4_DrmiSampleEntry::AP4_DrmiSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_EncvSampleEntry(AP4_ATOM_TYPE_DRMI, size, stream, atom_factory)
{
}
@@ -300,12 +287,9 @@ AP4_ProtectionSchemeInfo::~AP4_ProtectionSchemeInfo()
+---------------------------------------------------------------------*/
AP4_ProtectionSchemeInfo::AP4_ProtectionSchemeInfo(AP4_ContainerAtom* schi)
{
- if(schi)
- {
+ if (schi) {
m_SchiAtom = (AP4_ContainerAtom*)schi->Clone();
- }
- else
- {
+ } else {
m_SchiAtom = NULL;
}
}
@@ -328,16 +312,13 @@ AP4_ProtectionKeyMap::~AP4_ProtectionKeyMap()
/*----------------------------------------------------------------------
| AP4_ProtectionKeyMap::SetKey
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_ProtectionKeyMap::SetKey(AP4_UI32 track_id, const AP4_UI08* key, const AP4_UI08* iv)
{
KeyEntry* entry = GetEntry(track_id);
- if(entry == NULL)
- {
+ if (entry == NULL) {
m_KeyEntries.Add(new KeyEntry(track_id, key, iv));
- }
- else
- {
+ } else {
entry->SetKey(key, iv);
}
@@ -347,12 +328,11 @@ AP4_ProtectionKeyMap::SetKey(AP4_UI32 track_id, const AP4_UI08* key, const AP4_U
/*----------------------------------------------------------------------
| AP4_ProtectionKeyMap::SetKey
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_ProtectionKeyMap::SetKeys(const AP4_ProtectionKeyMap& key_map)
{
AP4_List<KeyEntry>::Item* item = key_map.m_KeyEntries.FirstItem();
- while(item)
- {
+ while (item) {
KeyEntry* entry = item->GetData();
m_KeyEntries.Add(new KeyEntry(entry->m_TrackId,
entry->m_Key,
@@ -365,20 +345,17 @@ AP4_ProtectionKeyMap::SetKeys(const AP4_ProtectionKeyMap& key_map)
/*----------------------------------------------------------------------
| AP4_ProtectionKeyMap::GetKeyIv
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ProtectionKeyMap::GetKeyAndIv(AP4_UI32 track_id,
- const AP4_UI08*& key,
+AP4_Result
+AP4_ProtectionKeyMap::GetKeyAndIv(AP4_UI32 track_id,
+ const AP4_UI08*& key,
const AP4_UI08*& iv)
{
KeyEntry* entry = GetEntry(track_id);
- if(entry)
- {
+ if (entry) {
key = entry->m_Key;
iv = entry->m_IV;
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_NO_SUCH_ITEM;
}
}
@@ -386,16 +363,13 @@ AP4_ProtectionKeyMap::GetKeyAndIv(AP4_UI32 track_id,
/*----------------------------------------------------------------------
| AP4_ProtectionKeyMap::GetKey
+---------------------------------------------------------------------*/
-const AP4_UI08*
+const AP4_UI08*
AP4_ProtectionKeyMap::GetKey(AP4_UI32 track_id) const
{
KeyEntry* entry = GetEntry(track_id);
- if(entry)
- {
+ if (entry) {
return entry->m_Key;
- }
- else
- {
+ } else {
return NULL;
}
}
@@ -407,10 +381,9 @@ AP4_ProtectionKeyMap::KeyEntry*
AP4_ProtectionKeyMap::GetEntry(AP4_UI32 track_id) const
{
AP4_List<KeyEntry>::Item* item = m_KeyEntries.FirstItem();
- while(item)
- {
+ while (item) {
KeyEntry* entry = (KeyEntry*)item->GetData();
- if(entry->m_TrackId == track_id) return entry;
+ if (entry->m_TrackId == track_id) return entry;
item = item->GetNext();
}
@@ -420,9 +393,9 @@ AP4_ProtectionKeyMap::GetEntry(AP4_UI32 track_id) const
/*----------------------------------------------------------------------
| AP4_ProtectionKeyMap::KeyEntry::KeyEntry
+---------------------------------------------------------------------*/
-AP4_ProtectionKeyMap::KeyEntry::KeyEntry(AP4_UI32 track_id,
- const AP4_UI08* key,
- const AP4_UI08* iv /* = NULL */) :
+AP4_ProtectionKeyMap::KeyEntry::KeyEntry(AP4_UI32 track_id,
+ const AP4_UI08* key,
+ const AP4_UI08* iv /* = NULL */) :
m_TrackId(track_id)
{
SetKey(key, iv);
@@ -435,12 +408,9 @@ void
AP4_ProtectionKeyMap::KeyEntry::SetKey(const AP4_UI08* key, const AP4_UI08* iv)
{
AP4_CopyMemory(m_Key, key, sizeof(m_Key));
- if(iv)
- {
+ if (iv) {
AP4_CopyMemory(m_IV, iv, sizeof(m_IV));
- }
- else
- {
+ } else {
AP4_SetMemory(m_IV, 0, sizeof(m_IV));
}
}
@@ -457,8 +427,8 @@ AP4_TrackPropertyMap::~AP4_TrackPropertyMap()
| AP4_TrackPropertyMap::SetProperty
+---------------------------------------------------------------------*/
AP4_Result
-AP4_TrackPropertyMap::SetProperty(AP4_UI32 track_id,
- const char* name,
+AP4_TrackPropertyMap::SetProperty(AP4_UI32 track_id,
+ const char* name,
const char* value)
{
return m_Entries.Add(new Entry(track_id, name, value));
@@ -467,12 +437,11 @@ AP4_TrackPropertyMap::SetProperty(AP4_UI32 track_id,
/*----------------------------------------------------------------------
| AP4_TrackPropertyMap::SetProperties
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_TrackPropertyMap::SetProperties(const AP4_TrackPropertyMap& properties)
{
AP4_List<Entry>::Item* item = properties.m_Entries.FirstItem();
- while(item)
- {
+ while (item) {
Entry* entry = item->GetData();
m_Entries.Add(new Entry(entry->m_TrackId,
entry->m_Name.GetChars(),
@@ -489,12 +458,10 @@ const char*
AP4_TrackPropertyMap::GetProperty(AP4_UI32 track_id, const char* name)
{
AP4_List<Entry>::Item* item = m_Entries.FirstItem();
- while(item)
- {
+ while (item) {
Entry* entry = item->GetData();
- if(entry->m_TrackId == track_id &&
- AP4_CompareStrings(entry->m_Name.GetChars(), name) == 0)
- {
+ if (entry->m_TrackId == track_id &&
+ AP4_CompareStrings(entry->m_Name.GetChars(), name) == 0) {
return entry->m_Value.GetChars();
}
item = item->GetNext();
@@ -507,76 +474,69 @@ AP4_TrackPropertyMap::GetProperty(AP4_UI32 track_id, const char* name)
/*----------------------------------------------------------------------
| AP4_TrackPropertyMap::GetTextualHeaders
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_TrackPropertyMap::GetTextualHeaders(AP4_UI32 track_id, AP4_DataBuffer& textual_headers)
{
AP4_Size buffer_size = 0;
AP4_Result result = AP4_SUCCESS;
AP4_Byte* data_buffer;
-
+
// get the size needed for the textual headers
AP4_List<Entry>::Item* item = m_Entries.FirstItem();
- while(item)
- {
+ while (item) {
Entry* entry = item->GetData();
- if(entry->m_TrackId == track_id)
- {
+ if (entry->m_TrackId == track_id) {
const char* name = entry->m_Name.GetChars();
- if(AP4_CompareStrings(name, "ContentId") != 0 &&
- AP4_CompareStrings(name, "RightsIssuerUrl") != 0 &&
- AP4_CompareStrings(name, "KID") != 0)
- {
- buffer_size += (entry->m_Name.GetLength() +
+ if (AP4_CompareStrings(name, "ContentId") != 0 &&
+ AP4_CompareStrings(name, "RightsIssuerUrl") != 0 &&
+ AP4_CompareStrings(name, "KID") != 0) {
+ buffer_size += (entry->m_Name.GetLength() +
entry->m_Value.GetLength() +
- 2); // colon + nul
-
- }
+ 2); // colon + nul
+
+ }
}
- item = item->GetNext();
+ item = item->GetNext();
}
-
+
result = textual_headers.SetDataSize(buffer_size);
AP4_CHECK(result);
-
+
data_buffer = textual_headers.UseData();
-
+
// set the textual headers
item = m_Entries.FirstItem();
- while(item)
- {
+ while (item) {
Entry* entry = item->GetData();
- if(entry->m_TrackId == track_id)
- {
+ if (entry->m_TrackId == track_id) {
const char* name = entry->m_Name.GetChars();
const char* value = NULL;
AP4_Size name_len = 0;
AP4_Size value_len = 0;
-
- if(AP4_CompareStrings(name, "ContentId") != 0 &&
- AP4_CompareStrings(name, "RightsIssuerUrl") != 0 &&
- AP4_CompareStrings(name, "KID") != 0)
- {
+
+ if (AP4_CompareStrings(name, "ContentId") != 0 &&
+ AP4_CompareStrings(name, "RightsIssuerUrl") != 0 &&
+ AP4_CompareStrings(name, "KID") != 0) {
name_len = entry->m_Name.GetLength();
value = entry->m_Value.GetChars();
- value_len = entry->m_Value.GetLength();
-
+ value_len = entry->m_Value.GetLength();
+
// format is name:value\0
- if(name && value)
- {
+ if (name && value) {
AP4_CopyMemory(data_buffer, name, name_len);
data_buffer[name_len] = ':';
- data_buffer += (1 + name_len);
+ data_buffer += (1+name_len);
AP4_CopyMemory(data_buffer, value, value_len);
data_buffer[value_len] = '\0';
- data_buffer += (1 + value_len);
- }
- }
- }
- item = item->GetNext();
+ data_buffer += (1+value_len);
+ }
+ }
+ }
+ item = item->GetNext();
}
-
+
// success path
- return AP4_SUCCESS;
+ return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
@@ -608,7 +568,7 @@ AP4_ProtectedSampleDescription::AP4_ProtectedSampleDescription(
AP4_ProtectedSampleDescription::~AP4_ProtectedSampleDescription()
{
delete m_SchemeInfo;
- if(m_OriginalSampleDescriptionIsOwned) delete m_OriginalSampleDescription;
+ if (m_OriginalSampleDescriptionIsOwned) delete m_OriginalSampleDescription;
}
/*----------------------------------------------------------------------
@@ -618,33 +578,32 @@ AP4_Atom*
AP4_ProtectedSampleDescription::ToAtom() const
{
// construct the atom for the original sample description
- if(m_OriginalSampleDescription == NULL) return NULL;
+ if (m_OriginalSampleDescription == NULL) return NULL;
AP4_Atom* atom = m_OriginalSampleDescription->ToAtom();
-
+
// switch the atom type
atom->SetType(m_Format);
// check that the constructed atom is a container
AP4_ContainerAtom* container = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
- if(container == NULL) return atom; // not a container ?? return now.
-
+ if (container == NULL) return atom; // not a container ?? return now.
+
// create the sinf atom
AP4_ContainerAtom* sinf = new AP4_ContainerAtom(AP4_ATOM_TYPE_SINF);
-
+
// create and add a frma atom
AP4_FrmaAtom* frma = new AP4_FrmaAtom(m_OriginalFormat);
sinf->AddChild(frma);
-
+
// create and add a schm atom
AP4_SchmAtom* schm = new AP4_SchmAtom(m_SchemeType, m_SchemeVersion, m_SchemeUri.GetChars());
sinf->AddChild(schm);
// add the schi atom
- if(m_SchemeInfo && m_SchemeInfo->GetSchiAtom())
- {
+ if (m_SchemeInfo && m_SchemeInfo->GetSchiAtom()) {
sinf->AddChild(m_SchemeInfo->GetSchiAtom()->Clone());
}
-
+
// add the sinf to the returned atom
container->AddChild(sinf);
@@ -654,61 +613,56 @@ AP4_ProtectedSampleDescription::ToAtom() const
/*----------------------------------------------------------------------
| AP4_SampleDecrypter:Create
+---------------------------------------------------------------------*/
-AP4_SampleDecrypter*
+AP4_SampleDecrypter*
AP4_SampleDecrypter::Create(AP4_ProtectedSampleDescription* sample_description,
const AP4_UI08* key,
AP4_Size key_size,
AP4_BlockCipherFactory* block_cipher_factory)
{
- if(sample_description == NULL || key == NULL) return NULL;
+ if (sample_description == NULL || key == NULL) return NULL;
// select the block cipher factory
- if(block_cipher_factory == NULL)
- {
+ if (block_cipher_factory == NULL) {
block_cipher_factory = &AP4_DefaultBlockCipherFactory::Instance;
}
- switch(sample_description->GetSchemeType())
- {
- case AP4_PROTECTION_SCHEME_TYPE_OMA:
- {
- AP4_OmaDcfSampleDecrypter* decrypter = NULL;
- AP4_Result result = AP4_OmaDcfSampleDecrypter::Create(sample_description,
- key,
- key_size,
- block_cipher_factory,
- decrypter);
- if(AP4_FAILED(result)) return NULL;
- return decrypter;
- }
-
- case AP4_PROTECTION_SCHEME_TYPE_IAEC:
- {
- AP4_IsmaCipher* decrypter = NULL;
- AP4_Result result = AP4_IsmaCipher::CreateSampleDecrypter(sample_description,
- key,
- key_size,
- block_cipher_factory,
- decrypter);
- if(AP4_FAILED(result)) return NULL;
- return decrypter;
- }
+ switch(sample_description->GetSchemeType()) {
+ case AP4_PROTECTION_SCHEME_TYPE_OMA: {
+ AP4_OmaDcfSampleDecrypter* decrypter = NULL;
+ AP4_Result result = AP4_OmaDcfSampleDecrypter::Create(sample_description,
+ key,
+ key_size,
+ block_cipher_factory,
+ decrypter);
+ if (AP4_FAILED(result)) return NULL;
+ return decrypter;
+ }
- case AP4_PROTECTION_SCHEME_TYPE_PIFF:
- {
- AP4_PiffSampleDecrypter* decrypter = NULL;
- AP4_Result result = AP4_PiffSampleDecrypter::Create(sample_description,
- NULL,
- key,
- key_size,
- block_cipher_factory,
- decrypter);
- if(AP4_FAILED(result)) return NULL;
- return decrypter;
- }
+ case AP4_PROTECTION_SCHEME_TYPE_IAEC: {
+ AP4_IsmaCipher* decrypter = NULL;
+ AP4_Result result = AP4_IsmaCipher::CreateSampleDecrypter(sample_description,
+ key,
+ key_size,
+ block_cipher_factory,
+ decrypter);
+ if (AP4_FAILED(result)) return NULL;
+ return decrypter;
+ }
- default:
- return NULL;
+ case AP4_PROTECTION_SCHEME_TYPE_PIFF: {
+ AP4_PiffSampleDecrypter* decrypter = NULL;
+ AP4_Result result = AP4_PiffSampleDecrypter::Create(sample_description,
+ NULL,
+ key,
+ key_size,
+ block_cipher_factory,
+ decrypter);
+ if (AP4_FAILED(result)) return NULL;
+ return decrypter;
+ }
+
+ default:
+ return NULL;
}
return NULL;
@@ -717,38 +671,35 @@ AP4_SampleDecrypter::Create(AP4_ProtectedSampleDescription* sample_description,
/*----------------------------------------------------------------------
| AP4_SampleDecrypter:Create
+---------------------------------------------------------------------*/
-AP4_SampleDecrypter*
+AP4_SampleDecrypter*
AP4_SampleDecrypter::Create(AP4_ProtectedSampleDescription* sample_description,
AP4_ContainerAtom* traf,
const AP4_UI08* key,
AP4_Size key_size,
AP4_BlockCipherFactory* block_cipher_factory)
{
- if(sample_description == NULL || traf == NULL || key == NULL) return NULL;
+ if (sample_description == NULL || traf == NULL || key == NULL) return NULL;
// select the block cipher factory
- if(block_cipher_factory == NULL)
- {
+ if (block_cipher_factory == NULL) {
block_cipher_factory = &AP4_DefaultBlockCipherFactory::Instance;
}
- switch(sample_description->GetSchemeType())
- {
- case AP4_PROTECTION_SCHEME_TYPE_PIFF:
- {
- AP4_PiffSampleDecrypter* decrypter = NULL;
- AP4_Result result = AP4_PiffSampleDecrypter::Create(sample_description,
- traf,
- key,
- key_size,
- block_cipher_factory,
- decrypter);
- if(AP4_FAILED(result)) return NULL;
- return decrypter;
- }
+ switch(sample_description->GetSchemeType()) {
+ case AP4_PROTECTION_SCHEME_TYPE_PIFF: {
+ AP4_PiffSampleDecrypter* decrypter = NULL;
+ AP4_Result result = AP4_PiffSampleDecrypter::Create(sample_description,
+ traf,
+ key,
+ key_size,
+ block_cipher_factory,
+ decrypter);
+ if (AP4_FAILED(result)) return NULL;
+ return decrypter;
+ }
- default:
- return NULL;
+ default:
+ return NULL;
}
return NULL;
@@ -761,18 +712,14 @@ AP4_StandardDecryptingProcessor::AP4_StandardDecryptingProcessor(
const AP4_ProtectionKeyMap* key_map /* = NULL */,
AP4_BlockCipherFactory* block_cipher_factory /* = NULL */)
{
- if(key_map)
- {
+ if (key_map) {
// copy the keys
m_KeyMap.SetKeys(*key_map);
}
-
- if(block_cipher_factory == NULL)
- {
+
+ if (block_cipher_factory == NULL) {
m_BlockCipherFactory = &AP4_DefaultBlockCipherFactory::Instance;
- }
- else
- {
+ } else {
m_BlockCipherFactory = block_cipher_factory;
}
}
@@ -780,28 +727,25 @@ AP4_StandardDecryptingProcessor::AP4_StandardDecryptingProcessor(
/*----------------------------------------------------------------------
| AP4_StandardDecryptingProcessor:Initialize
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_StandardDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
- AP4_ByteStream& /*stream*/,
- ProgressListener* /*listener*/)
+ AP4_ByteStream& /*stream*/,
+ ProgressListener* /*listener*/)
{
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
- if(ftyp)
- {
+ if (ftyp) {
// remove the atom, it will be replaced with a new one
top_level.RemoveChild(ftyp);
-
+
// keep the existing brand and compatible brands except for the ones we want to remove
AP4_Array<AP4_UI32> compatible_brands;
compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount());
- for(unsigned int i = 0; i < ftyp->GetCompatibleBrands().ItemCount(); i++)
- {
- if(ftyp->GetCompatibleBrands()[i] != AP4_OMA_DCF_BRAND_OPF2)
- {
+ for (unsigned int i=0; i<ftyp->GetCompatibleBrands().ItemCount(); i++) {
+ if (ftyp->GetCompatibleBrands()[i] != AP4_OMA_DCF_BRAND_OPF2) {
compatible_brands.Append(ftyp->GetCompatibleBrands()[i]);
}
}
-
+
// create a replacement for the major brand
top_level.AddChild(new AP4_FtypAtom(ftyp->GetMajorBrand(),
ftyp->GetMinorVersion(),
@@ -809,63 +753,57 @@ AP4_StandardDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
compatible_brands.ItemCount()), 0);
delete ftyp;
}
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_StandardDecryptingProcessor:CreateTrackHandler
+---------------------------------------------------------------------*/
-AP4_Processor::TrackHandler*
+AP4_Processor::TrackHandler*
AP4_StandardDecryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
{
// find the stsd atom
AP4_StsdAtom* stsd = AP4_DYNAMIC_CAST(AP4_StsdAtom, trak->FindChild("mdia/minf/stbl/stsd"));
// avoid tracks with no stsd atom (should not happen)
- if(stsd == NULL) return NULL;
+ if (stsd == NULL) return NULL;
// we only look at the first sample description
AP4_SampleDescription* desc = stsd->GetSampleDescription(0);
AP4_SampleEntry* entry = stsd->GetSampleEntry(0);
- if(desc == NULL || entry == NULL) return NULL;
- if(desc->GetType() == AP4_SampleDescription::TYPE_PROTECTED)
- {
+ if (desc == NULL || entry == NULL) return NULL;
+ if (desc->GetType() == AP4_SampleDescription::TYPE_PROTECTED) {
// create a handler for this track
- AP4_ProtectedSampleDescription* protected_desc =
+ AP4_ProtectedSampleDescription* protected_desc =
static_cast<AP4_ProtectedSampleDescription*>(desc);
- if(protected_desc->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_OMA)
- {
+ if (protected_desc->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_OMA) {
const AP4_UI08* key = m_KeyMap.GetKey(trak->GetId());
- if(key)
- {
+ if (key) {
AP4_OmaDcfTrackDecrypter* handler = NULL;
- AP4_Result result = AP4_OmaDcfTrackDecrypter::Create(key,
- AP4_CIPHER_BLOCK_SIZE,
- protected_desc,
- entry,
- m_BlockCipherFactory,
- handler);
- if(AP4_FAILED(result)) return NULL;
+ AP4_Result result = AP4_OmaDcfTrackDecrypter::Create(key,
+ AP4_CIPHER_BLOCK_SIZE,
+ protected_desc,
+ entry,
+ m_BlockCipherFactory,
+ handler);
+ if (AP4_FAILED(result)) return NULL;
return handler;
}
- }
- else if(protected_desc->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_IAEC)
- {
+ } else if (protected_desc->GetSchemeType() == AP4_PROTECTION_SCHEME_TYPE_IAEC) {
const AP4_UI08* key = m_KeyMap.GetKey(trak->GetId());
- if(key)
- {
+ if (key) {
AP4_IsmaTrackDecrypter* handler = NULL;
- AP4_Result result = AP4_IsmaTrackDecrypter::Create(key,
- AP4_CIPHER_BLOCK_SIZE,
- protected_desc,
- entry,
- m_BlockCipherFactory,
- handler);
- if(AP4_FAILED(result)) return NULL;
+ AP4_Result result = AP4_IsmaTrackDecrypter::Create(key,
+ AP4_CIPHER_BLOCK_SIZE,
+ protected_desc,
+ entry,
+ m_BlockCipherFactory,
+ handler);
+ if (AP4_FAILED(result)) return NULL;
return handler;
}
- }
+ }
}
return NULL;
@@ -889,39 +827,36 @@ AP4_DecryptingStream::Create(CipherMode mode,
stream = NULL;
// default cipher settings
- if(block_cipher_factory == NULL)
- {
+ if (block_cipher_factory == NULL) {
block_cipher_factory = &AP4_DefaultBlockCipherFactory::Instance;
}
-
+
// get the encrypted size (includes padding)
AP4_LargeSize encrypted_size = 0;
AP4_Result result = encrypted_stream.GetSize(encrypted_size);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// check IV
- if(iv == NULL || iv_size != 16) return AP4_ERROR_INVALID_PARAMETERS;
-
+ if (iv == NULL || iv_size != 16) return AP4_ERROR_INVALID_PARAMETERS;
+
// check that the encrypted size is consistent with the cipher mode
- if(mode == CIPHER_MODE_CBC)
- {
+ if (mode == CIPHER_MODE_CBC) {
// we need at least 32 bytes of data+padding
// we also need a multiple of the block size
- if(encrypted_size < 32 || ((encrypted_size % 16) != 0))
- {
+ if (encrypted_size < 32 || ((encrypted_size % 16) != 0)) {
return AP4_ERROR_INVALID_FORMAT;
}
}
-
+
// create the stream cipher
AP4_BlockCipher* block_cipher;
result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
- (mode == CIPHER_MODE_CTR ?
+ (mode == CIPHER_MODE_CTR ?
AP4_BlockCipher::ENCRYPT :
AP4_BlockCipher::DECRYPT),
key, key_size, block_cipher);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// keep a reference to the source stream
encrypted_stream.AddReference();
@@ -937,24 +872,23 @@ AP4_DecryptingStream::Create(CipherMode mode,
dec_stream->m_BufferFullness = 0;
dec_stream->m_BufferOffset = 0;
dec_stream->m_ReferenceCount = 1;
-
+
// create the cipher according to the mode
- switch(mode)
- {
- case CIPHER_MODE_CBC:
- dec_stream->m_StreamCipher = new AP4_CbcStreamCipher(block_cipher,
- AP4_StreamCipher::DECRYPT);
- break;
- case CIPHER_MODE_CTR:
- dec_stream->m_StreamCipher = new AP4_CtrStreamCipher(block_cipher,
- NULL,
- AP4_CIPHER_BLOCK_SIZE);
- break;
- default:
- // should never occur
- AP4_ASSERT(0);
+ switch (mode) {
+ case CIPHER_MODE_CBC:
+ dec_stream->m_StreamCipher = new AP4_CbcStreamCipher(block_cipher,
+ AP4_StreamCipher::DECRYPT);
+ break;
+ case CIPHER_MODE_CTR:
+ dec_stream->m_StreamCipher = new AP4_CtrStreamCipher(block_cipher,
+ NULL,
+ AP4_CIPHER_BLOCK_SIZE);
+ break;
+ default:
+ // should never occur
+ AP4_ASSERT(0);
}
-
+
// set the IV
dec_stream->m_StreamCipher->SetIV(iv);
@@ -973,7 +907,7 @@ AP4_DecryptingStream::~AP4_DecryptingStream()
/*----------------------------------------------------------------------
| AP4_DecryptingStream::AddReference
+---------------------------------------------------------------------*/
-void
+void
AP4_DecryptingStream::AddReference()
{
++m_ReferenceCount;
@@ -982,40 +916,37 @@ AP4_DecryptingStream::AddReference()
/*----------------------------------------------------------------------
| AP4_DecryptingStream::Release
+---------------------------------------------------------------------*/
-void
+void
AP4_DecryptingStream::Release()
{
- if(--m_ReferenceCount == 0) delete this;
+ if (--m_ReferenceCount == 0) delete this;
}
/*----------------------------------------------------------------------
| AP4_DecryptingStream::ReadPartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DecryptingStream::ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+AP4_Result
+AP4_DecryptingStream::ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read)
{
bytes_read = 0;
// never read more than what's available
- AP4_LargeSize available = m_CleartextSize - m_CleartextPosition;
- if(available < bytes_to_read)
- {
- if(available == 0)
- {
+ AP4_LargeSize available = m_CleartextSize-m_CleartextPosition;
+ if (available < bytes_to_read) {
+ if (available == 0) {
return AP4_ERROR_EOS;
}
bytes_to_read = (AP4_Size)available;
}
-
- if(m_BufferFullness)
- {
+
+ if (m_BufferFullness) {
// we have some leftovers
AP4_Size chunk = bytes_to_read;
- if(chunk > m_BufferFullness) chunk = m_BufferFullness;
+ if (chunk > m_BufferFullness) chunk = m_BufferFullness;
AP4_CopyMemory(buffer, &m_Buffer[m_BufferOffset], chunk);
- buffer = (char*)buffer + chunk;
+ buffer = (char*)buffer+chunk;
m_CleartextPosition += chunk;
available -= chunk;
bytes_to_read -= chunk;
@@ -1027,45 +958,36 @@ AP4_DecryptingStream::ReadPartial(void* buffer,
// seek to the right place in the input
m_EncryptedStream->Seek(m_EncryptedPosition);
- while(bytes_to_read)
- {
+ while (bytes_to_read) {
// read from the source
AP4_UI08 encrypted[16];
AP4_Size encrypted_read = 0;
AP4_Result result = m_EncryptedStream->ReadPartial(encrypted, 16, encrypted_read);
- if(result == AP4_ERROR_EOS)
- {
- if(bytes_read == 0)
- {
+ if (result == AP4_ERROR_EOS) {
+ if (bytes_read == 0) {
return AP4_ERROR_EOS;
- }
- else
- {
+ } else {
return AP4_SUCCESS;
}
- }
- else if(result != AP4_SUCCESS)
- {
+ } else if (result != AP4_SUCCESS) {
return result;
- }
- else
- {
+ } else {
m_EncryptedPosition += encrypted_read;
}
bool is_last_buffer = (m_EncryptedPosition >= m_EncryptedSize);
AP4_Size buffer_size = 16;
- result = m_StreamCipher->ProcessBuffer(encrypted,
- encrypted_read,
- m_Buffer,
+ result = m_StreamCipher->ProcessBuffer(encrypted,
+ encrypted_read,
+ m_Buffer,
&buffer_size,
is_last_buffer);
m_BufferOffset = 0;
m_BufferFullness = buffer_size;
AP4_Size chunk = bytes_to_read;
- if(chunk > m_BufferFullness) chunk = m_BufferFullness;
+ if (chunk > m_BufferFullness) chunk = m_BufferFullness;
AP4_CopyMemory(buffer, &m_Buffer[m_BufferOffset], chunk);
- buffer = (char*)buffer + chunk;
+ buffer = (char*)buffer+chunk;
m_CleartextPosition += chunk;
available -= chunk;
bytes_to_read -= chunk;
@@ -1080,9 +1002,9 @@ AP4_DecryptingStream::ReadPartial(void* buffer,
/*----------------------------------------------------------------------
| AP4_DecryptingStream::WritePartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DecryptingStream::WritePartial(const void* /* buffer */,
- AP4_Size /* bytes_to_write */,
+AP4_Result
+AP4_DecryptingStream::WritePartial(const void* /* buffer */,
+ AP4_Size /* bytes_to_write */,
AP4_Size& /* bytes_written */)
{
return AP4_ERROR_NOT_SUPPORTED;
@@ -1091,47 +1013,45 @@ AP4_DecryptingStream::WritePartial(const void* /* buffer */,
/*----------------------------------------------------------------------
| AP4_DecryptingStream::Seek
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_DecryptingStream::Seek(AP4_Position position)
{
AP4_Cardinal preroll = 0;
-
+
// check bounds
- if(position > m_CleartextSize)
- {
+ if (position > m_CleartextSize) {
return AP4_ERROR_INVALID_PARAMETERS;
}
-
+
// try to put the stream cipher at the right offset
AP4_CHECK(m_StreamCipher->SetStreamOffset(position, &preroll));
// seek in the source stream
- AP4_CHECK(m_EncryptedStream->Seek(position - preroll));
-
+ AP4_CHECK(m_EncryptedStream->Seek(position-preroll));
+
// if we need to, process the preroll bytes
- if(preroll > 0)
- {
+ if (preroll > 0) {
AP4_Size out_size = 0;
AP4_UI08 buffer[2*AP4_CIPHER_BLOCK_SIZE]; // bigger than preroll
AP4_CHECK(m_EncryptedStream->Read(buffer, preroll));
AP4_CHECK(m_StreamCipher->ProcessBuffer(buffer, preroll, buffer, &out_size));
- AP4_ASSERT(out_size == 0); // we're just feeding prerolled bytes,
- // there can be no output
+ AP4_ASSERT(out_size == 0); // we're just feeding prerolled bytes,
+ // there can be no output
}
-
+
// update the counters
m_CleartextPosition = position;
m_EncryptedPosition = position;
m_BufferFullness = 0;
m_BufferOffset = 0;
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_DecryptingStream::Tell
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_DecryptingStream::Tell(AP4_Position& position)
{
position = m_CleartextPosition;
@@ -1141,7 +1061,7 @@ AP4_DecryptingStream::Tell(AP4_Position& position)
/*----------------------------------------------------------------------
| AP4_DecryptingStream::GetSize
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_DecryptingStream::GetSize(AP4_LargeSize& size)
{
size = m_CleartextSize;
@@ -1168,25 +1088,24 @@ AP4_EncryptingStream::Create(CipherMode mode,
// get the cleartext size
AP4_LargeSize cleartext_size = 0;
AP4_Result result = cleartext_stream.GetSize(cleartext_size);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// check IV
- if(iv == NULL || iv_size != 16) return AP4_ERROR_INVALID_PARAMETERS;
-
+ if (iv == NULL || iv_size != 16) return AP4_ERROR_INVALID_PARAMETERS;
+
// compute the encrypted size
AP4_LargeSize encrypted_size = cleartext_size;
- if(mode == CIPHER_MODE_CBC)
- {
- encrypted_size += (16 - (cleartext_size % 16)); // with padding
+ if (mode == CIPHER_MODE_CBC) {
+ encrypted_size += (16-(cleartext_size%16)); // with padding
}
-
+
// create the stream cipher
AP4_BlockCipher* block_cipher;
result = block_cipher_factory->Create(AP4_BlockCipher::AES_128,
AP4_BlockCipher::ENCRYPT,
key, key_size, block_cipher);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// keep a reference to the source stream
cleartext_stream.AddReference();
@@ -1204,30 +1123,28 @@ AP4_EncryptingStream::Create(CipherMode mode,
enc_stream->m_ReferenceCount = 1;
// deal with the prepended IV if required
- if(prepend_iv)
- {
+ if (prepend_iv) {
enc_stream->m_EncryptedSize += 16;
enc_stream->m_BufferFullness = 16;
AP4_CopyMemory(enc_stream->m_Buffer, iv, 16);
}
-
+
// create the cipher according to the mode
- switch(mode)
- {
- case CIPHER_MODE_CBC:
- enc_stream->m_StreamCipher = new AP4_CbcStreamCipher(block_cipher,
- AP4_StreamCipher::ENCRYPT);
- break;
- case CIPHER_MODE_CTR:
- enc_stream->m_StreamCipher = new AP4_CtrStreamCipher(block_cipher,
- NULL,
- AP4_CIPHER_BLOCK_SIZE);
- break;
- default:
- // should never occur
- AP4_ASSERT(0);
+ switch (mode) {
+ case CIPHER_MODE_CBC:
+ enc_stream->m_StreamCipher = new AP4_CbcStreamCipher(block_cipher,
+ AP4_StreamCipher::ENCRYPT);
+ break;
+ case CIPHER_MODE_CTR:
+ enc_stream->m_StreamCipher = new AP4_CtrStreamCipher(block_cipher,
+ NULL,
+ AP4_CIPHER_BLOCK_SIZE);
+ break;
+ default:
+ // should never occur
+ AP4_ASSERT(0);
}
-
+
// set the IV
enc_stream->m_StreamCipher->SetIV(iv);
@@ -1246,7 +1163,7 @@ AP4_EncryptingStream::~AP4_EncryptingStream()
/*----------------------------------------------------------------------
| AP4_EncryptingStream::AddReference
+---------------------------------------------------------------------*/
-void
+void
AP4_EncryptingStream::AddReference()
{
++m_ReferenceCount;
@@ -1255,37 +1172,35 @@ AP4_EncryptingStream::AddReference()
/*----------------------------------------------------------------------
| AP4_EncryptingStream::Release
+---------------------------------------------------------------------*/
-void
+void
AP4_EncryptingStream::Release()
{
- if(--m_ReferenceCount == 0) delete this;
+ if (--m_ReferenceCount == 0) delete this;
}
/*----------------------------------------------------------------------
| AP4_EncryptingStream::ReadPartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_EncryptingStream::ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+AP4_Result
+AP4_EncryptingStream::ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read)
{
bytes_read = 0;
// never read more than what's available
- AP4_LargeSize available = m_EncryptedSize - m_EncryptedPosition;
- if(available < bytes_to_read)
- {
- if(available == 0) return AP4_ERROR_EOS;
+ AP4_LargeSize available = m_EncryptedSize-m_EncryptedPosition;
+ if (available < bytes_to_read) {
+ if (available == 0) return AP4_ERROR_EOS;
bytes_to_read = (AP4_Size)available;
}
-
- if(m_BufferFullness)
- {
+
+ if (m_BufferFullness) {
// we have some leftovers
AP4_Size chunk = bytes_to_read;
- if(chunk > m_BufferFullness) chunk = m_BufferFullness;
+ if (chunk > m_BufferFullness) chunk = m_BufferFullness;
AP4_CopyMemory(buffer, &m_Buffer[m_BufferOffset], chunk);
- buffer = (char*)buffer + chunk;
+ buffer = (char*)buffer+chunk;
m_EncryptedPosition += chunk;
available -= chunk;
bytes_to_read -= chunk;
@@ -1297,47 +1212,37 @@ AP4_EncryptingStream::ReadPartial(void* buffer,
// seek to the right place in the input
m_CleartextStream->Seek(m_CleartextPosition);
- while(bytes_to_read)
- {
+ while (bytes_to_read) {
// read from the source
AP4_UI08 cleartext[16];
AP4_Size cleartext_read = 0;
AP4_Result result = m_CleartextStream->ReadPartial(cleartext, 16, cleartext_read);
- if(result == AP4_ERROR_EOS)
- {
- if(bytes_read == 0)
- {
+ if (result == AP4_ERROR_EOS) {
+ if (bytes_read == 0) {
return AP4_ERROR_EOS;
- }
- else
- {
+ } else {
return AP4_SUCCESS;
}
- }
- else if(result != AP4_SUCCESS)
- {
+ } else if (result != AP4_SUCCESS) {
return result;
- }
- else
- {
+ } else {
m_CleartextPosition += cleartext_read;
}
bool is_last_buffer = (m_CleartextPosition >= m_CleartextSize);
AP4_Size buffer_size = 32; // enough for one block plus one block padding
- result = m_StreamCipher->ProcessBuffer(cleartext,
- cleartext_read,
- m_Buffer,
+ result = m_StreamCipher->ProcessBuffer(cleartext,
+ cleartext_read,
+ m_Buffer,
&buffer_size,
is_last_buffer);
m_BufferOffset = 0;
m_BufferFullness = buffer_size;
AP4_Size chunk = bytes_to_read;
- if(chunk > m_BufferFullness) chunk = m_BufferFullness;
- if(chunk)
- {
+ if (chunk > m_BufferFullness) chunk = m_BufferFullness;
+ if (chunk) {
AP4_CopyMemory(buffer, &m_Buffer[m_BufferOffset], chunk);
- buffer = (char*)buffer + chunk;
+ buffer = (char*)buffer+chunk;
m_EncryptedPosition += chunk;
available -= chunk;
bytes_to_read -= chunk;
@@ -1353,9 +1258,9 @@ AP4_EncryptingStream::ReadPartial(void* buffer,
/*----------------------------------------------------------------------
| AP4_EncryptingStream::WritePartial
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_EncryptingStream::WritePartial(const void* /* buffer */,
- AP4_Size /* bytes_to_write */,
+AP4_Result
+AP4_EncryptingStream::WritePartial(const void* /* buffer */,
+ AP4_Size /* bytes_to_write */,
AP4_Size& /* bytes_written */)
{
return AP4_ERROR_NOT_SUPPORTED;
@@ -1364,15 +1269,12 @@ AP4_EncryptingStream::WritePartial(const void* /* buffer */,
/*----------------------------------------------------------------------
| AP4_EncryptingStream::Seek
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_EncryptingStream::Seek(AP4_Position position)
{
- if(position == m_EncryptedPosition)
- {
+ if (position == m_EncryptedPosition) {
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_NOT_SUPPORTED;
}
}
@@ -1380,7 +1282,7 @@ AP4_EncryptingStream::Seek(AP4_Position position)
/*----------------------------------------------------------------------
| AP4_EncryptingStream::Tell
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_EncryptingStream::Tell(AP4_Position& position)
{
position = m_EncryptedPosition;
@@ -1390,7 +1292,7 @@ AP4_EncryptingStream::Tell(AP4_Position& position)
/*----------------------------------------------------------------------
| AP4_EncryptingStream::GetSize
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_EncryptingStream::GetSize(AP4_LargeSize& size)
{
size = m_EncryptedSize;
@@ -1415,21 +1317,19 @@ AP4_DefaultBlockCipherFactory::Create(AP4_BlockCipher::CipherType type,
// setup default return vaule
cipher = NULL;
- switch(type)
- {
- case AP4_BlockCipher::AES_128:
- // check cipher parameters
- if(key == NULL || key_size != AP4_AES_BLOCK_SIZE)
- {
- return AP4_ERROR_INVALID_PARAMETERS;
- }
+ switch (type) {
+ case AP4_BlockCipher::AES_128:
+ // check cipher parameters
+ if (key == NULL || key_size != AP4_AES_BLOCK_SIZE) {
+ return AP4_ERROR_INVALID_PARAMETERS;
+ }
- // create the cipher
- cipher = new AP4_AesBlockCipher(key, direction);
- return AP4_SUCCESS;
+ // create the cipher
+ cipher = new AP4_AesBlockCipher(key, direction);
+ return AP4_SUCCESS;
- default:
- // not supported
- return AP4_ERROR_NOT_SUPPORTED;
+ default:
+ // not supported
+ return AP4_ERROR_NOT_SUPPORTED;
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.h
index a7ff9f678..1979193ad 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Protection.h
@@ -50,7 +50,7 @@ class AP4_StreamCipher;
// this is fixed for now
const unsigned int AP4_PROTECTION_KEY_LENGTH = 16;
-const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_ITUNES = AP4_ATOM_TYPE('i', 't', 'u', 'n');
+const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_ITUNES = AP4_ATOM_TYPE('i','t','u','n');
/*----------------------------------------------------------------------
| AP4_EncaSampleEntry
@@ -71,7 +71,7 @@ public:
AP4_SampleDescription* ToSampleDescription();
// this method is used as a factory by the ISMACryp classes
- // NOTE: this should be named ToSampleDescription, but C++ has a
+ // NOTE: this should be named ToSampleDescription, but C++ has a
// problem with that because the base class does not have this
// overloaded method, but has another other one by that name
virtual AP4_SampleDescription* ToTargetSampleDescription(AP4_UI32 format);
@@ -96,7 +96,7 @@ public:
AP4_SampleDescription* ToSampleDescription();
// this method is used as a factory by the ISMACryp classes
- // NOTE: this should be named ToSampleDescription, but C++ has a
+ // NOTE: this should be named ToSampleDescription, but C++ has a
// problem with that because the base class does not have this
// overloaded method, but has another other one by that name
virtual AP4_SampleDescription* ToTargetSampleDescription(AP4_UI32 format);
@@ -144,8 +144,7 @@ public:
private:
// types
- class KeyEntry
- {
+ class KeyEntry {
public:
KeyEntry(AP4_UI32 track_id, const AP4_UI08* key, const AP4_UI08* iv = NULL);
void SetKey(const AP4_UI08* key, const AP4_UI08* iv);
@@ -172,18 +171,17 @@ public:
AP4_Result SetProperties(const AP4_TrackPropertyMap& properties);
const char* GetProperty(AP4_UI32 track_id, const char* name);
AP4_Result GetTextualHeaders(AP4_UI32 track_id, AP4_DataBuffer& buffer);
-
+
// destructor
virtual ~AP4_TrackPropertyMap();
private:
// types
- class Entry
- {
+ class Entry {
public:
Entry(AP4_UI32 track_id, const char* name, const char* value) :
- m_TrackId(track_id), m_Name(name), m_Value(value) {}
+ m_TrackId(track_id), m_Name(name), m_Value(value) {}
AP4_UI32 m_TrackId;
AP4_String m_Name;
AP4_String m_Value;
@@ -204,10 +202,7 @@ public:
virtual ~AP4_ProtectionSchemeInfo();
// accessors
- AP4_ContainerAtom* GetSchiAtom()
- {
- return m_SchiAtom;
- }
+ AP4_ContainerAtom* GetSchiAtom() { return m_SchiAtom; }
protected:
AP4_ContainerAtom* m_SchiAtom;
@@ -229,33 +224,19 @@ public:
AP4_UI32 scheme_version,
const char* scheme_uri,
AP4_ContainerAtom* schi_atom, // will be cloned
- bool transfer_ownership_of_original = true);
+ bool transfer_ownership_of_original=true);
~AP4_ProtectedSampleDescription();
-
+
// accessors
- AP4_SampleDescription* GetOriginalSampleDescription()
- {
+ AP4_SampleDescription* GetOriginalSampleDescription() {
return m_OriginalSampleDescription;
}
- AP4_UI32 GetOriginalFormat() const
- {
- return m_OriginalFormat;
- }
- AP4_UI32 GetSchemeType() const
- {
- return m_SchemeType;
- }
- AP4_UI32 GetSchemeVersion() const
- {
- return m_SchemeVersion;
- }
- const AP4_String& GetSchemeUri() const
- {
- return m_SchemeUri;
- }
- AP4_ProtectionSchemeInfo* GetSchemeInfo() const
- {
- return m_SchemeInfo;
+ AP4_UI32 GetOriginalFormat() const { return m_OriginalFormat; }
+ AP4_UI32 GetSchemeType() const { return m_SchemeType; }
+ AP4_UI32 GetSchemeVersion() const { return m_SchemeVersion; }
+ const AP4_String& GetSchemeUri() const { return m_SchemeUri; }
+ AP4_ProtectionSchemeInfo* GetSchemeInfo() const {
+ return m_SchemeInfo;
}
// implementation of abstract base class methods
@@ -279,20 +260,18 @@ class AP4_BlockCipher
{
public:
// types
- typedef enum
- {
+ typedef enum {
ENCRYPT,
DECRYPT
} CipherDirection;
- typedef enum
- {
+ typedef enum {
AES_128
} CipherType;
// constructor and destructor
virtual ~AP4_BlockCipher() {}
-
+
// methods
virtual AP4_Result ProcessBlock(const AP4_UI08* block_in, AP4_UI08* block_out) = 0;
};
@@ -356,14 +335,8 @@ public:
virtual ~AP4_SampleDecrypter() {}
// methods
- virtual AP4_Size GetDecryptedSampleSize(AP4_Sample& sample)
- {
- return sample.GetSize();
- }
- virtual AP4_Result SetSampleIndex(AP4_Ordinal /*index*/)
- {
- return AP4_SUCCESS;
- }
+ virtual AP4_Size GetDecryptedSampleSize(AP4_Sample& sample) { return sample.GetSize(); }
+ virtual AP4_Result SetSampleIndex(AP4_Ordinal /*index*/) { return AP4_SUCCESS; }
virtual AP4_Result DecryptSampleData(AP4_DataBuffer& data_in,
AP4_DataBuffer& data_out,
const AP4_UI08* iv = NULL) = 0;
@@ -380,11 +353,8 @@ public:
AP4_BlockCipherFactory* block_cipher_factory = NULL);
// accessors
- AP4_ProtectionKeyMap& GetKeyMap()
- {
- return m_KeyMap;
- }
-
+ AP4_ProtectionKeyMap& GetKeyMap() { return m_KeyMap; }
+
// methods
virtual AP4_Result Initialize(AP4_AtomParent& top_level,
AP4_ByteStream& stream,
@@ -400,11 +370,9 @@ private:
/*----------------------------------------------------------------------
| AP4_DecryptingStream
+---------------------------------------------------------------------*/
-class AP4_DecryptingStream : public AP4_ByteStream
-{
+class AP4_DecryptingStream : public AP4_ByteStream {
public:
- typedef enum
- {
+ typedef enum {
CIPHER_MODE_CTR,
CIPHER_MODE_CBC
} CipherMode;
@@ -420,11 +388,11 @@ public:
AP4_ByteStream*& stream);
// AP4_ByteStream methods
- virtual AP4_Result ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+ virtual AP4_Result ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read);
- virtual AP4_Result WritePartial(const void* buffer,
- AP4_Size bytes_to_write,
+ virtual AP4_Result WritePartial(const void* buffer,
+ AP4_Size bytes_to_write,
AP4_Size& bytes_written);
virtual AP4_Result Seek(AP4_Position position);
virtual AP4_Result Tell(AP4_Position& position);
@@ -456,11 +424,9 @@ private:
/*----------------------------------------------------------------------
| AP4_EncryptingStream
+---------------------------------------------------------------------*/
-class AP4_EncryptingStream : public AP4_ByteStream
-{
+class AP4_EncryptingStream : public AP4_ByteStream {
public:
- typedef enum
- {
+ typedef enum {
CIPHER_MODE_CTR,
CIPHER_MODE_CBC
} CipherMode;
@@ -476,11 +442,11 @@ public:
AP4_ByteStream*& stream);
// AP4_ByteStream methods
- virtual AP4_Result ReadPartial(void* buffer,
- AP4_Size bytes_to_read,
+ virtual AP4_Result ReadPartial(void* buffer,
+ AP4_Size bytes_to_read,
AP4_Size& bytes_read);
- virtual AP4_Result WritePartial(const void* buffer,
- AP4_Size bytes_to_write,
+ virtual AP4_Result WritePartial(const void* buffer,
+ AP4_Size bytes_to_write,
AP4_Size& bytes_written);
virtual AP4_Result Seek(AP4_Position position);
virtual AP4_Result Tell(AP4_Position& position);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Results.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Results.cpp
index 6dbd42fd8..1bb2c5cd8 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Results.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Results.cpp
@@ -39,55 +39,30 @@
const char*
AP4_ResultText(int result)
{
- switch(result)
- {
- case AP4_SUCCESS:
- return "AP4_SUCCESS";
- case AP4_FAILURE:
- return "AP4_FAILURE";
- case AP4_ERROR_OUT_OF_MEMORY:
- return "AP4_ERROR_OUT_OF_MEMORY";
- case AP4_ERROR_INVALID_PARAMETERS:
- return "AP4_ERROR_INVALID_PARAMETERS";
- case AP4_ERROR_NO_SUCH_FILE:
- return "AP4_ERROR_NO_SUCH_FILE";
- case AP4_ERROR_PERMISSION_DENIED:
- return "AP4_ERROR_PERMISSION_DENIED";
- case AP4_ERROR_CANNOT_OPEN_FILE:
- return "AP4_ERROR_CANNOT_OPEN_FILE";
- case AP4_ERROR_EOS:
- return "AP4_ERROR_EOS";
- case AP4_ERROR_WRITE_FAILED:
- return "AP4_ERROR_WRITE_FAILED";
- case AP4_ERROR_READ_FAILED:
- return "AP4_ERROR_READ_FAILED";
- case AP4_ERROR_INVALID_FORMAT:
- return "AP4_ERROR_INVALID_FORMAT";
- case AP4_ERROR_NO_SUCH_ITEM:
- return "AP4_ERROR_NO_SUCH_ITEM";
- case AP4_ERROR_OUT_OF_RANGE:
- return "AP4_ERROR_OUT_OF_RANGE";
- case AP4_ERROR_INTERNAL:
- return "AP4_ERROR_INTERNAL";
- case AP4_ERROR_INVALID_STATE:
- return "AP4_ERROR_INVALID_STATE";
- case AP4_ERROR_LIST_EMPTY:
- return "AP4_ERROR_LIST_EMPTY";
- case AP4_ERROR_LIST_OPERATION_ABORTED:
- return "AP4_ERROR_LIST_OPERATION_ABORTED";
- case AP4_ERROR_INVALID_RTP_CONSTRUCTOR_TYPE:
- return "AP4_ERROR_INVALID_RTP_CONSTRUCTOR_TYPE";
- case AP4_ERROR_NOT_SUPPORTED:
- return "AP4_ERROR_NOT_SUPPORTED";
- case AP4_ERROR_INVALID_TRACK_TYPE:
- return "AP4_ERROR_INVALID_TRACK_TYPE";
- case AP4_ERROR_INVALID_RTP_PACKET_EXTRA_DATA:
- return "AP4_ERROR_INVALID_RTP_PACKET_EXTRA_DATA";
- case AP4_ERROR_BUFFER_TOO_SMALL:
- return "AP4_ERROR_BUFFER_TOO_SMALL";
- case AP4_ERROR_NOT_ENOUGH_DATA:
- return "AP4_ERROR_NOT_ENOUGH_DATA";
- default:
- return "UNKNOWN";
+ switch (result) {
+ case AP4_SUCCESS: return "AP4_SUCCESS";
+ case AP4_FAILURE: return "AP4_FAILURE";
+ case AP4_ERROR_OUT_OF_MEMORY: return "AP4_ERROR_OUT_OF_MEMORY";
+ case AP4_ERROR_INVALID_PARAMETERS: return "AP4_ERROR_INVALID_PARAMETERS";
+ case AP4_ERROR_NO_SUCH_FILE: return "AP4_ERROR_NO_SUCH_FILE";
+ case AP4_ERROR_PERMISSION_DENIED: return "AP4_ERROR_PERMISSION_DENIED";
+ case AP4_ERROR_CANNOT_OPEN_FILE: return "AP4_ERROR_CANNOT_OPEN_FILE";
+ case AP4_ERROR_EOS: return "AP4_ERROR_EOS";
+ case AP4_ERROR_WRITE_FAILED: return "AP4_ERROR_WRITE_FAILED";
+ case AP4_ERROR_READ_FAILED: return "AP4_ERROR_READ_FAILED";
+ case AP4_ERROR_INVALID_FORMAT: return "AP4_ERROR_INVALID_FORMAT";
+ case AP4_ERROR_NO_SUCH_ITEM: return "AP4_ERROR_NO_SUCH_ITEM";
+ case AP4_ERROR_OUT_OF_RANGE: return "AP4_ERROR_OUT_OF_RANGE";
+ case AP4_ERROR_INTERNAL: return "AP4_ERROR_INTERNAL";
+ case AP4_ERROR_INVALID_STATE: return "AP4_ERROR_INVALID_STATE";
+ case AP4_ERROR_LIST_EMPTY: return "AP4_ERROR_LIST_EMPTY";
+ case AP4_ERROR_LIST_OPERATION_ABORTED: return "AP4_ERROR_LIST_OPERATION_ABORTED";
+ case AP4_ERROR_INVALID_RTP_CONSTRUCTOR_TYPE: return "AP4_ERROR_INVALID_RTP_CONSTRUCTOR_TYPE";
+ case AP4_ERROR_NOT_SUPPORTED: return "AP4_ERROR_NOT_SUPPORTED";
+ case AP4_ERROR_INVALID_TRACK_TYPE: return "AP4_ERROR_INVALID_TRACK_TYPE";
+ case AP4_ERROR_INVALID_RTP_PACKET_EXTRA_DATA: return "AP4_ERROR_INVALID_RTP_PACKET_EXTRA_DATA";
+ case AP4_ERROR_BUFFER_TOO_SMALL: return "AP4_ERROR_BUFFER_TOO_SMALL";
+ case AP4_ERROR_NOT_ENOUGH_DATA: return "AP4_ERROR_NOT_ENOUGH_DATA";
+ default: return "UNKNOWN";
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.cpp
index 5308cf363..ad46363cd 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - sdp Atoms
+| AP4 - sdp Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -44,9 +44,8 @@ AP4_RtpAtom::AP4_RtpAtom(AP4_UI32 size, AP4_ByteStream& stream) :
stream.ReadUI32(m_DescriptionFormat);
// sdptext
- int str_size = size - (AP4_ATOM_HEADER_SIZE + 4);
- if(str_size)
- {
+ int str_size = size-(AP4_ATOM_HEADER_SIZE+4);
+ if (str_size) {
char* str = new char[str_size+1];
stream.Read(str, str_size);
str[str_size] = '\0'; // force null-termination
@@ -65,16 +64,16 @@ AP4_RtpAtom::WriteFields(AP4_ByteStream& stream)
// description format
result = stream.WriteUI32(m_DescriptionFormat);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// sdp text
result = stream.Write(m_SdpText.GetChars(), m_SdpText.GetLength());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// pad with zeros if necessary
- AP4_Size padding = m_Size32 - (AP4_ATOM_HEADER_SIZE + 4 + m_SdpText.GetLength());
- while(padding--) stream.WriteUI08(0);
-
+ AP4_Size padding = m_Size32-(AP4_ATOM_HEADER_SIZE+4+m_SdpText.GetLength());
+ while (padding--) stream.WriteUI08(0);
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.h
index 1f30eebdc..596d96cfc 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - rtp Atoms
+| AP4 - rtp Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -49,16 +49,12 @@ class AP4_RtpAtom : public AP4_Atom
{
public:
// class methods
- static AP4_RtpAtom* Create(AP4_Size size, AP4_ByteStream& stream)
- {
+ static AP4_RtpAtom* Create(AP4_Size size, AP4_ByteStream& stream) {
return new AP4_RtpAtom(size, stream);
}
// methods
- const AP4_String& GetSdpText()
- {
- return m_SdpText;
- }
+ const AP4_String& GetSdpText() { return m_SdpText; }
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.cpp
index 71b1f915a..3f9f19c0e 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.cpp
@@ -38,8 +38,7 @@
AP4_RtpSampleData::~AP4_RtpSampleData()
{
AP4_List<AP4_RtpPacket>::Item* it = m_Packets.FirstItem();
- while(it != NULL)
- {
+ while (it != NULL) {
it->GetData()->Release();
it = it->GetNext();
}
@@ -56,22 +55,20 @@ AP4_RtpSampleData::AP4_RtpSampleData(AP4_ByteStream& stream, AP4_UI32 size)
AP4_UI16 packet_count;
stream.ReadUI16(packet_count);
-
+
AP4_UI16 reserved;
stream.ReadUI16(reserved); // later, check that reserved is 0
// packets
- for(AP4_UI16 i = 0; i < packet_count; i++)
- {
+ for (AP4_UI16 i=0; i<packet_count; i++) {
AP4_RtpPacket* packet = new AP4_RtpPacket(stream);
m_Packets.Add(packet);
}
// extra data
stream.Tell(extra_data_start);
- AP4_Size extra_data_size = size - (AP4_UI32)(extra_data_start - start);
- if(extra_data_size != 0)
- {
+ AP4_Size extra_data_size = size - (AP4_UI32)(extra_data_start-start);
+ if (extra_data_size != 0) {
m_ExtraData.SetDataSize(extra_data_size);
stream.Read(m_ExtraData.UseData(), extra_data_size);
}
@@ -88,8 +85,7 @@ AP4_RtpSampleData::GetSize()
// packets
AP4_List<AP4_RtpPacket>::Item* it = m_Packets.FirstItem();
- while(it != NULL)
- {
+ while (it != NULL) {
result = it->GetData()->GetSize();
it = it->GetNext();
}
@@ -114,23 +110,22 @@ AP4_RtpSampleData::ToByteStream()
// write in it
AP4_Result result = stream->WriteUI16(static_cast<AP4_UI16>(m_Packets.ItemCount()));
- if(AP4_FAILED(result)) goto bail;
+ if (AP4_FAILED(result)) goto bail;
result = stream->WriteUI16(0); // reserved
- if(AP4_FAILED(result)) goto bail;
+ if (AP4_FAILED(result)) goto bail;
{
AP4_List<AP4_RtpPacket>::Item* it = m_Packets.FirstItem();
- while(it != NULL)
- {
+ while (it != NULL) {
result = it->GetData()->Write(*stream);
- if(AP4_FAILED(result)) goto bail;
+ if (AP4_FAILED(result)) goto bail;
it = it->GetNext();
}
}
result = stream->Write(m_ExtraData.GetData(), m_ExtraData.GetDataSize());
- if(AP4_FAILED(result)) goto bail;
+ if (AP4_FAILED(result)) goto bail;
// return
return stream;
@@ -154,14 +149,14 @@ AP4_RtpSampleData::AddPacket(AP4_RtpPacket* packet)
/*----------------------------------------------------------------------
| AP4_RtpPacket::AP4_RtpPacket
+---------------------------------------------------------------------*/
-AP4_RtpPacket::AP4_RtpPacket(int relative_time,
- bool p_bit,
- bool x_bit,
- bool m_bit,
- AP4_UI08 payload_type,
- AP4_UI16 sequence_seed,
+AP4_RtpPacket::AP4_RtpPacket(int relative_time,
+ bool p_bit,
+ bool x_bit,
+ bool m_bit,
+ AP4_UI08 payload_type,
+ AP4_UI16 sequence_seed,
int time_stamp_offset /* = 0 */,
- bool bframe_flag /* = false */,
+ bool bframe_flag /* = false */,
bool repeat_flag /* = false */) :
m_ReferenceCount(1),
m_RelativeTime(relative_time),
@@ -216,36 +211,31 @@ AP4_RtpPacket::AP4_RtpPacket(AP4_ByteStream& stream) :
stream.ReadUI16(constructor_count);
// parse the packet extra data
- if(extra_flag)
- {
+ if (extra_flag) {
// read the length
AP4_UI32 extra_length;
stream.ReadUI32(extra_length);
- // check it
- if(extra_length < 4) return;
+ // check it
+ if (extra_length < 4) return;
// now read the entries
extra_length -= 4;
- while(extra_length > 0)
- {
+ while (extra_length > 0) {
AP4_UI32 entry_length;
AP4_UI32 entry_tag;
stream.ReadUI32(entry_length);
stream.ReadUI32(entry_tag);
// check the entry
- if(entry_length < 8) return;
+ if (entry_length < 8) return;
// parse the single entry that's currently defined in the spec
- if(entry_tag == AP4_ATOM_TYPE('r', 't', 'p', 'o') && entry_length == 12)
- {
+ if (entry_tag == AP4_ATOM_TYPE('r','t','p','o') && entry_length == 12) {
AP4_UI32 time_stamp_offset;
stream.ReadUI32(time_stamp_offset);
m_TimeStampOffset = time_stamp_offset;
- }
- else
- {
+ } else {
// ignore it
AP4_Position cur_pos;
stream.Tell(cur_pos);
@@ -257,8 +247,7 @@ AP4_RtpPacket::AP4_RtpPacket(AP4_ByteStream& stream) :
}
// constructors
- for(AP4_UI16 i = 0; i < constructor_count; i++)
- {
+ for (AP4_UI16 i=0; i<constructor_count; i++) {
AP4_RtpConstructor* constructor = NULL;
AP4_RtpConstructorFactory::CreateConstructorFromStream(stream, constructor);
m_Constructors.Add(constructor);
@@ -271,8 +260,7 @@ AP4_RtpPacket::AP4_RtpPacket(AP4_ByteStream& stream) :
AP4_RtpPacket::~AP4_RtpPacket()
{
AP4_List<AP4_RtpConstructor>::Item* it = m_Constructors.FirstItem();
- while(it != NULL)
- {
+ while (it != NULL) {
it->GetData()->Release();
it = it->GetNext();
}
@@ -293,8 +281,7 @@ AP4_RtpPacket::AddReference()
void
AP4_RtpPacket::Release()
{
- if(--m_ReferenceCount == 0)
- {
+ if (--m_ReferenceCount == 0) {
delete this;
}
}
@@ -305,7 +292,7 @@ AP4_RtpPacket::Release()
AP4_Size
AP4_RtpPacket::GetSize()
{
- AP4_Size result = 12 + (m_TimeStampOffset != 0) ? 16 : 0;
+ AP4_Size result = 12 + (m_TimeStampOffset != 0)?16:0;
result += m_Constructors.ItemCount() * AP4_RTP_CONSTRUCTOR_SIZE;
return result;
}
@@ -314,60 +301,58 @@ AP4_RtpPacket::GetSize()
| AP4_RtpPacket::Write
+---------------------------------------------------------------------*/
AP4_Result
-AP4_RtpPacket::Write(AP4_ByteStream& stream)
+AP4_RtpPacket::Write(AP4_ByteStream& stream)
{
// check the payload type
- if(m_PayloadType > 128) return AP4_FAILURE;
+ if (m_PayloadType > 128) return AP4_FAILURE;
// now write
AP4_Result result = stream.WriteUI32(m_RelativeTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI08(0x80 | m_PBit << 5 | m_XBit << 4);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI08(m_MBit << 7 | m_PayloadType);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI16(m_SequenceSeed);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI08(0);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// deal with extra flag
bool extra_flag = m_TimeStampOffset != 0;
- result = stream.WriteUI08(0x00 | extra_flag << 2
- | m_BFrameFlag << 1
- | m_RepeatFlag << 0);
- if(AP4_FAILED(result)) return result;
+ result = stream.WriteUI08(0x00 | extra_flag << 2
+ | m_BFrameFlag << 1
+ | m_RepeatFlag << 0);
+ if (AP4_FAILED(result)) return result;
// constructor count
result = stream.WriteUI16(static_cast<AP4_UI16>(m_Constructors.ItemCount()));
// write extra data
- if(extra_flag)
- {
+ if (extra_flag) {
// extra_length
result = stream.WriteUI32(16); // 4 (extra_length) + 12 (rtpo atom)
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// rtpo atom
result = stream.WriteUI32(12); // size
- if(AP4_FAILED(result)) return result;
- result = stream.WriteUI32(AP4_ATOM_TYPE('r', 't', 'p', 'o'));
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
+ result = stream.WriteUI32(AP4_ATOM_TYPE('r','t','p','o'));
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_TimeStampOffset);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// constructors
AP4_List<AP4_RtpConstructor>::Item* it = m_Constructors.FirstItem();
- while(it != NULL)
- {
+ while (it != NULL) {
result = it->GetData()->Write(stream);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
it = it->GetNext();
}
return result;
@@ -377,7 +362,7 @@ AP4_RtpPacket::Write(AP4_ByteStream& stream)
| AP4_RtpPacket::AddConstructor
+---------------------------------------------------------------------*/
AP4_Result
-AP4_RtpPacket::AddConstructor(AP4_RtpConstructor* constructor)
+AP4_RtpPacket::AddConstructor(AP4_RtpConstructor* constructor)
{
constructor->AddReference();
return m_Constructors.Add(constructor);
@@ -393,10 +378,9 @@ AP4_RtpPacket::GetConstructedDataSize()
AP4_Size size = 12;
// constructed data from constructors
- AP4_List<AP4_RtpConstructor>::Item* constructors_it
- = m_Constructors.FirstItem();
- while(constructors_it != NULL)
- {
+ AP4_List<AP4_RtpConstructor>::Item* constructors_it
+ = m_Constructors.FirstItem();
+ while (constructors_it != NULL) {
size += constructors_it->GetData()->GetConstructedDataSize();
constructors_it = constructors_it->GetNext();
}
@@ -420,8 +404,7 @@ AP4_RtpConstructor::AddReference()
void
AP4_RtpConstructor::Release()
{
- if(--m_ReferenceCount == 0)
- {
+ if (--m_ReferenceCount == 0) {
delete this;
}
}
@@ -432,7 +415,7 @@ AP4_Result
AP4_RtpConstructor::Write(AP4_ByteStream& stream)
{
AP4_Result result = stream.WriteUI08(m_Type);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return DoWrite(stream);
}
@@ -445,7 +428,7 @@ AP4_NoopRtpConstructor::AP4_NoopRtpConstructor(AP4_ByteStream& stream) :
{
AP4_Position cur_offset;
stream.Tell(cur_offset);
- stream.Seek(cur_offset + 15);
+ stream.Seek(cur_offset+15);
}
/*----------------------------------------------------------------------
@@ -483,7 +466,7 @@ AP4_ImmediateRtpConstructor::AP4_ImmediateRtpConstructor(AP4_ByteStream& stream)
stream.Read(m_Data.UseData(), data_size);
// reposition the stream
- stream.Seek(cur_offset + 15);
+ stream.Seek(cur_offset+15);
}
@@ -494,26 +477,26 @@ AP4_Result
AP4_ImmediateRtpConstructor::DoWrite(AP4_ByteStream& stream)
{
// first check that the data is not too large
- if(m_Data.GetDataSize() > 14) return AP4_FAILURE;
+ if (m_Data.GetDataSize() > 14) return AP4_FAILURE;
// now write
AP4_Result result = stream.WriteUI08(static_cast<AP4_UI08>(m_Data.GetDataSize()));
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.Write(m_Data.GetData(), m_Data.GetDataSize());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// pad
AP4_Byte pad[14];
- return stream.Write(pad, sizeof(pad) - m_Data.GetDataSize());
+ return stream.Write(pad, sizeof(pad)-m_Data.GetDataSize());
}
/*----------------------------------------------------------------------
| AP4_SampleRtpConstructor::AP4_SampleRtpConstructor
+---------------------------------------------------------------------*/
-AP4_SampleRtpConstructor::AP4_SampleRtpConstructor(AP4_UI08 track_ref_index,
- AP4_UI16 length,
- AP4_UI32 sample_num,
- AP4_UI32 sample_offset) :
+AP4_SampleRtpConstructor::AP4_SampleRtpConstructor(AP4_UI08 track_ref_index,
+ AP4_UI16 length,
+ AP4_UI32 sample_num,
+ AP4_UI32 sample_offset) :
AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE),
m_TrackRefIndex(track_ref_index),
m_Length(length),
@@ -538,7 +521,7 @@ AP4_SampleRtpConstructor::AP4_SampleRtpConstructor(AP4_ByteStream& stream) :
stream.ReadUI32(m_SampleOffset);
// reposition the stream
- stream.Seek(cur_offset + 15);
+ stream.Seek(cur_offset+15);
}
/*----------------------------------------------------------------------
| AP4_SampleRtpConstructor::DoWrite
@@ -547,19 +530,19 @@ AP4_Result
AP4_SampleRtpConstructor::DoWrite(AP4_ByteStream& stream)
{
AP4_Result result = stream.WriteUI08(m_TrackRefIndex);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI16(m_Length);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_SampleNum);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_SampleOffset);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI16(1); // bytes per block
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return stream.WriteUI16(1); // samples per block
}
@@ -567,10 +550,10 @@ AP4_SampleRtpConstructor::DoWrite(AP4_ByteStream& stream)
/*----------------------------------------------------------------------
| AP4_SampleDescRtpConstructor::AP4_SampleDescRtpConstructor
+---------------------------------------------------------------------*/
-AP4_SampleDescRtpConstructor::AP4_SampleDescRtpConstructor(AP4_UI08 track_ref_index,
- AP4_UI16 length,
- AP4_UI32 sample_desc_index,
- AP4_UI32 sample_desc_offset) :
+AP4_SampleDescRtpConstructor::AP4_SampleDescRtpConstructor(AP4_UI08 track_ref_index,
+ AP4_UI16 length,
+ AP4_UI32 sample_desc_index,
+ AP4_UI32 sample_desc_offset) :
AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC),
m_TrackRefIndex(track_ref_index),
m_Length(length),
@@ -595,7 +578,7 @@ AP4_SampleDescRtpConstructor::AP4_SampleDescRtpConstructor(AP4_ByteStream& strea
stream.ReadUI32(m_SampleDescOffset);
// reposition the stream
- stream.Seek(cur_offset + 15);
+ stream.Seek(cur_offset+15);
}
/*----------------------------------------------------------------------
@@ -605,16 +588,16 @@ AP4_Result
AP4_SampleDescRtpConstructor::DoWrite(AP4_ByteStream& stream)
{
AP4_Result result = stream.WriteUI08(m_TrackRefIndex);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI16(m_Length);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_SampleDescIndex);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_SampleDescOffset);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return stream.WriteUI32(0); // reserved
}
@@ -623,31 +606,30 @@ AP4_SampleDescRtpConstructor::DoWrite(AP4_ByteStream& stream)
| AP4_RtpConstructorFactory::CreateConstructorFromStream
+---------------------------------------------------------------------*/
AP4_Result
-AP4_RtpConstructorFactory::CreateConstructorFromStream(AP4_ByteStream& stream,
- AP4_RtpConstructor*& constructor)
+AP4_RtpConstructorFactory::CreateConstructorFromStream(AP4_ByteStream& stream,
+ AP4_RtpConstructor*& constructor)
{
// read the first byte (type)
AP4_RtpConstructor::Type type;
AP4_Result result = stream.ReadUI08(type);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// now create the right constructor
- switch(type)
- {
- case AP4_RTP_CONSTRUCTOR_TYPE_NOOP:
- constructor = new AP4_NoopRtpConstructor(stream);
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_IMMEDIATE:
- constructor = new AP4_ImmediateRtpConstructor(stream);
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE:
- constructor = new AP4_SampleRtpConstructor(stream);
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC:
- constructor = new AP4_SampleDescRtpConstructor(stream);
- break;
- default:
- return AP4_ERROR_INVALID_RTP_CONSTRUCTOR_TYPE;
+ switch(type) {
+ case AP4_RTP_CONSTRUCTOR_TYPE_NOOP:
+ constructor = new AP4_NoopRtpConstructor(stream);
+ break;
+ case AP4_RTP_CONSTRUCTOR_TYPE_IMMEDIATE:
+ constructor = new AP4_ImmediateRtpConstructor(stream);
+ break;
+ case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE:
+ constructor = new AP4_SampleRtpConstructor(stream);
+ break;
+ case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC:
+ constructor = new AP4_SampleDescRtpConstructor(stream);
+ break;
+ default:
+ return AP4_ERROR_INVALID_RTP_CONSTRUCTOR_TYPE;
}
return AP4_SUCCESS;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.h
index 7972c119f..f747c8212 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4RtpHint.h
@@ -59,14 +59,12 @@ public:
virtual AP4_Result AddPacket(AP4_RtpPacket* packet);
virtual AP4_Size GetSize();
virtual AP4_ByteStream* ToByteStream();
-
+
// accessors
- AP4_List<AP4_RtpPacket>& GetPackets()
- {
+ AP4_List<AP4_RtpPacket>& GetPackets() {
return m_Packets;
}
- const AP4_DataBuffer& GetExtraData() const
- {
+ const AP4_DataBuffer& GetExtraData() const {
return m_ExtraData;
}
@@ -104,52 +102,24 @@ public:
// Referenceable methods
void AddReference();
void Release();
-
+
// Accessors
- int GetRelativeTime() const
- {
- return m_RelativeTime;
- }
- bool GetPBit() const
- {
- return m_PBit;
- }
- bool GetXBit() const
- {
- return m_XBit;
- }
- bool GetMBit() const
- {
- return m_MBit;
- }
- AP4_UI08 GetPayloadType() const
- {
- return m_PayloadType;
- }
- AP4_UI16 GetSequenceSeed() const
- {
- return m_SequenceSeed;
- }
- int GetTimeStampOffset() const
- {
- return m_TimeStampOffset;
- }
- bool GetBFrameFlag() const
- {
- return m_BFrameFlag;
- }
- bool GetRepeatFlag() const
- {
- return m_RepeatFlag;
- }
- AP4_List<AP4_RtpConstructor>& GetConstructors()
- {
+ int GetRelativeTime() const { return m_RelativeTime; }
+ bool GetPBit() const { return m_PBit; }
+ bool GetXBit() const { return m_XBit; }
+ bool GetMBit() const { return m_MBit; }
+ AP4_UI08 GetPayloadType() const { return m_PayloadType; }
+ AP4_UI16 GetSequenceSeed() const { return m_SequenceSeed; }
+ int GetTimeStampOffset() const { return m_TimeStampOffset; }
+ bool GetBFrameFlag() const { return m_BFrameFlag; }
+ bool GetRepeatFlag() const { return m_RepeatFlag; }
+ AP4_List<AP4_RtpConstructor>& GetConstructors() {
return m_Constructors;
}
private:
// members
- AP4_Cardinal m_ReferenceCount;
+ AP4_Cardinal m_ReferenceCount;
int m_RelativeTime;
bool m_PBit;
bool m_XBit;
@@ -175,10 +145,7 @@ public:
AP4_RtpConstructor(Type type) : m_ReferenceCount(1), m_Type(type) {}
// methods
- Type GetType() const
- {
- return m_Type;
- }
+ Type GetType() const { return m_Type; }
AP4_Result Write(AP4_ByteStream& stream);
virtual AP4_Size GetConstructedDataSize() = 0;
@@ -220,10 +187,7 @@ public:
AP4_NoopRtpConstructor() : AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_NOOP) {}
// methods
- virtual AP4_Size GetConstructedDataSize()
- {
- return 0;
- }
+ virtual AP4_Size GetConstructedDataSize() { return 0; }
protected:
// methods
@@ -239,18 +203,12 @@ public:
// constructor
AP4_ImmediateRtpConstructor(AP4_ByteStream& stream);
AP4_ImmediateRtpConstructor(const AP4_DataBuffer& data);
-
+
// accessors
- const AP4_DataBuffer& GetData() const
- {
- return m_Data;
- }
+ const AP4_DataBuffer& GetData() const { return m_Data; }
// methods
- virtual AP4_Size GetConstructedDataSize()
- {
- return m_Data.GetDataSize();
- }
+ virtual AP4_Size GetConstructedDataSize() { return m_Data.GetDataSize(); }
protected:
// methods
@@ -272,30 +230,15 @@ public:
AP4_UI16 length,
AP4_UI32 sample_num,
AP4_UI32 sample_offset);
-
+
// accessors
- AP4_UI08 GetTrackRefIndex() const
- {
- return m_TrackRefIndex;
- }
- AP4_UI16 GetLength() const
- {
- return m_Length;
- }
- AP4_UI32 GetSampleNum() const
- {
- return m_SampleNum;
- }
- AP4_UI32 GetSampleOffset() const
- {
- return m_SampleOffset;
- }
+ AP4_UI08 GetTrackRefIndex() const { return m_TrackRefIndex; }
+ AP4_UI16 GetLength() const { return m_Length; }
+ AP4_UI32 GetSampleNum() const { return m_SampleNum; }
+ AP4_UI32 GetSampleOffset() const { return m_SampleOffset; }
// methods
- virtual AP4_Size GetConstructedDataSize()
- {
- return m_Length;
- }
+ virtual AP4_Size GetConstructedDataSize() { return m_Length; }
protected:
// methods
@@ -322,29 +265,14 @@ public:
AP4_UI32 sample_desc_offset);
// accessors
- AP4_UI08 GetTrackRefIndex() const
- {
- return m_TrackRefIndex;
- }
- AP4_UI16 GetLength() const
- {
- return m_Length;
- }
- AP4_UI32 GetSampleDescIndex() const
- {
- return m_SampleDescIndex;
- }
- AP4_UI32 GetSampleDescOffset() const
- {
- return m_SampleDescOffset;
- }
+ AP4_UI08 GetTrackRefIndex() const { return m_TrackRefIndex; }
+ AP4_UI16 GetLength() const { return m_Length; }
+ AP4_UI32 GetSampleDescIndex() const { return m_SampleDescIndex; }
+ AP4_UI32 GetSampleDescOffset() const { return m_SampleDescOffset; }
// methods
- virtual AP4_Size GetConstructedDataSize()
- {
- return m_Length;
- }
-
+ virtual AP4_Size GetConstructedDataSize() { return m_Length; }
+
protected:
// methods
virtual AP4_Result DoWrite(AP4_ByteStream& stream);
@@ -359,11 +287,11 @@ protected:
/*----------------------------------------------------------------------
| AP4_RtpConstructorFactory
+---------------------------------------------------------------------*/
-class AP4_RtpConstructorFactory
+class AP4_RtpConstructorFactory
{
public:
static AP4_Result CreateConstructorFromStream(AP4_ByteStream& stream,
- AP4_RtpConstructor*& constructor);
+ AP4_RtpConstructor*& constructor);
};
#endif // _AP4_RTP_HINT_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.cpp
index 38a01ce36..7b791c3e4 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - SLConfig Descriptor
+| AP4 - SLConfig Descriptor
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.h
index 66820e6a3..73a26ec9b 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SLConfigDescriptor.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - SLConfig Descriptor
+| AP4 - SLConfig Descriptor
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -43,7 +43,7 @@ const AP4_UI08 AP4_DESCRIPTOR_TAG_SL_CONFIG = 0x06;
/*----------------------------------------------------------------------
| AP4_SLConfigDescriptor
+---------------------------------------------------------------------*/
-class AP4_SLConfigDescriptor : public AP4_Descriptor
+class AP4_SLConfigDescriptor : public AP4_Descriptor
{
public:
// methods
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.cpp
index d0a15aa55..060084044 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.cpp
@@ -135,21 +135,21 @@ AP4_Result
AP4_Sample::ReadData(AP4_DataBuffer& data, AP4_Size size, AP4_Size offset)
{
// check that we have a stream
- if(m_DataStream == NULL) return AP4_FAILURE;
+ if (m_DataStream == NULL) return AP4_FAILURE;
// shortcut
- if(size == 0) return AP4_SUCCESS;
+ if (size == 0) return AP4_SUCCESS;
// check the size
- if(m_Size < size + offset) return AP4_FAILURE;
+ if (m_Size < size+offset) return AP4_FAILURE;
// set the buffer size
AP4_Result result = data.SetDataSize(size);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// get the data from the stream
- result = m_DataStream->Seek(m_Offset + offset);
- if(AP4_FAILED(result)) return result;
+ result = m_DataStream->Seek(m_Offset+offset);
+ if (AP4_FAILED(result)) return result;
return m_DataStream->Read(data.UseData(), size);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.h
index 0af63fbac..ba5a0235f 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Sample.h
@@ -43,7 +43,7 @@ class AP4_DataBuffer;
/*----------------------------------------------------------------------
| AP4_Sample DO NOT DERIVE FROM THIS CLASS
+---------------------------------------------------------------------*/
-class AP4_Sample
+class AP4_Sample
{
public:
/**
@@ -55,19 +55,19 @@ public:
* Copy constructor
*/
AP4_Sample(const AP4_Sample& other);
-
+
/**
* Construct an AP4_Sample referencing a data stream
*
- * @param data_stream The byte stream that contains the sample data.
- * The sample object added to the track will keep a reference to that byte
+ * @param data_stream The byte stream that contains the sample data.
+ * The sample object added to the track will keep a reference to that byte
* stream
* @param offset Position of the first byte of sample data within the stream
* @param size Size in bytes of the sample data
- * @param description_index Index of the sample description that applies to
+ * @param description_index Index of the sample description that applies to
* this sample
* @param dts Decoding timestamp of the sample
- * @param cts_delta Difference between the CTS (composition/display timestamp) and the
+ * @param cts_delta Difference between the CTS (composition/display timestamp) and the
* DTS (decoding timestamp), in the timescale of the media.
* @param sync_flag Boolean flag indicating whether this is a sync sample
* or not
@@ -80,7 +80,7 @@ public:
AP4_UI64 dts,
AP4_UI32 cts_delta,
bool sync_flag);
-
+
~AP4_Sample(); // not virtual on purpose: do not derive from it
// operators
@@ -88,119 +88,71 @@ public:
// methods
AP4_Result ReadData(AP4_DataBuffer& data);
- AP4_Result ReadData(AP4_DataBuffer& data,
- AP4_Size size,
+ AP4_Result ReadData(AP4_DataBuffer& data,
+ AP4_Size size,
AP4_Size offset = 0);
// sample properties accessors
AP4_ByteStream* GetDataStream();
void SetDataStream(AP4_ByteStream& stream);
- AP4_Position GetOffset() const
- {
- return m_Offset;
- }
- void SetOffset(AP4_Position offset)
- {
- m_Offset = offset;
- }
- AP4_Size GetSize()
- {
- return m_Size;
- }
- void SetSize(AP4_Size size)
- {
- m_Size = size;
- }
- AP4_Ordinal GetDescriptionIndex() const
- {
- return m_DescriptionIndex;
- }
- void SetDescriptionIndex(AP4_Ordinal index)
- {
- m_DescriptionIndex = index;
- }
-
+ AP4_Position GetOffset() const { return m_Offset; }
+ void SetOffset(AP4_Position offset) { m_Offset = offset; }
+ AP4_Size GetSize() { return m_Size; }
+ void SetSize(AP4_Size size) { m_Size = size; }
+ AP4_Ordinal GetDescriptionIndex() const { return m_DescriptionIndex; }
+ void SetDescriptionIndex(AP4_Ordinal index) { m_DescriptionIndex = index; }
+
/**
* Get the DTS (Decoding Time Stamp) of the sample in the timescale of the media
*/
- AP4_UI64 GetDts() const
- {
- return m_Dts;
- }
+ AP4_UI64 GetDts() const { return m_Dts; }
/**
* Set the DTS (Decoding Time Stamp) of the sample in the timescale of the media
*/
- void SetDts(AP4_UI64 dts)
- {
- m_Dts = dts;
- }
+ void SetDts(AP4_UI64 dts) { m_Dts = dts; }
/**
* Get the CTS (Composition Time Stamp) of the sample in the timescale of the media
*/
- AP4_UI64 GetCts() const
- {
- return m_Dts + m_CtsDelta;
- }
+ AP4_UI64 GetCts() const { return m_Dts+m_CtsDelta; }
/**
* Set the CTS (Composition Time Stamp) of the sample in the timescale of the media
*/
- void SetCts(AP4_UI64 cts)
- {
- m_CtsDelta = (cts > m_Dts) ? (AP4_UI32)(cts - m_Dts) : 0;
- }
+ void SetCts(AP4_UI64 cts) { m_CtsDelta = (cts > m_Dts) ? (AP4_UI32)(cts-m_Dts) : 0; }
/**
* Get the CTS Delta (difference between the CTS (Composition Time Stamp) and DTS (Decoding Time Stamp)
* of the sample in the timescale of the media.
*/
- AP4_UI32 GetCtsDelta() const
- {
- return m_CtsDelta;
- }
+ AP4_UI32 GetCtsDelta() const { return m_CtsDelta; }
/**
* Set the CTS Delta (difference between the CTS (Composition Time Stamp) and DTS (Decoding Time Stamp)
* of the sample in the timescale of the media.
*/
- void SetCtsDelta(AP4_UI32 delta)
- {
- m_CtsDelta = (AP4_SI32)delta;
- }
+ void SetCtsDelta(AP4_UI32 delta) { m_CtsDelta = (AP4_SI32)delta; }
/**
* Get the duration of the sample in the timescale of the media
*/
- AP4_UI32 GetDuration() const
- {
- return m_Duration;
- }
+ AP4_UI32 GetDuration() const { return m_Duration; }
/**
* Set the duration of the sample in the timescale of the media
*/
- void SetDuration(AP4_UI32 duration)
- {
- m_Duration = duration;
- }
+ void SetDuration(AP4_UI32 duration) { m_Duration = duration; }
/**
* Return whether the sample is a sync (random-access point) sample or not.
*/
- bool IsSync() const
- {
- return m_IsSync;
- }
+ bool IsSync() const { return m_IsSync; }
/**
* Set whether the sample is a sync (random-access point) sample or not.
*/
- void SetSync(bool is_sync)
- {
- m_IsSync = is_sync;
- }
+ void SetSync(bool is_sync) { m_IsSync = is_sync; }
protected:
AP4_ByteStream* m_DataStream;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.cpp
index f7a0b1698..e301d0cf4 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.cpp
@@ -56,70 +56,38 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_AvcSampleDescription)
const char*
AP4_GetFormatName(AP4_UI32 format)
{
- switch(format)
- {
- case AP4_SAMPLE_FORMAT_MP4A:
- return "MPEG-4 Audio";
- case AP4_SAMPLE_FORMAT_MP4V:
- return "MPEG-4 Video";
- case AP4_SAMPLE_FORMAT_MP4S:
- return "MPEG-4 Systems";
- case AP4_SAMPLE_FORMAT_ALAC:
- return "Apple Lossless Audio";
- case AP4_SAMPLE_FORMAT_AVC1:
- return "H.264";
- case AP4_SAMPLE_FORMAT_OVC1:
- return "VC-1";
- case AP4_SAMPLE_FORMAT_OWMA:
- return "WMA";
- case AP4_SAMPLE_FORMAT_AC_3:
- return "Dolby Digital (AC-3)";
- case AP4_SAMPLE_FORMAT_EC_3:
- return "Dolby Digital Plus (Enhanced AC-3)";
- case AP4_SAMPLE_FORMAT_AVCP:
- return "Advanced Video Coding Parameters";
- case AP4_SAMPLE_FORMAT_DRAC:
- return "Dirac";
- case AP4_SAMPLE_FORMAT_DRA1:
- return "DRA Audio";
- case AP4_SAMPLE_FORMAT_G726:
- return "G726";
- case AP4_SAMPLE_FORMAT_MJP2:
- return "Motion JPEG 2000";
- case AP4_SAMPLE_FORMAT_OKSD:
- return "OMA Keys";
- case AP4_SAMPLE_FORMAT_RAW_:
- return "Uncompressed Audio";
- case AP4_SAMPLE_FORMAT_RTP_:
- return "RTP Hints";
- case AP4_SAMPLE_FORMAT_S263:
- return "H.263";
- case AP4_SAMPLE_FORMAT_SAMR:
- return "Narrowband AMR";
- case AP4_SAMPLE_FORMAT_SAWB:
- return "Wideband AMR";
- case AP4_SAMPLE_FORMAT_SAWP:
- return "Extended AMR";
- case AP4_SAMPLE_FORMAT_SEVC:
- return "EVRC Voice";
- case AP4_SAMPLE_FORMAT_SQCP:
- return "13K Voice";
- case AP4_SAMPLE_FORMAT_SRTP:
- return "SRTP Hints";
- case AP4_SAMPLE_FORMAT_SSMV:
- return "SMV Voice";
- case AP4_SAMPLE_FORMAT_TEXT:
- return "Textual Metadata";
- case AP4_SAMPLE_FORMAT_TWOS:
- return "Uncompressed 16-bit Audio";
- case AP4_SAMPLE_FORMAT_TX3G:
- return "Timed Text";
- case AP4_SAMPLE_FORMAT_VC_1:
- return "SMPTE VC-1";
- case AP4_SAMPLE_FORMAT_XML_:
- return "XML Metadata";
- default:
- return NULL;
+ switch (format) {
+ case AP4_SAMPLE_FORMAT_MP4A: return "MPEG-4 Audio";
+ case AP4_SAMPLE_FORMAT_MP4V: return "MPEG-4 Video";
+ case AP4_SAMPLE_FORMAT_MP4S: return "MPEG-4 Systems";
+ case AP4_SAMPLE_FORMAT_ALAC: return "Apple Lossless Audio";
+ case AP4_SAMPLE_FORMAT_AVC1: return "H.264";
+ case AP4_SAMPLE_FORMAT_OVC1: return "VC-1";
+ case AP4_SAMPLE_FORMAT_OWMA: return "WMA";
+ case AP4_SAMPLE_FORMAT_AC_3: return "Dolby Digital (AC-3)";
+ case AP4_SAMPLE_FORMAT_EC_3: return "Dolby Digital Plus (Enhanced AC-3)";
+ case AP4_SAMPLE_FORMAT_AVCP: return "Advanced Video Coding Parameters";
+ case AP4_SAMPLE_FORMAT_DRAC: return "Dirac";
+ case AP4_SAMPLE_FORMAT_DRA1: return "DRA Audio";
+ case AP4_SAMPLE_FORMAT_G726: return "G726";
+ case AP4_SAMPLE_FORMAT_MJP2: return "Motion JPEG 2000";
+ case AP4_SAMPLE_FORMAT_OKSD: return "OMA Keys";
+ case AP4_SAMPLE_FORMAT_RAW_: return "Uncompressed Audio";
+ case AP4_SAMPLE_FORMAT_RTP_: return "RTP Hints";
+ case AP4_SAMPLE_FORMAT_S263: return "H.263";
+ case AP4_SAMPLE_FORMAT_SAMR: return "Narrowband AMR";
+ case AP4_SAMPLE_FORMAT_SAWB: return "Wideband AMR";
+ case AP4_SAMPLE_FORMAT_SAWP: return "Extended AMR";
+ case AP4_SAMPLE_FORMAT_SEVC: return "EVRC Voice";
+ case AP4_SAMPLE_FORMAT_SQCP: return "13K Voice";
+ case AP4_SAMPLE_FORMAT_SRTP: return "SRTP Hints";
+ case AP4_SAMPLE_FORMAT_SSMV: return "SMV Voice";
+ case AP4_SAMPLE_FORMAT_TEXT: return "Textual Metadata";
+ case AP4_SAMPLE_FORMAT_TWOS: return "Uncompressed 16-bit Audio";
+ case AP4_SAMPLE_FORMAT_TX3G: return "Timed Text";
+ case AP4_SAMPLE_FORMAT_VC_1: return "SMPTE VC-1";
+ case AP4_SAMPLE_FORMAT_XML_: return "XML Metadata";
+ default: return NULL;
}
}
@@ -127,21 +95,18 @@ AP4_GetFormatName(AP4_UI32 format)
| AP4_SampleDescription::AP4_SampleDescription
+---------------------------------------------------------------------*/
AP4_SampleDescription::AP4_SampleDescription(Type type,
- AP4_UI32 format,
- AP4_AtomParent* details) :
+ AP4_UI32 format,
+ AP4_AtomParent* details) :
m_Type(type), m_Format(format)
{
- if(details)
- {
- for(AP4_List<AP4_Atom>::Item* item = details->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
+ if (details) {
+ for (AP4_List<AP4_Atom>::Item* item = details->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
- if(atom)
- {
+ if (atom) {
AP4_Atom* clone = atom->Clone();
- if(clone) m_Details.AddChild(clone);
+ if (clone) m_Details.AddChild(clone);
}
}
}
@@ -153,27 +118,24 @@ AP4_SampleDescription::AP4_SampleDescription(Type type,
AP4_SampleDescription*
AP4_SampleDescription::Clone(AP4_Result* result)
{
- if(result) *result = AP4_SUCCESS;
+ if (result) *result = AP4_SUCCESS;
AP4_Atom* atom = ToAtom();
- if(atom == NULL)
- {
- if(result) *result = AP4_FAILURE;
+ if (atom == NULL) {
+ if (result) *result = AP4_FAILURE;
return NULL;
}
AP4_SampleEntry* sample_entry = AP4_DYNAMIC_CAST(AP4_SampleEntry, atom);
- if(sample_entry == NULL)
- {
- if(result) *result = AP4_ERROR_INTERNAL;
+ if (sample_entry == NULL) {
+ if (result) *result = AP4_ERROR_INTERNAL;
delete atom;
return NULL;
}
-
+
AP4_SampleDescription* clone = sample_entry->ToSampleDescription();
- if(clone == NULL)
- {
- if(result) *result = AP4_ERROR_INTERNAL;
+ if (clone == NULL) {
+ if (result) *result = AP4_ERROR_INTERNAL;
}
-
+
delete atom;
return clone;
}
@@ -191,8 +153,8 @@ AP4_SampleDescription::ToAtom() const
| AP4_UnknownSampleDescription::AP4_UnknownSampleDescription
+---------------------------------------------------------------------*/
AP4_UnknownSampleDescription::AP4_UnknownSampleDescription(AP4_Atom* atom) :
- AP4_SampleDescription(AP4_SampleDescription::TYPE_UNKNOWN,
- atom->GetType(),
+ AP4_SampleDescription(AP4_SampleDescription::TYPE_UNKNOWN,
+ atom->GetType(),
NULL),
m_Atom(atom->Clone())
{
@@ -213,53 +175,48 @@ AP4_SampleDescription*
AP4_UnknownSampleDescription::Clone(AP4_Result* result)
{
AP4_Atom* atom_clone = NULL;
- if(m_Atom)
- {
+ if (m_Atom) {
atom_clone = m_Atom->Clone();
- if(atom_clone == NULL)
- {
- if(result) *result = AP4_FAILURE;
+ if (atom_clone == NULL) {
+ if (result) *result = AP4_FAILURE;
return NULL;
}
}
- if(result) *result = AP4_SUCCESS;
+ if (result) *result = AP4_SUCCESS;
return new AP4_UnknownSampleDescription(atom_clone);
}
/*----------------------------------------------------------------------
| AP4_UnknownSampleDescription::ToAtom
+---------------------------------------------------------------------*/
-AP4_Atom*
+AP4_Atom*
AP4_UnknownSampleDescription::ToAtom() const
{
- if(m_Atom)
- {
+ if (m_Atom) {
return m_Atom->Clone();
- }
- else
- {
+ } else {
return NULL;
}
}
-
+
/*----------------------------------------------------------------------
| AP4_AvcSampleDescription::AP4_AvcSampleDescription
+---------------------------------------------------------------------*/
AP4_AvcSampleDescription::AP4_AvcSampleDescription(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- AP4_UI08 profile,
- AP4_UI08 level,
- AP4_UI08 profile_compatibility,
- AP4_UI08 length_size,
- const AP4_Array<AP4_DataBuffer>& sequence_parameters,
- const AP4_Array<AP4_DataBuffer>& picture_parameters) :
+ AP4_UI16 height,
+ AP4_UI16 depth,
+ const char* compressor_name,
+ AP4_UI08 profile,
+ AP4_UI08 level,
+ AP4_UI08 profile_compatibility,
+ AP4_UI08 length_size,
+ const AP4_Array<AP4_DataBuffer>& sequence_parameters,
+ const AP4_Array<AP4_DataBuffer>& picture_parameters) :
AP4_SampleDescription(TYPE_AVC, AP4_SAMPLE_FORMAT_AVC1, NULL),
AP4_VideoSampleDescription(width, height, depth, compressor_name)
{
- m_AvccAtom = new AP4_AvccAtom(profile,
- level,
+ m_AvccAtom = new AP4_AvccAtom(profile,
+ level,
profile_compatibility,
length_size,
sequence_parameters,
@@ -271,19 +228,16 @@ AP4_AvcSampleDescription::AP4_AvcSampleDescription(AP4_UI16 width,
| AP4_AvcSampleDescription::AP4_AvcSampleDescription
+---------------------------------------------------------------------*/
AP4_AvcSampleDescription::AP4_AvcSampleDescription(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- const AP4_AvccAtom* avcc) :
+ AP4_UI16 height,
+ AP4_UI16 depth,
+ const char* compressor_name,
+ const AP4_AvccAtom* avcc) :
AP4_SampleDescription(TYPE_AVC, AP4_SAMPLE_FORMAT_AVC1, NULL),
AP4_VideoSampleDescription(width, height, depth, compressor_name)
{
- if(avcc)
- {
+ if (avcc) {
m_AvccAtom = new AP4_AvccAtom(*avcc);
- }
- else
- {
+ } else {
// should never happen
m_AvccAtom = new AP4_AvccAtom();
}
@@ -294,21 +248,18 @@ AP4_AvcSampleDescription::AP4_AvcSampleDescription(AP4_UI16 width,
| AP4_AvcSampleDescription::AP4_AvcSampleDescription
+---------------------------------------------------------------------*/
AP4_AvcSampleDescription::AP4_AvcSampleDescription(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- AP4_AtomParent* details) :
+ AP4_UI16 height,
+ AP4_UI16 depth,
+ const char* compressor_name,
+ AP4_AtomParent* details) :
AP4_SampleDescription(TYPE_AVC, AP4_SAMPLE_FORMAT_AVC1, details),
AP4_VideoSampleDescription(width, height, depth, compressor_name),
m_AvccAtom(NULL)
{
AP4_AvccAtom* avcc = AP4_DYNAMIC_CAST(AP4_AvccAtom, details->GetChild(AP4_ATOM_TYPE_AVCC));
- if(avcc)
- {
+ if (avcc) {
m_AvccAtom = new AP4_AvccAtom(*avcc);
- }
- else
- {
+ } else {
// shoud never happen
m_AvccAtom = new AP4_AvccAtom();
}
@@ -321,10 +272,10 @@ AP4_AvcSampleDescription::AP4_AvcSampleDescription(AP4_UI16 width,
AP4_Atom*
AP4_AvcSampleDescription::ToAtom() const
{
- return new AP4_Avc1SampleEntry(m_Width,
- m_Height,
- m_Depth,
- m_CompressorName.GetChars(),
+ return new AP4_Avc1SampleEntry(m_Width,
+ m_Height,
+ m_Depth,
+ m_CompressorName.GetChars(),
*m_AvccAtom);
}
@@ -332,7 +283,7 @@ AP4_AvcSampleDescription::ToAtom() const
| AP4_MpegSampleDescription::AP4_MpegSampleDescription
+---------------------------------------------------------------------*/
AP4_MpegSampleDescription::AP4_MpegSampleDescription(AP4_UI32 format,
- AP4_EsdsAtom* esds) :
+ AP4_EsdsAtom* esds) :
AP4_SampleDescription(TYPE_MPEG, format, NULL),
m_StreamType(0),
m_ObjectTypeId(0),
@@ -340,17 +291,15 @@ AP4_MpegSampleDescription::AP4_MpegSampleDescription(AP4_UI32 format,
m_MaxBitrate(0),
m_AvgBitrate(0)
{
- if(esds)
- {
+ if (esds) {
// get the es descriptor
const AP4_EsDescriptor* es_desc = esds->GetEsDescriptor();
- if(es_desc == NULL) return;
+ if (es_desc == NULL) return;
// get the decoder config descriptor
const AP4_DecoderConfigDescriptor* dc_desc =
es_desc->GetDecoderConfigDescriptor();
- if(dc_desc)
- {
+ if (dc_desc) {
m_StreamType = dc_desc->GetStreamType();
m_ObjectTypeId = dc_desc->GetObjectTypeIndication();
m_BufferSize = dc_desc->GetBufferSize();
@@ -358,8 +307,7 @@ AP4_MpegSampleDescription::AP4_MpegSampleDescription(AP4_UI32 format,
m_AvgBitrate = dc_desc->GetAvgBitrate();
const AP4_DecoderSpecificInfoDescriptor* dsi_desc =
dc_desc->GetDecoderSpecificInfoDescriptor();
- if(dsi_desc != NULL)
- {
+ if (dsi_desc != NULL) {
m_DecoderInfo.SetData(dsi_desc->GetDecoderSpecificInfo().GetData(),
dsi_desc->GetDecoderSpecificInfo().GetDataSize());
}
@@ -385,8 +333,7 @@ AP4_MpegSampleDescription::AP4_MpegSampleDescription(
m_MaxBitrate(max_bitrate),
m_AvgBitrate(avg_bitrate)
{
- if(decoder_info != NULL)
- {
+ if (decoder_info != NULL) {
m_DecoderInfo.SetData(decoder_info->GetData(), decoder_info->GetDataSize());
}
}
@@ -394,31 +341,28 @@ AP4_MpegSampleDescription::AP4_MpegSampleDescription(
/*----------------------------------------------------------------------
| AP4_MpegSampleDescription::CreateEsDescriptor
+---------------------------------------------------------------------*/
-AP4_EsDescriptor*
+AP4_EsDescriptor*
AP4_MpegSampleDescription::CreateEsDescriptor() const
{
AP4_EsDescriptor* desc = new AP4_EsDescriptor(0);
AP4_DecoderSpecificInfoDescriptor* dsi_desc;
- if(m_DecoderInfo.GetDataSize() != 0)
- {
+ if (m_DecoderInfo.GetDataSize() != 0) {
dsi_desc = new AP4_DecoderSpecificInfoDescriptor(m_DecoderInfo);
- }
- else
- {
+ } else {
dsi_desc = NULL;
}
- AP4_DecoderConfigDescriptor* decoder_config =
+ AP4_DecoderConfigDescriptor* decoder_config =
new AP4_DecoderConfigDescriptor(m_StreamType,
- m_ObjectTypeId,
- m_BufferSize,
- m_MaxBitrate,
- m_AvgBitrate,
- dsi_desc);
+ m_ObjectTypeId,
+ m_BufferSize,
+ m_MaxBitrate,
+ m_AvgBitrate,
+ dsi_desc);
desc->AddSubDescriptor(decoder_config);
-
+
// add a fixed SL Config
desc->AddSubDescriptor(new AP4_SLConfigDescriptor());
-
+
return desc;
}
@@ -486,8 +430,8 @@ AP4_MpegAudioSampleDescription::AP4_MpegAudioSampleDescription(
AP4_UI32 avg_bitrate) :
AP4_MpegSampleDescription(AP4_ATOM_TYPE_MP4A,
AP4_STREAM_TYPE_AUDIO,
- oti,
- decoder_info, buffer_size,
+ oti,
+ decoder_info, buffer_size,
max_bitrate, avg_bitrate),
AP4_AudioSampleDescription(sample_rate, sample_size, channel_count)
{
@@ -499,7 +443,7 @@ AP4_MpegAudioSampleDescription::AP4_MpegAudioSampleDescription(
AP4_Atom*
AP4_MpegAudioSampleDescription::ToAtom() const
{
- return new AP4_Mp4aSampleEntry(m_SampleRate << 16,
+ return new AP4_Mp4aSampleEntry(m_SampleRate<<16,
m_SampleSize,
m_ChannelCount,
CreateEsDescriptor());
@@ -511,20 +455,16 @@ AP4_MpegAudioSampleDescription::ToAtom() const
AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType
AP4_MpegAudioSampleDescription::GetMpeg4AudioObjectType() const
{
- if(m_ObjectTypeId == AP4_OTI_MPEG4_AUDIO &&
- m_DecoderInfo.GetDataSize() >= 1)
- {
- AP4_UI08 type = m_DecoderInfo.GetData()[0] >> 3;
- if(type == 31)
- {
- if(m_DecoderInfo.GetDataSize() < 2) return 0;
- type = 32 + (((m_DecoderInfo.GetData()[0] & 0x07) << 3) |
- ((m_DecoderInfo.GetData()[1] & 0xE0) >> 5));
+ if (m_ObjectTypeId == AP4_OTI_MPEG4_AUDIO &&
+ m_DecoderInfo.GetDataSize() >= 1) {
+ AP4_UI08 type = m_DecoderInfo.GetData()[0]>>3;
+ if (type == 31) {
+ if (m_DecoderInfo.GetDataSize() < 2) return 0;
+ type = 32+(((m_DecoderInfo.GetData()[0]&0x07)<<3) |
+ ((m_DecoderInfo.GetData()[1]&0xE0)>>5));
}
return type;
- }
- else
- {
+ } else {
return 0;
}
}
@@ -538,7 +478,7 @@ AP4_MpegVideoSampleDescription::AP4_MpegVideoSampleDescription(
AP4_UI16 depth,
const char* compressor_name,
AP4_EsdsAtom* esds) :
-
+
AP4_MpegSampleDescription(AP4_ATOM_TYPE_MP4V, esds),
AP4_VideoSampleDescription(width, height, depth, compressor_name)
{
@@ -557,7 +497,7 @@ AP4_MpegVideoSampleDescription::AP4_MpegVideoSampleDescription(
AP4_UI32 buffer_size,
AP4_UI32 max_bitrate,
AP4_UI32 avg_bitrate) :
- AP4_MpegSampleDescription(AP4_ATOM_TYPE_MP4V,
+ AP4_MpegSampleDescription(AP4_ATOM_TYPE_MP4V,
AP4_STREAM_TYPE_VISUAL,
oti,
decoder_info,
@@ -584,164 +524,95 @@ AP4_MpegVideoSampleDescription::ToAtom() const
/*----------------------------------------------------------------------
| AP4_MpegSampleDescription::GetStreamTypeString
+---------------------------------------------------------------------*/
-const char*
+const char*
AP4_MpegSampleDescription::GetStreamTypeString(StreamType type)
{
- switch(type)
- {
- case AP4_STREAM_TYPE_FORBIDDEN:
- return "INVALID";
- case AP4_STREAM_TYPE_OD:
- return "Object Descriptor";
- case AP4_STREAM_TYPE_CR:
- return "CR";
- case AP4_STREAM_TYPE_BIFS:
- return "BIFS";
- case AP4_STREAM_TYPE_VISUAL:
- return "Visual";
- case AP4_STREAM_TYPE_AUDIO:
- return "Audio";
- case AP4_STREAM_TYPE_MPEG7:
- return "MPEG-7";
- case AP4_STREAM_TYPE_IPMP:
- return "IPMP";
- case AP4_STREAM_TYPE_OCI:
- return "OCI";
- case AP4_STREAM_TYPE_MPEGJ:
- return "MPEG-J";
- default:
- return "UNKNOWN";
+ switch (type) {
+ case AP4_STREAM_TYPE_FORBIDDEN: return "INVALID";
+ case AP4_STREAM_TYPE_OD: return "Object Descriptor";
+ case AP4_STREAM_TYPE_CR: return "CR";
+ case AP4_STREAM_TYPE_BIFS: return "BIFS";
+ case AP4_STREAM_TYPE_VISUAL: return "Visual";
+ case AP4_STREAM_TYPE_AUDIO: return "Audio";
+ case AP4_STREAM_TYPE_MPEG7: return "MPEG-7";
+ case AP4_STREAM_TYPE_IPMP: return "IPMP";
+ case AP4_STREAM_TYPE_OCI: return "OCI";
+ case AP4_STREAM_TYPE_MPEGJ: return "MPEG-J";
+ default: return "UNKNOWN";
}
}
/*----------------------------------------------------------------------
| AP4_MpegSampleDescription::GetObjectTypeString
+---------------------------------------------------------------------*/
-const char*
+const char*
AP4_MpegSampleDescription::GetObjectTypeString(OTI oti)
{
- switch(oti)
- {
- case AP4_OTI_MPEG4_SYSTEM:
- return "MPEG-4 System";
- case AP4_OTI_MPEG4_SYSTEM_COR:
- return "MPEG-4 System COR";
- case AP4_OTI_MPEG4_VISUAL:
- return "MPEG-4 Video";
- case AP4_OTI_MPEG4_AUDIO:
- return "MPEG-4 Audio";
- case AP4_OTI_MPEG2_VISUAL_SIMPLE:
- return "MPEG-2 Video Simple Profile";
- case AP4_OTI_MPEG2_VISUAL_MAIN:
- return "MPEG-2 Video Main Profile";
- case AP4_OTI_MPEG2_VISUAL_SNR:
- return "MPEG-2 Video SNR";
- case AP4_OTI_MPEG2_VISUAL_SPATIAL:
- return "MPEG-2 Video Spatial";
- case AP4_OTI_MPEG2_VISUAL_HIGH:
- return "MPEG-2 Video High";
- case AP4_OTI_MPEG2_VISUAL_422:
- return "MPEG-2 Video 4:2:2";
- case AP4_OTI_MPEG2_AAC_AUDIO_MAIN:
- return "MPEG-2 Audio AAC Main Profile";
- case AP4_OTI_MPEG2_AAC_AUDIO_LC:
- return "MPEG-2 Audio AAC Low Complexity";
- case AP4_OTI_MPEG2_AAC_AUDIO_SSRP:
- return "MPEG-2 Audio AAC SSRP";
- case AP4_OTI_MPEG2_PART3_AUDIO:
- return "MPEG-2 Audio Part-3";
- case AP4_OTI_MPEG1_VISUAL:
- return "MPEG-1 Video";
- case AP4_OTI_MPEG1_AUDIO:
- return "MPEG-1 Audio";
- case AP4_OTI_JPEG:
- return "JPEG";
- default:
- return "UNKNOWN";
+ switch (oti) {
+ case AP4_OTI_MPEG4_SYSTEM: return "MPEG-4 System";
+ case AP4_OTI_MPEG4_SYSTEM_COR: return "MPEG-4 System COR";
+ case AP4_OTI_MPEG4_VISUAL: return "MPEG-4 Video";
+ case AP4_OTI_MPEG4_AUDIO: return "MPEG-4 Audio";
+ case AP4_OTI_MPEG2_VISUAL_SIMPLE: return "MPEG-2 Video Simple Profile";
+ case AP4_OTI_MPEG2_VISUAL_MAIN: return "MPEG-2 Video Main Profile";
+ case AP4_OTI_MPEG2_VISUAL_SNR: return "MPEG-2 Video SNR";
+ case AP4_OTI_MPEG2_VISUAL_SPATIAL: return "MPEG-2 Video Spatial";
+ case AP4_OTI_MPEG2_VISUAL_HIGH: return "MPEG-2 Video High";
+ case AP4_OTI_MPEG2_VISUAL_422: return "MPEG-2 Video 4:2:2";
+ case AP4_OTI_MPEG2_AAC_AUDIO_MAIN: return "MPEG-2 Audio AAC Main Profile";
+ case AP4_OTI_MPEG2_AAC_AUDIO_LC: return "MPEG-2 Audio AAC Low Complexity";
+ case AP4_OTI_MPEG2_AAC_AUDIO_SSRP: return "MPEG-2 Audio AAC SSRP";
+ case AP4_OTI_MPEG2_PART3_AUDIO: return "MPEG-2 Audio Part-3";
+ case AP4_OTI_MPEG1_VISUAL: return "MPEG-1 Video";
+ case AP4_OTI_MPEG1_AUDIO: return "MPEG-1 Audio";
+ case AP4_OTI_JPEG: return "JPEG";
+ default: return "UNKNOWN";
}
}
/*----------------------------------------------------------------------
| AP4_MpegAudioSampleDescription::GetMpeg4AudioObjectTypeString
+---------------------------------------------------------------------*/
-const char*
+const char*
AP4_MpegAudioSampleDescription::GetMpeg4AudioObjectTypeString(Mpeg4AudioObjectType type)
{
- switch(type)
- {
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_MAIN:
- return "AAC Main Profile";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LC:
- return "AAC Low Complexity";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SSR:
- return "AAC Scalable Sample Rate";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LTP:
- return "AAC Long Term Predictor";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_SBR:
- return "Spectral Band Replication";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SCALABLE:
- return "AAC Scalable";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_TWINVQ:
- return "Twin VQ";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_CELP:
- return "CELP";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_HVXC:
- return "HVXC";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_TTSI:
- return "TTSI";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_MAIN_SYNTHETIC:
- return "Main Synthetic";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_WAVETABLE_SYNTHESIS:
- return "Wavetable Synthesis";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_GENERAL_MIDI:
- return "General MIDI";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ALGORITHMIC_SYNTHESIS:
- return "Algorithmic Synthesis";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LC:
- return "Error Resilient AAC Low Complexity";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LTP:
- return "Error Resilient AAC Long Term Prediction";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE:
- return "Error Resilient AAC Scalable";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_TWINVQ:
- return "Error Resilient Twin VQ";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_BSAC:
- return "Error Resilient Bit Sliced Arithmetic Coding";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LD:
- return "Error Resilient AAC Low Delay";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_CELP:
- return "Error Resilient CELP";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_HVXC:
- return "Error Resilient HVXC";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_HILN:
- return "Error Resilient HILN";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_PARAMETRIC:
- return "Error Resilient Parametric";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_SSC:
- return "SSC";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_MPEG_SURROUND:
- return "MPEG Surround";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_1:
- return "MPEG Layer 1";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_2:
- return "MPEG Layer 2";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_3:
- return "MPEG Layer 3";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_DST:
- return "Direct Stream Transfer";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ALS:
- return "ALS Lossless Coding";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_SLS:
- return "SLS Scalable Lossless Coding";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_SLS_NON_CORE:
- return "SLS Scalable Lossless Coding (Non Core)";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_ELD:
- return "Error Resilient AAC ELD";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_SMR_SIMPLE:
- return "SMR Simple";
- case AP4_MPEG4_AUDIO_OBJECT_TYPE_SMR_MAIN:
- return "SMR Main";
- default:
- return "UNKNOWN";
+ switch (type) {
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_MAIN: return "AAC Main Profile";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LC: return "AAC Low Complexity";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SSR: return "AAC Scalable Sample Rate";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LTP: return "AAC Long Term Predictor";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_SBR: return "Spectral Band Replication";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SCALABLE: return "AAC Scalable";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_TWINVQ: return "Twin VQ";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_CELP: return "CELP";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_HVXC: return "HVXC";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_TTSI: return "TTSI";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_MAIN_SYNTHETIC: return "Main Synthetic";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_WAVETABLE_SYNTHESIS: return "Wavetable Synthesis";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_GENERAL_MIDI: return "General MIDI";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ALGORITHMIC_SYNTHESIS: return "Algorithmic Synthesis";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LC: return "Error Resilient AAC Low Complexity";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LTP: return "Error Resilient AAC Long Term Prediction";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE: return "Error Resilient AAC Scalable";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_TWINVQ: return "Error Resilient Twin VQ";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_BSAC: return "Error Resilient Bit Sliced Arithmetic Coding";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LD: return "Error Resilient AAC Low Delay";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_CELP: return "Error Resilient CELP";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_HVXC: return "Error Resilient HVXC";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_HILN: return "Error Resilient HILN";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_PARAMETRIC: return "Error Resilient Parametric";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_SSC: return "SSC";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_MPEG_SURROUND: return "MPEG Surround";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_1: return "MPEG Layer 1";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_2: return "MPEG Layer 2";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_3: return "MPEG Layer 3";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_DST: return "Direct Stream Transfer";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ALS: return "ALS Lossless Coding";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_SLS: return "SLS Scalable Lossless Coding";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_SLS_NON_CORE: return "SLS Scalable Lossless Coding (Non Core)";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_ELD: return "Error Resilient AAC ELD";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_SMR_SIMPLE: return "SMR Simple";
+ case AP4_MPEG4_AUDIO_OBJECT_TYPE_SMR_MAIN: return "SMR Main";
+ default: return "UNKNOWN";
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.h
index d38be6658..9e60cad7d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleDescription.h
@@ -88,12 +88,11 @@ AP4_GetFormatName(AP4_UI32 format);
+---------------------------------------------------------------------*/
class AP4_SampleDescription
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST(AP4_SampleDescription)
// type constants of the sample description
- enum Type
- {
+ enum Type {
TYPE_UNKNOWN = 0x00,
TYPE_MPEG = 0x01,
TYPE_PROTECTED = 0x02,
@@ -101,30 +100,21 @@ public:
};
// constructors & destructor
- AP4_SampleDescription(Type type,
- AP4_UI32 format,
+ AP4_SampleDescription(Type type,
+ AP4_UI32 format,
AP4_AtomParent* details);
virtual ~AP4_SampleDescription() {}
virtual AP4_SampleDescription* Clone(AP4_Result* result = NULL);
-
+
// accessors
- Type GetType() const
- {
- return m_Type;
- }
- AP4_UI32 GetFormat() const
- {
- return m_Format;
- }
- AP4_AtomParent& GetDetails()
- {
- return m_Details;
- }
-
+ Type GetType() const { return m_Type; }
+ AP4_UI32 GetFormat() const { return m_Format; }
+ AP4_AtomParent& GetDetails() { return m_Details; }
+
// factories
virtual AP4_Atom* ToAtom() const;
-protected:
+ protected:
Type m_Type;
AP4_UI32 m_Format;
AP4_AtomParent m_Details;
@@ -143,14 +133,11 @@ public:
~AP4_UnknownSampleDescription();
virtual AP4_SampleDescription* Clone(AP4_Result* result);
- virtual AP4_Atom* ToAtom() const;
-
+ virtual AP4_Atom* ToAtom() const;
+
// accessor
- const AP4_Atom* GetAtom()
- {
- return m_Atom;
- }
-
+ const AP4_Atom* GetAtom() { return m_Atom; }
+
private:
AP4_Atom* m_Atom;
};
@@ -167,23 +154,14 @@ public:
AP4_AudioSampleDescription(unsigned int sample_rate,
unsigned int sample_size,
unsigned int channel_count) :
- m_SampleRate(sample_rate),
- m_SampleSize(sample_size),
- m_ChannelCount(channel_count) {}
+ m_SampleRate(sample_rate),
+ m_SampleSize(sample_size),
+ m_ChannelCount(channel_count) {}
// accessors
- AP4_UI32 GetSampleRate()
- {
- return m_SampleRate;
- }
- AP4_UI16 GetSampleSize()
- {
- return m_SampleSize;
- }
- AP4_UI16 GetChannelCount()
- {
- return m_ChannelCount;
- }
+ AP4_UI32 GetSampleRate() { return m_SampleRate; }
+ AP4_UI16 GetSampleSize() { return m_SampleSize; }
+ AP4_UI16 GetChannelCount() { return m_ChannelCount; }
protected:
// members
@@ -205,28 +183,16 @@ public:
AP4_UI16 height,
AP4_UI16 depth,
const char* compressor_name) :
- m_Width(width),
- m_Height(height),
- m_Depth(depth),
- m_CompressorName(compressor_name) {}
+ m_Width(width),
+ m_Height(height),
+ m_Depth(depth),
+ m_CompressorName(compressor_name) {}
// accessors
- AP4_UI16 GetWidth()
- {
- return m_Width;
- }
- AP4_UI16 GetHeight()
- {
- return m_Height;
- }
- AP4_UI16 GetDepth()
- {
- return m_Depth;
- }
- const char* GetCompressorName()
- {
- return m_CompressorName.GetChars();
- }
+ AP4_UI16 GetWidth() { return m_Width; }
+ AP4_UI16 GetHeight() { return m_Height; }
+ AP4_UI16 GetDepth() { return m_Depth; }
+ const char* GetCompressorName() { return m_CompressorName.GetChars(); }
protected:
// members
@@ -240,7 +206,7 @@ protected:
| AP4_GenericAudioSampleDescription
+---------------------------------------------------------------------*/
class AP4_GenericAudioSampleDescription : public AP4_SampleDescription,
- public AP4_AudioSampleDescription
+ public AP4_AudioSampleDescription
{
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D2(AP4_GenericAudioSampleDescription, AP4_SampleDescription, AP4_AudioSampleDescription)
@@ -259,7 +225,7 @@ public:
| AP4_GenericVideoSampleDescription
+---------------------------------------------------------------------*/
class AP4_GenericVideoSampleDescription : public AP4_SampleDescription,
- public AP4_VideoSampleDescription
+ public AP4_VideoSampleDescription
{
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D2(AP4_GenericVideoSampleDescription, AP4_SampleDescription, AP4_VideoSampleDescription)
@@ -271,15 +237,15 @@ public:
AP4_UI16 depth,
const char* compressor_name,
AP4_AtomParent* details) :
- AP4_SampleDescription(TYPE_UNKNOWN, format, details),
- AP4_VideoSampleDescription(width, height, depth, compressor_name) {}
+ AP4_SampleDescription(TYPE_UNKNOWN, format, details),
+ AP4_VideoSampleDescription(width, height, depth, compressor_name) {}
};
/*----------------------------------------------------------------------
| AP4_AvcSampleDescription
+---------------------------------------------------------------------*/
class AP4_AvcSampleDescription : public AP4_SampleDescription,
- public AP4_VideoSampleDescription
+ public AP4_VideoSampleDescription
{
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D2(AP4_AvcSampleDescription, AP4_SampleDescription, AP4_VideoSampleDescription)
@@ -290,7 +256,7 @@ public:
AP4_UI16 depth,
const char* compressor_name,
const AP4_AvccAtom* avcc);
-
+
AP4_AvcSampleDescription(AP4_UI16 width,
AP4_UI16 height,
AP4_UI16 depth,
@@ -307,47 +273,22 @@ public:
AP4_UI08 nalu_length_size,
const AP4_Array<AP4_DataBuffer>& sequence_parameters,
const AP4_Array<AP4_DataBuffer>& picture_parameters);
-
+
// accessors
- AP4_UI08 GetConfigurationVersion() const
- {
- return m_AvccAtom->GetConfigurationVersion();
- }
- AP4_UI08 GetProfile() const
- {
- return m_AvccAtom->GetProfile();
- }
- AP4_UI08 GetLevel() const
- {
- return m_AvccAtom->GetLevel();
- }
- AP4_UI08 GetProfileCompatibility() const
- {
- return m_AvccAtom->GetProfileCompatibility();
- }
- AP4_UI08 GetNaluLengthSize() const
- {
- return m_AvccAtom->GetNaluLengthSize();
- }
- AP4_Array<AP4_DataBuffer>& GetSequenceParameters()
- {
- return m_AvccAtom->GetSequenceParameters();
- }
- AP4_Array<AP4_DataBuffer>& GetPictureParameters()
- {
- return m_AvccAtom->GetPictureParameters();
- }
- const AP4_DataBuffer& GetRawBytes() const
- {
- return m_AvccAtom->GetRawBytes();
- }
-
+ AP4_UI08 GetConfigurationVersion() const { return m_AvccAtom->GetConfigurationVersion(); }
+ AP4_UI08 GetProfile() const { return m_AvccAtom->GetProfile(); }
+ AP4_UI08 GetLevel() const { return m_AvccAtom->GetLevel(); }
+ AP4_UI08 GetProfileCompatibility() const { return m_AvccAtom->GetProfileCompatibility(); }
+ AP4_UI08 GetNaluLengthSize() const { return m_AvccAtom->GetNaluLengthSize(); }
+ AP4_Array<AP4_DataBuffer>& GetSequenceParameters() {return m_AvccAtom->GetSequenceParameters(); }
+ AP4_Array<AP4_DataBuffer>& GetPictureParameters() { return m_AvccAtom->GetPictureParameters(); }
+ const AP4_DataBuffer& GetRawBytes() const { return m_AvccAtom->GetRawBytes(); }
+
// inherited from AP4_SampleDescription
virtual AP4_Atom* ToAtom() const;
-
+
// static methods
- static const char* GetProfileName(AP4_UI08 profile)
- {
+ static const char* GetProfileName(AP4_UI08 profile) {
return AP4_AvccAtom::GetProfileName(profile);
}
@@ -360,13 +301,13 @@ private:
+---------------------------------------------------------------------*/
class AP4_MpegSampleDescription : public AP4_SampleDescription
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_MpegSampleDescription, AP4_SampleDescription)
// types
typedef AP4_UI08 StreamType;
typedef AP4_UI08 OTI;
-
+
// class methods
static const char* GetStreamTypeString(StreamType type);
static const char* GetObjectTypeString(OTI oti);
@@ -381,37 +322,19 @@ public:
AP4_UI32 buffer_size,
AP4_UI32 max_bitrate,
AP4_UI32 avg_bitrate);
-
+
// accessors
- AP4_Byte GetStreamType() const
- {
- return m_StreamType;
- }
- AP4_Byte GetObjectTypeId() const
- {
- return m_ObjectTypeId;
- }
- AP4_UI32 GetBufferSize() const
- {
- return m_BufferSize;
- }
- AP4_UI32 GetMaxBitrate() const
- {
- return m_MaxBitrate;
- }
- AP4_UI32 GetAvgBitrate() const
- {
- return m_AvgBitrate;
- }
- const AP4_DataBuffer& GetDecoderInfo() const
- {
- return m_DecoderInfo;
- }
+ AP4_Byte GetStreamType() const { return m_StreamType; }
+ AP4_Byte GetObjectTypeId() const { return m_ObjectTypeId; }
+ AP4_UI32 GetBufferSize() const { return m_BufferSize; }
+ AP4_UI32 GetMaxBitrate() const { return m_MaxBitrate; }
+ AP4_UI32 GetAvgBitrate() const { return m_AvgBitrate; }
+ const AP4_DataBuffer& GetDecoderInfo() const { return m_DecoderInfo; }
// methods
AP4_EsDescriptor* CreateEsDescriptor() const;
-protected:
+ protected:
// members
AP4_UI32 m_Format;
StreamType m_StreamType;
@@ -447,23 +370,23 @@ public:
| AP4_MpegAudioSampleDescription
+---------------------------------------------------------------------*/
class AP4_MpegAudioSampleDescription : public AP4_MpegSampleDescription,
- public AP4_AudioSampleDescription
+ public AP4_AudioSampleDescription
{
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D2(AP4_MpegAudioSampleDescription, AP4_MpegSampleDescription, AP4_AudioSampleDescription)
// types
typedef AP4_UI08 Mpeg4AudioObjectType;
-
+
// class methods
static const char* GetMpeg4AudioObjectTypeString(Mpeg4AudioObjectType type);
-
+
// constructor
AP4_MpegAudioSampleDescription(unsigned int sample_rate,
unsigned int sample_size,
unsigned int channel_count,
AP4_EsdsAtom* esds);
-
+
AP4_MpegAudioSampleDescription(OTI oti,
unsigned int sample_rate,
unsigned int sample_size,
@@ -477,8 +400,8 @@ public:
AP4_Atom* ToAtom() const;
/**
- * For sample descriptions of MPEG-4 audio tracks (i.e GetObjectTypeId()
- * returns AP4_OTI_MPEG4_AUDIO), this method returns the MPEG4 Audio Object
+ * For sample descriptions of MPEG-4 audio tracks (i.e GetObjectTypeId()
+ * returns AP4_OTI_MPEG4_AUDIO), this method returns the MPEG4 Audio Object
* Type. For other sample descriptions, this method returns 0.
*/
Mpeg4AudioObjectType GetMpeg4AudioObjectType() const;
@@ -488,7 +411,7 @@ public:
| AP4_MpegVideoSampleDescription
+---------------------------------------------------------------------*/
class AP4_MpegVideoSampleDescription : public AP4_MpegSampleDescription,
- public AP4_VideoSampleDescription
+ public AP4_VideoSampleDescription
{
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D2(AP4_MpegVideoSampleDescription, AP4_MpegSampleDescription, AP4_VideoSampleDescription)
@@ -499,7 +422,7 @@ public:
AP4_UI16 depth,
const char* compressor_name,
AP4_EsdsAtom* esds);
-
+
AP4_MpegVideoSampleDescription(OTI oti,
AP4_UI16 width,
AP4_UI16 height,
@@ -519,7 +442,7 @@ public:
+---------------------------------------------------------------------*/
const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_FORBIDDEN = 0x00;
const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_OD = 0x01;
-const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_CR = 0x02;
+const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_CR = 0x02;
const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_BIFS = 0x03;
const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_VISUAL = 0x04;
const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_AUDIO = 0x05;
@@ -587,8 +510,8 @@ const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_SMR_SIMPLE = 40; /**< SMR
const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_SMR_MAIN = 41; /**< SMR Main */
// ==> Start patch MPC
-const AP4_MpegSampleDescription::OTI AP4_NERO_VOBSUB = 0xE0;
-// <== End patch MPC
+const AP4_MpegSampleDescription::OTI AP4_NERO_VOBSUB = 0xE0;
+// <== End patch MPC
#endif // _AP4_SAMPLE_DESCRIPTION_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.cpp
index ee975ab08..086401b01 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.cpp
@@ -93,11 +93,10 @@ AP4_SampleEntry::Read(AP4_ByteStream& stream, AP4_AtomFactory& atom_factory)
// read children atoms (ex: esds and maybe others)
// NOTE: not all sample entries have children atoms
- AP4_Size payload_size = (AP4_Size)(GetSize() - GetHeaderSize());
+ AP4_Size payload_size = (AP4_Size)(GetSize()-GetHeaderSize());
AP4_Size fields_size = GetFieldsSize();
- if(payload_size > fields_size)
- {
- ReadChildren(atom_factory, stream, payload_size - fields_size);
+ if (payload_size > fields_size) {
+ ReadChildren(atom_factory, stream, payload_size-fields_size);
}
}
@@ -129,15 +128,15 @@ AP4_Result
AP4_SampleEntry::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
+
// reserved1
result = stream.Write(m_Reserved1, sizeof(m_Reserved1));
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// data reference index
result = stream.WriteUI16(m_DataReferenceIndex);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
return result;
}
@@ -151,11 +150,11 @@ AP4_SampleEntry::Write(AP4_ByteStream& stream)
// write the header
result = WriteHeader(stream);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// write the fields
result = WriteFields(stream);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// write the children atoms
return m_Children.Apply(AP4_AtomListWriter(stream));
@@ -200,12 +199,12 @@ void
AP4_SampleEntry::OnChildChanged(AP4_Atom*)
{
// recompute our size
- AP4_UI64 size = GetHeaderSize() + GetFieldsSize();
+ AP4_UI64 size = GetHeaderSize()+GetFieldsSize();
m_Children.Apply(AP4_AtomSizeAdder(size));
m_Size32 = (AP4_UI32)size;
// update our parent
- if(m_Parent) m_Parent->OnChildChanged(this);
+ if (m_Parent) m_Parent->OnChildChanged(this);
}
/*----------------------------------------------------------------------
@@ -220,14 +219,13 @@ AP4_SampleEntry::ToSampleDescription()
/*----------------------------------------------------------------------
| AP4_UnknownSampleEntry::AP4_UnknownSampleEntry
+---------------------------------------------------------------------*/
-AP4_UnknownSampleEntry::AP4_UnknownSampleEntry(AP4_Atom::Type type,
- AP4_Size size,
- AP4_ByteStream& stream) :
+AP4_UnknownSampleEntry::AP4_UnknownSampleEntry(AP4_Atom::Type type,
+ AP4_Size size,
+ AP4_ByteStream& stream) :
AP4_SampleEntry(type, size)
{
- if(size > AP4_ATOM_HEADER_SIZE + AP4_SampleEntry::GetFieldsSize())
- {
- m_Payload.SetDataSize(size - (AP4_ATOM_HEADER_SIZE + AP4_SampleEntry::GetFieldsSize()));
+ if (size > AP4_ATOM_HEADER_SIZE+AP4_SampleEntry::GetFieldsSize()) {
+ m_Payload.SetDataSize(size-(AP4_ATOM_HEADER_SIZE+AP4_SampleEntry::GetFieldsSize()));
ReadFields(stream);
}
}
@@ -235,7 +233,7 @@ AP4_UnknownSampleEntry::AP4_UnknownSampleEntry(AP4_Atom::Type type,
/*----------------------------------------------------------------------
| AP4_UnknownSampleEntry::ToSampleDescription
+---------------------------------------------------------------------*/
-AP4_SampleDescription*
+AP4_SampleDescription*
AP4_UnknownSampleEntry::ToSampleDescription()
{
return new AP4_UnknownSampleDescription(this);
@@ -244,10 +242,10 @@ AP4_UnknownSampleEntry::ToSampleDescription()
/*----------------------------------------------------------------------
| AP4_UnknownSampleEntry::GetFieldsSize
+---------------------------------------------------------------------*/
-AP4_Size
+AP4_Size
AP4_UnknownSampleEntry::GetFieldsSize()
{
- return AP4_SampleEntry::GetFieldsSize() + m_Payload.GetDataSize();
+ return AP4_SampleEntry::GetFieldsSize()+m_Payload.GetDataSize();
}
/*----------------------------------------------------------------------
@@ -258,8 +256,8 @@ AP4_UnknownSampleEntry::ReadFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// read the payload
return stream.Read(m_Payload.UseData(), m_Payload.GetDataSize());
}
@@ -271,11 +269,11 @@ AP4_Result
AP4_UnknownSampleEntry::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
+
// write the fields of the base class
result = AP4_SampleEntry::WriteFields(stream);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// write the payload
return stream.Write(m_Payload.GetData(), m_Payload.GetDataSize());
}
@@ -288,7 +286,7 @@ AP4_MpegSystemSampleEntry::AP4_MpegSystemSampleEntry(
AP4_EsDescriptor* descriptor) :
AP4_SampleEntry(type)
{
- if(descriptor) AddChild(new AP4_EsdsAtom(descriptor));
+ if (descriptor) AddChild(new AP4_EsdsAtom(descriptor));
}
/*----------------------------------------------------------------------
@@ -310,7 +308,7 @@ AP4_SampleDescription*
AP4_MpegSystemSampleEntry::ToSampleDescription()
{
return new AP4_MpegSystemSampleDescription(
- AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS)));
+ AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS)));
}
/*----------------------------------------------------------------------
@@ -325,8 +323,8 @@ AP4_Mp4sSampleEntry::AP4_Mp4sSampleEntry(AP4_EsDescriptor* descriptor) :
| AP4_Mp4sSampleEntry::AP4_Mp4sSampleEntry
+---------------------------------------------------------------------*/
AP4_Mp4sSampleEntry::AP4_Mp4sSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_MpegSystemSampleEntry(AP4_ATOM_TYPE_MP4S, size, stream, atom_factory)
{
}
@@ -339,16 +337,16 @@ AP4_Mp4sSampleEntry::ToSampleDescription()
{
// create a sample description
return new AP4_MpegSystemSampleDescription(
- AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS)));
+ AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS)));
}
/*----------------------------------------------------------------------
| AP4_AudioSampleEntry::AP4_AudioSampleEntry
+---------------------------------------------------------------------*/
AP4_AudioSampleEntry::AP4_AudioSampleEntry(AP4_Atom::Type format,
- AP4_UI32 sample_rate,
- AP4_UI16 sample_size,
- AP4_UI16 channel_count) :
+ AP4_UI32 sample_rate,
+ AP4_UI16 sample_size,
+ AP4_UI16 channel_count) :
AP4_SampleEntry(format),
m_QtVersion(0),
m_QtRevision(0),
@@ -369,7 +367,7 @@ AP4_AudioSampleEntry::AP4_AudioSampleEntry(AP4_Atom::Type format,
m_QtV2BitsPerChannel(0),
m_QtV2FormatSpecificFlags(0),
m_QtV2BytesPerAudioPacket(0),
- m_QtV2LPCMFramesPerAudioPacket(0)
+ m_QtV2LPCMFramesPerAudioPacket(0)
{
m_Size32 += 20;
}
@@ -378,30 +376,27 @@ AP4_AudioSampleEntry::AP4_AudioSampleEntry(AP4_Atom::Type format,
| AP4_AudioSampleEntry::AP4_AudioSampleEntry
+---------------------------------------------------------------------*/
AP4_AudioSampleEntry::AP4_AudioSampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_Size size,
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_SampleEntry(format, size)
{
Read(stream, atom_factory);
}
-
+
/*----------------------------------------------------------------------
| AP4_AudioSampleEntry::GetFieldsSize
+---------------------------------------------------------------------*/
AP4_Size
AP4_AudioSampleEntry::GetFieldsSize()
{
- AP4_Size size = AP4_SampleEntry::GetFieldsSize() + 20;
- if(m_QtVersion == 1)
- {
+ AP4_Size size = AP4_SampleEntry::GetFieldsSize()+20;
+ if (m_QtVersion == 1) {
size += 16;
+ } else if (m_QtVersion == 2) {
+ size += 36+m_QtV2Extension.GetDataSize();
}
- else if(m_QtVersion == 2)
- {
- size += 36 + m_QtV2Extension.GetDataSize();
- }
-
+
return size;
}
@@ -411,13 +406,10 @@ AP4_AudioSampleEntry::GetFieldsSize()
AP4_UI32
AP4_AudioSampleEntry::GetSampleRate()
{
- if(m_QtVersion == 2)
- {
+ if (m_QtVersion == 2) {
return (AP4_UI32)(m_QtV2SampleRate64);
- }
- else
- {
- return m_SampleRate >> 16;
+ } else {
+ return m_SampleRate>>16;
}
}
@@ -427,12 +419,9 @@ AP4_AudioSampleEntry::GetSampleRate()
AP4_UI16
AP4_AudioSampleEntry::GetChannelCount()
{
- if(m_QtVersion == 2)
- {
+ if (m_QtVersion == 2) {
return m_QtV2ChannelCount;
- }
- else
- {
+ } else {
return m_ChannelCount;
}
}
@@ -445,7 +434,7 @@ AP4_AudioSampleEntry::ReadFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if(result < 0) return result;
+ if (result < 0) return result;
// read the fields of this class
stream.ReadUI16(m_QtVersion);
@@ -458,15 +447,12 @@ AP4_AudioSampleEntry::ReadFields(AP4_ByteStream& stream)
stream.ReadUI32(m_SampleRate);
// if this is a QT V1 entry, read the extension
- if(m_QtVersion == 1)
- {
+ if (m_QtVersion == 1) {
stream.ReadUI32(m_QtV1SamplesPerPacket);
stream.ReadUI32(m_QtV1BytesPerPacket);
stream.ReadUI32(m_QtV1BytesPerFrame);
stream.ReadUI32(m_QtV1BytesPerSample);
- }
- else if(m_QtVersion == 2)
- {
+ } else if (m_QtVersion == 2) {
stream.ReadUI32(m_QtV2StructSize);
stream.ReadDouble(m_QtV2SampleRate64);
stream.ReadUI32(m_QtV2ChannelCount);
@@ -475,19 +461,16 @@ AP4_AudioSampleEntry::ReadFields(AP4_ByteStream& stream)
stream.ReadUI32(m_QtV2FormatSpecificFlags);
stream.ReadUI32(m_QtV2BytesPerAudioPacket);
stream.ReadUI32(m_QtV2LPCMFramesPerAudioPacket);
- if(m_QtV2StructSize > 72)
- {
- unsigned int ext_size = m_QtV2StructSize - 72;
+ if (m_QtV2StructSize > 72) {
+ unsigned int ext_size = m_QtV2StructSize-72;
m_QtV2Extension.SetDataSize(ext_size);
stream.Read(m_QtV2Extension.UseData(), ext_size);
}
m_QtV1SamplesPerPacket =
- m_QtV1BytesPerPacket =
- m_QtV1BytesPerFrame =
- m_QtV1BytesPerSample = 0;
- }
- else
- {
+ m_QtV1BytesPerPacket =
+ m_QtV1BytesPerFrame =
+ m_QtV1BytesPerSample = 0;
+ } else {
m_QtV1SamplesPerPacket = 0;
m_QtV1BytesPerPacket = 0;
m_QtV1BytesPerFrame = 0;
@@ -501,7 +484,7 @@ AP4_AudioSampleEntry::ReadFields(AP4_ByteStream& stream)
m_QtV2BytesPerAudioPacket = 0;
m_QtV2LPCMFramesPerAudioPacket = 0;
}
-
+
return AP4_SUCCESS;
}
@@ -512,55 +495,52 @@ AP4_Result
AP4_AudioSampleEntry::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
+
// write the fields of the base class
result = AP4_SampleEntry::WriteFields(stream);
// QT version
result = stream.WriteUI16(m_QtVersion);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// QT revision
result = stream.WriteUI16(m_QtRevision);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// QT vendor
result = stream.WriteUI32(m_QtVendor);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// channel count
result = stream.WriteUI16(m_ChannelCount);
- if(AP4_FAILED(result)) return result;
-
- // sample size
+ if (AP4_FAILED(result)) return result;
+
+ // sample size
result = stream.WriteUI16(m_SampleSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// QT compression ID
result = stream.WriteUI16(m_QtCompressionId);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// QT packet size
result = stream.WriteUI16(m_QtPacketSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// sample rate
result = stream.WriteUI32(m_SampleRate);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
- if(m_QtVersion == 1)
- {
+ if (m_QtVersion == 1) {
result = stream.WriteUI32(m_QtV1SamplesPerPacket);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_QtV1BytesPerPacket);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_QtV1BytesPerFrame);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_QtV1BytesPerSample);
- if(AP4_FAILED(result)) return result;
- }
- else if(m_QtVersion == 2)
- {
+ if (AP4_FAILED(result)) return result;
+ } else if (m_QtVersion == 2) {
stream.WriteUI32(m_QtV2StructSize);
stream.WriteDouble(m_QtV2SampleRate64);
stream.WriteUI32(m_QtV2ChannelCount);
@@ -569,13 +549,12 @@ AP4_AudioSampleEntry::WriteFields(AP4_ByteStream& stream)
stream.WriteUI32(m_QtV2FormatSpecificFlags);
stream.WriteUI32(m_QtV2BytesPerAudioPacket);
stream.WriteUI32(m_QtV2LPCMFramesPerAudioPacket);
- if(m_QtV2Extension.GetDataSize())
- {
+ if (m_QtV2Extension.GetDataSize()) {
stream.Write(m_QtV2Extension.GetData(),
m_QtV2Extension.GetDataSize());
}
}
-
+
return result;
}
@@ -592,11 +571,10 @@ AP4_AudioSampleEntry::InspectFields(AP4_AtomInspector& inspector)
inspector.AddField("channel_count", GetChannelCount());
inspector.AddField("sample_size", GetSampleSize());
inspector.AddField("sample_rate", GetSampleRate());
- if(m_QtVersion)
- {
+ if (m_QtVersion) {
inspector.AddField("qt_version", m_QtVersion);
}
-
+
return AP4_SUCCESS;
}
@@ -608,11 +586,11 @@ AP4_AudioSampleEntry::ToSampleDescription()
{
// create a sample description
return new AP4_GenericAudioSampleDescription(
- m_Type,
- GetSampleRate(),
- GetSampleSize(),
- GetChannelCount(),
- this);
+ m_Type,
+ GetSampleRate(),
+ GetSampleSize(),
+ GetChannelCount(),
+ this);
}
/*----------------------------------------------------------------------
@@ -620,13 +598,13 @@ AP4_AudioSampleEntry::ToSampleDescription()
+---------------------------------------------------------------------*/
AP4_MpegAudioSampleEntry::AP4_MpegAudioSampleEntry(
AP4_UI32 type,
- AP4_UI32 sample_rate,
+ AP4_UI32 sample_rate,
AP4_UI16 sample_size,
AP4_UI16 channel_count,
AP4_EsDescriptor* descriptor) :
AP4_AudioSampleEntry(type, sample_rate, sample_size, channel_count)
{
- if(descriptor) AddChild(new AP4_EsdsAtom(descriptor));
+ if (descriptor) AddChild(new AP4_EsdsAtom(descriptor));
}
/*----------------------------------------------------------------------
@@ -649,32 +627,30 @@ AP4_MpegAudioSampleEntry::ToSampleDescription()
{
// find the esds atom
AP4_EsdsAtom* esds = AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS));
- if(esds == NULL)
- {
+ if (esds == NULL) {
// check if this is a quicktime style sample description
- if(m_QtVersion > 0)
- {
+ if (m_QtVersion > 0) {
esds = AP4_DYNAMIC_CAST(AP4_EsdsAtom, FindChild("wave/esds"));
}
}
-
+
// create a sample description
return new AP4_MpegAudioSampleDescription(GetSampleRate(),
- GetSampleSize(),
- GetChannelCount(),
- esds);
+ GetSampleSize(),
+ GetChannelCount(),
+ esds);
}
/*----------------------------------------------------------------------
| AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry
+---------------------------------------------------------------------*/
-AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry(AP4_UI32 sample_rate,
- AP4_UI16 sample_size,
- AP4_UI16 channel_count,
- AP4_EsDescriptor* descriptor) :
- AP4_MpegAudioSampleEntry(AP4_ATOM_TYPE_MP4A,
- sample_rate,
- sample_size,
+AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry(AP4_UI32 sample_rate,
+ AP4_UI16 sample_size,
+ AP4_UI16 channel_count,
+ AP4_EsDescriptor* descriptor) :
+ AP4_MpegAudioSampleEntry(AP4_ATOM_TYPE_MP4A,
+ sample_rate,
+ sample_size,
channel_count,
descriptor)
{
@@ -684,8 +660,8 @@ AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry(AP4_UI32 sample_rate,
| AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry
+---------------------------------------------------------------------*/
AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_MpegAudioSampleEntry(AP4_ATOM_TYPE_MP4A, size, stream, atom_factory)
{
}
@@ -694,7 +670,7 @@ AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry(AP4_Size size,
| AP4_VisualSampleEntry::AP4_VisualSampleEntry
+---------------------------------------------------------------------*/
AP4_VisualSampleEntry::AP4_VisualSampleEntry(
- AP4_Atom::Type format,
+ AP4_Atom::Type format,
AP4_UI16 width,
AP4_UI16 height,
AP4_UI16 depth,
@@ -720,9 +696,9 @@ AP4_VisualSampleEntry::AP4_VisualSampleEntry(
| AP4_VisualSampleEntry::AP4_VisualSampleEntry
+---------------------------------------------------------------------*/
AP4_VisualSampleEntry::AP4_VisualSampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_Size size,
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_SampleEntry(format, size)
{
Read(stream, atom_factory);
@@ -734,7 +710,7 @@ AP4_VisualSampleEntry::AP4_VisualSampleEntry(AP4_Atom::Type format,
AP4_Size
AP4_VisualSampleEntry::GetFieldsSize()
{
- return AP4_SampleEntry::GetFieldsSize() + 70;
+ return AP4_SampleEntry::GetFieldsSize()+70;
}
/*----------------------------------------------------------------------
@@ -745,7 +721,7 @@ AP4_VisualSampleEntry::ReadFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if(result < 0) return result;
+ if (result < 0) return result;
// read fields from this class
stream.ReadUI16(m_Predefined1);
@@ -761,8 +737,7 @@ AP4_VisualSampleEntry::ReadFields(AP4_ByteStream& stream)
char compressor_name[33];
stream.Read(compressor_name, 32);
int name_length = compressor_name[0];
- if(name_length < 32)
- {
+ if (name_length < 32) {
compressor_name[name_length+1] = 0; // force null termination
m_CompressorName = &compressor_name[1];
}
@@ -780,71 +755,69 @@ AP4_Result
AP4_VisualSampleEntry::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
+
// write the fields of the base class
result = AP4_SampleEntry::WriteFields(stream);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// predefined1
result = stream.WriteUI16(m_Predefined1);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// reserved2
result = stream.WriteUI16(m_Reserved2);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// predefined2
result = stream.Write(m_Predefined2, sizeof(m_Predefined2));
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// width
result = stream.WriteUI16(m_Width);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// height
result = stream.WriteUI16(m_Height);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// horizontal resolution
result = stream.WriteUI32(m_HorizResolution);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// vertical resolution
result = stream.WriteUI32(m_VertResolution);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// reserved3
result = stream.WriteUI32(m_Reserved3);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// frame count
result = stream.WriteUI16(m_FrameCount);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// compressor name
unsigned char compressor_name[32];
unsigned int name_length = m_CompressorName.GetLength();
- if(name_length > 31) name_length = 31;
+ if (name_length > 31) name_length = 31;
compressor_name[0] = name_length;
- for(unsigned int i = 0; i < name_length; i++)
- {
+ for (unsigned int i=0; i<name_length; i++) {
compressor_name[i+1] = m_CompressorName[i];
}
- for(unsigned int i = name_length + 1; i < 32; i++)
- {
+ for (unsigned int i=name_length+1; i<32; i++) {
compressor_name[i] = 0;
}
result = stream.Write(compressor_name, 32);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// depth
result = stream.WriteUI16(m_Depth);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// predefined3
result = stream.WriteUI16(m_Predefined3);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
return result;
}
@@ -873,12 +846,12 @@ AP4_VisualSampleEntry::ToSampleDescription()
{
// create a sample description
return new AP4_GenericVideoSampleDescription(
- m_Type,
- m_Width,
- m_Height,
- m_Depth,
- m_CompressorName.GetChars(),
- this);
+ m_Type,
+ m_Width,
+ m_Height,
+ m_Depth,
+ m_CompressorName.GetChars(),
+ this);
}
/*----------------------------------------------------------------------
@@ -891,13 +864,13 @@ AP4_MpegVideoSampleEntry::AP4_MpegVideoSampleEntry(
AP4_UI16 depth,
const char* compressor_name,
AP4_EsDescriptor* descriptor) :
- AP4_VisualSampleEntry(type,
- width,
- height,
- depth,
+ AP4_VisualSampleEntry(type,
+ width,
+ height,
+ depth,
compressor_name)
{
- if(descriptor) AddChild(new AP4_EsdsAtom(descriptor));
+ if (descriptor) AddChild(new AP4_EsdsAtom(descriptor));
}
/*----------------------------------------------------------------------
@@ -920,25 +893,25 @@ AP4_MpegVideoSampleEntry::ToSampleDescription()
{
// create a sample description
return new AP4_MpegVideoSampleDescription(
- m_Width,
- m_Height,
- m_Depth,
- m_CompressorName.GetChars(),
- AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS)));
+ m_Width,
+ m_Height,
+ m_Depth,
+ m_CompressorName.GetChars(),
+ AP4_DYNAMIC_CAST(AP4_EsdsAtom, GetChild(AP4_ATOM_TYPE_ESDS)));
}
/*----------------------------------------------------------------------
| AP4_Mp4vSampleEntry::AP4_Mp4vSampleEntry
+---------------------------------------------------------------------*/
AP4_Mp4vSampleEntry::AP4_Mp4vSampleEntry(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- AP4_EsDescriptor* descriptor) :
- AP4_MpegVideoSampleEntry(AP4_ATOM_TYPE_MP4V,
- width,
- height,
- depth,
+ AP4_UI16 height,
+ AP4_UI16 depth,
+ const char* compressor_name,
+ AP4_EsDescriptor* descriptor) :
+ AP4_MpegVideoSampleEntry(AP4_ATOM_TYPE_MP4V,
+ width,
+ height,
+ depth,
compressor_name,
descriptor)
{
@@ -948,8 +921,8 @@ AP4_Mp4vSampleEntry::AP4_Mp4vSampleEntry(AP4_UI16 width,
| AP4_Mp4vSampleEntry::AP4_Mp4aSampleEntry
+---------------------------------------------------------------------*/
AP4_Mp4vSampleEntry::AP4_Mp4vSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_MpegVideoSampleEntry(AP4_ATOM_TYPE_MP4V, size, stream, atom_factory)
{
}
@@ -958,25 +931,25 @@ AP4_Mp4vSampleEntry::AP4_Mp4vSampleEntry(AP4_Size size,
| AP4_Avc1SampleEntry::AP4_Avc1SampleEntry
+---------------------------------------------------------------------*/
AP4_Avc1SampleEntry::AP4_Avc1SampleEntry(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- const AP4_AvccAtom& avcc) :
- AP4_VisualSampleEntry(AP4_ATOM_TYPE_AVC1,
- width,
- height,
- depth,
+ AP4_UI16 height,
+ AP4_UI16 depth,
+ const char* compressor_name,
+ const AP4_AvccAtom& avcc) :
+ AP4_VisualSampleEntry(AP4_ATOM_TYPE_AVC1,
+ width,
+ height,
+ depth,
compressor_name)
{
- AddChild(new AP4_AvccAtom(avcc));
+ AddChild(new AP4_AvccAtom(avcc));
}
/*----------------------------------------------------------------------
| AP4_Avc1SampleEntry::AP4_Avc1SampleEntry
+---------------------------------------------------------------------*/
AP4_Avc1SampleEntry::AP4_Avc1SampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
AP4_VisualSampleEntry(AP4_ATOM_TYPE_AVC1, size, stream, atom_factory)
{
}
@@ -988,20 +961,20 @@ AP4_SampleDescription*
AP4_Avc1SampleEntry::ToSampleDescription()
{
return new AP4_AvcSampleDescription(
- m_Width,
- m_Height,
- m_Depth,
- m_CompressorName.GetChars(),
- AP4_DYNAMIC_CAST(AP4_AvccAtom, GetChild(AP4_ATOM_TYPE_AVCC)));
+ m_Width,
+ m_Height,
+ m_Depth,
+ m_CompressorName.GetChars(),
+ AP4_DYNAMIC_CAST(AP4_AvccAtom, GetChild(AP4_ATOM_TYPE_AVCC)));
}
/*----------------------------------------------------------------------
| AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry
+---------------------------------------------------------------------*/
AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry(AP4_UI16 hint_track_version,
- AP4_UI16 highest_compatible_version,
- AP4_UI32 max_packet_size,
- AP4_UI32 timescale):
+ AP4_UI16 highest_compatible_version,
+ AP4_UI32 max_packet_size,
+ AP4_UI32 timescale):
AP4_SampleEntry(AP4_ATOM_TYPE_RTP_),
m_HintTrackVersion(hint_track_version),
m_HighestCompatibleVersion(highest_compatible_version),
@@ -1015,8 +988,8 @@ AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry(AP4_UI16 hint_track_version,
| AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry
+---------------------------------------------------------------------*/
AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory):
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory):
AP4_SampleEntry(AP4_ATOM_TYPE_RTP_, size)
{
Read(stream, atom_factory);
@@ -1028,7 +1001,7 @@ AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry(AP4_Size size,
AP4_Size
AP4_RtpHintSampleEntry::GetFieldsSize()
{
- return AP4_SampleEntry::GetFieldsSize() + 8;
+ return AP4_SampleEntry::GetFieldsSize()+8;
}
/*----------------------------------------------------------------------
@@ -1039,15 +1012,15 @@ AP4_RtpHintSampleEntry::ReadFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if(result < 0) return result;
+ if (result < 0) return result;
// data
result = stream.ReadUI16(m_HintTrackVersion);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_HighestCompatibleVersion);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI32(m_MaxPacketSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return AP4_SUCCESS;
}
@@ -1060,15 +1033,15 @@ AP4_RtpHintSampleEntry::WriteFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::WriteFields(stream);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// data
result = stream.WriteUI16(m_HintTrackVersion);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI16(m_HighestCompatibleVersion);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_MaxPacketSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return result;
}
@@ -1081,12 +1054,12 @@ AP4_RtpHintSampleEntry::InspectFields(AP4_AtomInspector& inspector)
{
// sample entry
AP4_SampleEntry::InspectFields(inspector);
-
+
// fields
inspector.AddField("hint_track_version", m_HintTrackVersion);
inspector.AddField("highest_compatible_version", m_HighestCompatibleVersion);
inspector.AddField("max_packet_size", m_MaxPacketSize);
-
+
return AP4_SUCCESS;
}
@@ -1095,8 +1068,8 @@ AP4_RtpHintSampleEntry::InspectFields(AP4_AtomInspector& inspector)
| AP4_TextSampleEntry::AP4_TextSampleEntry
+---------------------------------------------------------------------*/
AP4_TextSampleEntry::AP4_TextSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory):
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory):
AP4_SampleEntry(AP4_ATOM_TYPE_TEXT, size)
{
// read fields
@@ -1106,7 +1079,7 @@ AP4_TextSampleEntry::AP4_TextSampleEntry(AP4_Size size,
/*----------------------------------------------------------------------
| AP4_TextSampleEntry::~AP4_TextSampleEntry
+---------------------------------------------------------------------*/
-AP4_TextSampleEntry::~AP4_TextSampleEntry()
+AP4_TextSampleEntry::~AP4_TextSampleEntry()
{
}
@@ -1118,37 +1091,37 @@ AP4_TextSampleEntry::ReadFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if(result < 0) return result;
+ if (result < 0) return result;
// data
result = stream.ReadUI32(m_Description.DisplayFlags);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI32(m_Description.TextJustification);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.Read(&m_Description.BackgroundColor, 4);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.TextBox.Top);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.TextBox.Left);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.TextBox.Bottom);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.TextBox.Right);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.Style.StartChar);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.Style.EndChar);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.Style.Ascent);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.Style.Font.Id);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI08(m_Description.Style.Font.Face);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI08(m_Description.Style.Font.Size);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.Read(&m_Description.Style.Font.Color, 4);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// TODO: stream.ReadString(); -> m_Description.DefaultFontName
@@ -1163,8 +1136,8 @@ AP4_TextSampleEntry::WriteFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::WriteFields(stream);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// TODO: data
return result;
@@ -1178,9 +1151,9 @@ AP4_TextSampleEntry::InspectFields(AP4_AtomInspector& inspector)
{
// sample entry
AP4_SampleEntry::InspectFields(inspector);
-
+
// TODO: fields
-
+
return AP4_SUCCESS;
}
@@ -1188,8 +1161,8 @@ AP4_TextSampleEntry::InspectFields(AP4_AtomInspector& inspector)
| AP4_Tx3gSampleEntry::AP4_Tx3gSampleEntry
+---------------------------------------------------------------------*/
AP4_Tx3gSampleEntry::AP4_Tx3gSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory):
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory):
AP4_SampleEntry(AP4_ATOM_TYPE_TX3G, size)
{
// read fields
@@ -1197,13 +1170,13 @@ AP4_Tx3gSampleEntry::AP4_Tx3gSampleEntry(AP4_Size size,
ReadFields(stream);
// read children atoms (fdat? blnk?)
- ReadChildren(atom_factory, stream, size - AP4_ATOM_HEADER_SIZE - fields_size);
+ ReadChildren(atom_factory, stream, size-AP4_ATOM_HEADER_SIZE-fields_size);
}
/*----------------------------------------------------------------------
| AP4_Tx3gSampleEntry::~AP4_Tx3gSampleEntry
+---------------------------------------------------------------------*/
-AP4_Tx3gSampleEntry::~AP4_Tx3gSampleEntry()
+AP4_Tx3gSampleEntry::~AP4_Tx3gSampleEntry()
{
}
@@ -1213,7 +1186,7 @@ AP4_Tx3gSampleEntry::~AP4_Tx3gSampleEntry()
AP4_Size
AP4_Tx3gSampleEntry::GetFieldsSize()
{
- return AP4_SampleEntry::GetFieldsSize() + 4 + 1 + 1 + 4 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 1 + 1 + 4;
+ return AP4_SampleEntry::GetFieldsSize()+4+1+1+4+2+2+2+2+2+2+2+1+1+4;
}
/*----------------------------------------------------------------------
@@ -1224,37 +1197,37 @@ AP4_Tx3gSampleEntry::ReadFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if(result < 0) return result;
+ if (result < 0) return result;
// data
result = stream.ReadUI32(m_Description.DisplayFlags);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI08(m_Description.HorizontalJustification);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI08(m_Description.VerticalJustification);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.Read(&m_Description.BackgroundColor, 4);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.TextBox.Top);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.TextBox.Left);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.TextBox.Bottom);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.TextBox.Right);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.Style.StartChar);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.Style.EndChar);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI16(m_Description.Style.Font.Id);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI08(m_Description.Style.Font.Face);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.ReadUI08(m_Description.Style.Font.Size);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.Read(&m_Description.Style.Font.Color, 4);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return AP4_SUCCESS;
}
@@ -1267,8 +1240,8 @@ AP4_Tx3gSampleEntry::WriteFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::WriteFields(stream);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// TODO: data
return result;
@@ -1282,9 +1255,9 @@ AP4_Tx3gSampleEntry::InspectFields(AP4_AtomInspector& inspector)
{
// sample entry
AP4_SampleEntry::InspectFields(inspector);
-
+
// TODO: fields
-
+
return AP4_SUCCESS;
}
@@ -1292,24 +1265,24 @@ AP4_Tx3gSampleEntry::InspectFields(AP4_AtomInspector& inspector)
| AP4_Tx3gSampleEntry::GetFontNameById
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_Tx3gSampleEntry::GetFontNameById(AP4_Ordinal Id, AP4_String& Name)
{
- if(AP4_FtabAtom* ftab = dynamic_cast<AP4_FtabAtom*>(GetChild(AP4_ATOM_TYPE_FTAB)))
- {
- AP4_Array<AP4_FtabAtom::AP4_Tx3gFontRecord> FontRecords = ftab->GetFontRecords();
-
- for(int i = 0, j = FontRecords.ItemCount(); i < j; i++)
- {
- if(Id == FontRecords[i].Id)
- {
- Name = FontRecords[i].Name;
- return AP4_SUCCESS;
- }
- }
- }
+ if(AP4_FtabAtom* ftab = dynamic_cast<AP4_FtabAtom*>(GetChild(AP4_ATOM_TYPE_FTAB)))
+ {
+ AP4_Array<AP4_FtabAtom::AP4_Tx3gFontRecord> FontRecords = ftab->GetFontRecords();
- return AP4_FAILURE;
+ for(int i = 0, j = FontRecords.ItemCount(); i < j; i++)
+ {
+ if(Id == FontRecords[i].Id)
+ {
+ Name = FontRecords[i].Name;
+ return AP4_SUCCESS;
+ }
+ }
+ }
+
+ return AP4_FAILURE;
}
@@ -1319,18 +1292,18 @@ AP4_Tx3gSampleEntry::GetFontNameById(AP4_Ordinal Id, AP4_String& Name)
| AP4_AC3SampleEntry::AP4_AC3SampleEntry
+---------------------------------------------------------------------*/
AP4_AC3SampleEntry::AP4_AC3SampleEntry(AP4_Atom::Type format,
- AP4_UI32 sample_rate,
- AP4_UI16 sample_size,
- AP4_UI16 channel_count) :
+ AP4_UI32 sample_rate,
+ AP4_UI16 sample_size,
+ AP4_UI16 channel_count) :
AP4_AudioSampleEntry(format, sample_rate, sample_size, channel_count)
{
}
AP4_AC3SampleEntry::AP4_AC3SampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_AudioSampleEntry(format, size, stream, atom_factory)
+ AP4_Size size,
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
+ AP4_AudioSampleEntry(format, size, stream, atom_factory)
{
}
@@ -1342,70 +1315,68 @@ AP4_Result
AP4_AC3SampleEntry::ReadFields(AP4_ByteStream& stream)
{
- AP4_AudioSampleEntry::ReadFields(stream);
-
- // SampleSize field from AudioSampleEntry shall be ignored
- m_SampleSize = 0;
-
- // AC3SpecificBox
-
- // BoxHeader.Size, BoxHeader.Type
- char junk[8];
- stream.Read(junk, 8);
-
- AP4_UI32 data;
- stream.ReadUI24(data);
-
- // fscod
- switch((data >> 22) & 0x3)
- {
- case 0:
- m_SampleRate = 48000;
- break;
- case 1:
- m_SampleRate = 44100;
- break;
- case 2:
- m_SampleRate = 32000;
- break;
- }
-
- m_SampleRate <<= 16;
-
- // acmod
- switch((data >> 11) & 0x7)
- {
- case 1:
- m_ChannelCount = 1;
- break;
- case 0:
- case 2:
- m_ChannelCount = 2;
- break;
- case 3:
- case 4:
- m_ChannelCount = 3;
- break;
- case 5:
- case 6:
- m_ChannelCount = 4;
- break;
- case 7:
- m_ChannelCount = 5;
- break;
- }
-
- // lfeon
- if(((data >> 10) & 0x1) == 1)
- m_ChannelCount++;
-
- return AP4_SUCCESS;
+ AP4_AudioSampleEntry::ReadFields(stream);
+
+ // SampleSize field from AudioSampleEntry shall be ignored
+ m_SampleSize = 0;
+
+ // AC3SpecificBox
+
+ // BoxHeader.Size, BoxHeader.Type
+ char junk[8];
+ stream.Read(junk, 8);
+
+ AP4_UI32 data;
+ stream.ReadUI24(data);
+
+ // fscod
+ switch ((data>>22) & 0x3) {
+ case 0:
+ m_SampleRate = 48000;
+ break;
+ case 1:
+ m_SampleRate = 44100;
+ break;
+ case 2:
+ m_SampleRate = 32000;
+ break;
+ }
+
+ m_SampleRate <<= 16;
+
+ // acmod
+ switch ((data>>11) & 0x7) {
+ case 1:
+ m_ChannelCount = 1;
+ break;
+ case 0:
+ case 2:
+ m_ChannelCount = 2;
+ break;
+ case 3:
+ case 4:
+ m_ChannelCount = 3;
+ break;
+ case 5:
+ case 6:
+ m_ChannelCount = 4;
+ break;
+ case 7:
+ m_ChannelCount = 5;
+ break;
+ }
+
+ // lfeon
+ if (((data>>10) & 0x1) == 1)
+ m_ChannelCount++;
+
+ return AP4_SUCCESS;
}
AP4_Size
AP4_AC3SampleEntry::GetFieldsSize()
{
- return AP4_AudioSampleEntry::GetFieldsSize() + 11;
+ return AP4_AudioSampleEntry::GetFieldsSize() + 11;
}
// <== End patch MPC \ No newline at end of file
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.h
index 90d40cb22..f11a3506c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleEntry.h
@@ -50,21 +50,18 @@ class AP4_AvccAtom;
+---------------------------------------------------------------------*/
class AP4_SampleEntry : public AP4_ContainerAtom
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_SampleEntry, AP4_ContainerAtom)
// methods
AP4_SampleEntry(AP4_Atom::Type format, AP4_UI16 data_ref_index = 1);
- AP4_SampleEntry(AP4_Atom::Type format,
+ AP4_SampleEntry(AP4_Atom::Type format,
AP4_Size size,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
virtual ~AP4_SampleEntry() {}
-
- AP4_UI16 GetDataReferenceIndex()
- {
- return m_DataReferenceIndex;
- }
+
+ AP4_UI16 GetDataReferenceIndex() { return m_DataReferenceIndex; }
virtual AP4_Result Write(AP4_ByteStream& stream);
virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
virtual AP4_SampleDescription* ToSampleDescription();
@@ -72,7 +69,7 @@ public:
// AP4_AtomParent methods
virtual void OnChildChanged(AP4_Atom* child);
-protected:
+ protected:
// constructor
AP4_SampleEntry(AP4_Atom::Type format, AP4_Size size);
@@ -93,20 +90,17 @@ protected:
+---------------------------------------------------------------------*/
class AP4_UnknownSampleEntry : public AP4_SampleEntry
{
-public:
+ public:
// this constructor takes ownership of the atom passed to it
AP4_UnknownSampleEntry(AP4_Atom::Type type, AP4_Size size, AP4_ByteStream& stream);
-
+
// AP4_SampleEntry methods
virtual AP4_SampleDescription* ToSampleDescription();
// accessors
- const AP4_DataBuffer& GetPayload()
- {
- return m_Payload;
- }
-
-protected:
+ const AP4_DataBuffer& GetPayload() { return m_Payload; }
+
+ protected:
// methods
virtual AP4_Size GetFieldsSize();
virtual AP4_Result ReadFields(AP4_ByteStream& stream);
@@ -134,21 +128,12 @@ public:
// accessors
AP4_UI32 GetSampleRate();
- AP4_UI16 GetSampleSize()
- {
- return m_SampleSize;
- }
+ AP4_UI16 GetSampleSize() { return m_SampleSize; }
AP4_UI16 GetChannelCount();
- // ==> Start patch MPC
- AP4_UI32 GetBytesPerFrame()
- {
- return m_QtV1BytesPerFrame;
- };
- AP4_UI32 GetSamplesPerPacket()
- {
- return m_QtV1SamplesPerPacket;
- }
- // <== End patch MPC
+ // ==> Start patch MPC
+ AP4_UI32 GetBytesPerFrame() { return m_QtV1BytesPerFrame; };
+ AP4_UI32 GetSamplesPerPacket(){ return m_QtV1SamplesPerPacket; }
+ // <== End patch MPC
// methods
AP4_SampleDescription* ToSampleDescription();
@@ -164,17 +149,17 @@ protected:
AP4_UI16 m_QtVersion; // 0, 1 or 2
AP4_UI16 m_QtRevision; // 0
AP4_UI32 m_QtVendor; // 0
- AP4_UI16 m_ChannelCount;
- AP4_UI16 m_SampleSize;
+ AP4_UI16 m_ChannelCount;
+ AP4_UI16 m_SampleSize;
AP4_UI16 m_QtCompressionId; // 0 or -2
AP4_UI16 m_QtPacketSize; // always 0
- AP4_UI32 m_SampleRate; // 16.16 fixed point
-
+ AP4_UI32 m_SampleRate; // 16.16 fixed point
+
AP4_UI32 m_QtV1SamplesPerPacket;
AP4_UI32 m_QtV1BytesPerPacket;
AP4_UI32 m_QtV1BytesPerFrame;
AP4_UI32 m_QtV1BytesPerSample;
-
+
AP4_UI32 m_QtV2StructSize;
double m_QtV2SampleRate64;
AP4_UI32 m_QtV2ChannelCount;
@@ -193,7 +178,7 @@ class AP4_VisualSampleEntry : public AP4_SampleEntry
{
public:
// methods
- AP4_VisualSampleEntry(AP4_Atom::Type format,
+ AP4_VisualSampleEntry(AP4_Atom::Type format,
AP4_UI16 width,
AP4_UI16 height,
AP4_UI16 depth,
@@ -204,30 +189,12 @@ public:
AP4_AtomFactory& atom_factory);
// accessors
- AP4_UI16 GetWidth()
- {
- return m_Width;
- }
- AP4_UI16 GetHeight()
- {
- return m_Height;
- }
- AP4_UI16 GetHorizResolution()
- {
- return m_HorizResolution;
- }
- AP4_UI16 GetVertResolution()
- {
- return m_VertResolution;
- }
- AP4_UI16 GetDepth()
- {
- return m_Depth;
- }
- const char* GetCompressorName()
- {
- return m_CompressorName.GetChars();
- }
+ AP4_UI16 GetWidth() { return m_Width; }
+ AP4_UI16 GetHeight() { return m_Height; }
+ AP4_UI16 GetHorizResolution(){ return m_HorizResolution; }
+ AP4_UI16 GetVertResolution() { return m_VertResolution; }
+ AP4_UI16 GetDepth() { return m_Depth; }
+ const char* GetCompressorName() { return m_CompressorName.GetChars(); }
// methods
AP4_SampleDescription* ToSampleDescription();
@@ -249,7 +216,7 @@ protected:
AP4_UI32 m_VertResolution; // = 0x00480000 (72 dpi)
AP4_UI32 m_Reserved3; // = 0
AP4_UI16 m_FrameCount; // = 1
- AP4_String m_CompressorName;
+ AP4_String m_CompressorName;
AP4_UI16 m_Depth; // = 0x0018
AP4_UI16 m_Predefined3; // = 0xFFFF
};
@@ -280,7 +247,7 @@ class AP4_MpegAudioSampleEntry : public AP4_AudioSampleEntry
public:
// constructors
AP4_MpegAudioSampleEntry(AP4_UI32 type,
- AP4_UI32 sample_rate,
+ AP4_UI32 sample_rate,
AP4_UI16 sample_size,
AP4_UI16 channel_count,
AP4_EsDescriptor* descriptor);
@@ -320,7 +287,7 @@ public:
+---------------------------------------------------------------------*/
class AP4_Mp4sSampleEntry : public AP4_MpegSystemSampleEntry
{
-public:
+ public:
// constructors
AP4_Mp4sSampleEntry(AP4_Size size,
AP4_ByteStream& stream,
@@ -336,12 +303,12 @@ public:
+---------------------------------------------------------------------*/
class AP4_Mp4aSampleEntry : public AP4_MpegAudioSampleEntry
{
-public:
+ public:
// constructors
AP4_Mp4aSampleEntry(AP4_Size size,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
- AP4_Mp4aSampleEntry(AP4_UI32 sample_rate,
+ AP4_Mp4aSampleEntry(AP4_UI32 sample_rate,
AP4_UI16 sample_size,
AP4_UI16 channel_count,
AP4_EsDescriptor* descriptor);
@@ -352,7 +319,7 @@ public:
+---------------------------------------------------------------------*/
class AP4_Mp4vSampleEntry : public AP4_MpegVideoSampleEntry
{
-public:
+ public:
// constructors
AP4_Mp4vSampleEntry(AP4_Size size,
AP4_ByteStream& stream,
@@ -361,7 +328,7 @@ public:
AP4_UI16 height,
AP4_UI16 depth,
const char* compressor_name,
- AP4_EsDescriptor* descriptor);
+ AP4_EsDescriptor* descriptor);
};
/*----------------------------------------------------------------------
@@ -379,7 +346,7 @@ public:
AP4_UI16 depth,
const char* compressor_name,
const AP4_AvccAtom& avcc);
-
+
// inherited from AP4_SampleEntry
virtual AP4_SampleDescription* ToSampleDescription();
};
@@ -398,7 +365,7 @@ public:
AP4_RtpHintSampleEntry(AP4_Size size,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
-
+
protected:
// methods
virtual AP4_Size GetFieldsSize();
@@ -421,36 +388,21 @@ class AP4_TextSampleEntry : public AP4_SampleEntry
public:
// methods
AP4_TextSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory);
virtual ~AP4_TextSampleEntry();
-
- struct AP4_TextDescription
- {
- AP4_UI32 DisplayFlags;
- AP4_UI32 TextJustification;
- AP4_UI32 BackgroundColor;
- struct
- {
- AP4_UI16 Top, Left, Bottom, Right;
- } TextBox;
- struct
- {
- AP4_UI16 StartChar, EndChar, Ascent;
- struct
- {
- AP4_UI16 Id;
- AP4_UI08 Face, Size;
- AP4_UI32 Color;
- } Font;
- } Style;
- AP4_String DefaultFontName;
- };
-
- const AP4_TextDescription& GetDescription() const
- {
- return m_Description;
- };
+
+ struct AP4_TextDescription
+ {
+ AP4_UI32 DisplayFlags;
+ AP4_UI32 TextJustification;
+ AP4_UI32 BackgroundColor;
+ struct {AP4_UI16 Top, Left, Bottom, Right;} TextBox;
+ struct {AP4_UI16 StartChar, EndChar, Ascent; struct {AP4_UI16 Id; AP4_UI08 Face, Size; AP4_UI32 Color;} Font;} Style;
+ AP4_String DefaultFontName;
+ };
+
+ const AP4_TextDescription& GetDescription() const { return m_Description; };
protected:
// methods
@@ -459,7 +411,7 @@ protected:
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
// members
- AP4_TextDescription m_Description;
+ AP4_TextDescription m_Description;
};
/*----------------------------------------------------------------------
@@ -470,38 +422,23 @@ class AP4_Tx3gSampleEntry : public AP4_SampleEntry
public:
// methods
AP4_Tx3gSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory);
virtual ~AP4_Tx3gSampleEntry();
+
+ struct AP4_Tx3gDescription
+ {
+ AP4_UI32 DisplayFlags;
+ AP4_UI08 HorizontalJustification;
+ AP4_UI08 VerticalJustification;
+ AP4_UI32 BackgroundColor;
+ struct {AP4_UI16 Top, Left, Bottom, Right;} TextBox;
+ struct {AP4_UI16 StartChar, EndChar; struct {AP4_UI16 Id; AP4_UI08 Face, Size; AP4_UI32 Color;} Font;} Style;
+ };
- struct AP4_Tx3gDescription
- {
- AP4_UI32 DisplayFlags;
- AP4_UI08 HorizontalJustification;
- AP4_UI08 VerticalJustification;
- AP4_UI32 BackgroundColor;
- struct
- {
- AP4_UI16 Top, Left, Bottom, Right;
- } TextBox;
- struct
- {
- AP4_UI16 StartChar, EndChar;
- struct
- {
- AP4_UI16 Id;
- AP4_UI08 Face, Size;
- AP4_UI32 Color;
- } Font;
- } Style;
- };
-
- const AP4_Tx3gDescription& GetDescription() const
- {
- return m_Description;
- };
-
- AP4_Result GetFontNameById(AP4_Ordinal Id, AP4_String& Name);
+ const AP4_Tx3gDescription& GetDescription() const { return m_Description; };
+
+ AP4_Result GetFontNameById(AP4_Ordinal Id, AP4_String& Name);
protected:
// methods
@@ -511,7 +448,7 @@ protected:
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
// members
- AP4_Tx3gDescription m_Description;
+ AP4_Tx3gDescription m_Description;
};
@@ -521,20 +458,20 @@ protected:
+---------------------------------------------------------------------*/
class AP4_AC3SampleEntry : public AP4_AudioSampleEntry
{
-public:
+ public:
// constructors
AP4_AC3SampleEntry(AP4_Atom::Type format,
- AP4_UI32 sample_rate,
+ AP4_UI32 sample_rate,
AP4_UI16 sample_size,
AP4_UI16 channel_count);
AP4_AC3SampleEntry(AP4_Atom::Type format,
- AP4_Size size,
+ AP4_Size size,
AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory);
protected:
- virtual AP4_Size GetFieldsSize();
+ virtual AP4_Size GetFieldsSize();
virtual AP4_Result ReadFields(AP4_ByteStream& stream);
};
// <== End patch MPC
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.cpp
index d0dfb7e29..a641c6a2d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.cpp
@@ -42,7 +42,7 @@ AP4_TrackSampleSource::AP4_TrackSampleSource(AP4_Track* track) :
m_SampleIndex(0)
{
}
-
+
/*----------------------------------------------------------------------
| AP4_TrackSampleSource
+---------------------------------------------------------------------*/
@@ -55,7 +55,7 @@ AP4_TrackSampleSource::GetTimeScale()
/*----------------------------------------------------------------------
| AP4_TrackSampleSource::GetDurationMs
+---------------------------------------------------------------------*/
-AP4_UI32
+AP4_UI32
AP4_TrackSampleSource::GetDurationMs()
{
return m_Track->GetDurationMs();
@@ -64,7 +64,7 @@ AP4_TrackSampleSource::GetDurationMs()
/*----------------------------------------------------------------------
| AP4_TrackSampleSource::GetTrackId
+---------------------------------------------------------------------*/
-AP4_UI32
+AP4_UI32
AP4_TrackSampleSource::GetTrackId()
{
return m_Track->GetId();
@@ -73,18 +73,18 @@ AP4_TrackSampleSource::GetTrackId()
/*----------------------------------------------------------------------
| AP4_TrackSampleSource::ReadNextSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_TrackSampleSource::ReadNextSample(AP4_Sample& sample, AP4_DataBuffer& buffer)
{
AP4_Result result = m_Track->ReadSample(m_SampleIndex, sample, buffer);
- if(AP4_SUCCEEDED(result)) ++m_SampleIndex;
+ if (AP4_SUCCEEDED(result)) ++m_SampleIndex;
return result;
}
/*----------------------------------------------------------------------
| AP4_TrackSampleSource::GetNearestSyncSampleIndex
+---------------------------------------------------------------------*/
-AP4_Ordinal
+AP4_Ordinal
AP4_TrackSampleSource::GetNearestSyncSampleIndex(AP4_Ordinal indx, bool before)
{
return m_Track->GetNearestSyncSampleIndex(indx, before);
@@ -93,7 +93,7 @@ AP4_TrackSampleSource::GetNearestSyncSampleIndex(AP4_Ordinal indx, bool before)
/*----------------------------------------------------------------------
| AP4_TrackSampleSource::GetSampleIndexForTimeStampMs
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_TrackSampleSource::GetSampleIndexForTimeStampMs(AP4_UI32 timestamp, AP4_Ordinal& indx)
{
return m_Track->GetSampleIndexForTimeStampMs(timestamp, indx);
@@ -102,21 +102,21 @@ AP4_TrackSampleSource::GetSampleIndexForTimeStampMs(AP4_UI32 timestamp, AP4_Ordi
/*----------------------------------------------------------------------
| AP4_TrackSampleSource::SetSampleIndex
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_TrackSampleSource::SetSampleIndex(AP4_Ordinal indx)
{
- if(indx >= m_Track->GetSampleCount()) return AP4_ERROR_OUT_OF_RANGE;
+ if (indx >= m_Track->GetSampleCount()) return AP4_ERROR_OUT_OF_RANGE;
m_SampleIndex = indx;
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_TrackSampleSource::GetSampleDescription
+---------------------------------------------------------------------*/
-AP4_SampleDescription*
+AP4_SampleDescription*
AP4_TrackSampleSource::GetSampleDescription(AP4_Ordinal indx)
{
return m_Track->GetSampleDescription(indx);
}
-
+
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.h
index 9cdc0178b..3f2cd94d2 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleSource.h
@@ -49,12 +49,12 @@ class AP4_SampleSource
{
public:
virtual ~AP4_SampleSource() {}
-
+
/**
* Return the timscale of the sample's media
*/
virtual AP4_UI32 GetTimeScale() = 0;
-
+
/**
* Return the duration in milliseconds
*/
@@ -65,27 +65,27 @@ public:
* no track ID associated with it.
*/
virtual AP4_UI32 GetTrackId() = 0;
-
+
/**
* Read the next sample from the source
*/
virtual AP4_Result ReadNextSample(AP4_Sample& sample, AP4_DataBuffer& buffer) = 0;
-
+
/**
* Return the index of the nearest sync sample from a given sample index.
*/
- virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal indx, bool before = true) = 0;
-
+ virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal indx, bool before=true) = 0;
+
/**
* Return the sample index given a timestamp in milliseconds
*/
virtual AP4_Result GetSampleIndexForTimeStampMs(AP4_UI32 timestamp, AP4_Ordinal& indx) = 0;
-
+
/**
* Seek to a specific sample index.
*/
virtual AP4_Result SetSampleIndex(AP4_Ordinal indx) = 0;
-
+
/**
* Return a sample description by index.
* Returns NULL if there is no sample description with the requested index.
@@ -99,17 +99,17 @@ public:
class AP4_TrackSampleSource : public AP4_SampleSource
{
public:
- AP4_TrackSampleSource(AP4_Track* track);
-
+ AP4_TrackSampleSource(AP4_Track* track);
+
virtual AP4_UI32 GetTimeScale();
virtual AP4_UI32 GetDurationMs();
virtual AP4_UI32 GetTrackId();
virtual AP4_Result ReadNextSample(AP4_Sample& sample, AP4_DataBuffer& buffer);
- virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal indx, bool before = true);
+ virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal indx, bool before=true);
virtual AP4_Result GetSampleIndexForTimeStampMs(AP4_UI32 timestamp, AP4_Ordinal& indx);
virtual AP4_Result SetSampleIndex(AP4_Ordinal indx);
virtual AP4_SampleDescription* GetSampleDescription(AP4_Ordinal indx);
-
+
private:
AP4_Track* m_Track;
AP4_Ordinal m_SampleIndex;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.cpp
index 743ca6f84..3f892d2a9 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.cpp
@@ -44,7 +44,7 @@
/*----------------------------------------------------------------------
| AP4_SampleTable::GenerateStblAtom
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_SampleTable::GenerateStblAtom(AP4_ContainerAtom*& stbl)
{
// create the stbl container
@@ -64,10 +64,10 @@ AP4_SampleTable::GenerateStblAtom(AP4_ContainerAtom*& stbl)
// create the stss atom
AP4_StssAtom* stss = new AP4_StssAtom();
-
+
// declare the ctts atom (may be created later)
AP4_CttsAtom* ctts = NULL;
-
+
// start chunk table
AP4_Ordinal current_chunk_index = 0;
AP4_Size current_chunk_size = 0;
@@ -83,69 +83,61 @@ AP4_SampleTable::GenerateStblAtom(AP4_ContainerAtom*& stbl)
// process all the samples
bool all_samples_are_sync = false;
AP4_Cardinal sample_count = GetSampleCount();
- for(AP4_Ordinal i = 0; i < sample_count; i++)
- {
+ for (AP4_Ordinal i=0; i<sample_count; i++) {
AP4_Sample sample;
GetSample(i, sample);
-
+
// update DTS table
AP4_UI32 new_duration = sample.GetDuration();
- if(new_duration != current_duration && current_duration_run != 0)
- {
+ if (new_duration != current_duration && current_duration_run != 0) {
// emit a new stts entry
stts->AddEntry(current_duration_run, current_duration);
-
+
// reset the run count
current_duration_run = 0;
- }
+ }
++current_duration_run;
current_duration = new_duration;
-
+
// update CTS table
AP4_UI32 new_cts_delta = sample.GetCtsDelta();
- if(new_cts_delta != current_cts_delta && current_cts_delta_run != 0)
- {
+ if (new_cts_delta != current_cts_delta && current_cts_delta_run != 0) {
// create a ctts atom if we don't have one
- if(ctts == NULL) ctts = new AP4_CttsAtom();
-
+ if (ctts == NULL) ctts = new AP4_CttsAtom();
+
//emit a new ctts entry
ctts->AddEntry(current_cts_delta_run, current_cts_delta);
-
+
// reset the run count
current_cts_delta_run = 0;
}
++current_cts_delta_run;
current_cts_delta = new_cts_delta;
-
+
// add an entry into the stsz atom
stsz->AddEntry(sample.GetSize());
-
+
// update the sync sample table
- if(sample.IsSync())
- {
- stss->AddEntry(i + 1);
- if(i == 0) all_samples_are_sync = true;
- }
- else
- {
+ if (sample.IsSync()) {
+ stss->AddEntry(i+1);
+ if (i==0) all_samples_are_sync = true;
+ } else {
all_samples_are_sync = false;
}
-
+
// see in which chunk this sample is
AP4_Ordinal chunk_index = 0;
AP4_Ordinal position_in_chunk = 0;
AP4_Result result = GetSampleChunkPosition(i, chunk_index, position_in_chunk);
- if(AP4_SUCCEEDED(result))
- {
- if(chunk_index != current_chunk_index && current_samples_in_chunk != 0)
- {
+ if (AP4_SUCCEEDED(result)) {
+ if (chunk_index != current_chunk_index && current_samples_in_chunk != 0) {
// new chunk
chunk_offsets.Append(current_chunk_offset);
current_chunk_offset += current_chunk_size;
- stsc->AddEntry(1,
+ stsc->AddEntry(1,
current_samples_in_chunk,
- current_sample_description_index + 1);
+ current_sample_description_index+1);
current_samples_in_chunk = 0;
current_chunk_size = 0;
@@ -155,32 +147,30 @@ AP4_SampleTable::GenerateStblAtom(AP4_ContainerAtom*& stbl)
// store the sample description index
current_sample_description_index = sample.GetDescriptionIndex();
-
+
// adjust the current chunk info
current_chunk_size += sample.GetSize();
- ++current_samples_in_chunk;
+ ++current_samples_in_chunk;
}
// finish the stts table
stts->AddEntry(current_duration_run, current_duration);
// finish the ctts table if we have one
- if(ctts)
- {
+ if (ctts) {
AP4_ASSERT(current_cts_delta_run != 0);
-
+
// add a ctts entry
ctts->AddEntry(current_cts_delta_run, current_cts_delta);
- }
-
+ }
+
// process any unfinished chunk
- if(current_samples_in_chunk != 0)
- {
+ if (current_samples_in_chunk != 0) {
// new chunk
chunk_offsets.Append(current_chunk_offset);
- stsc->AddEntry(1,
+ stsc->AddEntry(1,
current_samples_in_chunk,
- current_sample_description_index + 1);
+ current_sample_description_index+1);
}
// attach the children of stbl
@@ -188,24 +178,19 @@ AP4_SampleTable::GenerateStblAtom(AP4_ContainerAtom*& stbl)
stbl->AddChild(stsz);
stbl->AddChild(stsc);
stbl->AddChild(stts);
- if(ctts) stbl->AddChild(ctts);
- if(!all_samples_are_sync && stss->GetEntries().ItemCount() != 0)
- {
+ if (ctts) stbl->AddChild(ctts);
+ if (!all_samples_are_sync && stss->GetEntries().ItemCount() != 0) {
stbl->AddChild(stss);
- }
- else
- {
+ } else {
delete stss;
}
-
+
// see if we need a co64 or an stco atom
AP4_Size chunk_count = chunk_offsets.ItemCount();
- if(current_chunk_offset <= 0xFFFFFFFF)
- {
+ if (current_chunk_offset <= 0xFFFFFFFF) {
// make an array of 32-bit entries
AP4_UI32* chunk_offsets_32 = new AP4_UI32[chunk_count];
- for(unsigned int i = 0; i < chunk_count; i++)
- {
+ for (unsigned int i=0; i<chunk_count; i++) {
chunk_offsets_32[i] = (AP4_UI32)chunk_offsets[i];
}
// create the stco atom
@@ -213,9 +198,7 @@ AP4_SampleTable::GenerateStblAtom(AP4_ContainerAtom*& stbl)
stbl->AddChild(stco);
delete[] chunk_offsets_32;
- }
- else
- {
+ } else {
// create the co64 atom
AP4_Co64Atom* co64 = new AP4_Co64Atom(&chunk_offsets[0], chunk_count);
stbl->AddChild(co64);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.h
index 67c3b843a..45a6c7bb0 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SampleTable.h
@@ -44,8 +44,7 @@ class AP4_SampleDescription;
/*----------------------------------------------------------------------
| AP4_SampleTable
+---------------------------------------------------------------------*/
-class AP4_SampleTable
-{
+class AP4_SampleTable {
public:
// constructors and destructor
virtual ~AP4_SampleTable() {};
@@ -54,14 +53,14 @@ public:
virtual AP4_Result GenerateStblAtom(AP4_ContainerAtom*& stbl);
virtual AP4_Result GetSample(AP4_Ordinal sample_index, AP4_Sample& sample) = 0;
virtual AP4_Cardinal GetSampleCount() = 0;
- virtual AP4_Result GetSampleChunkPosition(AP4_Ordinal sample_index,
- AP4_Ordinal& chunk_index,
- AP4_Ordinal& position_in_chunk) = 0;
+ virtual AP4_Result GetSampleChunkPosition(AP4_Ordinal sample_index,
+ AP4_Ordinal& chunk_index,
+ AP4_Ordinal& position_in_chunk) = 0;
virtual AP4_Cardinal GetSampleDescriptionCount() = 0;
virtual AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index) = 0;
virtual AP4_Result GetSampleIndexForTimeStamp(AP4_UI64 ts,
- AP4_Ordinal& index) = 0;
- virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal index, bool before = true) = 0;
+ AP4_Ordinal& index) = 0;
+ virtual AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal index, bool before=true) = 0;
};
#endif // _AP4_SAMPLE_TABLE_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.cpp
index 5916a14a9..767e59368 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - schm Atoms
+| AP4 - schm Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -42,29 +42,27 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_SchmAtom)
| AP4_SchmAtom::Create
+---------------------------------------------------------------------*/
AP4_SchmAtom*
-AP4_SchmAtom::Create(AP4_Size size,
+AP4_SchmAtom::Create(AP4_Size size,
AP4_Array<AP4_Atom::Type>* context,
AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
- if(size < AP4_FULL_ATOM_HEADER_SIZE + 6) return NULL;
-
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
+ if (size < AP4_FULL_ATOM_HEADER_SIZE+6) return NULL;
+
// check the context to see if this is a short form atom or not
bool short_form = false;
- if(size < AP4_FULL_ATOM_HEADER_SIZE + 8) short_form = true;
- if(context)
- {
+ if (size < AP4_FULL_ATOM_HEADER_SIZE+8) short_form = true;
+ if (context) {
AP4_Size context_depth = context->ItemCount();
- if(context_depth >= 2 &&
- (*context)[context_depth-2] == AP4_ATOM_TYPE('m', 'r', 'l', 'n'))
- {
+ if (context_depth >= 2 &&
+ (*context)[context_depth-2] == AP4_ATOM_TYPE('m','r','l','n')) {
short_form = true;
}
}
-
+
return new AP4_SchmAtom(size, version, flags, short_form, stream);
}
@@ -75,23 +73,22 @@ AP4_SchmAtom::AP4_SchmAtom(AP4_UI32 scheme_type,
AP4_UI32 scheme_version,
const char* scheme_uri,
bool short_form) :
- AP4_Atom(AP4_ATOM_TYPE_SCHM, AP4_FULL_ATOM_HEADER_SIZE + 4 + (short_form ? 2 : 4), 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_SCHM, AP4_FULL_ATOM_HEADER_SIZE+4+(short_form?2:4), 0, 0),
m_AtomHasShortForm(short_form),
m_SchemeType(scheme_type),
m_SchemeVersion(scheme_version)
{
- if(scheme_uri)
- {
+ if (scheme_uri) {
m_SchemeUri = scheme_uri;
m_Flags = 1;
- m_Size32 += m_SchemeUri.GetLength() + 1;
+ m_Size32 += m_SchemeUri.GetLength()+1;
}
}
/*----------------------------------------------------------------------
| AP4_SchmAtom::AP4_SchmAtom
+---------------------------------------------------------------------*/
-AP4_SchmAtom::AP4_SchmAtom(AP4_UI32 size,
+AP4_SchmAtom::AP4_SchmAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
bool short_form,
@@ -100,21 +97,16 @@ AP4_SchmAtom::AP4_SchmAtom(AP4_UI32 size,
m_AtomHasShortForm(short_form)
{
stream.ReadUI32(m_SchemeType);
- if(short_form)
- {
+ if (short_form) {
AP4_UI16 short_version;
stream.ReadUI16(short_version);
m_SchemeVersion = short_version;
- }
- else
- {
+ } else {
stream.ReadUI32(m_SchemeVersion);
}
- if(m_Flags & 1)
- {
- int str_size = size - (AP4_FULL_ATOM_HEADER_SIZE + 8);
- if(str_size > 0)
- {
+ if (m_Flags & 1) {
+ int str_size = size-(AP4_FULL_ATOM_HEADER_SIZE+8);
+ if (str_size > 0) {
char* str = new char[str_size];
stream.Read(str, str_size);
str[str_size-1] = '\0'; // force null-termination
@@ -134,30 +126,26 @@ AP4_SchmAtom::WriteFields(AP4_ByteStream& stream)
// scheme type
result = stream.WriteUI32(m_SchemeType);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// scheme version
- if(m_AtomHasShortForm)
- {
+ if (m_AtomHasShortForm) {
result = stream.WriteUI16((AP4_UI16)m_SchemeVersion);
- if(AP4_FAILED(result)) return result;
- }
- else
- {
+ if (AP4_FAILED(result)) return result;
+ } else {
result = stream.WriteUI32(m_SchemeVersion);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
-
+
// uri if needed
- if(m_Flags & 1)
- {
- result = stream.Write(m_SchemeUri.GetChars(), m_SchemeUri.GetLength() + 1);
- if(AP4_FAILED(result)) return result;
+ if (m_Flags & 1) {
+ result = stream.Write(m_SchemeUri.GetChars(), m_SchemeUri.GetLength()+1);
+ if (AP4_FAILED(result)) return result;
// pad with zeros if necessary
- AP4_Size fields_size = 4 + (m_AtomHasShortForm ? 2 : 4);
- AP4_Size padding = m_Size32 - (AP4_FULL_ATOM_HEADER_SIZE + fields_size + m_SchemeUri.GetLength() + 1);
- while(padding--) stream.WriteUI08(0);
+ AP4_Size fields_size = 4+(m_AtomHasShortForm?2:4);
+ AP4_Size padding = m_Size32-(AP4_FULL_ATOM_HEADER_SIZE+fields_size+m_SchemeUri.GetLength()+1);
+ while (padding--) stream.WriteUI08(0);
}
return result;
@@ -172,17 +160,13 @@ AP4_SchmAtom::InspectFields(AP4_AtomInspector& inspector)
char st[5];
AP4_FormatFourChars(st, m_SchemeType);
inspector.AddField("scheme_type", st);
- if(m_AtomHasShortForm)
- {
+ if (m_AtomHasShortForm) {
inspector.AddField("scheme_version (short)", m_SchemeVersion);
- }
- else
- {
+ } else {
inspector.AddField("scheme_version", m_SchemeVersion);
}
- if(m_Flags & 1)
- {
- inspector.AddField("scheme_uri", m_SchemeUri.GetChars());
+ if (m_Flags & 1) {
+ inspector.AddField("scheme_uri", m_SchemeUri.GetChars());
}
return AP4_SUCCESS;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.h
index fa60f9d62..3b2a065db 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SchmAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - schm Atoms
+| AP4 - schm Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -51,7 +51,7 @@ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_SchmAtom, AP4_Atom)
// class methods
- static AP4_SchmAtom* Create(AP4_Size size,
+ static AP4_SchmAtom* Create(AP4_Size size,
AP4_Array<AP4_Atom::Type>* context,
AP4_ByteStream& stream);
@@ -66,22 +66,13 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- AP4_UI32 GetSchemeType()
- {
- return m_SchemeType;
- }
- AP4_UI32 GetSchemeVersion()
- {
- return m_SchemeVersion;
- }
- AP4_String& GetSchemeUri()
- {
- return m_SchemeUri;
- }
+ AP4_UI32 GetSchemeType() { return m_SchemeType; }
+ AP4_UI32 GetSchemeVersion() { return m_SchemeVersion; }
+ AP4_String& GetSchemeUri() { return m_SchemeUri; }
private:
// methods
- AP4_SchmAtom(AP4_UI32 size,
+ AP4_SchmAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
bool short_form,
@@ -89,7 +80,7 @@ private:
// members
bool m_AtomHasShortForm; // for versions of this where the version
- // field is only 16 bits
+ // field is only 16 bits
AP4_UI32 m_SchemeType;
AP4_UI32 m_SchemeVersion;
AP4_String m_SchemeUri;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.cpp
index 88abc8f93..56237781e 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - sdp Atoms
+| AP4 - sdp Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -41,7 +41,7 @@ AP4_SdpAtom::AP4_SdpAtom(const char* sdp_text) :
AP4_Atom(AP4_ATOM_TYPE_SDP_, AP4_ATOM_HEADER_SIZE),
m_SdpText(sdp_text)
{
- m_Size32 += m_SdpText.GetLength() + 1;
+ m_Size32 += m_SdpText.GetLength()+1;
}
/*----------------------------------------------------------------------
@@ -51,9 +51,8 @@ AP4_SdpAtom::AP4_SdpAtom(AP4_UI32 size, AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_SDP_, size)
{
// sdptext
- AP4_Size str_size = size - AP4_ATOM_HEADER_SIZE;
- if(str_size > 0)
- {
+ AP4_Size str_size = size-AP4_ATOM_HEADER_SIZE;
+ if (str_size > 0) {
char* str = new char[str_size+1];
stream.Read(str, str_size);
str[str_size] = '\0'; // force null-termination
@@ -70,12 +69,12 @@ AP4_SdpAtom::WriteFields(AP4_ByteStream& stream)
{
// sdptext
AP4_Result result = stream.Write(m_SdpText.GetChars(), m_SdpText.GetLength());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// pad with zeros if necessary
- AP4_Size padding = m_Size32 - (AP4_ATOM_HEADER_SIZE + m_SdpText.GetLength());
- while(padding--) stream.WriteUI08(0);
-
+ AP4_Size padding = m_Size32-(AP4_ATOM_HEADER_SIZE+m_SdpText.GetLength());
+ while (padding--) stream.WriteUI08(0);
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.h
index 0c8ea9a1f..421a73b12 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SdpAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - sdp Atoms
+| AP4 - sdp Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -48,8 +48,7 @@ class AP4_SdpAtom : public AP4_Atom
{
public:
// class methods
- static AP4_SdpAtom* Create(AP4_Size size, AP4_ByteStream& stream)
- {
+ static AP4_SdpAtom* Create(AP4_Size size, AP4_ByteStream& stream) {
return new AP4_SdpAtom(size, stream);
}
@@ -57,7 +56,7 @@ public:
AP4_SdpAtom(const char* sdp_text);
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
// accessors
const AP4_String& GetSdpText() const;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.cpp
index ee7adb9d1..88052ced1 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - smhd Atoms
+| AP4 - smhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -41,8 +41,8 @@ AP4_SmhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_SmhdAtom(size, version, flags, stream);
}
@@ -50,7 +50,7 @@ AP4_SmhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_SmhdAtom::AP4_SmhdAtom
+---------------------------------------------------------------------*/
AP4_SmhdAtom::AP4_SmhdAtom(AP4_UI16 balance) :
- AP4_Atom(AP4_ATOM_TYPE_SMHD, AP4_FULL_ATOM_HEADER_SIZE + 4, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_SMHD, AP4_FULL_ATOM_HEADER_SIZE+4, 0, 0),
m_Balance(balance)
{
m_Reserved = 0;
@@ -59,7 +59,7 @@ AP4_SmhdAtom::AP4_SmhdAtom(AP4_UI16 balance) :
/*----------------------------------------------------------------------
| AP4_SmhdAtom::AP4_SmhdAtom
+---------------------------------------------------------------------*/
-AP4_SmhdAtom::AP4_SmhdAtom(AP4_UI32 size,
+AP4_SmhdAtom::AP4_SmhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -79,11 +79,11 @@ AP4_SmhdAtom::WriteFields(AP4_ByteStream& stream)
// balance
result = stream.WriteUI16(m_Balance);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// reserved
result = stream.WriteUI16(m_Reserved);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.h
index 1cf71d987..8d6269b5b 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SmhdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - smhd Atoms
+| AP4 - smhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -51,7 +51,7 @@ public:
private:
// methods
- AP4_SmhdAtom(AP4_UI32 size,
+ AP4_SmhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.cpp
index 397da3850..4ed8fe1f3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stco Atoms
+| AP4 - stco Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_StcoAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_StcoAtom(size, version, flags, stream);
}
@@ -55,39 +55,36 @@ AP4_StcoAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_StcoAtom::AP4_StcoAtom
+---------------------------------------------------------------------*/
AP4_StcoAtom::AP4_StcoAtom(AP4_UI32* entries, AP4_UI32 entry_count) :
- AP4_Atom(AP4_ATOM_TYPE_STCO,
- AP4_FULL_ATOM_HEADER_SIZE + 4 + entry_count * 4,
- 0, 0),
- m_Entries(new AP4_UI32[entry_count]),
- m_EntryCount(entry_count)
+AP4_Atom(AP4_ATOM_TYPE_STCO,
+ AP4_FULL_ATOM_HEADER_SIZE+4+entry_count*4,
+ 0, 0),
+ m_Entries(new AP4_UI32[entry_count]),
+ m_EntryCount(entry_count)
{
- AP4_CopyMemory(m_Entries, entries, m_EntryCount * 4);
+ AP4_CopyMemory(m_Entries, entries, m_EntryCount*4);
}
/*----------------------------------------------------------------------
| AP4_StcoAtom::AP4_StcoAtom
+---------------------------------------------------------------------*/
-AP4_StcoAtom::AP4_StcoAtom(AP4_UI32 size,
+AP4_StcoAtom::AP4_StcoAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_STCO, size, version, flags)
{
stream.ReadUI32(m_EntryCount);
- if(m_EntryCount > (size - AP4_FULL_ATOM_HEADER_SIZE - 4) / 4)
- {
- m_EntryCount = (size - AP4_FULL_ATOM_HEADER_SIZE - 4) / 4;
+ if (m_EntryCount > (size-AP4_FULL_ATOM_HEADER_SIZE-4)/4) {
+ m_EntryCount = (size-AP4_FULL_ATOM_HEADER_SIZE-4)/4;
}
m_Entries = new AP4_UI32[m_EntryCount];
unsigned char* buffer = new unsigned char[m_EntryCount*4];
- AP4_Result result = stream.Read(buffer, m_EntryCount * 4);
- if(AP4_FAILED(result))
- {
+ AP4_Result result = stream.Read(buffer, m_EntryCount*4);
+ if (AP4_FAILED(result)) {
delete[] buffer;
return;
}
- for(AP4_Ordinal i = 0; i < m_EntryCount; i++)
- {
+ for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
m_Entries[i] = AP4_BytesToUInt32BE(&buffer[i*4]);
}
delete[] buffer;
@@ -108,8 +105,7 @@ AP4_Result
AP4_StcoAtom::GetChunkOffset(AP4_Ordinal chunk, AP4_UI32& chunk_offset)
{
// check the bounds
- if(chunk > m_EntryCount || chunk == 0)
- {
+ if (chunk > m_EntryCount || chunk == 0) {
return AP4_ERROR_OUT_OF_RANGE;
}
@@ -126,8 +122,7 @@ AP4_Result
AP4_StcoAtom::SetChunkOffset(AP4_Ordinal chunk, AP4_UI32 chunk_offset)
{
// check the bounds
- if(chunk > m_EntryCount || chunk == 0)
- {
+ if (chunk > m_EntryCount || chunk == 0) {
return AP4_ERROR_OUT_OF_RANGE;
}
@@ -143,8 +138,7 @@ AP4_StcoAtom::SetChunkOffset(AP4_Ordinal chunk, AP4_UI32 chunk_offset)
AP4_Result
AP4_StcoAtom::AdjustChunkOffsets(int delta)
{
- for(AP4_Ordinal i = 0; i < m_EntryCount; i++)
- {
+ for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
m_Entries[i] += delta;
}
@@ -161,13 +155,12 @@ AP4_StcoAtom::WriteFields(AP4_ByteStream& stream)
// entry count
result = stream.WriteUI32(m_EntryCount);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// entries
- for(AP4_Ordinal i = 0; i < m_EntryCount; i++)
- {
+ for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
result = stream.WriteUI32(m_Entries[i]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return result;
@@ -180,15 +173,13 @@ AP4_Result
AP4_StcoAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("entry_count", m_EntryCount);
- if(inspector.GetVerbosity() >= 1)
- {
+ if (inspector.GetVerbosity() >= 1) {
char header[32];
- for(AP4_Ordinal i = 0; i < m_EntryCount; i++)
- {
+ for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
AP4_FormatString(header, sizeof(header), "entry %8d", i);
inspector.AddField(header, m_Entries[i]);
}
}
-
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.h
index 2a4777250..7fdaea4cc 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StcoAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stco Atoms
+| AP4 - stco Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -51,21 +51,15 @@ public:
~AP4_StcoAtom();
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_Cardinal GetChunkCount()
- {
- return m_EntryCount;
- }
- AP4_UI32* GetChunkOffsets()
- {
- return m_Entries;
- }
+ AP4_Cardinal GetChunkCount() { return m_EntryCount; }
+ AP4_UI32* GetChunkOffsets() { return m_Entries; }
AP4_Result GetChunkOffset(AP4_Ordinal chunk, AP4_UI32& chunk_offset);
AP4_Result SetChunkOffset(AP4_Ordinal chunk, AP4_UI32 chunk_offset);
AP4_Result AdjustChunkOffsets(int delta);
-
+
private:
// methods
- AP4_StcoAtom(AP4_UI32 size,
+ AP4_StcoAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.cpp
index f3a3f77d2..f93422416 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.cpp
@@ -46,24 +46,22 @@ AP4_String::AP4_String() : m_Chars(&EmptyString), m_Length(0) {}
/*----------------------------------------------------------------------
| AP4_String::AP4_String
+---------------------------------------------------------------------*/
-AP4_String::AP4_String(const char* s)
-{
- if(s == NULL)
- {
+AP4_String::AP4_String(const char* s) {
+ if (s == NULL) {
m_Chars = &EmptyString;
m_Length = 0;
return;
}
m_Length = (AP4_Size)AP4_StringLength(s);
m_Chars = new char[m_Length+1];
- AP4_CopyMemory(m_Chars, s, m_Length + 1);
+ AP4_CopyMemory(m_Chars, s, m_Length+1);
}
/*----------------------------------------------------------------------
| AP4_String::AP4_String
+---------------------------------------------------------------------*/
AP4_String::AP4_String(const char* s, AP4_Size size) :
- m_Chars(new char[size+1]),
+ m_Chars(new char[size+1]),
m_Length(size)
{
m_Chars[size] = 0;
@@ -73,29 +71,27 @@ AP4_String::AP4_String(const char* s, AP4_Size size) :
/*----------------------------------------------------------------------
| AP4_String::AP4_String
+---------------------------------------------------------------------*/
-AP4_String::AP4_String(const AP4_String& s)
-{
+AP4_String::AP4_String(const AP4_String& s) {
m_Length = s.m_Length;
m_Chars = new char[m_Length+1];
- AP4_CopyMemory(m_Chars, s.m_Chars, m_Length + 1);
+ AP4_CopyMemory(m_Chars, s.m_Chars, m_Length+1);
}
/*----------------------------------------------------------------------
| AP4_String::AP4_String
+---------------------------------------------------------------------*/
-AP4_String::AP4_String(AP4_Size size)
-{
+AP4_String::AP4_String(AP4_Size size) {
m_Length = size;
m_Chars = new char[m_Length+1];
- for(unsigned int i = 0; i < size + 1; i++) m_Chars[i] = 0;
+ for (unsigned int i=0; i<size+1; i++) m_Chars[i] = 0;
}
/*----------------------------------------------------------------------
| AP4_String::~AP4_String
+---------------------------------------------------------------------*/
-AP4_String::~AP4_String()
+AP4_String::~AP4_String()
{
- if(m_Chars != &EmptyString) delete[] m_Chars;
+ if (m_Chars != &EmptyString) delete[] m_Chars;
}
/*----------------------------------------------------------------------
@@ -104,11 +100,11 @@ AP4_String::~AP4_String()
const AP4_String&
AP4_String::operator=(const AP4_String& s)
{
- if(&s == this) return s;
- if(m_Chars != &EmptyString) delete[] m_Chars;
+ if (&s == this) return s;
+ if (m_Chars != &EmptyString) delete[] m_Chars;
m_Length = s.m_Length;
m_Chars = new char[m_Length+1];
- AP4_CopyMemory(m_Chars, s.m_Chars, m_Length + 1);
+ AP4_CopyMemory(m_Chars, s.m_Chars, m_Length+1);
return *this;
}
@@ -119,14 +115,11 @@ AP4_String::operator=(const AP4_String& s)
const AP4_String&
AP4_String::operator=(const char* s)
{
- if(s == NULL)
- {
- if(m_Chars != &EmptyString) delete[] m_Chars;
+ if (s == NULL) {
+ if (m_Chars != &EmptyString) delete[] m_Chars;
m_Chars = &EmptyString;
m_Length = 0;
- }
- else
- {
+ } else {
Assign(s, (AP4_Size)AP4_StringLength(s));
}
@@ -139,10 +132,9 @@ AP4_String::operator=(const char* s)
bool
AP4_String::operator==(const AP4_String& s) const
{
- if(m_Length != s.m_Length) return false;
- for(unsigned int i = 0; i < m_Length; i++)
- {
- if(m_Chars[i] != s.m_Chars[i]) return false;
+ if (m_Length != s.m_Length) return false;
+ for (unsigned int i=0; i<m_Length; i++) {
+ if (m_Chars[i] != s.m_Chars[i]) return false;
}
return true;
}
@@ -155,10 +147,9 @@ bool
AP4_String::operator==(const char* s) const
{
AP4_Size s_length = (AP4_Size)AP4_StringLength(s);
- if(m_Length != s_length) return false;
- for(unsigned int i = 0; i < s_length; i++)
- {
- if(m_Chars[i] != s[i]) return false;
+ if (m_Length != s_length) return false;
+ for (unsigned int i=0; i<s_length; i++) {
+ if (m_Chars[i] != s[i]) return false;
}
return true;
}
@@ -169,7 +160,7 @@ AP4_String::operator==(const char* s) const
void
AP4_String::Assign(const char* s, AP4_Size size)
{
- if(m_Chars != &EmptyString) delete[] m_Chars;
+ if (m_Chars != &EmptyString) delete[] m_Chars;
m_Length = size;
m_Chars = new char[m_Length+1];
AP4_CopyMemory(m_Chars, s, m_Length);
@@ -183,9 +174,8 @@ int
AP4_String::Find(char c, unsigned int start) const
{
const char* chars = GetChars();
- for(unsigned int i = start; i < m_Length; i++)
- {
- if(chars[i] == c) return i;
+ for (unsigned int i=start; i<m_Length; i++) {
+ if (chars[i] == c) return i;
}
return -1;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.h
index 0461075bd..f1d81ef06 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4String.h
@@ -54,37 +54,21 @@ public:
// operators
const AP4_String& operator=(const AP4_String& s);
const AP4_String& operator=(const char* s);
- char operator[](unsigned int index) const
- {
+ char operator[](unsigned int index) const {
return m_Chars[index];
}
bool operator==(const AP4_String& s) const;
- bool operator!=(const AP4_String& s) const
- {
- return !(*this == s);
- }
+ bool operator!=(const AP4_String& s) const { return !(*this == s); }
bool operator==(const char* s) const;
- bool operator!=(const char* s) const
- {
- return !(*this == s);
- }
+ bool operator!=(const char* s) const { return !(*this == s); }
// methods
- AP4_Size GetLength() const
- {
- return m_Length;
- }
- const char* GetChars() const
- {
- return m_Chars;
- }
- char* UseChars()
- {
- return m_Chars;
- }
+ AP4_Size GetLength() const { return m_Length; }
+ const char* GetChars() const { return m_Chars; }
+ char* UseChars() { return m_Chars; }
void Assign(const char* chars, AP4_Size size);
int Find(char c, unsigned int start = 0) const;
-
+
private:
// class members
static char EmptyString;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.cpp
index ad4e10c52..7e108f285 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.cpp
@@ -1,6 +1,6 @@
-/*****************************************************************
+ /*****************************************************************
|
-| AP4 - stsc Atoms
+| AP4 - stsc Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -24,7 +24,7 @@
| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
| 02111-1307, USA.
|
-****************************************************************/
+ ****************************************************************/
/*----------------------------------------------------------------------
| includes
@@ -46,8 +46,8 @@ AP4_StscAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_StscAtom(size, version, flags, stream);
}
@@ -55,7 +55,7 @@ AP4_StscAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_StscAtom::AP4_StscAtom
+---------------------------------------------------------------------*/
AP4_StscAtom::AP4_StscAtom() :
- AP4_Atom(AP4_ATOM_TYPE_STSC, AP4_FULL_ATOM_HEADER_SIZE + 4, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_STSC, AP4_FULL_ATOM_HEADER_SIZE+4, 0, 0),
m_CachedChunkGroup(0)
{
}
@@ -63,7 +63,7 @@ AP4_StscAtom::AP4_StscAtom() :
/*----------------------------------------------------------------------
| AP4_StscAtom::AP4_StscAtom
+---------------------------------------------------------------------*/
-AP4_StscAtom::AP4_StscAtom(AP4_UI32 size,
+AP4_StscAtom::AP4_StscAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -75,21 +75,18 @@ AP4_StscAtom::AP4_StscAtom(AP4_UI32 size,
stream.ReadUI32(entry_count);
m_Entries.SetItemCount(entry_count);
unsigned char* buffer = new unsigned char[entry_count*12];
- AP4_Result result = stream.Read(buffer, entry_count * 12);
- if(AP4_FAILED(result))
- {
+ AP4_Result result = stream.Read(buffer, entry_count*12);
+ if (AP4_FAILED(result)) {
delete[] buffer;
return;
}
- for(unsigned int i = 0; i < entry_count; i++)
- {
+ for (unsigned int i=0; i<entry_count; i++) {
AP4_UI32 first_chunk = AP4_BytesToUInt32BE(&buffer[i*12 ]);
AP4_UI32 samples_per_chunk = AP4_BytesToUInt32BE(&buffer[i*12+4]);
AP4_UI32 sample_description_index = AP4_BytesToUInt32BE(&buffer[i*12+8]);
- if(i)
- {
- AP4_Ordinal prev = i - 1;
- m_Entries[prev].m_ChunkCount = first_chunk - m_Entries[prev].m_FirstChunk;
+ if (i) {
+ AP4_Ordinal prev = i-1;
+ m_Entries[prev].m_ChunkCount = first_chunk-m_Entries[prev].m_FirstChunk;
first_sample += m_Entries[prev].m_ChunkCount * m_Entries[prev].m_SamplesPerChunk;
}
m_Entries[i].m_ChunkCount = 0; // not known yet
@@ -114,14 +111,13 @@ AP4_StscAtom::WriteFields(AP4_ByteStream& stream)
result = stream.WriteUI32(entry_count);
// entries
- for(AP4_Ordinal i = 0; i < entry_count; i++)
- {
+ for (AP4_Ordinal i=0; i<entry_count; i++) {
stream.WriteUI32(m_Entries[i].m_FirstChunk);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
stream.WriteUI32(m_Entries[i].m_SamplesPerChunk);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
stream.WriteUI32(m_Entries[i].m_SampleDescriptionIndex);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return result;
@@ -130,7 +126,7 @@ AP4_StscAtom::WriteFields(AP4_ByteStream& stream)
/*----------------------------------------------------------------------
| AP4_StscAtom::AddEntry
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_StscAtom::AddEntry(AP4_Cardinal chunk_count,
AP4_Cardinal samples_per_chunk,
AP4_Ordinal sample_description_index)
@@ -138,18 +134,15 @@ AP4_StscAtom::AddEntry(AP4_Cardinal chunk_count,
AP4_Ordinal first_chunk;
AP4_Ordinal first_sample;
AP4_Cardinal entry_count = m_Entries.ItemCount();
- if(entry_count == 0)
- {
+ if (entry_count == 0) {
// first entry
first_chunk = 1;
first_sample = 1;
- }
- else
- {
- first_chunk = m_Entries[entry_count-1].m_FirstChunk +
+ } else {
+ first_chunk = m_Entries[entry_count-1].m_FirstChunk+
m_Entries[entry_count-1].m_ChunkCount;
- first_sample = m_Entries[entry_count-1].m_FirstSample +
- m_Entries[entry_count-1].m_ChunkCount *
+ first_sample = m_Entries[entry_count-1].m_FirstSample+
+ m_Entries[entry_count-1].m_ChunkCount*
m_Entries[entry_count-1].m_SamplesPerChunk;
}
m_Entries.Append(AP4_StscTableEntry(first_chunk, first_sample, chunk_count, samples_per_chunk, sample_description_index));
@@ -175,35 +168,26 @@ AP4_StscAtom::GetChunkForSample(AP4_Ordinal sample,
// decide whether to start the search from the cached index
// or from the start
AP4_Ordinal group;
- if(m_CachedChunkGroup < m_Entries.ItemCount() &&
- m_Entries[m_CachedChunkGroup].m_FirstSample <= sample)
- {
+ if (m_CachedChunkGroup < m_Entries.ItemCount() &&
+ m_Entries[m_CachedChunkGroup].m_FirstSample <= sample) {
group = m_CachedChunkGroup;
- }
- else
- {
+ } else {
group = 0;
}
// find which group of chunk contains this one
- while(group < m_Entries.ItemCount())
- {
- AP4_Cardinal sample_count =
- m_Entries[group].m_ChunkCount * m_Entries[group].m_SamplesPerChunk;
- if(sample_count == 0)
- {
+ while (group < m_Entries.ItemCount()) {
+ AP4_Cardinal sample_count =
+ m_Entries[group].m_ChunkCount*m_Entries[group].m_SamplesPerChunk;
+ if (sample_count == 0) {
// unlimited samples in this group (last group)
- if(m_Entries[group].m_FirstSample > sample)
- {
+ if (m_Entries[group].m_FirstSample > sample) {
// something is wrong
return AP4_ERROR_INVALID_FORMAT;
}
- }
- else
- {
+ } else {
// normal group
- if(m_Entries[group].m_FirstSample + sample_count <= sample)
- {
+ if (m_Entries[group].m_FirstSample + sample_count <= sample) {
// the sample is not in this group
group++;
continue;
@@ -211,18 +195,17 @@ AP4_StscAtom::GetChunkForSample(AP4_Ordinal sample,
}
// the sample is in this group
- if(m_Entries[group].m_SamplesPerChunk == 0)
- {
+ if (m_Entries[group].m_SamplesPerChunk == 0) {
// something is wrong
return AP4_ERROR_INVALID_FORMAT;
}
- unsigned int chunk_offset =
- ((sample - m_Entries[group].m_FirstSample) /
- m_Entries[group].m_SamplesPerChunk);
+ unsigned int chunk_offset =
+ ((sample-m_Entries[group].m_FirstSample) /
+ m_Entries[group].m_SamplesPerChunk);
chunk = m_Entries[group].m_FirstChunk + chunk_offset;
skip = sample -
- (m_Entries[group].m_FirstSample +
- m_Entries[group].m_SamplesPerChunk * chunk_offset);
+ (m_Entries[group].m_FirstSample +
+ m_Entries[group].m_SamplesPerChunk*chunk_offset);
sample_description_index = m_Entries[group].m_SampleDescriptionIndex;
// cache the result (to accelerate finding the right group
@@ -248,24 +231,22 @@ AP4_StscAtom::InspectFields(AP4_AtomInspector& inspector)
inspector.AddField("entry_count", m_Entries.ItemCount());
// dump table entries
- if(inspector.GetVerbosity() >= 1)
- {
+ if (inspector.GetVerbosity() >= 1) {
char header[32];
char value[256];
- for(unsigned int i = 0; i < m_Entries.ItemCount(); i++)
- {
- AP4_FormatString(header, sizeof(header), "entry %8d", i);
- AP4_FormatString(value, sizeof(value),
- "first_chunk=%d, first_sample*=%d, chunk_count*=%d, samples_per_chunk=%d, sample_desc_index=%d",
- m_Entries[i].m_FirstChunk,
- m_Entries[i].m_FirstSample,
- m_Entries[i].m_ChunkCount,
- m_Entries[i].m_SamplesPerChunk,
- m_Entries[i].m_SampleDescriptionIndex);
+ for (unsigned int i=0; i<m_Entries.ItemCount(); i++) {
+ AP4_FormatString(header, sizeof(header), "entry %8d", i);
+ AP4_FormatString(value, sizeof(value),
+ "first_chunk=%d, first_sample*=%d, chunk_count*=%d, samples_per_chunk=%d, sample_desc_index=%d",
+ m_Entries[i].m_FirstChunk,
+ m_Entries[i].m_FirstSample,
+ m_Entries[i].m_ChunkCount,
+ m_Entries[i].m_SamplesPerChunk,
+ m_Entries[i].m_SampleDescriptionIndex);
inspector.AddField(header, value);
}
}
-
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.h
index c0acf224a..23def43b7 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StscAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stsc Atoms
+| AP4 - stsc Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -39,14 +39,13 @@
/*----------------------------------------------------------------------
| AP4_StscTableEntry
+---------------------------------------------------------------------*/
-class AP4_StscTableEntry
-{
-public:
- AP4_StscTableEntry() :
- m_FirstChunk(0),
+class AP4_StscTableEntry {
+ public:
+ AP4_StscTableEntry() :
+ m_FirstChunk(0),
m_FirstSample(0),
m_ChunkCount(0),
- m_SamplesPerChunk(0),
+ m_SamplesPerChunk(0),
m_SampleDescriptionIndex(0) {}
AP4_StscTableEntry(AP4_Ordinal first_chunk,
AP4_Ordinal first_sample,
@@ -81,7 +80,7 @@ class AP4_StscAtom : public AP4_Atom
{
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_StscAtom, AP4_Atom)
-
+
// class methods
static AP4_StscAtom* Create(AP4_Size size, AP4_ByteStream& stream);
@@ -97,14 +96,14 @@ public:
AP4_Ordinal sample_description_index);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- // ==> Start patch MPC
- // FIXME
- friend class AP4_AtomSampleTable;
- // <== End patch MPC
+ // ==> Start patch MPC
+ // FIXME
+ friend class AP4_AtomSampleTable;
+ // <== End patch MPC
private:
// methods
- AP4_StscAtom(AP4_UI32 size,
+ AP4_StscAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.cpp
index 766b1ca7a..3ce86da1b 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stsd Atoms
+| AP4 - stsd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -45,14 +45,14 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_StsdAtom)
| AP4_StsdAtom::Create
+---------------------------------------------------------------------*/
AP4_StsdAtom*
-AP4_StsdAtom::Create(AP4_Size size,
- AP4_ByteStream& stream,
+AP4_StsdAtom::Create(AP4_Size size,
+ AP4_ByteStream& stream,
AP4_AtomFactory& atom_factory)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_StsdAtom(size, version, flags, stream, atom_factory);
}
@@ -65,8 +65,7 @@ AP4_StsdAtom::AP4_StsdAtom(AP4_SampleTable* sample_table) :
m_Size32 += 4;
AP4_Cardinal sample_description_count = sample_table->GetSampleDescriptionCount();
m_SampleDescriptions.EnsureCapacity(sample_description_count);
- for(AP4_Ordinal i = 0; i < sample_description_count; i++)
- {
+ for (AP4_Ordinal i=0; i<sample_description_count; i++) {
// clear the cache entry
m_SampleDescriptions.Append(NULL);
@@ -98,14 +97,12 @@ AP4_StsdAtom::AP4_StsdAtom(AP4_UI32 size,
atom_factory.PushContext(m_Type);
// read all entries
- AP4_LargeSize bytes_available = size - AP4_FULL_ATOM_HEADER_SIZE - 4;
- for(unsigned int i = 0; i < entry_count; i++)
- {
+ AP4_LargeSize bytes_available = size-AP4_FULL_ATOM_HEADER_SIZE-4;
+ for (unsigned int i=0; i<entry_count; i++) {
AP4_Atom* atom;
- if(AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
- bytes_available,
- atom)))
- {
+ if (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
+ bytes_available,
+ atom))) {
atom->SetParent(this);
m_Children.Add(atom);
}
@@ -116,8 +113,7 @@ AP4_StsdAtom::AP4_StsdAtom(AP4_UI32 size,
// initialize the sample description cache
m_SampleDescriptions.EnsureCapacity(m_Children.ItemCount());
- for(AP4_Ordinal i = 0; i < m_Children.ItemCount(); i++)
- {
+ for (AP4_Ordinal i=0; i<m_Children.ItemCount(); i++) {
m_SampleDescriptions.Append(NULL);
}
}
@@ -127,8 +123,7 @@ AP4_StsdAtom::AP4_StsdAtom(AP4_UI32 size,
+---------------------------------------------------------------------*/
AP4_StsdAtom::~AP4_StsdAtom()
{
- for(AP4_Ordinal i = 0; i < m_SampleDescriptions.ItemCount(); i++)
- {
+ for (AP4_Ordinal i=0; i<m_SampleDescriptions.ItemCount(); i++) {
delete m_SampleDescriptions[i];
}
}
@@ -143,7 +138,7 @@ AP4_StsdAtom::WriteFields(AP4_ByteStream& stream)
// entry count
result = stream.WriteUI32(m_Children.ItemCount());
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// entries
return m_Children.Apply(AP4_AtomListWriter(stream));
@@ -156,12 +151,12 @@ void
AP4_StsdAtom::OnChildChanged(AP4_Atom*)
{
// remcompute our size
- AP4_UI64 size = GetHeaderSize() + 4;
+ AP4_UI64 size = GetHeaderSize()+4;
m_Children.Apply(AP4_AtomSizeAdder(size));
m_Size32 = (AP4_UI32)size;
// update our parent
- if(m_Parent) m_Parent->OnChildChanged(this);
+ if (m_Parent) m_Parent->OnChildChanged(this);
}
/*----------------------------------------------------------------------
@@ -171,21 +166,18 @@ AP4_SampleDescription*
AP4_StsdAtom::GetSampleDescription(AP4_Ordinal index)
{
// check index
- if(index >= m_Children.ItemCount()) return NULL;
+ if (index >= m_Children.ItemCount()) return NULL;
// return the description if we already have it in the internal table
- if(m_SampleDescriptions[index]) return m_SampleDescriptions[index];
+ if (m_SampleDescriptions[index]) return m_SampleDescriptions[index];
// create and cache a sample description for this entry
AP4_Atom* entry;
m_Children.Get(index, entry);
AP4_SampleEntry* sample_entry = AP4_DYNAMIC_CAST(AP4_SampleEntry, entry);
- if(sample_entry == NULL)
- {
+ if (sample_entry == NULL) {
m_SampleDescriptions[index] = new AP4_UnknownSampleDescription(entry);
- }
- else
- {
+ } else {
m_SampleDescriptions[index] = sample_entry->ToSampleDescription();
}
return m_SampleDescriptions[index];
@@ -198,7 +190,7 @@ AP4_SampleEntry*
AP4_StsdAtom::GetSampleEntry(AP4_Ordinal index)
{
// check index
- if(index >= m_Children.ItemCount()) return NULL;
+ if (index >= m_Children.ItemCount()) return NULL;
// return the sample entry
AP4_Atom* entry;
@@ -222,7 +214,7 @@ AP4_Result
AP4_StsdAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("entry-count", m_Children.ItemCount());
-
+
// inspect children
m_Children.Apply(AP4_AtomListInspector(inspector));
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.h
index b47948d25..8a5013a72 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StsdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stsd Atoms
+| AP4 - stsd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.cpp
index 76a348249..23d06f82d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stss Atoms
+| AP4 - stss Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_StssAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_StssAtom(size, version, flags, stream);
}
@@ -55,14 +55,14 @@ AP4_StssAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_StssAtom::AP4_StssAtom
+---------------------------------------------------------------------*/
AP4_StssAtom::AP4_StssAtom() :
- AP4_Atom(AP4_ATOM_TYPE_STSS, AP4_FULL_ATOM_HEADER_SIZE + 4, 0, 0)
+ AP4_Atom(AP4_ATOM_TYPE_STSS, AP4_FULL_ATOM_HEADER_SIZE+4, 0, 0)
{
}
/*----------------------------------------------------------------------
| AP4_StssAtom::AP4_StssAtom
+---------------------------------------------------------------------*/
-AP4_StssAtom::AP4_StssAtom(AP4_UI32 size,
+AP4_StssAtom::AP4_StssAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -71,11 +71,9 @@ AP4_StssAtom::AP4_StssAtom(AP4_UI32 size,
{
AP4_UI32 entry_count;
stream.ReadUI32(entry_count);
- while(entry_count--)
- {
+ while (entry_count--) {
AP4_UI32 entry_sample_index;
- if(stream.ReadUI32(entry_sample_index) == AP4_SUCCESS)
- {
+ if (stream.ReadUI32(entry_sample_index) == AP4_SUCCESS) {
m_Entries.Append(entry_sample_index);
}
}
@@ -92,13 +90,12 @@ AP4_StssAtom::WriteFields(AP4_ByteStream& stream)
// entry count
AP4_Cardinal entry_count = m_Entries.ItemCount();
result = stream.WriteUI32(entry_count);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// entries
- for(AP4_Ordinal i = 0; i < entry_count; i++)
- {
+ for (AP4_Ordinal i=0; i<entry_count; i++) {
result = stream.WriteUI32(m_Entries[i]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return result;
@@ -112,7 +109,7 @@ AP4_StssAtom::AddEntry(AP4_UI32 sample)
{
m_Entries.Append(sample);
m_Size32 += 4;
-
+
return AP4_SUCCESS;
}
@@ -125,24 +122,21 @@ AP4_StssAtom::IsSampleSync(AP4_Ordinal sample)
unsigned int entry_index = 0;
// check bounds
- if(sample == 0 || m_Entries.ItemCount() == 0) return false;
+ if (sample == 0 || m_Entries.ItemCount() == 0) return false;
// see if we can start from the cached index
- if(m_Entries[m_LookupCache] <= sample)
- {
+ if (m_Entries[m_LookupCache] <= sample) {
entry_index = m_LookupCache;
}
// do a linear search
- while(entry_index < m_Entries.ItemCount() &&
- m_Entries[entry_index] <= sample)
- {
- if(m_Entries[entry_index] == sample)
- {
+ while (entry_index < m_Entries.ItemCount() &&
+ m_Entries[entry_index] <= sample) {
+ if (m_Entries[entry_index] == sample) {
m_LookupCache = entry_index;
return true;
}
- entry_index++;
+ entry_index++;
}
return false;
@@ -158,4 +152,4 @@ AP4_StssAtom::InspectFields(AP4_AtomInspector& inspector)
return AP4_SUCCESS;
}
-
+
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.h
index ccc4bf795..0384cb6a3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StssAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stss Atoms
+| AP4 - stss Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -48,13 +48,10 @@ public:
// constructor
AP4_StssAtom();
-
+
// methods
// methods
- const AP4_Array<AP4_UI32>& GetEntries()
- {
- return m_Entries;
- }
+ const AP4_Array<AP4_UI32>& GetEntries() { return m_Entries; }
AP4_Result AddEntry(AP4_UI32 sample);
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual bool IsSampleSync(AP4_Ordinal sample);
@@ -62,11 +59,11 @@ public:
private:
// methods
- AP4_StssAtom(AP4_UI32 size,
+ AP4_StssAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
-
+
// members
AP4_Array<AP4_UI32> m_Entries;
AP4_Ordinal m_LookupCache;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.cpp
index 19f116346..97dfc9f91 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stsz Atoms
+| AP4 - stsz Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_StszAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_StszAtom(size, version, flags, stream);
}
@@ -55,7 +55,7 @@ AP4_StszAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_StszAtom::AP4_StszAtom
+---------------------------------------------------------------------*/
AP4_StszAtom::AP4_StszAtom() :
- AP4_Atom(AP4_ATOM_TYPE_STSZ, AP4_FULL_ATOM_HEADER_SIZE + 8, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_STSZ, AP4_FULL_ATOM_HEADER_SIZE+8, 0, 0),
m_SampleSize(0),
m_SampleCount(0)
{
@@ -64,7 +64,7 @@ AP4_StszAtom::AP4_StszAtom() :
/*----------------------------------------------------------------------
| AP4_StszAtom::AP4_StszAtom
+---------------------------------------------------------------------*/
-AP4_StszAtom::AP4_StszAtom(AP4_UI32 size,
+AP4_StszAtom::AP4_StszAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -72,19 +72,16 @@ AP4_StszAtom::AP4_StszAtom(AP4_UI32 size,
{
stream.ReadUI32(m_SampleSize);
stream.ReadUI32(m_SampleCount);
- if(m_SampleSize == 0) // means that the samples have different sizes
- {
+ if (m_SampleSize == 0) { // means that the samples have different sizes
unsigned long sample_count = m_SampleCount;
m_Entries.SetItemCount(sample_count);
unsigned char* buffer = new unsigned char[sample_count*4];
- AP4_Result result = stream.Read(buffer, sample_count * 4);
- if(AP4_FAILED(result))
- {
+ AP4_Result result = stream.Read(buffer, sample_count*4);
+ if (AP4_FAILED(result)) {
delete[] buffer;
return;
}
- for(unsigned int i = 0; i < sample_count; i++)
- {
+ for (unsigned int i=0; i<sample_count; i++) {
m_Entries[i] = AP4_BytesToUInt32BE(&buffer[i*4]);
}
delete[] buffer;
@@ -101,19 +98,17 @@ AP4_StszAtom::WriteFields(AP4_ByteStream& stream)
// sample size
result = stream.WriteUI32(m_SampleSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// sample count
result = stream.WriteUI32(m_SampleCount);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// entries if needed (the samples have different sizes)
- if(m_SampleSize == 0)
- {
- for(AP4_UI32 i = 0; i < m_SampleCount; i++)
- {
+ if (m_SampleSize == 0) {
+ for (AP4_UI32 i=0; i<m_SampleCount; i++) {
result = stream.WriteUI32(m_Entries[i]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
}
@@ -136,20 +131,14 @@ AP4_Result
AP4_StszAtom::GetSampleSize(AP4_Ordinal sample, AP4_Size& sample_size)
{
// check the sample index
- if(sample > m_SampleCount || sample == 0)
- {
+ if (sample > m_SampleCount || sample == 0) {
sample_size = 0;
return AP4_ERROR_OUT_OF_RANGE;
- }
- else
- {
+ } else {
// find the size
- if(m_SampleSize != 0) // constant size
- {
+ if (m_SampleSize != 0) { // constant size
sample_size = m_SampleSize;
- }
- else
- {
+ } else {
sample_size = m_Entries[sample - 1];
}
return AP4_SUCCESS;
@@ -163,33 +152,23 @@ AP4_Result
AP4_StszAtom::SetSampleSize(AP4_Ordinal sample, AP4_Size sample_size)
{
// check the sample index
- if(sample > m_SampleCount || sample == 0)
- {
+ if (sample > m_SampleCount || sample == 0) {
return AP4_ERROR_OUT_OF_RANGE;
- }
- else
- {
- if(m_Entries.ItemCount() == 0)
- {
+ } else {
+ if (m_Entries.ItemCount() == 0) {
// all samples must have the same size
- if(sample_size != m_SampleSize)
- {
+ if (sample_size != m_SampleSize) {
// not the same
- if(sample == 1)
- {
+ if (sample == 1) {
// if this is the first sample, update the global size
m_SampleSize = sample_size;
return AP4_SUCCESS;
- }
- else
- {
+ } else {
// can't have different sizes
return AP4_ERROR_INVALID_PARAMETERS;
}
}
- }
- else
- {
+ } else {
// each sample has a different size
m_Entries[sample - 1] = sample_size;
}
@@ -201,7 +180,7 @@ AP4_StszAtom::SetSampleSize(AP4_Ordinal sample, AP4_Size sample_size)
/*----------------------------------------------------------------------
| AP4_StszAtom::AddEntry
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_StszAtom::AddEntry(AP4_UI32 size)
{
m_Entries.Append(size);
@@ -220,11 +199,9 @@ AP4_StszAtom::InspectFields(AP4_AtomInspector& inspector)
inspector.AddField("sample_size", m_SampleSize);
inspector.AddField("sample_count", m_Entries.ItemCount());
- if(inspector.GetVerbosity() >= 2)
- {
+ if (inspector.GetVerbosity() >= 2) {
char header[32];
- for(AP4_Ordinal i = 0; i < m_Entries.ItemCount(); i++)
- {
+ for (AP4_Ordinal i=0; i<m_Entries.ItemCount(); i++) {
AP4_FormatString(header, sizeof(header), "entry %8d", i);
inspector.AddField(header, m_Entries[i]);
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.h
index 70d480c46..70bfa9309 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4StszAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stsz Atoms
+| AP4 - stsz Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -51,7 +51,7 @@ public:
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
virtual AP4_UI32 GetSampleCount();
- virtual AP4_Result GetSampleSize(AP4_Ordinal sample,
+ virtual AP4_Result GetSampleSize(AP4_Ordinal sample,
AP4_Size& sample_size);
/**
* Set the sample size.
@@ -63,18 +63,18 @@ public:
* the global size, and calling with sample>1 will check that
* the value of sample_size is the same as the global size m_SampleSize.
*/
- virtual AP4_Result SetSampleSize(AP4_Ordinal sample,
+ virtual AP4_Result SetSampleSize(AP4_Ordinal sample,
AP4_Size sample_size);
virtual AP4_Result AddEntry(AP4_UI32 size);
- // ==> Start patch MPC
- // FIXME
- friend class AP4_AtomSampleTable;
- // <== End patch MPC
+ // ==> Start patch MPC
+ // FIXME
+ friend class AP4_AtomSampleTable;
+ // <== End patch MPC
private:
// methods
- AP4_StszAtom(AP4_UI32 size,
+ AP4_StszAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.cpp
index 4db29e8e6..15a8d8418 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stts Atoms
+| AP4 - stts Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_SttsAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_SttsAtom(size, version, flags, stream);
}
@@ -55,7 +55,7 @@ AP4_SttsAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_SttsAtom::AP4_SttsAtom
+---------------------------------------------------------------------*/
AP4_SttsAtom::AP4_SttsAtom() :
- AP4_Atom(AP4_ATOM_TYPE_STTS, AP4_FULL_ATOM_HEADER_SIZE + 4, 0, 0)
+ AP4_Atom(AP4_ATOM_TYPE_STTS, AP4_FULL_ATOM_HEADER_SIZE+4, 0, 0)
{
m_LookupCache.entry_index = 0;
m_LookupCache.sample = 0;
@@ -65,7 +65,7 @@ AP4_SttsAtom::AP4_SttsAtom() :
/*----------------------------------------------------------------------
| AP4_SttsAtom::AP4_SttsAtom
+---------------------------------------------------------------------*/
-AP4_SttsAtom::AP4_SttsAtom(AP4_UI32 size,
+AP4_SttsAtom::AP4_SttsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -77,13 +77,11 @@ AP4_SttsAtom::AP4_SttsAtom(AP4_UI32 size,
AP4_UI32 entry_count;
stream.ReadUI32(entry_count);
- while(entry_count--)
- {
+ while (entry_count--) {
AP4_UI32 sample_count;
AP4_UI32 sample_duration;
- if(stream.ReadUI32(sample_count) == AP4_SUCCESS &&
- stream.ReadUI32(sample_duration) == AP4_SUCCESS)
- {
+ if (stream.ReadUI32(sample_count) == AP4_SUCCESS &&
+ stream.ReadUI32(sample_duration) == AP4_SUCCESS) {
m_Entries.Append(AP4_SttsTableEntry(sample_count,
sample_duration));
}
@@ -98,17 +96,16 @@ AP4_SttsAtom::GetDts(AP4_Ordinal sample, AP4_UI64& dts, AP4_UI32* duration)
{
// default value
dts = 0;
- if(duration) *duration = 0;
-
+ if (duration) *duration = 0;
+
// sample indexes start at 1
- if(sample == 0) return AP4_ERROR_OUT_OF_RANGE;
+ if (sample == 0) return AP4_ERROR_OUT_OF_RANGE;
// check the lookup cache
AP4_Ordinal lookup_start = 0;
AP4_Ordinal sample_start = 0;
AP4_UI64 dts_start = 0;
- if(sample >= m_LookupCache.sample)
- {
+ if (sample >= m_LookupCache.sample) {
// start from the cached entry
lookup_start = m_LookupCache.entry_index;
sample_start = m_LookupCache.sample;
@@ -116,28 +113,26 @@ AP4_SttsAtom::GetDts(AP4_Ordinal sample, AP4_UI64& dts, AP4_UI32* duration)
}
// look from the last known point
- for(AP4_Ordinal i = lookup_start; i < m_Entries.ItemCount(); i++)
- {
+ for (AP4_Ordinal i = lookup_start; i < m_Entries.ItemCount(); i++) {
AP4_SttsTableEntry& entry = m_Entries[i];
// check if we have reached the sample
- if(sample <= sample_start + entry.m_SampleCount)
- {
+ if (sample <= sample_start+entry.m_SampleCount) {
// we are within the sample range for the current entry
- dts = dts_start + (AP4_UI64)(sample - 1 - sample_start) * (AP4_UI64)entry.m_SampleDuration;
- if(duration) *duration = entry.m_SampleDuration;
-
+ dts = dts_start + (AP4_UI64)(sample-1 - sample_start) * (AP4_UI64)entry.m_SampleDuration;
+ if (duration) *duration = entry.m_SampleDuration;
+
// update the lookup cache
m_LookupCache.entry_index = i;
m_LookupCache.sample = sample_start;
m_LookupCache.dts = dts_start;
-
+
return AP4_SUCCESS;
}
-
+
// update the sample and dts bases
sample_start += entry.m_SampleCount;
- dts_start += entry.m_SampleCount * entry.m_SampleDuration;
+ dts_start += entry.m_SampleCount*entry.m_SampleDuration;
}
// sample is greater than the number of samples
@@ -167,18 +162,17 @@ AP4_SttsAtom::WriteFields(AP4_ByteStream& stream)
// write the entry count
AP4_Cardinal entry_count = m_Entries.ItemCount();
result = stream.WriteUI32(entry_count);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// write the entries
- for(AP4_Ordinal i = 0; i < entry_count; i++)
- {
+ for (AP4_Ordinal i=0; i<entry_count; i++) {
// sample count
result = stream.WriteUI32(m_Entries[i].m_SampleCount);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// time offset
result = stream.WriteUI32(m_Entries[i].m_SampleDuration);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return AP4_SUCCESS;
@@ -188,24 +182,22 @@ AP4_SttsAtom::WriteFields(AP4_ByteStream& stream)
| AP4_SttsAtom::GetSampleIndexForTimeStamp
+---------------------------------------------------------------------*/
AP4_Result
-AP4_SttsAtom::GetSampleIndexForTimeStamp(AP4_UI64 ts,
- AP4_Ordinal& sample_index)
+AP4_SttsAtom::GetSampleIndexForTimeStamp(AP4_UI64 ts,
+ AP4_Ordinal& sample_index)
{
// init
AP4_Cardinal entry_count = m_Entries.ItemCount();
AP4_UI64 accumulated = 0;
sample_index = 0;
-
- for(AP4_Ordinal i = 0; i < entry_count; i++)
- {
- AP4_UI64 next_accumulated =
+
+ for (AP4_Ordinal i=0; i<entry_count; i++) {
+ AP4_UI64 next_accumulated =
accumulated +
- (AP4_UI64)m_Entries[i].m_SampleCount *
+ (AP4_UI64)m_Entries[i].m_SampleCount *
(AP4_UI64)m_Entries[i].m_SampleDuration;
-
+
// check if the ts is in the range of this entry
- if(ts < next_accumulated)
- {
+ if (ts < next_accumulated) {
sample_index += (AP4_UI32)((ts - accumulated) / m_Entries[i].m_SampleDuration);
return AP4_SUCCESS;
}
@@ -227,17 +219,15 @@ AP4_SttsAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("entry_count", m_Entries.ItemCount());
- if(inspector.GetVerbosity() >= 1)
- {
+ if (inspector.GetVerbosity() >= 1) {
char header[32];
char value[256];
- for(AP4_Ordinal i = 0; i < m_Entries.ItemCount(); i++)
- {
+ for (AP4_Ordinal i=0; i<m_Entries.ItemCount(); i++) {
AP4_FormatString(header, sizeof(header), "entry %8d", i);
- AP4_FormatString(value, sizeof(value),
- "sample_count=%d, sample_duration=%d",
- m_Entries[i].m_SampleCount,
- m_Entries[i].m_SampleDuration);
+ AP4_FormatString(value, sizeof(value),
+ "sample_count=%d, sample_duration=%d",
+ m_Entries[i].m_SampleCount,
+ m_Entries[i].m_SampleDuration);
inspector.AddField(header, value);
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.h
index 4f9784c85..def7acc37 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SttsAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - stts Atoms
+| AP4 - stts Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -38,11 +38,10 @@
/*----------------------------------------------------------------------
| AP4_SttsTableEntry
+---------------------------------------------------------------------*/
-class AP4_SttsTableEntry
-{
-public:
- AP4_SttsTableEntry() :
- m_SampleCount(0),
+class AP4_SttsTableEntry {
+ public:
+ AP4_SttsTableEntry() :
+ m_SampleCount(0),
m_SampleDuration(0) {}
AP4_SttsTableEntry(AP4_UI32 sample_count,
AP4_UI32 sample_duration) :
@@ -69,26 +68,25 @@ public:
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result GetDts(AP4_Ordinal sample, AP4_UI64& dts, AP4_UI32* duration = NULL);
virtual AP4_Result AddEntry(AP4_UI32 sample_count, AP4_UI32 sample_duration);
- virtual AP4_Result GetSampleIndexForTimeStamp(AP4_UI64 ts,
- AP4_Ordinal& sample_index);
+ virtual AP4_Result GetSampleIndexForTimeStamp(AP4_UI64 ts,
+ AP4_Ordinal& sample_index);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- // ==> Start patch MPC
- // FIXME
- friend class AP4_AtomSampleTable;
- // <== End patch MPC
+ // ==> Start patch MPC
+ // FIXME
+ friend class AP4_AtomSampleTable;
+ // <== End patch MPC
private:
// methods
- AP4_SttsAtom(AP4_UI32 size,
+ AP4_SttsAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
// members
AP4_Array<AP4_SttsTableEntry> m_Entries;
- struct
- {
+ struct {
AP4_Ordinal entry_index;
AP4_Ordinal sample;
AP4_UI64 dts;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.cpp
index 492c045c2..b2926e4ac 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.cpp
@@ -38,7 +38,7 @@
| AP4_SyntheticSampleTable::AP4_SyntheticSampleTable()
+---------------------------------------------------------------------*/
AP4_SyntheticSampleTable::AP4_SyntheticSampleTable(AP4_Cardinal chunk_size) :
- m_ChunkSize(chunk_size ? chunk_size : AP4_SYNTHETIC_SAMPLE_TABLE_DEFAULT_CHUNK_SIZE)
+ m_ChunkSize(chunk_size?chunk_size:AP4_SYNTHETIC_SAMPLE_TABLE_DEFAULT_CHUNK_SIZE)
{
m_LookupCache.m_Sample = 0;
m_LookupCache.m_Chunk = 0;
@@ -58,7 +58,7 @@ AP4_SyntheticSampleTable::~AP4_SyntheticSampleTable()
AP4_Result
AP4_SyntheticSampleTable::GetSample(AP4_Ordinal sample_index, AP4_Sample& sample)
{
- if(sample_index >= m_Samples.ItemCount()) return AP4_ERROR_OUT_OF_RANGE;
+ if (sample_index >= m_Samples.ItemCount()) return AP4_ERROR_OUT_OF_RANGE;
sample = m_Samples[sample_index];
return AP4_SUCCESS;
@@ -67,7 +67,7 @@ AP4_SyntheticSampleTable::GetSample(AP4_Ordinal sample_index, AP4_Sample& sample
/*----------------------------------------------------------------------
| AP4_SyntheticSampleTable::GetSampleCount
+---------------------------------------------------------------------*/
-AP4_Cardinal
+AP4_Cardinal
AP4_SyntheticSampleTable::GetSampleCount()
{
return m_Samples.ItemCount();
@@ -76,48 +76,45 @@ AP4_SyntheticSampleTable::GetSampleCount()
/*----------------------------------------------------------------------
| AP4_SyntheticSampleTable::GetSampleChunkPosition
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_SyntheticSampleTable::GetSampleChunkPosition(
- AP4_Ordinal sample_index,
+ AP4_Ordinal sample_index,
AP4_Ordinal& chunk_index,
AP4_Ordinal& position_in_chunk)
{
// default values
chunk_index = 0;
position_in_chunk = 0;
-
+
// check parameters
- if(sample_index >= m_Samples.ItemCount()) return AP4_ERROR_OUT_OF_RANGE;
-
- // look for the chunk
+ if (sample_index >= m_Samples.ItemCount()) return AP4_ERROR_OUT_OF_RANGE;
+
+ // look for the chunk
AP4_Ordinal sample_cursor = 0;
AP4_Ordinal chunk_cursor = 0;
- if(sample_index >= m_LookupCache.m_Sample)
- {
+ if (sample_index >= m_LookupCache.m_Sample) {
sample_cursor = m_LookupCache.m_Sample;
chunk_cursor = m_LookupCache.m_Chunk;
}
- for(;
- chunk_cursor < m_SamplesInChunk.ItemCount();
- sample_cursor += m_SamplesInChunk[chunk_cursor++])
- {
- if(sample_cursor + m_SamplesInChunk[chunk_cursor] > sample_index)
- {
+ for (;
+ chunk_cursor < m_SamplesInChunk.ItemCount();
+ sample_cursor += m_SamplesInChunk[chunk_cursor++]) {
+ if (sample_cursor+m_SamplesInChunk[chunk_cursor] > sample_index) {
chunk_index = chunk_cursor;
- position_in_chunk = sample_index - sample_cursor;
+ position_in_chunk = sample_index-sample_cursor;
m_LookupCache.m_Sample = sample_cursor;
m_LookupCache.m_Chunk = chunk_cursor;
return AP4_SUCCESS;
}
}
-
+
return AP4_ERROR_OUT_OF_RANGE;
}
/*----------------------------------------------------------------------
| AP4_SyntheticSampleTable::GetSampleDescriptionCount
+---------------------------------------------------------------------*/
-AP4_Cardinal
+AP4_Cardinal
AP4_SyntheticSampleTable::GetSampleDescriptionCount()
{
return m_SampleDescriptions.ItemCount();
@@ -126,16 +123,13 @@ AP4_SyntheticSampleTable::GetSampleDescriptionCount()
/*----------------------------------------------------------------------
| AP4_SyntheticSampleTable::GetSampleDescription
+---------------------------------------------------------------------*/
-AP4_SampleDescription*
+AP4_SampleDescription*
AP4_SyntheticSampleTable::GetSampleDescription(AP4_Ordinal index)
{
SampleDescriptionHolder* holder;
- if(AP4_SUCCEEDED(m_SampleDescriptions.Get(index, holder)))
- {
+ if (AP4_SUCCEEDED(m_SampleDescriptions.Get(index, holder))) {
return holder->m_SampleDescription;
- }
- else
- {
+ } else {
return NULL;
}
}
@@ -143,9 +137,9 @@ AP4_SyntheticSampleTable::GetSampleDescription(AP4_Ordinal index)
/*----------------------------------------------------------------------
| AP4_SyntheticSampleTable::AddSampleDescription
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_SyntheticSampleTable::AddSampleDescription(AP4_SampleDescription* description,
- bool transfer_ownership)
+ bool transfer_ownership)
{
return m_SampleDescriptions.Add(new SampleDescriptionHolder(description, transfer_ownership));
}
@@ -153,7 +147,7 @@ AP4_SyntheticSampleTable::AddSampleDescription(AP4_SampleDescription* descriptio
/*----------------------------------------------------------------------
| AP4_SyntheticSampleTable::AddSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_SyntheticSampleTable::AddSample(AP4_ByteStream& data_stream,
AP4_Position offset,
AP4_Size size,
@@ -164,50 +158,38 @@ AP4_SyntheticSampleTable::AddSample(AP4_ByteStream& data_stream,
bool sync)
{
// decide if we need to start a new chunk or increment the last one
- if(m_SamplesInChunk.ItemCount() == 0 ||
- m_SamplesInChunk[m_SamplesInChunk.ItemCount()-1] >= m_ChunkSize ||
- m_Samples.ItemCount() == 0 ||
- m_Samples[m_Samples.ItemCount()-1].GetDescriptionIndex() != description_index)
- {
+ if (m_SamplesInChunk.ItemCount() == 0 ||
+ m_SamplesInChunk[m_SamplesInChunk.ItemCount()-1] >= m_ChunkSize ||
+ m_Samples.ItemCount() == 0 ||
+ m_Samples[m_Samples.ItemCount()-1].GetDescriptionIndex() != description_index) {
m_SamplesInChunk.Append(1);
- }
- else
- {
+ } else {
++m_SamplesInChunk[m_SamplesInChunk.ItemCount()-1];
}
-
+
// compute the timestamps
- if(m_Samples.ItemCount() > 0)
- {
+ if (m_Samples.ItemCount() > 0) {
AP4_Sample* prev_sample = &m_Samples[m_Samples.ItemCount()-1];
- if(dts == 0)
- {
- if(prev_sample->GetDuration() == 0)
- {
+ if (dts == 0) {
+ if (prev_sample->GetDuration() == 0) {
// can't compute the DTS for this sample
return AP4_ERROR_INVALID_PARAMETERS;
}
- dts = prev_sample->GetDts() + prev_sample->GetDuration();
- }
- else
- {
- if(prev_sample->GetDuration() == 0)
- {
+ dts = prev_sample->GetDts()+prev_sample->GetDuration();
+ } else {
+ if (prev_sample->GetDuration() == 0) {
// update the previous sample
- if(dts <= prev_sample->GetDts()) return AP4_ERROR_INVALID_PARAMETERS;
- prev_sample->SetDuration((AP4_UI32)(dts - prev_sample->GetDts()));
- }
- else
- {
- if(dts != prev_sample->GetDts() + prev_sample->GetDuration())
- {
+ if (dts <= prev_sample->GetDts()) return AP4_ERROR_INVALID_PARAMETERS;
+ prev_sample->SetDuration((AP4_UI32)(dts-prev_sample->GetDts()));
+ } else {
+ if (dts != prev_sample->GetDts()+prev_sample->GetDuration()) {
// mismatch
return AP4_ERROR_INVALID_PARAMETERS;
}
}
}
}
-
+
// add the sample to the table
AP4_Sample sample(data_stream, offset, size, duration, description_index, dts, cts_delta, sync);
return m_Samples.Append(sample);
@@ -216,9 +198,9 @@ AP4_SyntheticSampleTable::AddSample(AP4_ByteStream& data_stream,
/*----------------------------------------------------------------------
| AP4_SyntheticSampleTable::GetSampleIndexForTimeStamp
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SyntheticSampleTable::GetSampleIndexForTimeStamp(AP4_UI64 /* ts */,
- AP4_Ordinal& /* index */)
+AP4_Result
+AP4_SyntheticSampleTable::GetSampleIndexForTimeStamp(AP4_UI64 /* ts */,
+ AP4_Ordinal& /* index */)
{
return AP4_ERROR_NOT_SUPPORTED;
}
@@ -226,24 +208,19 @@ AP4_SyntheticSampleTable::GetSampleIndexForTimeStamp(AP4_UI64 /* ts */,
/*----------------------------------------------------------------------
| AP4_SyntheticSampleTable::GetNearestSyncSampleIndex
+---------------------------------------------------------------------*/
-AP4_Ordinal
+AP4_Ordinal
AP4_SyntheticSampleTable::GetNearestSyncSampleIndex(AP4_Ordinal sample_index, bool before)
{
- if(before)
- {
- for(int i = sample_index; i >= 0; i--)
- {
- if(m_Samples[i].IsSync()) return i;
+ if (before) {
+ for (int i=sample_index; i>=0; i--) {
+ if (m_Samples[i].IsSync()) return i;
}
// not found?
return 0;
- }
- else
- {
+ } else {
AP4_Cardinal entry_count = m_Samples.ItemCount();
- for(unsigned int i = sample_index; i < entry_count; i++)
- {
- if(m_Samples[i].IsSync()) return i;
+ for (unsigned int i=sample_index; i<entry_count; i++) {
+ if (m_Samples[i].IsSync()) return i;
}
// not found?
return m_Samples.ItemCount();
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.h
index 9f9ba4d6b..e54d9074d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4SyntheticSampleTable.h
@@ -53,18 +53,18 @@ const AP4_Cardinal AP4_SYNTHETIC_SAMPLE_TABLE_DEFAULT_CHUNK_SIZE = 10;
+---------------------------------------------------------------------*/
class AP4_SyntheticSampleTable : public AP4_SampleTable
{
-public:
+ public:
// methods
- AP4_SyntheticSampleTable(AP4_Cardinal chunk_size
- = AP4_SYNTHETIC_SAMPLE_TABLE_DEFAULT_CHUNK_SIZE);
+ AP4_SyntheticSampleTable(AP4_Cardinal chunk_size
+ = AP4_SYNTHETIC_SAMPLE_TABLE_DEFAULT_CHUNK_SIZE);
virtual ~AP4_SyntheticSampleTable();
// AP4_SampleTable methods
virtual AP4_Result GetSample(AP4_Ordinal index, AP4_Sample& sample);
virtual AP4_Cardinal GetSampleCount();
- virtual AP4_Result GetSampleChunkPosition(AP4_Ordinal sample_index,
- AP4_Ordinal& chunk_index,
- AP4_Ordinal& position_in_chunk);
+ virtual AP4_Result GetSampleChunkPosition(AP4_Ordinal sample_index,
+ AP4_Ordinal& chunk_index,
+ AP4_Ordinal& position_in_chunk);
virtual AP4_Cardinal GetSampleDescriptionCount();
virtual AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index);
virtual AP4_Result GetSampleIndexForTimeStamp(AP4_UI64 ts, AP4_Ordinal& index);
@@ -72,19 +72,19 @@ public:
// methods
/**
- * Add a sample description to the sample table.
+ * Add a sample description to the sample table.
* Each added sample description will have the next available index, starting at 0
*
* @param description Pointer to the sample description to add
* @param transfer_ownership Boolean flag indicating whether the ownership of the
* sample description object is transfered to the sample table object (true by default).
- * If true, the sample table object will own the sample description object, and will
- * delete it when it is itself deleted. If false, the ownership remains with the caller,
+ * If true, the sample table object will own the sample description object, and will
+ * delete it when it is itself deleted. If false, the ownership remains with the caller,
* and only a referencing pointer is kept, thus the caller must ensure that the object
* is not deleted before the sample table is deleted.
*/
virtual AP4_Result AddSampleDescription(AP4_SampleDescription* description,
- bool transfer_ownership = true);
+ bool transfer_ownership=true);
/**
* Add a sample to the sample table, where the sample duration is given
@@ -97,16 +97,16 @@ public:
* value can be 0 if the duration is not known. In that case, the next sample
* added to the table MUST have a non-zero value for the DTS (decoding timestamp),
* which will allow the actual duration of this sample to be computed.
- * @param description_index Index of the sample description that applies to
+ * @param description_index Index of the sample description that applies to
* this sample (typically 0).
* @param dts DTS (decoding timestamp) of the sample. If this value is 0, and there
- * already are samples in the table, the DTS of the sample will be automatically
+ * already are samples in the table, the DTS of the sample will be automatically
* computed based on the DTS and duration of the preceding sample. If this value is
- * not equal to the DTS+duration of the preceding sample, the duration of the
+ * not equal to the DTS+duration of the preceding sample, the duration of the
* preceding sample is automatically adjusted, unless it has a non-zero value, in which
* case AP4_ERROR_INVALID_PARAMETERS is returned.
* The DTS of the first sample in the table MUST always be 0.
- * @param cts_delta Difference between the CTS (composition/display timestamp) and DTS
+ * @param cts_delta Difference between the CTS (composition/display timestamp) and DTS
* (decoding timestamp) of the sample (in the timescale of the media)
* @param sync Boolean flag indicating whether this is a sync sample or not.
*/
@@ -121,26 +121,21 @@ public:
private:
// classes
- class SampleDescriptionHolder
- {
+ class SampleDescriptionHolder {
public:
SampleDescriptionHolder(AP4_SampleDescription* description, bool is_owned) :
m_SampleDescription(description), m_IsOwned(is_owned) {}
- ~SampleDescriptionHolder()
- {
- if(m_IsOwned) delete m_SampleDescription;
- }
+ ~SampleDescriptionHolder() { if (m_IsOwned) delete m_SampleDescription; }
AP4_SampleDescription* m_SampleDescription;
bool m_IsOwned;
};
-
+
// members
AP4_Array<AP4_Sample> m_Samples;
AP4_List<SampleDescriptionHolder> m_SampleDescriptions;
AP4_Cardinal m_ChunkSize;
AP4_Array<AP4_UI32> m_SamplesInChunk;
- struct
- {
+ struct {
AP4_Ordinal m_Sample;
AP4_Ordinal m_Chunk;
} m_LookupCache;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.cpp
index 7daa6af08..678e6ccb3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tfhd Atoms
+| AP4 - tfhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -45,31 +45,31 @@ AP4_TfhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version > 0) return NULL;
- if(size != ComputeSize(flags)) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version > 0) return NULL;
+ if (size != ComputeSize(flags)) return NULL;
return new AP4_TfhdAtom(size, version, flags, stream);
}
/*----------------------------------------------------------------------
| AP4_TfhdAtom::ComputeSize
+---------------------------------------------------------------------*/
-AP4_UI32
+AP4_UI32
AP4_TfhdAtom::ComputeSize(AP4_UI32 flags)
{
- AP4_UI32 size = AP4_FULL_ATOM_HEADER_SIZE + 4;
- if(flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT) size += 8;
- if(flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT) size += 4;
- if(flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT) size += 4;
- if(flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT) size += 4;
- if(flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT) size += 4;
+ AP4_UI32 size = AP4_FULL_ATOM_HEADER_SIZE+4;
+ if (flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT) size += 8;
+ if (flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT) size += 4;
+ if (flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT) size += 4;
+ if (flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT) size += 4;
+ if (flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT) size += 4;
return size;
}
/*----------------------------------------------------------------------
| AP4_TfhdAtom::AP4_TfhdAtom
+---------------------------------------------------------------------*/
-AP4_TfhdAtom::AP4_TfhdAtom(AP4_UI32 flags,
+AP4_TfhdAtom::AP4_TfhdAtom(AP4_UI32 flags,
AP4_UI32 track_id,
AP4_UI64 base_data_offset,
AP4_UI32 sample_description_index,
@@ -89,31 +89,26 @@ AP4_TfhdAtom::AP4_TfhdAtom(AP4_UI32 flags,
/*----------------------------------------------------------------------
| AP4_TfhdAtom::AP4_TfhdAtom
+---------------------------------------------------------------------*/
-AP4_TfhdAtom::AP4_TfhdAtom(AP4_UI32 size,
+AP4_TfhdAtom::AP4_TfhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_TFHD, size, version, flags)
{
stream.ReadUI32(m_TrackId);
- if(flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT)
- {
+ if (flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT) {
stream.ReadUI64(m_BaseDataOffset);
}
- if(flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT)
- {
+ if (flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT) {
stream.ReadUI32(m_SampleDescriptionIndex);
}
- if(flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT)
- {
+ if (flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT) {
stream.ReadUI32(m_DefaultSampleDuration);
}
- if(flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT)
- {
+ if (flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT) {
stream.ReadUI32(m_DefaultSampleSize);
}
- if(flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT)
- {
+ if (flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT) {
stream.ReadUI32(m_DefaultSampleFlags);
}
}
@@ -125,35 +120,30 @@ AP4_Result
AP4_TfhdAtom::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
+
result = stream.WriteUI32(m_TrackId);
- if(AP4_FAILED(result)) return result;
- if(m_Flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT)
- {
+ if (AP4_FAILED(result)) return result;
+ if (m_Flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT) {
result = stream.WriteUI64(m_BaseDataOffset);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT)
- {
+ if (m_Flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT) {
result = stream.WriteUI32(m_SampleDescriptionIndex);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT)
- {
+ if (m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT) {
stream.WriteUI32(m_DefaultSampleDuration);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT)
- {
+ if (m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT) {
stream.WriteUI32(m_DefaultSampleSize);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT)
- {
+ if (m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT) {
stream.WriteUI32(m_DefaultSampleFlags);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
-
+
return AP4_SUCCESS;
}
@@ -164,25 +154,20 @@ AP4_Result
AP4_TfhdAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("track ID", m_TrackId);
- if(m_Flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT)
- {
+ if (m_Flags & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT) {
inspector.AddField("base data offset", m_BaseDataOffset);
}
- if(m_Flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT)
- {
+ if (m_Flags & AP4_TFHD_FLAG_SAMPLE_DESCRIPTION_INDEX_PRESENT) {
inspector.AddField("sample description index", m_SampleDescriptionIndex);
}
- if(m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT)
- {
+ if (m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_DURATION_PRESENT) {
inspector.AddField("default sample duration", m_DefaultSampleDuration);
}
- if(m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT)
- {
+ if (m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_SIZE_PRESENT) {
inspector.AddField("default sample size", m_DefaultSampleSize);
}
- if(m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT)
- {
- inspector.AddField("default sample flags", m_DefaultSampleFlags, AP4_AtomInspector::HINT_HEX);
+ if (m_Flags & AP4_TFHD_FLAG_DEFAULT_SAMPLE_FLAGS_PRESENT) {
+ inspector.AddField("default sample flags", m_DefaultSampleFlags, AP4_AtomInspector::HINT_HEX );
}
return AP4_SUCCESS;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.h
index 6fba18062..db0d3f777 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfhdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tfhd Atoms
+| AP4 - tfhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -57,7 +57,7 @@ public:
static AP4_UI32 ComputeSize(AP4_UI32 flags);
// methods
- AP4_TfhdAtom(AP4_UI32 flags,
+ AP4_TfhdAtom(AP4_UI32 flags,
AP4_UI32 track_id,
AP4_UI64 base_data_offset,
AP4_UI32 sample_description_index,
@@ -67,58 +67,22 @@ public:
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_UI32 GetTrackId()
- {
- return m_TrackId;
- }
- void SetTrackId(AP4_UI32 track_id)
- {
- m_TrackId = track_id;
- }
- AP4_UI64 GetBaseDataOffset()
- {
- return m_BaseDataOffset;
- }
- void SetBaseDataOffset(AP4_UI64 offset)
- {
- m_BaseDataOffset = offset;
- }
- AP4_UI32 GetSampleDescriptionIndex()
- {
- return m_SampleDescriptionIndex;
- }
- void SetSampleDescriptionIndex(AP4_UI32 indx)
- {
- m_SampleDescriptionIndex = indx;
- }
- AP4_UI32 GetDefaultSampleDuration()
- {
- return m_DefaultSampleDuration;
- }
- void SetDefaultSampleDuration(AP4_UI32 duration)
- {
- m_DefaultSampleDuration = duration;
- }
- AP4_UI32 GetDefaultSampleSize()
- {
- return m_DefaultSampleSize;
- }
- void SetDefaultSampleSize(AP4_UI32 size)
- {
- m_DefaultSampleSize = size;
- }
- AP4_UI32 GetDefaultSampleFlags()
- {
- return m_DefaultSampleFlags;
- }
- void SetDefaultSampleFlags(AP4_UI32 flags)
- {
- m_DefaultSampleFlags = flags;
- }
+ AP4_UI32 GetTrackId() { return m_TrackId; }
+ void SetTrackId(AP4_UI32 track_id) { m_TrackId = track_id; }
+ AP4_UI64 GetBaseDataOffset() { return m_BaseDataOffset; }
+ void SetBaseDataOffset(AP4_UI64 offset) { m_BaseDataOffset = offset; }
+ AP4_UI32 GetSampleDescriptionIndex() { return m_SampleDescriptionIndex; }
+ void SetSampleDescriptionIndex(AP4_UI32 indx) { m_SampleDescriptionIndex = indx; }
+ AP4_UI32 GetDefaultSampleDuration() { return m_DefaultSampleDuration; }
+ void SetDefaultSampleDuration(AP4_UI32 duration) { m_DefaultSampleDuration = duration; }
+ AP4_UI32 GetDefaultSampleSize() { return m_DefaultSampleSize; }
+ void SetDefaultSampleSize(AP4_UI32 size) { m_DefaultSampleSize = size; }
+ AP4_UI32 GetDefaultSampleFlags() { return m_DefaultSampleFlags; }
+ void SetDefaultSampleFlags(AP4_UI32 flags) { m_DefaultSampleFlags = flags; }
private:
// methods
- AP4_TfhdAtom(AP4_UI32 size,
+ AP4_TfhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.cpp
index 2aa930892..1c5437128 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tfra Atoms
+| AP4 - tfra Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -36,14 +36,14 @@
/*----------------------------------------------------------------------
| AP4_TfraAtom::Create
+---------------------------------------------------------------------*/
-AP4_TfraAtom*
+AP4_TfraAtom*
AP4_TfraAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version = 0;
AP4_UI32 flags = 0;
AP4_Result result = ReadFullHeader(stream, version, flags);
- if(AP4_FAILED(result)) return NULL;
- if(version > 1) return NULL;
+ if (AP4_FAILED(result)) return NULL;
+ if (version > 1) return NULL;
return new AP4_TfraAtom(size, version, flags, stream);
}
@@ -51,37 +51,33 @@ AP4_TfraAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_TfraAtom::AP4_TfraAtom
+---------------------------------------------------------------------*/
AP4_TfraAtom::AP4_TfraAtom() :
- AP4_Atom(AP4_ATOM_TYPE_TFRA, AP4_FULL_ATOM_HEADER_SIZE + 4 + 4 + 4)
+ AP4_Atom(AP4_ATOM_TYPE_TFRA, AP4_FULL_ATOM_HEADER_SIZE+4+4+4)
{
}
/*----------------------------------------------------------------------
| AP4_TfraAtom::AP4_TfraAtom
+---------------------------------------------------------------------*/
-AP4_TfraAtom::AP4_TfraAtom(AP4_UI32 size,
- AP4_UI32 version,
- AP4_UI32 flags,
+AP4_TfraAtom::AP4_TfraAtom(AP4_UI32 size,
+ AP4_UI32 version,
+ AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_TFRA, size, version, flags)
{
stream.ReadUI32(m_TrackId);
AP4_UI32 fields = 0;
stream.ReadUI32(fields);
- m_LengthSizeOfTrafNumber = (fields >> 4) & 3;
- m_LengthSizeOfTrunNumber = (fields >> 2) & 3;
- m_LengthSizeOfSampleNumber = (fields) & 3;
+ m_LengthSizeOfTrafNumber = (fields>>4)&3;
+ m_LengthSizeOfTrunNumber = (fields>>2)&3;
+ m_LengthSizeOfSampleNumber = (fields )&3;
AP4_UI32 entry_count = 0;
stream.ReadUI32(entry_count);
m_Entries.SetItemCount(entry_count);
- for(unsigned int i = 0; i < entry_count; i++)
- {
- if(version == 1)
- {
+ for (unsigned int i=0; i<entry_count; i++) {
+ if (version == 1) {
stream.ReadUI64(m_Entries[i].m_Time);
stream.ReadUI64(m_Entries[i].m_MoofOffset);
- }
- else
- {
+ } else {
AP4_UI32 time = 0;
AP4_UI32 moof_offset = 0;
stream.ReadUI32(time);
@@ -89,101 +85,86 @@ AP4_TfraAtom::AP4_TfraAtom(AP4_UI32 size,
m_Entries[i].m_Time = time;
m_Entries[i].m_MoofOffset = moof_offset;
}
- switch(m_LengthSizeOfTrafNumber)
- {
- case 0:
- {
- AP4_UI08 traf_number;
- stream.ReadUI08(traf_number);
- m_Entries[i].m_TrafNumber = traf_number;
- break;
- }
- case 1:
- {
- AP4_UI16 traf_number;
- stream.ReadUI16(traf_number);
- m_Entries[i].m_TrafNumber = traf_number;
- break;
- }
- case 2:
- {
- AP4_UI32 traf_number;
- stream.ReadUI24(traf_number);
- m_Entries[i].m_TrafNumber = traf_number;
- break;
- }
- case 3:
- {
- AP4_UI32 traf_number;
- stream.ReadUI32(traf_number);
- m_Entries[i].m_TrafNumber = traf_number;
- break;
- }
- }
-
- switch(m_LengthSizeOfTrunNumber)
- {
- case 0:
- {
- AP4_UI08 trun_number;
- stream.ReadUI08(trun_number);
- m_Entries[i].m_TrunNumber = trun_number;
- break;
- }
- case 1:
- {
- AP4_UI16 trun_number;
- stream.ReadUI16(trun_number);
- m_Entries[i].m_TrunNumber = trun_number;
- break;
- }
- case 2:
- {
- AP4_UI32 trun_number;
- stream.ReadUI24(trun_number);
- m_Entries[i].m_TrunNumber = trun_number;
- break;
- }
- case 3:
- {
- AP4_UI32 trun_number;
- stream.ReadUI32(trun_number);
- m_Entries[i].m_TrunNumber = trun_number;
- break;
- }
- }
-
- switch(m_LengthSizeOfSampleNumber)
- {
- case 0:
- {
- AP4_UI08 sample_number;
- stream.ReadUI08(sample_number);
- m_Entries[i].m_SampleNumber = sample_number;
- break;
- }
- case 1:
- {
- AP4_UI16 sample_number;
- stream.ReadUI16(sample_number);
- m_Entries[i].m_SampleNumber = sample_number;
- break;
- }
- case 2:
- {
- AP4_UI32 sample_number;
- stream.ReadUI24(sample_number);
- m_Entries[i].m_SampleNumber = sample_number;
- break;
- }
- case 3:
- {
- AP4_UI32 sample_number;
- stream.ReadUI32(sample_number);
- m_Entries[i].m_SampleNumber = sample_number;
- break;
+ switch (m_LengthSizeOfTrafNumber) {
+ case 0: {
+ AP4_UI08 traf_number;
+ stream.ReadUI08(traf_number);
+ m_Entries[i].m_TrafNumber = traf_number;
+ break;
+ }
+ case 1: {
+ AP4_UI16 traf_number;
+ stream.ReadUI16(traf_number);
+ m_Entries[i].m_TrafNumber = traf_number;
+ break;
+ }
+ case 2: {
+ AP4_UI32 traf_number;
+ stream.ReadUI24(traf_number);
+ m_Entries[i].m_TrafNumber = traf_number;
+ break;
+ }
+ case 3: {
+ AP4_UI32 traf_number;
+ stream.ReadUI32(traf_number);
+ m_Entries[i].m_TrafNumber = traf_number;
+ break;
+ }
}
+
+ switch (m_LengthSizeOfTrunNumber) {
+ case 0: {
+ AP4_UI08 trun_number;
+ stream.ReadUI08(trun_number);
+ m_Entries[i].m_TrunNumber = trun_number;
+ break;
+ }
+ case 1: {
+ AP4_UI16 trun_number;
+ stream.ReadUI16(trun_number);
+ m_Entries[i].m_TrunNumber = trun_number;
+ break;
+ }
+ case 2: {
+ AP4_UI32 trun_number;
+ stream.ReadUI24(trun_number);
+ m_Entries[i].m_TrunNumber = trun_number;
+ break;
+ }
+ case 3: {
+ AP4_UI32 trun_number;
+ stream.ReadUI32(trun_number);
+ m_Entries[i].m_TrunNumber = trun_number;
+ break;
+ }
}
+
+ switch (m_LengthSizeOfSampleNumber) {
+ case 0: {
+ AP4_UI08 sample_number;
+ stream.ReadUI08(sample_number);
+ m_Entries[i].m_SampleNumber = sample_number;
+ break;
+ }
+ case 1: {
+ AP4_UI16 sample_number;
+ stream.ReadUI16(sample_number);
+ m_Entries[i].m_SampleNumber = sample_number;
+ break;
+ }
+ case 2: {
+ AP4_UI32 sample_number;
+ stream.ReadUI24(sample_number);
+ m_Entries[i].m_SampleNumber = sample_number;
+ break;
+ }
+ case 3: {
+ AP4_UI32 sample_number;
+ stream.ReadUI32(sample_number);
+ m_Entries[i].m_SampleNumber = sample_number;
+ break;
+ }
+ }
}
}
@@ -196,100 +177,93 @@ AP4_TfraAtom::WriteFields(AP4_ByteStream& stream)
AP4_Result result;
result = stream.WriteUI32(m_TrackId);
- if(AP4_FAILED(result)) return result;
- AP4_UI32 fields = (m_LengthSizeOfTrafNumber << 4) |
- (m_LengthSizeOfTrunNumber << 2) |
- (m_LengthSizeOfSampleNumber);
+ if (AP4_FAILED(result)) return result;
+ AP4_UI32 fields = (m_LengthSizeOfTrafNumber<<4)|
+ (m_LengthSizeOfTrunNumber<<2)|
+ (m_LengthSizeOfSampleNumber );
result = stream.WriteUI32(fields);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_Entries.ItemCount());
- for(unsigned int i = 0; i < m_Entries.ItemCount(); i++)
- {
- if(m_Version == 1)
- {
+ for (unsigned int i=0; i<m_Entries.ItemCount(); i++) {
+ if (m_Version == 1) {
result = stream.WriteUI64(m_Entries[i].m_Time);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI64(m_Entries[i].m_MoofOffset);
- if(AP4_FAILED(result)) return result;
- }
- else
- {
+ if (AP4_FAILED(result)) return result;
+ } else {
result = stream.WriteUI32((AP4_UI32)m_Entries[i].m_Time);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32((AP4_UI32)m_Entries[i].m_MoofOffset);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- switch(m_LengthSizeOfTrafNumber)
- {
- case 0:
- result = stream.WriteUI08((AP4_UI08)m_Entries[i].m_TrafNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ switch (m_LengthSizeOfTrafNumber) {
+ case 0:
+ result = stream.WriteUI08((AP4_UI08)m_Entries[i].m_TrafNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
- case 1:
- result = stream.WriteUI16((AP4_UI16)m_Entries[i].m_TrafNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ case 1:
+ result = stream.WriteUI16((AP4_UI16)m_Entries[i].m_TrafNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
- case 2:
- result = stream.WriteUI24(m_Entries[i].m_TrafNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ case 2:
+ result = stream.WriteUI24(m_Entries[i].m_TrafNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
- case 3:
- result = stream.WriteUI32(m_Entries[i].m_TrafNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ case 3:
+ result = stream.WriteUI32(m_Entries[i].m_TrafNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
}
+
+ switch (m_LengthSizeOfTrunNumber) {
+ case 0:
+ result = stream.WriteUI08((AP4_UI08)m_Entries[i].m_TrunNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
- switch(m_LengthSizeOfTrunNumber)
- {
- case 0:
- result = stream.WriteUI08((AP4_UI08)m_Entries[i].m_TrunNumber);
- if(AP4_FAILED(result)) return result;
- break;
-
- case 1:
- result = stream.WriteUI16((AP4_UI16)m_Entries[i].m_TrunNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ case 1:
+ result = stream.WriteUI16((AP4_UI16)m_Entries[i].m_TrunNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
- case 2:
- result = stream.WriteUI24(m_Entries[i].m_TrunNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ case 2:
+ result = stream.WriteUI24(m_Entries[i].m_TrunNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
- case 3:
- result = stream.WriteUI32(m_Entries[i].m_TrunNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ case 3:
+ result = stream.WriteUI32(m_Entries[i].m_TrunNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
}
- switch(m_LengthSizeOfSampleNumber)
- {
- case 0:
- result = stream.WriteUI08((AP4_UI08)m_Entries[i].m_SampleNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ switch (m_LengthSizeOfSampleNumber) {
+ case 0:
+ result = stream.WriteUI08((AP4_UI08)m_Entries[i].m_SampleNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
- case 1:
- result = stream.WriteUI16((AP4_UI16)m_Entries[i].m_SampleNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ case 1:
+ result = stream.WriteUI16((AP4_UI16)m_Entries[i].m_SampleNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
- case 2:
- result = stream.WriteUI24(m_Entries[i].m_SampleNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ case 2:
+ result = stream.WriteUI24(m_Entries[i].m_SampleNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
- case 3:
- result = stream.WriteUI32(m_Entries[i].m_SampleNumber);
- if(AP4_FAILED(result)) return result;
- break;
+ case 3:
+ result = stream.WriteUI32(m_Entries[i].m_SampleNumber);
+ if (AP4_FAILED(result)) return result;
+ break;
}
}
-
+
return AP4_SUCCESS;
}
@@ -304,14 +278,12 @@ AP4_TfraAtom::InspectFields(AP4_AtomInspector& inspector)
inspector.AddField("length_size_of_trun_num", m_LengthSizeOfTrunNumber);
inspector.AddField("length_size_of_sample_num", m_LengthSizeOfSampleNumber);
inspector.AddField("entry count", m_Entries.ItemCount());
- if(inspector.GetVerbosity() >= 1)
- {
- for(unsigned int i = 0; i < m_Entries.ItemCount(); i++)
- {
+ if (inspector.GetVerbosity() >= 1) {
+ for (unsigned int i=0; i<m_Entries.ItemCount(); i++) {
char name[16];
char value[256];
AP4_FormatString(name, sizeof(name), "[%04d]", i);
- AP4_FormatString(value, sizeof(value),
+ AP4_FormatString(value, sizeof(value),
"time=%lld, moof_offset=%lld, traf_number=%d, trun_number=%d, sample_number=%d",
m_Entries[i].m_Time,
m_Entries[i].m_MoofOffset,
@@ -321,6 +293,6 @@ AP4_TfraAtom::InspectFields(AP4_AtomInspector& inspector)
inspector.AddField(name, value);
}
}
-
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.h
index 22a3c0df7..fc5f78495 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TfraAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tfra Atoms
+| AP4 - tfra Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -48,8 +48,7 @@ class AP4_TfraAtom : public AP4_Atom
{
public:
// types
- struct Entry
- {
+ struct Entry {
Entry() : m_Time(0), m_MoofOffset(0), m_TrafNumber(0), m_TrunNumber(0), m_SampleNumber(0) {}
AP4_UI64 m_Time;
AP4_UI64 m_MoofOffset;
@@ -57,11 +56,11 @@ public:
AP4_UI32 m_TrunNumber;
AP4_UI32 m_SampleNumber;
};
-
+
// class methods
static AP4_TfraAtom* Create(AP4_Size size, AP4_ByteStream& stream);
-
- // constructors
+
+ // constructors
AP4_TfraAtom();
// methods
@@ -69,10 +68,7 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- AP4_Array<Entry>& GetEntries()
- {
- return m_Entries;
- }
+ AP4_Array<Entry>& GetEntries() { return m_Entries; }
private:
// methods
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.cpp
index fb05c36d7..f6f446e7d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tims Atoms
+| AP4 - tims Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -38,7 +38,7 @@
| AP4_TimsAtom::AP4_TimsAtom
+---------------------------------------------------------------------*/
AP4_TimsAtom::AP4_TimsAtom(AP4_UI32 timescale) :
- AP4_Atom(AP4_ATOM_TYPE_TIMS, AP4_ATOM_HEADER_SIZE + 4),
+ AP4_Atom(AP4_ATOM_TYPE_TIMS, AP4_ATOM_HEADER_SIZE+4),
m_TimeScale(timescale)
{
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.h
index 6f47d45df..3a78bdc2a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TimsAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tims Atoms
+| AP4 - tims Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -41,8 +41,7 @@ class AP4_TimsAtom : public AP4_Atom
{
public:
// class methods
- static AP4_TimsAtom* Create(AP4_Size size, AP4_ByteStream& stream)
- {
+ static AP4_TimsAtom* Create(AP4_Size size, AP4_ByteStream& stream) {
return new AP4_TimsAtom(size, stream);
}
@@ -52,10 +51,7 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- virtual AP4_UI32 GetTimeScale()
- {
- return m_TimeScale;
- }
+ virtual AP4_UI32 GetTimeScale() { return m_TimeScale; }
private:
// methods
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.cpp
index f106b58f4..6060ac049 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tkhd Atoms
+| AP4 - tkhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_TkhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version > 1) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version > 1) return NULL;
return new AP4_TkhdAtom(size, version, flags, stream);
}
@@ -61,7 +61,7 @@ AP4_TkhdAtom::AP4_TkhdAtom(AP4_UI32 creation_time,
AP4_UI16 volume,
AP4_UI32 width,
AP4_UI32 height) :
- AP4_Atom(AP4_ATOM_TYPE_TKHD, AP4_FULL_ATOM_HEADER_SIZE + 80, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_TKHD, AP4_FULL_ATOM_HEADER_SIZE+80, 0, 0),
m_CreationTime(creation_time),
m_ModificationTime(modification_time),
m_TrackId(track_id),
@@ -93,14 +93,13 @@ AP4_TkhdAtom::AP4_TkhdAtom(AP4_UI32 creation_time,
/*----------------------------------------------------------------------
| AP4_TkhdAtom::AP4_TkhdAtom
+---------------------------------------------------------------------*/
-AP4_TkhdAtom::AP4_TkhdAtom(AP4_UI32 size,
+AP4_TkhdAtom::AP4_TkhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_TKHD, size, version, flags)
{
- if(m_Version == 0)
- {
+ if (m_Version == 0) {
// we only deal with version 0 for now
AP4_UI32 creation_time;
stream.ReadUI32(creation_time);
@@ -113,9 +112,7 @@ AP4_TkhdAtom::AP4_TkhdAtom(AP4_UI32 size,
AP4_UI32 duration;
stream.ReadUI32(duration);
m_Duration = duration;
- }
- else
- {
+ } else {
stream.ReadUI64(m_CreationTime);
stream.ReadUI64(m_ModificationTime);
stream.ReadUI32(m_TrackId);
@@ -128,8 +125,7 @@ AP4_TkhdAtom::AP4_TkhdAtom(AP4_UI32 size,
stream.ReadUI16(m_AlternateGroup);
stream.ReadUI16(m_Volume);
stream.ReadUI16(m_Reserved3);
- for(int i = 0; i < 9; i++)
- {
+ for (int i=0; i<9; i++) {
stream.ReadUI32(m_Matrix[i]);
}
stream.ReadUI32(m_Width);
@@ -145,60 +141,56 @@ AP4_TkhdAtom::WriteFields(AP4_ByteStream& stream)
AP4_Result result;
// creation/modification time, track id, reserved1 & duration
- if(m_Version == 0)
- {
+ if (m_Version == 0) {
result = stream.WriteUI32((AP4_UI32)m_CreationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32((AP4_UI32)m_ModificationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_TrackId);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_Reserved1);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32((AP4_UI32)m_Duration);
- if(AP4_FAILED(result)) return result;
- }
- else
- {
+ if (AP4_FAILED(result)) return result;
+ } else {
result = stream.WriteUI64(m_CreationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI64(m_ModificationTime);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_TrackId);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_Reserved1);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI64(m_Duration);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// reserved2
result = stream.Write(m_Reserved2, sizeof(m_Reserved2));
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// layer, alternate group & volume
result = stream.WriteUI16(m_Layer);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI16(m_AlternateGroup);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI16(m_Volume);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// reserved3
result = stream.WriteUI16(m_Reserved3);
// matrix
- for(int i = 0; i < 9; i++)
- {
+ for (int i=0; i<9; i++) {
result = stream.WriteUI32(m_Matrix[i]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
// width & height
result = stream.WriteUI32(m_Width);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI32(m_Height);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return result;
}
@@ -212,8 +204,8 @@ AP4_TkhdAtom::InspectFields(AP4_AtomInspector& inspector)
inspector.AddField("enabled", ((m_Flags & AP4_TKHD_FLAG_TRACK_ENABLED) ? 1 : 0), AP4_AtomInspector::HINT_BOOLEAN);
inspector.AddField("id", m_TrackId);
inspector.AddField("duration", m_Duration);
- inspector.AddFieldF("width", (float)m_Width / 65536.0f);
- inspector.AddFieldF("height", (float)m_Height / 65536.0f);
-
+ inspector.AddFieldF("width", (float)m_Width/65536.0f);
+ inspector.AddFieldF("height", (float)m_Height/65536.0f);
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.h
index a703638d7..d0d0f7b68 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TkhdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tkhd Atoms
+| AP4 - tkhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -61,53 +61,28 @@ public:
AP4_UI64 duration,
AP4_UI16 volume,
AP4_UI32 width,
- AP4_UI32 height);
+ AP4_UI32 height);
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_UI64 GetDuration()
- {
- return m_Duration;
- }
- void SetDuration(AP4_UI64 duration)
- {
- m_Duration = duration;
- }
- AP4_UI32 GetTrackId()
- {
- return m_TrackId;
- }
- void SetTrackId(AP4_UI32 track_id)
- {
- m_TrackId = track_id;
- }
+ AP4_UI64 GetDuration() { return m_Duration; }
+ void SetDuration(AP4_UI64 duration) { m_Duration = duration; }
+ AP4_UI32 GetTrackId() { return m_TrackId; }
+ void SetTrackId(AP4_UI32 track_id) { m_TrackId = track_id; }
- void GetTranslation(float& x, float& y)
- {
+ void GetTranslation(float& x, float& y) {
x = (float)(*(int*)&m_Matrix[6]) / 65536;
y = (float)(*(int*)&m_Matrix[7]) / 65536;
}
- AP4_UI32 GetWidth()
- {
- return m_Width;
- }
- void SetWidth(AP4_UI32 width)
- {
- m_Width = width;
- }
- AP4_UI32 GetHeight()
- {
- return m_Height;
- }
- void SetHeight(AP4_UI32 height)
- {
- m_Height = height;
- }
+ AP4_UI32 GetWidth() { return m_Width; }
+ void SetWidth(AP4_UI32 width) { m_Width = width; }
+ AP4_UI32 GetHeight() { return m_Height; }
+ void SetHeight(AP4_UI32 height) { m_Height = height; }
-private:
+ private:
// methods
- AP4_TkhdAtom(AP4_UI32 size,
+ AP4_TkhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.cpp
index 810750582..9dc915571 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.cpp
@@ -49,7 +49,7 @@
+---------------------------------------------------------------------*/
AP4_Track::AP4_Track(Type type,
AP4_SampleTable* sample_table,
- AP4_UI32 track_id,
+ AP4_UI32 track_id,
AP4_UI32 movie_time_scale,
AP4_UI64 track_duration,
AP4_UI32 media_time_scale,
@@ -61,66 +61,65 @@ AP4_Track::AP4_Track(Type type,
m_Type(type),
m_SampleTable(sample_table),
m_SampleTableIsOwned(true),
- m_MovieTimeScale(movie_time_scale ?
- movie_time_scale :
+ m_MovieTimeScale(movie_time_scale ?
+ movie_time_scale :
AP4_TRACK_DEFAULT_MOVIE_TIMESCALE)
{
// compute the default volume value
unsigned int volume = 0;
- if(type == TYPE_AUDIO) volume = 0x100;
+ if (type == TYPE_AUDIO) volume = 0x100;
// compute the handler type and name
AP4_Atom::Type hdlr_type;
const char* hdlr_name;
- switch(type)
- {
- case TYPE_AUDIO:
- hdlr_type = AP4_HANDLER_TYPE_SOUN;
- hdlr_name = "Bento4 Sound Handler";
- break;
-
- case TYPE_VIDEO:
- hdlr_type = AP4_HANDLER_TYPE_VIDE;
- hdlr_name = "Bento4 Video Handler";
- break;
-
- case TYPE_HINT:
- hdlr_type = AP4_HANDLER_TYPE_HINT;
- hdlr_name = "Bento4 Hint Handler";
- break;
-
- case TYPE_TEXT:
- hdlr_type = AP4_HANDLER_TYPE_TEXT;
- hdlr_name = "Bento4 Text Handler";
- break;
-
- default:
- hdlr_type = 0;
- hdlr_name = NULL;
- break;
+ switch (type) {
+ case TYPE_AUDIO:
+ hdlr_type = AP4_HANDLER_TYPE_SOUN;
+ hdlr_name = "Bento4 Sound Handler";
+ break;
+
+ case TYPE_VIDEO:
+ hdlr_type = AP4_HANDLER_TYPE_VIDE;
+ hdlr_name = "Bento4 Video Handler";
+ break;
+
+ case TYPE_HINT:
+ hdlr_type = AP4_HANDLER_TYPE_HINT;
+ hdlr_name = "Bento4 Hint Handler";
+ break;
+
+ case TYPE_TEXT:
+ hdlr_type = AP4_HANDLER_TYPE_TEXT;
+ hdlr_name = "Bento4 Text Handler";
+ break;
+
+ default:
+ hdlr_type = 0;
+ hdlr_name = NULL;
+ break;
}
// create a trak atom
m_TrakAtom = new AP4_TrakAtom(sample_table,
- hdlr_type,
+ hdlr_type,
hdlr_name,
- track_id,
- 0,
- 0,
+ track_id,
+ 0,
+ 0,
track_duration,
media_time_scale,
media_duration,
- volume,
+ volume,
language,
- width,
+ width,
height);
}
/*----------------------------------------------------------------------
| AP4_Track::AP4_Track
+---------------------------------------------------------------------*/
-AP4_Track::AP4_Track(AP4_TrakAtom& atom,
- AP4_ByteStream& sample_stream,
+AP4_Track::AP4_Track(AP4_TrakAtom& atom,
+ AP4_ByteStream& sample_stream,
AP4_UI32 movie_time_scale) :
m_TrakAtom(&atom),
m_TrakAtomIsOwned(false),
@@ -131,51 +130,35 @@ AP4_Track::AP4_Track(AP4_TrakAtom& atom,
{
// find the handler type
AP4_Atom* sub = atom.FindChild("mdia/hdlr");
- if(sub)
- {
+ if (sub) {
AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, sub);
- if(hdlr)
- {
+ if (hdlr) {
AP4_UI32 type = hdlr->GetHandlerType();
- if(type == AP4_HANDLER_TYPE_SOUN)
- {
+ if (type == AP4_HANDLER_TYPE_SOUN) {
m_Type = TYPE_AUDIO;
- }
- else if(type == AP4_HANDLER_TYPE_VIDE)
- {
+ } else if (type == AP4_HANDLER_TYPE_VIDE) {
m_Type = TYPE_VIDEO;
- }
- else if(type == AP4_HANDLER_TYPE_HINT)
- {
+ } else if (type == AP4_HANDLER_TYPE_HINT) {
m_Type = TYPE_HINT;
- }
- else if(type == AP4_HANDLER_TYPE_ODSM ||
- type == AP4_HANDLER_TYPE_SDSM)
- {
+ } else if (type == AP4_HANDLER_TYPE_ODSM ||
+ type == AP4_HANDLER_TYPE_SDSM) {
m_Type = TYPE_SYSTEM;
- }
- else if(type == AP4_HANDLER_TYPE_TEXT ||
- type == AP4_HANDLER_TYPE_TX3G)
- {
+ } else if (type == AP4_HANDLER_TYPE_TEXT ||
+ type == AP4_HANDLER_TYPE_TX3G) {
m_Type = TYPE_TEXT;
- }
- else if(type == AP4_HANDLER_TYPE_JPEG)
- {
+ } else if (type == AP4_HANDLER_TYPE_JPEG) {
m_Type = TYPE_JPEG;
- // ==> Start patch MPC
- }
- else if(type == AP4_HANDLER_TYPE_SUBP)
- {
- m_Type = TYPE_SUBP;
- // <== End patch MPC
- }
+ // ==> Start patch MPC
+ } else if (type == AP4_HANDLER_TYPE_SUBP) {
+ m_Type = TYPE_SUBP;
+ // <== End patch MPC
+ }
}
}
// create a facade for the stbl atom
AP4_ContainerAtom* stbl = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom.FindChild("mdia/minf/stbl"));
- if(stbl)
- {
+ if (stbl) {
m_SampleTable = new AP4_AtomSampleTable(stbl, sample_stream);
}
}
@@ -185,33 +168,31 @@ AP4_Track::AP4_Track(AP4_TrakAtom& atom,
+---------------------------------------------------------------------*/
AP4_Track::~AP4_Track()
{
- if(m_TrakAtomIsOwned) delete m_TrakAtom;
- if(m_SampleTableIsOwned) delete m_SampleTable;
+ if (m_TrakAtomIsOwned) delete m_TrakAtom;
+ if (m_SampleTableIsOwned) delete m_SampleTable;
}
/*----------------------------------------------------------------------
| AP4_Track::Clone
+---------------------------------------------------------------------*/
-AP4_Track*
+AP4_Track*
AP4_Track::Clone(AP4_Result* result)
{
AP4_SyntheticSampleTable* sample_table = new AP4_SyntheticSampleTable();
-
+
// default return value
- if(result) *result = AP4_SUCCESS;
-
+ if (result) *result = AP4_SUCCESS;
+
// add clones of the sample descriptions to the new sample table
- for(unsigned int i = 0; ; i++)
- {
+ for (unsigned int i=0; ;i++) {
AP4_SampleDescription* sample_description = GetSampleDescription(i);
- if(sample_description == NULL) break;
+ if (sample_description == NULL) break;
sample_table->AddSampleDescription(sample_description->Clone());
}
AP4_Sample sample;
AP4_Ordinal index = 0;
- while(AP4_SUCCEEDED(GetSample(index, sample)))
- {
+ while (AP4_SUCCEEDED(GetSample(index, sample))) {
AP4_ByteStream* data_stream;
data_stream = sample.GetDataStream();
sample_table->AddSample(*data_stream,
@@ -224,8 +205,8 @@ AP4_Track::Clone(AP4_Result* result)
sample.IsSync());
AP4_RELEASE(data_stream); // release our ref, the table has kept its own ref.
index++;
- }
-
+ }
+
// create the cloned track
AP4_Track* clone = new AP4_Track(GetType(),
sample_table,
@@ -237,7 +218,7 @@ AP4_Track::Clone(AP4_Result* result)
GetTrackLanguage().GetChars(),
GetWidth(),
GetHeight());
-
+
return clone;
}
@@ -247,7 +228,7 @@ AP4_Track::Clone(AP4_Result* result)
AP4_Result
AP4_Track::Attach(AP4_MoovAtom* moov)
{
- if(!m_TrakAtomIsOwned) return AP4_ERROR_INTERNAL;
+ if (!m_TrakAtomIsOwned) return AP4_ERROR_INTERNAL;
moov->AddChild(m_TrakAtom);
m_TrakAtomIsOwned = false;
@@ -260,11 +241,9 @@ AP4_Track::Attach(AP4_MoovAtom* moov)
AP4_UI32
AP4_Track::GetFlags()
{
- if(m_TrakAtom)
- {
+ if (m_TrakAtom) {
AP4_TkhdAtom* tkhd = AP4_DYNAMIC_CAST(AP4_TkhdAtom, m_TrakAtom->FindChild("tkhd"));
- if(tkhd)
- {
+ if (tkhd) {
return tkhd->GetFlags();
}
}
@@ -277,11 +256,9 @@ AP4_Track::GetFlags()
AP4_Result
AP4_Track::SetFlags(AP4_UI32 flags)
{
- if(m_TrakAtom)
- {
+ if (m_TrakAtom) {
AP4_TkhdAtom* tkhd = AP4_DYNAMIC_CAST(AP4_TkhdAtom, m_TrakAtom->FindChild("tkhd"));
- if(tkhd)
- {
+ if (tkhd) {
tkhd->SetFlags(flags);
return AP4_SUCCESS;
}
@@ -295,11 +272,9 @@ AP4_Track::SetFlags(AP4_UI32 flags)
AP4_UI32
AP4_Track::GetHandlerType()
{
- if(m_TrakAtom)
- {
+ if (m_TrakAtom) {
AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, m_TrakAtom->FindChild("mdia/hdlr"));
- if(hdlr)
- {
+ if (hdlr) {
return hdlr->GetHandlerType();
}
}
@@ -376,7 +351,7 @@ AP4_Track::GetSampleCount()
/*----------------------------------------------------------------------
| AP4_Track::GetSample
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_Track::GetSample(AP4_Ordinal index, AP4_Sample& sample)
{
// delegate to the sample table
@@ -396,8 +371,8 @@ AP4_Track::GetSampleDescription(AP4_Ordinal index)
/*----------------------------------------------------------------------
| AP4_Track::ReadSample
+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Track::ReadSample(AP4_Ordinal index,
+AP4_Result
+AP4_Track::ReadSample(AP4_Ordinal index,
AP4_Sample& sample,
AP4_DataBuffer& data)
{
@@ -405,7 +380,7 @@ AP4_Track::ReadSample(AP4_Ordinal index,
// get the sample
result = GetSample(index, sample);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// read the data
return sample.ReadData(data);
@@ -414,7 +389,7 @@ AP4_Track::ReadSample(AP4_Ordinal index,
/*----------------------------------------------------------------------
| AP4_Track::GetSampleIndexForTimeStampMs
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_Track::GetSampleIndexForTimeStampMs(AP4_UI32 ts_ms, AP4_Ordinal& index)
{
// convert the ts in the timescale of the track's media
@@ -426,10 +401,10 @@ AP4_Track::GetSampleIndexForTimeStampMs(AP4_UI32 ts_ms, AP4_Ordinal& index)
/*----------------------------------------------------------------------
| AP4_Track::GetNearestSyncSampleIndex
+---------------------------------------------------------------------*/
-AP4_Ordinal
+AP4_Ordinal
AP4_Track::GetNearestSyncSampleIndex(AP4_Ordinal index, bool before /* = true */)
{
- if(m_SampleTable == NULL) return index;
+ if (m_SampleTable == NULL) return index;
return m_SampleTable->GetNearestSyncSampleIndex(index, before);
}
@@ -440,13 +415,13 @@ AP4_Result
AP4_Track::SetMovieTimeScale(AP4_UI32 time_scale)
{
// check that we can convert
- if(m_MovieTimeScale == 0) return AP4_FAILURE;
+ if (m_MovieTimeScale == 0) return AP4_FAILURE;
// convert from one time scale to the other
- m_TrakAtom->SetDuration(AP4_ConvertTime(m_TrakAtom->GetDuration(),
+ m_TrakAtom->SetDuration(AP4_ConvertTime(m_TrakAtom->GetDuration(),
m_MovieTimeScale,
time_scale));
-
+
// keep the new movie timescale
m_MovieTimeScale = time_scale;
@@ -459,7 +434,7 @@ AP4_Track::SetMovieTimeScale(AP4_UI32 time_scale)
AP4_UI32
AP4_Track::GetMediaTimeScale()
{
- return m_TrakAtom ? m_TrakAtom->GetMediaTimeScale() : 0;
+ return m_TrakAtom?m_TrakAtom->GetMediaTimeScale():0;
}
/*----------------------------------------------------------------------
@@ -468,7 +443,7 @@ AP4_Track::GetMediaTimeScale()
AP4_UI64
AP4_Track::GetMediaDuration()
{
- return m_TrakAtom ? m_TrakAtom->GetMediaDuration() : 0;
+ return m_TrakAtom?m_TrakAtom->GetMediaDuration():0;
}
/*----------------------------------------------------------------------
@@ -477,8 +452,7 @@ AP4_Track::GetMediaDuration()
const AP4_String
AP4_Track::GetTrackName()
{
- if(AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, m_TrakAtom->FindChild("mdia/hdlr")))
- {
+ if (AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, m_TrakAtom->FindChild("mdia/hdlr"))) {
return hdlr->GetHandlerName();
}
return NULL;
@@ -490,8 +464,7 @@ AP4_Track::GetTrackName()
const AP4_String
AP4_Track::GetTrackLanguage()
{
- if(AP4_MdhdAtom* mdhd = AP4_DYNAMIC_CAST(AP4_MdhdAtom, m_TrakAtom->FindChild("mdia/mdhd")))
- {
+ if (AP4_MdhdAtom* mdhd = AP4_DYNAMIC_CAST(AP4_MdhdAtom, m_TrakAtom->FindChild("mdia/mdhd"))) {
return mdhd->GetLanguage();
}
return NULL;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.h
index 33836d607..12b48560c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Track.h
@@ -63,12 +63,10 @@ const AP4_UI32 AP4_TRACK_FLAG_IN_PREVIEW = 0x0004;
/*----------------------------------------------------------------------
| AP4_Track
+---------------------------------------------------------------------*/
-class AP4_Track
-{
-public:
+class AP4_Track {
+ public:
// types
- typedef enum
- {
+ typedef enum {
TYPE_UNKNOWN = 0,
TYPE_AUDIO = 1,
TYPE_VIDEO = 2,
@@ -77,15 +75,15 @@ public:
TYPE_TEXT = 5,
TYPE_JPEG = 6,
TYPE_RTP = 7,
- // ==> Start patch MPC
- TYPE_SUBP = 8
- // <== End patch MPC
+ // ==> Start patch MPC
+ TYPE_SUBP = 8
+ // <== End patch MPC
} Type;
// methods
AP4_Track(Type type,
AP4_SampleTable* sample_table, // ownership is transfered to the AP4_Track object
- AP4_UI32 track_id,
+ AP4_UI32 track_id,
AP4_UI32 movie_time_scale, // 0 = use default
AP4_UI64 track_duration, // in the movie timescale
AP4_UI32 media_time_scale,
@@ -93,24 +91,21 @@ public:
const char* language,
AP4_UI32 width, // in 16.16 fixed point
AP4_UI32 height); // in 16.16 fixed point
- AP4_Track(AP4_TrakAtom& atom,
+ AP4_Track(AP4_TrakAtom& atom,
AP4_ByteStream& sample_stream,
AP4_UI32 movie_time_scale);
virtual ~AP4_Track();
-
- /**
- * Clone a track. This is useful if you want to create a track from
- * a non-synthetic track (parsed from a file for example) and
+
+ /**
+ * Clone a track. This is useful if you want to create a track from
+ * a non-synthetic track (parsed from a file for example) and
* write it out
*/
AP4_Track* Clone(AP4_Result* result = NULL);
-
+
AP4_UI32 GetFlags();
AP4_Result SetFlags(AP4_UI32 flags);
- AP4_Track::Type GetType()
- {
- return m_Type;
- }
+ AP4_Track::Type GetType() { return m_Type; }
AP4_UI32 GetHandlerType();
AP4_UI64 GetDuration(); // in the timescale of the movie
AP4_UI32 GetDurationMs(); // in milliseconds
@@ -118,35 +113,26 @@ public:
AP4_UI32 GetHeight(); // in 16.16 fixed point
AP4_Cardinal GetSampleCount();
AP4_Result GetSample(AP4_Ordinal index, AP4_Sample& sample);
- AP4_Result ReadSample(AP4_Ordinal index,
+ AP4_Result ReadSample(AP4_Ordinal index,
AP4_Sample& sample,
AP4_DataBuffer& data);
- AP4_Result GetSampleIndexForTimeStampMs(AP4_UI32 ts_ms,
- AP4_Ordinal& index);
- AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal index, bool before = true);
+ AP4_Result GetSampleIndexForTimeStampMs(AP4_UI32 ts_ms,
+ AP4_Ordinal& index);
+ AP4_Ordinal GetNearestSyncSampleIndex(AP4_Ordinal index, bool before=true);
AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index);
- AP4_SampleTable* GetSampleTable()
- {
- return m_SampleTable;
- }
+ AP4_SampleTable* GetSampleTable() { return m_SampleTable; }
AP4_UI32 GetId();
AP4_Result SetId(AP4_UI32 track_id);
- AP4_TrakAtom* GetTrakAtom()
- {
- return m_TrakAtom;
- }
+ AP4_TrakAtom* GetTrakAtom() { return m_TrakAtom; }
AP4_Result SetMovieTimeScale(AP4_UI32 time_scale);
- AP4_UI32 GetMovieTimeScale()
- {
- return m_MovieTimeScale;
- }
+ AP4_UI32 GetMovieTimeScale() { return m_MovieTimeScale; }
AP4_UI32 GetMediaTimeScale();
AP4_UI64 GetMediaDuration(); // in the timescale of the media
const AP4_String GetTrackName();
const AP4_String GetTrackLanguage();
AP4_Result Attach(AP4_MoovAtom* moov);
-protected:
+ protected:
// members
AP4_TrakAtom* m_TrakAtom;
bool m_TrakAtomIsOwned;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.cpp
index b35a76284..57202f92e 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - trak Atoms
+| AP4 - trak Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -55,7 +55,7 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_TrakAtom)
+---------------------------------------------------------------------*/
AP4_TrakAtom::AP4_TrakAtom(AP4_SampleTable* sample_table,
AP4_Atom::Type hdlr_type,
- const char* hdlr_name,
+ const char* hdlr_name,
AP4_UI32 track_id,
AP4_UI32 creation_time,
AP4_UI32 modification_time,
@@ -71,12 +71,12 @@ AP4_TrakAtom::AP4_TrakAtom(AP4_SampleTable* sample_table,
AP4_Result result;
// create a tkhd atom
- m_TkhdAtom = new AP4_TkhdAtom(creation_time,
- modification_time,
+ m_TkhdAtom = new AP4_TkhdAtom(creation_time,
+ modification_time,
track_id,
- track_duration,
- volume,
- width,
+ track_duration,
+ volume,
+ width,
height);
// create an edts
@@ -87,24 +87,23 @@ AP4_TrakAtom::AP4_TrakAtom(AP4_SampleTable* sample_table,
// create a hdlr atom for the mdia atom
AP4_HdlrAtom* hdlr = new AP4_HdlrAtom(hdlr_type, hdlr_name);
- // create a minf atom
+ // create a minf atom
AP4_ContainerAtom* minf = new AP4_ContainerAtom(AP4_ATOM_TYPE_MINF);
// create a media header atom for minf (vmhd, smhd, hmhd or nmhd)
AP4_Atom* minf_header;
- switch(hdlr_type)
- {
- case AP4_HANDLER_TYPE_VIDE:
- minf_header = new AP4_VmhdAtom(0, 0, 0, 0);
- break;
-
- case AP4_HANDLER_TYPE_SOUN:
- minf_header = new AP4_SmhdAtom(0);
- break;
-
- default:
- minf_header = new AP4_NmhdAtom();
- break;
+ switch (hdlr_type) {
+ case AP4_HANDLER_TYPE_VIDE:
+ minf_header = new AP4_VmhdAtom(0, 0, 0, 0);
+ break;
+
+ case AP4_HANDLER_TYPE_SOUN:
+ minf_header = new AP4_SmhdAtom(0);
+ break;
+
+ default:
+ minf_header = new AP4_NmhdAtom();
+ break;
}
// create a dinf atom for minf
@@ -119,15 +118,15 @@ AP4_TrakAtom::AP4_TrakAtom(AP4_SampleTable* sample_table,
// create a stbl atom for minf
AP4_ContainerAtom* stbl;
result = sample_table->GenerateStblAtom(stbl);
- if(AP4_FAILED(result)) stbl = NULL;
-
+ if (AP4_FAILED(result)) stbl = NULL;
+
// populate the dinf atom
dinf->AddChild(dref);
// populate the minf atom
minf->AddChild(minf_header);
minf->AddChild(dinf);
- if(stbl) minf->AddChild(stbl);
+ if (stbl) minf->AddChild(stbl);
// create a mdhd atom for the mdia atom
m_MdhdAtom = new AP4_MdhdAtom(creation_time,
@@ -164,7 +163,7 @@ AP4_TrakAtom::AP4_TrakAtom(AP4_UI32 size,
AP4_UI32
AP4_TrakAtom::GetId()
{
- return m_TkhdAtom ? m_TkhdAtom->GetTrackId() : 0;
+ return m_TkhdAtom?m_TkhdAtom->GetTrackId():0;
}
/*----------------------------------------------------------------------
@@ -173,13 +172,10 @@ AP4_TrakAtom::GetId()
AP4_Result
AP4_TrakAtom::SetId(AP4_UI32 id)
{
- if(m_TkhdAtom)
- {
- m_TkhdAtom->SetTrackId(id);
+ if (m_TkhdAtom) {
+ m_TkhdAtom->SetTrackId(id);
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_STATE;
}
}
@@ -190,7 +186,7 @@ AP4_TrakAtom::SetId(AP4_UI32 id)
AP4_UI32
AP4_TrakAtom::GetMediaTimeScale()
{
- return m_MdhdAtom ? m_MdhdAtom->GetTimeScale() : 0;
+ return m_MdhdAtom?m_MdhdAtom->GetTimeScale():0;
}
/*----------------------------------------------------------------------
@@ -199,13 +195,10 @@ AP4_TrakAtom::GetMediaTimeScale()
AP4_Result
AP4_TrakAtom::SetMediaTimeScale(AP4_UI32 timescale)
{
- if(m_MdhdAtom)
- {
- m_MdhdAtom->SetTimeScale(timescale);
+ if (m_MdhdAtom) {
+ m_MdhdAtom->SetTimeScale(timescale);
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_STATE;
}
}
@@ -216,7 +209,7 @@ AP4_TrakAtom::SetMediaTimeScale(AP4_UI32 timescale)
AP4_UI64
AP4_TrakAtom::GetDuration()
{
- return m_TkhdAtom ? m_TkhdAtom->GetDuration() : 0;
+ return m_TkhdAtom?m_TkhdAtom->GetDuration():0;
}
/*----------------------------------------------------------------------
@@ -225,13 +218,10 @@ AP4_TrakAtom::GetDuration()
AP4_Result
AP4_TrakAtom::SetDuration(AP4_UI64 duration)
{
- if(m_TkhdAtom)
- {
+ if (m_TkhdAtom) {
m_TkhdAtom->SetDuration(duration);
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_STATE;
}
}
@@ -242,7 +232,7 @@ AP4_TrakAtom::SetDuration(AP4_UI64 duration)
AP4_UI64
AP4_TrakAtom::GetMediaDuration()
{
- return m_MdhdAtom ? m_MdhdAtom->GetDuration() : 0;
+ return m_MdhdAtom?m_MdhdAtom->GetDuration():0;
}
/*----------------------------------------------------------------------
@@ -251,13 +241,10 @@ AP4_TrakAtom::GetMediaDuration()
AP4_Result
AP4_TrakAtom::SetMediaDuration(AP4_UI32 duration)
{
- if(m_MdhdAtom)
- {
+ if (m_MdhdAtom) {
m_MdhdAtom->SetDuration(duration);
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_STATE;
}
}
@@ -268,7 +255,7 @@ AP4_TrakAtom::SetMediaDuration(AP4_UI32 duration)
AP4_UI32
AP4_TrakAtom::GetWidth()
{
- return m_TkhdAtom ? m_TkhdAtom->GetWidth() : 0;
+ return m_TkhdAtom?m_TkhdAtom->GetWidth():0;
}
/*----------------------------------------------------------------------
@@ -277,13 +264,10 @@ AP4_TrakAtom::GetWidth()
AP4_Result
AP4_TrakAtom::SetWidth(AP4_UI32 width)
{
- if(m_TkhdAtom)
- {
+ if (m_TkhdAtom) {
m_TkhdAtom->SetWidth(width);
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_STATE;
}
}
@@ -294,7 +278,7 @@ AP4_TrakAtom::SetWidth(AP4_UI32 width)
AP4_UI32
AP4_TrakAtom::GetHeight()
{
- return m_TkhdAtom ? m_TkhdAtom->GetHeight() : 0;
+ return m_TkhdAtom?m_TkhdAtom->GetHeight():0;
}
/*----------------------------------------------------------------------
@@ -303,13 +287,10 @@ AP4_TrakAtom::GetHeight()
AP4_Result
AP4_TrakAtom::SetHeight(AP4_UI32 height)
{
- if(m_TkhdAtom)
- {
+ if (m_TkhdAtom) {
m_TkhdAtom->SetHeight(height);
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_STATE;
}
}
@@ -317,22 +298,17 @@ AP4_TrakAtom::SetHeight(AP4_UI32 height)
/*----------------------------------------------------------------------
| AP4_TrakAtom::AdjustChunkOffsets
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_TrakAtom::AdjustChunkOffsets(AP4_SI64 delta)
{
AP4_Atom* atom;
- if((atom = FindChild("mdia/minf/stbl/stco")))
- {
+ if ((atom = FindChild("mdia/minf/stbl/stco"))) {
AP4_StcoAtom* stco = AP4_DYNAMIC_CAST(AP4_StcoAtom, atom);
return stco->AdjustChunkOffsets((int)delta);
- }
- else if((atom = FindChild("mdia/minf/stbl/co64")))
- {
+ } else if ((atom = FindChild("mdia/minf/stbl/co64"))) {
AP4_Co64Atom* co64 = AP4_DYNAMIC_CAST(AP4_Co64Atom, atom);
return co64->AdjustChunkOffsets(delta);
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_STATE;
}
}
@@ -344,34 +320,27 @@ AP4_Result
AP4_TrakAtom::GetChunkOffsets(AP4_Array<AP4_UI64>& chunk_offsets)
{
AP4_Atom* atom;
- if((atom = FindChild("mdia/minf/stbl/stco")))
- {
+ if ((atom = FindChild("mdia/minf/stbl/stco"))) {
AP4_StcoAtom* stco = AP4_DYNAMIC_CAST(AP4_StcoAtom, atom);
- if(stco == NULL) return AP4_ERROR_INTERNAL;
+ if (stco == NULL) return AP4_ERROR_INTERNAL;
AP4_Cardinal stco_chunk_count = stco->GetChunkCount();
const AP4_UI32* stco_chunk_offsets = stco->GetChunkOffsets();
chunk_offsets.SetItemCount(stco_chunk_count);
- for(unsigned int i = 0; i < stco_chunk_count; i++)
- {
+ for (unsigned int i=0; i<stco_chunk_count; i++) {
chunk_offsets[i] = stco_chunk_offsets[i];
}
return AP4_SUCCESS;
- }
- else if((atom = FindChild("mdia/minf/stbl/co64")))
- {
+ } else if ((atom = FindChild("mdia/minf/stbl/co64"))) {
AP4_Co64Atom* co64 = AP4_DYNAMIC_CAST(AP4_Co64Atom, atom);
- if(co64 == NULL) return AP4_ERROR_INTERNAL;
+ if (co64 == NULL) return AP4_ERROR_INTERNAL;
AP4_Cardinal co64_chunk_count = co64->GetChunkCount();
const AP4_UI64* co64_chunk_offsets = co64->GetChunkOffsets();
chunk_offsets.SetItemCount(co64_chunk_count);
- for(unsigned int i = 0; i < co64_chunk_count; i++)
- {
+ for (unsigned int i=0; i<co64_chunk_count; i++) {
chunk_offsets[i] = co64_chunk_offsets[i];
}
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_STATE;
}
}
@@ -383,40 +352,31 @@ AP4_Result
AP4_TrakAtom::SetChunkOffsets(const AP4_Array<AP4_UI64>& chunk_offsets)
{
AP4_Atom* atom;
- if((atom = FindChild("mdia/minf/stbl/stco")))
- {
+ if ((atom = FindChild("mdia/minf/stbl/stco"))) {
AP4_StcoAtom* stco = AP4_DYNAMIC_CAST(AP4_StcoAtom, atom);
- if(stco == NULL) return AP4_ERROR_INTERNAL;
+ if (stco == NULL) return AP4_ERROR_INTERNAL;
AP4_Cardinal stco_chunk_count = stco->GetChunkCount();
AP4_UI32* stco_chunk_offsets = stco->GetChunkOffsets();
- if(stco_chunk_count > chunk_offsets.ItemCount())
- {
+ if (stco_chunk_count > chunk_offsets.ItemCount()) {
return AP4_ERROR_OUT_OF_RANGE;
}
- for(unsigned int i = 0; i < stco_chunk_count; i++)
- {
+ for (unsigned int i=0; i<stco_chunk_count; i++) {
stco_chunk_offsets[i] = (AP4_UI32)chunk_offsets[i];
}
return AP4_SUCCESS;
- }
- else if((atom = FindChild("mdia/minf/stbl/co64")))
- {
+ } else if ((atom = FindChild("mdia/minf/stbl/co64"))) {
AP4_Co64Atom* co64 = AP4_DYNAMIC_CAST(AP4_Co64Atom, atom);
- if(co64 == NULL) return AP4_ERROR_INTERNAL;
+ if (co64 == NULL) return AP4_ERROR_INTERNAL;
AP4_Cardinal co64_chunk_count = co64->GetChunkCount();
AP4_UI64* co64_chunk_offsets = co64->GetChunkOffsets();
- if(co64_chunk_count > chunk_offsets.ItemCount())
- {
+ if (co64_chunk_count > chunk_offsets.ItemCount()) {
return AP4_ERROR_OUT_OF_RANGE;
}
- for(unsigned int i = 0; i < co64_chunk_count; i++)
- {
+ for (unsigned int i=0; i<co64_chunk_count; i++) {
co64_chunk_offsets[i] = chunk_offsets[i];
}
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_ERROR_INVALID_STATE;
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.h
index 8aa57336f..8006375ee 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrakAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - trak Atoms
+| AP4 - trak Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -48,14 +48,13 @@ class AP4_SampleTable;
+---------------------------------------------------------------------*/
class AP4_TrakAtom : public AP4_ContainerAtom
{
-public:
+ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_TrakAtom, AP4_ContainerAtom)
// class methods
- static AP4_TrakAtom* Create(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory)
- {
+ static AP4_TrakAtom* Create(AP4_Size size,
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) {
return new AP4_TrakAtom(size, stream, atom_factory);
}
@@ -63,7 +62,7 @@ public:
AP4_TrakAtom(AP4_SampleTable* sample_table,
AP4_Atom::Type hdlr_type,
const char* hdlr_name,
- AP4_UI32 track_id,
+ AP4_UI32 track_id,
AP4_UI32 creation_time,
AP4_UI32 modification_time,
AP4_UI64 track_duration,
@@ -73,10 +72,7 @@ public:
const char* language,
AP4_UI32 width,
AP4_UI32 heigh);
- AP4_TkhdAtom* GetTkhdAtom()
- {
- return m_TkhdAtom;
- }
+ AP4_TkhdAtom* GetTkhdAtom() { return m_TkhdAtom; }
AP4_Result AdjustChunkOffsets(AP4_SI64 delta);
AP4_Result GetChunkOffsets(AP4_Array<AP4_UI64>& chunk_offsets);
AP4_Result SetChunkOffsets(const AP4_Array<AP4_UI64>& chunk_offsets);
@@ -92,8 +88,8 @@ public:
AP4_Result SetWidth(AP4_UI32 width);
AP4_UI32 GetHeight();
AP4_Result SetHeight(AP4_UI32 height);
-
-private:
+
+ private:
// methods
AP4_TrakAtom(AP4_UI32 size,
AP4_ByteStream& stream,
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.cpp
index aa97f3d45..bac78fd4c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tref type Atoms
+| AP4 - tref type Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -47,16 +47,15 @@ AP4_TrefTypeAtom::AP4_TrefTypeAtom(AP4_Atom::Type type) :
/*----------------------------------------------------------------------
| AP4_TrefTypeAtom::AP4_TrefTypeAtom
+---------------------------------------------------------------------*/
-AP4_TrefTypeAtom::AP4_TrefTypeAtom(AP4_Atom::Type type,
- AP4_UI32 size,
+AP4_TrefTypeAtom::AP4_TrefTypeAtom(AP4_Atom::Type type,
+ AP4_UI32 size,
AP4_ByteStream& stream) :
AP4_Atom(type, size)
{
AP4_Size data_size = size - 8; // size and atom type
-
+
// read the track ids
- while(data_size >= 4)
- {
+ while (data_size >= 4) {
AP4_UI32 track_id;
stream.ReadUI32(track_id);
m_TrackIds.Append(track_id);
@@ -71,8 +70,7 @@ AP4_Result
AP4_TrefTypeAtom::AddTrackId(AP4_UI32 track_id)
{
AP4_Result result = m_TrackIds.Append(track_id);
- if(AP4_SUCCEEDED(result))
- {
+ if (AP4_SUCCEEDED(result)) {
m_Size32 += 4;
}
return result;
@@ -87,10 +85,9 @@ AP4_TrefTypeAtom::WriteFields(AP4_ByteStream& stream)
AP4_Result result = AP4_SUCCESS;
AP4_Size track_id_count = m_TrackIds.ItemCount();
- for(AP4_Ordinal i = 0; i < track_id_count; i++)
- {
+ for (AP4_Ordinal i=0; i<track_id_count; i++) {
result = stream.WriteUI32(m_TrackIds[i]);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return AP4_SUCCESS;
@@ -103,9 +100,8 @@ AP4_Result
AP4_TrefTypeAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("track_id_count", m_TrackIds.ItemCount());
- for(AP4_Ordinal i = 0; i < m_TrackIds.ItemCount(); i++)
- {
- inspector.AddField("track id ", m_TrackIds[i]);
+ for (AP4_Ordinal i=0; i<m_TrackIds.ItemCount(); i++) {
+ inspector.AddField("track id ", m_TrackIds[i]);
}
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.h
index 129e03250..438f03f53 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrefTypeAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - tref type Atoms
+| AP4 - tref type Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -44,27 +44,23 @@ public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_TrefTypeAtom, AP4_Atom)
// class methods
- static AP4_TrefTypeAtom* Create(AP4_Atom::Type type,
- AP4_UI32 size,
- AP4_ByteStream& stream)
- {
+ static AP4_TrefTypeAtom* Create(AP4_Atom::Type type,
+ AP4_UI32 size,
+ AP4_ByteStream& stream) {
return new AP4_TrefTypeAtom(type, size, stream);
}
// contructor
AP4_TrefTypeAtom(AP4_Atom::Type type);
-
+
// methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
AP4_Result AddTrackId(AP4_UI32 track_id);
// accessors
- const AP4_Array<AP4_UI32>& GetTrackIds()
- {
- return m_TrackIds;
- }
-
+ const AP4_Array<AP4_UI32>& GetTrackIds() { return m_TrackIds; }
+
private:
// methods
AP4_TrefTypeAtom(AP4_Atom::Type type, AP4_UI32 size, AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.cpp
index 7e0a8effc..6745e764a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - trex Atoms
+| AP4 - trex Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -46,8 +46,8 @@ AP4_TrexAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_TrexAtom(size, version, flags, stream);
}
@@ -59,7 +59,7 @@ AP4_TrexAtom::AP4_TrexAtom(AP4_UI32 track_id,
AP4_UI32 default_sample_duration,
AP4_UI32 default_sample_size,
AP4_UI32 default_sample_flags) :
- AP4_Atom(AP4_ATOM_TYPE_TREX, AP4_FULL_ATOM_HEADER_SIZE + 20, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_TREX, AP4_FULL_ATOM_HEADER_SIZE+20, 0, 0),
m_TrackId(track_id),
m_DefaultSampleDescriptionIndex(default_sample_description_index),
m_DefaultSampleDuration(default_sample_duration),
@@ -71,7 +71,7 @@ AP4_TrexAtom::AP4_TrexAtom(AP4_UI32 track_id,
/*----------------------------------------------------------------------
| AP4_TrexAtom::AP4_TrexAtom
+---------------------------------------------------------------------*/
-AP4_TrexAtom::AP4_TrexAtom(AP4_UI32 size,
+AP4_TrexAtom::AP4_TrexAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.h
index a8b19126f..42cf1fa2d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrexAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - trex Atoms
+| AP4 - trex Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -61,40 +61,25 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- AP4_UI32 GetTrackId()
- {
- return m_TrackId;
- }
- AP4_UI32 GetDefaultSampleDescriptionIndex()
- {
- return m_DefaultSampleDescriptionIndex;
- }
- AP4_UI32 GetDefaultSampleDuration()
- {
- return m_DefaultSampleDuration;
- }
- AP4_UI32 GetDefaultSampleSize()
- {
- return m_DefaultSampleSize;
- }
- AP4_UI32 GetDefaultSampleFlags()
- {
- return m_DefaultSampleFlags;
- }
+ AP4_UI32 GetTrackId() { return m_TrackId; }
+ AP4_UI32 GetDefaultSampleDescriptionIndex() { return m_DefaultSampleDescriptionIndex; }
+ AP4_UI32 GetDefaultSampleDuration() { return m_DefaultSampleDuration; }
+ AP4_UI32 GetDefaultSampleSize() { return m_DefaultSampleSize; }
+ AP4_UI32 GetDefaultSampleFlags() { return m_DefaultSampleFlags; }
private:
// methods
- AP4_TrexAtom(AP4_UI32 size,
+ AP4_TrexAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
- AP4_ByteStream& stream);
+ AP4_ByteStream& stream);
// members
- AP4_UI32 m_TrackId;
- AP4_UI32 m_DefaultSampleDescriptionIndex;
- AP4_UI32 m_DefaultSampleDuration;
- AP4_UI32 m_DefaultSampleSize;
- AP4_UI32 m_DefaultSampleFlags;
+ AP4_UI32 m_TrackId;
+ AP4_UI32 m_DefaultSampleDescriptionIndex;
+ AP4_UI32 m_DefaultSampleDuration;
+ AP4_UI32 m_DefaultSampleSize;
+ AP4_UI32 m_DefaultSampleFlags;
};
#endif // _AP4_TREX_ATOM_H_
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.cpp
index 56ee52726..e7d4ffc71 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - trun Atoms
+| AP4 - trun Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -45,22 +45,21 @@ AP4_TrunAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version > 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version > 0) return NULL;
return new AP4_TrunAtom(size, version, flags, stream);
}
/*----------------------------------------------------------------------
| AP4_TrunAtom::ComputeRecordFieldsCount
+---------------------------------------------------------------------*/
-unsigned int
+unsigned int
AP4_TrunAtom::ComputeRecordFieldsCount(AP4_UI32 flags)
{
// count the number of bits set to 1 in the second byte of the flags
unsigned int count = 0;
- for(unsigned int i = 0; i < 8; i++)
- {
- if(flags & (1 << (i + 8))) ++count;
+ for (unsigned int i=0; i<8; i++) {
+ if (flags & (1<<(i+8))) ++count;
}
return count;
}
@@ -68,14 +67,13 @@ AP4_TrunAtom::ComputeRecordFieldsCount(AP4_UI32 flags)
/*----------------------------------------------------------------------
| AP4_TrunAtom::ComputeOptionalFieldsCount
+---------------------------------------------------------------------*/
-unsigned int
+unsigned int
AP4_TrunAtom::ComputeOptionalFieldsCount(AP4_UI32 flags)
{
// count the number of bits set to 1 in the LSB of the flags
unsigned int count = 0;
- for(unsigned int i = 0; i < 8; i++)
- {
- if(flags & (1 << i)) ++count;
+ for (unsigned int i=0; i<8; i++) {
+ if (flags & (1<<i)) ++count;
}
return count;
}
@@ -83,20 +81,20 @@ AP4_TrunAtom::ComputeOptionalFieldsCount(AP4_UI32 flags)
/*----------------------------------------------------------------------
| AP4_TrunAtom::AP4_TrunAtom
+---------------------------------------------------------------------*/
-AP4_TrunAtom::AP4_TrunAtom(AP4_UI32 flags,
+AP4_TrunAtom::AP4_TrunAtom(AP4_UI32 flags,
AP4_SI32 data_offset,
AP4_UI32 first_sample_flags) :
- AP4_Atom(AP4_ATOM_TYPE_TRUN, AP4_FULL_ATOM_HEADER_SIZE + 4, 0, flags),
+ AP4_Atom(AP4_ATOM_TYPE_TRUN, AP4_FULL_ATOM_HEADER_SIZE+4, 0, flags),
m_DataOffset(data_offset),
m_FirstSampleFlags(first_sample_flags)
{
- m_Size32 += 4 * ComputeOptionalFieldsCount(flags);
+ m_Size32 += 4*ComputeOptionalFieldsCount(flags);
}
/*----------------------------------------------------------------------
| AP4_TrunAtom::AP4_TrunAtom
+---------------------------------------------------------------------*/
-AP4_TrunAtom::AP4_TrunAtom(AP4_UI32 size,
+AP4_TrunAtom::AP4_TrunAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -107,54 +105,45 @@ AP4_TrunAtom::AP4_TrunAtom(AP4_UI32 size,
// read optional fields
int optional_fields_count = (int)ComputeOptionalFieldsCount(flags);
- if(flags & AP4_TRUN_FLAG_DATA_OFFSET_PRESENT)
- {
+ if (flags & AP4_TRUN_FLAG_DATA_OFFSET_PRESENT) {
AP4_UI32 offset = 0;
stream.ReadUI32(offset);
m_DataOffset = (AP4_SI32)offset;
--optional_fields_count;
}
- if(flags & AP4_TRUN_FLAG_FIRST_SAMPLE_FLAGS_PRESENT)
- {
+ if (flags & AP4_TRUN_FLAG_FIRST_SAMPLE_FLAGS_PRESENT) {
stream.ReadUI32(m_FirstSampleFlags);
--optional_fields_count;
}
-
- // discard unknown optional fields
- for(int i = 0; i < optional_fields_count; i++)
- {
+
+ // discard unknown optional fields
+ for (int i=0; i<optional_fields_count; i++) {
AP4_UI32 discard;
stream.ReadUI32(discard);
}
-
+
int record_fields_count = (int)ComputeRecordFieldsCount(flags);
m_Entries.SetItemCount(sample_count);
- for(unsigned int i = 0; i < sample_count; i++)
- {
- if(flags & AP4_TRUN_FLAG_SAMPLE_DURATION_PRESENT)
- {
+ for (unsigned int i=0; i<sample_count; i++) {
+ if (flags & AP4_TRUN_FLAG_SAMPLE_DURATION_PRESENT) {
stream.ReadUI32(m_Entries[i].sample_duration);
--record_fields_count;
}
- if(flags & AP4_TRUN_FLAG_SAMPLE_SIZE_PRESENT)
- {
+ if (flags & AP4_TRUN_FLAG_SAMPLE_SIZE_PRESENT) {
stream.ReadUI32(m_Entries[i].sample_size);
--record_fields_count;
}
- if(flags & AP4_TRUN_FLAG_SAMPLE_FLAGS_PRESENT)
- {
+ if (flags & AP4_TRUN_FLAG_SAMPLE_FLAGS_PRESENT) {
stream.ReadUI32(m_Entries[i].sample_flags);
--record_fields_count;
}
- if(flags & AP4_TRUN_FLAG_SAMPLE_COMPOSITION_TIME_OFFSET_PRESENT)
- {
+ if (flags & AP4_TRUN_FLAG_SAMPLE_COMPOSITION_TIME_OFFSET_PRESENT) {
stream.ReadUI32(m_Entries[i].sample_composition_time_offset);
--record_fields_count;
}
-
- // skip unknown fields
- for(int j = 0; j < record_fields_count; j++)
- {
+
+ // skip unknown fields
+ for (int j=0;j<record_fields_count; j++) {
AP4_UI32 discard;
stream.ReadUI32(discard);
}
@@ -168,44 +157,37 @@ AP4_Result
AP4_TrunAtom::WriteFields(AP4_ByteStream& stream)
{
AP4_Result result;
-
+
result = stream.WriteUI32(m_Entries.ItemCount());
- if(AP4_FAILED(result)) return result;
- if(m_Flags & AP4_TRUN_FLAG_DATA_OFFSET_PRESENT)
- {
+ if (AP4_FAILED(result)) return result;
+ if (m_Flags & AP4_TRUN_FLAG_DATA_OFFSET_PRESENT) {
result = stream.WriteUI32((AP4_UI32)m_DataOffset);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_TRUN_FLAG_FIRST_SAMPLE_FLAGS_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_FIRST_SAMPLE_FLAGS_PRESENT) {
result = stream.WriteUI32(m_FirstSampleFlags);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
AP4_UI32 sample_count = m_Entries.ItemCount();
- for(unsigned int i = 0; i < sample_count; i++)
- {
- if(m_Flags & AP4_TRUN_FLAG_SAMPLE_DURATION_PRESENT)
- {
+ for (unsigned int i=0; i<sample_count; i++) {
+ if (m_Flags & AP4_TRUN_FLAG_SAMPLE_DURATION_PRESENT) {
result = stream.WriteUI32(m_Entries[i].sample_duration);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_TRUN_FLAG_SAMPLE_SIZE_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_SAMPLE_SIZE_PRESENT) {
result = stream.WriteUI32(m_Entries[i].sample_size);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_TRUN_FLAG_SAMPLE_FLAGS_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_SAMPLE_FLAGS_PRESENT) {
result = stream.WriteUI32(m_Entries[i].sample_flags);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- if(m_Flags & AP4_TRUN_FLAG_SAMPLE_COMPOSITION_TIME_OFFSET_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_SAMPLE_COMPOSITION_TIME_OFFSET_PRESENT) {
stream.WriteUI32(m_Entries[i].sample_composition_time_offset);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
}
-
+
return AP4_SUCCESS;
}
@@ -216,19 +198,15 @@ AP4_Result
AP4_TrunAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("sample count", m_Entries.ItemCount());
- if(m_Flags & AP4_TRUN_FLAG_DATA_OFFSET_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_DATA_OFFSET_PRESENT) {
inspector.AddField("data offset", m_DataOffset);
}
- if(m_Flags & AP4_TRUN_FLAG_FIRST_SAMPLE_FLAGS_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_FIRST_SAMPLE_FLAGS_PRESENT) {
inspector.AddField("first sample flags", m_FirstSampleFlags, AP4_AtomInspector::HINT_HEX);
}
- if(inspector.GetVerbosity() >= 1)
- {
- AP4_UI32 sample_count = m_Entries.ItemCount();
- for(unsigned int i = 0; i < sample_count; i++)
- {
+ if (inspector.GetVerbosity() >= 1) {
+ AP4_UI32 sample_count = m_Entries.ItemCount();
+ for (unsigned int i=0; i<sample_count; i++) {
char header[32];
AP4_FormatString(header, sizeof(header), "entry %04d", i);
char v0[32];
@@ -239,23 +217,19 @@ AP4_TrunAtom::InspectFields(AP4_AtomInspector& inspector)
const char* s1 = "";
const char* s2 = "";
const char* s3 = "";
- if(m_Flags & AP4_TRUN_FLAG_SAMPLE_DURATION_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_SAMPLE_DURATION_PRESENT) {
AP4_FormatString(v0, sizeof(v0), "sample duration:%d", m_Entries[i].sample_duration);
s0 = v0;
}
- if(m_Flags & AP4_TRUN_FLAG_SAMPLE_SIZE_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_SAMPLE_SIZE_PRESENT) {
AP4_FormatString(v1, sizeof(v1), "sample size:%d", m_Entries[i].sample_size);
s1 = v1;
}
- if(m_Flags & AP4_TRUN_FLAG_SAMPLE_FLAGS_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_SAMPLE_FLAGS_PRESENT) {
AP4_FormatString(v2, sizeof(v2), "sample flags:%x", m_Entries[i].sample_flags);
s2 = v2;
}
- if(m_Flags & AP4_TRUN_FLAG_SAMPLE_COMPOSITION_TIME_OFFSET_PRESENT)
- {
+ if (m_Flags & AP4_TRUN_FLAG_SAMPLE_COMPOSITION_TIME_OFFSET_PRESENT) {
AP4_FormatString(v3, sizeof(v3), "sample composition time offset:%d", m_Entries[i].sample_composition_time_offset);
s3 = v3;
}
@@ -264,6 +238,6 @@ AP4_TrunAtom::InspectFields(AP4_AtomInspector& inspector)
inspector.AddField(header, value);
}
}
-
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.h
index fe4c43700..9bdc382b3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4TrunAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - trun Atoms
+| AP4 - trun Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -54,44 +54,34 @@ public:
AP4_IMPLEMENT_DYNAMIC_CAST(AP4_TrunAtom)
// types
- struct Entry
- {
+ struct Entry {
Entry() : sample_duration(0), sample_size(0), sample_flags(0), sample_composition_time_offset(0) {}
AP4_UI32 sample_duration;
AP4_UI32 sample_size;
AP4_UI32 sample_flags;
AP4_UI32 sample_composition_time_offset;
};
-
+
// class methods
static AP4_TrunAtom* Create(AP4_Size size, AP4_ByteStream& stream);
static unsigned int ComputeOptionalFieldsCount(AP4_UI32 flags);
static unsigned int ComputeRecordFieldsCount(AP4_UI32 flags);
// methods
- AP4_TrunAtom(AP4_UI32 flags,
+ AP4_TrunAtom(AP4_UI32 flags,
AP4_SI32 data_offset,
AP4_UI32 first_sample_flags);
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- AP4_SI32 GetDataOffset()
- {
- return m_DataOffset;
- }
- AP4_UI32 GetFirstSampleFlags()
- {
- return m_FirstSampleFlags;
- }
- const AP4_Array<Entry>& GetEntries()
- {
- return m_Entries;
- }
-
+ AP4_SI32 GetDataOffset() { return m_DataOffset; }
+ AP4_UI32 GetFirstSampleFlags() { return m_FirstSampleFlags; }
+ const AP4_Array<Entry>& GetEntries() { return m_Entries; }
+
private:
// methods
- AP4_TrunAtom(AP4_UI32 size,
+ AP4_TrunAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Types.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Types.h
index 0d42b8043..86409c337 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Types.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Types.h
@@ -52,22 +52,21 @@ typedef unsigned long AP4_Size;
// the rest depends on whether the platform supports 64-bit integers
#if defined(AP4_CONFIG_HAVE_INT64)
-// we have 64-bit integers
-typedef AP4_CONFIG_INT64_TYPE AP4_SI64;
-typedef unsigned AP4_CONFIG_INT64_TYPE AP4_UI64;
-typedef unsigned AP4_CONFIG_INT64_TYPE AP4_LargeSize;
-typedef AP4_CONFIG_INT64_TYPE AP4_Offset;
-typedef unsigned AP4_CONFIG_INT64_TYPE AP4_Position;
+ // we have 64-bit integers
+ typedef AP4_CONFIG_INT64_TYPE AP4_SI64;
+ typedef unsigned AP4_CONFIG_INT64_TYPE AP4_UI64;
+ typedef unsigned AP4_CONFIG_INT64_TYPE AP4_LargeSize;
+ typedef AP4_CONFIG_INT64_TYPE AP4_Offset;
+ typedef unsigned AP4_CONFIG_INT64_TYPE AP4_Position;
#else
-// use only 32-bit integers
-typedef struct
-{
- AP4_UI32 hi;
- AP4_UI32 lo;
-} AP4_UI64, AP4_SI64;
-typedef unsigned long AP4_LargeSize;
-typedef long AP4_Offset;
-typedef unsigned long AP4_Position;
+ // use only 32-bit integers
+ typedef struct {
+ AP4_UI32 hi;
+ AP4_UI32 lo;
+ } AP4_UI64, AP4_SI64;
+ typedef unsigned long AP4_LargeSize;
+ typedef long AP4_Offset;
+ typedef unsigned long AP4_Position;
#endif
#ifndef NULL
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.cpp
index 0989e8d58..8659d9837 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - url Atoms
+| AP4 - url Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -41,8 +41,8 @@ AP4_UrlAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_UrlAtom(size, version, flags, stream);
}
@@ -57,18 +57,16 @@ AP4_UrlAtom::AP4_UrlAtom() :
/*----------------------------------------------------------------------
| AP4_UrlAtom::AP4_UrlAtom
+---------------------------------------------------------------------*/
-AP4_UrlAtom::AP4_UrlAtom(AP4_UI32 size,
+AP4_UrlAtom::AP4_UrlAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_URL, size, version, flags)
{
- if((m_Flags & 1) == 0)
- {
+ if ((m_Flags & 1) == 0) {
// not self contained
- AP4_Size str_size = size - AP4_FULL_ATOM_HEADER_SIZE;
- if(str_size > 0)
- {
+ AP4_Size str_size = size-AP4_FULL_ATOM_HEADER_SIZE;
+ if (str_size > 0) {
char* str = new char[str_size];
stream.Read(str, str_size);
str[str_size-1] = '\0'; // force null-termination
@@ -84,22 +82,18 @@ AP4_UrlAtom::AP4_UrlAtom(AP4_UI32 size,
AP4_Result
AP4_UrlAtom::WriteFields(AP4_ByteStream& stream)
{
- if(m_Flags & 1)
- {
+ if (m_Flags & 1) {
// local ref (self contained)
return AP4_SUCCESS;
- }
- else
- {
+ } else {
// url (not self contained)
- if(m_Size32 > AP4_FULL_ATOM_HEADER_SIZE)
- {
- AP4_Result result = stream.Write(m_Url.GetChars(), m_Url.GetLength() + 1);
- if(AP4_FAILED(result)) return result;
+ if (m_Size32 > AP4_FULL_ATOM_HEADER_SIZE) {
+ AP4_Result result = stream.Write(m_Url.GetChars(), m_Url.GetLength()+1);
+ if (AP4_FAILED(result)) return result;
// pad with zeros if necessary
- AP4_Size padding = m_Size32 - (AP4_FULL_ATOM_HEADER_SIZE + m_Url.GetLength() + 1);
- while(padding--) stream.WriteUI08(0);
+ AP4_Size padding = m_Size32-(AP4_FULL_ATOM_HEADER_SIZE+m_Url.GetLength()+1);
+ while (padding--) stream.WriteUI08(0);
}
return AP4_SUCCESS;
}
@@ -111,12 +105,9 @@ AP4_UrlAtom::WriteFields(AP4_ByteStream& stream)
AP4_Result
AP4_UrlAtom::InspectFields(AP4_AtomInspector& inspector)
{
- if(m_Flags & 1)
- {
+ if (m_Flags & 1) {
inspector.AddField("location", "[local to file]");
- }
- else
- {
+ } else {
inspector.AddField("location", m_Url.GetChars());
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.h
index 001dc8ef6..3e354f70c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UrlAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - url Atoms
+| AP4 - url Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -51,7 +51,7 @@ public:
private:
// methods
- AP4_UrlAtom(AP4_UI32 size,
+ AP4_UrlAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.cpp
index b7a8d81dd..ef7834a3c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.cpp
@@ -40,7 +40,7 @@ AP4_BytesToDoubleBE(const unsigned char* bytes)
AP4_UI64 i_value = AP4_BytesToUInt64BE(bytes);
void* v_value = reinterpret_cast<void*>(&i_value);
double* d_value = reinterpret_cast<double*>(v_value);
-
+
return *d_value;
}
@@ -50,15 +50,15 @@ AP4_BytesToDoubleBE(const unsigned char* bytes)
AP4_UI64
AP4_BytesToUInt64BE(const unsigned char* bytes)
{
- return
- (((AP4_UI64)bytes[0]) << 56) |
- (((AP4_UI64)bytes[1]) << 48) |
- (((AP4_UI64)bytes[2]) << 40) |
- (((AP4_UI64)bytes[3]) << 32) |
- (((AP4_UI64)bytes[4]) << 24) |
- (((AP4_UI64)bytes[5]) << 16) |
- (((AP4_UI64)bytes[6]) << 8) |
- (((AP4_UI64)bytes[7]));
+ return
+ ( ((AP4_UI64)bytes[0])<<56 ) |
+ ( ((AP4_UI64)bytes[1])<<48 ) |
+ ( ((AP4_UI64)bytes[2])<<40 ) |
+ ( ((AP4_UI64)bytes[3])<<32 ) |
+ ( ((AP4_UI64)bytes[4])<<24 ) |
+ ( ((AP4_UI64)bytes[5])<<16 ) |
+ ( ((AP4_UI64)bytes[6])<<8 ) |
+ ( ((AP4_UI64)bytes[7]) );
}
/*----------------------------------------------------------------------
@@ -69,7 +69,7 @@ AP4_BytesFromDoubleBE(unsigned char* bytes, double value)
{
void* v_value = reinterpret_cast<void*>(&value);
AP4_UI64* i_value = reinterpret_cast<AP4_UI64*>(v_value);
-
+
AP4_BytesFromUInt64BE(bytes, *i_value);
}
@@ -86,7 +86,7 @@ AP4_BytesFromUInt64BE(unsigned char* bytes, AP4_UI64 value)
bytes[4] = (unsigned char)(value >> 24);
bytes[5] = (unsigned char)(value >> 16);
bytes[6] = (unsigned char)(value >> 8);
- bytes[7] = (unsigned char)(value);
+ bytes[7] = (unsigned char)(value );
}
/*----------------------------------------------------------------------
@@ -95,33 +95,32 @@ AP4_BytesFromUInt64BE(unsigned char* bytes, AP4_UI64 value)
AP4_UI32
AP4_DurationMsFromUnits(AP4_UI64 units, AP4_UI32 units_per_second)
{
- if(units_per_second == 0) return 0;
- return (AP4_UI32)(((double)units * 1000.0) / (double)units_per_second);
+ if (units_per_second == 0) return 0;
+ return (AP4_UI32)(((double)units*1000.0)/(double)units_per_second);
}
/*----------------------------------------------------------------------
| AP4_ConvertTime
+---------------------------------------------------------------------*/
-AP4_UI64
+AP4_UI64
AP4_ConvertTime(AP4_UI64 time_value,
AP4_UI32 from_time_scale,
AP4_UI32 to_time_scale)
{
- if(from_time_scale == 0) return 0;
- double ratio = (double)to_time_scale / (double)from_time_scale;
- return ((AP4_UI64)((double)time_value * ratio));
+ if (from_time_scale == 0) return 0;
+ double ratio = (double)to_time_scale/(double)from_time_scale;
+ return ((AP4_UI64)((double)time_value*ratio));
}
/*----------------------------------------------------------------------
| AP4_FormatFourChars
+---------------------------------------------------------------------*/
void
-AP4_FormatFourChars(char* str, AP4_UI32 value)
-{
+AP4_FormatFourChars(char* str, AP4_UI32 value) {
str[0] = (value >> 24) & 0xFF;
str[1] = (value >> 16) & 0xFF;
str[2] = (value >> 8) & 0xFF;
- str[3] = (value) & 0xFF;
+ str[3] = (value ) & 0xFF;
str[4] = '\0';
}
@@ -129,13 +128,10 @@ AP4_FormatFourChars(char* str, AP4_UI32 value)
| AP4_FormatFourCharsPrintable
+---------------------------------------------------------------------*/
void
-AP4_FormatFourCharsPrintable(char* str, AP4_UI32 value)
-{
+AP4_FormatFourCharsPrintable(char* str, AP4_UI32 value) {
AP4_FormatFourChars(str, value);
- for(int i = 0; i < 4; i++)
- {
- if(str[i] < ' ' || str[i] >= 127)
- {
+ for (int i=0; i<4; i++) {
+ if (str[i]<' ' || str[i] >= 127) {
str[i] = '.';
}
}
@@ -149,18 +145,14 @@ AP4_SplitArgs(char* arg, char*& arg0, char*& arg1)
{
arg0 = arg;
char* c = arg;
- while(*c != 0 && *c != ':')
- {
+ while (*c != 0 && *c != ':') {
c++;
}
- if(*c == ':')
- {
+ if (*c == ':') {
*c++ = '\0';
arg1 = c;
return AP4_SUCCESS;
- }
- else
- {
+ } else {
return AP4_FAILURE;
}
}
@@ -172,7 +164,7 @@ AP4_Result
AP4_SplitArgs(char* arg, char*& arg0, char*& arg1, char*& arg2)
{
AP4_Result result = AP4_SplitArgs(arg, arg0, arg1);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return AP4_SplitArgs(arg1, arg1, arg2);
}
@@ -182,48 +174,24 @@ AP4_SplitArgs(char* arg, char*& arg0, char*& arg1, char*& arg2)
unsigned char
AP4_HexNibble(char c)
{
- switch(c)
- {
- case '0':
- return 0;
- case '1':
- return 1;
- case '2':
- return 2;
- case '3':
- return 3;
- case '4':
- return 4;
- case '5':
- return 5;
- case '6':
- return 6;
- case '7':
- return 7;
- case '8':
- return 8;
- case '9':
- return 9;
- case 'a':
- case 'A':
- return 10;
- case 'b':
- case 'B':
- return 11;
- case 'c':
- case 'C':
- return 12;
- case 'd':
- case 'D':
- return 13;
- case 'e':
- case 'E':
- return 14;
- case 'f':
- case 'F':
- return 15;
- default:
- return 0;
+ switch (c) {
+ case '0': return 0;
+ case '1': return 1;
+ case '2': return 2;
+ case '3': return 3;
+ case '4': return 4;
+ case '5': return 5;
+ case '6': return 6;
+ case '7': return 7;
+ case '8': return 8;
+ case '9': return 9;
+ case 'a': case 'A': return 10;
+ case 'b': case 'B': return 11;
+ case 'c': case 'C': return 12;
+ case 'd': case 'D': return 13;
+ case 'e': case 'E': return 14;
+ case 'f': case 'F': return 15;
+ default: return 0;
}
}
@@ -231,18 +199,13 @@ AP4_HexNibble(char c)
| AP4_NibbleHex
+---------------------------------------------------------------------*/
char
-AP4_NibbleHex(unsigned int nibble)
+AP4_NibbleHex(unsigned int nibble)
{
- if(nibble < 10)
- {
- return '0' + nibble;
- }
- else if(nibble < 16)
- {
- return 'A' + (nibble - 10);
- }
- else
- {
+ if (nibble < 10) {
+ return '0'+nibble;
+ } else if (nibble < 16) {
+ return 'A'+(nibble-10);
+ } else {
return ' ';
}
}
@@ -253,9 +216,8 @@ AP4_NibbleHex(unsigned int nibble)
AP4_Result
AP4_ParseHex(const char* hex, unsigned char* bytes, unsigned int count)
{
- if(AP4_StringLength(hex) != 2 * count) return AP4_ERROR_INVALID_PARAMETERS;
- for(unsigned int i = 0; i < count; i++)
- {
+ if (AP4_StringLength(hex) != 2*count) return AP4_ERROR_INVALID_PARAMETERS;
+ for (unsigned int i=0; i<count; i++) {
bytes[i] = (AP4_HexNibble(hex[2*i]) << 4) | (AP4_HexNibble(hex[2*i+1]));
}
return AP4_SUCCESS;
@@ -267,37 +229,32 @@ AP4_ParseHex(const char* hex, unsigned char* bytes, unsigned int count)
AP4_Result
AP4_FormatHex(const AP4_UI08* data, unsigned int data_size, char* hex)
{
- for(unsigned int i = 0; i < data_size; i++)
- {
- *hex++ = AP4_NibbleHex(data[i] >> 4);
- *hex++ = AP4_NibbleHex(data[i] & 0x0F);
+ for (unsigned int i=0; i<data_size; i++) {
+ *hex++ = AP4_NibbleHex(data[i]>>4);
+ *hex++ = AP4_NibbleHex(data[i]&0x0F);
}
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_BitWriter::Write
+---------------------------------------------------------------------*/
-void
+void
AP4_BitWriter::Write(AP4_UI32 bits, unsigned int bit_count)
{
unsigned char* data = m_Data;
- if(m_BitCount + bit_count > m_DataSize * 8) return;
- data += m_BitCount / 8;
- unsigned int space = 8 - (m_BitCount % 8);
- while(bit_count)
- {
- unsigned int mask = bit_count == 32 ? 0xFFFFFFFF : ((1 << bit_count) - 1);
- if(bit_count <= space)
- {
- *data |= ((bits & mask) << (space - bit_count));
+ if (m_BitCount+bit_count > m_DataSize*8) return;
+ data += m_BitCount/8;
+ unsigned int space = 8-(m_BitCount%8);
+ while (bit_count) {
+ unsigned int mask = bit_count==32 ? 0xFFFFFFFF : ((1<<bit_count)-1);
+ if (bit_count <= space) {
+ *data |= ((bits&mask) << (space-bit_count));
m_BitCount += bit_count;
return;
- }
- else
- {
- *data |= ((bits & mask) >> (bit_count - space));
+ } else {
+ *data |= ((bits&mask) >> (bit_count-space));
++data;
m_BitCount += space;
bit_count -= space;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.h
index df3f9c228..e2d3b6c93 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4Utils.h
@@ -51,11 +51,11 @@ void AP4_BytesFromUInt64BE(unsigned char* bytes, AP4_UI64 value);
inline AP4_UI32
AP4_BytesToUInt32BE(const unsigned char* bytes)
{
- return
- (((AP4_UI32)bytes[0]) << 24) |
- (((AP4_UI32)bytes[1]) << 16) |
- (((AP4_UI32)bytes[2]) << 8) |
- (((AP4_UI32)bytes[3]));
+ return
+ ( ((AP4_UI32)bytes[0])<<24 ) |
+ ( ((AP4_UI32)bytes[1])<<16 ) |
+ ( ((AP4_UI32)bytes[2])<<8 ) |
+ ( ((AP4_UI32)bytes[3]) );
}
/*----------------------------------------------------------------------
@@ -73,10 +73,10 @@ AP4_BytesToInt32BE(const unsigned char* bytes)
inline AP4_UI32
AP4_BytesToUInt24BE(const unsigned char* bytes)
{
- return
- (((AP4_UI32)bytes[0]) << 16) |
- (((AP4_UI32)bytes[1]) << 8) |
- (((AP4_UI32)bytes[2]));
+ return
+ ( ((AP4_UI32)bytes[0])<<16 ) |
+ ( ((AP4_UI32)bytes[1])<<8 ) |
+ ( ((AP4_UI32)bytes[2]) );
}
/*----------------------------------------------------------------------
@@ -85,9 +85,9 @@ AP4_BytesToUInt24BE(const unsigned char* bytes)
inline AP4_UI16
AP4_BytesToUInt16BE(const unsigned char* bytes)
{
- return
- (((AP4_UI16)bytes[0]) << 8) |
- (((AP4_UI16)bytes[1]));
+ return
+ ( ((AP4_UI16)bytes[0])<<8 ) |
+ ( ((AP4_UI16)bytes[1]) );
}
/*----------------------------------------------------------------------
@@ -108,7 +108,7 @@ AP4_BytesFromUInt32BE(unsigned char* bytes, AP4_UI32 value)
bytes[0] = (unsigned char)(value >> 24);
bytes[1] = (unsigned char)(value >> 16);
bytes[2] = (unsigned char)(value >> 8);
- bytes[3] = (unsigned char)(value);
+ bytes[3] = (unsigned char)(value );
}
/*----------------------------------------------------------------------
@@ -119,7 +119,7 @@ AP4_BytesFromUInt24BE(unsigned char* bytes, AP4_UI32 value)
{
bytes[0] = (unsigned char)(value >> 16);
bytes[1] = (unsigned char)(value >> 8);
- bytes[2] = (unsigned char)(value);
+ bytes[2] = (unsigned char)(value );
}
/*----------------------------------------------------------------------
@@ -129,7 +129,7 @@ inline void
AP4_BytesFromUInt16BE(unsigned char* bytes, AP4_UI16 value)
{
bytes[0] = (unsigned char)(value >> 8);
- bytes[1] = (unsigned char)(value);
+ bytes[1] = (unsigned char)(value );
}
/*----------------------------------------------------------------------
@@ -187,34 +187,21 @@ AP4_SplitArgs(char* arg, char*& arg0, char*& arg1);
class AP4_BitWriter
{
public:
- AP4_BitWriter(AP4_Size size) : m_DataSize(size), m_BitCount(0)
- {
- if(size)
- {
+ AP4_BitWriter(AP4_Size size) : m_DataSize(size), m_BitCount(0) {
+ if (size) {
m_Data = new unsigned char[size];
AP4_SetMemory(m_Data, 0, size);
- }
- else
- {
+ } else {
m_Data = NULL;
}
}
- ~AP4_BitWriter()
- {
- delete m_Data;
- }
-
+ ~AP4_BitWriter() { delete m_Data; }
+
void Write(AP4_UI32 bits, unsigned int bit_count);
-
- unsigned int GetBitCount()
- {
- return m_BitCount;
- }
- const unsigned char* GetData()
- {
- return m_Data;
- }
-
+
+ unsigned int GetBitCount() { return m_BitCount; }
+ const unsigned char* GetData() { return m_Data; }
+
private:
unsigned char* m_Data;
unsigned int m_DataSize;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.cpp
index 27981438d..e71eced66 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - UUID Atoms
+| AP4 - UUID Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -36,7 +36,7 @@
/*----------------------------------------------------------------------
| AP4_UuidAtom::AP4_UuidAtom
+---------------------------------------------------------------------*/
-AP4_UuidAtom::AP4_UuidAtom(AP4_UI64 size, const AP4_UI08* uuid) :
+AP4_UuidAtom::AP4_UuidAtom(AP4_UI64 size, const AP4_UI08* uuid) :
AP4_Atom(AP4_ATOM_TYPE_UUID, size)
{
AP4_CopyMemory(m_Uuid, uuid, 16);
@@ -45,7 +45,7 @@ AP4_UuidAtom::AP4_UuidAtom(AP4_UI64 size, const AP4_UI08* uuid) :
/*----------------------------------------------------------------------
| AP4_UuidAtom::AP4_UuidAtom
+---------------------------------------------------------------------*/
-AP4_UuidAtom::AP4_UuidAtom(AP4_UI64 size, const AP4_UI08* uuid, AP4_UI32 version, AP4_UI32 flags) :
+AP4_UuidAtom::AP4_UuidAtom(AP4_UI64 size, const AP4_UI08* uuid, AP4_UI32 version, AP4_UI32 flags) :
AP4_Atom(AP4_ATOM_TYPE_UUID, size, false, version, flags)
{
AP4_CopyMemory(m_Uuid, uuid, 16);
@@ -54,11 +54,10 @@ AP4_UuidAtom::AP4_UuidAtom(AP4_UI64 size, const AP4_UI08* uuid, AP4_UI32 version
/*----------------------------------------------------------------------
| AP4_UuidAtom::AP4_UuidAtom
+---------------------------------------------------------------------*/
-AP4_UuidAtom::AP4_UuidAtom(AP4_UI64 size, bool is_full, AP4_ByteStream& stream) :
+AP4_UuidAtom::AP4_UuidAtom(AP4_UI64 size, bool is_full, AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_UUID, size)
{
- if(is_full)
- {
+ if (is_full) {
m_IsFull = true;
ReadFullHeader(stream, m_Version, m_Flags);
}
@@ -70,7 +69,7 @@ AP4_UuidAtom::AP4_UuidAtom(AP4_UI64 size, bool is_full, AP4_ByteStream& stream)
AP4_Size
AP4_UuidAtom::GetHeaderSize() const
{
- return (m_IsFull ? AP4_FULL_UUID_ATOM_HEADER_SIZE : AP4_UUID_ATOM_HEADER_SIZE) + (m_Size32 == 1 ? 8 : 0);
+ return (m_IsFull ? AP4_FULL_UUID_ATOM_HEADER_SIZE : AP4_UUID_ATOM_HEADER_SIZE)+(m_Size32==1?8:0);
}
/*----------------------------------------------------------------------
@@ -83,30 +82,28 @@ AP4_UuidAtom::WriteHeader(AP4_ByteStream& stream)
// write the size
result = stream.WriteUI32(m_Size32);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// write the type
result = stream.WriteUI32(m_Type);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// handle 64-bit sizes
- if(m_Size32 == 1)
- {
+ if (m_Size32 == 1) {
result = stream.WriteUI64(m_Size64);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
- // write the extended type
+ // write the extended type
result = stream.Write(m_Uuid, 16);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// for full atoms, write version and flags
- if(m_IsFull)
- {
+ if (m_IsFull) {
result = stream.WriteUI08(m_Version);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
result = stream.WriteUI24(m_Flags);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
}
return AP4_SUCCESS;
@@ -121,13 +118,12 @@ AP4_UuidAtom::InspectHeader(AP4_AtomInspector& inspector)
char uuid[37];
uuid[36] = '\0';
char* dst = uuid;
- for(unsigned int i = 0; i < 16; i++)
- {
- *dst++ = AP4_NibbleHex(m_Uuid[i] >> 4);
- *dst++ = AP4_NibbleHex(m_Uuid[i] & 0x0F);
- if(i == 5 || i == 7 || i == 9 || i == 11) *dst++ = '-';
+ for (unsigned int i=0; i<16; i++) {
+ *dst++ = AP4_NibbleHex(m_Uuid[i]>>4);
+ *dst++ = AP4_NibbleHex(m_Uuid[i]&0x0F);
+ if (i == 5 || i == 7 || i == 9 || i == 11) *dst++ = '-';
}
-
+
// write atom name
char name[7];
name[0] = '[';
@@ -136,33 +132,27 @@ AP4_UuidAtom::InspectHeader(AP4_AtomInspector& inspector)
name[6] = '\0';
char header[128];
char extra[32] = "";
- if(m_IsFull)
- {
- if(m_Version && m_Flags)
- {
- AP4_FormatString(extra, sizeof(extra),
+ if (m_IsFull) {
+ if (m_Version && m_Flags) {
+ AP4_FormatString(extra, sizeof(extra),
", version=%d, flags=%x",
m_Version,
m_Flags);
- }
- else if(m_Version)
- {
- AP4_FormatString(extra, sizeof(extra),
+ } else if (m_Version) {
+ AP4_FormatString(extra, sizeof(extra),
", version=%d",
m_Version);
- }
- else if(m_Flags)
- {
- AP4_FormatString(extra, sizeof(extra),
+ } else if (m_Flags) {
+ AP4_FormatString(extra, sizeof(extra),
", flags=%x",
m_Flags);
}
}
- AP4_FormatString(header, sizeof(header),
- "{%s} size=%ld+%lld%s",
+ AP4_FormatString(header, sizeof(header),
+ "{%s} size=%ld+%lld%s",
uuid,
- GetHeaderSize(),
- GetSize() - GetHeaderSize(),
+ GetHeaderSize(),
+ GetSize()-GetHeaderSize(),
extra);
inspector.StartElement(name, header);
@@ -172,22 +162,22 @@ AP4_UuidAtom::InspectHeader(AP4_AtomInspector& inspector)
/*----------------------------------------------------------------------
| AP4_UnknownUuidAtom::AP4_UnknownUuidAtom
+---------------------------------------------------------------------*/
-AP4_UnknownUuidAtom::AP4_UnknownUuidAtom(AP4_UI64 size, AP4_ByteStream& stream) :
+AP4_UnknownUuidAtom::AP4_UnknownUuidAtom(AP4_UI64 size, AP4_ByteStream& stream) :
AP4_UuidAtom(size, false, stream)
{
// store the data
- m_Data.SetDataSize((AP4_Size)size - GetHeaderSize());
+ m_Data.SetDataSize((AP4_Size)size-GetHeaderSize());
stream.Read(m_Data.UseData(), m_Data.GetDataSize());
}
/*----------------------------------------------------------------------
| AP4_UnknownUuidAtom::AP4_UnknownUuidAtom
+---------------------------------------------------------------------*/
-AP4_UnknownUuidAtom::AP4_UnknownUuidAtom(AP4_UI64 size, const AP4_UI08* uuid, AP4_ByteStream& stream) :
+AP4_UnknownUuidAtom::AP4_UnknownUuidAtom(AP4_UI64 size, const AP4_UI08* uuid, AP4_ByteStream& stream) :
AP4_UuidAtom(size, uuid)
{
// store the data
- m_Data.SetDataSize((AP4_Size)size - GetHeaderSize());
+ m_Data.SetDataSize((AP4_Size)size-GetHeaderSize());
stream.Read(m_Data.UseData(), m_Data.GetDataSize());
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.h
index 763fd53cd..2c425193a 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4UuidAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - UUID Atoms
+| AP4 - UUID Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -26,7 +26,7 @@
|
****************************************************************/
/**
-* @file
+* @file
* @brief UUID Atoms
*/
@@ -42,8 +42,8 @@
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_UUID_ATOM_HEADER_SIZE = AP4_ATOM_HEADER_SIZE + 16;
-const AP4_UI32 AP4_FULL_UUID_ATOM_HEADER_SIZE = AP4_FULL_ATOM_HEADER_SIZE + 16;
+const AP4_UI32 AP4_UUID_ATOM_HEADER_SIZE = AP4_ATOM_HEADER_SIZE+16;
+const AP4_UI32 AP4_FULL_UUID_ATOM_HEADER_SIZE = AP4_FULL_ATOM_HEADER_SIZE+16;
/*----------------------------------------------------------------------
| AP4_UuidAtom
@@ -51,8 +51,7 @@ const AP4_UI32 AP4_FULL_UUID_ATOM_HEADER_SIZE = AP4_FULL_ATOM_HEADER_SIZE + 16;
/**
* Base class for uuid atoms.
*/
-class AP4_UuidAtom : public AP4_Atom
-{
+class AP4_UuidAtom : public AP4_Atom {
public:
// constructor and destructor
virtual ~AP4_UuidAtom() {};
@@ -63,11 +62,8 @@ public:
virtual AP4_Result InspectHeader(AP4_AtomInspector& inspector);
// accessors
- const AP4_UI08* GetUuid()
- {
- return m_Uuid;
- }
-
+ const AP4_UI08* GetUuid() { return m_Uuid; }
+
protected:
// members
AP4_UuidAtom(AP4_UI64 size, const AP4_UI08* uuid);
@@ -82,8 +78,7 @@ protected:
/**
* Unknown uuid atoms.
*/
-class AP4_UnknownUuidAtom : public AP4_UuidAtom
-{
+class AP4_UnknownUuidAtom : public AP4_UuidAtom {
public:
// constructors
AP4_UnknownUuidAtom(AP4_UI64 size, AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.cpp
index fc48d1ceb..0aaf37c72 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - vmhd Atoms
+| AP4 - vmhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -42,8 +42,8 @@ AP4_VmhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_VmhdAtom(size, version, flags, stream);
}
@@ -51,7 +51,7 @@ AP4_VmhdAtom::Create(AP4_Size size, AP4_ByteStream& stream)
| AP4_VmhdAtom::AP4_VmhdAtom
+---------------------------------------------------------------------*/
AP4_VmhdAtom::AP4_VmhdAtom(AP4_UI16 graphics_mode, AP4_UI16 r, AP4_UI16 g, AP4_UI16 b) :
- AP4_Atom(AP4_ATOM_TYPE_VMHD, AP4_FULL_ATOM_HEADER_SIZE + 8, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_VMHD, AP4_FULL_ATOM_HEADER_SIZE+8, 0, 0),
m_GraphicsMode(graphics_mode)
{
m_OpColor[0] = r;
@@ -62,7 +62,7 @@ AP4_VmhdAtom::AP4_VmhdAtom(AP4_UI16 graphics_mode, AP4_UI16 r, AP4_UI16 g, AP4_U
/*----------------------------------------------------------------------
| AP4_VmhdAtom::AP4_VmhdAtom
+---------------------------------------------------------------------*/
-AP4_VmhdAtom::AP4_VmhdAtom(AP4_UI32 size,
+AP4_VmhdAtom::AP4_VmhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
@@ -82,11 +82,11 @@ AP4_VmhdAtom::WriteFields(AP4_ByteStream& stream)
// graphics mode
result = stream.WriteUI16(m_GraphicsMode);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// op color
result = stream.Write(m_OpColor, sizeof(m_OpColor));
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
return AP4_SUCCESS;
}
@@ -100,7 +100,7 @@ AP4_VmhdAtom::InspectFields(AP4_AtomInspector& inspector)
inspector.AddField("graphics_mode", m_GraphicsMode);
char formatted[16];
AP4_FormatString(formatted, sizeof(formatted), "%04x,%04x,%04x",
- m_OpColor[0], m_OpColor[1], m_OpColor[2]);
+ m_OpColor[0], m_OpColor[1], m_OpColor[2]);
inspector.AddField("op_color", formatted);
return AP4_SUCCESS;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.h b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.h
index ba9f82da8..6fed056e3 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Core/Ap4VmhdAtom.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - vmhd Atoms
+| AP4 - vmhd Atoms
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -50,7 +50,7 @@ public:
private:
// methods
- AP4_VmhdAtom(AP4_UI32 size,
+ AP4_VmhdAtom(AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.cpp
index e084cb96d..ef0619901 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.cpp
@@ -11,23 +11,23 @@ All rights reserved.
LICENSE TERMS
-The free distribution and use of this software in both source and binary
+The free distribution and use of this software in both source and binary
form is allowed (with or without changes) provided that:
-1. distributions of this source code include the above copyright
+1. distributions of this source code include the above copyright
notice, this list of conditions and the following disclaimer;
2. distributions in binary form include the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other associated materials;
-3. the copyright holder's name is not used to endorse products
-built using this software without specific written permission.
+3. the copyright holder's name is not used to endorse products
+built using this software without specific written permission.
DISCLAIMER
This software is provided 'as is' with no explicit or implied warranties
-in respect of its properties, including, but not limited to, correctness
+in respect of its properties, including, but not limited to, correctness
and fitness for purpose.
-------------------------------------------------------------------------
Issue Date: 29/07/2002
@@ -46,8 +46,7 @@ typedef AP4_UI32 aes_32t;
typedef AP4_UI08 aes_08t;
typedef unsigned int aes_rval;
struct aes_ctx // the AES context for encryption
-{
- aes_32t k_sch[4*AP4_AES_BLOCK_SIZE]; // the encryption key schedule
+{ aes_32t k_sch[4*AP4_AES_BLOCK_SIZE]; // the encryption key schedule
aes_32t n_rnd; // the number of cipher rounds
aes_32t n_blk; // the number of bytes in the state
};
@@ -69,21 +68,21 @@ struct aes_ctx // the AES context for encryption
/* START OF CONFIGURATION OPTIONS
USE OF DEFINES
-
- Later in this section there are a number of defines that control the
- operation of the code. In each section, the purpose of each define is
- explained so that the relevant form can be included or excluded by
- setting either 1's or 0's respectively on the branches of the related
+
+ Later in this section there are a number of defines that control the
+ operation of the code. In each section, the purpose of each define is
+ explained so that the relevant form can be included or excluded by
+ setting either 1's or 0's respectively on the branches of the related
#if clauses.
*/
/* 1. BYTE ORDER IN 32-BIT WORDS
- To obtain the highest speed on processors with 32-bit words, this code
+ To obtain the highest speed on processors with 32-bit words, this code
needs to determine the order in which bytes are packed into such words.
- The following block of code is an attempt to capture the most obvious
- ways in which various environemnts define byte order. It may well fail,
- in which case the definitions will need to be set by editing at the
+ The following block of code is an attempt to capture the most obvious
+ ways in which various environemnts define byte order. It may well fail,
+ in which case the definitions will need to be set by editing at the
points marked **** EDIT HERE IF NECESSARY **** below.
*/
#define AES_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
@@ -105,27 +104,27 @@ struct aes_ctx // the AES context for encryption
/* 2. BYTE ORDER WITHIN 32 BIT WORDS
- The fundamental data processing units in Rijndael are 8-bit bytes. The
- input, output and key input are all enumerated arrays of bytes in which
- bytes are numbered starting at zero and increasing to one less than the
- number of bytes in the array in question. This enumeration is only used
- for naming bytes and does not imply any adjacency or order relationship
- from one byte to another. When these inputs and outputs are considered
- as bit sequences, bits 8*n to 8*n+7 of the bit sequence are mapped to
- byte[n] with bit 8n+i in the sequence mapped to bit 7-i within the byte.
- In this implementation bits are numbered from 0 to 7 starting at the
+ The fundamental data processing units in Rijndael are 8-bit bytes. The
+ input, output and key input are all enumerated arrays of bytes in which
+ bytes are numbered starting at zero and increasing to one less than the
+ number of bytes in the array in question. This enumeration is only used
+ for naming bytes and does not imply any adjacency or order relationship
+ from one byte to another. When these inputs and outputs are considered
+ as bit sequences, bits 8*n to 8*n+7 of the bit sequence are mapped to
+ byte[n] with bit 8n+i in the sequence mapped to bit 7-i within the byte.
+ In this implementation bits are numbered from 0 to 7 starting at the
numerically least significant end of each byte (bit n represents 2^n).
- However, Rijndael can be implemented more efficiently using 32-bit
+ However, Rijndael can be implemented more efficiently using 32-bit
words by packing bytes into words so that bytes 4*n to 4*n+3 are placed
- into word[n]. While in principle these bytes can be assembled into words
- in any positions, this implementation only supports the two formats in
+ into word[n]. While in principle these bytes can be assembled into words
+ in any positions, this implementation only supports the two formats in
which bytes in adjacent positions within words also have adjacent byte
- numbers. This order is called big-endian if the lowest numbered bytes
- in words have the highest numeric significance and little-endian if the
- opposite applies.
-
- This code can work in either order irrespective of the order used by the
+ numbers. This order is called big-endian if the lowest numbered bytes
+ in words have the highest numeric significance and little-endian if the
+ opposite applies.
+
+ This code can work in either order irrespective of the order used by the
machine on which it runs. Normally the internal byte order will be set
to the order of the processor on which the code is to be run but this
define can be used to reverse this in special situations
@@ -138,20 +137,20 @@ struct aes_ctx // the AES context for encryption
#define INTERNAL_BYTE_ORDER AES_BIG_ENDIAN
#endif
-/* 3. FAST INPUT/OUTPUT OPERATIONS.
+/* 3. FAST INPUT/OUTPUT OPERATIONS.
- On some machines it is possible to improve speed by transferring the
- bytes in the input and output arrays to and from the internal 32-bit
- variables by addressing these arrays as if they are arrays of 32-bit
- words. On some machines this will always be possible but there may
- be a large performance penalty if the byte arrays are not aligned on
- the normal word boundaries. On other machines this technique will
+ On some machines it is possible to improve speed by transferring the
+ bytes in the input and output arrays to and from the internal 32-bit
+ variables by addressing these arrays as if they are arrays of 32-bit
+ words. On some machines this will always be possible but there may
+ be a large performance penalty if the byte arrays are not aligned on
+ the normal word boundaries. On other machines this technique will
lead to memory access errors when such 32-bit word accesses are not
- properly aligned. The option SAFE_IO avoids such problems but will
- often be slower on those machines that support misaligned access
- (especially so if care is taken to align the input and output byte
- arrays on 32-bit word boundaries). If SAFE_IO is not defined it is
- assumed that access to byte arrays as if they are arrays of 32-bit
+ properly aligned. The option SAFE_IO avoids such problems but will
+ often be slower on those machines that support misaligned access
+ (especially so if care is taken to align the input and output byte
+ arrays on 32-bit word boundaries). If SAFE_IO is not defined it is
+ assumed that access to byte arrays as if they are arrays of 32-bit
words will not cause problems when such accesses are misaligned.
*/
#if 1
@@ -161,12 +160,12 @@ struct aes_ctx // the AES context for encryption
/* 4. LOOP UNROLLING
The code for encryption and decrytpion cycles through a number of rounds
- that can be implemented either in a loop or by expanding the code into a
+ that can be implemented either in a loop or by expanding the code into a
long sequence of instructions, the latter producing a larger program but
one that will often be much faster. The latter is called loop unrolling.
There are also potential speed advantages in expanding two iterations in
a loop with half the number of iterations, which is called partial loop
- unrolling. The following options allow partial or full loop unrolling
+ unrolling. The following options allow partial or full loop unrolling
to be set independently for encryption and decryption
*/
#if 0
@@ -187,8 +186,8 @@ struct aes_ctx // the AES context for encryption
/* 5. FIXED OR DYNAMIC TABLES
- When this section is included the tables used by the code are comipled
- statically into the binary file. Otherwise they are computed once when
+ When this section is included the tables used by the code are comipled
+ statically into the binary file. Otherwise they are computed once when
the code is first used.
*/
#if 1
@@ -197,7 +196,7 @@ struct aes_ctx // the AES context for encryption
/* 6. FAST FINITE FIELD OPERATIONS
- If this section is included, tables are used to provide faster finite
+ If this section is included, tables are used to provide faster finite
field arithmetic (this has no effect if FIXED_TABLES is defined).
*/
#if 1
@@ -206,8 +205,8 @@ struct aes_ctx // the AES context for encryption
/* 7. INTERNAL STATE VARIABLE FORMAT
- The internal state of Rijndael is stored in a number of local 32-bit
- word varaibles which can be defined either as an array or as individual
+ The internal state of Rijndael is stored in a number of local 32-bit
+ word varaibles which can be defined either as an array or as individual
names variables. Include this section if you want to store these local
variables in arrays. Otherwise individual local variables will be used.
*/
@@ -217,10 +216,10 @@ struct aes_ctx // the AES context for encryption
/* In this implementation the columns of the state array are each held in
32-bit words. The state array can be held in various ways: in an array
- of words, in a number of individual word variables or in a number of
+ of words, in a number of individual word variables or in a number of
processor registers. The following define maps a variable name x and
a column number c to the way the state array variable is to be held.
- The first define below maps the state into an array x[c] whereas the
+ The first define below maps the state into an array x[c] whereas the
second form maps the state into a number of individual variables x0,
x1, etc. Another form could map individual state colums to machine
register names.
@@ -246,16 +245,16 @@ struct aes_ctx // the AES context for encryption
This cipher proceeds by repeating in a number of cycles known as 'rounds'
which are implemented by a round function which can optionally be speeded
- up using tables. The basic tables are each 256 32-bit words, with either
+ up using tables. The basic tables are each 256 32-bit words, with either
one or four tables being required for each round function depending on
how much speed is required. The encryption and decryption round functions
are different and the last encryption and decrytpion round functions are
different again making four different round functions in all.
This means that:
- 1. Normal encryption and decryption rounds can each use either 0, 1
+ 1. Normal encryption and decryption rounds can each use either 0, 1
or 4 tables and table spaces of 0, 1024 or 4096 bytes each.
- 2. The last encryption and decryption rounds can also use either 0, 1
+ 2. The last encryption and decryption rounds can also use either 0, 1
or 4 tables and table spaces of 0, 1024 or 4096 bytes each.
Include or exclude the appropriate definitions below to set the number
@@ -295,7 +294,7 @@ struct aes_ctx // the AES context for encryption
#endif
/* The decryption key schedule can be speeded up with tables in the same
- way that the round functions can. Include or exclude the following
+ way that the round functions can. Include or exclude the following
defines to set this requirement.
*/
#if 1
@@ -317,7 +316,7 @@ struct aes_ctx // the AES context for encryption
#if defined(BLOCK_SIZE) && ((BLOCK_SIZE & 3) || BLOCK_SIZE < 16 || BLOCK_SIZE > 32)
#error An illegal block size has been specified.
-#endif
+#endif
#if !defined(BLOCK_SIZE)
#define RC_LENGTH 29
@@ -332,7 +331,7 @@ struct aes_ctx // the AES context for encryption
#define LAST_ENC_ROUND NO_TABLES
#elif ENC_ROUND == ONE_TABLE && LAST_ENC_ROUND == FOUR_TABLES
#undef LAST_ENC_ROUND
-#define LAST_ENC_ROUND ONE_TABLE
+#define LAST_ENC_ROUND ONE_TABLE
#endif
#if ENC_ROUND == NO_TABLES && ENC_UNROLL != NONE
@@ -345,7 +344,7 @@ struct aes_ctx // the AES context for encryption
#define LAST_DEC_ROUND NO_TABLES
#elif DEC_ROUND == ONE_TABLE && LAST_DEC_ROUND == FOUR_TABLES
#undef LAST_DEC_ROUND
-#define LAST_DEC_ROUND ONE_TABLE
+#define LAST_DEC_ROUND ONE_TABLE
#endif
#if DEC_ROUND == NO_TABLES && DEC_UNROLL != NONE
@@ -355,11 +354,11 @@ struct aes_ctx // the AES context for encryption
/* upr(x,n): rotates bytes within words by n positions, moving bytes to
higher index positions with wrap around into low positions
- ups(x,n): moves bytes by n positions to higher index positions in
+ ups(x,n): moves bytes by n positions to higher index positions in
words but without wrap around
bval(x,n): extracts a byte from a word
- NOTE: The definitions given here are intended only for use with
+ NOTE: The definitions given here are intended only for use with
unsigned variables and with shift counts that are compile
time constants
*/
@@ -401,7 +400,7 @@ struct aes_ctx // the AES context for encryption
#if !defined(_MSC_VER)
#define _lrotl(x,n) ((((aes_32t)(x)) << n) | (((aes_32t)(x)) >> (32 - n)))
#endif
-#define bswap_32(x) ((_lrotl((x),8) & 0x00ff00ff) | (_lrotl((x),24) & 0xff00ff00))
+#define bswap_32(x) ((_lrotl((x),8) & 0x00ff00ff) | (_lrotl((x),24) & 0xff00ff00))
#endif
#define word_in(x) bswap_32(*(aes_32t*)(x))
@@ -424,9 +423,9 @@ struct aes_ctx // the AES context for encryption
give improved performance if a fast 32-bit multiply is not available. Note
that a temporary variable u needs to be defined where FFmulX is used.
-#define FFmulX(x) (u = (x) & m1, u |= (u >> 1), ((x) & m2) << 1) ^ ((u >> 3) | (u >> 6))
+#define FFmulX(x) (u = (x) & m1, u |= (u >> 1), ((x) & m2) << 1) ^ ((u >> 3) | (u >> 6))
#define m4 (0x01010101 * BPOLY)
-#define FFmulX(x) (u = (x) & m1, ((x) & m2) << 1) ^ ((u - (u >> 7)) & m4)
+#define FFmulX(x) (u = (x) & m1, ((x) & m2) << 1) ^ ((u - (u >> 7)) & m4)
*/
/* Work out which tables are needed for the different options */
@@ -651,7 +650,7 @@ void gen_tabs(void);
/*----------------------------------------------------------------------
| tables
+---------------------------------------------------------------------*/
-#if defined(FIXED_TABLES) || !defined(FF_TABLES)
+#if defined(FIXED_TABLES) || !defined(FF_TABLES)
/* finite field arithmetic operations */
@@ -773,7 +772,7 @@ void gen_tabs(void);
#define h0(x) (x)
-/* These defines are used to ensure tables are generated in the
+/* These defines are used to ensure tables are generated in the
right format depending on the internal byte order required
*/
@@ -831,16 +830,16 @@ static const aes_08t inv_s_box[256] = { isb_data(h0) };
static const aes_32t ft_tab[256] = { sb_data(u0) };
#endif
#ifdef FT4_SET
-static const aes_32t ft_tab[4][256] =
-{ { sb_data(u0) }, { sb_data(u1) }, { sb_data(u2) }, { sb_data(u3) } };
+static const aes_32t ft_tab[4][256] =
+ { { sb_data(u0) }, { sb_data(u1) }, { sb_data(u2) }, { sb_data(u3) } };
#endif
#ifdef FL1_SET
static const aes_32t fl_tab[256] = { sb_data(w0) };
#endif
#ifdef FL4_SET
-static const aes_32t fl_tab[4][256] =
-{ { sb_data(w0) }, { sb_data(w1) }, { sb_data(w2) }, { sb_data(w3) } };
+static const aes_32t fl_tab[4][256] =
+ { { sb_data(w0) }, { sb_data(w1) }, { sb_data(w2) }, { sb_data(w3) } };
#endif
#ifdef IT1_SET
@@ -848,15 +847,15 @@ static const aes_32t it_tab[256] = { isb_data(v0) };
#endif
#ifdef IT4_SET
static const aes_32t it_tab[4][256] =
-{ { isb_data(v0) }, { isb_data(v1) }, { isb_data(v2) }, { isb_data(v3) } };
+ { { isb_data(v0) }, { isb_data(v1) }, { isb_data(v2) }, { isb_data(v3) } };
#endif
#ifdef IL1_SET
static const aes_32t il_tab[256] = { isb_data(w0) };
#endif
#ifdef IL4_SET
-static const aes_32t il_tab[4][256] =
-{ { isb_data(w0) }, { isb_data(w1) }, { isb_data(w2) }, { isb_data(w3) } };
+static const aes_32t il_tab[4][256] =
+ { { isb_data(w0) }, { isb_data(w1) }, { isb_data(w2) }, { isb_data(w3) } };
#endif
#ifdef LS1_SET
@@ -864,15 +863,15 @@ static const aes_32t ls_tab[256] = { sb_data(w0) };
#endif
#ifdef LS4_SET
static const aes_32t ls_tab[4][256] =
-{ { sb_data(w0) }, { sb_data(w1) }, { sb_data(w2) }, { sb_data(w3) } };
+ { { sb_data(w0) }, { sb_data(w1) }, { sb_data(w2) }, { sb_data(w3) } };
#endif
#ifdef IM1_SET
static const aes_32t im_tab[256] = { mm_data(v0) };
#endif
#ifdef IM4_SET
-static const aes_32t im_tab[4][256] =
-{ { mm_data(v0) }, { mm_data(v1) }, { mm_data(v2) }, { mm_data(v3) } };
+static const aes_32t im_tab[4][256] =
+ { { mm_data(v0) }, { mm_data(v1) }, { mm_data(v2) }, { mm_data(v3) } };
#endif
#else /* dynamic table generation */
@@ -936,8 +935,8 @@ aes_32t im_tab[4][256];
/* Generate the tables for the dynamic table option
- It will generally be sensible to use tables to compute finite
- field multiplies and inverses but where memory is scarse this
+ It will generally be sensible to use tables to compute finite
+ field multiplies and inverses but where memory is scarse this
code might sometimes be better. But it only has effect during
initialisation so its pretty unimportant in overall terms.
*/
@@ -948,9 +947,8 @@ aes_32t im_tab[4][256];
*/
static aes_08t hibit(const aes_32t x)
-{
- aes_08t r = (aes_08t)((x >> 1) | (x >> 2));
-
+{ aes_08t r = (aes_08t)((x >> 1) | (x >> 2));
+
r |= (r >> 2);
r |= (r >> 4);
return (r + 1) >> 1;
@@ -959,8 +957,7 @@ static aes_08t hibit(const aes_32t x)
/* return the inverse of the finite field element x */
static aes_08t fi(const aes_08t x)
-{
- aes_08t p1 = x, p2 = BPOLY, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0;
+{ aes_08t p1 = x, p2 = BPOLY, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0;
if(x < 2) return x;
@@ -969,21 +966,15 @@ static aes_08t fi(const aes_08t x)
if(!n1) return v1;
while(n2 >= n1)
- {
- n2 /= n1;
- p2 ^= p1 * n2;
- v2 ^= v1 * n2;
- n2 = hibit(p2);
+ {
+ n2 /= n1; p2 ^= p1 * n2; v2 ^= v1 * n2; n2 = hibit(p2);
}
-
+
if(!n2) return v2;
while(n1 >= n2)
- {
- n1 /= n2;
- p1 ^= p2 * n1;
- v1 ^= v2 * n1;
- n1 = hibit(p1);
+ {
+ n1 /= n2; p1 ^= p2 * n1; v1 ^= v2 * n1; n1 = hibit(p1);
}
}
}
@@ -1011,8 +1002,7 @@ static aes_08t fi(const aes_08t x)
(w = (aes_32t)x, w = (w<<1)^(w<<3)^(w<<6), 0x05^(aes_08t)(w^(w>>8)))
void gen_tabs(void)
-{
- aes_32t i, w;
+{ aes_32t i, w;
#if defined(FF_TABLES)
@@ -1023,16 +1013,15 @@ void gen_tabs(void)
root is 0x03, used here to generate the tables
*/
- i = 0;
- w = 1;
+ i = 0; w = 1;
do
- {
+ {
pow[i] = (aes_08t)w;
pow[i + 255] = (aes_08t)w;
log[w] = (aes_08t)i++;
- w ^= (w << 1) ^(w & 0x80 ? WPOLY : 0);
+ w ^= (w << 1) ^ (w & 0x80 ? WPOLY : 0);
}
- while(w != 1);
+ while (w != 1);
#endif
@@ -1043,8 +1032,7 @@ void gen_tabs(void)
}
for(i = 0; i < 256; ++i)
- {
- aes_08t b;
+ { aes_08t b;
b = fwd_affine(fi((aes_08t)i));
w = bytes2word(f2(b), b, b, f3(b));
@@ -1058,9 +1046,9 @@ void gen_tabs(void)
#endif
#ifdef FT4_SET
ft_tab[0][i] = w;
- ft_tab[1][i] = upr(w, 1);
- ft_tab[2][i] = upr(w, 2);
- ft_tab[3][i] = upr(w, 3);
+ ft_tab[1][i] = upr(w,1);
+ ft_tab[2][i] = upr(w,2);
+ ft_tab[3][i] = upr(w,3);
#endif
w = bytes2word(b, 0, 0, 0);
@@ -1069,9 +1057,9 @@ void gen_tabs(void)
#endif
#ifdef FL4_SET
fl_tab[0][i] = w;
- fl_tab[1][i] = upr(w, 1);
- fl_tab[2][i] = upr(w, 2);
- fl_tab[3][i] = upr(w, 3);
+ fl_tab[1][i] = upr(w,1);
+ fl_tab[2][i] = upr(w,2);
+ fl_tab[3][i] = upr(w,3);
#endif
#ifdef LS1_SET /* table for key schedule if fl_tab above is */
@@ -1079,9 +1067,9 @@ void gen_tabs(void)
#endif
#ifdef LS4_SET
ls_tab[0][i] = w;
- ls_tab[1][i] = upr(w, 1);
- ls_tab[2][i] = upr(w, 2);
- ls_tab[3][i] = upr(w, 3);
+ ls_tab[1][i] = upr(w,1);
+ ls_tab[2][i] = upr(w,2);
+ ls_tab[3][i] = upr(w,3);
#endif
b = fi(inv_affine((aes_08t)i));
@@ -1092,9 +1080,9 @@ void gen_tabs(void)
#endif
#ifdef IM4_SET
im_tab[0][b] = w;
- im_tab[1][b] = upr(w, 1);
- im_tab[2][b] = upr(w, 2);
- im_tab[3][b] = upr(w, 3);
+ im_tab[1][b] = upr(w,1);
+ im_tab[2][b] = upr(w,2);
+ im_tab[3][b] = upr(w,3);
#endif
#ifdef ISB_SET
@@ -1105,9 +1093,9 @@ void gen_tabs(void)
#endif
#ifdef IT4_SET
it_tab[0][i] = w;
- it_tab[1][i] = upr(w, 1);
- it_tab[2][i] = upr(w, 2);
- it_tab[3][i] = upr(w, 3);
+ it_tab[1][i] = upr(w,1);
+ it_tab[2][i] = upr(w,2);
+ it_tab[3][i] = upr(w,3);
#endif
w = bytes2word(b, 0, 0, 0);
#ifdef IL1_SET /* tables for last decryption round */
@@ -1115,9 +1103,9 @@ void gen_tabs(void)
#endif
#ifdef IL4_SET
il_tab[0][i] = w;
- il_tab[1][i] = upr(w, 1);
- il_tab[2][i] = upr(w, 2);
- il_tab[3][i] = upr(w, 3);
+ il_tab[1][i] = upr(w,1);
+ il_tab[2][i] = upr(w,2);
+ il_tab[3][i] = upr(w,3);
#endif
}
@@ -1137,10 +1125,9 @@ static aes_rval aes_blk_len(unsigned int blen, aes_ctx cx[1])
if(!tab_init) gen_tabs();
#endif
- if((blen & 7) || blen < 16 || blen > 32)
- {
- cx->n_blk = 0;
- return aes_bad;
+ if((blen & 7) || blen < 16 || blen > 32)
+ {
+ cx->n_blk = 0; return aes_bad;
}
cx->n_blk = blen;
@@ -1154,10 +1141,10 @@ static aes_rval aes_blk_len(unsigned int blen, aes_ctx cx[1])
This corresponds to bit lengths of 128, 192 and 256 bits, and
to Nk values of 4, 6 and 8 respectively.
- The following macros implement a single cycle in the key
- schedule generation process. The number of cycles needed
+ The following macros implement a single cycle in the key
+ schedule generation process. The number of cycles needed
for each cx->n_col and nk value is:
-
+
nk = 4 5 6 7 8
------------------------------
cx->n_col = 4 10 9 8 7 7
@@ -1200,8 +1187,7 @@ static aes_rval aes_blk_len(unsigned int blen, aes_ctx cx[1])
#if defined(ENCRYPTION_KEY_SCHEDULE)
static aes_rval aes_enc_key(const unsigned char in_key[], unsigned int klen, aes_ctx cx[1])
-{
- aes_32t ss[8];
+{ aes_32t ss[8];
#if !defined(FIXED_TABLES)
if(!tab_init) gen_tabs();
@@ -1212,10 +1198,10 @@ static aes_rval aes_enc_key(const unsigned char in_key[], unsigned int klen, aes
#else
cx->n_blk = BLOCK_SIZE;
#endif
-
+
cx->n_blk = (cx->n_blk & ~3) | 1;
- cx->k_sch[0] = ss[0] = word_in(in_key);
+ cx->k_sch[0] = ss[0] = word_in(in_key );
cx->k_sch[1] = ss[1] = word_in(in_key + 4);
cx->k_sch[2] = ss[2] = word_in(in_key + 8);
cx->k_sch[3] = ss[3] = word_in(in_key + 12);
@@ -1224,79 +1210,53 @@ static aes_rval aes_enc_key(const unsigned char in_key[], unsigned int klen, aes
switch(klen)
{
- case 16:
- ke4(cx->k_sch, 0);
- ke4(cx->k_sch, 1);
- ke4(cx->k_sch, 2);
- ke4(cx->k_sch, 3);
- ke4(cx->k_sch, 4);
- ke4(cx->k_sch, 5);
- ke4(cx->k_sch, 6);
- ke4(cx->k_sch, 7);
- ke4(cx->k_sch, 8);
- kel4(cx->k_sch, 9);
- cx->n_rnd = 10;
- break;
- case 24:
- cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- ke6(cx->k_sch, 0);
- ke6(cx->k_sch, 1);
- ke6(cx->k_sch, 2);
- ke6(cx->k_sch, 3);
- ke6(cx->k_sch, 4);
- ke6(cx->k_sch, 5);
- ke6(cx->k_sch, 6);
- kel6(cx->k_sch, 7);
- cx->n_rnd = 12;
- break;
- case 32:
- cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- cx->k_sch[6] = ss[6] = word_in(in_key + 24);
- cx->k_sch[7] = ss[7] = word_in(in_key + 28);
- ke8(cx->k_sch, 0);
- ke8(cx->k_sch, 1);
- ke8(cx->k_sch, 2);
- ke8(cx->k_sch, 3);
- ke8(cx->k_sch, 4);
- ke8(cx->k_sch, 5);
- kel8(cx->k_sch, 6);
- cx->n_rnd = 14;
- break;
- default:
- cx->n_rnd = 0;
- return aes_bad;
+ case 16: ke4(cx->k_sch, 0); ke4(cx->k_sch, 1);
+ ke4(cx->k_sch, 2); ke4(cx->k_sch, 3);
+ ke4(cx->k_sch, 4); ke4(cx->k_sch, 5);
+ ke4(cx->k_sch, 6); ke4(cx->k_sch, 7);
+ ke4(cx->k_sch, 8); kel4(cx->k_sch, 9);
+ cx->n_rnd = 10; break;
+ case 24: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
+ cx->k_sch[5] = ss[5] = word_in(in_key + 20);
+ ke6(cx->k_sch, 0); ke6(cx->k_sch, 1);
+ ke6(cx->k_sch, 2); ke6(cx->k_sch, 3);
+ ke6(cx->k_sch, 4); ke6(cx->k_sch, 5);
+ ke6(cx->k_sch, 6); kel6(cx->k_sch, 7);
+ cx->n_rnd = 12; break;
+ case 32: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
+ cx->k_sch[5] = ss[5] = word_in(in_key + 20);
+ cx->k_sch[6] = ss[6] = word_in(in_key + 24);
+ cx->k_sch[7] = ss[7] = word_in(in_key + 28);
+ ke8(cx->k_sch, 0); ke8(cx->k_sch, 1);
+ ke8(cx->k_sch, 2); ke8(cx->k_sch, 3);
+ ke8(cx->k_sch, 4); ke8(cx->k_sch, 5);
+ kel8(cx->k_sch, 6);
+ cx->n_rnd = 14; break;
+ default: cx->n_rnd = 0; return aes_bad;
}
#else
- {
- aes_32t i, l;
+ { aes_32t i, l;
cx->n_rnd = ((klen >> 2) > nc ? (klen >> 2) : nc) + 6;
l = (nc * cx->n_rnd + nc - 1) / (klen >> 2);
switch(klen)
{
- case 16:
- for(i = 0; i < l; ++i)
- ke4(cx->k_sch, i);
- break;
- case 24:
- cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- for(i = 0; i < l; ++i)
- ke6(cx->k_sch, i);
- break;
- case 32:
- cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- cx->k_sch[6] = ss[6] = word_in(in_key + 24);
- cx->k_sch[7] = ss[7] = word_in(in_key + 28);
- for(i = 0; i < l; ++i)
- ke8(cx->k_sch, i);
- break;
- default:
- cx->n_rnd = 0;
- return aes_bad;
+ case 16: for(i = 0; i < l; ++i)
+ ke4(cx->k_sch, i);
+ break;
+ case 24: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
+ cx->k_sch[5] = ss[5] = word_in(in_key + 20);
+ for(i = 0; i < l; ++i)
+ ke6(cx->k_sch, i);
+ break;
+ case 32: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
+ cx->k_sch[5] = ss[5] = word_in(in_key + 20);
+ cx->k_sch[6] = ss[6] = word_in(in_key + 24);
+ cx->k_sch[7] = ss[7] = word_in(in_key + 28);
+ for(i = 0; i < l; ++i)
+ ke8(cx->k_sch, i);
+ break;
+ default: cx->n_rnd = 0; return aes_bad;
}
}
#endif
@@ -1394,8 +1354,7 @@ static aes_rval aes_enc_key(const unsigned char in_key[], unsigned int klen, aes
}
static aes_rval aes_dec_key(const unsigned char in_key[], unsigned int klen, aes_ctx cx[1])
-{
- aes_32t ss[8];
+{ aes_32t ss[8];
d_vars
#if !defined(FIXED_TABLES)
@@ -1410,7 +1369,7 @@ static aes_rval aes_dec_key(const unsigned char in_key[], unsigned int klen, aes
cx->n_blk = (cx->n_blk & ~3) | 2;
- cx->k_sch[0] = ss[0] = word_in(in_key);
+ cx->k_sch[0] = ss[0] = word_in(in_key );
cx->k_sch[1] = ss[1] = word_in(in_key + 4);
cx->k_sch[2] = ss[2] = word_in(in_key + 8);
cx->k_sch[3] = ss[3] = word_in(in_key + 12);
@@ -1419,79 +1378,54 @@ static aes_rval aes_dec_key(const unsigned char in_key[], unsigned int klen, aes
switch(klen)
{
- case 16:
- kdf4(cx->k_sch, 0);
- kd4(cx->k_sch, 1);
- kd4(cx->k_sch, 2);
- kd4(cx->k_sch, 3);
- kd4(cx->k_sch, 4);
- kd4(cx->k_sch, 5);
- kd4(cx->k_sch, 6);
- kd4(cx->k_sch, 7);
- kd4(cx->k_sch, 8);
- kdl4(cx->k_sch, 9);
- cx->n_rnd = 10;
- break;
- case 24:
- cx->k_sch[4] = ff(ss[4] = word_in(in_key + 16));
- cx->k_sch[5] = ff(ss[5] = word_in(in_key + 20));
- kdf6(cx->k_sch, 0);
- kd6(cx->k_sch, 1);
- kd6(cx->k_sch, 2);
- kd6(cx->k_sch, 3);
- kd6(cx->k_sch, 4);
- kd6(cx->k_sch, 5);
- kd6(cx->k_sch, 6);
- kdl6(cx->k_sch, 7);
- cx->n_rnd = 12;
- break;
- case 32:
- cx->k_sch[4] = ff(ss[4] = word_in(in_key + 16));
- cx->k_sch[5] = ff(ss[5] = word_in(in_key + 20));
- cx->k_sch[6] = ff(ss[6] = word_in(in_key + 24));
- cx->k_sch[7] = ff(ss[7] = word_in(in_key + 28));
- kdf8(cx->k_sch, 0);
- kd8(cx->k_sch, 1);
- kd8(cx->k_sch, 2);
- kd8(cx->k_sch, 3);
- kd8(cx->k_sch, 4);
- kd8(cx->k_sch, 5);
- kdl8(cx->k_sch, 6);
- cx->n_rnd = 14;
- break;
- default:
- cx->n_rnd = 0;
- return aes_bad;
+ case 16: kdf4(cx->k_sch, 0); kd4(cx->k_sch, 1);
+ kd4(cx->k_sch, 2); kd4(cx->k_sch, 3);
+ kd4(cx->k_sch, 4); kd4(cx->k_sch, 5);
+ kd4(cx->k_sch, 6); kd4(cx->k_sch, 7);
+ kd4(cx->k_sch, 8); kdl4(cx->k_sch, 9);
+ cx->n_rnd = 10; break;
+ case 24: cx->k_sch[4] = ff(ss[4] = word_in(in_key + 16));
+ cx->k_sch[5] = ff(ss[5] = word_in(in_key + 20));
+ kdf6(cx->k_sch, 0); kd6(cx->k_sch, 1);
+ kd6(cx->k_sch, 2); kd6(cx->k_sch, 3);
+ kd6(cx->k_sch, 4); kd6(cx->k_sch, 5);
+ kd6(cx->k_sch, 6); kdl6(cx->k_sch, 7);
+ cx->n_rnd = 12; break;
+ case 32: cx->k_sch[4] = ff(ss[4] = word_in(in_key + 16));
+ cx->k_sch[5] = ff(ss[5] = word_in(in_key + 20));
+ cx->k_sch[6] = ff(ss[6] = word_in(in_key + 24));
+ cx->k_sch[7] = ff(ss[7] = word_in(in_key + 28));
+ kdf8(cx->k_sch, 0); kd8(cx->k_sch, 1);
+ kd8(cx->k_sch, 2); kd8(cx->k_sch, 3);
+ kd8(cx->k_sch, 4); kd8(cx->k_sch, 5);
+ kdl8(cx->k_sch, 6);
+ cx->n_rnd = 14; break;
+ default: cx->n_rnd = 0; return aes_bad;
}
#else
- {
- aes_32t i, l;
+ { aes_32t i, l;
cx->n_rnd = ((klen >> 2) > nc ? (klen >> 2) : nc) + 6;
l = (nc * cx->n_rnd + nc - 1) / (klen >> 2);
switch(klen)
{
- case 16:
- for(i = 0; i < l; ++i)
- ke4(cx->k_sch, i);
- break;
- case 24:
- cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- for(i = 0; i < l; ++i)
- ke6(cx->k_sch, i);
- break;
- case 32:
- cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- cx->k_sch[6] = ss[6] = word_in(in_key + 24);
- cx->k_sch[7] = ss[7] = word_in(in_key + 28);
- for(i = 0; i < l; ++i)
- ke8(cx->k_sch, i);
- break;
- default:
- cx->n_rnd = 0;
- return aes_bad;
+ case 16:
+ for(i = 0; i < l; ++i)
+ ke4(cx->k_sch, i);
+ break;
+ case 24: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
+ cx->k_sch[5] = ss[5] = word_in(in_key + 20);
+ for(i = 0; i < l; ++i)
+ ke6(cx->k_sch, i);
+ break;
+ case 32: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
+ cx->k_sch[5] = ss[5] = word_in(in_key + 20);
+ cx->k_sch[6] = ss[6] = word_in(in_key + 24);
+ cx->k_sch[7] = ss[7] = word_in(in_key + 28);
+ for(i = 0; i < l; ++i)
+ ke8(cx->k_sch, i);
+ break;
+ default: cx->n_rnd = 0; return aes_bad;
}
#if (DEC_ROUND != NO_TABLES)
for(i = nc; i < nc * cx->n_rnd; ++i)
@@ -1519,10 +1453,10 @@ static aes_rval aes_dec_key(const unsigned char in_key[], unsigned int klen, aes
#define locals(y,x) x[4],y[4]
#else
#define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3
-/*
- the following defines prevent the compiler requiring the declaration
- of generated but unused variables in the fwd_var and inv_var macros
-*/
+ /*
+ the following defines prevent the compiler requiring the declaration
+ of generated but unused variables in the fwd_var and inv_var macros
+ */
#define b04 unused
#define b05 unused
#define b06 unused
@@ -1633,18 +1567,18 @@ switch(nc) \
#if defined(ENCRYPTION)
/* I am grateful to Frank Yellin for the following construction
- (and that for decryption) which, given the column (c) of the
- output state variable, gives the input state variables which
+ (and that for decryption) which, given the column (c) of the
+ output state variable, gives the input state variables which
are needed in its computation for each row (r) of the state.
- For the fixed block size options, compilers should be able to
- reduce this complex expression (and the equivalent one for
- decryption) to a static variable reference at compile time.
+ For the fixed block size options, compilers should be able to
+ reduce this complex expression (and the equivalent one for
+ decryption) to a static variable reference at compile time.
But for variable block size code, there will be some limbs on
which conditional clauses will be returned.
*/
-/* y = output word, x = input word, r = row, c = column for r = 0,
+/* y = output word, x = input word, r = row, c = column for r = 0,
1, 2 and 3 = column accessed for row r.
*/
@@ -1707,14 +1641,13 @@ switch(nc) \
#endif
static aes_rval aes_enc_blk(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])
-{
- aes_32t locals(b0, b1);
+{ aes_32t locals(b0, b1);
const aes_32t *kp = cx->k_sch;
dec_fmvars /* declare variables for fwd_mcol() if needed */
if(!(cx->n_blk & 1)) return aes_bad;
- state_in(b0, in_blk, kp);
+ state_in(b0, in_blk, kp);
#if (ENC_UNROLL == FULL)
@@ -1722,45 +1655,40 @@ static aes_rval aes_enc_blk(const unsigned char in_blk[], unsigned char out_blk[
switch(cx->n_rnd)
{
- case 14:
- round(fwd_rnd, b1, b0, kp - 4 * nc);
- round(fwd_rnd, b0, b1, kp - 3 * nc);
- case 12:
- round(fwd_rnd, b1, b0, kp - 2 * nc);
- round(fwd_rnd, b0, b1, kp - nc);
- case 10:
- round(fwd_rnd, b1, b0, kp);
- round(fwd_rnd, b0, b1, kp + nc);
- round(fwd_rnd, b1, b0, kp + 2 * nc);
- round(fwd_rnd, b0, b1, kp + 3 * nc);
- round(fwd_rnd, b1, b0, kp + 4 * nc);
- round(fwd_rnd, b0, b1, kp + 5 * nc);
- round(fwd_rnd, b1, b0, kp + 6 * nc);
- round(fwd_rnd, b0, b1, kp + 7 * nc);
- round(fwd_rnd, b1, b0, kp + 8 * nc);
- round(fwd_lrnd, b0, b1, kp + 9 * nc);
+ case 14: round(fwd_rnd, b1, b0, kp - 4 * nc);
+ round(fwd_rnd, b0, b1, kp - 3 * nc);
+ case 12: round(fwd_rnd, b1, b0, kp - 2 * nc);
+ round(fwd_rnd, b0, b1, kp - nc);
+ case 10: round(fwd_rnd, b1, b0, kp );
+ round(fwd_rnd, b0, b1, kp + nc);
+ round(fwd_rnd, b1, b0, kp + 2 * nc);
+ round(fwd_rnd, b0, b1, kp + 3 * nc);
+ round(fwd_rnd, b1, b0, kp + 4 * nc);
+ round(fwd_rnd, b0, b1, kp + 5 * nc);
+ round(fwd_rnd, b1, b0, kp + 6 * nc);
+ round(fwd_rnd, b0, b1, kp + 7 * nc);
+ round(fwd_rnd, b1, b0, kp + 8 * nc);
+ round(fwd_lrnd, b0, b1, kp + 9 * nc);
}
#else
-
+
#if (ENC_UNROLL == PARTIAL)
- {
- aes_32t rnd;
+ { aes_32t rnd;
for(rnd = 0; rnd < (cx->n_rnd >> 1) - 1; ++rnd)
{
kp += nc;
- round(fwd_rnd, b1, b0, kp);
+ round(fwd_rnd, b1, b0, kp);
kp += nc;
- round(fwd_rnd, b0, b1, kp);
+ round(fwd_rnd, b0, b1, kp);
}
kp += nc;
round(fwd_rnd, b1, b0, kp);
#else
- {
- aes_32t rnd, *p0 = b0, *p1 = b1, *pt;
+ { aes_32t rnd, *p0 = b0, *p1 = b1, *pt;
for(rnd = 0; rnd < cx->n_rnd - 1; ++rnd)
{
kp += nc;
- round(fwd_rnd, p1, p0, kp);
+ round(fwd_rnd, p1, p0, kp);
pt = p0, p0 = p1, p1 = pt;
}
#endif
@@ -1836,8 +1764,7 @@ static aes_rval aes_enc_blk(const unsigned char in_blk[], unsigned char out_blk[
#endif
static aes_rval aes_dec_blk(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])
-{
- aes_32t locals(b0, b1);
+{ aes_32t locals(b0, b1);
const aes_32t *kp = cx->k_sch + nc * cx->n_rnd;
dec_imvars /* declare variables for inv_mcol() if needed */
@@ -1850,45 +1777,40 @@ static aes_rval aes_dec_blk(const unsigned char in_blk[], unsigned char out_blk[
kp = cx->k_sch + 9 * nc;
switch(cx->n_rnd)
{
- case 14:
- round(inv_rnd, b1, b0, kp + 4 * nc);
- round(inv_rnd, b0, b1, kp + 3 * nc);
- case 12:
- round(inv_rnd, b1, b0, kp + 2 * nc);
- round(inv_rnd, b0, b1, kp + nc);
- case 10:
- round(inv_rnd, b1, b0, kp);
- round(inv_rnd, b0, b1, kp - nc);
- round(inv_rnd, b1, b0, kp - 2 * nc);
- round(inv_rnd, b0, b1, kp - 3 * nc);
- round(inv_rnd, b1, b0, kp - 4 * nc);
- round(inv_rnd, b0, b1, kp - 5 * nc);
- round(inv_rnd, b1, b0, kp - 6 * nc);
- round(inv_rnd, b0, b1, kp - 7 * nc);
- round(inv_rnd, b1, b0, kp - 8 * nc);
- round(inv_lrnd, b0, b1, kp - 9 * nc);
+ case 14: round(inv_rnd, b1, b0, kp + 4 * nc);
+ round(inv_rnd, b0, b1, kp + 3 * nc);
+ case 12: round(inv_rnd, b1, b0, kp + 2 * nc);
+ round(inv_rnd, b0, b1, kp + nc );
+ case 10: round(inv_rnd, b1, b0, kp );
+ round(inv_rnd, b0, b1, kp - nc);
+ round(inv_rnd, b1, b0, kp - 2 * nc);
+ round(inv_rnd, b0, b1, kp - 3 * nc);
+ round(inv_rnd, b1, b0, kp - 4 * nc);
+ round(inv_rnd, b0, b1, kp - 5 * nc);
+ round(inv_rnd, b1, b0, kp - 6 * nc);
+ round(inv_rnd, b0, b1, kp - 7 * nc);
+ round(inv_rnd, b1, b0, kp - 8 * nc);
+ round(inv_lrnd, b0, b1, kp - 9 * nc);
}
#else
-
+
#if (DEC_UNROLL == PARTIAL)
- {
- aes_32t rnd;
+ { aes_32t rnd;
for(rnd = 0; rnd < (cx->n_rnd >> 1) - 1; ++rnd)
{
- kp -= nc;
- round(inv_rnd, b1, b0, kp);
- kp -= nc;
- round(inv_rnd, b0, b1, kp);
+ kp -= nc;
+ round(inv_rnd, b1, b0, kp);
+ kp -= nc;
+ round(inv_rnd, b0, b1, kp);
}
kp -= nc;
round(inv_rnd, b1, b0, kp);
#else
- {
- aes_32t rnd, *p0 = b0, *p1 = b1, *pt;
+ { aes_32t rnd, *p0 = b0, *p1 = b1, *pt;
for(rnd = 0; rnd < cx->n_rnd - 1; ++rnd)
{
kp -= nc;
- round(inv_rnd, p1, p0, kp);
+ round(inv_rnd, p1, p0, kp);
pt = p0, p0 = p1, p1 = pt;
}
#endif
@@ -1907,16 +1829,13 @@ static aes_rval aes_dec_blk(const unsigned char in_blk[], unsigned char out_blk[
| AP4_AesBlockCipher::AP4_AesBlockCipher
+---------------------------------------------------------------------*/
AP4_AesBlockCipher::AP4_AesBlockCipher(const AP4_UI08* key,
-CipherDirection direction) :
+ CipherDirection direction) :
m_Direction(direction)
{
m_Context = new aes_ctx;
- if(direction == AP4_BlockCipher::ENCRYPT)
- {
+ if (direction == AP4_BlockCipher::ENCRYPT) {
aes_enc_key(key, AP4_AES_KEY_LENGTH, m_Context);
- }
- else
- {
+ } else {
aes_dec_key(key, AP4_AES_KEY_LENGTH, m_Context);
}
}
@@ -1932,17 +1851,14 @@ AP4_AesBlockCipher::~AP4_AesBlockCipher()
/*----------------------------------------------------------------------
| AP4_AesBlockCipher::EncryptBlock
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_AesBlockCipher::ProcessBlock(const AP4_UI08* block_in,
-AP4_UI08* block_out)
+ AP4_UI08* block_out)
{
aes_rval result;
- if(m_Direction == AP4_BlockCipher::ENCRYPT)
- {
+ if (m_Direction == AP4_BlockCipher::ENCRYPT) {
result = aes_enc_blk(block_in, block_out, m_Context);
- }
- else
- {
+ } else {
result = aes_dec_blk(block_in, block_out, m_Context);
}
return result == aes_good ? AP4_SUCCESS : AP4_FAILURE;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.h b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.h
index 724e57ebe..353cf6473 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4AesBlockCipher.h
@@ -11,23 +11,23 @@
LICENSE TERMS
- The free distribution and use of this software in both source and binary
+ The free distribution and use of this software in both source and binary
form is allowed (with or without changes) provided that:
- 1. distributions of this source code include the above copyright
+ 1. distributions of this source code include the above copyright
notice, this list of conditions and the following disclaimer;
2. distributions in binary form include the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other associated materials;
- 3. the copyright holder's name is not used to endorse products
- built using this software without specific written permission.
+ 3. the copyright holder's name is not used to endorse products
+ built using this software without specific written permission.
DISCLAIMER
This software is provided 'as is' with no explicit or implied warranties
- in respect of its properties, including, but not limited to, correctness
+ in respect of its properties, including, but not limited to, correctness
and fitness for purpose.
-------------------------------------------------------------------------
Issue Date: 29/07/2002
@@ -61,13 +61,13 @@ class AP4_AesBlockCipher : public AP4_BlockCipher
{
public:
// constructor and destructor
- AP4_AesBlockCipher(const AP4_UI08* key,
+ AP4_AesBlockCipher(const AP4_UI08* key,
AP4_BlockCipher::CipherDirection direction);
- ~AP4_AesBlockCipher();
-
- // AP4_AesBlockCipher methods
- virtual AP4_Result ProcessBlock(const AP4_UI08* input,
- AP4_UI08* output);
+ ~AP4_AesBlockCipher();
+
+ // AP4_AesBlockCipher methods
+ virtual AP4_Result ProcessBlock(const AP4_UI08* input,
+ AP4_UI08* output);
private:
// members
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.cpp
index 8d9e81759..387f69453 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.cpp
@@ -28,7 +28,7 @@
/*
Portions of this code are based on the code of LibTomCrypt
- that was released into public domain by Tom St Denis.
+ that was released into public domain by Tom St Denis.
*/
/*----------------------------------------------------------------------
@@ -42,21 +42,20 @@
+---------------------------------------------------------------------*/
#define AP4_SHA256_BLOCK_SIZE 64
-static const AP4_UI32 AP4_Sha256_K[64] =
-{
- 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
- 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
- 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
- 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
- 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
- 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
- 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
- 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
- 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
- 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
- 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
- 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
- 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
+static const AP4_UI32 AP4_Sha256_K[64] = {
+ 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
+ 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
+ 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
+ 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
+ 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
+ 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
+ 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
+ 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
+ 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
+ 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
+ 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
+ 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
+ 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
};
/*----------------------------------------------------------------------
@@ -67,20 +66,20 @@ class AP4_DigestSha256
public:
AP4_DigestSha256();
virtual ~AP4_DigestSha256() {}
-
+
// AP4_Hmac methods
virtual AP4_Result Update(const AP4_UI08* data, AP4_Size data_size);
virtual AP4_Result Final(AP4_DataBuffer& digest);
-
+
private:
// methods
void CompressBlock(const AP4_UI08* block);
-
+
// members
- AP4_UI64 m_Length;
+ AP4_UI64 m_Length;
AP4_UI32 m_Pending;
- AP4_UI32 m_State[8];
- AP4_UI08 m_Buffer[64];
+ AP4_UI32 m_State[8];
+ AP4_UI08 m_Buffer[64];
};
/*----------------------------------------------------------------------
@@ -97,14 +96,13 @@ class AP4_HmacSha256 : public AP4_Hmac
{
public:
AP4_HmacSha256(const AP4_UI08* key, AP4_Size key_size);
-
+
// AP4_Hmac methods
- virtual AP4_Result Update(const AP4_UI08* data, AP4_Size data_size)
- {
+ virtual AP4_Result Update(const AP4_UI08* data, AP4_Size data_size) {
return m_InnerDigest.Update(data, data_size);
}
virtual AP4_Result Final(AP4_DataBuffer& buffer);
-
+
private:
AP4_DigestSha256 m_InnerDigest;
AP4_DigestSha256 m_OuterDigest;
@@ -117,14 +115,14 @@ AP4_DigestSha256::AP4_DigestSha256() :
m_Length(0),
m_Pending(0)
{
- m_State[0] = 0x6A09E667UL;
- m_State[1] = 0xBB67AE85UL;
- m_State[2] = 0x3C6EF372UL;
- m_State[3] = 0xA54FF53AUL;
- m_State[4] = 0x510E527FUL;
- m_State[5] = 0x9B05688CUL;
- m_State[6] = 0x1F83D9ABUL;
- m_State[7] = 0x5BE0CD19UL;
+ m_State[0] = 0x6A09E667UL;
+ m_State[1] = 0xBB67AE85UL;
+ m_State[2] = 0x3C6EF372UL;
+ m_State[3] = 0xA54FF53AUL;
+ m_State[4] = 0x510E527FUL;
+ m_State[5] = 0x9B05688CUL;
+ m_State[6] = 0x1F83D9ABUL;
+ m_State[7] = 0x5BE0CD19UL;
}
/*----------------------------------------------------------------------
@@ -134,7 +132,7 @@ AP4_DigestSha256::AP4_DigestSha256() :
( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
#define AP4_Sha256_Ch(x,y,z) (z ^ (x & (y ^ z)))
-#define AP4_Sha256_Maj(x,y,z) (((x | y) & z) | (x & y))
+#define AP4_Sha256_Maj(x,y,z) (((x | y) & z) | (x & y))
#define AP4_Sha256_S(x, n) AP4_Sha256_RORc((x), (n))
#define AP4_Sha256_R(x, n) (((x)&0xFFFFFFFFUL)>>(n))
#define AP4_Sha256_Sigma0(x) (AP4_Sha256_S(x, 2) ^ AP4_Sha256_S(x, 13) ^ AP4_Sha256_S(x, 22))
@@ -148,50 +146,38 @@ AP4_DigestSha256::AP4_DigestSha256() :
void
AP4_DigestSha256::CompressBlock(const AP4_UI08* block)
{
- AP4_UI32 S[8], W[64];
+ AP4_UI32 S[8], W[64];
- /* copy the state into S */
- for(unsigned int i = 0; i < 8; i++)
- {
- S[i] = m_State[i];
- }
+ /* copy the state into S */
+ for (unsigned int i = 0; i < 8; i++) {
+ S[i] = m_State[i];
+ }
- /* copy the 512-bit block into W[0..15] */
- for(unsigned int i = 0; i < 16; i++)
- {
- W[i] = AP4_BytesToUInt32BE(&block[4*i]);
+ /* copy the 512-bit block into W[0..15] */
+ for (unsigned int i = 0; i < 16; i++) {
+ W[i] = AP4_BytesToUInt32BE(&block[4*i]);
}
-
- /* fill W[16..63] */
- for(unsigned int i = 16; i < AP4_SHA256_BLOCK_SIZE; i++)
- {
- W[i] = AP4_Sha256_Gamma1(W[i-2]) + W[i-7] + AP4_Sha256_Gamma0(W[i-15]) + W[i-16];
- }
-
- /* compress */
- AP4_UI32 t, t0, t1;
- for(unsigned int i = 0; i < AP4_SHA256_BLOCK_SIZE; ++i)
- {
+
+ /* fill W[16..63] */
+ for (unsigned int i = 16; i < AP4_SHA256_BLOCK_SIZE; i++) {
+ W[i] = AP4_Sha256_Gamma1(W[i-2]) + W[i-7] + AP4_Sha256_Gamma0(W[i-15]) + W[i-16];
+ }
+
+ /* compress */
+ AP4_UI32 t, t0, t1;
+ for (unsigned int i = 0; i < AP4_SHA256_BLOCK_SIZE; ++i) {
t0 = S[7] + AP4_Sha256_Sigma1(S[4]) + AP4_Sha256_Ch(S[4], S[5], S[6]) + AP4_Sha256_K[i] + W[i];
t1 = AP4_Sha256_Sigma0(S[0]) + AP4_Sha256_Maj(S[0], S[1], S[2]);
S[3] += t0;
S[7] = t0 + t1;
- t = S[7];
- S[7] = S[6];
- S[6] = S[5];
- S[5] = S[4];
- S[4] = S[3];
- S[3] = S[2];
- S[2] = S[1];
- S[1] = S[0];
- S[0] = t;
- }
-
- /* feedback */
- for(unsigned int i = 0; i < 8; i++)
- {
- m_State[i] = m_State[i] + S[i];
- }
+ t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
+ S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
+ }
+
+ /* feedback */
+ for (unsigned int i = 0; i < 8; i++) {
+ m_State[i] = m_State[i] + S[i];
+ }
}
@@ -201,35 +187,29 @@ AP4_DigestSha256::CompressBlock(const AP4_UI08* block)
AP4_Result
AP4_DigestSha256::Update(const AP4_UI08* data, AP4_Size data_size)
{
- while(data_size > 0)
- {
- if(m_Pending == 0 && data_size >= AP4_SHA256_BLOCK_SIZE)
- {
- CompressBlock(data);
- m_Length += AP4_SHA256_BLOCK_SIZE * 8;
- data += AP4_SHA256_BLOCK_SIZE;
- data_size -= AP4_SHA256_BLOCK_SIZE;
- }
- else
- {
- unsigned int chunk = data_size;
- if(chunk > (AP4_SHA256_BLOCK_SIZE - m_Pending))
- {
+ while (data_size > 0) {
+ if (m_Pending == 0 && data_size >= AP4_SHA256_BLOCK_SIZE) {
+ CompressBlock(data);
+ m_Length += AP4_SHA256_BLOCK_SIZE * 8;
+ data += AP4_SHA256_BLOCK_SIZE;
+ data_size -= AP4_SHA256_BLOCK_SIZE;
+ } else {
+ unsigned int chunk = data_size;
+ if (chunk > (AP4_SHA256_BLOCK_SIZE - m_Pending)) {
chunk = AP4_SHA256_BLOCK_SIZE - m_Pending;
}
- AP4_CopyMemory(&m_Buffer[m_Pending], data, chunk);
- m_Pending += chunk;
- data += chunk;
- data_size -= chunk;
- if(m_Pending == AP4_SHA256_BLOCK_SIZE)
- {
- CompressBlock(m_Buffer);
- m_Length += 8 * AP4_SHA256_BLOCK_SIZE;
- m_Pending = 0;
- }
- }
- }
-
+ AP4_CopyMemory(&m_Buffer[m_Pending], data, chunk);
+ m_Pending += chunk;
+ data += chunk;
+ data_size -= chunk;
+ if (m_Pending == AP4_SHA256_BLOCK_SIZE) {
+ CompressBlock(m_Buffer);
+ m_Length += 8 * AP4_SHA256_BLOCK_SIZE;
+ m_Pending = 0;
+ }
+ }
+ }
+
return AP4_SUCCESS;
}
@@ -240,46 +220,42 @@ AP4_DigestSha256::Update(const AP4_UI08* data, AP4_Size data_size)
AP4_Result
AP4_DigestSha256::Final(AP4_DataBuffer& digest)
{
- /* increase the length of the message */
- m_Length += m_Pending * 8;
-
- /* append the '1' bit */
- m_Buffer[m_Pending++] = 0x80;
-
- /* if the length is currently above 56 bytes we append zeros
- * then compress. Then we can fall back to padding zeros and length
- * encoding like normal.
- */
- if(m_Pending > 56)
- {
- while(m_Pending < 64)
- {
- m_Buffer[m_Pending++] = 0;
- }
- CompressBlock(m_Buffer);
- m_Pending = 0;
- }
-
- /* pad upto 56 bytes of zeroes */
- while(m_Pending < 56)
- {
- m_Buffer[m_Pending++] = 0;
- }
-
- /* store length */
- AP4_BytesFromUInt64BE(&m_Buffer[56], m_Length);
- CompressBlock(m_Buffer);
-
- /* copy output */
+ /* increase the length of the message */
+ m_Length += m_Pending * 8;
+
+ /* append the '1' bit */
+ m_Buffer[m_Pending++] = 0x80;
+
+ /* if the length is currently above 56 bytes we append zeros
+ * then compress. Then we can fall back to padding zeros and length
+ * encoding like normal.
+ */
+ if (m_Pending > 56) {
+ while (m_Pending < 64) {
+ m_Buffer[m_Pending++] = 0;
+ }
+ CompressBlock(m_Buffer);
+ m_Pending = 0;
+ }
+
+ /* pad upto 56 bytes of zeroes */
+ while (m_Pending < 56) {
+ m_Buffer[m_Pending++] = 0;
+ }
+
+ /* store length */
+ AP4_BytesFromUInt64BE(&m_Buffer[56], m_Length);
+ CompressBlock(m_Buffer);
+
+ /* copy output */
digest.SetDataSize(32);
AP4_UI08* out = digest.UseData();
- for(unsigned int i = 0; i < 8; i++)
- {
- AP4_BytesFromUInt32BE(out, m_State[i]);
+ for (unsigned int i = 0; i < 8; i++) {
+ AP4_BytesFromUInt32BE(out, m_State[i]);
out += 4;
}
-
- return AP4_SUCCESS;
+
+ return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
@@ -287,12 +263,11 @@ AP4_DigestSha256::Final(AP4_DataBuffer& digest)
+---------------------------------------------------------------------*/
AP4_HmacSha256::AP4_HmacSha256(const AP4_UI08* key, AP4_Size key_size)
{
- AP4_UI08 workspace[AP4_SHA256_BLOCK_SIZE];
-
+ AP4_UI08 workspace[AP4_SHA256_BLOCK_SIZE];
+
/* if the key is larger than the block size, use a digest of the key */
AP4_DataBuffer hk;
- if(key_size > AP4_SHA256_BLOCK_SIZE)
- {
+ if (key_size > AP4_SHA256_BLOCK_SIZE) {
AP4_DigestSha256 kdigest;
kdigest.Update(key, key_size);
kdigest.Final(hk);
@@ -301,29 +276,25 @@ AP4_HmacSha256::AP4_HmacSha256(const AP4_UI08* key, AP4_Size key_size)
}
/* compute key XOR ipad */
- for(unsigned int i = 0; i < key_size; i++)
- {
- workspace[i] = key[i] ^ 0x36;
+ for (unsigned int i = 0; i < key_size; i++) {
+ workspace[i] = key[i] ^ 0x36;
}
- for(unsigned int i = key_size; i < AP4_SHA256_BLOCK_SIZE; i++)
- {
- workspace[i] = 0x36;
+ for (unsigned int i = key_size; i < AP4_SHA256_BLOCK_SIZE; i++) {
+ workspace[i] = 0x36;
}
-
- /* start the inner digest with (key XOR ipad) */
+
+ /* start the inner digest with (key XOR ipad) */
m_InnerDigest.Update(workspace, AP4_SHA256_BLOCK_SIZE);
/* compute key XOR opad */
- for(unsigned int i = 0; i < key_size; i++)
- {
- workspace[i] = key[i] ^ 0x5c;
+ for (unsigned int i = 0; i < key_size; i++) {
+ workspace[i] = key[i] ^ 0x5c;
}
- for(unsigned int i = key_size; i < AP4_SHA256_BLOCK_SIZE; i++)
- {
- workspace[i] = 0x5c;
+ for (unsigned int i = key_size; i < AP4_SHA256_BLOCK_SIZE; i++) {
+ workspace[i] = 0x5c;
}
-
- /* start the outer digest with (key XOR opad) */
+
+ /* start the outer digest with (key XOR opad) */
m_OuterDigest.Update(workspace, AP4_SHA256_BLOCK_SIZE);
}
@@ -337,7 +308,7 @@ AP4_HmacSha256::Final(AP4_DataBuffer& mac)
AP4_DataBuffer inner;
m_InnerDigest.Final(inner);
m_OuterDigest.Update(inner.GetData(), inner.GetDataSize());
-
+
/* return the value of the outer digest */
return m_OuterDigest.Final(mac);
}
@@ -346,19 +317,14 @@ AP4_HmacSha256::Final(AP4_DataBuffer& mac)
| AP4_Hmac::Create
+---------------------------------------------------------------------*/
AP4_Result
-AP4_Hmac::Create(Algorithm algorithm,
+AP4_Hmac::Create(Algorithm algorithm,
const AP4_UI08* key,
AP4_Size key_size,
AP4_Hmac*& hmac)
{
- switch(algorithm)
- {
- case SHA256:
- hmac = new AP4_HmacSha256(key, key_size);
- return AP4_SUCCESS;
- default:
- hmac = NULL;
- return AP4_ERROR_NOT_SUPPORTED;
+ switch (algorithm) {
+ case SHA256: hmac = new AP4_HmacSha256(key, key_size); return AP4_SUCCESS;
+ default: hmac = NULL; return AP4_ERROR_NOT_SUPPORTED;
}
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.h b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.h
index e8fe8d0c6..22957a0d4 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4Hmac.h
@@ -43,17 +43,16 @@ class AP4_Hmac
{
public:
// types
- typedef enum
- {
+ typedef enum {
SHA256
} Algorithm;
-
+
// class methods
- static AP4_Result Create(Algorithm algorithm,
+ static AP4_Result Create(Algorithm algorithm,
const AP4_UI08* key,
AP4_Size key_size,
AP4_Hmac*& hmac);
-
+
// methods
virtual ~AP4_Hmac() {}
virtual AP4_Result Update(const AP4_UI08* data, AP4_Size data_size) = 0;
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.cpp
index 9ab357126..3cc37f5ce 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.cpp
@@ -28,7 +28,7 @@
/*
Portions of this code are based on the code of LibTomCrypt
- that was released into public domain by Tom St Denis.
+ that was released into public domain by Tom St Denis.
*/
/*----------------------------------------------------------------------
@@ -46,59 +46,56 @@
| AP4_AesKeyWrap
+---------------------------------------------------------------------*/
AP4_Result
-AP4_AesKeyWrap(const AP4_UI08* kek,
- const AP4_UI08* cleartext_key,
+AP4_AesKeyWrap(const AP4_UI08* kek,
+ const AP4_UI08* cleartext_key,
AP4_Size cleartext_key_size,
AP4_DataBuffer& wrapped_key)
{
// check parameters
- if(cleartext_key_size % 8)
- {
+ if (cleartext_key_size % 8) {
// not a multiple of 64 bits
return AP4_ERROR_INVALID_PARAMETERS;
}
-
+
// the output size is (n+1)*64 bits
// where n is the number of 64-bit blocks
// of the cleartext key
- unsigned int n = cleartext_key_size / 8;
- wrapped_key.SetDataSize((n + 1) * 8);
-
+ unsigned int n = cleartext_key_size/8;
+ wrapped_key.SetDataSize((n+1)*8);
+
// Step 1. Initialize variables.
// Set A = IV, an initial value (0xA6)
// For i = 1 to n
// R[i] = P[i]
AP4_UI08* a = (AP4_UI08*)wrapped_key.UseData();
AP4_SetMemory(a, 0xA6, 8);
- AP4_UI08* r = a + 8;
+ AP4_UI08* r = a+8;
AP4_CopyMemory(r, cleartext_key, cleartext_key_size);
-
+
// Step 2. Calculate intermediate values.
// For j = 0 to 5
// For i=1 to n
// B = AES(K, A | R[i])
// A = MSB(64, B) ^ t where t = (n*j)+i
- // R[i] = LSB(64, B)
+ // R[i] = LSB(64, B)
AP4_AesBlockCipher block_cipher(kek, AP4_BlockCipher::ENCRYPT);
- for(unsigned int j = 0; j <= 5; j++)
- {
- r = a + 8;
- for(unsigned int i = 1; i <= n; i++)
- {
+ for (unsigned int j=0; j <= 5; j++) {
+ r = a + 8;
+ for (unsigned int i=1; i<=n; i++) {
AP4_UI08 workspace[16];
AP4_UI08 b[16];
AP4_CopyMemory(workspace, a, 8);
AP4_CopyMemory(&workspace[8], r, 8);
block_cipher.ProcessBlock(workspace, b);
AP4_CopyMemory(a, b, 8);
- a[7] ^= n * j + i;
+ a[7] ^= n*j+i;
AP4_CopyMemory(r, &b[8], 8);
r += 8;
- }
- }
-
+ }
+ }
+
// Step 3. Output the results.
- // (Nothing to do here since we've worked in-place
+ // (Nothing to do here since we've worked in-place
return AP4_SUCCESS;
}
@@ -112,25 +109,24 @@ AP4_AesKeyUnwrap(const AP4_UI08* kek,
AP4_DataBuffer& cleartext_key)
{
// check parameters
- if((wrapped_key_size % 8) || (wrapped_key_size < 24))
- {
+ if ((wrapped_key_size % 8) || (wrapped_key_size < 24)) {
// not a multiple of 64 bits or too small
return AP4_ERROR_INVALID_PARAMETERS;
}
-
+
// setup the output buffer
- unsigned int n = (wrapped_key_size / 8) - 1;
- cleartext_key.SetDataSize(n * 8);
-
+ unsigned int n = (wrapped_key_size/8)-1;
+ cleartext_key.SetDataSize(n*8);
+
// Step 1. Initialize variables.
// Set A = C[0]
// For i = 1 to n
// R[i] = C[i]
- AP4_UI08 a[8];
+ AP4_UI08 a[8];
AP4_CopyMemory(a, wrapped_key, 8);
AP4_UI08* r = (AP4_UI08*)cleartext_key.UseData();
- AP4_CopyMemory(r, wrapped_key + 8, 8 * n);
-
+ AP4_CopyMemory(r, wrapped_key+8, 8*n);
+
// Step 2. Compute intermediate values.
// For j = 5 to 0
// For i = n to 1
@@ -138,15 +134,13 @@ AP4_AesKeyUnwrap(const AP4_UI08* kek,
// A = MSB(64, B)
// R[i] = LSB(64, B)
AP4_AesBlockCipher block_cipher(kek, AP4_BlockCipher::DECRYPT);
- for(int j = 5; j >= 0; j--)
- {
- r = (AP4_UI08*)cleartext_key.UseData() + (n - 1) * 8;
- for(int i = n; i >= 1; i--)
- {
+ for (int j=5; j>=0; j--) {
+ r = (AP4_UI08*)cleartext_key.UseData()+(n-1)*8;
+ for (int i=n; i>=1; i--) {
AP4_UI08 workspace[16];
AP4_UI08 b[16];
AP4_CopyMemory(workspace, a, 8);
- workspace[7] ^= (n * j) + i;
+ workspace[7] ^= (n*j)+i;
AP4_CopyMemory(&workspace[8], r, 8);
block_cipher.ProcessBlock(workspace, b);
AP4_CopyMemory(a, b, 8);
@@ -154,7 +148,7 @@ AP4_AesKeyUnwrap(const AP4_UI08* kek,
r -= 8;
}
}
-
+
// Step 3. Output results.
// If A is an appropriate initial value (see 2.2.3),
// Then
@@ -162,14 +156,12 @@ AP4_AesKeyUnwrap(const AP4_UI08* kek,
// P[i] = R[i]
// Else
// Return an error
- for(unsigned int i = 0; i < 8; i++)
- {
- if(a[i] != 0xA6)
- {
+ for (unsigned int i=0; i<8; i++) {
+ if (a[i] != 0xA6) {
cleartext_key.SetDataSize(0);
return AP4_ERROR_INVALID_FORMAT;
}
- }
+ }
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.h b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.h
index 95ba65711..d0db038e9 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4KeyWrap.h
@@ -39,11 +39,11 @@
/*----------------------------------------------------------------------
| functions
+---------------------------------------------------------------------*/
-AP4_Result AP4_AesKeyWrap(const AP4_UI08* kek,
- const AP4_UI08* cleartext_key,
+AP4_Result AP4_AesKeyWrap(const AP4_UI08* kek,
+ const AP4_UI08* cleartext_key,
AP4_Size cleartext_key_size,
AP4_DataBuffer& wrapped_key);
-
+
AP4_Result AP4_AesKeyUnwrap(const AP4_UI08* kek,
const AP4_UI08* wrapped_key,
AP4_Size wrapped_key_size,
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.cpp b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.cpp
index cbb7d9f57..0b9320f5c 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.cpp
@@ -36,22 +36,19 @@
| AP4_CtrStreamCipher::AP4_CtrStreamCipher
+---------------------------------------------------------------------*/
AP4_CtrStreamCipher::AP4_CtrStreamCipher(AP4_BlockCipher* block_cipher,
- const AP4_UI08* salt,
- AP4_Size counter_size) :
+ const AP4_UI08* salt,
+ AP4_Size counter_size) :
m_StreamOffset(0),
m_CounterSize(counter_size),
m_BlockCipher(block_cipher)
{
- if(m_CounterSize > 16) m_CounterSize = 16;
+ if (m_CounterSize > 16) m_CounterSize = 16;
// use the salt to initialize the base counter
- if(salt)
- {
+ if (salt) {
// initialize the base counter with a salting key
AP4_CopyMemory(m_BaseCounter, salt, AP4_CIPHER_BLOCK_SIZE);
- }
- else
- {
+ } else {
// initialize the base counter with zeros
AP4_SetMemory(m_BaseCounter, 0, AP4_CIPHER_BLOCK_SIZE);
}
@@ -75,13 +72,10 @@ AP4_CtrStreamCipher::~AP4_CtrStreamCipher()
AP4_Result
AP4_CtrStreamCipher::SetIV(const AP4_UI08* counter)
{
- if(counter)
- {
+ if (counter) {
AP4_CopyMemory(&m_BaseCounter[AP4_CIPHER_BLOCK_SIZE-m_CounterSize],
counter, m_CounterSize);
- }
- else
- {
+ } else {
AP4_SetMemory(&m_BaseCounter[AP4_CIPHER_BLOCK_SIZE-m_CounterSize],
0, m_CounterSize);
}
@@ -98,19 +92,18 @@ AP4_CtrStreamCipher::SetStreamOffset(AP4_UI64 offset,
AP4_Cardinal* preroll)
{
// do nothing if we're already at that offset
- if(offset == m_StreamOffset) return AP4_SUCCESS;
+ if (offset == m_StreamOffset) return AP4_SUCCESS;
// update the offset
m_StreamOffset = offset;
// update the key stream if necessary
- if(m_StreamOffset & 0xF)
- {
+ if (m_StreamOffset & 0xF) {
UpdateKeyStream();
}
-
- if(preroll != NULL) *preroll = 0;
-
+
+ if (preroll != NULL) *preroll = 0;
+
return AP4_SUCCESS;
}
@@ -121,25 +114,23 @@ void
AP4_CtrStreamCipher::UpdateKeyStream()
{
// setup counter offset bytes
- AP4_UI64 counter_offset = m_StreamOffset / AP4_CIPHER_BLOCK_SIZE;
+ AP4_UI64 counter_offset = m_StreamOffset/AP4_CIPHER_BLOCK_SIZE;
AP4_UI08 counter_offset_bytes[8];
AP4_BytesFromUInt64BE(counter_offset_bytes, counter_offset);
-
+
// compute the new counter
AP4_UI08 counter_block[AP4_CIPHER_BLOCK_SIZE];
unsigned int carry = 0;
- for(unsigned int i = 0; i < m_CounterSize; i++)
- {
- unsigned int o = AP4_CIPHER_BLOCK_SIZE - 1 - i;
+ for (unsigned int i=0; i<m_CounterSize; i++) {
+ unsigned int o = AP4_CIPHER_BLOCK_SIZE-1-i;
unsigned int x = m_BaseCounter[o];
- unsigned int y = (i < 8) ? counter_offset_bytes[7-i] : 0;
- unsigned int sum = x + y + carry;
- counter_block[o] = (AP4_UI08)(sum & 0xFF);
- carry = ((sum >= 0x100) ? 1 : 0);
+ unsigned int y = (i<8)?counter_offset_bytes[7-i]:0;
+ unsigned int sum = x+y+carry;
+ counter_block[o] = (AP4_UI08)(sum&0xFF);
+ carry = ((sum >= 0x100)?1:0);
}
- for(unsigned int i = m_CounterSize; i < AP4_CIPHER_BLOCK_SIZE; i++)
- {
- unsigned int o = AP4_CIPHER_BLOCK_SIZE - 1 - i;
+ for (unsigned int i=m_CounterSize; i<AP4_CIPHER_BLOCK_SIZE; i++) {
+ unsigned int o = AP4_CIPHER_BLOCK_SIZE-1-i;
counter_block[o] = m_BaseCounter[o];
}
@@ -151,44 +142,40 @@ AP4_CtrStreamCipher::UpdateKeyStream()
| AP4_CtrStreamCipher::ProcessBuffer
+---------------------------------------------------------------------*/
AP4_Result
-AP4_CtrStreamCipher::ProcessBuffer(const AP4_UI08* in,
+AP4_CtrStreamCipher::ProcessBuffer(const AP4_UI08* in,
AP4_Size in_size,
- AP4_UI08* out,
+ AP4_UI08* out,
AP4_Size* out_size /* = NULL */,
bool /* is_last_buffer */)
{
- if(m_BlockCipher == NULL) return AP4_ERROR_INVALID_STATE;
-
- if(out_size != NULL && *out_size < in_size)
- {
+ if (m_BlockCipher == NULL) return AP4_ERROR_INVALID_STATE;
+
+ if (out_size != NULL && *out_size < in_size) {
return AP4_ERROR_BUFFER_TOO_SMALL;
}
- // in CTR mode, the output is the same size as the input
- if(out_size != NULL) *out_size = in_size;
+ // in CTR mode, the output is the same size as the input
+ if (out_size != NULL) *out_size = in_size;
// process all the bytes in the buffer
- while(in_size)
- {
+ while (in_size) {
// compute the number of bytes available in this chunk
- AP4_UI32 index = (AP4_UI32)(m_StreamOffset & (AP4_CIPHER_BLOCK_SIZE - 1));
+ AP4_UI32 index = (AP4_UI32)(m_StreamOffset & (AP4_CIPHER_BLOCK_SIZE-1));
AP4_UI32 chunk;
// update the key stream if we are on a boundary
- if(index == 0)
- {
+ if (index == 0) {
UpdateKeyStream();
chunk = AP4_CIPHER_BLOCK_SIZE;
}
// compute the number of bytes remaining in the chunk
chunk = AP4_CIPHER_BLOCK_SIZE - index;
- if(chunk > in_size) chunk = in_size;
+ if (chunk > in_size) chunk = in_size;
// encrypt/decrypt the chunk
AP4_UI08* x = &m_XBlock[index];
- for(AP4_UI32 i = 0; i < chunk; i++)
- {
+ for (AP4_UI32 i = 0; i < chunk; i++) {
*out++ = *in++ ^ *x++;
}
@@ -196,7 +183,7 @@ AP4_CtrStreamCipher::ProcessBuffer(const AP4_UI08* in,
m_StreamOffset += chunk;
in_size -= chunk;
}
-
+
return AP4_SUCCESS;
}
@@ -204,7 +191,7 @@ AP4_CtrStreamCipher::ProcessBuffer(const AP4_UI08* in,
| AP4_CbcStreamCipher::AP4_CbcStreamCipher
+---------------------------------------------------------------------*/
AP4_CbcStreamCipher::AP4_CbcStreamCipher(AP4_BlockCipher* block_cipher,
- CipherDirection direction) :
+ CipherDirection direction) :
m_Direction(direction),
m_StreamOffset(0),
m_OutputSkip(0),
@@ -247,43 +234,38 @@ AP4_CbcStreamCipher::SetStreamOffset(AP4_UI64 offset,
AP4_Cardinal* preroll)
{
// does not make sense for encryption
- if(m_Direction == AP4_StreamCipher::ENCRYPT) return AP4_ERROR_NOT_SUPPORTED;
-
+ if (m_Direction == AP4_StreamCipher::ENCRYPT) return AP4_ERROR_NOT_SUPPORTED;
+
// check params
- if(preroll == NULL) return AP4_ERROR_INVALID_PARAMETERS;
+ if (preroll == NULL) return AP4_ERROR_INVALID_PARAMETERS;
// reset the end of stream flag
m_Eos = false;
-
+
// special cases
- if(offset == 0)
- {
+ if (offset == 0) {
*preroll = 0;
return SetIV(m_Iv);
}
- if(offset == m_StreamOffset)
- {
+ if (offset == m_StreamOffset) {
*preroll = m_PrerollByteCount;
- m_OutputSkip = (AP4_Size)(offset % AP4_CIPHER_BLOCK_SIZE);
+ m_OutputSkip = (AP4_Size)(offset%AP4_CIPHER_BLOCK_SIZE);
return AP4_SUCCESS;
}
// other cases
- if(offset < AP4_CIPHER_BLOCK_SIZE)
- {
+ if (offset < AP4_CIPHER_BLOCK_SIZE) {
// reset the IV to the output block cache
AP4_CopyMemory(m_OutBlockCache, m_Iv, AP4_CIPHER_BLOCK_SIZE);
m_PrerollByteCount = (AP4_Cardinal) offset;
+ } else {
+ m_PrerollByteCount = (AP4_Cardinal) ((offset%AP4_CIPHER_BLOCK_SIZE)
+ + AP4_CIPHER_BLOCK_SIZE);
}
- else
- {
- m_PrerollByteCount = (AP4_Cardinal)((offset % AP4_CIPHER_BLOCK_SIZE)
- + AP4_CIPHER_BLOCK_SIZE);
- }
-
+
*preroll = m_PrerollByteCount;
m_StreamOffset = offset;
- m_OutputSkip = (AP4_Size)(offset % AP4_CIPHER_BLOCK_SIZE);
+ m_OutputSkip = (AP4_Size)(offset%AP4_CIPHER_BLOCK_SIZE);
return AP4_SUCCESS;
}
@@ -292,71 +274,60 @@ AP4_CbcStreamCipher::SetStreamOffset(AP4_UI64 offset,
| AP4_CbcStreamCipher::ProcessBuffer
+---------------------------------------------------------------------*/
AP4_Result
-AP4_CbcStreamCipher::ProcessBuffer(const AP4_UI08* in,
+AP4_CbcStreamCipher::ProcessBuffer(const AP4_UI08* in,
AP4_Size in_size,
- AP4_UI08* out,
+ AP4_UI08* out,
AP4_Size* out_size,
bool is_last_buffer /* = false */)
{
// check the parameters
- if(out_size == NULL) return AP4_ERROR_INVALID_PARAMETERS;
-
+ if (out_size == NULL) return AP4_ERROR_INVALID_PARAMETERS;
+
// check the state
- if(m_BlockCipher == NULL || m_Eos)
- {
+ if (m_BlockCipher == NULL || m_Eos) {
*out_size = 0;
return AP4_ERROR_INVALID_STATE;
}
- if(is_last_buffer) m_Eos = true;
-
+ if (is_last_buffer) m_Eos = true;
+
// if there was a previous call to SetStreamOffset that set m_PrerollByteCount,
- // we require that this call provides the at least entire preroll data
- if(m_PrerollByteCount)
- {
- if(in_size < m_PrerollByteCount)
- {
+ // we require that this call provides the at least entire preroll data
+ if (m_PrerollByteCount) {
+ if (in_size < m_PrerollByteCount) {
*out_size = 0;
return AP4_ERROR_NOT_ENOUGH_DATA;
}
}
// compute how many blocks we span
- AP4_UI64 start_block = m_StreamOffset / AP4_CIPHER_BLOCK_SIZE;
- AP4_UI64 end_block = (m_StreamOffset + in_size - m_PrerollByteCount) / AP4_CIPHER_BLOCK_SIZE;
- AP4_UI32 blocks_needed = (AP4_UI32)(end_block - start_block);
+ AP4_UI64 start_block = m_StreamOffset/AP4_CIPHER_BLOCK_SIZE;
+ AP4_UI64 end_block = (m_StreamOffset+in_size-m_PrerollByteCount)/AP4_CIPHER_BLOCK_SIZE;
+ AP4_UI32 blocks_needed = (AP4_UI32)(end_block-start_block);
- if(m_Direction == ENCRYPT)
- {
+ if (m_Direction == ENCRYPT) {
// compute how many blocks we will need to produce
unsigned int padded_in_size = in_size;
AP4_UI08 pad_byte = 0;
- if(is_last_buffer)
- {
+ if (is_last_buffer) {
++blocks_needed;
- pad_byte = AP4_CIPHER_BLOCK_SIZE - (AP4_UI08)((m_StreamOffset + in_size) % AP4_CIPHER_BLOCK_SIZE);
+ pad_byte = AP4_CIPHER_BLOCK_SIZE-(AP4_UI08)((m_StreamOffset+in_size)%AP4_CIPHER_BLOCK_SIZE);
padded_in_size += pad_byte;
}
- if(*out_size < blocks_needed * AP4_CIPHER_BLOCK_SIZE)
- {
- *out_size = blocks_needed * AP4_CIPHER_BLOCK_SIZE;
+ if (*out_size < blocks_needed*AP4_CIPHER_BLOCK_SIZE) {
+ *out_size = blocks_needed*AP4_CIPHER_BLOCK_SIZE;
return AP4_ERROR_BUFFER_TOO_SMALL;
}
- *out_size = blocks_needed * AP4_CIPHER_BLOCK_SIZE;
+ *out_size = blocks_needed*AP4_CIPHER_BLOCK_SIZE;
- unsigned int position = (unsigned int)(m_StreamOffset % AP4_CIPHER_BLOCK_SIZE);
+ unsigned int position = (unsigned int)(m_StreamOffset%AP4_CIPHER_BLOCK_SIZE);
m_StreamOffset += in_size;
- for(unsigned int x = 0; x < padded_in_size; x++)
- {
- if(x < in_size)
- {
+ for (unsigned int x=0; x<padded_in_size; x++) {
+ if (x < in_size) {
m_InBlockCache[position] = in[x] ^ m_OutBlockCache[position];
+ } else {
+ m_InBlockCache[position] = pad_byte ^ m_OutBlockCache[position];
}
- else
- {
- m_InBlockCache[position] = pad_byte ^ m_OutBlockCache[position];
- }
- if(++position == AP4_CIPHER_BLOCK_SIZE)
- {
+ if (++position == AP4_CIPHER_BLOCK_SIZE) {
// encrypt and emit a block
m_BlockCipher->ProcessBlock(m_InBlockCache, m_OutBlockCache);
AP4_CopyMemory(out, m_OutBlockCache, AP4_CIPHER_BLOCK_SIZE);
@@ -364,27 +335,21 @@ AP4_CbcStreamCipher::ProcessBuffer(const AP4_UI08* in,
position = 0;
}
}
- }
- else
- {
+ } else {
// compute how many blocks we may produce
- AP4_Size bytes_produced = blocks_needed * AP4_CIPHER_BLOCK_SIZE;
- if(bytes_produced > m_OutputSkip)
- {
+ AP4_Size bytes_produced = blocks_needed*AP4_CIPHER_BLOCK_SIZE;
+ if (bytes_produced > m_OutputSkip) {
bytes_produced -= m_OutputSkip;
}
- if(*out_size < bytes_produced)
- {
+ if (*out_size < bytes_produced) {
*out_size = bytes_produced;
return AP4_ERROR_BUFFER_TOO_SMALL;
}
*out_size = bytes_produced;
-
- // if we've just been seeked (SetStreamOffset),
- if(m_PrerollByteCount > 0)
- {
- if(m_PrerollByteCount >= AP4_CIPHER_BLOCK_SIZE)
- {
+
+ // if we've just been seeked (SetStreamOffset),
+ if (m_PrerollByteCount > 0) {
+ if (m_PrerollByteCount >= AP4_CIPHER_BLOCK_SIZE) {
// fill the outblock cache with the first 16 bytes
AP4_CopyMemory(m_OutBlockCache, in, AP4_CIPHER_BLOCK_SIZE);
in += AP4_CIPHER_BLOCK_SIZE;
@@ -393,10 +358,9 @@ AP4_CbcStreamCipher::ProcessBuffer(const AP4_UI08* in,
}
AP4_ASSERT(m_PrerollByteCount < 16);
-
+
// fill m_InBlockCache with the input for the remaining m_PrerollByteCount
- if(m_PrerollByteCount)
- {
+ if (m_PrerollByteCount) {
AP4_CopyMemory(m_InBlockCache, in, m_PrerollByteCount);
in += m_PrerollByteCount;
in_size -= m_PrerollByteCount;
@@ -404,49 +368,43 @@ AP4_CbcStreamCipher::ProcessBuffer(const AP4_UI08* in,
}
}
- unsigned int position = (unsigned int)(m_StreamOffset % AP4_CIPHER_BLOCK_SIZE);
+ unsigned int position = (unsigned int)(m_StreamOffset%AP4_CIPHER_BLOCK_SIZE);
m_StreamOffset += in_size;
- for(unsigned int x = 0; x < in_size; x++)
- {
+ for (unsigned int x=0; x<in_size; x++) {
m_InBlockCache[position] = in[x];
- if(++position == AP4_CIPHER_BLOCK_SIZE)
- {
+ if (++position == AP4_CIPHER_BLOCK_SIZE) {
// decrypt a block
AP4_UI08 out_block[AP4_CIPHER_BLOCK_SIZE];
m_BlockCipher->ProcessBlock(m_InBlockCache, out_block);
- for(unsigned int y = 0; y < AP4_CIPHER_BLOCK_SIZE; y++)
- {
+ for (unsigned int y=0; y<AP4_CIPHER_BLOCK_SIZE; y++) {
out_block[y] ^= m_OutBlockCache[y];
}
AP4_CopyMemory(m_OutBlockCache, m_InBlockCache, AP4_CIPHER_BLOCK_SIZE);
-
+
// emit the block (or partial block) to the out buffer
- unsigned int out_chunk = AP4_CIPHER_BLOCK_SIZE - m_OutputSkip;
- AP4_CopyMemory(out, out_block + m_OutputSkip, out_chunk);
+ unsigned int out_chunk = AP4_CIPHER_BLOCK_SIZE-m_OutputSkip;
+ AP4_CopyMemory(out, out_block+m_OutputSkip, out_chunk);
out += out_chunk;
position = 0;
m_OutputSkip = 0;
}
}
- if(is_last_buffer && m_Direction == DECRYPT)
- {
+ if (is_last_buffer && m_Direction == DECRYPT) {
// check that we have fed an integral number of blocks
- if(m_StreamOffset % AP4_CIPHER_BLOCK_SIZE != 0)
- {
+ if (m_StreamOffset%AP4_CIPHER_BLOCK_SIZE != 0) {
*out_size = 0;
return AP4_ERROR_INVALID_PARAMETERS;
}
// remove the padding
AP4_UI08 pad_byte = out[-1];
- if(pad_byte == 0 || pad_byte > AP4_CIPHER_BLOCK_SIZE)
- {
+ if (pad_byte == 0 || pad_byte > AP4_CIPHER_BLOCK_SIZE) {
*out_size = 0;
return AP4_ERROR_INVALID_FORMAT;
}
*out_size -= pad_byte;
}
}
-
+
return AP4_SUCCESS;
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.h b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.h
index ca4893d16..9fcec8136 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/Crypto/Ap4StreamCipher.h
@@ -39,7 +39,7 @@
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
-// we only support this for now
+// we only support this for now
const unsigned int AP4_CIPHER_BLOCK_SIZE = 16;
/*----------------------------------------------------------------------
@@ -49,29 +49,28 @@ class AP4_StreamCipher
{
public:
// types
- typedef enum
- {
+ typedef enum {
ENCRYPT,
DECRYPT
} CipherDirection;
-
+
// methods
virtual ~AP4_StreamCipher() {}
-
+
virtual AP4_UI64 GetStreamOffset() = 0;
-
+
virtual AP4_Result ProcessBuffer(const AP4_UI08* in,
AP4_Size in_size,
AP4_UI08* out,
AP4_Size* out_size,
bool is_last_buffer = false) = 0;
-
+
// preroll gives the number of bytes you have to preroll your input and feed
- // it through ProcessBuffer (in one shot) in order to be able to spit out
+ // it through ProcessBuffer (in one shot) in order to be able to spit out
// the output at the given offset
virtual AP4_Result SetStreamOffset(AP4_UI64 offset,
AP4_Cardinal* preroll) = 0;
-
+
virtual AP4_Result SetIV(const AP4_UI08* iv) = 0;
virtual const AP4_UI08* GetIV() = 0;
};
@@ -83,35 +82,29 @@ public:
class AP4_CtrStreamCipher : public AP4_StreamCipher
{
public:
- // methods
+ // methods
/**
* The block cipher is passed with transfer of ownership (it will
* be destroyed when this object is destroyed).
*/
- AP4_CtrStreamCipher(AP4_BlockCipher* block_cipher,
+ AP4_CtrStreamCipher(AP4_BlockCipher* block_cipher,
const AP4_UI08* salt,
AP4_Size counter_size);
~AP4_CtrStreamCipher();
-
+
// AP4_StreamCipher implementation
virtual AP4_Result SetStreamOffset(AP4_UI64 offset,
- AP4_Cardinal* preroll = NULL);
- virtual AP4_UI64 GetStreamOffset()
- {
- return m_StreamOffset;
- }
+ AP4_Cardinal* preroll = NULL);
+ virtual AP4_UI64 GetStreamOffset() { return m_StreamOffset; }
virtual AP4_Result ProcessBuffer(const AP4_UI08* in,
AP4_Size in_size,
AP4_UI08* out,
AP4_Size* out_size = NULL,
bool is_last_buffer = false);
-
+
virtual AP4_Result SetIV(const AP4_UI08* iv);
- virtual const AP4_UI08* GetIV()
- {
- return m_BaseCounter;
- }
+ virtual const AP4_UI08* GetIV() { return m_BaseCounter; }
private:
// methods
@@ -140,24 +133,18 @@ public:
*/
AP4_CbcStreamCipher(AP4_BlockCipher* block_cipher, CipherDirection direction);
~AP4_CbcStreamCipher();
-
+
// AP4_StreamCipher implementation
virtual AP4_Result SetStreamOffset(AP4_UI64 offset,
AP4_Cardinal* preroll);
- virtual AP4_UI64 GetStreamOffset()
- {
- return m_StreamOffset;
- }
+ virtual AP4_UI64 GetStreamOffset() { return m_StreamOffset; }
virtual AP4_Result ProcessBuffer(const AP4_UI08* in,
AP4_Size in_size,
AP4_UI08* out,
AP4_Size* out_size,
bool is_last_buffer = false);
virtual AP4_Result SetIV(const AP4_UI08* iv);
- virtual const AP4_UI08* GetIV()
- {
- return m_Iv;
- };
+ virtual const AP4_UI08* GetIV() { return m_Iv; };
private:
// members
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.cpp b/src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.cpp
index 0a00e3ecb..5f97839d9 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.cpp
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - MetaData
+| AP4 - MetaData
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -50,8 +50,7 @@ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_DataAtom)
/*----------------------------------------------------------------------
| metadata keys
+---------------------------------------------------------------------*/
-static const AP4_MetaData::KeyInfo AP4_MetaData_KeyInfos [] =
-{
+static const AP4_MetaData::KeyInfo AP4_MetaData_KeyInfos [] = {
{"Name", "Name", AP4_ATOM_TYPE_cNAM, AP4_MetaData::Value::TYPE_STRING_UTF_8},
{"Artist", "Artist", AP4_ATOM_TYPE_cART, AP4_MetaData::Value::TYPE_STRING_UTF_8},
{"AlbumArtist", "Album Artist", AP4_ATOM_TYPE_aART, AP4_MetaData::Value::TYPE_STRING_UTF_8},
@@ -98,13 +97,13 @@ static const AP4_MetaData::KeyInfo AP4_MetaData_KeyInfos [] =
{"Author", "Author", AP4_ATOM_TYPE_AUTH, AP4_MetaData::Value::TYPE_STRING_UTF_8},
};
AP4_Array<AP4_MetaData::KeyInfo> AP4_MetaData::KeyInfos(
- AP4_MetaData_KeyInfos,
- sizeof(AP4_MetaData_KeyInfos) / sizeof(KeyInfo));
+ AP4_MetaData_KeyInfos,
+ sizeof(AP4_MetaData_KeyInfos)/sizeof(KeyInfo));
/*----------------------------------------------------------------------
| genre IDs
+---------------------------------------------------------------------*/
-static const char* const Ap4Id3Genres[] =
+static const char* const Ap4Id3Genres[] =
{
"Blues",
"Classic Rock",
@@ -235,8 +234,7 @@ static const char* const Ap4Id3Genres[] =
};
static const char*
-Ap4StikNames[] =
-{
+Ap4StikNames[] = {
"Movie", // 0
"Normal", // 1
"Audiobook", // 2
@@ -246,7 +244,7 @@ Ap4StikNames[] =
"Music Video", // 6
"?", // 7
"?", // 8
- "Short Film", // 9
+ "Short Film", // 9
"TV Show", // 10
"Booklet", // 11
"?", // 12
@@ -287,8 +285,7 @@ const AP4_Size AP4_DATA_ATOM_MAX_SIZE = 0x40000000;
/*----------------------------------------------------------------------
| 3GPP localized string atoms
+---------------------------------------------------------------------*/
-const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::_3gppLocalizedStringTypes[] =
-{
+const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::_3gppLocalizedStringTypes[] = {
AP4_ATOM_TYPE_TITL,
AP4_ATOM_TYPE_DSCP,
AP4_ATOM_TYPE_CPRT,
@@ -296,17 +293,15 @@ const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::_3gppLocalizedStringTypes[] =
AP4_ATOM_TYPE_AUTH,
AP4_ATOM_TYPE_GNRE
};
-const AP4_MetaDataAtomTypeHandler::TypeList AP4_MetaDataAtomTypeHandler::_3gppLocalizedStringTypeList =
-{
+const AP4_MetaDataAtomTypeHandler::TypeList AP4_MetaDataAtomTypeHandler::_3gppLocalizedStringTypeList = {
_3gppLocalizedStringTypes,
- sizeof(_3gppLocalizedStringTypes) / sizeof(_3gppLocalizedStringTypes[0])
+ sizeof(_3gppLocalizedStringTypes)/sizeof(_3gppLocalizedStringTypes[0])
};
/*----------------------------------------------------------------------
| other 3GPP atoms
+---------------------------------------------------------------------*/
-const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::_3gppOtherTypes[] =
-{
+const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::_3gppOtherTypes[] = {
AP4_ATOM_TYPE_RTNG,
AP4_ATOM_TYPE_CLSF,
AP4_ATOM_TYPE_KYWD,
@@ -314,32 +309,29 @@ const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::_3gppOtherTypes[] =
AP4_ATOM_TYPE_ALBM,
AP4_ATOM_TYPE_YRRC,
};
-const AP4_MetaDataAtomTypeHandler::TypeList AP4_MetaDataAtomTypeHandler::_3gppOtherTypeList =
-{
+const AP4_MetaDataAtomTypeHandler::TypeList AP4_MetaDataAtomTypeHandler::_3gppOtherTypeList = {
_3gppOtherTypes,
- sizeof(_3gppOtherTypes) / sizeof(_3gppOtherTypes[0])
+ sizeof(_3gppOtherTypes)/sizeof(_3gppOtherTypes[0])
};
/*----------------------------------------------------------------------
| DCF string atoms
+---------------------------------------------------------------------*/
-const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::DcfStringTypes[] =
-{
+const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::DcfStringTypes[] = {
AP4_ATOM_TYPE_ICNU,
AP4_ATOM_TYPE_INFU,
AP4_ATOM_TYPE_CVRU,
AP4_ATOM_TYPE_LRCU
};
-const AP4_MetaDataAtomTypeHandler::TypeList AP4_MetaDataAtomTypeHandler::DcfStringTypeList =
-{
+const AP4_MetaDataAtomTypeHandler::TypeList AP4_MetaDataAtomTypeHandler::DcfStringTypeList = {
DcfStringTypes,
- sizeof(DcfStringTypes) / sizeof(DcfStringTypes[0])
+ sizeof(DcfStringTypes)/sizeof(DcfStringTypes[0])
};
/*----------------------------------------------------------------------
| atom type lists
+---------------------------------------------------------------------*/
-const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::IlstTypes[] =
+const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::IlstTypes[] =
{
AP4_ATOM_TYPE_dddd,
AP4_ATOM_TYPE_cNAM,
@@ -388,16 +380,15 @@ const AP4_Atom::Type AP4_MetaDataAtomTypeHandler::IlstTypes[] =
AP4_ATOM_TYPE_SOCO,
AP4_ATOM_TYPE_SOSN
};
-const AP4_MetaDataAtomTypeHandler::TypeList AP4_MetaDataAtomTypeHandler::IlstTypeList =
-{
+const AP4_MetaDataAtomTypeHandler::TypeList AP4_MetaDataAtomTypeHandler::IlstTypeList = {
IlstTypes,
- sizeof(IlstTypes) / sizeof(IlstTypes[0])
+ sizeof(IlstTypes)/sizeof(IlstTypes[0])
};
/*----------------------------------------------------------------------
| AP4_MetaDataAtomTypeHandler::CreateAtom
+---------------------------------------------------------------------*/
-AP4_Result
+AP4_Result
AP4_MetaDataAtomTypeHandler::CreateAtom(AP4_Atom::Type type,
AP4_UI32 size,
AP4_ByteStream& stream,
@@ -406,46 +397,31 @@ AP4_MetaDataAtomTypeHandler::CreateAtom(AP4_Atom::Type type,
{
atom = NULL;
- if(context == AP4_ATOM_TYPE_ILST)
- {
- if(IsTypeInList(type, IlstTypeList))
- {
+ if (context == AP4_ATOM_TYPE_ILST) {
+ if (IsTypeInList(type, IlstTypeList)) {
m_AtomFactory->PushContext(type);
atom = AP4_ContainerAtom::Create(type, size, false, false, stream, *m_AtomFactory);
m_AtomFactory->PopContext();
}
- }
- else if(type == AP4_ATOM_TYPE_DATA)
- {
- if(IsTypeInList(context, IlstTypeList))
- {
+ } else if (type == AP4_ATOM_TYPE_DATA) {
+ if (IsTypeInList(context, IlstTypeList)) {
atom = new AP4_DataAtom(size, stream);
}
- }
- else if(context == AP4_ATOM_TYPE_dddd)
- {
- if(type == AP4_ATOM_TYPE_MEAN || type == AP4_ATOM_TYPE_NAME)
- {
+ } else if (context == AP4_ATOM_TYPE_dddd) {
+ if (type == AP4_ATOM_TYPE_MEAN || type == AP4_ATOM_TYPE_NAME) {
atom = new AP4_MetaDataStringAtom(type, size, stream);
}
- }
- else if(context == AP4_ATOM_TYPE_UDTA)
- {
- if(IsTypeInList(type, _3gppLocalizedStringTypeList))
- {
+ } else if (context == AP4_ATOM_TYPE_UDTA) {
+ if (IsTypeInList(type, _3gppLocalizedStringTypeList)) {
atom = AP4_3GppLocalizedStringAtom::Create(type, size, stream);
- }
- else if(IsTypeInList(type, DcfStringTypeList))
- {
+ } else if (IsTypeInList(type, DcfStringTypeList)) {
atom = AP4_DcfStringAtom::Create(type, size, stream);
- }
- else if(type == AP4_ATOM_TYPE_DCFD)
- {
+ } else if (type == AP4_ATOM_TYPE_DCFD) {
atom = AP4_DcfdAtom::Create(size, stream);
}
}
- return atom ? AP4_SUCCESS : AP4_FAILURE;
+ return atom?AP4_SUCCESS:AP4_FAILURE;
}
/*----------------------------------------------------------------------
@@ -454,9 +430,8 @@ AP4_MetaDataAtomTypeHandler::CreateAtom(AP4_Atom::Type type,
bool
AP4_MetaDataAtomTypeHandler::IsTypeInList(AP4_Atom::Type type, const AP4_MetaDataAtomTypeHandler::TypeList& list)
{
- for(unsigned int i = 0; i < list.m_Size; i++)
- {
- if(type == list.m_Types[i]) return true;
+ for (unsigned int i=0; i<list.m_Size; i++) {
+ if (type == list.m_Types[i]) return true;
}
return false;
}
@@ -470,37 +445,30 @@ AP4_MetaData::AP4_MetaData(AP4_File* file)
AP4_Movie* movie = file->GetMovie();
// handle the movie's metadata if there is a movie in the file
- if(movie)
- {
+ if (movie) {
AP4_MoovAtom* moov = movie->GetMoovAtom();
- if(moov == NULL) return;
+ if (moov == NULL) return;
ParseMoov(moov);
- }
- else
- {
+ } else {
// if we don't have a movie, try to show metadata from a udta atom
AP4_List<AP4_Atom>& top_level_atoms = file->GetTopLevelAtoms();
-
+
AP4_List<AP4_Atom>::Item* atom_item = top_level_atoms.FirstItem();
- while(atom_item)
- {
+ while (atom_item) {
AP4_ContainerAtom* container = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom_item->GetData());
- if(container)
- {
+ if (container) {
// look for a udta in a DCF layout
AP4_Atom* udta = container->FindChild("odhe/udta");
- if(udta)
- {
+ if (udta) {
AP4_ContainerAtom* udta_container = AP4_DYNAMIC_CAST(AP4_ContainerAtom, udta);
- if(udta_container)
- {
+ if (udta_container) {
ParseUdta(udta_container, "dcf");
}
}
}
atom_item = atom_item->GetNext();
}
- }
+ }
}
/*----------------------------------------------------------------------
@@ -511,23 +479,21 @@ AP4_MetaData::ParseMoov(AP4_MoovAtom* moov)
{
// look for a 'meta' atom with 'hdlr' type 'mdir'
AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, moov->FindChild("udta/meta/hdlr"));
- if(hdlr == NULL || hdlr->GetHandlerType() != AP4_HANDLER_TYPE_MDIR) return AP4_ERROR_NO_SUCH_ITEM;
+ if (hdlr == NULL || hdlr->GetHandlerType() != AP4_HANDLER_TYPE_MDIR) return AP4_ERROR_NO_SUCH_ITEM;
// get the list of entries
AP4_ContainerAtom* ilst = AP4_DYNAMIC_CAST(AP4_ContainerAtom, moov->FindChild("udta/meta/ilst"));
- if(ilst == NULL) return AP4_ERROR_NO_SUCH_ITEM;
-
+ if (ilst == NULL) return AP4_ERROR_NO_SUCH_ITEM;
+
AP4_List<AP4_Atom>::Item* ilst_item = ilst->GetChildren().FirstItem();
- while(ilst_item)
- {
- AP4_ContainerAtom* entry_atom = AP4_DYNAMIC_CAST(AP4_ContainerAtom, ilst_item->GetData());
- if(entry_atom)
- {
+ while (ilst_item) {
+ AP4_ContainerAtom* entry_atom = AP4_DYNAMIC_CAST(AP4_ContainerAtom, ilst_item->GetData());
+ if (entry_atom) {
AddIlstEntries(entry_atom, "meta");
}
ilst_item = ilst_item->GetNext();
}
-
+
return AP4_SUCCESS;
}
@@ -538,35 +504,30 @@ AP4_Result
AP4_MetaData::ParseUdta(AP4_ContainerAtom* udta, const char* namespc)
{
// check that the atom is indeed a 'udta' atom
- if(udta->GetType() != AP4_ATOM_TYPE_UDTA)
- {
+ if (udta->GetType() != AP4_ATOM_TYPE_UDTA) {
return AP4_ERROR_INVALID_PARAMETERS;
}
-
+
AP4_List<AP4_Atom>::Item* udta_item = udta->GetChildren().FirstItem();
- for(; udta_item; udta_item = udta_item->GetNext())
- {
- AP4_3GppLocalizedStringAtom* _3gpp_atom = AP4_DYNAMIC_CAST(AP4_3GppLocalizedStringAtom, udta_item->GetData());
- if(_3gpp_atom)
- {
+ for (; udta_item; udta_item = udta_item->GetNext()) {
+ AP4_3GppLocalizedStringAtom* _3gpp_atom = AP4_DYNAMIC_CAST(AP4_3GppLocalizedStringAtom, udta_item->GetData());
+ if (_3gpp_atom) {
Add3GppEntry(_3gpp_atom, namespc);
continue;
- }
-
+ }
+
AP4_DcfStringAtom* dcfs_atom = AP4_DYNAMIC_CAST(AP4_DcfStringAtom, udta_item->GetData());
- if(dcfs_atom)
- {
+ if (dcfs_atom) {
AddDcfStringEntry(dcfs_atom, namespc);
continue;
- }
+ }
AP4_DcfdAtom* dcfd_atom = AP4_DYNAMIC_CAST(AP4_DcfdAtom, udta_item->GetData());
- if(dcfd_atom)
- {
+ if (dcfd_atom) {
AddDcfdEntry(dcfd_atom, namespc);
}
}
-
+
return AP4_SUCCESS;
}
@@ -588,24 +549,21 @@ AP4_MetaData::ResolveKeyName(AP4_Atom::Type atom_type, AP4_String& value)
char four_cc[5];
// look for a match in the key infos
- for(unsigned int i = 0;
- i < sizeof(AP4_MetaData_KeyInfos) / sizeof(AP4_MetaData_KeyInfos[0]);
- i++)
- {
- if(AP4_MetaData_KeyInfos[i].four_cc == atom_type)
- {
+ for (unsigned int i=0;
+ i<sizeof(AP4_MetaData_KeyInfos)/sizeof(AP4_MetaData_KeyInfos[0]);
+ i++) {
+ if (AP4_MetaData_KeyInfos[i].four_cc == atom_type) {
key_name = AP4_MetaData_KeyInfos[i].name;
break;
}
}
- if(key_name == NULL)
- {
+ if (key_name == NULL) {
// this key was not found in the key infos, create a name for it
AP4_FormatFourChars(four_cc, (AP4_UI32)atom_type);
key_name = four_cc;
}
value = key_name;
-
+
return AP4_SUCCESS;
}
@@ -617,27 +575,24 @@ AP4_MetaData::AddIlstEntries(AP4_ContainerAtom* atom, const char* namespc)
{
AP4_MetaData::Value* value = NULL;
- if(atom->GetType() == AP4_ATOM_TYPE_dddd)
- {
+ if (atom->GetType() == AP4_ATOM_TYPE_dddd) {
// look for the namespace
AP4_MetaDataStringAtom* mean = static_cast<AP4_MetaDataStringAtom*>(atom->GetChild(AP4_ATOM_TYPE_MEAN));
- if(mean == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (mean == NULL) return AP4_ERROR_INVALID_FORMAT;
// look for the name
AP4_MetaDataStringAtom* name = static_cast<AP4_MetaDataStringAtom*>(atom->GetChild(AP4_ATOM_TYPE_NAME));
- if(name == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (name == NULL) return AP4_ERROR_INVALID_FORMAT;
// get the value
AP4_DataAtom* data_atom = static_cast<AP4_DataAtom*>(atom->GetChild(AP4_ATOM_TYPE_DATA));
value = new AP4_AtomMetaDataValue(data_atom, atom->GetType());
- if(value == NULL) return AP4_ERROR_INVALID_FORMAT;
-
+ if (value == NULL) return AP4_ERROR_INVALID_FORMAT;
+
return m_Entries.Add(new Entry(name->GetValue().GetChars(),
mean->GetValue().GetChars(),
value));
- }
- else
- {
+ } else {
const char* key_name = NULL;
char four_cc[5];
@@ -647,11 +602,9 @@ AP4_MetaData::AddIlstEntries(AP4_ContainerAtom* atom, const char* namespc)
// add one entry for each data atom
AP4_List<AP4_Atom>::Item* data_item = atom->GetChildren().FirstItem();
- while(data_item)
- {
+ while (data_item) {
AP4_Atom* item_atom = data_item->GetData();
- if(item_atom->GetType() == AP4_ATOM_TYPE_DATA)
- {
+ if (item_atom->GetType() == AP4_ATOM_TYPE_DATA) {
AP4_DataAtom* data_atom = static_cast<AP4_DataAtom*>(item_atom);
value = new AP4_AtomMetaDataValue(data_atom, atom->GetType());
m_Entries.Add(new Entry(key_name, namespc, value));
@@ -671,16 +624,15 @@ AP4_MetaData::Add3GppEntry(AP4_3GppLocalizedStringAtom* atom, const char* namesp
{
AP4_String key_name;
ResolveKeyName(atom->GetType(), key_name);
-
+
const char* language = NULL;
- if(atom->GetLanguage()[0])
- {
+ if (atom->GetLanguage()[0]) {
language = atom->GetLanguage();
}
AP4_MetaData::Value* value = new AP4_StringMetaDataValue(atom->GetValue().GetChars(),
- language);
+ language);
m_Entries.Add(new Entry(key_name.GetChars(), namespc, value));
-
+
return AP4_SUCCESS;
}
@@ -692,10 +644,10 @@ AP4_MetaData::AddDcfStringEntry(AP4_DcfStringAtom* atom, const char* namespc)
{
AP4_String key_name;
ResolveKeyName(atom->GetType(), key_name);
-
+
AP4_MetaData::Value* value = new AP4_StringMetaDataValue(atom->GetValue().GetChars());
m_Entries.Add(new Entry(key_name.GetChars(), namespc, value));
-
+
return AP4_SUCCESS;
}
@@ -707,45 +659,44 @@ AP4_MetaData::AddDcfdEntry(AP4_DcfdAtom* atom, const char* namespc)
{
AP4_String key_name;
ResolveKeyName(atom->GetType(), key_name);
-
- AP4_MetaData::Value* value = new AP4_IntegerMetaDataValue(AP4_MetaData::Value::TYPE_INT_32_BE,
- atom->GetDuration());
+
+ AP4_MetaData::Value* value = new AP4_IntegerMetaDataValue(AP4_MetaData::Value::TYPE_INT_32_BE,
+ atom->GetDuration());
m_Entries.Add(new Entry(key_name.GetChars(), namespc, value));
-
+
return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
| AP4_MetaData::Value::MapDataTypeToCategory
+---------------------------------------------------------------------*/
-AP4_MetaData::Value::TypeCategory
+AP4_MetaData::Value::TypeCategory
AP4_MetaData::Value::MapTypeToCategory(Type type)
{
- switch(type)
- {
- case AP4_MetaData::Value::TYPE_INT_08_BE:
- case AP4_MetaData::Value::TYPE_INT_16_BE:
- case AP4_MetaData::Value::TYPE_INT_32_BE:
- return AP4_MetaData::Value::TYPE_CATEGORY_INTEGER;
-
- case AP4_MetaData::Value::TYPE_STRING_UTF_8:
- case AP4_MetaData::Value::TYPE_STRING_UTF_16:
- case AP4_MetaData::Value::TYPE_STRING_PASCAL:
- return AP4_MetaData::Value::TYPE_CATEGORY_STRING;
-
- case AP4_MetaData::Value::TYPE_FLOAT_32_BE:
- case AP4_MetaData::Value::TYPE_FLOAT_64_BE:
- return AP4_MetaData::Value::TYPE_CATEGORY_FLOAT;
-
- default:
- return AP4_MetaData::Value::TYPE_CATEGORY_BINARY;
+ switch (type) {
+ case AP4_MetaData::Value::TYPE_INT_08_BE:
+ case AP4_MetaData::Value::TYPE_INT_16_BE:
+ case AP4_MetaData::Value::TYPE_INT_32_BE:
+ return AP4_MetaData::Value::TYPE_CATEGORY_INTEGER;
+
+ case AP4_MetaData::Value::TYPE_STRING_UTF_8:
+ case AP4_MetaData::Value::TYPE_STRING_UTF_16:
+ case AP4_MetaData::Value::TYPE_STRING_PASCAL:
+ return AP4_MetaData::Value::TYPE_CATEGORY_STRING;
+
+ case AP4_MetaData::Value::TYPE_FLOAT_32_BE:
+ case AP4_MetaData::Value::TYPE_FLOAT_64_BE:
+ return AP4_MetaData::Value::TYPE_CATEGORY_FLOAT;
+
+ default:
+ return AP4_MetaData::Value::TYPE_CATEGORY_BINARY;
}
}
/*----------------------------------------------------------------------
| AP4_MetaData::Value::GetTypeCategory
+---------------------------------------------------------------------*/
-AP4_MetaData::Value::TypeCategory
+AP4_MetaData::Value::TypeCategory
AP4_MetaData::Value::GetTypeCategory() const
{
return MapTypeToCategory(m_Type);
@@ -758,89 +709,75 @@ AP4_Result
AP4_MetaData::Entry::ToAtom(AP4_Atom*& atom) const
{
atom = NULL;
-
- if(m_Value == NULL)
- {
+
+ if (m_Value == NULL) {
return AP4_ERROR_INVALID_PARAMETERS;
}
-
- if(m_Key.GetNamespace() == "meta")
- {
+
+ if (m_Key.GetNamespace() == "meta") {
// convert the name into an atom type
- if(m_Key.GetName().GetLength() != 4)
- {
+ if (m_Key.GetName().GetLength() != 4) {
// the name is not in the right format
return AP4_ERROR_INVALID_PARAMETERS;
}
- AP4_Atom::Type atom_type = AP4_Atom::TypeFromString(m_Key.GetName().GetChars());
-
+ AP4_Atom::Type atom_type = AP4_Atom::TypeFromString(m_Key.GetName().GetChars());
+
// create a container atom for the data
AP4_ContainerAtom* container = new AP4_ContainerAtom(atom_type);
// add the data atom
AP4_DataAtom* data = new AP4_DataAtom(*m_Value);
container->AddChild(data);
-
+
atom = container;
return AP4_SUCCESS;
- }
- else if(m_Key.GetNamespace() == "dcf")
- {
+ } else if (m_Key.GetNamespace() == "dcf") {
// convert the name into an atom type
- if(m_Key.GetName().GetLength() != 4)
- {
+ if (m_Key.GetName().GetLength() != 4) {
// the name is not in the right format
return AP4_ERROR_INVALID_PARAMETERS;
}
- AP4_Atom::Type atom_type = AP4_Atom::TypeFromString(m_Key.GetName().GetChars());
+ AP4_Atom::Type atom_type = AP4_Atom::TypeFromString(m_Key.GetName().GetChars());
- if(AP4_MetaDataAtomTypeHandler::IsTypeInList(atom_type,
- AP4_MetaDataAtomTypeHandler::DcfStringTypeList))
- {
+ if (AP4_MetaDataAtomTypeHandler::IsTypeInList(atom_type,
+ AP4_MetaDataAtomTypeHandler::DcfStringTypeList)) {
AP4_String atom_value = m_Value->ToString();
atom = new AP4_DcfStringAtom(atom_type, atom_value.GetChars());
return AP4_SUCCESS;
- }
- else if(AP4_MetaDataAtomTypeHandler::IsTypeInList(atom_type,
- AP4_MetaDataAtomTypeHandler::_3gppLocalizedStringTypeList))
- {
+ } else if (AP4_MetaDataAtomTypeHandler::IsTypeInList(atom_type,
+ AP4_MetaDataAtomTypeHandler::_3gppLocalizedStringTypeList)) {
AP4_String atom_value = m_Value->ToString();
const char* language = "eng"; // default
- if(m_Value->GetLanguage().GetLength() != 0)
- {
+ if (m_Value->GetLanguage().GetLength() != 0) {
language = m_Value->GetLanguage().GetChars();
}
atom = new AP4_3GppLocalizedStringAtom(atom_type, language, atom_value.GetChars());
return AP4_SUCCESS;
- }
- else if(atom_type == AP4_ATOM_TYPE_DCFD)
- {
+ } else if (atom_type == AP4_ATOM_TYPE_DCFD) {
atom = new AP4_DcfdAtom(m_Value->ToInteger());
return AP4_SUCCESS;
}
-
- // not supported
- return AP4_ERROR_NOT_SUPPORTED;
- }
- else
- {
+
+ // not supported
+ return AP4_ERROR_NOT_SUPPORTED;
+ } else {
// create a '----' atom
AP4_ContainerAtom* container = new AP4_ContainerAtom(AP4_ATOM_TYPE_dddd);
-
+
// add a 'mean' string
container->AddChild(new AP4_MetaDataStringAtom(AP4_ATOM_TYPE_MEAN, m_Key.GetNamespace().GetChars()));
-
+
// add a 'name' string
container->AddChild(new AP4_MetaDataStringAtom(AP4_ATOM_TYPE_NAME, m_Key.GetName().GetChars()));
// add the data atom
AP4_DataAtom* data = new AP4_DataAtom(*m_Value);
container->AddChild(data);
-
+
atom = container;
return AP4_SUCCESS;
}
-
+
return AP4_ERROR_NOT_SUPPORTED;
}
@@ -850,36 +787,30 @@ AP4_MetaData::Entry::ToAtom(AP4_Atom*& atom) const
AP4_ContainerAtom*
AP4_MetaData::Entry::FindInIlst(AP4_ContainerAtom* ilst) const
{
- if(m_Key.GetNamespace() == "meta")
- {
+ if (m_Key.GetNamespace() == "meta") {
AP4_Atom::Type atom_type = AP4_Atom::TypeFromString(m_Key.GetName().GetChars());
return AP4_DYNAMIC_CAST(AP4_ContainerAtom, ilst->GetChild(atom_type));
- }
- else
- {
+ } else {
AP4_List<AP4_Atom>::Item* ilst_item = ilst->GetChildren().FirstItem();
- while(ilst_item)
- {
- AP4_ContainerAtom* entry_atom = AP4_DYNAMIC_CAST(AP4_ContainerAtom, ilst_item->GetData());
- if(entry_atom)
- {
+ while (ilst_item) {
+ AP4_ContainerAtom* entry_atom = AP4_DYNAMIC_CAST(AP4_ContainerAtom, ilst_item->GetData());
+ if (entry_atom) {
AP4_MetaDataStringAtom* mean = static_cast<AP4_MetaDataStringAtom*>(entry_atom->GetChild(AP4_ATOM_TYPE_MEAN));
AP4_MetaDataStringAtom* name = static_cast<AP4_MetaDataStringAtom*>(entry_atom->GetChild(AP4_ATOM_TYPE_NAME));
- if(mean && name &&
- mean->GetValue() == m_Key.GetNamespace() &&
- name->GetValue() == m_Key.GetName())
- {
+ if (mean && name &&
+ mean->GetValue() == m_Key.GetNamespace() &&
+ name->GetValue() == m_Key.GetName()) {
return entry_atom;
}
}
ilst_item = ilst_item->GetNext();
}
}
-
+
// not found
return NULL;
}
-
+
/*----------------------------------------------------------------------
| AP4_MetaData::Entry::AddToFileIlst
+---------------------------------------------------------------------*/
@@ -887,69 +818,61 @@ AP4_Result
AP4_MetaData::Entry::AddToFileIlst(AP4_File& file, AP4_Ordinal index)
{
// check that we have a correct entry
- if(m_Value == NULL) return AP4_ERROR_INVALID_STATE;
+ if (m_Value == NULL) return AP4_ERROR_INVALID_STATE;
// convert the entry into an atom
AP4_Atom* atom;
AP4_Result result = ToAtom(atom);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
AP4_ContainerAtom* entry_atom = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
- if(entry_atom == NULL)
- {
+ if (entry_atom == NULL) {
return AP4_ERROR_INVALID_FORMAT;
}
// look for the 'moov'
AP4_Movie* movie = file.GetMovie();
- if(movie == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (movie == NULL) return AP4_ERROR_INVALID_FORMAT;
AP4_MoovAtom* moov = movie->GetMoovAtom();
- if(moov == NULL) return AP4_ERROR_INVALID_FORMAT;
-
- // look for 'udta', and create if it does not exist
+ if (moov == NULL) return AP4_ERROR_INVALID_FORMAT;
+
+ // look for 'udta', and create if it does not exist
AP4_ContainerAtom* udta = AP4_DYNAMIC_CAST(AP4_ContainerAtom, moov->FindChild("udta", true));
- if(udta == NULL) return AP4_ERROR_INTERNAL;
-
+ if (udta == NULL) return AP4_ERROR_INTERNAL;
+
// look for 'meta', and create if it does not exist ('meta' is a FULL atom)
AP4_ContainerAtom* meta = AP4_DYNAMIC_CAST(AP4_ContainerAtom, udta->FindChild("meta", true, true));
- if(meta == NULL) return AP4_ERROR_INTERNAL;
+ if (meta == NULL) return AP4_ERROR_INTERNAL;
// look for a 'hdlr' atom type 'mdir'
AP4_HdlrAtom* hdlr = AP4_DYNAMIC_CAST(AP4_HdlrAtom, meta->FindChild("hdlr"));
- if(hdlr == NULL)
- {
+ if (hdlr == NULL) {
hdlr = new AP4_HdlrAtom(AP4_HANDLER_TYPE_MDIR, "");
meta->AddChild(hdlr);
- }
- else
- {
- if(hdlr->GetHandlerType() != AP4_HANDLER_TYPE_MDIR)
- {
+ } else {
+ if (hdlr->GetHandlerType() != AP4_HANDLER_TYPE_MDIR) {
return AP4_ERROR_INVALID_FORMAT;
}
}
// get/create the list of entries
AP4_ContainerAtom* ilst = AP4_DYNAMIC_CAST(AP4_ContainerAtom, meta->FindChild("ilst", true));
- if(ilst == NULL) return AP4_ERROR_INTERNAL;
-
+ if (ilst == NULL) return AP4_ERROR_INTERNAL;
+
// look if there is already a container for this entry
AP4_ContainerAtom* existing = FindInIlst(ilst);
- if(existing == NULL)
- {
+ if (existing == NULL) {
// just add the one we have
ilst->AddChild(entry_atom);
- }
- else
- {
+ } else {
// add the entry's data to the existing entry
AP4_DataAtom* data_atom = AP4_DYNAMIC_CAST(AP4_DataAtom, entry_atom->GetChild(AP4_ATOM_TYPE_DATA));
- if(data_atom == NULL) return AP4_ERROR_INTERNAL;
+ if (data_atom == NULL) return AP4_ERROR_INTERNAL;
entry_atom->RemoveChild(data_atom);
existing->AddChild(data_atom, index);
delete entry_atom;
}
-
- return AP4_SUCCESS;
+
+ return AP4_SUCCESS;
}
/*----------------------------------------------------------------------
@@ -959,20 +882,20 @@ AP4_Result
AP4_MetaData::Entry::AddToFileDcf(AP4_File& file, AP4_Ordinal index)
{
// check that we have a correct entry
- if(m_Value == NULL) return AP4_ERROR_INVALID_STATE;
-
+ if (m_Value == NULL) return AP4_ERROR_INVALID_STATE;
+
// look for 'odrm/odhe'
AP4_ContainerAtom* odhe = AP4_DYNAMIC_CAST(AP4_ContainerAtom, file.FindChild("odrm/odhe"));
- if(odhe == NULL) return AP4_ERROR_NO_SUCH_ITEM;
+ if (odhe == NULL) return AP4_ERROR_NO_SUCH_ITEM;
// get/create the list of entries
AP4_ContainerAtom* udta = AP4_DYNAMIC_CAST(AP4_ContainerAtom, odhe->FindChild("udta", true));
- if(udta == NULL) return AP4_ERROR_INTERNAL;
-
+ if (udta == NULL) return AP4_ERROR_INTERNAL;
+
// convert the entry into an atom
AP4_Atom* data_atom;
AP4_Result result = ToAtom(data_atom);
- if(AP4_FAILED(result)) return result;
+ if (AP4_FAILED(result)) return result;
// add the entry's data to the container
return udta->AddChild(data_atom, index);
@@ -985,19 +908,14 @@ AP4_Result
AP4_MetaData::Entry::AddToFile(AP4_File& file, AP4_Ordinal index)
{
// check that we have a correct entry
- if(m_Value == NULL) return AP4_ERROR_INVALID_STATE;
-
+ if (m_Value == NULL) return AP4_ERROR_INVALID_STATE;
+
// check the namespace of the key to know where to add the atom
- if(m_Key.GetNamespace() == "meta")
- {
+ if (m_Key.GetNamespace() == "meta") {
return AddToFileIlst(file, index);
- }
- else if(m_Key.GetNamespace() == "dcf")
- {
+ } else if (m_Key.GetNamespace() == "dcf") {
return AddToFileDcf(file, index);
- }
- else
- {
+ } else {
// custom namespace
return AddToFileIlst(file, index);
}
@@ -1011,29 +929,28 @@ AP4_MetaData::Entry::RemoveFromFileIlst(AP4_File& file, AP4_Ordinal index)
{
// look for the 'moov'
AP4_Movie* movie = file.GetMovie();
- if(movie == NULL) return AP4_ERROR_INVALID_FORMAT;
+ if (movie == NULL) return AP4_ERROR_INVALID_FORMAT;
AP4_MoovAtom* moov = movie->GetMoovAtom();
- if(moov == NULL) return AP4_ERROR_INVALID_FORMAT;
-
+ if (moov == NULL) return AP4_ERROR_INVALID_FORMAT;
+
// look for 'udta/meta/ilst'
AP4_ContainerAtom* ilst = AP4_DYNAMIC_CAST(AP4_ContainerAtom, moov->FindChild("udta/meta/ilst"));
- if(ilst == NULL) return AP4_ERROR_NO_SUCH_ITEM;
-
+ if (ilst == NULL) return AP4_ERROR_NO_SUCH_ITEM;
+
// look if there is already a container for this entry
AP4_ContainerAtom* existing = FindInIlst(ilst);
- if(existing == NULL) return AP4_ERROR_NO_SUCH_ITEM;
-
+ if (existing == NULL) return AP4_ERROR_NO_SUCH_ITEM;
+
// remove the data atom in the entry
AP4_Result result = existing->DeleteChild(AP4_ATOM_TYPE_DATA, index);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
// if the entry is empty, remove it
- if(existing->GetChildren().ItemCount() == 0)
- {
+ if (existing->GetChildren().ItemCount() == 0) {
ilst->RemoveChild(existing);
delete existing;
}
-
+
return AP4_SUCCESS;
}
@@ -1045,13 +962,13 @@ AP4_MetaData::Entry::RemoveFromFileDcf(AP4_File& file, AP4_Ordinal index)
{
// look for 'odrm/odhe/udta'
AP4_ContainerAtom* udta = AP4_DYNAMIC_CAST(AP4_ContainerAtom, file.FindChild("odrm/odhe/udta"));
- if(udta == NULL) return AP4_ERROR_NO_SUCH_ITEM;
-
+ if (udta == NULL) return AP4_ERROR_NO_SUCH_ITEM;
+
// remove the data atom in the entry
AP4_UI32 type = AP4_BytesToUInt32BE((const unsigned char*)m_Key.GetName().GetChars());
AP4_Result result = udta->DeleteChild(type, index);
- if(AP4_FAILED(result)) return result;
-
+ if (AP4_FAILED(result)) return result;
+
return AP4_SUCCESS;
}
@@ -1062,16 +979,11 @@ AP4_Result
AP4_MetaData::Entry::RemoveFromFile(AP4_File& file, AP4_Ordinal index)
{
// check the namespace of the key to know where to add the atom
- if(m_Key.GetNamespace() == "meta")
- {
+ if (m_Key.GetNamespace() == "meta") {
return RemoveFromFileIlst(file, index);
- }
- else if(m_Key.GetNamespace() == "dcf")
- {
+ } else if (m_Key.GetNamespace() == "dcf") {
return RemoveFromFileDcf(file, index);
- }
- else
- {
+ } else {
// unsupported namespace
return AP4_ERROR_NOT_SUPPORTED;
}
@@ -1166,151 +1078,121 @@ AP4_BinaryMetaDataValue::ToInteger() const
| AP4_AtomMetaDataValue::AP4_AtomMetaDataValue
+---------------------------------------------------------------------*/
AP4_AtomMetaDataValue::AP4_AtomMetaDataValue(AP4_DataAtom* atom,
- AP4_UI32 parent_type) :
+ AP4_UI32 parent_type) :
Value(atom->GetValueType()),
m_DataAtom(atom)
{
- switch(parent_type)
- {
- case AP4_ATOM_TYPE_GNRE:
- m_Meaning = MEANING_ID3_GENRE;
- break;
-
- case AP4_ATOM_TYPE_CPIL:
- m_Meaning = MEANING_BOOLEAN;
- break;
+ switch (parent_type) {
+ case AP4_ATOM_TYPE_GNRE:
+ m_Meaning = MEANING_ID3_GENRE;
+ break;
- case AP4_ATOM_TYPE_PGAP:
- case AP4_ATOM_TYPE_PCST:
- m_Meaning = MEANING_BOOLEAN;
- break;
+ case AP4_ATOM_TYPE_CPIL:
+ m_Meaning = MEANING_BOOLEAN;
+ break;
- case AP4_ATOM_TYPE_STIK:
- m_Meaning = MEANING_FILE_KIND;
- break;
+ case AP4_ATOM_TYPE_PGAP:
+ case AP4_ATOM_TYPE_PCST:
+ m_Meaning = MEANING_BOOLEAN;
+ break;
- case AP4_ATOM_TYPE_PURL:
- case AP4_ATOM_TYPE_EGID:
- m_Meaning = MEANING_BINARY_ENCODED_CHARS;
- break;
+ case AP4_ATOM_TYPE_STIK:
+ m_Meaning = MEANING_FILE_KIND;
+ break;
- default:
- break;
+ case AP4_ATOM_TYPE_PURL:
+ case AP4_ATOM_TYPE_EGID:
+ m_Meaning = MEANING_BINARY_ENCODED_CHARS;
+ break;
+
+ default:
+ break;
}
}
/*----------------------------------------------------------------------
| AP4_AtomMetaDataValue::ToString
+---------------------------------------------------------------------*/
-AP4_String
+AP4_String
AP4_AtomMetaDataValue::ToString() const
{
char string[256] = "";
AP4_MetaData::Value::Type value_type = m_DataAtom->GetValueType();
- switch(AP4_MetaData::Value::MapTypeToCategory(value_type))
- {
- case AP4_MetaData::Value::TYPE_CATEGORY_INTEGER:
- {
- long value;
- if(AP4_SUCCEEDED(m_DataAtom->LoadInteger(value)))
- {
- if(m_Meaning == MEANING_BOOLEAN)
- {
- if(value)
- {
- return "True";
- }
- else
- {
- return "False";
- }
- }
- else if(m_Meaning == MEANING_FILE_KIND)
+ switch (AP4_MetaData::Value::MapTypeToCategory(value_type)) {
+ case AP4_MetaData::Value::TYPE_CATEGORY_INTEGER:
{
- if(value >= 0 && ((unsigned int)value) <= sizeof(Ap4StikNames) / sizeof(Ap4StikNames[0]))
- {
- AP4_FormatString(string, sizeof(string), "(%ld) %s", value, Ap4StikNames[value]);
- }
- else
- {
- return "Unknown";
+ long value;
+ if (AP4_SUCCEEDED(m_DataAtom->LoadInteger(value))) {
+ if (m_Meaning == MEANING_BOOLEAN) {
+ if (value) {
+ return "True";
+ } else {
+ return "False";
+ }
+ } else if (m_Meaning == MEANING_FILE_KIND) {
+ if (value >= 0 && ((unsigned int)value) <= sizeof(Ap4StikNames)/sizeof(Ap4StikNames[0])) {
+ AP4_FormatString(string, sizeof(string), "(%ld) %s", value, Ap4StikNames[value]);
+ } else {
+ return "Unknown";
+ }
+ } else {
+ AP4_FormatString(string, sizeof(string), "%ld", value);
+ }
}
+ return AP4_String((const char*)string);
+ break;
}
- else
- {
- AP4_FormatString(string, sizeof(string), "%ld", value);
- }
- }
- return AP4_String((const char*)string);
- break;
- }
-
- case AP4_MetaData::Value::TYPE_CATEGORY_STRING:
- {
- AP4_String* category_string;
- if(AP4_SUCCEEDED(m_DataAtom->LoadString(category_string)))
- {
- AP4_String result(*category_string);
- delete category_string;
- return result;
- }
- break;
- }
- case AP4_MetaData::Value::TYPE_CATEGORY_BINARY:
- {
- AP4_DataBuffer data;
- if(AP4_SUCCEEDED(m_DataAtom->LoadBytes(data)))
- {
- if(m_Meaning == MEANING_ID3_GENRE && data.GetDataSize() == 2)
+ case AP4_MetaData::Value::TYPE_CATEGORY_STRING:
{
- unsigned int genre = (data.GetData()[0]) * 256 + data.GetData()[1];
- if(genre >= 1 && genre <= sizeof(Ap4Id3Genres) / sizeof(Ap4Id3Genres[0]))
- {
- AP4_FormatString(string, sizeof(string), "(%d) %s", genre, Ap4Id3Genres[genre-1]);
- return AP4_String((const char*)string);
- }
- else
- {
- return "Unknown";
+ AP4_String* category_string;
+ if (AP4_SUCCEEDED(m_DataAtom->LoadString(category_string))) {
+ AP4_String result(*category_string);
+ delete category_string;
+ return result;
}
+ break;
}
- else if(m_Meaning == MEANING_BINARY_ENCODED_CHARS)
- {
- AP4_String result;
- result.Assign((const char*)data.GetData(), data.GetDataSize());
- return result;
- }
- else
+
+ case AP4_MetaData::Value::TYPE_CATEGORY_BINARY:
{
- unsigned int dump_length = data.GetDataSize();
- bool truncate = false;
- if(dump_length > 16)
- {
- dump_length = 16;
- truncate = true;
- }
- char* out = string;
- for(unsigned int i = 0; i < dump_length; i++)
- {
- AP4_FormatString(out, sizeof(string) - (out - string), "%02x ", data.GetData()[i]);
- out += 3;
- }
- if(truncate)
- {
- *out++ = '.';
- *out++ = '.';
- *out++ = '.';
- *out++ = ' ';
+ AP4_DataBuffer data;
+ if (AP4_SUCCEEDED(m_DataAtom->LoadBytes(data))) {
+ if (m_Meaning == MEANING_ID3_GENRE && data.GetDataSize() == 2) {
+ unsigned int genre = (data.GetData()[0])*256+data.GetData()[1];
+ if (genre >= 1 && genre <= sizeof(Ap4Id3Genres)/sizeof(Ap4Id3Genres[0])) {
+ AP4_FormatString(string, sizeof(string), "(%d) %s", genre, Ap4Id3Genres[genre-1]);
+ return AP4_String((const char*)string);
+ } else {
+ return "Unknown";
+ }
+ } else if (m_Meaning == MEANING_BINARY_ENCODED_CHARS) {
+ AP4_String result;
+ result.Assign((const char*)data.GetData(), data.GetDataSize());
+ return result;
+ } else {
+ unsigned int dump_length = data.GetDataSize();
+ bool truncate = false;
+ if (dump_length > 16) {
+ dump_length = 16;
+ truncate = true;
+ }
+ char* out = string;
+ for (unsigned int i=0; i<dump_length; i++) {
+ AP4_FormatString(out, sizeof(string)-(out-string), "%02x ", data.GetData()[i]);
+ out += 3;
+ }
+ if (truncate) {
+ *out++='.'; *out++='.'; *out++='.'; *out++=' ';
+ }
+ AP4_FormatString(out, sizeof(string)-(out-string), "[%ld bytes]", data.GetDataSize());
+ }
}
- AP4_FormatString(out, sizeof(string) - (out - string), "[%ld bytes]", data.GetDataSize());
+ return AP4_String(string);
}
- }
- return AP4_String(string);
- }
- default:
- return AP4_String();
+ default:
+ return AP4_String();
}
return AP4_String();
@@ -1328,16 +1210,13 @@ AP4_AtomMetaDataValue::ToBytes(AP4_DataBuffer& bytes) const
/*----------------------------------------------------------------------
| AP4_AtomMetaDataValue::ToInteger
+---------------------------------------------------------------------*/
-long
+long
AP4_AtomMetaDataValue::ToInteger() const
{
long value;
- if(AP4_SUCCEEDED(m_DataAtom->LoadInteger(value)))
- {
+ if (AP4_SUCCEEDED(m_DataAtom->LoadInteger(value))) {
return value;
- }
- else
- {
+ } else {
return 0;
}
}
@@ -1352,81 +1231,70 @@ AP4_DataAtom::AP4_DataAtom(const AP4_MetaData::Value& value) :
AP4_MemoryByteStream* memory = new AP4_MemoryByteStream(256);
AP4_Size payload_size = 8;
m_Source = memory;
-
- switch(value.GetType())
- {
- case AP4_MetaData::Value::TYPE_STRING_UTF_8:
- {
- m_DataType = DATA_TYPE_STRING_UTF_8;
- AP4_String string_value = value.ToString();
- if(string_value.GetLength())
- {
- memory->Write(string_value.GetChars(), string_value.GetLength());
+
+ switch (value.GetType()) {
+ case AP4_MetaData::Value::TYPE_STRING_UTF_8: {
+ m_DataType = DATA_TYPE_STRING_UTF_8;
+ AP4_String string_value = value.ToString();
+ if (string_value.GetLength()) {
+ memory->Write(string_value.GetChars(), string_value.GetLength());
+ }
+ payload_size += string_value.GetLength();
+ break;
+ }
+
+ case AP4_MetaData::Value::TYPE_INT_08_BE: {
+ m_DataType = DATA_TYPE_SIGNED_INT_BE;
+ AP4_UI08 int_value = (AP4_UI08)value.ToInteger();
+ memory->Write(&int_value, 1);
+ payload_size += 1;
+ break;
+ }
+
+ case AP4_MetaData::Value::TYPE_INT_16_BE: {
+ m_DataType = DATA_TYPE_SIGNED_INT_BE;
+ AP4_UI16 int_value = (AP4_UI16)value.ToInteger();
+ memory->Write(&int_value, 2);
+ payload_size += 2;
+ break;
}
- payload_size += string_value.GetLength();
- break;
- }
-
- case AP4_MetaData::Value::TYPE_INT_08_BE:
- {
- m_DataType = DATA_TYPE_SIGNED_INT_BE;
- AP4_UI08 int_value = (AP4_UI08)value.ToInteger();
- memory->Write(&int_value, 1);
- payload_size += 1;
- break;
- }
-
- case AP4_MetaData::Value::TYPE_INT_16_BE:
- {
- m_DataType = DATA_TYPE_SIGNED_INT_BE;
- AP4_UI16 int_value = (AP4_UI16)value.ToInteger();
- memory->Write(&int_value, 2);
- payload_size += 2;
- break;
- }
- case AP4_MetaData::Value::TYPE_INT_32_BE:
- {
- m_DataType = DATA_TYPE_SIGNED_INT_BE;
- AP4_UI32 int_value = (AP4_UI32)value.ToInteger();
- memory->Write(&int_value, 4);
- payload_size += 4;
- break;
- }
+ case AP4_MetaData::Value::TYPE_INT_32_BE: {
+ m_DataType = DATA_TYPE_SIGNED_INT_BE;
+ AP4_UI32 int_value = (AP4_UI32)value.ToInteger();
+ memory->Write(&int_value, 4);
+ payload_size += 4;
+ break;
+ }
- case AP4_MetaData::Value::TYPE_JPEG:
- m_DataType = DATA_TYPE_JPEG;
- // FALLTHROUGH
- case AP4_MetaData::Value::TYPE_GIF:
- if(m_DataType == DATA_TYPE_BINARY) m_DataType = DATA_TYPE_GIF;
- // FALLTHROUGH
- case AP4_MetaData::Value::TYPE_BINARY:
- {
- AP4_DataBuffer buffer;
- value.ToBytes(buffer);
- if(buffer.GetDataSize())
- {
- memory->Write(buffer.GetData(), buffer.GetDataSize());
+ case AP4_MetaData::Value::TYPE_JPEG:
+ m_DataType = DATA_TYPE_JPEG;
+ // FALLTHROUGH
+ case AP4_MetaData::Value::TYPE_GIF:
+ if (m_DataType == DATA_TYPE_BINARY) m_DataType = DATA_TYPE_GIF;
+ // FALLTHROUGH
+ case AP4_MetaData::Value::TYPE_BINARY: {
+ AP4_DataBuffer buffer;
+ value.ToBytes(buffer);
+ if (buffer.GetDataSize()) {
+ memory->Write(buffer.GetData(), buffer.GetDataSize());
+ }
+ payload_size += buffer.GetDataSize();
+ break;
}
- payload_size += buffer.GetDataSize();
- break;
- }
- default:
- break;
+ default:
+ break;
}
-
+
const AP4_String& language = value.GetLanguage();
- if(language == "en")
- {
+ if (language == "en") {
m_DataLang = LANGUAGE_ENGLISH;
- }
- else
- {
+ } else {
// default
m_DataLang = LANGUAGE_ENGLISH;
}
-
+
m_Size32 += payload_size;
}
@@ -1436,18 +1304,16 @@ AP4_DataAtom::AP4_DataAtom(const AP4_MetaData::Value& value) :
AP4_DataAtom::AP4_DataAtom(AP4_UI32 size, AP4_ByteStream& stream) :
AP4_Atom(AP4_ATOM_TYPE_DATA, size)
{
- if(size < AP4_ATOM_HEADER_SIZE + 8) return;
+ if (size < AP4_ATOM_HEADER_SIZE+8) return;
AP4_UI32 i;
- stream.ReadUI32(i);
- m_DataType = (DataType)i;
- stream.ReadUI32(i);
- m_DataLang = (DataLang)i;
+ stream.ReadUI32(i); m_DataType = (DataType)i;
+ stream.ReadUI32(i); m_DataLang = (DataLang)i;
// the stream for the data is a substream of this source
AP4_Position data_offset;
stream.Tell(data_offset);
- AP4_Size data_size = size - AP4_ATOM_HEADER_SIZE - 8;
+ AP4_Size data_size = size-AP4_ATOM_HEADER_SIZE-8;
m_Source = new AP4_SubStream(stream, data_offset, data_size);
}
@@ -1465,44 +1331,38 @@ AP4_DataAtom::~AP4_DataAtom()
AP4_MetaData::Value::Type
AP4_DataAtom::GetValueType()
{
- switch(m_DataType)
- {
- case DATA_TYPE_BINARY:
- return AP4_MetaData::Value::TYPE_BINARY;
-
- case DATA_TYPE_SIGNED_INT_BE:
- switch(m_Size32 - 16)
- {
- case 1:
- return AP4_MetaData::Value::TYPE_INT_08_BE;
- case 2:
- return AP4_MetaData::Value::TYPE_INT_16_BE;
- case 4:
- return AP4_MetaData::Value::TYPE_INT_32_BE;
- default:
+ switch (m_DataType) {
+ case DATA_TYPE_BINARY:
return AP4_MetaData::Value::TYPE_BINARY;
- }
- break;
-
- case DATA_TYPE_STRING_UTF_8:
- return AP4_MetaData::Value::TYPE_STRING_UTF_8;
-
- case DATA_TYPE_STRING_UTF_16:
- return AP4_MetaData::Value::TYPE_STRING_UTF_16;
-
- case DATA_TYPE_STRING_PASCAL:
- return AP4_MetaData::Value::TYPE_STRING_PASCAL;
-
- case DATA_TYPE_GIF:
- return AP4_MetaData::Value::TYPE_GIF;
- case DATA_TYPE_JPEG:
- return AP4_MetaData::Value::TYPE_JPEG;
+ case DATA_TYPE_SIGNED_INT_BE:
+ switch (m_Size32-16) {
+ case 1: return AP4_MetaData::Value::TYPE_INT_08_BE;
+ case 2: return AP4_MetaData::Value::TYPE_INT_16_BE;
+ case 4: return AP4_MetaData::Value::TYPE_INT_32_BE;
+ default: return AP4_MetaData::Value::TYPE_BINARY;
+ }
+ break;
+
+ case DATA_TYPE_STRING_UTF_8:
+ return AP4_MetaData::Value::TYPE_STRING_UTF_8;
+
+ case DATA_TYPE_STRING_UTF_16:
+ return AP4_MetaData::Value::TYPE_STRING_UTF_16;
+
+ case DATA_TYPE_STRING_PASCAL:
+ return AP4_MetaData::Value::TYPE_STRING_PASCAL;
+
+ case DATA_TYPE_GIF:
+ return AP4_MetaData::Value::TYPE_GIF;
+
+ case DATA_TYPE_JPEG:
+ return AP4_MetaData::Value::TYPE_JPEG;
- default:
- return AP4_MetaData::Value::TYPE_BINARY;
+ default:
+ return AP4_MetaData::Value::TYPE_BINARY;
}
-
+
return AP4_MetaData::Value::TYPE_BINARY;
}
@@ -1514,8 +1374,7 @@ AP4_DataAtom::WriteFields(AP4_ByteStream& stream)
{
stream.WriteUI32(m_DataType);
stream.WriteUI32(m_DataLang);
- if(m_Source)
- {
+ if (m_Source) {
AP4_LargeSize size = 0;
m_Source->GetSize(size);
m_Source->Seek(0);
@@ -1533,20 +1392,15 @@ AP4_DataAtom::InspectFields(AP4_AtomInspector& inspector)
{
inspector.AddField("type", m_DataType);
inspector.AddField("lang", m_DataLang);
- if(m_DataType == DATA_TYPE_STRING_UTF_8)
- {
+ if (m_DataType == DATA_TYPE_STRING_UTF_8) {
AP4_String* str;
- if(AP4_SUCCEEDED(LoadString(str)))
- {
+ if (AP4_SUCCEEDED(LoadString(str))) {
inspector.AddField("value", str->GetChars());
delete str;
}
- }
- else if(m_DataType == DATA_TYPE_SIGNED_INT_BE)
- {
+ } else if (m_DataType == DATA_TYPE_SIGNED_INT_BE) {
long value;
- if(AP4_SUCCEEDED(LoadInteger(value)))
- {
+ if (AP4_SUCCEEDED(LoadInteger(value))) {
inspector.AddField("value", value);
}
}
@@ -1560,24 +1414,20 @@ AP4_DataAtom::InspectFields(AP4_AtomInspector& inspector)
AP4_Result
AP4_DataAtom::LoadString(AP4_String*& string)
{
- if(m_Source == NULL)
- {
+ if (m_Source == NULL) {
string = new AP4_String();
return AP4_SUCCESS;
- }
- else
- {
+ } else {
// create a string with enough capactiy for the data
AP4_LargeSize size = 0;
m_Source->GetSize(size);
- if(size > AP4_DATA_ATOM_MAX_SIZE) return AP4_ERROR_OUT_OF_RANGE;
+ if (size > AP4_DATA_ATOM_MAX_SIZE) return AP4_ERROR_OUT_OF_RANGE;
string = new AP4_String((AP4_Size)size);
// read from the start of the stream
m_Source->Seek(0);
AP4_Result result = m_Source->Read(string->UseChars(), (AP4_Size)size);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
delete string;
string = NULL;
}
@@ -1592,19 +1442,17 @@ AP4_DataAtom::LoadString(AP4_String*& string)
AP4_Result
AP4_DataAtom::LoadBytes(AP4_DataBuffer& bytes)
{
- if(m_Source == NULL)
- {
+ if (m_Source == NULL) {
bytes.SetDataSize(0);
return AP4_SUCCESS;
}
AP4_LargeSize size = 0;
m_Source->GetSize(size);
- if(size > AP4_DATA_ATOM_MAX_SIZE) return AP4_ERROR_OUT_OF_RANGE;
+ if (size > AP4_DATA_ATOM_MAX_SIZE) return AP4_ERROR_OUT_OF_RANGE;
bytes.SetDataSize((AP4_Size)size);
m_Source->Seek(0);
AP4_Result result = m_Source->Read(bytes.UseData(), (AP4_Size)size);
- if(AP4_FAILED(result))
- {
+ if (AP4_FAILED(result)) {
bytes.SetDataSize(0);
}
return result;
@@ -1614,36 +1462,25 @@ AP4_DataAtom::LoadBytes(AP4_DataBuffer& bytes)
| AP4_DataAtom::LoadInteger
+---------------------------------------------------------------------*/
AP4_Result
-AP4_DataAtom::LoadInteger(long& value)
+AP4_DataAtom::LoadInteger(long& value)
{
AP4_Result result = AP4_FAILURE;
value = 0;
- if(m_Source == NULL) return AP4_SUCCESS;
+ if (m_Source == NULL) return AP4_SUCCESS;
AP4_LargeSize size = 0;
m_Source->GetSize(size);
- if(size > 4)
- {
+ if (size > 4) {
return AP4_ERROR_OUT_OF_RANGE;
}
unsigned char bytes[4];
m_Source->Seek(0);
m_Source->Read(bytes, (AP4_Size)size);
result = AP4_SUCCESS;
- switch(size)
- {
- case 1:
- value = bytes[0];
- break;
- case 2:
- value = AP4_BytesToInt16BE(bytes);
- break;
- case 4:
- value = AP4_BytesToInt32BE(bytes);
- break;
- default:
- value = 0;
- result = AP4_ERROR_INVALID_FORMAT;
- break;
+ switch (size) {
+ case 1: value = bytes[0]; break;
+ case 2: value = AP4_BytesToInt16BE(bytes); break;
+ case 4: value = AP4_BytesToInt32BE(bytes); break;
+ default: value = 0; result = AP4_ERROR_INVALID_FORMAT; break;
}
return result;
}
@@ -1655,7 +1492,7 @@ AP4_MetaDataStringAtom::AP4_MetaDataStringAtom(Type type, const char* value) :
AP4_Atom(type, AP4_ATOM_HEADER_SIZE),
m_Value(value)
{
- m_Size32 += 4 + m_Value.GetLength();
+ m_Size32 += 4+m_Value.GetLength();
}
/*----------------------------------------------------------------------
@@ -1663,7 +1500,7 @@ AP4_MetaDataStringAtom::AP4_MetaDataStringAtom(Type type, const char* value) :
+---------------------------------------------------------------------*/
AP4_MetaDataStringAtom::AP4_MetaDataStringAtom(Type type, AP4_UI32 size, AP4_ByteStream& stream) :
AP4_Atom(type, size),
- m_Value((AP4_Size)(size - AP4_ATOM_HEADER_SIZE - 4))
+ m_Value((AP4_Size)(size-AP4_ATOM_HEADER_SIZE-4))
{
stream.ReadUI32(m_Reserved);
stream.Read(m_Value.UseChars(), m_Value.GetLength());
@@ -1693,55 +1530,54 @@ AP4_MetaDataStringAtom::InspectFields(AP4_AtomInspector& inspector)
| AP4_3GppLocalizedStringAtom::Create
+---------------------------------------------------------------------*/
AP4_3GppLocalizedStringAtom*
-AP4_3GppLocalizedStringAtom::Create(Type type, AP4_UI32 size, AP4_ByteStream& stream)
+AP4_3GppLocalizedStringAtom::Create(Type type, AP4_UI32 size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_3GppLocalizedStringAtom(type, size, version, flags, stream);
}
/*----------------------------------------------------------------------
| AP4_3GppLocalizedStringAtom::AP4_3GppLocalizedStringAtom
+---------------------------------------------------------------------*/
-AP4_3GppLocalizedStringAtom::AP4_3GppLocalizedStringAtom(Type type,
- const char* language,
- const char* value) :
- AP4_Atom(type, AP4_FULL_ATOM_HEADER_SIZE + 2, 0, 0),
+AP4_3GppLocalizedStringAtom::AP4_3GppLocalizedStringAtom(Type type,
+ const char* language,
+ const char* value) :
+ AP4_Atom(type, AP4_FULL_ATOM_HEADER_SIZE+2, 0, 0),
m_Value(value)
{
m_Language[0] = language[0];
m_Language[1] = language[1];
m_Language[2] = language[2];
m_Language[3] = language[3];
-
- m_Size32 += m_Value.GetLength() + 1;
+
+ m_Size32 += m_Value.GetLength()+1;
}
/*----------------------------------------------------------------------
| AP4_3GppLocalizedStringAtom::AP4_3GppLocalizedStringAtom
+---------------------------------------------------------------------*/
-AP4_3GppLocalizedStringAtom::AP4_3GppLocalizedStringAtom(Type type,
- AP4_UI32 size,
- AP4_UI32 version,
- AP4_UI32 flags,
- AP4_ByteStream& stream) :
+AP4_3GppLocalizedStringAtom::AP4_3GppLocalizedStringAtom(Type type,
+ AP4_UI32 size,
+ AP4_UI32 version,
+ AP4_UI32 flags,
+ AP4_ByteStream& stream) :
AP4_Atom(type, size, version, flags)
{
// read the language code
AP4_UI16 packed_language;
stream.ReadUI16(packed_language);
- m_Language[0] = 0x60 + ((packed_language >> 10) & 0x1F);
- m_Language[1] = 0x60 + ((packed_language >> 5) & 0x1F);
- m_Language[2] = 0x60 + ((packed_language) & 0x1F);
+ m_Language[0] = 0x60+((packed_language>>10)&0x1F);
+ m_Language[1] = 0x60+((packed_language>> 5)&0x1F);
+ m_Language[2] = 0x60+((packed_language )&0x1F);
m_Language[3] = '\0';
-
+
// read the value (should be a NULL-terminated string, but we'll
// allow for strings that are not terminated)
- if(size > AP4_FULL_ATOM_HEADER_SIZE + 2)
- {
- AP4_UI32 value_size = size - (AP4_FULL_ATOM_HEADER_SIZE + 2);
+ if (size > AP4_FULL_ATOM_HEADER_SIZE+2) {
+ AP4_UI32 value_size = size-(AP4_FULL_ATOM_HEADER_SIZE+2);
char* value = new char[value_size];
stream.Read(value, value_size);
m_Value.Assign(value, value_size);
@@ -1755,20 +1591,18 @@ AP4_3GppLocalizedStringAtom::AP4_3GppLocalizedStringAtom(Type type,
AP4_Result
AP4_3GppLocalizedStringAtom::WriteFields(AP4_ByteStream& stream)
{
- AP4_UI16 packed_language = ((m_Language[0] - 0x60) << 10) |
- ((m_Language[1] - 0x60) << 5) |
- ((m_Language[2] - 0x60));
+ AP4_UI16 packed_language = ((m_Language[0]-0x60)<<10) |
+ ((m_Language[1]-0x60)<< 5) |
+ ((m_Language[2]-0x60));
stream.WriteUI16(packed_language);
- AP4_Size payload_size = (AP4_UI32)GetSize() - GetHeaderSize();
- if(payload_size < 2) return AP4_ERROR_INVALID_FORMAT;
- AP4_Size value_size = m_Value.GetLength() + 1;
- if(value_size > payload_size - 2)
- {
- value_size = payload_size - 2;
+ AP4_Size payload_size = (AP4_UI32)GetSize()-GetHeaderSize();
+ if (payload_size < 2) return AP4_ERROR_INVALID_FORMAT;
+ AP4_Size value_size = m_Value.GetLength()+1;
+ if (value_size > payload_size-2) {
+ value_size = payload_size-2;
}
stream.Write(m_Value.GetChars(), value_size);
- for(unsigned int i = value_size; i < payload_size - 2; i++)
- {
+ for (unsigned int i=value_size; i<payload_size-2; i++) {
stream.WriteUI08(0);
}
return AP4_SUCCESS;
@@ -1789,12 +1623,12 @@ AP4_3GppLocalizedStringAtom::InspectFields(AP4_AtomInspector& inspector)
| AP4_DcfStringAtom::Create
+---------------------------------------------------------------------*/
AP4_DcfStringAtom*
-AP4_DcfStringAtom::Create(Type type, AP4_UI32 size, AP4_ByteStream& stream)
+AP4_DcfStringAtom::Create(Type type, AP4_UI32 size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
return new AP4_DcfStringAtom(type, size, version, flags, stream);
}
@@ -1811,16 +1645,15 @@ AP4_DcfStringAtom::AP4_DcfStringAtom(Type type, const char* value) :
/*----------------------------------------------------------------------
| AP4_DcfStringAtom::AP4_DcfStringAtom
+---------------------------------------------------------------------*/
-AP4_DcfStringAtom::AP4_DcfStringAtom(Type type,
- AP4_UI32 size,
+AP4_DcfStringAtom::AP4_DcfStringAtom(Type type,
+ AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
AP4_Atom(type, size, version, flags)
{
- if(size > AP4_FULL_ATOM_HEADER_SIZE)
- {
- AP4_UI32 value_size = size - (AP4_FULL_ATOM_HEADER_SIZE);
+ if (size > AP4_FULL_ATOM_HEADER_SIZE) {
+ AP4_UI32 value_size = size-(AP4_FULL_ATOM_HEADER_SIZE);
char* value = new char[value_size];
stream.Read(value, value_size);
m_Value.Assign(value, value_size);
@@ -1834,7 +1667,7 @@ AP4_DcfStringAtom::AP4_DcfStringAtom(Type type,
AP4_Result
AP4_DcfStringAtom::WriteFields(AP4_ByteStream& stream)
{
- if(m_Value.GetLength()) stream.Write(m_Value.GetChars(), m_Value.GetLength());
+ if (m_Value.GetLength()) stream.Write(m_Value.GetChars(), m_Value.GetLength());
return AP4_SUCCESS;
}
@@ -1852,13 +1685,13 @@ AP4_DcfStringAtom::InspectFields(AP4_AtomInspector& inspector)
| AP4_DcfdAtom::Create
+---------------------------------------------------------------------*/
AP4_DcfdAtom*
-AP4_DcfdAtom::Create(AP4_UI32 size, AP4_ByteStream& stream)
+AP4_DcfdAtom::Create(AP4_UI32 size, AP4_ByteStream& stream)
{
AP4_UI32 version;
AP4_UI32 flags;
- if(AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
- if(version != 0) return NULL;
- if(size != AP4_FULL_ATOM_HEADER_SIZE + 4) return NULL;
+ if (AP4_FAILED(AP4_Atom::ReadFullHeader(stream, version, flags))) return NULL;
+ if (version != 0) return NULL;
+ if (size != AP4_FULL_ATOM_HEADER_SIZE+4) return NULL;
return new AP4_DcfdAtom(version, flags, stream);
}
@@ -1868,7 +1701,7 @@ AP4_DcfdAtom::Create(AP4_UI32 size, AP4_ByteStream& stream)
AP4_DcfdAtom::AP4_DcfdAtom(AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_DCFD, AP4_FULL_ATOM_HEADER_SIZE + 4, version, flags)
+ AP4_Atom(AP4_ATOM_TYPE_DCFD, AP4_FULL_ATOM_HEADER_SIZE+4, version, flags)
{
stream.ReadUI32(m_Duration);
}
@@ -1877,7 +1710,7 @@ AP4_DcfdAtom::AP4_DcfdAtom(AP4_UI32 version,
| AP4_DcfdAtom::AP4_DcfdAtom
+---------------------------------------------------------------------*/
AP4_DcfdAtom::AP4_DcfdAtom(AP4_UI32 duration) :
- AP4_Atom(AP4_ATOM_TYPE_DCFD, AP4_FULL_ATOM_HEADER_SIZE + 4, 0, 0),
+ AP4_Atom(AP4_ATOM_TYPE_DCFD, AP4_FULL_ATOM_HEADER_SIZE+4, 0, 0),
m_Duration(duration)
{
}
diff --git a/src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.h b/src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.h
index b8d488b7b..491365f11 100644
--- a/src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.h
+++ b/src/filters/parser/MP4Splitter/AP4/Source/MetaData/Ap4MetaData.h
@@ -1,6 +1,6 @@
/*****************************************************************
|
-| AP4 - MetaData
+| AP4 - MetaData
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
@@ -53,98 +53,90 @@ class AP4_DcfdAtom;
/*----------------------------------------------------------------------
| metadata keys
+---------------------------------------------------------------------*/
-const AP4_Atom::Type AP4_ATOM_TYPE_DATA = AP4_ATOM_TYPE('d', 'a', 't', 'a'); // data
-const AP4_Atom::Type AP4_ATOM_TYPE_MEAN = AP4_ATOM_TYPE('m', 'e', 'a', 'n'); // namespace
-const AP4_Atom::Type AP4_ATOM_TYPE_NAME = AP4_ATOM_TYPE('n', 'a', 'm', 'e'); // name
-const AP4_Atom::Type AP4_ATOM_TYPE_dddd = AP4_ATOM_TYPE('-', '-', '-', '-'); // free form
-const AP4_Atom::Type AP4_ATOM_TYPE_cNAM = AP4_ATOM_TYPE(0xA9, 'n', 'a', 'm'); // name
-const AP4_Atom::Type AP4_ATOM_TYPE_cART = AP4_ATOM_TYPE(0xA9, 'A', 'R', 'T'); // artist
-const AP4_Atom::Type AP4_ATOM_TYPE_cCOM = AP4_ATOM_TYPE(0xA9, 'c', 'o', 'm'); // composer
-const AP4_Atom::Type AP4_ATOM_TYPE_cWRT = AP4_ATOM_TYPE(0xA9, 'w', 'r', 't'); // writer
-const AP4_Atom::Type AP4_ATOM_TYPE_cALB = AP4_ATOM_TYPE(0xA9, 'a', 'l', 'b'); // album
-const AP4_Atom::Type AP4_ATOM_TYPE_cGEN = AP4_ATOM_TYPE(0xA9, 'g', 'e', 'n'); // genre
-const AP4_Atom::Type AP4_ATOM_TYPE_cGRP = AP4_ATOM_TYPE(0xA9, 'g', 'r', 'p'); // group
-const AP4_Atom::Type AP4_ATOM_TYPE_cDAY = AP4_ATOM_TYPE(0xA9, 'd', 'a', 'y'); // date
-const AP4_Atom::Type AP4_ATOM_TYPE_cTOO = AP4_ATOM_TYPE(0xA9, 't', 'o', 'o'); // tool
-const AP4_Atom::Type AP4_ATOM_TYPE_cCMT = AP4_ATOM_TYPE(0xA9, 'c', 'm', 't'); // comment
-const AP4_Atom::Type AP4_ATOM_TYPE_cLYR = AP4_ATOM_TYPE(0xA9, 'l', 'y', 'r'); // lyrics
-const AP4_Atom::Type AP4_ATOM_TYPE_TRKN = AP4_ATOM_TYPE('t', 'r', 'k', 'n'); // track#
-const AP4_Atom::Type AP4_ATOM_TYPE_DISK = AP4_ATOM_TYPE('d', 'i', 's', 'k'); // disk#
-const AP4_Atom::Type AP4_ATOM_TYPE_COVR = AP4_ATOM_TYPE('c', 'o', 'v', 'r'); // cover art
-const AP4_Atom::Type AP4_ATOM_TYPE_DESC = AP4_ATOM_TYPE('d', 'e', 's', 'c'); // description
-const AP4_Atom::Type AP4_ATOM_TYPE_CPIL = AP4_ATOM_TYPE('c', 'p', 'i', 'l'); // compilation?
-const AP4_Atom::Type AP4_ATOM_TYPE_TMPO = AP4_ATOM_TYPE('t', 'm', 'p', 'o'); // tempo
-const AP4_Atom::Type AP4_ATOM_TYPE_apID = AP4_ATOM_TYPE('a', 'p', 'I', 'D');
-const AP4_Atom::Type AP4_ATOM_TYPE_cnID = AP4_ATOM_TYPE('c', 'n', 'I', 'D');
-const AP4_Atom::Type AP4_ATOM_TYPE_cmID = AP4_ATOM_TYPE('c', 'm', 'I', 'D');
-const AP4_Atom::Type AP4_ATOM_TYPE_atID = AP4_ATOM_TYPE('a', 't', 'I', 'D');
-const AP4_Atom::Type AP4_ATOM_TYPE_plID = AP4_ATOM_TYPE('p', 'l', 'I', 'D');
-const AP4_Atom::Type AP4_ATOM_TYPE_geID = AP4_ATOM_TYPE('g', 'e', 'I', 'D');
-const AP4_Atom::Type AP4_ATOM_TYPE_sfID = AP4_ATOM_TYPE('s', 'f', 'I', 'D');
-const AP4_Atom::Type AP4_ATOM_TYPE_akID = AP4_ATOM_TYPE('a', 'k', 'I', 'D');
-const AP4_Atom::Type AP4_ATOM_TYPE_aART = AP4_ATOM_TYPE('a', 'A', 'R', 'T');
-const AP4_Atom::Type AP4_ATOM_TYPE_TVNN = AP4_ATOM_TYPE('t', 'v', 'n', 'n'); // TV network
-const AP4_Atom::Type AP4_ATOM_TYPE_TVSH = AP4_ATOM_TYPE('t', 'v', 's', 'h'); // TV show
-const AP4_Atom::Type AP4_ATOM_TYPE_TVEN = AP4_ATOM_TYPE('t', 'v', 'e', 'n'); // TV episode name
-const AP4_Atom::Type AP4_ATOM_TYPE_TVSN = AP4_ATOM_TYPE('t', 'v', 's', 'n'); // TV show season #
-const AP4_Atom::Type AP4_ATOM_TYPE_TVES = AP4_ATOM_TYPE('t', 'v', 'e', 's'); // TV show episode #
-const AP4_Atom::Type AP4_ATOM_TYPE_STIK = AP4_ATOM_TYPE('s', 't', 'i', 'k');
-const AP4_Atom::Type AP4_ATOM_TYPE_PCST = AP4_ATOM_TYPE('p', 'c', 's', 't'); // Podcast?
-const AP4_Atom::Type AP4_ATOM_TYPE_PURD = AP4_ATOM_TYPE('p', 'u', 'r', 'd'); //
-const AP4_Atom::Type AP4_ATOM_TYPE_PURL = AP4_ATOM_TYPE('p', 'u', 'r', 'l'); // Podcast URL (binary)
-const AP4_Atom::Type AP4_ATOM_TYPE_EGID = AP4_ATOM_TYPE('e', 'g', 'i', 'd'); //
-const AP4_Atom::Type AP4_ATOM_TYPE_PGAP = AP4_ATOM_TYPE('p', 'g', 'a', 'p'); // Gapless Playback
-const AP4_Atom::Type AP4_ATOM_TYPE_CATG = AP4_ATOM_TYPE('c', 'a', 't', 'g'); // Category
-const AP4_Atom::Type AP4_ATOM_TYPE_KEYW = AP4_ATOM_TYPE('k', 'e', 'y', 'w'); // Keywords
-const AP4_Atom::Type AP4_ATOM_TYPE_SONM = AP4_ATOM_TYPE('s', 'o', 'n', 'm'); // Sort-Order: Name
-const AP4_Atom::Type AP4_ATOM_TYPE_SOAL = AP4_ATOM_TYPE('s', 'o', 'a', 'l'); // Sort-Order: Album
-const AP4_Atom::Type AP4_ATOM_TYPE_SOAR = AP4_ATOM_TYPE('s', 'o', 'a', 'r'); // Sort-Order: Artist
-const AP4_Atom::Type AP4_ATOM_TYPE_SOAA = AP4_ATOM_TYPE('s', 'o', 'a', 'a'); // Sort-Order: Album Artist
-const AP4_Atom::Type AP4_ATOM_TYPE_SOCO = AP4_ATOM_TYPE('s', 'o', 'c', 'o'); // Sort-Order: Composer
-const AP4_Atom::Type AP4_ATOM_TYPE_SOSN = AP4_ATOM_TYPE('s', 'o', 's', 'n'); // Sort-Order: Show
-
-const AP4_Atom::Type AP4_ATOM_TYPE_TITL = AP4_ATOM_TYPE('t', 'i', 't', 'l'); // 3GPP: title
-const AP4_Atom::Type AP4_ATOM_TYPE_DSCP = AP4_ATOM_TYPE('d', 's', 'c', 'p'); // 3GPP: description
-const AP4_Atom::Type AP4_ATOM_TYPE_CPRT = AP4_ATOM_TYPE('c', 'p', 'r', 't'); // 3GPP, ISO or ILST: copyright
-const AP4_Atom::Type AP4_ATOM_TYPE_PERF = AP4_ATOM_TYPE('p', 'e', 'r', 'f'); // 3GPP: performer
-const AP4_Atom::Type AP4_ATOM_TYPE_AUTH = AP4_ATOM_TYPE('a', 'u', 't', 'h'); // 3GPP: author
-const AP4_Atom::Type AP4_ATOM_TYPE_GNRE = AP4_ATOM_TYPE('g', 'n', 'r', 'e'); // 3GPP or ILST: genre (in 3GPP -> string, in ILST -> ID3v1 index + 1)
-const AP4_Atom::Type AP4_ATOM_TYPE_RTNG = AP4_ATOM_TYPE('r', 't', 'n', 'g'); // 3GPP or ILST: rating
-const AP4_Atom::Type AP4_ATOM_TYPE_CLSF = AP4_ATOM_TYPE('c', 'l', 's', 'f'); // 3GPP: classification
-const AP4_Atom::Type AP4_ATOM_TYPE_KYWD = AP4_ATOM_TYPE('k', 'y', 'w', 'd'); // 3GPP: keywords
-const AP4_Atom::Type AP4_ATOM_TYPE_LOCI = AP4_ATOM_TYPE('l', 'o', 'c', 'i'); // 3GPP: location information
-const AP4_Atom::Type AP4_ATOM_TYPE_ALBM = AP4_ATOM_TYPE('a', 'l', 'b', 'm'); // 3GPP: album title and track number
-const AP4_Atom::Type AP4_ATOM_TYPE_YRRC = AP4_ATOM_TYPE('y', 'r', 'r', 'c'); // 3GPP: recording year
-const AP4_Atom::Type AP4_ATOM_TYPE_TSEL = AP4_ATOM_TYPE('t', 's', 'e', 'l'); // 3GPP: track selection
-
-const AP4_Atom::Type AP4_ATOM_TYPE_ICNU = AP4_ATOM_TYPE('i', 'c', 'n', 'u'); // DCF: icon URI (OMA DCF 2.1)
-const AP4_Atom::Type AP4_ATOM_TYPE_INFU = AP4_ATOM_TYPE('i', 'n', 'f', 'u'); // DCF: info URI (OMA DCF 2.1)
-const AP4_Atom::Type AP4_ATOM_TYPE_CVRU = AP4_ATOM_TYPE('c', 'v', 'r', 'u'); // DCF: cover art URI (OMA DCF 2.1)
-const AP4_Atom::Type AP4_ATOM_TYPE_LRCU = AP4_ATOM_TYPE('l', 'r', 'c', 'u'); // DCF: lyrics URI (OMA DCF 2.1)
-const AP4_Atom::Type AP4_ATOM_TYPE_DCFD = AP4_ATOM_TYPE('d', 'c', 'f', 'D'); // DCF: duration (OMarlin)
+const AP4_Atom::Type AP4_ATOM_TYPE_DATA = AP4_ATOM_TYPE('d','a','t','a'); // data
+const AP4_Atom::Type AP4_ATOM_TYPE_MEAN = AP4_ATOM_TYPE('m','e','a','n'); // namespace
+const AP4_Atom::Type AP4_ATOM_TYPE_NAME = AP4_ATOM_TYPE('n','a','m','e'); // name
+const AP4_Atom::Type AP4_ATOM_TYPE_dddd = AP4_ATOM_TYPE('-','-','-','-'); // free form
+const AP4_Atom::Type AP4_ATOM_TYPE_cNAM = AP4_ATOM_TYPE(0xA9,'n','a','m'); // name
+const AP4_Atom::Type AP4_ATOM_TYPE_cART = AP4_ATOM_TYPE(0xA9,'A','R','T'); // artist
+const AP4_Atom::Type AP4_ATOM_TYPE_cCOM = AP4_ATOM_TYPE(0xA9,'c','o','m'); // composer
+const AP4_Atom::Type AP4_ATOM_TYPE_cWRT = AP4_ATOM_TYPE(0xA9,'w','r','t'); // writer
+const AP4_Atom::Type AP4_ATOM_TYPE_cALB = AP4_ATOM_TYPE(0xA9,'a','l','b'); // album
+const AP4_Atom::Type AP4_ATOM_TYPE_cGEN = AP4_ATOM_TYPE(0xA9,'g','e','n'); // genre
+const AP4_Atom::Type AP4_ATOM_TYPE_cGRP = AP4_ATOM_TYPE(0xA9,'g','r','p'); // group
+const AP4_Atom::Type AP4_ATOM_TYPE_cDAY = AP4_ATOM_TYPE(0xA9,'d','a','y'); // date
+const AP4_Atom::Type AP4_ATOM_TYPE_cTOO = AP4_ATOM_TYPE(0xA9,'t','o','o'); // tool
+const AP4_Atom::Type AP4_ATOM_TYPE_cCMT = AP4_ATOM_TYPE(0xA9,'c','m','t'); // comment
+const AP4_Atom::Type AP4_ATOM_TYPE_cLYR = AP4_ATOM_TYPE(0xA9,'l','y','r'); // lyrics
+const AP4_Atom::Type AP4_ATOM_TYPE_TRKN = AP4_ATOM_TYPE('t','r','k','n'); // track#
+const AP4_Atom::Type AP4_ATOM_TYPE_DISK = AP4_ATOM_TYPE('d','i','s','k'); // disk#
+const AP4_Atom::Type AP4_ATOM_TYPE_COVR = AP4_ATOM_TYPE('c','o','v','r'); // cover art
+const AP4_Atom::Type AP4_ATOM_TYPE_DESC = AP4_ATOM_TYPE('d','e','s','c'); // description
+const AP4_Atom::Type AP4_ATOM_TYPE_CPIL = AP4_ATOM_TYPE('c','p','i','l'); // compilation?
+const AP4_Atom::Type AP4_ATOM_TYPE_TMPO = AP4_ATOM_TYPE('t','m','p','o'); // tempo
+const AP4_Atom::Type AP4_ATOM_TYPE_apID = AP4_ATOM_TYPE('a','p','I','D');
+const AP4_Atom::Type AP4_ATOM_TYPE_cnID = AP4_ATOM_TYPE('c','n','I','D');
+const AP4_Atom::Type AP4_ATOM_TYPE_cmID = AP4_ATOM_TYPE('c','m','I','D');
+const AP4_Atom::Type AP4_ATOM_TYPE_atID = AP4_ATOM_TYPE('a','t','I','D');
+const AP4_Atom::Type AP4_ATOM_TYPE_plID = AP4_ATOM_TYPE('p','l','I','D');
+const AP4_Atom::Type AP4_ATOM_TYPE_geID = AP4_ATOM_TYPE('g','e','I','D');
+const AP4_Atom::Type AP4_ATOM_TYPE_sfID = AP4_ATOM_TYPE('s','f','I','D');
+const AP4_Atom::Type AP4_ATOM_TYPE_akID = AP4_ATOM_TYPE('a','k','I','D');
+const AP4_Atom::Type AP4_ATOM_TYPE_aART = AP4_ATOM_TYPE('a','A','R','T');
+const AP4_Atom::Type AP4_ATOM_TYPE_TVNN = AP4_ATOM_TYPE('t','v','n','n'); // TV network
+const AP4_Atom::Type AP4_ATOM_TYPE_TVSH = AP4_ATOM_TYPE('t','v','s','h'); // TV show
+const AP4_Atom::Type AP4_ATOM_TYPE_TVEN = AP4_ATOM_TYPE('t','v','e','n'); // TV episode name
+const AP4_Atom::Type AP4_ATOM_TYPE_TVSN = AP4_ATOM_TYPE('t','v','s','n'); // TV show season #
+const AP4_Atom::Type AP4_ATOM_TYPE_TVES = AP4_ATOM_TYPE('t','v','e','s'); // TV show episode #
+const AP4_Atom::Type AP4_ATOM_TYPE_STIK = AP4_ATOM_TYPE('s','t','i','k');
+const AP4_Atom::Type AP4_ATOM_TYPE_PCST = AP4_ATOM_TYPE('p','c','s','t'); // Podcast?
+const AP4_Atom::Type AP4_ATOM_TYPE_PURD = AP4_ATOM_TYPE('p','u','r','d'); //
+const AP4_Atom::Type AP4_ATOM_TYPE_PURL = AP4_ATOM_TYPE('p','u','r','l'); // Podcast URL (binary)
+const AP4_Atom::Type AP4_ATOM_TYPE_EGID = AP4_ATOM_TYPE('e','g','i','d'); //
+const AP4_Atom::Type AP4_ATOM_TYPE_PGAP = AP4_ATOM_TYPE('p','g','a','p'); // Gapless Playback
+const AP4_Atom::Type AP4_ATOM_TYPE_CATG = AP4_ATOM_TYPE('c','a','t','g'); // Category
+const AP4_Atom::Type AP4_ATOM_TYPE_KEYW = AP4_ATOM_TYPE('k','e','y','w'); // Keywords
+const AP4_Atom::Type AP4_ATOM_TYPE_SONM = AP4_ATOM_TYPE('s','o','n','m'); // Sort-Order: Name
+const AP4_Atom::Type AP4_ATOM_TYPE_SOAL = AP4_ATOM_TYPE('s','o','a','l'); // Sort-Order: Album
+const AP4_Atom::Type AP4_ATOM_TYPE_SOAR = AP4_ATOM_TYPE('s','o','a','r'); // Sort-Order: Artist
+const AP4_Atom::Type AP4_ATOM_TYPE_SOAA = AP4_ATOM_TYPE('s','o','a','a'); // Sort-Order: Album Artist
+const AP4_Atom::Type AP4_ATOM_TYPE_SOCO = AP4_ATOM_TYPE('s','o','c','o'); // Sort-Order: Composer
+const AP4_Atom::Type AP4_ATOM_TYPE_SOSN = AP4_ATOM_TYPE('s','o','s','n'); // Sort-Order: Show
+
+const AP4_Atom::Type AP4_ATOM_TYPE_TITL = AP4_ATOM_TYPE('t','i','t','l'); // 3GPP: title
+const AP4_Atom::Type AP4_ATOM_TYPE_DSCP = AP4_ATOM_TYPE('d','s','c','p'); // 3GPP: description
+const AP4_Atom::Type AP4_ATOM_TYPE_CPRT = AP4_ATOM_TYPE('c','p','r','t'); // 3GPP, ISO or ILST: copyright
+const AP4_Atom::Type AP4_ATOM_TYPE_PERF = AP4_ATOM_TYPE('p','e','r','f'); // 3GPP: performer
+const AP4_Atom::Type AP4_ATOM_TYPE_AUTH = AP4_ATOM_TYPE('a','u','t','h'); // 3GPP: author
+const AP4_Atom::Type AP4_ATOM_TYPE_GNRE = AP4_ATOM_TYPE('g','n','r','e'); // 3GPP or ILST: genre (in 3GPP -> string, in ILST -> ID3v1 index + 1)
+const AP4_Atom::Type AP4_ATOM_TYPE_RTNG = AP4_ATOM_TYPE('r','t','n','g'); // 3GPP or ILST: rating
+const AP4_Atom::Type AP4_ATOM_TYPE_CLSF = AP4_ATOM_TYPE('c','l','s','f'); // 3GPP: classification
+const AP4_Atom::Type AP4_ATOM_TYPE_KYWD = AP4_ATOM_TYPE('k','y','w','d'); // 3GPP: keywords
+const AP4_Atom::Type AP4_ATOM_TYPE_LOCI = AP4_ATOM_TYPE('l','o','c','i'); // 3GPP: location information
+const AP4_Atom::Type AP4_ATOM_TYPE_ALBM = AP4_ATOM_TYPE('a','l','b','m'); // 3GPP: album title and track number
+const AP4_Atom::Type AP4_ATOM_TYPE_YRRC = AP4_ATOM_TYPE('y','r','r','c'); // 3GPP: recording year
+const AP4_Atom::Type AP4_ATOM_TYPE_TSEL = AP4_ATOM_TYPE('t','s','e','l'); // 3GPP: track selection
+
+const AP4_Atom::Type AP4_ATOM_TYPE_ICNU = AP4_ATOM_TYPE('i','c','n','u'); // DCF: icon URI (OMA DCF 2.1)
+const AP4_Atom::Type AP4_ATOM_TYPE_INFU = AP4_ATOM_TYPE('i','n','f','u'); // DCF: info URI (OMA DCF 2.1)
+const AP4_Atom::Type AP4_ATOM_TYPE_CVRU = AP4_ATOM_TYPE('c','v','r','u'); // DCF: cover art URI (OMA DCF 2.1)
+const AP4_Atom::Type AP4_ATOM_TYPE_LRCU = AP4_ATOM_TYPE('l','r','c','u'); // DCF: lyrics URI (OMA DCF 2.1)
+const AP4_Atom::Type AP4_ATOM_TYPE_DCFD = AP4_ATOM_TYPE('d','c','f','D'); // DCF: duration (OMarlin)
/*----------------------------------------------------------------------
| AP4_MetaData
+---------------------------------------------------------------------*/
-class AP4_MetaData
-{
+class AP4_MetaData {
public:
- class Key
- {
+ class Key {
public:
// constructors
Key(const char* name, const char* ns) :
- m_Name(name), m_Namespace(ns) {}
+ m_Name(name), m_Namespace(ns) {}
// methods
- const AP4_String& GetNamespace() const
- {
- return m_Namespace;
- }
- const AP4_String& GetName() const
- {
- return m_Name;
- }
+ const AP4_String& GetNamespace() const { return m_Namespace; }
+ const AP4_String& GetName() const { return m_Name; }
private:
// members
@@ -152,12 +144,10 @@ public:
const AP4_String m_Namespace;
};
- class Value
- {
+ class Value {
public:
- // types
- typedef enum
- {
+ // types
+ typedef enum {
TYPE_BINARY,
TYPE_STRING_UTF_8,
TYPE_STRING_UTF_16,
@@ -171,55 +161,41 @@ public:
TYPE_FLOAT_64_BE
} Type;
- typedef enum
- {
+ typedef enum {
TYPE_CATEGORY_STRING,
TYPE_CATEGORY_BINARY,
TYPE_CATEGORY_INTEGER,
TYPE_CATEGORY_FLOAT
} TypeCategory;
- typedef enum
- {
+ typedef enum {
MEANING_UNKNOWN,
MEANING_ID3_GENRE,
MEANING_BOOLEAN,
MEANING_FILE_KIND,
MEANING_BINARY_ENCODED_CHARS
} Meaning;
-
+
// destructor
virtual ~Value() {}
// methods
- Type GetType() const
- {
- return m_Type;
- }
+ Type GetType() const { return m_Type; }
TypeCategory GetTypeCategory() const;
- Meaning GetMeaning() const
- {
- return m_Meaning;
- }
- const AP4_String& GetLanguage() const
- {
- return m_Language;
- }
- void SetLanguage(const char* language)
- {
- m_Language = language;
- }
+ Meaning GetMeaning() const { return m_Meaning; }
+ const AP4_String& GetLanguage() const { return m_Language; }
+ void SetLanguage(const char* language) { m_Language = language; }
virtual AP4_String ToString() const = 0;
virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) const = 0;
virtual long ToInteger() const = 0;
-
+
protected:
// class methods
static TypeCategory MapTypeToCategory(Type type);
-
+
// constructor
- Value(Type type,
- Meaning meaning = MEANING_UNKNOWN,
+ Value(Type type,
+ Meaning meaning = MEANING_UNKNOWN,
const char* language = NULL) :
m_Type(type), m_Meaning(meaning), m_Language(language) {}
@@ -228,9 +204,8 @@ public:
Meaning m_Meaning;
AP4_String m_Language;
};
-
- class KeyInfo
- {
+
+ class KeyInfo {
public:
// members
const char* name;
@@ -239,18 +214,14 @@ public:
Value::Type value_type;
};
- class Entry
- {
+ class Entry {
public:
// constructor
Entry(const char* name, const char* ns, Value* value) :
- m_Key(name, ns), m_Value(value) {}
+ m_Key(name, ns), m_Value(value) {}
// destructor
- ~Entry()
- {
- delete m_Value;
- }
+ ~Entry() { delete m_Value; }
// methods
AP4_Result AddToFile(AP4_File& file, AP4_Ordinal index = 0);
@@ -264,7 +235,7 @@ public:
// members
Key m_Key;
- Value* m_Value;
+ Value* m_Value;
};
// class members
@@ -272,19 +243,16 @@ public:
// constructor
AP4_MetaData(AP4_File* file);
-
+
// methods
AP4_Result ParseMoov(AP4_MoovAtom* moov);
AP4_Result ParseUdta(AP4_ContainerAtom* udta, const char* namespc);
-
+
// destructor
~AP4_MetaData();
// accessors
- const AP4_List<Entry>& GetEntries() const
- {
- return m_Entries;
- }
+ const AP4_List<Entry>& GetEntries() const { return m_Entries; }
// methods
AP4_Result ResolveKeyName(AP4_Atom::Type atom_type, AP4_String& value);
@@ -292,7 +260,7 @@ public:
AP4_Result Add3GppEntry(AP4_3GppLocalizedStringAtom* atom, const char* namespc);
AP4_Result AddDcfStringEntry(AP4_DcfStringAtom* atom, const char* namespc);
AP4_Result AddDcfdEntry(AP4_DcfdAtom* atom, const char* namespc);
-
+
private:
// members
AP4_List<Entry> m_Entries;
@@ -306,7 +274,7 @@ class AP4_MetaDataAtomTypeHandler : public AP4_AtomFactory::TypeHandler
public:
// constructor
AP4_MetaDataAtomTypeHandler(AP4_AtomFactory* atom_factory) :
- m_AtomFactory(atom_factory) {}
+ m_AtomFactory(atom_factory) {}
virtual AP4_Result CreateAtom(AP4_Atom::Type type,
AP4_UI32 size,
AP4_ByteStream& stream,
@@ -314,12 +282,11 @@ public:
AP4_Atom*& atom);
// types
- struct TypeList
- {
+ struct TypeList {
const AP4_Atom::Type* m_Types;
AP4_Size m_Size;
};
-
+
// class constants
static const AP4_Atom::Type IlstTypes[];
static const TypeList IlstTypeList;
@@ -329,7 +296,7 @@ public:
static const TypeList _3gppOtherTypeList;
static const AP4_Atom::Type DcfStringTypes[];
static const TypeList DcfStringTypeList;
-
+
// class methods
static bool IsTypeInList(AP4_Atom::Type type, const TypeList& list);
@@ -354,9 +321,9 @@ public:
protected:
// constructor
- AP4_MetaDataTag(AP4_UI32 data_type,
+ AP4_MetaDataTag(AP4_UI32 data_type,
AP4_UI32 data_lang,
- AP4_Size size,
+ AP4_Size size,
AP4_ByteStream& stream);
};
@@ -371,29 +338,23 @@ public:
// factory method
static AP4_3GppLocalizedStringAtom* Create(Type type, AP4_UI32 size, AP4_ByteStream& stream);
-
+
// constructor
AP4_3GppLocalizedStringAtom(Type type, const char* language, const char* value);
- AP4_3GppLocalizedStringAtom(Type type,
- AP4_UI32 size,
+ AP4_3GppLocalizedStringAtom(Type type,
+ AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
-
+
// AP4_Atom methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
// methods
- const char* GetLanguage() const
- {
- return m_Language;
- }
- const AP4_String& GetValue() const
- {
- return m_Value;
- }
-
+ const char* GetLanguage() const { return m_Language; }
+ const AP4_String& GetValue() const { return m_Value; }
+
private:
// members
char m_Language[4];
@@ -410,25 +371,22 @@ public:
// factory method
static AP4_DcfStringAtom* Create(Type type, AP4_UI32 size, AP4_ByteStream& stream);
-
+
// constructor
AP4_DcfStringAtom(Type type, const char* value);
- AP4_DcfStringAtom(Type type,
- AP4_UI32 size,
+ AP4_DcfStringAtom(Type type,
+ AP4_UI32 size,
AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
-
+
// AP4_Atom methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
// methods
- const AP4_String& GetValue() const
- {
- return m_Value;
- }
-
+ const AP4_String& GetValue() const { return m_Value; }
+
private:
// members
AP4_String m_Value;
@@ -444,23 +402,20 @@ public:
// factory method
static AP4_DcfdAtom* Create(AP4_UI32 size, AP4_ByteStream& stream);
-
+
// constructors
AP4_DcfdAtom(AP4_UI32 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
AP4_DcfdAtom(AP4_UI32 duration);
-
+
// AP4_Atom methods
virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
+
// methods
- AP4_UI32 GetDuration() const
- {
- return m_Duration;
- }
-
+ AP4_UI32 GetDuration() const { return m_Duration; }
+
private:
// members
AP4_UI32 m_Duration;
@@ -481,10 +436,7 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// methods
- const AP4_String& GetValue()
- {
- return m_Value;
- }
+ const AP4_String& GetValue() { return m_Value; }
private:
// members
@@ -500,8 +452,7 @@ class AP4_DataAtom : public AP4_Atom
public:
AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_DataAtom, AP4_Atom)
- typedef enum
- {
+ typedef enum {
DATA_TYPE_BINARY = 0,
DATA_TYPE_STRING_UTF_8 = 1,
DATA_TYPE_STRING_UTF_16 = 2,
@@ -513,8 +464,7 @@ public:
DATA_TYPE_FLOAT_64_BE = 23
} DataType;
- typedef enum
- {
+ typedef enum {
LANGUAGE_ENGLISH = 0
} DataLang;
@@ -530,16 +480,10 @@ public:
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
// accessors
- DataType GetDataType()
- {
- return m_DataType;
- }
- DataLang GetDataLang()
- {
- return m_DataLang;
- }
+ DataType GetDataType() { return m_DataType; }
+ DataLang GetDataLang() { return m_DataLang; }
AP4_MetaData::Value::Type GetValueType();
-
+
// methods
AP4_Result LoadString(AP4_String*& string);
AP4_Result LoadBytes(AP4_DataBuffer& bytes);
@@ -555,19 +499,18 @@ private:
/*----------------------------------------------------------------------
| AP4_StringMetaDataValue
+---------------------------------------------------------------------*/
-class AP4_StringMetaDataValue : public AP4_MetaData::Value
-{
+class AP4_StringMetaDataValue : public AP4_MetaData::Value {
public:
// constructor
- AP4_StringMetaDataValue(const char* value, const char* language = NULL) :
- Value(TYPE_STRING_UTF_8, MEANING_UNKNOWN, language),
+ AP4_StringMetaDataValue(const char* value, const char* language=NULL) :
+ Value(TYPE_STRING_UTF_8, MEANING_UNKNOWN, language),
m_Value(value) {}
// AP4_MetaData::Value methods
virtual AP4_String ToString() const;
virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) const;
virtual long ToInteger() const;
-
+
private:
// members
AP4_String m_Value;
@@ -576,8 +519,7 @@ private:
/*----------------------------------------------------------------------
| AP4_IntegerMetaDataValue
+---------------------------------------------------------------------*/
-class AP4_IntegerMetaDataValue : public AP4_MetaData::Value
-{
+class AP4_IntegerMetaDataValue : public AP4_MetaData::Value {
public:
// constructor
AP4_IntegerMetaDataValue(Type type, long value) :
@@ -587,7 +529,7 @@ public:
virtual AP4_String ToString() const;
virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) const;
virtual long ToInteger() const;
-
+
private:
// members
long m_Value;
@@ -596,8 +538,7 @@ private:
/*----------------------------------------------------------------------
| AP4_BinaryMetaDataValue
+---------------------------------------------------------------------*/
-class AP4_BinaryMetaDataValue : public AP4_MetaData::Value
-{
+class AP4_BinaryMetaDataValue : public AP4_MetaData::Value {
public:
// constructor
AP4_BinaryMetaDataValue(Type type, const AP4_UI08* data, AP4_Size size) :
@@ -607,7 +548,7 @@ public:
virtual AP4_String ToString() const;
virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) const;
virtual long ToInteger() const;
-
+
private:
// members
AP4_DataBuffer m_Value;