| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/filters/source_buffer_stream.h" | 5 #include "media/filters/source_buffer_stream.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 bool reverse_direction) { | 550 bool reverse_direction) { |
| 551 DCHECK_GT(total_bytes_to_free, 0); | 551 DCHECK_GT(total_bytes_to_free, 0); |
| 552 int bytes_to_free = total_bytes_to_free; | 552 int bytes_to_free = total_bytes_to_free; |
| 553 int bytes_freed = 0; | 553 int bytes_freed = 0; |
| 554 | 554 |
| 555 // This range will save the last GOP appended to |range_for_next_append_| | 555 // This range will save the last GOP appended to |range_for_next_append_| |
| 556 // if the buffers surrounding it get deleted during garbage collection. | 556 // if the buffers surrounding it get deleted during garbage collection. |
| 557 SourceBufferRange* new_range_for_append = NULL; | 557 SourceBufferRange* new_range_for_append = NULL; |
| 558 | 558 |
| 559 while (!ranges_.empty() && bytes_to_free > 0) { | 559 while (!ranges_.empty() && bytes_to_free > 0) { |
| 560 | |
| 561 SourceBufferRange* current_range = NULL; | 560 SourceBufferRange* current_range = NULL; |
| 562 BufferQueue buffers; | 561 BufferQueue buffers; |
| 563 int bytes_deleted = 0; | 562 int bytes_deleted = 0; |
| 564 | 563 |
| 565 if (reverse_direction) { | 564 if (reverse_direction) { |
| 566 current_range = ranges_.back(); | 565 current_range = ranges_.back(); |
| 567 if (current_range->LastGOPContainsNextBufferPosition()) { | 566 if (current_range->LastGOPContainsNextBufferPosition()) { |
| 568 DCHECK_EQ(current_range, selected_range_); | 567 DCHECK_EQ(current_range, selected_range_); |
| 569 break; | 568 break; |
| 570 } | 569 } |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 if (audio_configs_[0]->channel_layout() != config.channel_layout()) { | 1053 if (audio_configs_[0]->channel_layout() != config.channel_layout()) { |
| 1055 MEDIA_LOG(log_cb_) << "Audio channel layout changes not allowed."; | 1054 MEDIA_LOG(log_cb_) << "Audio channel layout changes not allowed."; |
| 1056 return false; | 1055 return false; |
| 1057 } | 1056 } |
| 1058 | 1057 |
| 1059 if (audio_configs_[0]->bits_per_channel() != config.bits_per_channel()) { | 1058 if (audio_configs_[0]->bits_per_channel() != config.bits_per_channel()) { |
| 1060 MEDIA_LOG(log_cb_) << "Audio bits per channel changes not allowed."; | 1059 MEDIA_LOG(log_cb_) << "Audio bits per channel changes not allowed."; |
| 1061 return false; | 1060 return false; |
| 1062 } | 1061 } |
| 1063 | 1062 |
| 1063 if (audio_configs_[0]->is_encrypted() != config.is_encrypted()) { |
| 1064 MEDIA_LOG(log_cb_) << "Audio encryption changes not allowed."; |
| 1065 return false; |
| 1066 } |
| 1067 |
| 1064 // Check to see if the new config matches an existing one. | 1068 // Check to see if the new config matches an existing one. |
| 1065 for (size_t i = 0; i < audio_configs_.size(); ++i) { | 1069 for (size_t i = 0; i < audio_configs_.size(); ++i) { |
| 1066 if (config.Matches(*audio_configs_[i])) { | 1070 if (config.Matches(*audio_configs_[i])) { |
| 1067 append_config_index_ = i; | 1071 append_config_index_ = i; |
| 1068 return true; | 1072 return true; |
| 1069 } | 1073 } |
| 1070 } | 1074 } |
| 1071 | 1075 |
| 1072 // No matches found so let's add this one to the list. | 1076 // No matches found so let's add this one to the list. |
| 1073 append_config_index_ = audio_configs_.size(); | 1077 append_config_index_ = audio_configs_.size(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1084 if (video_configs_[0]->is_encrypted() != config.is_encrypted()) { | 1088 if (video_configs_[0]->is_encrypted() != config.is_encrypted()) { |
| 1085 MEDIA_LOG(log_cb_) <<"Video Encryption changes not allowed."; | 1089 MEDIA_LOG(log_cb_) <<"Video Encryption changes not allowed."; |
| 1086 return false; | 1090 return false; |
| 1087 } | 1091 } |
| 1088 | 1092 |
| 1089 if (video_configs_[0]->codec() != config.codec()) { | 1093 if (video_configs_[0]->codec() != config.codec()) { |
| 1090 MEDIA_LOG(log_cb_) <<"Video codec changes not allowed."; | 1094 MEDIA_LOG(log_cb_) <<"Video codec changes not allowed."; |
| 1091 return false; | 1095 return false; |
| 1092 } | 1096 } |
| 1093 | 1097 |
| 1098 if (video_configs_[0]->is_encrypted() != config.is_encrypted()) { |
| 1099 MEDIA_LOG(log_cb_) << "Video encryption changes not allowed."; |
| 1100 return false; |
| 1101 } |
| 1102 |
| 1094 // Check to see if the new config matches an existing one. | 1103 // Check to see if the new config matches an existing one. |
| 1095 for (size_t i = 0; i < video_configs_.size(); ++i) { | 1104 for (size_t i = 0; i < video_configs_.size(); ++i) { |
| 1096 if (config.Matches(*video_configs_[i])) { | 1105 if (config.Matches(*video_configs_[i])) { |
| 1097 append_config_index_ = i; | 1106 append_config_index_ = i; |
| 1098 return true; | 1107 return true; |
| 1099 } | 1108 } |
| 1100 } | 1109 } |
| 1101 | 1110 |
| 1102 // No matches found so let's add this one to the list. | 1111 // No matches found so let's add this one to the list. |
| 1103 append_config_index_ = video_configs_.size(); | 1112 append_config_index_ = video_configs_.size(); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 return ComputeFudgeRoom(GetApproximateDuration()); | 1573 return ComputeFudgeRoom(GetApproximateDuration()); |
| 1565 } | 1574 } |
| 1566 | 1575 |
| 1567 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { | 1576 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { |
| 1568 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); | 1577 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); |
| 1569 DCHECK(max_interbuffer_distance != kNoTimestamp()); | 1578 DCHECK(max_interbuffer_distance != kNoTimestamp()); |
| 1570 return max_interbuffer_distance; | 1579 return max_interbuffer_distance; |
| 1571 } | 1580 } |
| 1572 | 1581 |
| 1573 } // namespace media | 1582 } // namespace media |
| OLD | NEW |