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/base/android/video_decoder_job.h" | 5 #include "media/base/android/video_decoder_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "media/base/android/media_codec_bridge.h" | 10 #include "media/base/android/media_codec_bridge.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // TODO(qinmin): Check if it is tolerable to use worker pool to handle all the | 22 // TODO(qinmin): Check if it is tolerable to use worker pool to handle all the |
23 // decoding tasks so that we don't need a global thread here. | 23 // decoding tasks so that we don't need a global thread here. |
24 // http://crbug.com/245750 | 24 // http://crbug.com/245750 |
25 base::LazyInstance<VideoDecoderThread>::Leaky | 25 base::LazyInstance<VideoDecoderThread>::Leaky |
26 g_video_decoder_thread = LAZY_INSTANCE_INITIALIZER; | 26 g_video_decoder_thread = LAZY_INSTANCE_INITIALIZER; |
27 | 27 |
28 VideoDecoderJob::VideoDecoderJob( | 28 VideoDecoderJob::VideoDecoderJob( |
29 const base::Closure& request_data_cb, | 29 const base::Closure& request_data_cb, |
30 const base::Closure& request_resources_cb, | 30 const base::Closure& request_resources_cb, |
31 const base::Closure& release_resources_cb, | |
32 const base::Closure& on_demuxer_config_changed_cb) | 31 const base::Closure& on_demuxer_config_changed_cb) |
33 : MediaDecoderJob(g_video_decoder_thread.Pointer()->message_loop_proxy(), | 32 : MediaDecoderJob(g_video_decoder_thread.Pointer()->message_loop_proxy(), |
34 request_data_cb, | 33 request_data_cb, |
35 on_demuxer_config_changed_cb), | 34 on_demuxer_config_changed_cb), |
36 video_codec_(kUnknownVideoCodec), | 35 video_codec_(kUnknownVideoCodec), |
37 width_(0), | 36 width_(0), |
38 height_(0), | 37 height_(0), |
39 request_resources_cb_(request_resources_cb), | 38 request_resources_cb_(request_resources_cb), |
40 release_resources_cb_(release_resources_cb), | |
41 next_video_data_is_iframe_(true) { | 39 next_video_data_is_iframe_(true) { |
42 } | 40 } |
43 | 41 |
44 VideoDecoderJob::~VideoDecoderJob() {} | 42 VideoDecoderJob::~VideoDecoderJob() {} |
45 | 43 |
46 bool VideoDecoderJob::SetVideoSurface(gfx::ScopedJavaSurface surface) { | 44 bool VideoDecoderJob::SetVideoSurface(gfx::ScopedJavaSurface surface) { |
47 // For an empty surface, always pass it to the |media_codec_bridge_| job so | 45 // For an empty surface, always pass it to the |media_codec_bridge_| job so |
48 // that it can detach from the current one. Otherwise, don't pass an | 46 // that it can detach from the current one. Otherwise, don't pass an |
49 // unprotected surface if the video content requires a protected one. | 47 // unprotected surface if the video content requires a protected one. |
50 if (!surface.IsEmpty() && IsProtectedSurfaceRequired() && | 48 if (!surface.IsEmpty() && IsProtectedSurfaceRequired() && |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 return false; | 140 return false; |
143 | 141 |
144 request_resources_cb_.Run(); | 142 request_resources_cb_.Run(); |
145 return true; | 143 return true; |
146 } | 144 } |
147 | 145 |
148 void VideoDecoderJob::CurrentDataConsumed(bool is_config_change) { | 146 void VideoDecoderJob::CurrentDataConsumed(bool is_config_change) { |
149 next_video_data_is_iframe_ = is_config_change; | 147 next_video_data_is_iframe_ = is_config_change; |
150 } | 148 } |
151 | 149 |
152 void VideoDecoderJob::OnMediaCodecBridgeReleased() { | |
153 release_resources_cb_.Run(); | |
154 } | |
155 | |
156 bool VideoDecoderJob::IsProtectedSurfaceRequired() { | 150 bool VideoDecoderJob::IsProtectedSurfaceRequired() { |
157 return is_content_encrypted() && drm_bridge() && | 151 return is_content_encrypted() && drm_bridge() && |
158 drm_bridge()->IsProtectedSurfaceRequired(); | 152 drm_bridge()->IsProtectedSurfaceRequired(); |
159 } | 153 } |
160 | 154 |
161 } // namespace media | 155 } // namespace media |
OLD | NEW |