Chromium Code Reviews| Index: media/filters/frame_processor_base.cc |
| diff --git a/media/filters/frame_processor_base.cc b/media/filters/frame_processor_base.cc |
| index 09b1b86c3b39011ce2d0a6cc406ebc80af98ef15..8e888922760b5a70c598f7dda918628d31daf634 100644 |
| --- a/media/filters/frame_processor_base.cc |
| +++ b/media/filters/frame_processor_base.cc |
| @@ -97,4 +97,65 @@ void FrameProcessorBase::NotifyNewMediaSegmentStarting( |
| } |
| } |
| +bool FrameProcessorBase::HandlePartialAppendWindowTrimming( |
| + base::TimeDelta append_window_start, |
| + base::TimeDelta append_window_end, |
| + base::TimeDelta frame_start_timestamp, |
| + base::TimeDelta frame_end_timestamp, |
| + const scoped_refptr<StreamParserBuffer>& buffer) { |
| + // Ignore any buffers which start after |append_window_start| or end after |
|
acolwell GONE FROM CHROMIUM
2014/05/23 17:27:30
DCHECK(DemuxerStream::AUDIO, buffer->type()) since
DaleCurtis
2014/05/23 21:46:26
Done.
|
| + // |append_window_end|. For simplicity, even those that start before |
| + // |append_window_start|. |
| + if (frame_start_timestamp > append_window_start || |
| + frame_end_timestamp > append_window_end) { |
| + // TODO(dalecurtis): Partial append window trimming could also be done |
| + // around |append_window_end|, but is not necessary since splice frames |
| + // cover overlaps there. |
| + return false; |
| + } |
| + |
| + // If the buffer is entirely before |append_window_start|, save it as preroll |
| + // for the first buffer which overlaps |append_window_start|. |
| + if (frame_start_timestamp < append_window_start && |
| + frame_end_timestamp <= append_window_start) { |
| + audio_preroll_buffer_ = buffer; |
| + audio_preroll_buffer_->set_timestamp(frame_start_timestamp); |
|
wolenetz
2014/05/23 19:59:45
also SetDecodeTimestamp()?
DaleCurtis
2014/05/23 21:46:26
I don't think it's necessary.
|
| + audio_preroll_buffer_->set_duration(frame_end_timestamp - |
| + frame_start_timestamp); |
| + return false; |
| + } |
| + |
| + // See if a partial discard can be done around |append_window_start|. |
| + DCHECK(frame_start_timestamp <= append_window_start); |
| + DCHECK(buffer->IsKeyframe()); |
| + DVLOG(1) << "Truncating buffer which overlaps append window start." |
| + << " presentation_timestamp " << frame_start_timestamp.InSecondsF() |
| + << " append_window_start " << append_window_start.InSecondsF(); |
| + |
| + // If this isn't the first buffer discarded by the append window, try to use |
| + // the last buffer discarded for preroll. This ensures that the partially |
| + // trimmed buffer can be correctly decoded. |
| + if (audio_preroll_buffer_) { |
| + if (audio_preroll_buffer_->timestamp() + |
| + audio_preroll_buffer_->duration() == |
| + frame_start_timestamp) { |
| + buffer->SetPrerollBuffer(audio_preroll_buffer_); |
| + } |
|
wolenetz
2014/05/23 19:59:45
nit: MEDIA_LOG when an audio_preroll_buffer exists
DaleCurtis
2014/05/23 21:46:26
For another CL, MEDIA_LOG isn't available here.
|
| + audio_preroll_buffer_ = NULL; |
| + } |
| + |
| + // Adjust the timestamp of this buffer forward to |append_window_start|. |
| + buffer->set_timestamp(append_window_start); |
|
acolwell GONE FROM CHROMIUM
2014/05/23 17:27:30
Shouldn't these 2 calls also only need to happen i
DaleCurtis
2014/05/23 21:46:26
Correct. Seems unnecessary to duplicate these sets
|
| + buffer->SetDecodeTimestamp(append_window_start); |
| + |
| + // Decrease the duration appropriately. We only need to shorten the buffer if |
| + // it overlaps |append_window_start|. |
| + if (frame_start_timestamp < append_window_start) { |
| + buffer->set_discard_padding(std::make_pair( |
| + append_window_start - frame_start_timestamp, base::TimeDelta())); |
| + buffer->set_duration(frame_end_timestamp - append_window_start); |
| + } |
| + return true; |
| +} |
| + |
| } // namespace media |