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

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 621573002: Expose a seekable range at 0 for streaming sources with duration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@io
Patch Set: Created 6 years, 2 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 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 "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/callback_helpers.h" 14 #include "base/callback_helpers.h"
15 #include "base/debug/alias.h" 15 #include "base/debug/alias.h"
16 #include "base/debug/crash_logging.h" 16 #include "base/debug/crash_logging.h"
17 #include "base/debug/trace_event.h" 17 #include "base/debug/trace_event.h"
18 #include "base/float_util.h"
18 #include "base/message_loop/message_loop_proxy.h" 19 #include "base/message_loop/message_loop_proxy.h"
19 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
20 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
21 #include "base/synchronization/waitable_event.h" 22 #include "base/synchronization/waitable_event.h"
22 #include "cc/blink/web_layer_impl.h" 23 #include "cc/blink/web_layer_impl.h"
23 #include "cc/layers/video_layer.h" 24 #include "cc/layers/video_layer.h"
24 #include "gpu/GLES2/gl2extchromium.h" 25 #include "gpu/GLES2/gl2extchromium.h"
25 #include "gpu/command_buffer/common/mailbox_holder.h" 26 #include "gpu/command_buffer/common/mailbox_holder.h"
26 #include "media/audio/null_audio_sink.h" 27 #include "media/audio/null_audio_sink.h"
27 #include "media/base/audio_hardware_config.h" 28 #include "media/base/audio_hardware_config.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 486 }
486 487
487 blink::WebTimeRanges WebMediaPlayerImpl::seekable() const { 488 blink::WebTimeRanges WebMediaPlayerImpl::seekable() const {
488 DCHECK(main_task_runner_->BelongsToCurrentThread()); 489 DCHECK(main_task_runner_->BelongsToCurrentThread());
489 490
490 // If we haven't even gotten to ReadyStateHaveMetadata yet then there 491 // If we haven't even gotten to ReadyStateHaveMetadata yet then there
491 // are no seekable ranges. 492 // are no seekable ranges.
492 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) 493 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata)
493 return blink::WebTimeRanges(); 494 return blink::WebTimeRanges();
494 495
495 // We don't support seeking in streaming media. 496 // We don't support seeking in streaming media except for a seek to zero when
496 if (data_source_ && data_source_->IsStreaming()) 497 // the source has a known duration.
497 return blink::WebTimeRanges(); 498 double seekable_end = duration();
498 499 if (data_source_ && data_source_->IsStreaming()) {
philipj_slow 2014/10/01 09:37:50 Can you DCHECK(base::IsFinite(seekable_end) && see
DaleCurtis 2014/10/06 23:55:42 I've reworked this to look more like the android c
499 // If we have a duration then use [0, duration] as the seekable range. 500 if (!base::IsFinite(seekable_end))
500 const double seekable_end = duration(); 501 return blink::WebTimeRanges();
501 if (!seekable_end) 502 seekable_end = 0.0;
502 return blink::WebTimeRanges(); 503 }
503 504
504 blink::WebTimeRange seekable_range(0.0, seekable_end); 505 blink::WebTimeRange seekable_range(0.0, seekable_end);
505 return blink::WebTimeRanges(&seekable_range, 1); 506 return blink::WebTimeRanges(&seekable_range, 1);
506 } 507 }
507 508
508 bool WebMediaPlayerImpl::didLoadingProgress() { 509 bool WebMediaPlayerImpl::didLoadingProgress() {
509 DCHECK(main_task_runner_->BelongsToCurrentThread()); 510 DCHECK(main_task_runner_->BelongsToCurrentThread());
510 bool pipeline_progress = pipeline_.DidLoadingProgress(); 511 bool pipeline_progress = pipeline_.DidLoadingProgress();
511 bool data_progress = buffered_data_source_host_.DidLoadingProgress(); 512 bool data_progress = buffered_data_source_host_.DidLoadingProgress();
512 return pipeline_progress || data_progress; 513 return pipeline_progress || data_progress;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 compositor_task_runner_->PostTask(FROM_HERE, 1030 compositor_task_runner_->PostTask(FROM_HERE,
1030 base::Bind(&GetCurrentFrameAndSignal, 1031 base::Bind(&GetCurrentFrameAndSignal,
1031 base::Unretained(compositor_), 1032 base::Unretained(compositor_),
1032 &video_frame, 1033 &video_frame,
1033 &event)); 1034 &event));
1034 event.Wait(); 1035 event.Wait();
1035 return video_frame; 1036 return video_frame;
1036 } 1037 }
1037 1038
1038 } // namespace media 1039 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698