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