Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: media/base/android/media_source_player.cc

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 DCHECK(doing_browser_seek_); 352 DCHECK(doing_browser_seek_);
353 pending_seek_ = false; 353 pending_seek_ = false;
354 SeekTo(pending_seek_time_); 354 SeekTo(pending_seek_time_);
355 return; 355 return;
356 } 356 }
357 357
358 // It is possible that a browser seek to I-frame had to seek to a buffered 358 // It is possible that a browser seek to I-frame had to seek to a buffered
359 // I-frame later than the requested one due to data removal or GC. Update 359 // I-frame later than the requested one due to data removal or GC. Update
360 // player clock to the actual seek target. 360 // player clock to the actual seek target.
361 if (doing_browser_seek_) { 361 if (doing_browser_seek_) {
362 DCHECK(actual_browser_seek_time != kNoTimestamp()); 362 DCHECK(actual_browser_seek_time != kNoTimestamp);
363 base::TimeDelta seek_time = actual_browser_seek_time; 363 base::TimeDelta seek_time = actual_browser_seek_time;
364 // A browser seek must not jump into the past. Ideally, it seeks to the 364 // A browser seek must not jump into the past. Ideally, it seeks to the
365 // requested time, but it might jump into the future. 365 // requested time, but it might jump into the future.
366 DCHECK(seek_time >= GetCurrentTime()); 366 DCHECK(seek_time >= GetCurrentTime());
367 DVLOG(1) << __FUNCTION__ << " : setting clock to actual browser seek time: " 367 DVLOG(1) << __FUNCTION__ << " : setting clock to actual browser seek time: "
368 << seek_time.InSecondsF(); 368 << seek_time.InSecondsF();
369 interpolator_.SetBounds(seek_time, seek_time); 369 interpolator_.SetBounds(seek_time, seek_time);
370 audio_decoder_job_->SetBaseTimestamp(seek_time); 370 audio_decoder_job_->SetBaseTimestamp(seek_time);
371 } else { 371 } else {
372 DCHECK(actual_browser_seek_time == kNoTimestamp()); 372 DCHECK(actual_browser_seek_time == kNoTimestamp);
373 } 373 }
374 374
375 base::TimeDelta current_time = GetCurrentTime(); 375 base::TimeDelta current_time = GetCurrentTime();
376 // TODO(qinmin): Simplify the logic by using |start_presentation_timestamp_| 376 // TODO(qinmin): Simplify the logic by using |start_presentation_timestamp_|
377 // to preroll media decoder jobs. Currently |start_presentation_timestamp_| 377 // to preroll media decoder jobs. Currently |start_presentation_timestamp_|
378 // is calculated from decoder output, while preroll relies on the access 378 // is calculated from decoder output, while preroll relies on the access
379 // unit's timestamp. There are some differences between the two. 379 // unit's timestamp. There are some differences between the two.
380 preroll_timestamp_ = current_time; 380 preroll_timestamp_ = current_time;
381 if (HasAudio()) 381 if (HasAudio())
382 audio_decoder_job_->BeginPrerolling(preroll_timestamp_); 382 audio_decoder_job_->BeginPrerolling(preroll_timestamp_);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (status == MEDIA_CODEC_ERROR) { 501 if (status == MEDIA_CODEC_ERROR) {
502 DVLOG(1) << __FUNCTION__ << " : decode error"; 502 DVLOG(1) << __FUNCTION__ << " : decode error";
503 Release(); 503 Release();
504 manager()->OnError(player_id(), MEDIA_ERROR_DECODE); 504 manager()->OnError(player_id(), MEDIA_ERROR_DECODE);
505 if (is_clock_manager) 505 if (is_clock_manager)
506 media_stat_->StopAndReport(GetCurrentTime()); 506 media_stat_->StopAndReport(GetCurrentTime());
507 return; 507 return;
508 } 508 }
509 509
510 // Increment frame counts for UMA. 510 // Increment frame counts for UMA.
511 if (current_presentation_timestamp != kNoTimestamp()) { 511 if (current_presentation_timestamp != kNoTimestamp) {
512 FrameStatistics& frame_stats = is_audio ? media_stat_->audio_frame_stats() 512 FrameStatistics& frame_stats = is_audio ? media_stat_->audio_frame_stats()
513 : media_stat_->video_frame_stats(); 513 : media_stat_->video_frame_stats();
514 frame_stats.IncrementFrameCount(); 514 frame_stats.IncrementFrameCount();
515 if (is_late_frame) 515 if (is_late_frame)
516 frame_stats.IncrementLateFrameCount(); 516 frame_stats.IncrementLateFrameCount();
517 } 517 }
518 518
519 DCHECK(!IsEventPending(PREFETCH_DONE_EVENT_PENDING)); 519 DCHECK(!IsEventPending(PREFETCH_DONE_EVENT_PENDING));
520 520
521 // Let |SEEK_EVENT_PENDING| (the highest priority event outside of 521 // Let |SEEK_EVENT_PENDING| (the highest priority event outside of
522 // |PREFETCH_DONE_EVENT_PENDING|) preempt output EOS detection here. Process 522 // |PREFETCH_DONE_EVENT_PENDING|) preempt output EOS detection here. Process
523 // any other pending events only after handling EOS detection. 523 // any other pending events only after handling EOS detection.
524 if (IsEventPending(SEEK_EVENT_PENDING)) { 524 if (IsEventPending(SEEK_EVENT_PENDING)) {
525 ProcessPendingEvents(); 525 ProcessPendingEvents();
526 // In case of Seek GetCurrentTime() already tells the time to seek to. 526 // In case of Seek GetCurrentTime() already tells the time to seek to.
527 if (is_clock_manager && !doing_browser_seek_) 527 if (is_clock_manager && !doing_browser_seek_)
528 media_stat_->StopAndReport(current_presentation_timestamp); 528 media_stat_->StopAndReport(current_presentation_timestamp);
529 return; 529 return;
530 } 530 }
531 531
532 if ((status == MEDIA_CODEC_OK || status == MEDIA_CODEC_INPUT_END_OF_STREAM) && 532 if ((status == MEDIA_CODEC_OK || status == MEDIA_CODEC_INPUT_END_OF_STREAM) &&
533 is_clock_manager && current_presentation_timestamp != kNoTimestamp()) { 533 is_clock_manager && current_presentation_timestamp != kNoTimestamp) {
534 UpdateTimestamps(current_presentation_timestamp, 534 UpdateTimestamps(current_presentation_timestamp,
535 max_presentation_timestamp); 535 max_presentation_timestamp);
536 } 536 }
537 537
538 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) { 538 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) {
539 PlaybackCompleted(is_audio); 539 PlaybackCompleted(is_audio);
540 if (is_clock_manager) 540 if (is_clock_manager)
541 interpolator_.StopInterpolating(); 541 interpolator_.StopInterpolating();
542 } 542 }
543 543
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 prerolling_ = false; 596 prerolling_ = false;
597 StartInternal(); 597 StartInternal();
598 } 598 }
599 return; 599 return;
600 } 600 }
601 601
602 if (is_clock_manager) { 602 if (is_clock_manager) {
603 // If we have a valid timestamp, start the starvation callback. Otherwise, 603 // If we have a valid timestamp, start the starvation callback. Otherwise,
604 // reset the |start_time_ticks_| so that the next frame will not suffer 604 // reset the |start_time_ticks_| so that the next frame will not suffer
605 // from the decoding delay caused by the current frame. 605 // from the decoding delay caused by the current frame.
606 if (current_presentation_timestamp != kNoTimestamp()) 606 if (current_presentation_timestamp != kNoTimestamp)
607 StartStarvationCallback(current_presentation_timestamp, 607 StartStarvationCallback(current_presentation_timestamp,
608 max_presentation_timestamp); 608 max_presentation_timestamp);
609 else 609 else
610 start_time_ticks_ = base::TimeTicks::Now(); 610 start_time_ticks_ = base::TimeTicks::Now();
611 } 611 }
612 612
613 if (is_audio) 613 if (is_audio)
614 DecodeMoreAudio(); 614 DecodeMoreAudio();
615 else 615 else
616 DecodeMoreVideo(); 616 DecodeMoreVideo();
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 is_waiting_for_key_ = false; 857 is_waiting_for_key_ = false;
858 key_added_while_decode_pending_ = false; 858 key_added_while_decode_pending_ = false;
859 859
860 // StartInternal() will trigger a prefetch, where in most cases we'll just 860 // StartInternal() will trigger a prefetch, where in most cases we'll just
861 // use previously received data. 861 // use previously received data.
862 if (playing_) 862 if (playing_)
863 StartInternal(); 863 StartInternal();
864 } 864 }
865 865
866 } // namespace media 866 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698