示例#1
0
void CombineRanges(const MediaByteRange& pending, const MediaByteRange& preload,
				   MediaByteRange& request)
{
	OP_ASSERT(request.IsEmpty());
	// If pending and preload overlap, let request be their union,
	// clamped to pending.start.
	if (!pending.IsEmpty() && !preload.IsEmpty())
	{
		request = pending;
		request.IntersectWith(preload);
		if (!request.IsEmpty())
		{
			// non-empty intersection => overlap
			request = pending;
			request.UnionWith(preload);
			request.IntersectWith(MediaByteRange(pending.start));
			OP_ASSERT(!request.IsEmpty());
		}
	}
	// Otherwise, pick the first non-empty of pending and preload.
	if (request.IsEmpty())
	{
		if (!pending.IsEmpty())
			request = pending;
		else
			request = preload;
	}
}
示例#2
0
void ReduceRanges(const List<MediaSourceClient>& clients,
				  MediaByteRange& pending, MediaByteRange& preload)
{
	OP_ASSERT(preload.IsEmpty());
	MediaSourceClient* client = clients.First();
	if (client)
	{
		for ( ; client; client = client->Suc())
		{
			// take the first non-empty pending
			if (pending.IsEmpty())
				pending = client->GetPending();
			// preload the union of all ranges
			preload.UnionWith(client->GetPreload());
		}
	}
	else
	{
		// with no clients, preload the whole resource
		preload.start = 0;
	}
}