当前位置: 首页>>代码示例>>C++>>正文


C++ MediaByteRange::SetLength方法代码示例

本文整理汇总了C++中MediaByteRange::SetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaByteRange::SetLength方法的具体用法?C++ MediaByteRange::SetLength怎么用?C++ MediaByteRange::SetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaByteRange的用法示例。


在下文中一共展示了MediaByteRange::SetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IntersectWithUnavailable

void IntersectWithUnavailable(MediaByteRange& range, URL& url)
{
	if (range.IsEmpty())
		return;

	// find the first unavailable range on or after range.start
	MediaByteRange unavail;
	BOOL available = FALSE;
	OpFileLength length = 0;
	url.GetPartialCoverage(range.start, available, length, TRUE);
	if (available)
	{
		OP_ASSERT(length > 0);
		unavail.start = range.start + length;
		length = 0;
		url.GetPartialCoverage(unavail.start, available, length, TRUE);
		OP_ASSERT(!available);
	}
	else
		unavail.start = range.start;

	// length is now the number of unavailable bytes, or 0 if unknown
	if (length > 0)
		unavail.SetLength(length);

	range.IntersectWith(unavail);
}
开发者ID:prestocore,项目名称:browser,代码行数:27,代码来源:mediasourceutil.cpp

示例2: resource

void
MediaSourceImpl::CalcRequest(MediaByteRange& request)
{
	if (IsStreaming())
	{
		// When streaming we only consider the pending range (if any).
		// When there are no clients, request the entire resource.
		// To support preload together with streaming, care must be
		// taken to not restart a preload request [0,Inf] as soon as
		// data has been evicted and the cached range is e.g.
		// [500,1000499] if there is no pending request in that range.

		if (!m_clients.Empty())
		{
			MediaByteRange preload; // unused
			ReduceRanges(m_clients, request, preload);
			if (!request.IsEmpty())
			{
				request.SetLength(FILE_LENGTH_NONE);
				IntersectWithUnavailable(request, m_use_url);
				if (!request.IsEmpty())
					request.SetLength(FILE_LENGTH_NONE);
			}
		}
		else
		{
			request.start = 0;
		}
		// At this point we should have an unbounded range, but it may
		// be clamped to the resource length below.
		OP_ASSERT(!request.IsFinite());
	}
	else
	{
		// When not streaming (using multiple range disk cache), both
		// pending and preload requests are taken into account.
		//
		// Example 1: Everything should be preloaded, but since there is a
		// pending read, start buffering from that offset first. Also,
		// don't refetch the end of the resource.
		//
		// resource: <---------------------->
		// buffered: <-->               <--->
		// pending:           <---->
		// preload:  <---------------------->
		// request:           <-------->
		//
		// Example 2: The requested preload is already buffered, so the
		// request is the empty range.
		//
		// resource: <---------------------->
		// buffered: <-------->
		// pending:  empty range
		// preload:  <----->
		// request:  empty range

		MediaByteRange pending, preload;
		ReduceRanges(m_clients, pending, preload);
		CombineRanges(pending, preload, request);
		IntersectWithUnavailable(request, m_use_url);
	}

	if (!request.IsEmpty())
	{
		// Extra restrictions if resource length is known (this won't
		// be needed after CORE-30311 is fixed).
		OpFileLength resource_length = GetTotalBytes();
		if (resource_length > 0)
		{
			OP_ASSERT(request.start <= resource_length);

			MediaByteRange resource(0, resource_length - 1);

			// Clamp request to resource.
			request.IntersectWith(resource);

			// Increase size if it is unreasonably small at the end...
			if (!request.IsEmpty() &&
				request.Length() < MEDIA_SOURCE_MIN_SIZE &&
				resource.Length() >= MEDIA_SOURCE_MIN_SIZE &&
				request.end == resource.end)
			{
				// ... but only if nothing in that range is available.
				MediaByteRange cand_request(resource_length - MEDIA_SOURCE_MIN_SIZE, resource_length - 1);
				OP_ASSERT(cand_request.Length() == MEDIA_SOURCE_MIN_SIZE);
				IntersectWithUnavailable(cand_request, m_use_url);
				if (cand_request.Length() == MEDIA_SOURCE_MIN_SIZE)
					request = cand_request;
			}
		}
	}

	OP_NEW_DBG("CalcRequest", "MediaSource");
	OP_DBG(("request: ") << request);
}
开发者ID:prestocore,项目名称:browser,代码行数:95,代码来源:mediasource.cpp


注:本文中的MediaByteRange::SetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。