| 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 #include <sstream> | 9 #include <sstream> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { | 1538 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { |
| 1539 DCHECK(!audio_configs_.empty()); | 1539 DCHECK(!audio_configs_.empty()); |
| 1540 DCHECK(video_configs_.empty()); | 1540 DCHECK(video_configs_.empty()); |
| 1541 DVLOG(3) << "UpdateAudioConfig."; | 1541 DVLOG(3) << "UpdateAudioConfig."; |
| 1542 | 1542 |
| 1543 if (audio_configs_[0].codec() != config.codec()) { | 1543 if (audio_configs_[0].codec() != config.codec()) { |
| 1544 MEDIA_LOG(ERROR, media_log_) << "Audio codec changes not allowed."; | 1544 MEDIA_LOG(ERROR, media_log_) << "Audio codec changes not allowed."; |
| 1545 return false; | 1545 return false; |
| 1546 } | 1546 } |
| 1547 | 1547 |
| 1548 if (!audio_configs_[0].encryption_scheme().Matches( | |
| 1549 config.encryption_scheme())) { | |
| 1550 MEDIA_LOG(ERROR, media_log_) << "Audio encryption changes not allowed."; | |
| 1551 return false; | |
| 1552 } | |
| 1553 | |
| 1554 // Check to see if the new config matches an existing one. | 1548 // Check to see if the new config matches an existing one. |
| 1555 for (size_t i = 0; i < audio_configs_.size(); ++i) { | 1549 for (size_t i = 0; i < audio_configs_.size(); ++i) { |
| 1556 if (config.Matches(audio_configs_[i])) { | 1550 if (config.Matches(audio_configs_[i])) { |
| 1557 append_config_index_ = i; | 1551 append_config_index_ = i; |
| 1558 return true; | 1552 return true; |
| 1559 } | 1553 } |
| 1560 } | 1554 } |
| 1561 | 1555 |
| 1562 // No matches found so let's add this one to the list. | 1556 // No matches found so let's add this one to the list. |
| 1563 append_config_index_ = audio_configs_.size(); | 1557 append_config_index_ = audio_configs_.size(); |
| 1564 DVLOG(2) << "New audio config - index: " << append_config_index_; | 1558 DVLOG(2) << "New audio config - index: " << append_config_index_; |
| 1565 audio_configs_.resize(audio_configs_.size() + 1); | 1559 audio_configs_.resize(audio_configs_.size() + 1); |
| 1566 audio_configs_[append_config_index_] = config; | 1560 audio_configs_[append_config_index_] = config; |
| 1567 return true; | 1561 return true; |
| 1568 } | 1562 } |
| 1569 | 1563 |
| 1570 bool SourceBufferStream::UpdateVideoConfig(const VideoDecoderConfig& config) { | 1564 bool SourceBufferStream::UpdateVideoConfig(const VideoDecoderConfig& config) { |
| 1571 DCHECK(!video_configs_.empty()); | 1565 DCHECK(!video_configs_.empty()); |
| 1572 DCHECK(audio_configs_.empty()); | 1566 DCHECK(audio_configs_.empty()); |
| 1573 DVLOG(3) << "UpdateVideoConfig."; | 1567 DVLOG(3) << "UpdateVideoConfig."; |
| 1574 | 1568 |
| 1575 if (video_configs_[0].codec() != config.codec()) { | 1569 if (video_configs_[0].codec() != config.codec()) { |
| 1576 MEDIA_LOG(ERROR, media_log_) << "Video codec changes not allowed."; | 1570 MEDIA_LOG(ERROR, media_log_) << "Video codec changes not allowed."; |
| 1577 return false; | 1571 return false; |
| 1578 } | 1572 } |
| 1579 | 1573 |
| 1580 if (!video_configs_[0].encryption_scheme().Matches( | |
| 1581 config.encryption_scheme())) { | |
| 1582 MEDIA_LOG(ERROR, media_log_) << "Video encryption changes not allowed."; | |
| 1583 return false; | |
| 1584 } | |
| 1585 | |
| 1586 // Check to see if the new config matches an existing one. | 1574 // Check to see if the new config matches an existing one. |
| 1587 for (size_t i = 0; i < video_configs_.size(); ++i) { | 1575 for (size_t i = 0; i < video_configs_.size(); ++i) { |
| 1588 if (config.Matches(video_configs_[i])) { | 1576 if (config.Matches(video_configs_[i])) { |
| 1589 append_config_index_ = i; | 1577 append_config_index_ = i; |
| 1590 return true; | 1578 return true; |
| 1591 } | 1579 } |
| 1592 } | 1580 } |
| 1593 | 1581 |
| 1594 // No matches found so let's add this one to the list. | 1582 // No matches found so let's add this one to the list. |
| 1595 append_config_index_ = video_configs_.size(); | 1583 append_config_index_ = video_configs_.size(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 | 1745 |
| 1758 if (!have_preroll_buffer) | 1746 if (!have_preroll_buffer) |
| 1759 return false; | 1747 return false; |
| 1760 | 1748 |
| 1761 pending_buffer_.swap(*out_buffer); | 1749 pending_buffer_.swap(*out_buffer); |
| 1762 pending_buffers_complete_ = false; | 1750 pending_buffers_complete_ = false; |
| 1763 return true; | 1751 return true; |
| 1764 } | 1752 } |
| 1765 | 1753 |
| 1766 } // namespace media | 1754 } // namespace media |
| OLD | NEW |