| 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 "content/renderer/media/android/media_source_delegate.h" | 5 #include "content/renderer/media/android/media_source_delegate.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "content/renderer/media/android/renderer_demuxer_android.h" | 13 #include "content/renderer/media/android/renderer_demuxer_android.h" |
| 14 #include "content/renderer/media/webmediaplayer_util.h" | |
| 15 #include "content/renderer/media/webmediasource_impl.h" | |
| 16 #include "media/base/android/demuxer_stream_player_params.h" | 14 #include "media/base/android/demuxer_stream_player_params.h" |
| 17 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
| 18 #include "media/base/demuxer_stream.h" | 16 #include "media/base/demuxer_stream.h" |
| 19 #include "media/base/media_log.h" | 17 #include "media/base/media_log.h" |
| 18 #include "media/blink/webmediaplayer_util.h" |
| 19 #include "media/blink/webmediasource_impl.h" |
| 20 #include "media/filters/chunk_demuxer.h" | 20 #include "media/filters/chunk_demuxer.h" |
| 21 #include "media/filters/decrypting_demuxer_stream.h" | 21 #include "media/filters/decrypting_demuxer_stream.h" |
| 22 #include "third_party/WebKit/public/platform/WebString.h" | 22 #include "third_party/WebKit/public/platform/WebString.h" |
| 23 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 23 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 24 | 24 |
| 25 using media::DemuxerStream; | 25 using media::DemuxerStream; |
| 26 using media::DemuxerConfigs; | 26 using media::DemuxerConfigs; |
| 27 using media::DemuxerData; | 27 using media::DemuxerData; |
| 28 using blink::WebMediaPlayer; | 28 using blink::WebMediaPlayer; |
| 29 using blink::WebString; | 29 using blink::WebString; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 void MediaSourceDelegate::InitializeDemuxer() { | 178 void MediaSourceDelegate::InitializeDemuxer() { |
| 179 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 179 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| 180 demuxer_client_->AddDelegate(demuxer_client_id_, this); | 180 demuxer_client_->AddDelegate(demuxer_client_id_, this); |
| 181 chunk_demuxer_->Initialize(this, | 181 chunk_demuxer_->Initialize(this, |
| 182 base::Bind(&MediaSourceDelegate::OnDemuxerInitDone, | 182 base::Bind(&MediaSourceDelegate::OnDemuxerInitDone, |
| 183 media_weak_factory_.GetWeakPtr()), | 183 media_weak_factory_.GetWeakPtr()), |
| 184 false); | 184 false); |
| 185 } | 185 } |
| 186 | 186 |
| 187 blink::WebTimeRanges MediaSourceDelegate::Buffered() const { | 187 blink::WebTimeRanges MediaSourceDelegate::Buffered() const { |
| 188 return ConvertToWebTimeRanges(buffered_time_ranges_); | 188 return media::ConvertToWebTimeRanges(buffered_time_ranges_); |
| 189 } | 189 } |
| 190 | 190 |
| 191 size_t MediaSourceDelegate::DecodedFrameCount() const { | 191 size_t MediaSourceDelegate::DecodedFrameCount() const { |
| 192 return statistics_.video_frames_decoded; | 192 return statistics_.video_frames_decoded; |
| 193 } | 193 } |
| 194 | 194 |
| 195 size_t MediaSourceDelegate::DroppedFrameCount() const { | 195 size_t MediaSourceDelegate::DroppedFrameCount() const { |
| 196 return statistics_.video_frames_dropped; | 196 return statistics_.video_frames_dropped; |
| 197 } | 197 } |
| 198 | 198 |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 660 |
| 661 base::TimeDelta MediaSourceDelegate::GetDuration() const { | 661 base::TimeDelta MediaSourceDelegate::GetDuration() const { |
| 662 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 662 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| 663 if (!chunk_demuxer_) | 663 if (!chunk_demuxer_) |
| 664 return media::kNoTimestamp(); | 664 return media::kNoTimestamp(); |
| 665 | 665 |
| 666 double duration = chunk_demuxer_->GetDuration(); | 666 double duration = chunk_demuxer_->GetDuration(); |
| 667 if (duration == std::numeric_limits<double>::infinity()) | 667 if (duration == std::numeric_limits<double>::infinity()) |
| 668 return media::kInfiniteDuration(); | 668 return media::kInfiniteDuration(); |
| 669 | 669 |
| 670 return ConvertSecondsToTimestamp(duration); | 670 return media::ConvertSecondsToTimestamp(duration); |
| 671 } | 671 } |
| 672 | 672 |
| 673 void MediaSourceDelegate::OnDemuxerOpened() { | 673 void MediaSourceDelegate::OnDemuxerOpened() { |
| 674 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 674 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 675 if (media_source_opened_cb_.is_null()) | 675 if (media_source_opened_cb_.is_null()) |
| 676 return; | 676 return; |
| 677 | 677 |
| 678 media_source_opened_cb_.Run(new WebMediaSourceImpl( | 678 media_source_opened_cb_.Run(new media::WebMediaSourceImpl( |
| 679 chunk_demuxer_.get(), base::Bind(&LogMediaSourceError, media_log_))); | 679 chunk_demuxer_.get(), base::Bind(&LogMediaSourceError, media_log_))); |
| 680 } | 680 } |
| 681 | 681 |
| 682 void MediaSourceDelegate::OnNeedKey(const std::string& type, | 682 void MediaSourceDelegate::OnNeedKey(const std::string& type, |
| 683 const std::vector<uint8>& init_data) { | 683 const std::vector<uint8>& init_data) { |
| 684 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 684 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 685 if (need_key_cb_.is_null()) | 685 if (need_key_cb_.is_null()) |
| 686 return; | 686 return; |
| 687 | 687 |
| 688 need_key_cb_.Run(type, init_data); | 688 need_key_cb_.Run(type, init_data); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 configs->video_size = config.natural_size(); | 756 configs->video_size = config.natural_size(); |
| 757 configs->is_video_encrypted = config.is_encrypted(); | 757 configs->is_video_encrypted = config.is_encrypted(); |
| 758 configs->video_extra_data = std::vector<uint8>( | 758 configs->video_extra_data = std::vector<uint8>( |
| 759 config.extra_data(), config.extra_data() + config.extra_data_size()); | 759 config.extra_data(), config.extra_data() + config.extra_data_size()); |
| 760 return true; | 760 return true; |
| 761 } | 761 } |
| 762 return false; | 762 return false; |
| 763 } | 763 } |
| 764 | 764 |
| 765 } // namespace content | 765 } // namespace content |
| OLD | NEW |