| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/formats/webm/webm_cluster_parser.h" | 5 #include "media/formats/webm/webm_cluster_parser.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 bool WebMClusterParser::Track::QueueBuffer( | 523 bool WebMClusterParser::Track::QueueBuffer( |
| 524 const scoped_refptr<StreamParserBuffer>& buffer) { | 524 const scoped_refptr<StreamParserBuffer>& buffer) { |
| 525 DCHECK(!last_added_buffer_missing_duration_); | 525 DCHECK(!last_added_buffer_missing_duration_); |
| 526 base::TimeDelta duration = buffer->duration(); | 526 base::TimeDelta duration = buffer->duration(); |
| 527 if (duration < base::TimeDelta() || duration == kNoTimestamp()) { | 527 if (duration < base::TimeDelta() || duration == kNoTimestamp()) { |
| 528 DVLOG(2) << "QueueBuffer() : Invalid buffer duration: " | 528 DVLOG(2) << "QueueBuffer() : Invalid buffer duration: " |
| 529 << duration.InSecondsF(); | 529 << duration.InSecondsF(); |
| 530 return false; | 530 return false; |
| 531 } | 531 } |
| 532 | 532 |
| 533 estimated_next_frame_duration_ = std::max(duration, | 533 // The estimated frame duration is the minimum non-zero duration since the |
| 534 estimated_next_frame_duration_); | 534 // last initialization segment. The minimum is used to ensure frame durations |
| 535 // aren't overestimated. |
| 536 if (duration > base::TimeDelta()) { |
| 537 if (estimated_next_frame_duration_ == kNoTimestamp()) { |
| 538 estimated_next_frame_duration_ = duration; |
| 539 } else { |
| 540 estimated_next_frame_duration_ = |
| 541 std::min(duration, estimated_next_frame_duration_); |
| 542 } |
| 543 } |
| 544 |
| 535 buffers_.push_back(buffer); | 545 buffers_.push_back(buffer); |
| 536 return true; | 546 return true; |
| 537 } | 547 } |
| 538 | 548 |
| 539 base::TimeDelta WebMClusterParser::Track::GetDurationDefaultOrEstimate() { | 549 base::TimeDelta WebMClusterParser::Track::GetDurationDefaultOrEstimate() { |
| 540 base::TimeDelta duration = default_duration_; | 550 base::TimeDelta duration = default_duration_; |
| 541 if (duration != kNoTimestamp()) { | 551 if (duration != kNoTimestamp()) { |
| 542 DVLOG(3) << __FUNCTION__ << " : using TrackEntry DefaultDuration"; | 552 DVLOG(3) << __FUNCTION__ << " : using TrackEntry DefaultDuration"; |
| 543 } else if (estimated_next_frame_duration_ != kNoTimestamp()) { | 553 } else if (estimated_next_frame_duration_ != kNoTimestamp()) { |
| 544 DVLOG(3) << __FUNCTION__ << " : using estimated duration"; | 554 DVLOG(3) << __FUNCTION__ << " : using estimated duration"; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 572 WebMClusterParser::FindTextTrack(int track_num) { | 582 WebMClusterParser::FindTextTrack(int track_num) { |
| 573 const TextTrackMap::iterator it = text_track_map_.find(track_num); | 583 const TextTrackMap::iterator it = text_track_map_.find(track_num); |
| 574 | 584 |
| 575 if (it == text_track_map_.end()) | 585 if (it == text_track_map_.end()) |
| 576 return NULL; | 586 return NULL; |
| 577 | 587 |
| 578 return &it->second; | 588 return &it->second; |
| 579 } | 589 } |
| 580 | 590 |
| 581 } // namespace media | 591 } // namespace media |
| OLD | NEW |