| 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 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { | 1573 bool SourceBufferStream::UpdateAudioConfig(const AudioDecoderConfig& config) { |
| 1574 DCHECK(!audio_configs_.empty()); | 1574 DCHECK(!audio_configs_.empty()); |
| 1575 DCHECK(video_configs_.empty()); | 1575 DCHECK(video_configs_.empty()); |
| 1576 DVLOG(3) << "UpdateAudioConfig."; | 1576 DVLOG(3) << "UpdateAudioConfig."; |
| 1577 | 1577 |
| 1578 if (audio_configs_[0].codec() != config.codec()) { | 1578 if (audio_configs_[0].codec() != config.codec()) { |
| 1579 MEDIA_LOG(ERROR, media_log_) << "Audio codec changes not allowed."; | 1579 MEDIA_LOG(ERROR, media_log_) << "Audio codec changes not allowed."; |
| 1580 return false; | 1580 return false; |
| 1581 } | 1581 } |
| 1582 | 1582 |
| 1583 if (!audio_configs_[0].encryption_scheme().Matches( | |
| 1584 config.encryption_scheme())) { | |
| 1585 MEDIA_LOG(ERROR, media_log_) << "Audio encryption changes not allowed."; | |
| 1586 return false; | |
| 1587 } | |
| 1588 | |
| 1589 // Check to see if the new config matches an existing one. | 1583 // Check to see if the new config matches an existing one. |
| 1590 for (size_t i = 0; i < audio_configs_.size(); ++i) { | 1584 for (size_t i = 0; i < audio_configs_.size(); ++i) { |
| 1591 if (config.Matches(audio_configs_[i])) { | 1585 if (config.Matches(audio_configs_[i])) { |
| 1592 append_config_index_ = i; | 1586 append_config_index_ = i; |
| 1593 return true; | 1587 return true; |
| 1594 } | 1588 } |
| 1595 } | 1589 } |
| 1596 | 1590 |
| 1597 // No matches found so let's add this one to the list. | 1591 // No matches found so let's add this one to the list. |
| 1598 append_config_index_ = audio_configs_.size(); | 1592 append_config_index_ = audio_configs_.size(); |
| 1599 DVLOG(2) << "New audio config - index: " << append_config_index_; | 1593 DVLOG(2) << "New audio config - index: " << append_config_index_; |
| 1600 audio_configs_.resize(audio_configs_.size() + 1); | 1594 audio_configs_.resize(audio_configs_.size() + 1); |
| 1601 audio_configs_[append_config_index_] = config; | 1595 audio_configs_[append_config_index_] = config; |
| 1602 return true; | 1596 return true; |
| 1603 } | 1597 } |
| 1604 | 1598 |
| 1605 bool SourceBufferStream::UpdateVideoConfig(const VideoDecoderConfig& config) { | 1599 bool SourceBufferStream::UpdateVideoConfig(const VideoDecoderConfig& config) { |
| 1606 DCHECK(!video_configs_.empty()); | 1600 DCHECK(!video_configs_.empty()); |
| 1607 DCHECK(audio_configs_.empty()); | 1601 DCHECK(audio_configs_.empty()); |
| 1608 DVLOG(3) << "UpdateVideoConfig."; | 1602 DVLOG(3) << "UpdateVideoConfig."; |
| 1609 | 1603 |
| 1610 if (video_configs_[0].codec() != config.codec()) { | 1604 if (video_configs_[0].codec() != config.codec()) { |
| 1611 MEDIA_LOG(ERROR, media_log_) << "Video codec changes not allowed."; | 1605 MEDIA_LOG(ERROR, media_log_) << "Video codec changes not allowed."; |
| 1612 return false; | 1606 return false; |
| 1613 } | 1607 } |
| 1614 | 1608 |
| 1615 if (!video_configs_[0].encryption_scheme().Matches( | |
| 1616 config.encryption_scheme())) { | |
| 1617 MEDIA_LOG(ERROR, media_log_) << "Video encryption changes not allowed."; | |
| 1618 return false; | |
| 1619 } | |
| 1620 | |
| 1621 // Check to see if the new config matches an existing one. | 1609 // Check to see if the new config matches an existing one. |
| 1622 for (size_t i = 0; i < video_configs_.size(); ++i) { | 1610 for (size_t i = 0; i < video_configs_.size(); ++i) { |
| 1623 if (config.Matches(video_configs_[i])) { | 1611 if (config.Matches(video_configs_[i])) { |
| 1624 append_config_index_ = i; | 1612 append_config_index_ = i; |
| 1625 return true; | 1613 return true; |
| 1626 } | 1614 } |
| 1627 } | 1615 } |
| 1628 | 1616 |
| 1629 // No matches found so let's add this one to the list. | 1617 // No matches found so let's add this one to the list. |
| 1630 append_config_index_ = video_configs_.size(); | 1618 append_config_index_ = video_configs_.size(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1792 | 1780 |
| 1793 if (!have_preroll_buffer) | 1781 if (!have_preroll_buffer) |
| 1794 return false; | 1782 return false; |
| 1795 | 1783 |
| 1796 pending_buffer_.swap(*out_buffer); | 1784 pending_buffer_.swap(*out_buffer); |
| 1797 pending_buffers_complete_ = false; | 1785 pending_buffers_complete_ = false; |
| 1798 return true; | 1786 return true; |
| 1799 } | 1787 } |
| 1800 | 1788 |
| 1801 } // namespace media | 1789 } // namespace media |
| OLD | NEW |