本文整理汇总了C++中TimeUnit类的典型用法代码示例。如果您正苦于以下问题:C++ TimeUnit类的具体用法?C++ TimeUnit怎么用?C++ TimeUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimeUnit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FastSeek
TimeUnit
MP3TrackDemuxer::ScanUntil(const TimeUnit& aTime) {
MP3LOG("ScanUntil(%" PRId64 ") avgFrameLen=%f mNumParsedFrames=%" PRIu64
" mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
aTime.ToMicroseconds(), AverageFrameLength(), mNumParsedFrames,
mFrameIndex, mOffset);
if (!aTime.ToMicroseconds()) {
return FastSeek(aTime);
}
if (Duration(mFrameIndex) > aTime) {
FastSeek(aTime);
}
if (Duration(mFrameIndex + 1) > aTime) {
return SeekPosition();
}
MediaByteRange nextRange = FindNextFrame();
while (SkipNextFrame(nextRange) && Duration(mFrameIndex + 1) < aTime) {
nextRange = FindNextFrame();
MP3LOGV("ScanUntil* avgFrameLen=%f mNumParsedFrames=%" PRIu64
" mFrameIndex=%" PRId64 " mOffset=%" PRIu64 " Duration=%" PRId64,
AverageFrameLength(), mNumParsedFrames,
mFrameIndex, mOffset, Duration(mFrameIndex + 1).ToMicroseconds());
}
MP3LOG("ScanUntil End avgFrameLen=%f mNumParsedFrames=%" PRIu64
" mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
AverageFrameLength(), mNumParsedFrames, mFrameIndex, mOffset);
return SeekPosition();
}
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:34,代码来源:MP3Demuxer.cpp
示例2: MOZ_ASSERT
bool
MediaSourceDecoder::CanPlayThrough()
{
MOZ_ASSERT(NS_IsMainThread());
if (NextFrameBufferedStatus() == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE) {
return false;
}
if (IsNaN(mMediaSource->Duration())) {
// Don't have any data yet.
return false;
}
TimeUnit duration = TimeUnit::FromSeconds(mMediaSource->Duration());
TimeUnit currentPosition = TimeUnit::FromMicroseconds(CurrentPosition());
if (duration.IsInfinite()) {
// We can't make an informed decision and just assume that it's a live stream
return true;
} else if (duration <= currentPosition) {
return true;
}
// If we have data up to the mediasource's duration or 30s ahead, we can
// assume that we can play without interruption.
TimeUnit timeAhead =
std::min(duration, currentPosition + TimeUnit::FromSeconds(30));
TimeInterval interval(currentPosition,
timeAhead,
MediaSourceDemuxer::EOS_FUZZ);
return GetBuffered().Contains(ClampIntervalToEnd(interval));
}
开发者ID:SJasoria,项目名称:gecko-dev,代码行数:30,代码来源:MediaSourceDecoder.cpp
示例3: getElapsed
// TODO: USE idx INSTEAD OF size_t
size_t getElapsed()
{
/*!
* Returns elapsed time as number of ticks of TimeUnits
* Elapsed time can mean 2 different things:
*
* 1. If TickCounter is running, elapsed time is measured between starTime
* and now.
* 2. If TickCounter is not running (i.e. it is stopped), elapsed time
* is measured between startTime and stopTime.
*/
// DIFFERENCE BETWEEN THE TWO "TIMEPOINTS" MUST BE CAST TO
// A "DURATION" USING THE std::chrono::duration_cast
TimeUnit duration;
// CASE 1 - TickCounter IS RUNNING, USE CURRENT TIME
if (isRunning)
{
duration = std::chrono::duration_cast <TimeUnit>
( std::chrono::high_resolution_clock::now() - startTime );
}
// CASE 2 - NOT RUNNING, USE stopTime
else
{
duration = std::chrono::duration_cast<TimeUnit>
(stopTime - startTime);
}
// CAST TO TICK COUNT
return static_cast <size_t> ( duration.count() );
}
开发者ID:erwi,项目名称:SpaMtrix,代码行数:32,代码来源:spamtrix_tickcounter.hpp
示例4: MP3DEMUXER_LOG
TimeUnit
MP3TrackDemuxer::FastSeek(TimeUnit aTime) {
MP3DEMUXER_LOG("FastSeek(%" PRId64 ") avgFrameLen=%f mNumParsedFrames=%" PRIu64
" mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
aTime, AverageFrameLength(), mNumParsedFrames, mFrameIndex,
mOffset);
if (!aTime.ToMicroseconds()) {
// Quick seek to the beginning of the stream.
mOffset = mFirstFrameOffset;
mFrameIndex = 0;
mParser.EndFrameSession();
return TimeUnit();
}
if (!mSamplesPerFrame || !mNumParsedFrames) {
return TimeUnit::FromMicroseconds(-1);
}
const int64_t numFrames = aTime.ToSeconds() *
mSamplesPerSecond / mSamplesPerFrame;
mOffset = mFirstFrameOffset + numFrames * AverageFrameLength();
mFrameIndex = numFrames;
MP3DEMUXER_LOG("FastSeek mSamplesPerSecond=%d mSamplesPerFrame=%d "
"numFrames=%" PRId64,
mSamplesPerSecond, mSamplesPerFrame, numFrames);
mParser.EndFrameSession();
return Duration(mFrameIndex);
}
开发者ID:Jar-win,项目名称:Waterfox,代码行数:32,代码来源:MP3Demuxer.cpp
示例5: stream
TimeIntervals
MP3TrackDemuxer::GetBuffered() {
AutoPinned<MediaResource> stream(mSource.GetResource());
TimeIntervals buffered;
if (Duration() > TimeUnit() && stream->IsDataCachedToEndOfResource(0)) {
// Special case completely cached files. This also handles local files.
buffered += TimeInterval(TimeUnit(), Duration());
MP3LOGV("buffered = [[%" PRId64 ", %" PRId64 "]]",
TimeUnit().ToMicroseconds(), Duration().ToMicroseconds());
return buffered;
}
MediaByteRangeSet ranges;
nsresult rv = stream->GetCachedRanges(ranges);
NS_ENSURE_SUCCESS(rv, buffered);
for (const auto& range: ranges) {
if (range.IsEmpty()) {
continue;
}
TimeUnit start = Duration(FrameIndexFromOffset(range.mStart));
TimeUnit end = Duration(FrameIndexFromOffset(range.mEnd));
MP3LOGV("buffered += [%" PRId64 ", %" PRId64 "]",
start.ToMicroseconds(), end.ToMicroseconds());
buffered += TimeInterval(start, end);
}
return buffered;
}
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:30,代码来源:MP3Demuxer.cpp
示例6: TEST
TEST(MP4Demuxer, GetNextKeyframe)
{
RefPtr<MP4DemuxerBinding> binding = new MP4DemuxerBinding("gizmo-frag.mp4");
binding->RunTestAndWait([binding]() {
// Insert a [0,end] buffered range, to simulate Moof's being buffered
// via MSE.
auto len = binding->resource->GetLength();
binding->resource->MockAddBufferedRange(0, len);
// gizmp-frag has two keyframes; one at dts=cts=0, and another at
// dts=cts=1000000. Verify we get expected results.
TimeUnit time;
binding->mVideoTrack =
binding->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
binding->mVideoTrack->Reset();
binding->mVideoTrack->GetNextRandomAccessPoint(&time);
EXPECT_EQ(time.ToMicroseconds(), 0);
binding->mVideoTrack->GetSamples()->Then(
binding->mTaskQueue, __func__,
[binding]() {
TimeUnit time;
binding->mVideoTrack->GetNextRandomAccessPoint(&time);
EXPECT_EQ(time.ToMicroseconds(), 1000000);
binding->mTaskQueue->BeginShutdown();
},
DO_FAIL);
});
}
开发者ID:Noctem,项目名称:gecko-dev,代码行数:29,代码来源:TestMP4Demuxer.cpp
示例7: Duration
TimeUnit
MP3TrackDemuxer::FastSeek(const TimeUnit& aTime) {
MP3LOG("FastSeek(%" PRId64 ") avgFrameLen=%f mNumParsedFrames=%" PRIu64
" mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
aTime, AverageFrameLength(), mNumParsedFrames, mFrameIndex, mOffset);
const auto& vbr = mParser.VBRInfo();
if (!aTime.ToMicroseconds()) {
// Quick seek to the beginning of the stream.
mFrameIndex = 0;
} else if (vbr.IsTOCPresent()) {
// Use TOC for more precise seeking.
const float durationFrac = static_cast<float>(aTime.ToMicroseconds()) /
Duration().ToMicroseconds();
mFrameIndex = FrameIndexFromOffset(vbr.Offset(durationFrac));
} else if (AverageFrameLength() > 0) {
mFrameIndex = FrameIndexFromTime(aTime);
}
mOffset = OffsetFromFrameIndex(mFrameIndex);
if (mOffset > mFirstFrameOffset && StreamLength() > 0) {
mOffset = std::min(StreamLength() - 1, mOffset);
}
mParser.EndFrameSession();
MP3LOG("FastSeek End TOC=%d avgFrameLen=%f mNumParsedFrames=%" PRIu64
" mFrameIndex=%" PRId64 " mFirstFrameOffset=%llu mOffset=%" PRIu64
" SL=%llu NumBytes=%u",
vbr.IsTOCPresent(), AverageFrameLength(), mNumParsedFrames, mFrameIndex,
mFirstFrameOffset, mOffset, StreamLength(), vbr.NumBytes().valueOr(0));
return Duration(mFrameIndex);
}
开发者ID:carriercomm,项目名称:system-addons,代码行数:35,代码来源:MP3Demuxer.cpp
示例8: GetBufferedStart
already_AddRefed<MediaByteBuffer>
SourceBuffer::PrepareAppend(const uint8_t* aData, uint32_t aLength, ErrorResult& aRv)
{
typedef SourceBufferContentManager::EvictDataResult Result;
if (!IsAttached() || mUpdating) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
mMediaSource->SetReadyState(MediaSourceReadyState::Open);
}
// Eviction uses a byte threshold. If the buffer is greater than the
// number of bytes then data is evicted. The time range for this
// eviction is reported back to the media source. It will then
// evict data before that range across all SourceBuffers it knows
// about.
// TODO: Make the eviction threshold smaller for audio-only streams.
// TODO: Drive evictions off memory pressure notifications.
// TODO: Consider a global eviction threshold rather than per TrackBuffer.
TimeUnit newBufferStartTime;
// Attempt to evict the amount of data we are about to add by lowering the
// threshold.
uint32_t toEvict =
(mEvictionThreshold > aLength) ? mEvictionThreshold - aLength : aLength;
Result evicted =
mContentManager->EvictData(TimeUnit::FromSeconds(mMediaSource->GetDecoder()->GetCurrentTime()),
toEvict, &newBufferStartTime);
if (evicted == Result::DATA_EVICTED) {
MSE_DEBUG("AppendData Evict; current buffered start=%f",
GetBufferedStart());
// We notify that we've evicted from the time range 0 through to
// the current start point.
mMediaSource->NotifyEvicted(0.0, newBufferStartTime.ToSeconds());
}
// See if we have enough free space to append our new data.
// As we can only evict once we have playable data, we must give a chance
// to the DASH player to provide a complete media segment.
if (aLength > mEvictionThreshold || evicted == Result::BUFFER_FULL ||
((!mIsUsingFormatReader &&
mContentManager->GetSize() > mEvictionThreshold - aLength) &&
evicted != Result::CANT_EVICT)) {
aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR);
return nullptr;
}
nsRefPtr<MediaByteBuffer> data = new MediaByteBuffer();
if (!data->AppendElements(aData, aLength, fallible)) {
aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR);
return nullptr;
}
return data.forget();
}
开发者ID:alison-shiue,项目名称:gecko-dev,代码行数:56,代码来源:SourceBuffer.cpp
示例9: Duration
TimeIntervals
MP3TrackDemuxer::GetBuffered() {
TimeUnit duration = Duration();
if (duration <= TimeUnit()) {
return TimeIntervals();
}
AutoPinned<MediaResource> stream(mSource.GetResource());
return GetEstimatedBufferedTimeRanges(stream, duration.ToMicroseconds());
}
开发者ID:MekliCZ,项目名称:positron,代码行数:10,代码来源:MP3Demuxer.cpp
示例10: mon
TimeUnit AudioSink::GetEndTime() const {
int64_t written;
{
MonitorAutoLock mon(mMonitor);
written = mWritten;
}
TimeUnit played = FramesToTimeUnit(written, mOutputRate) + mStartTime;
if (!played.IsValid()) {
NS_WARNING("Int overflow calculating audio end time");
return TimeUnit::Zero();
}
// As we may be resampling, rounding errors may occur. Ensure we never get
// past the original end time.
return std::min(mLastEndTime, played);
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:15,代码来源:AudioSink.cpp
示例11: mon
TimeUnit
AudioSink::GetEndTime() const
{
int64_t written;
{
MonitorAutoLock mon(mMonitor);
written = mWritten;
}
TimeUnit played = FramesToTimeUnit(written, mOutputRate) + mStartTime;
if (!played.IsValid()) {
NS_WARNING("Int overflow calculating audio end time");
return TimeUnit::Zero();
}
return played;
}
开发者ID:yrliou,项目名称:gecko-dev,代码行数:15,代码来源:AudioSink.cpp
示例12: PostOutput
nsresult PostOutput(BufferInfo::Param aInfo, MediaFormat::Param aFormat,
const TimeUnit& aDuration) override
{
RefPtr<layers::Image> img =
new SurfaceTextureImage(mSurfaceTexture.get(), mConfig.mDisplay,
gl::OriginPos::BottomLeft);
nsresult rv;
int32_t flags;
NS_ENSURE_SUCCESS(rv = aInfo->Flags(&flags), rv);
bool isSync = !!(flags & MediaCodec::BUFFER_FLAG_SYNC_FRAME);
int32_t offset;
NS_ENSURE_SUCCESS(rv = aInfo->Offset(&offset), rv);
int64_t presentationTimeUs;
NS_ENSURE_SUCCESS(rv = aInfo->PresentationTimeUs(&presentationTimeUs), rv);
RefPtr<VideoData> v =
VideoData::CreateFromImage(mConfig,
mImageContainer,
offset,
presentationTimeUs,
aDuration.ToMicroseconds(),
img,
isSync,
presentationTimeUs,
gfx::IntRect(0, 0,
mConfig.mDisplay.width,
mConfig.mDisplay.height));
INVOKE_CALLBACK(Output, v);
return NS_OK;
}
开发者ID:rnd-user,项目名称:gecko-dev,代码行数:34,代码来源:AndroidDecoderModule.cpp
示例13: WriteVideoToMediaStream
static void
WriteVideoToMediaStream(MediaStream* aStream,
layers::Image* aImage,
const TimeUnit& aEnd,
const TimeUnit& aStart,
const mozilla::gfx::IntSize& aIntrinsicSize,
const TimeStamp& aTimeStamp,
VideoSegment* aOutput,
const PrincipalHandle& aPrincipalHandle)
{
RefPtr<layers::Image> image = aImage;
auto end = aStream->MicrosecondsToStreamTimeRoundDown(aEnd.ToMicroseconds());
auto start = aStream->MicrosecondsToStreamTimeRoundDown(aStart.ToMicroseconds());
StreamTime duration = end - start;
aOutput->AppendFrame(image.forget(), duration, aIntrinsicSize,
aPrincipalHandle, false, aTimeStamp);
}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:17,代码来源:DecodedStream.cpp
示例14: TimeUnit
STEPEntity *
TimeUnit::Create(STEPWrapper *sw, SDAI_Application_instance *sse) {
Factory::OBJECTS::iterator i;
if ((i = Factory::FindObject(sse->STEPfile_id)) == Factory::objects.end()) {
TimeUnit *object = new TimeUnit(sw,sse->STEPfile_id);
Factory::AddObject(object);
if (!object->Load(sw, sse)) {
std::cerr << CLASSNAME << ":Error loading class in ::Create() method." << std::endl;
delete object;
return NULL;
}
return static_cast<STEPEntity *>(object);
} else {
return (*i).second;
}
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:18,代码来源:TimeUnit.cpp
示例15: TimeStamp
inline TimeStamp(TimeUnit unit, double dec)
: _unit(unit)
{
dec = std::max(0.0, dec);
dec = std::min(double(std::numeric_limits<uint32_t>::max()), dec);
double integral;
const double fractional = modf(dec, &integral);
_ticks = integral;
_subticks = fractional * unit.ppt();
}
开发者ID:EQ4,项目名称:lad,代码行数:10,代码来源:TimeStamp.hpp
示例16: DurationChanged
void MediaDecoder::DurationChanged(TimeUnit aNewDuration)
{
MOZ_ASSERT(NS_IsMainThread());
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
int64_t oldDuration = mDuration;
mDuration = aNewDuration.ToMicroseconds();
// Duration has changed so we should recompute playback rate
UpdatePlaybackRate();
SetInfinite(mDuration == -1);
if (mOwner && oldDuration != mDuration && !IsInfinite()) {
DECODER_LOG("Duration changed to %lld", mDuration);
mOwner->DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
}
if (CurrentPosition() > aNewDuration.ToMicroseconds()) {
Seek(aNewDuration.ToSeconds(), SeekTarget::Accurate);
}
}
开发者ID:ShakoHo,项目名称:gecko-dev,代码行数:20,代码来源:MediaDecoder.cpp
示例17: FastSeek
TimeUnit
WAVTrackDemuxer::ScanUntil(const TimeUnit& aTime)
{
if (!aTime.ToMicroseconds()) {
return FastSeek(aTime);
}
if (Duration(mChunkIndex) > aTime) {
FastSeek(aTime);
}
return SeekPosition();
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:13,代码来源:WaveDemuxer.cpp
示例18: Output
nsresult Output(BufferInfo::Param aInfo, void* aBuffer,
MediaFormat::Param aFormat, const TimeUnit& aDuration)
{
// The output on Android is always 16-bit signed
nsresult rv;
int32_t numChannels;
NS_ENSURE_SUCCESS(rv =
aFormat->GetInteger(NS_LITERAL_STRING("channel-count"), &numChannels), rv);
AudioConfig::ChannelLayout layout(numChannels);
if (!layout.IsValid()) {
return NS_ERROR_FAILURE;
}
int32_t sampleRate;
NS_ENSURE_SUCCESS(rv =
aFormat->GetInteger(NS_LITERAL_STRING("sample-rate"), &sampleRate), rv);
int32_t size;
NS_ENSURE_SUCCESS(rv = aInfo->Size(&size), rv);
int32_t offset;
NS_ENSURE_SUCCESS(rv = aInfo->Offset(&offset), rv);
#ifdef MOZ_SAMPLE_TYPE_S16
const int32_t numSamples = size / 2;
#else
#error We only support 16-bit integer PCM
#endif
const int32_t numFrames = numSamples / numChannels;
AlignedAudioBuffer audio(numSamples);
if (!audio) {
return NS_ERROR_OUT_OF_MEMORY;
}
const uint8_t* bufferStart = static_cast<uint8_t*>(aBuffer) + offset;
PodCopy(audio.get(), reinterpret_cast<const AudioDataValue*>(bufferStart),
numSamples);
int64_t presentationTimeUs;
NS_ENSURE_SUCCESS(rv = aInfo->PresentationTimeUs(&presentationTimeUs), rv);
RefPtr<AudioData> data = new AudioData(0, presentationTimeUs,
aDuration.ToMicroseconds(),
numFrames,
Move(audio),
numChannels,
sampleRate);
INVOKE_CALLBACK(Output, data);
return NS_OK;
}
开发者ID:ollie314,项目名称:gecko-dev,代码行数:51,代码来源:MediaCodecDataDecoder.cpp
示例19: TimeUnit
TimeUnit
MP3TrackDemuxer::FastSeek(TimeUnit aTime) {
if (!aTime.ToMicroseconds()) {
// Quick seek to the beginning of the stream.
mOffset = mFirstFrameOffset;
mFrameIndex = 0;
mParser.EndFrameSession();
return TimeUnit();
}
if (!mSamplesPerFrame || !mNumParsedFrames) {
return TimeUnit::FromMicroseconds(-1);
}
const int64_t numFrames = aTime.ToSeconds() *
mSamplesPerSecond / mSamplesPerFrame;
mOffset = mFirstFrameOffset + numFrames * AverageFrameLength();
mFrameIndex = numFrames;
mParser.EndFrameSession();
return Duration(mFrameIndex);
}
开发者ID:giota-cliqz,项目名称:browser-f,代码行数:23,代码来源:MP3Demuxer.cpp
示例20: FastSeek
TimeUnit
MP3TrackDemuxer::ScanUntil(TimeUnit aTime) {
if (!aTime.ToMicroseconds()) {
return FastSeek(aTime);
}
if (Duration(mFrameIndex) > aTime) {
FastSeek(aTime);
}
MediaByteRange nextRange = FindNextFrame();
while (SkipNextFrame(nextRange) && Duration(mFrameIndex + 1) < aTime) {
nextRange = FindNextFrame();
}
return Duration(mFrameIndex);
}
开发者ID:giota-cliqz,项目名称:browser-f,代码行数:17,代码来源:MP3Demuxer.cpp
注:本文中的TimeUnit类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论