| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/base/android/media_source_player.h" | 5 #include "media/base/android/media_source_player.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } | 496 } |
| 497 | 497 |
| 498 DCHECK(!IsEventPending(PREFETCH_DONE_EVENT_PENDING)); | 498 DCHECK(!IsEventPending(PREFETCH_DONE_EVENT_PENDING)); |
| 499 | 499 |
| 500 // Let |SEEK_EVENT_PENDING| (the highest priority event outside of | 500 // Let |SEEK_EVENT_PENDING| (the highest priority event outside of |
| 501 // |PREFETCH_DONE_EVENT_PENDING|) preempt output EOS detection here. Process | 501 // |PREFETCH_DONE_EVENT_PENDING|) preempt output EOS detection here. Process |
| 502 // any other pending events only after handling EOS detection. | 502 // any other pending events only after handling EOS detection. |
| 503 if (IsEventPending(SEEK_EVENT_PENDING)) { | 503 if (IsEventPending(SEEK_EVENT_PENDING)) { |
| 504 ProcessPendingEvents(); | 504 ProcessPendingEvents(); |
| 505 // In case of Seek GetCurrentTime() already tells the time to seek to. | 505 // In case of Seek GetCurrentTime() already tells the time to seek to. |
| 506 if (is_clock_manager) | 506 if (is_clock_manager && !doing_browser_seek_) |
| 507 media_stat_->StopAndReport(current_presentation_timestamp); | 507 media_stat_->StopAndReport(current_presentation_timestamp); |
| 508 return; | 508 return; |
| 509 } | 509 } |
| 510 | 510 |
| 511 if ((status == MEDIA_CODEC_OK || status == MEDIA_CODEC_INPUT_END_OF_STREAM) && | 511 if ((status == MEDIA_CODEC_OK || status == MEDIA_CODEC_INPUT_END_OF_STREAM) && |
| 512 is_clock_manager && current_presentation_timestamp != kNoTimestamp()) { | 512 is_clock_manager && current_presentation_timestamp != kNoTimestamp()) { |
| 513 UpdateTimestamps(current_presentation_timestamp, | 513 UpdateTimestamps(current_presentation_timestamp, |
| 514 max_presentation_timestamp); | 514 max_presentation_timestamp); |
| 515 } | 515 } |
| 516 | 516 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 // we don't really have a new key. This should rarely happen and the | 560 // we don't really have a new key. This should rarely happen and the |
| 561 // performance impact should be pretty small. | 561 // performance impact should be pretty small. |
| 562 // TODO(qinmin/xhwang): This class is complicated because we handle both audio | 562 // TODO(qinmin/xhwang): This class is complicated because we handle both audio |
| 563 // and video in one file. If we separate them, we should be able to remove a | 563 // and video in one file. If we separate them, we should be able to remove a |
| 564 // lot of duplication. | 564 // lot of duplication. |
| 565 | 565 |
| 566 // If the status is MEDIA_CODEC_ABORT, stop decoding new data. The player is | 566 // If the status is MEDIA_CODEC_ABORT, stop decoding new data. The player is |
| 567 // in the middle of a seek or stop event and needs to wait for the IPCs to | 567 // in the middle of a seek or stop event and needs to wait for the IPCs to |
| 568 // come. | 568 // come. |
| 569 if (status == MEDIA_CODEC_ABORT) { | 569 if (status == MEDIA_CODEC_ABORT) { |
| 570 if (is_clock_manager) | |
| 571 media_stat_->StopAndReport(GetCurrentTime()); | |
| 572 return; | 570 return; |
| 573 } | 571 } |
| 574 | 572 |
| 575 if (prerolling_ && IsPrerollFinished(is_audio)) { | 573 if (prerolling_ && IsPrerollFinished(is_audio)) { |
| 576 if (IsPrerollFinished(!is_audio)) { | 574 if (IsPrerollFinished(!is_audio)) { |
| 577 prerolling_ = false; | 575 prerolling_ = false; |
| 578 StartInternal(); | 576 StartInternal(); |
| 579 } | 577 } |
| 580 return; | 578 return; |
| 581 } | 579 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 } | 751 } |
| 754 | 752 |
| 755 if (!playing_) | 753 if (!playing_) |
| 756 return; | 754 return; |
| 757 | 755 |
| 758 start_time_ticks_ = base::TimeTicks::Now(); | 756 start_time_ticks_ = base::TimeTicks::Now(); |
| 759 start_presentation_timestamp_ = GetCurrentTime(); | 757 start_presentation_timestamp_ = GetCurrentTime(); |
| 760 if (!interpolator_.interpolating()) | 758 if (!interpolator_.interpolating()) |
| 761 interpolator_.StartInterpolating(); | 759 interpolator_.StartInterpolating(); |
| 762 | 760 |
| 763 media_stat_->Start(start_presentation_timestamp_); | 761 if (!AudioFinished() || !VideoFinished()) |
| 762 media_stat_->Start(start_presentation_timestamp_); |
| 764 | 763 |
| 765 if (!AudioFinished()) | 764 if (!AudioFinished()) |
| 766 DecodeMoreAudio(); | 765 DecodeMoreAudio(); |
| 767 | 766 |
| 768 if (!VideoFinished()) | 767 if (!VideoFinished()) |
| 769 DecodeMoreVideo(); | 768 DecodeMoreVideo(); |
| 770 } | 769 } |
| 771 | 770 |
| 772 void MediaSourcePlayer::OnDemuxerConfigsChanged() { | 771 void MediaSourcePlayer::OnDemuxerConfigsChanged() { |
| 773 manager()->OnMediaMetadataChanged( | 772 manager()->OnMediaMetadataChanged( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 is_waiting_for_key_ = false; | 844 is_waiting_for_key_ = false; |
| 846 key_added_while_decode_pending_ = false; | 845 key_added_while_decode_pending_ = false; |
| 847 | 846 |
| 848 // StartInternal() will trigger a prefetch, where in most cases we'll just | 847 // StartInternal() will trigger a prefetch, where in most cases we'll just |
| 849 // use previously received data. | 848 // use previously received data. |
| 850 if (playing_) | 849 if (playing_) |
| 851 StartInternal(); | 850 StartInternal(); |
| 852 } | 851 } |
| 853 | 852 |
| 854 } // namespace media | 853 } // namespace media |
| OLD | NEW |