本文整理汇总了C++中BMediaTrack::CurrentFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ BMediaTrack::CurrentFrame方法的具体用法?C++ BMediaTrack::CurrentFrame怎么用?C++ BMediaTrack::CurrentFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMediaTrack
的用法示例。
在下文中一共展示了BMediaTrack::CurrentFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int32
MediaView::MediaPlayer(
void *arg)
{
MediaView* view = (MediaView *)arg;
BWindow* window = view->Window();
BBitmap* bitmap = view->fBitmap;
BMediaTrack* videoTrack = view->fVideoTrack;
BMediaTrack* audioTrack = view->fAudioTrack;
BMediaTrack* counterTrack = (videoTrack != NULL) ? videoTrack : audioTrack;
AudioOutput* audioOutput = view->fAudioOutput;
void* adBuffer = view->fAudioDumpingBuffer;
int64 numFrames = counterTrack->CountFrames();
int64 numFramesToSkip = 0;
int64 numSkippedFrames = 0;
bool scrubbing = false;
bool seekNeeded = false;
int64 dummy;
media_header mh;
bigtime_t vStartTime, aStartTime, seekTime, snoozeTime, startTime;
bigtime_t curScrubbing, lastScrubbing, lastTime;
curScrubbing = lastScrubbing = system_time();
seekTime = 0LL;
// Main processing loop (handle stop->start->stop)
while (acquire_sem(view->fPlaySem) == B_OK) {
release_sem(view->fPlaySem);
// as we are doing stop->start, restart audio if needed.
if (audioTrack != NULL)
audioOutput->Play();
startTime = system_time()-counterTrack->CurrentTime();
// This will loop until the end of the stream
while ((counterTrack->CurrentFrame() < numFrames) || scrubbing) {
// We are in scrub mode
if (acquire_sem(view->fScrubSem) == B_OK) {
curScrubbing = system_time();
// We are entering scrub mode
if (!scrubbing) {
if (audioTrack != NULL)
audioOutput->Stop();
scrubbing = true;
}
// Do a seek.
seekNeeded = true;
seekTime = view->fScrubTime;
}
// We are not scrubbing
else if (scrubbing) {
if (audioTrack != NULL)
audioOutput->Play();
scrubbing = false;
}
// Handle seeking
if (seekNeeded) {
if (videoTrack) {
// Seek the seekTime as close as possible
vStartTime = seekTime;
videoTrack->SeekToTime(&vStartTime);
// Read frames until we get less than 50ms ahead.
lastTime = vStartTime;
do {
bitmap->LockBits();
status_t err = videoTrack->ReadFrames((char*)bitmap->Bits(), &dummy, &mh);
bitmap->UnlockBits();
if (err != B_OK) break;
vStartTime = mh.start_time;
if ((dummy == 0) || (vStartTime <= lastTime))
break;
lastTime = vStartTime;
} while (seekTime - vStartTime > 50000);
}
if (audioTrack) {
// Seek the extractor as close as possible
aStartTime = seekTime;
audioOutput->SeekToTime(&aStartTime);
// Read frames until we get less than 50ms ahead.
lastTime = aStartTime;
while (seekTime - aStartTime > 50000) {
if (audioTrack->ReadFrames((char *)adBuffer, &dummy, &mh) != B_OK)
break;
aStartTime = mh.start_time;
if ((dummy == 0) || (aStartTime <= lastTime))
break;
lastTime = aStartTime;
}
}
else startTime = system_time() - vStartTime;
// Set the current time
view->fCurTime = seekTime;
//.........这里部分代码省略.........
示例2: sizeof
//.........这里部分代码省略.........
" - user canceled before transcoding\n");
ret = B_CANCELED;
}
if (ret < B_OK) {
delete[] audioBuffer;
delete[] videoBuffer;
delete outFile;
return ret;
}
outFile->CommitHeader();
// this is where you would call outFile->AddCopyright(...)
int64 framesRead;
media_header mh;
int32 lastPercent, currPercent;
float completePercent;
BString status;
int64 start;
int64 end;
int32 stat = 0;
// read video from source and write to destination, if necessary
if (outVidTrack != NULL) {
lastPercent = -1;
videoFrameCount = inVidTrack->CountFrames();
if (endDuration == 0 || endDuration < startDuration) {
start = 0;
end = videoFrameCount;
} else {
inVidTrack->SeekToTime(&endDuration, stat);
end = inVidTrack->CurrentFrame();
inVidTrack->SeekToTime(&startDuration, stat);
start = inVidTrack->CurrentFrame();
if (end > videoFrameCount)
end = videoFrameCount;
if (start > end)
start = 0;
}
framesRead = 0;
for (int64 i = start; (i <= end) && !fCancel; i += framesRead) {
if ((ret = inVidTrack->ReadFrames(videoBuffer, &framesRead,
&mh)) != B_OK) {
fprintf(stderr, "Error reading video frame %" B_PRId64 ": %s\n", i,
strerror(ret));
snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Error read video frame %" B_PRId64), i);
status.UnlockBuffer();
SetStatusMessage(status.String());
break;
}
if ((ret = outVidTrack->WriteFrames(videoBuffer, framesRead,
mh.u.encoded_video.field_flags)) != B_OK) {
fprintf(stderr, "Error writing video frame %" B_PRId64 ": %s\n", i,
strerror(ret));
snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Error writing video frame %" B_PRId64), i);
status.UnlockBuffer();
SetStatusMessage(status.String());
break;