| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void MediaSourceDelegate::InitializeDemuxer() { | 182 void MediaSourceDelegate::InitializeDemuxer() { |
| 183 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 183 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| 184 demuxer_client_->AddDelegate(demuxer_client_id_, this); | 184 demuxer_client_->AddDelegate(demuxer_client_id_, this); |
| 185 chunk_demuxer_->Initialize(this, | 185 chunk_demuxer_->Initialize(this, |
| 186 base::Bind(&MediaSourceDelegate::OnDemuxerInitDone, | 186 base::Bind(&MediaSourceDelegate::OnDemuxerInitDone, |
| 187 media_weak_factory_.GetWeakPtr()), | 187 media_weak_factory_.GetWeakPtr()), |
| 188 false); | 188 false); |
| 189 } | 189 } |
| 190 | 190 |
| 191 blink::WebTimeRanges MediaSourceDelegate::Buffered() const { | 191 blink::WebTimeRanges MediaSourceDelegate::Buffered() const { |
| 192 return ConvertToWebTimeRanges(buffered_time_ranges_); | 192 return media::ConvertToWebTimeRanges(buffered_time_ranges_); |
| 193 } | 193 } |
| 194 | 194 |
| 195 size_t MediaSourceDelegate::DecodedFrameCount() const { | 195 size_t MediaSourceDelegate::DecodedFrameCount() const { |
| 196 return statistics_.video_frames_decoded; | 196 return statistics_.video_frames_decoded; |
| 197 } | 197 } |
| 198 | 198 |
| 199 size_t MediaSourceDelegate::DroppedFrameCount() const { | 199 size_t MediaSourceDelegate::DroppedFrameCount() const { |
| 200 return statistics_.video_frames_dropped; | 200 return statistics_.video_frames_dropped; |
| 201 } | 201 } |
| 202 | 202 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 | 655 |
| 656 base::TimeDelta MediaSourceDelegate::GetDuration() const { | 656 base::TimeDelta MediaSourceDelegate::GetDuration() const { |
| 657 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 657 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| 658 if (!chunk_demuxer_) | 658 if (!chunk_demuxer_) |
| 659 return media::kNoTimestamp(); | 659 return media::kNoTimestamp(); |
| 660 | 660 |
| 661 double duration = chunk_demuxer_->GetDuration(); | 661 double duration = chunk_demuxer_->GetDuration(); |
| 662 if (duration == std::numeric_limits<double>::infinity()) | 662 if (duration == std::numeric_limits<double>::infinity()) |
| 663 return media::kInfiniteDuration(); | 663 return media::kInfiniteDuration(); |
| 664 | 664 |
| 665 return ConvertSecondsToTimestamp(duration); | 665 return media::ConvertSecondsToTimestamp(duration); |
| 666 } | 666 } |
| 667 | 667 |
| 668 void MediaSourceDelegate::OnDemuxerOpened() { | 668 void MediaSourceDelegate::OnDemuxerOpened() { |
| 669 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 669 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 670 if (media_source_opened_cb_.is_null()) | 670 if (media_source_opened_cb_.is_null()) |
| 671 return; | 671 return; |
| 672 | 672 |
| 673 media_source_opened_cb_.Run(new WebMediaSourceImpl( | 673 media_source_opened_cb_.Run(new media::WebMediaSourceImpl( |
| 674 chunk_demuxer_.get(), base::Bind(&LogMediaSourceError, media_log_))); | 674 chunk_demuxer_.get(), base::Bind(&LogMediaSourceError, media_log_))); |
| 675 } | 675 } |
| 676 | 676 |
| 677 void MediaSourceDelegate::OnNeedKey(const std::string& type, | 677 void MediaSourceDelegate::OnNeedKey(const std::string& type, |
| 678 const std::vector<uint8>& init_data) { | 678 const std::vector<uint8>& init_data) { |
| 679 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 679 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 680 if (need_key_cb_.is_null()) | 680 if (need_key_cb_.is_null()) |
| 681 return; | 681 return; |
| 682 | 682 |
| 683 need_key_cb_.Run(type, init_data); | 683 need_key_cb_.Run(type, init_data); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 configs->video_size = config.natural_size(); | 751 configs->video_size = config.natural_size(); |
| 752 configs->is_video_encrypted = config.is_encrypted(); | 752 configs->is_video_encrypted = config.is_encrypted(); |
| 753 configs->video_extra_data = std::vector<uint8>( | 753 configs->video_extra_data = std::vector<uint8>( |
| 754 config.extra_data(), config.extra_data() + config.extra_data_size()); | 754 config.extra_data(), config.extra_data() + config.extra_data_size()); |
| 755 return true; | 755 return true; |
| 756 } | 756 } |
| 757 return false; | 757 return false; |
| 758 } | 758 } |
| 759 | 759 |
| 760 } // namespace content | 760 } // namespace content |
| OLD | NEW |