| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 #undef STATIC_ASSERT_MATCHING_ENUM | 96 #undef STATIC_ASSERT_MATCHING_ENUM |
| 97 | 97 |
| 98 #define BIND_TO_RENDER_LOOP(function) \ | 98 #define BIND_TO_RENDER_LOOP(function) \ |
| 99 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ | 99 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ |
| 100 BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) | 100 BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) |
| 101 | 101 |
| 102 #define BIND_TO_RENDER_LOOP1(function, arg1) \ | 102 #define BIND_TO_RENDER_LOOP1(function, arg1) \ |
| 103 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ | 103 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ |
| 104 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) | 104 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) |
| 105 | 105 |
| 106 static void AddLogEntry(const scoped_refptr<MediaLog>& media_log, |
| 107 MediaLog::MediaLogLevel level, |
| 108 const std::string& message) { |
| 109 media_log->AddEvent(media_log->CreateLogEvent(level, message)); |
| 110 } |
| 111 |
| 106 static blink::WebEncryptedMediaInitDataType ConvertInitDataType( | 112 static blink::WebEncryptedMediaInitDataType ConvertInitDataType( |
| 107 const std::string& init_data_type) { | 113 const std::string& init_data_type) { |
| 108 if (init_data_type == "cenc") | 114 if (init_data_type == "cenc") |
| 109 return blink::WebEncryptedMediaInitDataType::Cenc; | 115 return blink::WebEncryptedMediaInitDataType::Cenc; |
| 110 if (init_data_type == "keyids") | 116 if (init_data_type == "keyids") |
| 111 return blink::WebEncryptedMediaInitDataType::Keyids; | 117 return blink::WebEncryptedMediaInitDataType::Keyids; |
| 112 if (init_data_type == "webm") | 118 if (init_data_type == "webm") |
| 113 return blink::WebEncryptedMediaInitDataType::Webm; | 119 return blink::WebEncryptedMediaInitDataType::Webm; |
| 114 NOTREACHED() << "unexpected " << init_data_type; | 120 NOTREACHED() << "unexpected " << init_data_type; |
| 115 return blink::WebEncryptedMediaInitDataType::Unknown; | 121 return blink::WebEncryptedMediaInitDataType::Unknown; |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 data_source_->OnBufferingHaveEnough(); | 830 data_source_->OnBufferingHaveEnough(); |
| 825 | 831 |
| 826 // Blink expects a timeChanged() in response to a seek(). | 832 // Blink expects a timeChanged() in response to a seek(). |
| 827 if (should_notify_time_changed_) | 833 if (should_notify_time_changed_) |
| 828 client_->timeChanged(); | 834 client_->timeChanged(); |
| 829 } | 835 } |
| 830 | 836 |
| 831 void WebMediaPlayerImpl::OnDemuxerOpened() { | 837 void WebMediaPlayerImpl::OnDemuxerOpened() { |
| 832 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 838 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 833 client_->mediaSourceOpened(new WebMediaSourceImpl( | 839 client_->mediaSourceOpened(new WebMediaSourceImpl( |
| 834 chunk_demuxer_, base::Bind(&MediaLog::AddLogEvent, media_log_))); | 840 chunk_demuxer_, base::Bind(&AddLogEntry, media_log_))); |
| 835 } | 841 } |
| 836 | 842 |
| 837 void WebMediaPlayerImpl::OnAddTextTrack( | 843 void WebMediaPlayerImpl::OnAddTextTrack( |
| 838 const TextTrackConfig& config, | 844 const TextTrackConfig& config, |
| 839 const AddTextTrackDoneCB& done_cb) { | 845 const AddTextTrackDoneCB& done_cb) { |
| 840 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 846 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 841 | 847 |
| 842 const WebInbandTextTrackImpl::Kind web_kind = | 848 const WebInbandTextTrackImpl::Kind web_kind = |
| 843 static_cast<WebInbandTextTrackImpl::Kind>(config.kind()); | 849 static_cast<WebInbandTextTrackImpl::Kind>(config.kind()); |
| 844 const blink::WebString web_label = | 850 const blink::WebString web_label = |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 if (load_type_ != LoadTypeMediaSource) { | 900 if (load_type_ != LoadTypeMediaSource) { |
| 895 DCHECK(!chunk_demuxer_); | 901 DCHECK(!chunk_demuxer_); |
| 896 DCHECK(data_source_); | 902 DCHECK(data_source_); |
| 897 | 903 |
| 898 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), | 904 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), |
| 899 encrypted_media_init_data_cb, media_log_)); | 905 encrypted_media_init_data_cb, media_log_)); |
| 900 } else { | 906 } else { |
| 901 DCHECK(!chunk_demuxer_); | 907 DCHECK(!chunk_demuxer_); |
| 902 DCHECK(!data_source_); | 908 DCHECK(!data_source_); |
| 903 | 909 |
| 904 mse_log_cb = base::Bind(&MediaLog::AddLogEvent, media_log_); | 910 mse_log_cb = base::Bind(&AddLogEntry, media_log_); |
| 905 | 911 |
| 906 chunk_demuxer_ = new ChunkDemuxer( | 912 chunk_demuxer_ = new ChunkDemuxer( |
| 907 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), | 913 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), |
| 908 encrypted_media_init_data_cb, mse_log_cb, media_log_, true); | 914 encrypted_media_init_data_cb, mse_log_cb, media_log_, true); |
| 909 demuxer_.reset(chunk_demuxer_); | 915 demuxer_.reset(chunk_demuxer_); |
| 910 } | 916 } |
| 911 | 917 |
| 912 // ... and we're ready to go! | 918 // ... and we're ready to go! |
| 913 seeking_ = true; | 919 seeking_ = true; |
| 914 | 920 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 | 1040 |
| 1035 // pause() may be called after playback has ended and the HTMLMediaElement | 1041 // pause() may be called after playback has ended and the HTMLMediaElement |
| 1036 // requires that currentTime() == duration() after ending. We want to ensure | 1042 // requires that currentTime() == duration() after ending. We want to ensure |
| 1037 // |paused_time_| matches currentTime() in this case or a future seek() may | 1043 // |paused_time_| matches currentTime() in this case or a future seek() may |
| 1038 // incorrectly discard what it thinks is a seek to the existing time. | 1044 // incorrectly discard what it thinks is a seek to the existing time. |
| 1039 paused_time_ = | 1045 paused_time_ = |
| 1040 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 1046 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); |
| 1041 } | 1047 } |
| 1042 | 1048 |
| 1043 } // namespace media | 1049 } // namespace media |
| OLD | NEW |