| 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 "media/renderers/video_renderer_impl.h" | 5 #include "media/renderers/video_renderer_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/time/default_tick_clock.h" | 15 #include "base/time/default_tick_clock.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "media/base/bind_to_current_loop.h" | 17 #include "media/base/bind_to_current_loop.h" |
| 18 #include "media/base/buffers.h" | 18 #include "media/base/buffers.h" |
| 19 #include "media/base/limits.h" | 19 #include "media/base/limits.h" |
| 20 #include "media/base/media_switches.h" | 20 #include "media/base/media_switches.h" |
| 21 #include "media/base/pipeline.h" | 21 #include "media/base/pipeline.h" |
| 22 #include "media/base/video_frame.h" |
| 23 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 24 #include "media/video/gpu_memory_buffer_video_frame_pool.h" |
| 22 | 25 |
| 23 namespace media { | 26 namespace media { |
| 24 | 27 |
| 25 // TODO(dalecurtis): This experiment is temporary and should be removed once we | 28 // TODO(dalecurtis): This experiment is temporary and should be removed once we |
| 26 // have enough data to support the primacy of the new video rendering path; see | 29 // have enough data to support the primacy of the new video rendering path; see |
| 27 // http://crbug.com/485699 for details. | 30 // http://crbug.com/485699 for details. |
| 28 static bool ShouldUseVideoRenderingPath() { | 31 static bool ShouldUseVideoRenderingPath() { |
| 29 // Note: It's important to query the field trial state first, to ensure that | 32 // Note: It's important to query the field trial state first, to ensure that |
| 30 // UMA reports the correct group. | 33 // UMA reports the correct group. |
| 31 const std::string group_name = | 34 const std::string group_name = |
| 32 base::FieldTrialList::FindFullName("NewVideoRendererTrial"); | 35 base::FieldTrialList::FindFullName("NewVideoRendererTrial"); |
| 33 const bool disabled_via_cli = | 36 const bool disabled_via_cli = |
| 34 base::CommandLine::ForCurrentProcess()->HasSwitch( | 37 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 35 switches::kDisableNewVideoRenderer); | 38 switches::kDisableNewVideoRenderer); |
| 36 return !disabled_via_cli && !StartsWithASCII(group_name, "Disabled", true); | 39 return !disabled_via_cli && !StartsWithASCII(group_name, "Disabled", true); |
| 37 } | 40 } |
| 38 | 41 |
| 39 VideoRendererImpl::VideoRendererImpl( | 42 VideoRendererImpl::VideoRendererImpl( |
| 40 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 43 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 41 VideoRendererSink* sink, | 44 VideoRendererSink* sink, |
| 42 ScopedVector<VideoDecoder> decoders, | 45 ScopedVector<VideoDecoder> decoders, |
| 43 bool drop_frames, | 46 bool drop_frames, |
| 47 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories, |
| 44 const scoped_refptr<MediaLog>& media_log) | 48 const scoped_refptr<MediaLog>& media_log) |
| 45 : task_runner_(task_runner), | 49 : task_runner_(task_runner), |
| 46 use_new_video_renderering_path_(ShouldUseVideoRenderingPath()), | 50 use_new_video_renderering_path_(ShouldUseVideoRenderingPath()), |
| 47 sink_(sink), | 51 sink_(sink), |
| 48 sink_started_(false), | 52 sink_started_(false), |
| 49 video_frame_stream_( | 53 video_frame_stream_( |
| 50 new VideoFrameStream(task_runner, decoders.Pass(), media_log)), | 54 new VideoFrameStream(task_runner, decoders.Pass(), media_log)), |
| 55 gpu_memory_buffer_pool_( |
| 56 new GpuMemoryBufferVideoFramePool(task_runner, gpu_factories)), |
| 51 low_delay_(false), | 57 low_delay_(false), |
| 52 received_end_of_stream_(false), | 58 received_end_of_stream_(false), |
| 53 rendered_end_of_stream_(false), | 59 rendered_end_of_stream_(false), |
| 54 frame_available_(&lock_), | 60 frame_available_(&lock_), |
| 55 state_(kUninitialized), | 61 state_(kUninitialized), |
| 56 thread_(), | 62 thread_(), |
| 57 pending_read_(false), | 63 pending_read_(false), |
| 58 drop_frames_(drop_frames), | 64 drop_frames_(drop_frames), |
| 59 buffering_state_(BUFFERING_HAVE_NOTHING), | 65 buffering_state_(BUFFERING_HAVE_NOTHING), |
| 60 frames_decoded_(0), | 66 frames_decoded_(0), |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 base::TimeTicks VideoRendererImpl::ConvertMediaTimestamp( | 743 base::TimeTicks VideoRendererImpl::ConvertMediaTimestamp( |
| 738 base::TimeDelta media_time) { | 744 base::TimeDelta media_time) { |
| 739 std::vector<base::TimeDelta> media_times(1, media_time); | 745 std::vector<base::TimeDelta> media_times(1, media_time); |
| 740 std::vector<base::TimeTicks> wall_clock_times; | 746 std::vector<base::TimeTicks> wall_clock_times; |
| 741 if (!wall_clock_time_cb_.Run(media_times, &wall_clock_times)) | 747 if (!wall_clock_time_cb_.Run(media_times, &wall_clock_times)) |
| 742 return base::TimeTicks(); | 748 return base::TimeTicks(); |
| 743 return wall_clock_times[0]; | 749 return wall_clock_times[0]; |
| 744 } | 750 } |
| 745 | 751 |
| 746 } // namespace media | 752 } // namespace media |
| OLD | NEW |