Chromium Code Reviews| 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 |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 config.extra_data(), config.extra_data() + config.extra_data_size()); | 670 config.extra_data(), config.extra_data() + config.extra_data_size()); |
| 671 } | 671 } |
| 672 if (video_stream_) { | 672 if (video_stream_) { |
| 673 media::VideoDecoderConfig config = video_stream_->video_decoder_config(); | 673 media::VideoDecoderConfig config = video_stream_->video_decoder_config(); |
| 674 configs->video_codec = config.codec(); | 674 configs->video_codec = config.codec(); |
| 675 configs->video_size = config.natural_size(); | 675 configs->video_size = config.natural_size(); |
| 676 configs->is_video_encrypted = config.is_encrypted(); | 676 configs->is_video_encrypted = config.is_encrypted(); |
| 677 configs->video_extra_data = std::vector<uint8>( | 677 configs->video_extra_data = std::vector<uint8>( |
| 678 config.extra_data(), config.extra_data() + config.extra_data_size()); | 678 config.extra_data(), config.extra_data() + config.extra_data_size()); |
| 679 } | 679 } |
| 680 configs->duration_ms = GetDurationMs(); | 680 configs->duration = GetDuration(); |
| 681 | 681 |
| 682 if (demuxer_client_) | 682 if (demuxer_client_) |
| 683 demuxer_client_->DemuxerReady(demuxer_client_id_, *configs); | 683 demuxer_client_->DemuxerReady(demuxer_client_id_, *configs); |
| 684 | 684 |
| 685 base::AutoLock auto_lock(is_video_encrypted_lock_); | 685 base::AutoLock auto_lock(is_video_encrypted_lock_); |
| 686 is_video_encrypted_ = configs->is_video_encrypted; | 686 is_video_encrypted_ = configs->is_video_encrypted; |
| 687 } | 687 } |
| 688 | 688 |
| 689 int MediaSourceDelegate::GetDurationMs() { | 689 base::TimeDelta MediaSourceDelegate::GetDuration() { |
| 690 DCHECK(media_loop_->BelongsToCurrentThread()); | 690 DCHECK(media_loop_->BelongsToCurrentThread()); |
| 691 if (!chunk_demuxer_) | 691 if (!chunk_demuxer_) |
| 692 return -1; | 692 return media::kNoTimestamp(); |
| 693 | 693 |
| 694 double duration_ms = chunk_demuxer_->GetDuration() * 1000; | 694 double duration_seconds = chunk_demuxer_->GetDuration(); |
| 695 if (duration_ms > std::numeric_limits<int32>::max()) { | 695 if (duration_seconds == std::numeric_limits<double>::infinity()) { |
| 696 LOG(WARNING) << "Duration from ChunkDemuxer is too large; probably " | 696 return media::kInfiniteDuration(); |
| 697 "something has gone wrong."; | |
| 698 return std::numeric_limits<int32>::max(); | |
| 699 } | 697 } |
| 700 return duration_ms; | 698 |
| 699 return base::TimeDelta::FromSeconds(duration_seconds); | |
|
damienv1
2014/04/16 21:57:52
By doing that you have only a "1 second" accuracy
gunsch
2014/04/16 22:01:05
Good catch, I missed the int cast. Fixed.
| |
| 701 } | 700 } |
| 702 | 701 |
| 703 void MediaSourceDelegate::OnDemuxerOpened() { | 702 void MediaSourceDelegate::OnDemuxerOpened() { |
| 704 DCHECK(main_loop_->BelongsToCurrentThread()); | 703 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 705 if (media_source_opened_cb_.is_null()) | 704 if (media_source_opened_cb_.is_null()) |
| 706 return; | 705 return; |
| 707 | 706 |
| 708 media_source_opened_cb_.Run(new WebMediaSourceImpl( | 707 media_source_opened_cb_.Run(new WebMediaSourceImpl( |
| 709 chunk_demuxer_.get(), base::Bind(&LogMediaSourceError, media_log_))); | 708 chunk_demuxer_.get(), base::Bind(&LogMediaSourceError, media_log_))); |
| 710 } | 709 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 // current time have been garbage collected or removed by the web app, this is | 757 // current time have been garbage collected or removed by the web app, this is |
| 759 // unlikely. This may cause unexpected playback stall due to seek pending an | 758 // unlikely. This may cause unexpected playback stall due to seek pending an |
| 760 // append for a GOP prior to the last GOP demuxed. | 759 // append for a GOP prior to the last GOP demuxed. |
| 761 // TODO(wolenetz): Remove the possibility for this seek to cause unexpected | 760 // TODO(wolenetz): Remove the possibility for this seek to cause unexpected |
| 762 // player stall by replaying cached data since last keyframe in browser player | 761 // player stall by replaying cached data since last keyframe in browser player |
| 763 // rather than issuing browser seek. See http://crbug.com/304234. | 762 // rather than issuing browser seek. See http://crbug.com/304234. |
| 764 return seek_time; | 763 return seek_time; |
| 765 } | 764 } |
| 766 | 765 |
| 767 } // namespace content | 766 } // namespace content |
| OLD | NEW |