| 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 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { | 1526 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { |
| 1527 DCHECK(!audio_configs_.empty()); | 1527 DCHECK(!audio_configs_.empty()); |
| 1528 DCHECK(video_configs_.empty()); | 1528 DCHECK(video_configs_.empty()); |
| 1529 DVLOG(3) << "UpdateAudioConfig."; | 1529 DVLOG(3) << "UpdateAudioConfig."; |
| 1530 | 1530 |
| 1531 if (audio_configs_[0].codec() != config.codec()) { | 1531 if (audio_configs_[0].codec() != config.codec()) { |
| 1532 MEDIA_LOG(ERROR, media_log_) << "Audio codec changes not allowed."; | 1532 MEDIA_LOG(ERROR, media_log_) << "Audio codec changes not allowed."; |
| 1533 return false; | 1533 return false; |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 if (!audio_configs_[0].encryption_scheme().Matches( | |
| 1537 config.encryption_scheme())) { | |
| 1538 MEDIA_LOG(ERROR, media_log_) << "Audio encryption changes not allowed."; | |
| 1539 return false; | |
| 1540 } | |
| 1541 | |
| 1542 // Check to see if the new config matches an existing one. | 1536 // Check to see if the new config matches an existing one. |
| 1543 for (size_t i = 0; i < audio_configs_.size(); ++i) { | 1537 for (size_t i = 0; i < audio_configs_.size(); ++i) { |
| 1544 if (config.Matches(audio_configs_[i])) { | 1538 if (config.Matches(audio_configs_[i])) { |
| 1545 append_config_index_ = i; | 1539 append_config_index_ = i; |
| 1546 return true; | 1540 return true; |
| 1547 } | 1541 } |
| 1548 } | 1542 } |
| 1549 | 1543 |
| 1550 // No matches found so let's add this one to the list. | 1544 // No matches found so let's add this one to the list. |
| 1551 append_config_index_ = audio_configs_.size(); | 1545 append_config_index_ = audio_configs_.size(); |
| 1552 DVLOG(2) << "New audio config - index: " << append_config_index_; | 1546 DVLOG(2) << "New audio config - index: " << append_config_index_; |
| 1553 audio_configs_.resize(audio_configs_.size() + 1); | 1547 audio_configs_.resize(audio_configs_.size() + 1); |
| 1554 audio_configs_[append_config_index_] = config; | 1548 audio_configs_[append_config_index_] = config; |
| 1555 return true; | 1549 return true; |
| 1556 } | 1550 } |
| 1557 | 1551 |
| 1558 bool SourceBufferStream::UpdateVideoConfig(const VideoDecoderConfig& config) { | 1552 bool SourceBufferStream::UpdateVideoConfig(const VideoDecoderConfig& config) { |
| 1559 DCHECK(!video_configs_.empty()); | 1553 DCHECK(!video_configs_.empty()); |
| 1560 DCHECK(audio_configs_.empty()); | 1554 DCHECK(audio_configs_.empty()); |
| 1561 DVLOG(3) << "UpdateVideoConfig."; | 1555 DVLOG(3) << "UpdateVideoConfig."; |
| 1562 | 1556 |
| 1563 if (video_configs_[0].codec() != config.codec()) { | 1557 if (video_configs_[0].codec() != config.codec()) { |
| 1564 MEDIA_LOG(ERROR, media_log_) << "Video codec changes not allowed."; | 1558 MEDIA_LOG(ERROR, media_log_) << "Video codec changes not allowed."; |
| 1565 return false; | 1559 return false; |
| 1566 } | 1560 } |
| 1567 | 1561 |
| 1568 if (!video_configs_[0].encryption_scheme().Matches( | |
| 1569 config.encryption_scheme())) { | |
| 1570 MEDIA_LOG(ERROR, media_log_) << "Video encryption changes not allowed."; | |
| 1571 return false; | |
| 1572 } | |
| 1573 | |
| 1574 // Check to see if the new config matches an existing one. | 1562 // Check to see if the new config matches an existing one. |
| 1575 for (size_t i = 0; i < video_configs_.size(); ++i) { | 1563 for (size_t i = 0; i < video_configs_.size(); ++i) { |
| 1576 if (config.Matches(video_configs_[i])) { | 1564 if (config.Matches(video_configs_[i])) { |
| 1577 append_config_index_ = i; | 1565 append_config_index_ = i; |
| 1578 return true; | 1566 return true; |
| 1579 } | 1567 } |
| 1580 } | 1568 } |
| 1581 | 1569 |
| 1582 // No matches found so let's add this one to the list. | 1570 // No matches found so let's add this one to the list. |
| 1583 append_config_index_ = video_configs_.size(); | 1571 append_config_index_ = video_configs_.size(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1745 | 1733 |
| 1746 if (!have_preroll_buffer) | 1734 if (!have_preroll_buffer) |
| 1747 return false; | 1735 return false; |
| 1748 | 1736 |
| 1749 pending_buffer_.swap(*out_buffer); | 1737 pending_buffer_.swap(*out_buffer); |
| 1750 pending_buffers_complete_ = false; | 1738 pending_buffers_complete_ = false; |
| 1751 return true; | 1739 return true; |
| 1752 } | 1740 } |
| 1753 | 1741 |
| 1754 } // namespace media | 1742 } // namespace media |
| OLD | NEW |