Skip to content

Commit

Permalink
VIDEO: Add wrapper around setEndTime() to specify an end frame
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed Aug 17, 2014
1 parent 9a5b3bf commit 422922f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
25 changes: 25 additions & 0 deletions video/video_decoder.cpp
Expand Up @@ -778,6 +778,31 @@ void VideoDecoder::setEndTime(const Audio::Timestamp &endTime) {
}
}

void VideoDecoder::setEndFrame(uint frame) {
VideoTrack *track = 0;

for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
if ((*it)->getTrackType() == Track::kTrackTypeVideo) {
// We only allow this when one video track is present
if (track)
return;

track = (VideoTrack *)*it;
}
}

// If we didn't find a video track, we can't set the final frame (of course)
if (!track)
return;

Audio::Timestamp time = track->getFrameTime(frame + 1);

if (time < 0)
return;

setEndTime(time);
}

VideoDecoder::Track *VideoDecoder::getTrack(uint track) {
if (track > _internalTracks.size())
return 0;
Expand Down
11 changes: 11 additions & 0 deletions video/video_decoder.h
Expand Up @@ -213,6 +213,17 @@ class VideoDecoder {
*/
void setEndTime(const Audio::Timestamp &endTime);

/**
* Set the end frame.
*
* The passed frame will be the last frame to show.
*
* Like seekToFrame(), this only works when one video track is present,
* and that track supports getFrameTime(). This calls setEndTime()
* internally.
*/
void setEndFrame(uint frame);

/**
* Get the stop time of the video (if not set, zero)
*/
Expand Down

0 comments on commit 422922f

Please sign in to comment.