Chromium Code Reviews| Index: media/filters/source_buffer_stream.cc |
| diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc |
| index d20969f00c96c81089b8a94436700cf6aee9c5bf..e0f7266c2c267a91bd2c6caeda442491c2dd25e6 100644 |
| --- a/media/filters/source_buffer_stream.cc |
| +++ b/media/filters/source_buffer_stream.cc |
| @@ -50,6 +50,11 @@ static base::TimeDelta ComputeFudgeRoom(base::TimeDelta approximate_duration) { |
| // is set and there's not enough information to get a better estimate. |
| static int kDefaultBufferDurationInMs = 125; |
|
DaleCurtis
2015/07/16 20:39:22
These three should all be marked const.
wolenetz
2015/07/17 17:38:15
Good catch! I've converted these to enum values, a
|
| +// Limit the number of MEDIA_LOG() logs for splice buffer generation warnings |
|
DaleCurtis
2015/07/16 20:39:21
I feel like these will be hit really fast.
chcunningham
2015/07/17 01:36:26
I wouldn't have guessed so. Do you expect we have
wolenetz
2015/07/17 17:38:15
I think there is room to increase, though there is
DaleCurtis
2015/07/17 18:22:34
Yes I definitely think we need a more programmatic
|
| +// and successes. |
| +static int kMaxSpliceGenerationWarningLogs = 5; |
| +static int kMaxSpliceGenerationSuccessLogs = 5; |
| + |
| // The amount of time the beginning of the buffered data can differ from the |
| // start time in order to still be considered the start of stream. |
| static base::TimeDelta kSeekToStartFudgeRoom() { |
| @@ -114,7 +119,9 @@ SourceBufferStream::SourceBufferStream(const AudioDecoderConfig& audio_config, |
| config_change_pending_(false), |
| splice_buffers_index_(0), |
| pending_buffers_complete_(false), |
| - splice_frames_enabled_(splice_frames_enabled) { |
| + splice_frames_enabled_(splice_frames_enabled), |
| + num_splice_generation_warning_logs_(0), |
| + num_splice_generation_success_logs_(0) { |
| DCHECK(audio_config.IsValidConfig()); |
| audio_configs_.push_back(audio_config); |
| } |
| @@ -140,7 +147,9 @@ SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config, |
| config_change_pending_(false), |
| splice_buffers_index_(0), |
| pending_buffers_complete_(false), |
| - splice_frames_enabled_(splice_frames_enabled) { |
| + splice_frames_enabled_(splice_frames_enabled), |
| + num_splice_generation_warning_logs_(0), |
| + num_splice_generation_success_logs_(0) { |
| DCHECK(video_config.IsValidConfig()); |
| video_configs_.push_back(video_config); |
| } |
| @@ -167,8 +176,9 @@ SourceBufferStream::SourceBufferStream(const TextTrackConfig& text_config, |
| config_change_pending_(false), |
| splice_buffers_index_(0), |
| pending_buffers_complete_(false), |
| - splice_frames_enabled_(splice_frames_enabled) { |
| -} |
| + splice_frames_enabled_(splice_frames_enabled), |
| + num_splice_generation_warning_logs_(0), |
| + num_splice_generation_success_logs_(0) {} |
| SourceBufferStream::~SourceBufferStream() { |
| while (!ranges_.empty()) { |
| @@ -1548,8 +1558,17 @@ void SourceBufferStream::GenerateSpliceFrame(const BufferQueue& new_buffers) { |
| // |
| // We also do not want to generate splices if the first new buffer replaces an |
| // existing buffer exactly. |
| - if (pre_splice_buffers.front()->timestamp() >= splice_timestamp) |
| + if (pre_splice_buffers.front()->timestamp() >= splice_timestamp) { |
| + LIMITED_MEDIA_LOG(DEBUG, media_log_, num_splice_generation_warning_logs_, |
| + kMaxSpliceGenerationWarningLogs) |
| + << "Skipping splice frame buffering: first new buffer at " |
|
DaleCurtis
2015/07/16 20:39:22
s/buffering/generation/ ditto for all the rest.
wolenetz
2015/07/17 17:38:15
Done
|
| + << splice_timestamp.InMicroseconds() |
| + << "us begins at or before existing buffer at " |
| + << pre_splice_buffers.front()->timestamp().InMicroseconds() << "us."; |
| + DVLOG(1) << "Skipping splice: overlapped buffers begin at or after the " |
|
DaleCurtis
2015/07/16 20:39:21
Do we need both of these?
wolenetz
2015/07/17 17:38:15
I think the DVLOGs have value still (in the LIMITE
|
| + "first new buffer."; |
| return; |
| + } |
| // If any |pre_splice_buffers| are already splices or preroll, do not generate |
| // a splice. |
| @@ -1557,12 +1576,22 @@ void SourceBufferStream::GenerateSpliceFrame(const BufferQueue& new_buffers) { |
| const BufferQueue& original_splice_buffers = |
| pre_splice_buffers[i]->splice_buffers(); |
| if (!original_splice_buffers.empty()) { |
| + LIMITED_MEDIA_LOG(DEBUG, media_log_, num_splice_generation_warning_logs_, |
| + kMaxSpliceGenerationWarningLogs) |
| + << "Skipping splice frame buffering: overlapped buffers at " |
| + << pre_splice_buffers[i]->timestamp().InMicroseconds() |
| + << "us are in a previously buffered splice."; |
| DVLOG(1) << "Can't generate splice: overlapped buffers contain a " |
| "pre-existing splice."; |
| return; |
| } |
| if (pre_splice_buffers[i]->preroll_buffer().get()) { |
| + LIMITED_MEDIA_LOG(DEBUG, media_log_, num_splice_generation_warning_logs_, |
| + kMaxSpliceGenerationWarningLogs) |
| + << "Skipping splice frame buffering: overlapped buffers at " |
| + << pre_splice_buffers[i]->timestamp().InMicroseconds() |
| + << "us contain preroll."; |
| DVLOG(1) << "Can't generate splice: overlapped buffers contain preroll."; |
| return; |
| } |
| @@ -1579,15 +1608,27 @@ void SourceBufferStream::GenerateSpliceFrame(const BufferQueue& new_buffers) { |
| base::TimeDelta::FromSecondsD( |
| 2.0 / audio_configs_[append_config_index_].samples_per_second())); |
| if (splice_duration < minimum_splice_duration) { |
| + LIMITED_MEDIA_LOG(DEBUG, media_log_, num_splice_generation_warning_logs_, |
| + kMaxSpliceGenerationWarningLogs) |
| + << "Skipping splice frame buffering: not enough samples for splicing " |
| + "new buffer at " |
| + << splice_timestamp.InMicroseconds() << "us. Have " |
| + << splice_duration.InMicroseconds() << "us, but need " |
| + << minimum_splice_duration.InMicroseconds() << "us."; |
| DVLOG(1) << "Can't generate splice: not enough samples for crossfade; have " |
| - << splice_duration.InMicroseconds() << " us, but need " |
| - << minimum_splice_duration.InMicroseconds() << " us."; |
| + << splice_duration.InMicroseconds() << "us, but need " |
| + << minimum_splice_duration.InMicroseconds() << "us."; |
| return; |
| } |
| DVLOG(1) << "Generating splice frame @ " << new_buffers.front()->timestamp() |
| << ", splice duration: " << splice_duration.InMicroseconds() |
| << " us"; |
| + LIMITED_MEDIA_LOG(DEBUG, media_log_, num_splice_generation_success_logs_, |
| + kMaxSpliceGenerationSuccessLogs) |
| + << "Generated splice of overlap duration " |
| + << splice_duration.InMicroseconds() << "us into new buffer at " |
| + << splice_timestamp.InMicroseconds() << "us."; |
| new_buffers.front()->ConvertToSpliceBuffer(pre_splice_buffers); |
| } |