00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _AP4_SAMPLE_ENTRY_H_
00030 #define _AP4_SAMPLE_ENTRY_H_
00031
00032
00033
00034
00035 #include "Ap4.h"
00036 #include "Ap4ByteStream.h"
00037 #include "Ap4List.h"
00038 #include "Ap4Atom.h"
00039 #include "Ap4EsdsAtom.h"
00040 #include "Ap4AtomFactory.h"
00041 #include "Ap4ContainerAtom.h"
00042
00043
00044
00045
00046 class AP4_SampleDescription;
00047
00048
00049
00050
00051 class AP4_SampleEntry : public AP4_ContainerAtom
00052 {
00053 public:
00054
00055 AP4_SampleEntry(AP4_Atom::Type format, AP4_UI16 data_ref_index = 1);
00056 AP4_SampleEntry(AP4_Atom::Type format,
00057 AP4_Size size,
00058 AP4_ByteStream& stream,
00059 AP4_AtomFactory& atom_factory);
00060 AP4_UI16 GetDataReferenceIndex() { return m_DataReferenceIndex; }
00061 virtual AP4_Result Write(AP4_ByteStream& stream);
00062 virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
00063 virtual AP4_SampleDescription* ToSampleDescription();
00064
00065
00066 virtual void OnChildChanged(AP4_Atom* child);
00067
00068 protected:
00069
00070 AP4_SampleEntry(AP4_Atom::Type format, AP4_Size size);
00071
00072
00073 virtual AP4_Size GetFieldsSize();
00074 virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00075 virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00076 virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00077
00078
00079 AP4_UI08 m_Reserved1[6];
00080 AP4_UI16 m_DataReferenceIndex;
00081 };
00082
00083
00084
00085
00086 class AP4_MpegSampleEntry : public AP4_SampleEntry
00087 {
00088 protected:
00089
00090 AP4_MpegSampleEntry(AP4_Atom::Type format);
00091 AP4_MpegSampleEntry(AP4_Atom::Type format, AP4_Size size);
00092 AP4_MpegSampleEntry(AP4_Atom::Type format,
00093 AP4_EsDescriptor* descriptor);
00094 AP4_MpegSampleEntry(AP4_Atom::Type format,
00095 AP4_Size size,
00096 AP4_ByteStream& stream,
00097 AP4_AtomFactory& atom_factory);
00098
00099
00100 const AP4_DecoderConfigDescriptor* GetDecoderConfigDescriptor();
00101 };
00102
00103
00104
00105
00106 class AP4_Mp4sSampleEntry : public AP4_MpegSampleEntry
00107 {
00108 public:
00109
00110 AP4_Mp4sSampleEntry(AP4_Size size,
00111 AP4_ByteStream& stream,
00112 AP4_AtomFactory& atom_factory);
00113 AP4_Mp4sSampleEntry(AP4_EsDescriptor* descriptor);
00114
00115
00116 AP4_SampleDescription* ToSampleDescription();
00117 };
00118
00119
00120
00121
00122 class AP4_AudioSampleEntry : public AP4_MpegSampleEntry
00123 {
00124 public:
00125
00126 AP4_AudioSampleEntry(AP4_Atom::Type format,
00127 AP4_EsDescriptor* descriptor,
00128 AP4_UI32 sample_rate,
00129 AP4_UI16 sample_size,
00130 AP4_UI16 channel_count);
00131 AP4_AudioSampleEntry(AP4_Atom::Type format,
00132 AP4_Size size,
00133 AP4_ByteStream& stream,
00134 AP4_AtomFactory& atom_factory);
00135
00136
00137 AP4_UI32 GetSampleRate() { return m_SampleRate>>16; }
00138 AP4_UI16 GetSampleSize() { return m_SampleSize; }
00139 AP4_UI16 GetChannelCount() { return m_ChannelCount; }
00140
00141
00142 AP4_SampleDescription* ToSampleDescription();
00143
00144 protected:
00145
00146 virtual AP4_Size GetFieldsSize();
00147 virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00148 virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00149 virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00150
00151
00152 AP4_UI08 m_Reserved2[8];
00153 AP4_UI32 m_SampleRate;
00154 AP4_UI16 m_ChannelCount;
00155 AP4_UI16 m_SampleSize;
00156 AP4_UI16 m_Predefined1;
00157 AP4_UI16 m_Reserved3;
00158 };
00159
00160
00161
00162
00163 class AP4_Mp4aSampleEntry : public AP4_AudioSampleEntry
00164 {
00165 public:
00166
00167 AP4_Mp4aSampleEntry(AP4_Size size,
00168 AP4_ByteStream& stream,
00169 AP4_AtomFactory& atom_factory);
00170 AP4_Mp4aSampleEntry(AP4_UI32 sample_rate,
00171 AP4_UI16 sample_size,
00172 AP4_UI16 channel_count,
00173 AP4_EsDescriptor* descriptor);
00174 };
00175
00176
00177
00178
00179 class AP4_VisualSampleEntry : public AP4_MpegSampleEntry
00180 {
00181 public:
00182
00183 AP4_VisualSampleEntry(AP4_Atom::Type format,
00184 AP4_EsDescriptor* descriptor,
00185 AP4_UI16 width,
00186 AP4_UI16 height,
00187 AP4_UI16 depth,
00188 const char* compressor_name);
00189 AP4_VisualSampleEntry(AP4_Atom::Type format,
00190 AP4_Size size,
00191 AP4_ByteStream& stream,
00192 AP4_AtomFactory& atom_factory);
00193
00194
00195 AP4_UI16 GetWidth() { return m_Width; }
00196 AP4_UI16 GetHeight() { return m_Height; }
00197 AP4_UI16 GetHorizResolution(){ return m_HorizResolution; }
00198 AP4_UI16 GetVertResolution() { return m_VertResolution; }
00199 AP4_UI16 GetDepth() { return m_Depth; }
00200 const char* GetCompressorName() { return m_CompressorName.c_str(); }
00201
00202
00203 AP4_SampleDescription* ToSampleDescription();
00204
00205 protected:
00206
00207 virtual AP4_Size GetFieldsSize();
00208 virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00209 virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00210 virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00211
00212
00213 AP4_UI16 m_Predefined1;
00214 AP4_UI16 m_Reserved2;
00215 AP4_UI08 m_Predefined2[12];
00216 AP4_UI16 m_Width;
00217 AP4_UI16 m_Height;
00218 AP4_UI32 m_HorizResolution;
00219 AP4_UI32 m_VertResolution;
00220 AP4_UI32 m_Reserved3;
00221 AP4_UI16 m_FrameCount;
00222 AP4_String m_CompressorName;
00223 AP4_UI16 m_Depth;
00224 AP4_UI16 m_Predefined3;
00225 };
00226
00227
00228
00229
00230 class AP4_Mp4vSampleEntry : public AP4_VisualSampleEntry
00231 {
00232 public:
00233
00234 AP4_Mp4vSampleEntry(AP4_Size size,
00235 AP4_ByteStream& stream,
00236 AP4_AtomFactory& atom_factory);
00237 AP4_Mp4vSampleEntry(AP4_UI16 width,
00238 AP4_UI16 height,
00239 AP4_UI16 depth,
00240 const char* compressor_name,
00241 AP4_EsDescriptor* descriptor);
00242 };
00243
00244
00245
00246
00247 class AP4_Avc1SampleEntry : public AP4_VisualSampleEntry
00248 {
00249 public:
00250
00251 AP4_Avc1SampleEntry(AP4_Size size,
00252 AP4_ByteStream& stream,
00253 AP4_AtomFactory& atom_factory);
00254 AP4_Avc1SampleEntry(AP4_UI16 width,
00255 AP4_UI16 height,
00256 AP4_UI16 depth,
00257 const char* compressor_name,
00258 AP4_EsDescriptor* descriptor);
00259 };
00260
00261
00262
00263
00264 class AP4_RtpHintSampleEntry : public AP4_SampleEntry
00265 {
00266 public:
00267
00268 AP4_RtpHintSampleEntry(AP4_UI16 hint_track_version,
00269 AP4_UI16 highest_compatible_version,
00270 AP4_UI32 max_packet_size,
00271 AP4_UI32 timescale);
00272 AP4_RtpHintSampleEntry(AP4_Size size,
00273 AP4_ByteStream& stream,
00274 AP4_AtomFactory& atom_factory);
00275 virtual ~AP4_RtpHintSampleEntry();
00276
00277 protected:
00278
00279 virtual AP4_Size GetFieldsSize();
00280 virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00281 virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00282 virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00283
00284
00285 AP4_UI16 m_HintTrackVersion;
00286 AP4_UI16 m_HighestCompatibleVersion;
00287 AP4_UI32 m_MaxPacketSize;
00288 };
00289
00290
00291
00292
00293 class AP4_TextSampleEntry : public AP4_SampleEntry
00294 {
00295 public:
00296
00297 AP4_TextSampleEntry(AP4_Size size,
00298 AP4_ByteStream& stream,
00299 AP4_AtomFactory& atom_factory);
00300 virtual ~AP4_TextSampleEntry();
00301
00302 struct AP4_TextDescription
00303 {
00304 AP4_UI32 DisplayFlags;
00305 AP4_UI32 TextJustification;
00306 AP4_UI32 BackgroundColor;
00307 struct {AP4_UI16 Top, Left, Bottom, Right;} TextBox;
00308 struct {AP4_UI16 StartChar, EndChar, Ascent; struct {AP4_UI16 Id; AP4_UI08 Face, Size; AP4_UI32 Color;} Font;} Style;
00309 AP4_String DefaultFontName;
00310 };
00311
00312 const AP4_TextDescription& GetDescription() const { return m_Description; };
00313
00314 protected:
00315
00316 virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00317 virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00318 virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00319
00320
00321 AP4_TextDescription m_Description;
00322 };
00323
00324
00325
00326
00327 class AP4_Tx3gSampleEntry : public AP4_SampleEntry
00328 {
00329 public:
00330
00331 AP4_Tx3gSampleEntry(AP4_Size size,
00332 AP4_ByteStream& stream,
00333 AP4_AtomFactory& atom_factory);
00334 virtual ~AP4_Tx3gSampleEntry();
00335
00336 struct AP4_Tx3gDescription
00337 {
00338 AP4_UI32 DisplayFlags;
00339 AP4_UI08 HorizontalJustification;
00340 AP4_UI08 VerticalJustification;
00341 AP4_UI32 BackgroundColor;
00342 struct {AP4_UI16 Top, Left, Bottom, Right;} TextBox;
00343 struct {AP4_UI16 StartChar, EndChar; struct {AP4_UI16 Id; AP4_UI08 Face, Size; AP4_UI32 Color;} Font;} Style;
00344 };
00345
00346 const AP4_Tx3gDescription& GetDescription() const { return m_Description; };
00347
00348 AP4_Result GetFontNameById(AP4_Ordinal Id, AP4_String& Name);
00349
00350 protected:
00351
00352 virtual AP4_Size GetFieldsSize();
00353 virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00354 virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00355 virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00356
00357
00358 AP4_Tx3gDescription m_Description;
00359 };
00360
00361 #endif // _AP4_SAMPLE_ENTRY_H_