示例#1
0
// skip over a KLV packet
UInt64 mxflib::Partition::Skip( UInt64 start )
{
	if( !start ) return 0;

	MXFFilePtr PF = Object->GetParentFile();

	PF->Seek( start );
	ULPtr FirstUL = PF->ReadKey();
	if(!FirstUL) return 0;

	// do the skip
	Length Len = PF->ReadBER();
	PF->Seek( PF->Tell() + Len );

	UInt64 ret = PF->Tell();

	// check in case we've hit the next Partition Pack
	ULPtr NextUL = PF->ReadKey();
	if(!NextUL) return 0;

	// Is this a partition pack?
	if(IsPartitionKey(NextUL->GetValue())) return 0;

	return ret;
}
示例#2
0
/*! If the UL has not yet been used the correct static or dynamic tag will 
 *	be determined and added to the primer
 *	\return The tag to use, or 0 if no more dynamic tags available
 */
Tag Primer::Lookup(ULPtr ItemUL, Tag TryTag /*=0*/)
{
	// If a tag has been suggested then try that
	if(TryTag != 0)
	{
		// Is it known by us?
		Primer::iterator it = find(TryTag);
		if(it != end())
		{
			// Only use it if the UL matches
			if(!memcmp((*it).second.GetValue(), ItemUL->GetValue(), 16)) return TryTag;
		}
		else
		{
			// It could be the right tag, but not yet in this primer
			// DRAGONS: Not implementer yet!!!
		}
	}

	// Do we have this UL already?
	std::map<UL, Tag>::iterator it = TagLookup.find(ItemUL);
	if(it != TagLookup.end())
	{
		return (*it).second;
	}

	// Try and find the type with this UL
	MDOTypePtr Type = MDOType::Find(ItemUL);
	if(Type)
	{
		if(Type->GetKey().Size != 2)
		{
			// No static tag supplied - fall through and use a dynamic tag
		}
		else
		{
			Tag ThisTag = (Type->GetKey().Data[0] << 8) + Type->GetKey().Data[1];
			insert(Primer::value_type(ThisTag, ItemUL));
			return ThisTag;
		}
	}

	// Generate a dynamic tag
	// DRAGONS: Not very efficient
	while(NextDynamic >= 0x8000)
	{
		if(find(NextDynamic) == end())
		{
			Tag Ret = NextDynamic;
			NextDynamic--;
			insert(Primer::value_type(Ret, ItemUL));
			return Ret;
		}
		NextDynamic--;
	}

	//! Out of dynamic tags!
	error("Run out of dynamic tags!\n");
	return 0;
}
示例#3
0
// skip over any KLVFill
// DRAGONS: does not iterate - only copes with single KLVFill
UInt64 mxflib::Partition::SkipFill( UInt64 start )
{
	if( !start ) return 0;

	MXFFilePtr PF = Object->GetParentFile();

	PF->Seek( start );
	ULPtr FirstUL = PF->ReadKey();
	if(!FirstUL) return 0;

	if(FirstUL->Matches(KLVFill_UL))
	{
		// Skip over the KLVFill
		Length Len = PF->ReadBER();
		PF->Seek( PF->Tell() + Len );
	}
	else
	{
		// was not KLVFill, so stay where we are
		PF->Seek( start );
	}

	UInt64 ret = PF->Tell();

	// check in case we've hit the next Partition Pack
	ULPtr NextUL = PF->ReadKey();
	if(!NextUL) return 0;

	// Is this a partition pack?
	if(IsPartitionKey(NextUL->GetValue()))
	{
		UInt8 byte14 = (NextUL->GetValue())[13];
		if( byte14 == 2 || byte14 == 3 || byte14 == 4 )	return 0;
		// we've found a Partition Pack - end of Body -- DRAGONS:?? Not true!!

		if( byte14 == 0x11 )	return 0;
		// we've found a RIP - end of Body
	}

	return ret;
}