本文整理汇总了C++中AP4_Atom::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ AP4_Atom::GetSize方法的具体用法?C++ AP4_Atom::GetSize怎么用?C++ AP4_Atom::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP4_Atom
的用法示例。
在下文中一共展示了AP4_Atom::GetSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintUsageAndExit
/*----------------------------------------------------------------------
| main
+---------------------------------------------------------------------*/
int
main(int argc, char** argv)
{
if (argc != 2) {
PrintUsageAndExit();
}
const char* input_filename = argv[1];
// open the input
AP4_ByteStream* input = NULL;
AP4_Result result = AP4_FileByteStream::Create(input_filename, AP4_FileByteStream::STREAM_MODE_READ, input);
if (AP4_FAILED(result)) {
fprintf(stderr, "ERROR: cannot open input file (%s)\n", input_filename);
return 1;
}
// get the movie
AP4_File* file = new AP4_File(*input, AP4_DefaultAtomFactory::Instance, true);
AP4_Movie* movie = file->GetMovie();
AP4_Atom* atom = NULL;
do {
// process the next atom
result = AP4_DefaultAtomFactory::Instance.CreateAtomFromStream(*input, atom);
if (AP4_SUCCEEDED(result)) {
printf("atom size=%lld\n", atom->GetSize());
if (atom->GetType() == AP4_ATOM_TYPE_MOOF) {
AP4_ContainerAtom* moof = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
if (moof) {
// remember where we are in the stream
AP4_Position position = 0;
input->Tell(position);
// process the movie fragment
ProcessMoof(movie, moof, input, position-atom->GetSize(), position+8);
// go back to where we were before processing the fragment
input->Seek(position);
}
} else {
delete atom;
}
}
} while (AP4_SUCCEEDED(result));
// cleanup
delete file;
input->Release();
return 0;
}
示例2: assert
/*----------------------------------------------------------------------
| AP4_LinearReader::AdvanceFragment
+---------------------------------------------------------------------*/
AP4_Result
AP4_LinearReader::AdvanceFragment()
{
AP4_Result result;
// go the the start of the next fragment
result = m_FragmentStream->Seek(m_NextFragmentPosition);
if (AP4_FAILED(result)) return result;
// read atoms until we find a moof
assert(m_HasFragments);
if (!m_FragmentStream) return AP4_ERROR_INVALID_STATE;
do {
AP4_Atom* atom = NULL;
result = AP4_DefaultAtomFactory::Instance.CreateAtomFromStream(*m_FragmentStream, atom);
if (AP4_SUCCEEDED(result)) {
if (atom->GetType() == AP4_ATOM_TYPE_MOOF) {
AP4_ContainerAtom* moof = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
if (moof) {
// remember where we are in the stream
AP4_Position position = 0;
m_FragmentStream->Tell(position);
// process the movie fragment
result = ProcessMoof(moof, position-atom->GetSize(), position+8);
if (AP4_FAILED(result)) return result;
// compute where the next fragment will be
AP4_UI32 size;
AP4_UI32 type;
m_FragmentStream->Tell(position);
result = m_FragmentStream->ReadUI32(size);
if (AP4_FAILED(result)) return AP4_SUCCESS; // can't read more
result = m_FragmentStream->ReadUI32(type);
if (AP4_FAILED(result)) return AP4_SUCCESS; // can't read more
if (size == 0) {
m_NextFragmentPosition = 0;
} else if (size == 1) {
AP4_UI64 size_64 = 0;
result = m_FragmentStream->ReadUI64(size_64);
if (AP4_FAILED(result)) return AP4_SUCCESS; // can't read more
m_NextFragmentPosition = position+size_64;
} else {
m_NextFragmentPosition = position+size;
}
return AP4_SUCCESS;
} else {
delete atom;
}
} else {
delete atom;
}
}
} while (AP4_SUCCEEDED(result));
return AP4_ERROR_EOS;
}
示例3:
/*----------------------------------------------------------------------
| AP4_StsdAtom::AP4_StsdAtom
+---------------------------------------------------------------------*/
AP4_StsdAtom::AP4_StsdAtom(AP4_SampleTable* sample_table) :
AP4_ContainerAtom(AP4_ATOM_TYPE_STSD, 4+AP4_FULL_ATOM_HEADER_SIZE, true)
{
AP4_Cardinal sample_description_count = sample_table->GetSampleDescriptionCount();
m_SampleDescriptions.EnsureCapacity(sample_description_count);
for (AP4_Ordinal i=0; i<sample_description_count; i++) {
// clear the cache entry
m_SampleDescriptions.Append(NULL);
// create an entry for the description
AP4_SampleDescription* sample_description = sample_table->GetSampleDescription(i);
AP4_Atom* entry = sample_description->ToAtom();
m_Children.Add(entry);
// update the size
m_Size += entry->GetSize();
}
}
示例4: if
//.........这里部分代码省略.........
{
AP4_MehdAtom *mehd(AP4_DYNAMIC_CAST(AP4_MehdAtom, mvex_base->GetChild(AP4_ATOM_TYPE_MEHD, 0)));
mvhd->SetDuration(mehd ? mehd->GetDuration() : 0);
}
// finalize the processor
Finalize(top_level);
// calculate the size of all atoms combined
AP4_UI64 atoms_size = 0;
top_level.GetChildren().Apply(AP4_AtomSizeAdder(atoms_size));
// write all atoms
top_level.GetChildren().Apply(AP4_AtomListWriter(output));
m_MoovAtom = moov[0];
m_MoovAtom->Detach();
}
if (partitions & 2)
{
// process the fragments, if any
result = AP4_SUCCESS;
AP4_Array<AP4_UI64> moof_positions, mdat_positions;
moof_positions.SetItemCount(input.ItemCount());
mdat_positions.SetItemCount(input.ItemCount());
for (;;)
{
AP4_ContainerAtom *moof = NULL;
AP4_UI32 track_index(0);
#if 0
for (AP4_Cardinal streamid(0); streamid < input.ItemCount(); ++streamid)
{
AP4_Atom* atom = NULL;
if (AP4_SUCCEEDED(input[streamid]->Tell(stream_offset)) && AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(*input[streamid], atom)))
{
if (atom->GetType() != AP4_ATOM_TYPE_MOOF)
return AP4_ERROR_INVALID_FORMAT;
moof_positions[streamid] = stream_offset;
mdat_positions[streamid] = stream_offset + atom->GetSize() + +AP4_ATOM_HEADER_SIZE;
if (moof)
{
int index(0);
for (; AP4_Atom* child = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom)->GetChild(AP4_ATOM_TYPE_TRAF, index++);)
moof->AddChild(child->Clone());
delete atom;
}
else
moof = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
NormalizeTRAF(AP4_DYNAMIC_CAST(AP4_ContainerAtom, moof), m_StreamData[streamid].trackStart,
m_StreamData[streamid].trackStart + m_StreamData[streamid].trackCount, track_index);
}
else
delete atom;
}
#else
double mindts(9999999999.0);
AP4_Cardinal nextStream(~0);
for (AP4_Cardinal track(0); track < m_TrackData.ItemCount(); ++track)
if ((double)m_TrackData[track].dts / m_TrackData[track].timescale < mindts)
{
mindts = (double)m_TrackData[track].dts / m_TrackData[track].timescale;
nextStream = m_TrackData[track].streamId;
}
AP4_Atom* atom = NULL;
if (AP4_SUCCEEDED(result = input[nextStream]->Tell(stream_offset)) && AP4_SUCCEEDED(result = atom_factory.CreateAtomFromStream(*input[nextStream], atom)))
{
if (atom->GetType() != AP4_ATOM_TYPE_MOOF)
return AP4_ERROR_INVALID_FORMAT;
} else if (atom)
return result;
moof_positions[nextStream] = stream_offset;
mdat_positions[nextStream] = stream_offset + atom->GetSize() + +AP4_ATOM_HEADER_SIZE;
moof = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
NormalizeTRAF(AP4_DYNAMIC_CAST(AP4_ContainerAtom, moof), m_StreamData[nextStream].trackStart,
m_StreamData[nextStream].trackStart + m_StreamData[nextStream].trackCount, track_index);
#endif
if (!moof)
break;
if (AP4_FAILED(result = ProcessFragment(moof, NULL, 0, output, moof_positions, mdat_positions)))
return result;
delete moof;
moof = NULL;
}
// cleanup
m_TrackData.Clear();
m_StreamData.Clear();
}
return AP4_SUCCESS;
}
示例5: if
//.........这里部分代码省略.........
return BLT_ERROR_INVALID_MEDIA_FORMAT;
}
AP4_MpegSampleDescription* mpeg_desc = NULL;
if (sample_desc->GetType() == AP4_SampleDescription::TYPE_MPEG) {
ATX_LOG_FINE("sample description is of type MPEG");
mpeg_desc = dynamic_cast<AP4_MpegSampleDescription*>(sample_desc);
}
if (mpeg_desc) {
stream_info.data_type = mpeg_desc->GetObjectTypeString(mpeg_desc->GetObjectTypeId());
stream_info.average_bitrate = mpeg_desc->GetAvgBitrate();
stream_info.nominal_bitrate = mpeg_desc->GetAvgBitrate();
stream_info.mask |= BLT_STREAM_INFO_MASK_AVERAGE_BITRATE |
BLT_STREAM_INFO_MASK_NOMINAL_BITRATE |
BLT_STREAM_INFO_MASK_DATA_TYPE;
}
// setup the output media type
AP4_DataBuffer decoder_info;
BLT_MediaTypeId media_type_id = BLT_MEDIA_TYPE_ID_NONE;
AP4_UI32 format_or_object_type_id = 0;
if (mpeg_desc) {
decoder_info.SetData(mpeg_desc->GetDecoderInfo().GetData(),
mpeg_desc->GetDecoderInfo().GetDataSize());
media_type_id = self->mp4_es_type_id;
format_or_object_type_id = mpeg_desc->GetObjectTypeId();
} else {
// here we have to be format-specific for the decoder info
stream_info.data_type = AP4_GetFormatName(sample_desc->GetFormat());
stream_info.mask |= BLT_STREAM_INFO_MASK_DATA_TYPE;
format_or_object_type_id = sample_desc->GetFormat();
if (sample_desc->GetFormat() == AP4_SAMPLE_FORMAT_AVC1) {
// look for an 'avcC' atom
AP4_AvccAtom* avcc = static_cast<AP4_AvccAtom*>(sample_desc->GetDetails().GetChild(AP4_ATOM_TYPE_AVCC));
if (avcc) {
// pass the avcc payload as the decoder info
decoder_info.SetData(avcc->GetRawBytes().GetData(),
avcc->GetRawBytes().GetDataSize());
}
} else if (sample_desc->GetFormat() == AP4_SAMPLE_FORMAT_ALAC) {
// look for an 'alac' atom (either top-level or inside a 'wave')
AP4_Atom* alac = sample_desc->GetDetails().GetChild(AP4_SAMPLE_FORMAT_ALAC);
if (alac == NULL) {
AP4_ContainerAtom* wave = dynamic_cast<AP4_ContainerAtom*>(sample_desc->GetDetails().GetChild(AP4_ATOM_TYPE_WAVE));
if (wave) {
alac = wave->GetChild(AP4_SAMPLE_FORMAT_ALAC);
}
}
if (alac) {
// pass the alac payload as the decoder info
AP4_MemoryByteStream* mbs = new AP4_MemoryByteStream((AP4_Size)alac->GetSize());
alac->WriteFields(*mbs);
decoder_info.SetData(mbs->GetData(), mbs->GetDataSize());
mbs->Release();
}
}
media_type_id = self->iso_base_es_type_id;
}
BLT_Mp4MediaType* media_type = NULL;
unsigned int struct_size = decoder_info.GetDataSize()?decoder_info.GetDataSize()-1:0;
if (audio_desc) {
struct_size += sizeof(BLT_Mp4AudioMediaType);
BLT_Mp4AudioMediaType* audio_type = (BLT_Mp4AudioMediaType*)ATX_AllocateZeroMemory(struct_size);;
audio_type->base.stream_type = BLT_MP4_STREAM_TYPE_AUDIO;
audio_type->channel_count = audio_desc->GetChannelCount();
audio_type->sample_rate = audio_desc->GetSampleRate();
audio_type->decoder_info_length = decoder_info.GetDataSize();
if (decoder_info.GetDataSize()) {
ATX_CopyMemory(&audio_type->decoder_info[0], decoder_info.GetData(), decoder_info.GetDataSize());
}
media_type = &audio_type->base;
} else {
struct_size += sizeof(BLT_Mp4VideoMediaType);
BLT_Mp4VideoMediaType* video_type = (BLT_Mp4VideoMediaType*)ATX_AllocateZeroMemory(struct_size);
video_type->base.stream_type = BLT_MP4_STREAM_TYPE_VIDEO;
video_type->width = video_desc->GetWidth();
video_type->height = video_desc->GetHeight();
video_type->decoder_info_length = decoder_info.GetDataSize();
if (decoder_info.GetDataSize()) {
ATX_CopyMemory(&video_type->decoder_info[0], decoder_info.GetData(), decoder_info.GetDataSize());
}
media_type = &video_type->base;
}
media_type->base.id = media_type_id;
media_type->base.extension_size = struct_size-sizeof(BLT_MediaType);
media_type->format_or_object_type_id = format_or_object_type_id;
self->media_type = &media_type->base;
self->sample_description_index = indx;
// final update to the stream info
BLT_Stream_SetInfo(ATX_BASE(self->parser, BLT_BaseMediaNode).context, &stream_info);
// enable the track in the linear reader if we have one
if (self->parser->input.reader) {
self->parser->input.reader->EnableTrack(self->track->GetId());
}
return BLT_SUCCESS;
}