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

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

Issue 1372203002: Throttle media decoding after excessive Android media server crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new infobar text per UI review Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_codec_video_decoder.h" 5 #include "media/base/android/media_codec_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/base/android/media_codec_bridge.h" 9 #include "media/base/android/media_codec_bridge.h"
10 #include "media/base/android/media_statistics.h" 10 #include "media/base/android/media_statistics.h"
11 #include "media/base/demuxer_stream.h" 11 #include "media/base/demuxer_stream.h"
12 #include "media/base/timestamp_constants.h" 12 #include "media/base/timestamp_constants.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 namespace { 16 namespace {
17 const int kDelayForStandAloneEOS = 2; // milliseconds 17 const int kDelayForStandAloneEOS = 2; // milliseconds
18 } 18 }
19 19
20 MediaCodecVideoDecoder::MediaCodecVideoDecoder( 20 MediaCodecVideoDecoder::MediaCodecVideoDecoder(
21 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, 21 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
22 FrameStatistics* frame_statistics, 22 FrameStatistics* frame_statistics,
23 const base::Closure& request_data_cb, 23 const base::Closure& request_data_cb,
24 const base::Closure& starvation_cb, 24 const base::Closure& starvation_cb,
25 const base::Closure& decoder_drained_cb, 25 const base::Closure& decoder_drained_cb,
26 const base::Closure& stop_done_cb, 26 const base::Closure& stop_done_cb,
27 const base::Closure& waiting_for_decryption_key_cb, 27 const base::Closure& waiting_for_decryption_key_cb,
28 const base::Closure& error_cb, 28 const base::Closure& error_cb,
29 const SetTimeCallback& update_current_time_cb, 29 const SetTimeCallback& update_current_time_cb,
30 const VideoSizeChangedCallback& video_size_changed_cb, 30 const VideoSizeChangedCallback& video_size_changed_cb)
31 const base::Closure& codec_created_cb)
32 : MediaCodecDecoder("VideoDecoder", 31 : MediaCodecDecoder("VideoDecoder",
33 media_task_runner, 32 media_task_runner,
34 frame_statistics, 33 frame_statistics,
35 request_data_cb, 34 request_data_cb,
36 starvation_cb, 35 starvation_cb,
37 decoder_drained_cb, 36 decoder_drained_cb,
38 stop_done_cb, 37 stop_done_cb,
39 waiting_for_decryption_key_cb, 38 waiting_for_decryption_key_cb,
40 error_cb), 39 error_cb),
41 is_protected_surface_required_(false), 40 is_protected_surface_required_(false),
42 update_current_time_cb_(update_current_time_cb), 41 update_current_time_cb_(update_current_time_cb),
43 video_size_changed_cb_(video_size_changed_cb), 42 video_size_changed_cb_(video_size_changed_cb) {
44 codec_created_cb_(codec_created_cb) {
45 } 43 }
46 44
47 MediaCodecVideoDecoder::~MediaCodecVideoDecoder() { 45 MediaCodecVideoDecoder::~MediaCodecVideoDecoder() {
48 DCHECK(media_task_runner_->BelongsToCurrentThread()); 46 DCHECK(media_task_runner_->BelongsToCurrentThread());
49 DVLOG(1) << "VideoDecoder::~VideoDecoder()"; 47 DVLOG(1) << "VideoDecoder::~VideoDecoder()";
50 ReleaseDecoderResources(); 48 ReleaseDecoderResources();
51 } 49 }
52 50
53 const char* MediaCodecVideoDecoder::class_name() const { 51 const char* MediaCodecVideoDecoder::class_name() const {
54 return "VideoDecoder"; 52 return "VideoDecoder";
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 media_crypto)); 178 media_crypto));
181 179
182 if (!media_codec_bridge_) { 180 if (!media_codec_bridge_) {
183 DVLOG(0) << class_name() << "::" << __FUNCTION__ 181 DVLOG(0) << class_name() << "::" << __FUNCTION__
184 << " failed: cannot create video codec"; 182 << " failed: cannot create video codec";
185 return kConfigFailure; 183 return kConfigFailure;
186 } 184 }
187 185
188 DVLOG(0) << class_name() << "::" << __FUNCTION__ << " succeeded"; 186 DVLOG(0) << class_name() << "::" << __FUNCTION__ << " succeeded";
189 187
190 media_task_runner_->PostTask(FROM_HERE, codec_created_cb_);
191
192 if (!codec_created_for_tests_cb_.is_null()) 188 if (!codec_created_for_tests_cb_.is_null())
193 media_task_runner_->PostTask(FROM_HERE, codec_created_for_tests_cb_); 189 media_task_runner_->PostTask(FROM_HERE, codec_created_for_tests_cb_);
194 190
195 return kConfigOk; 191 return kConfigOk;
196 } 192 }
197 193
198 void MediaCodecVideoDecoder::AssociateCurrentTimeWithPTS(base::TimeDelta pts) { 194 void MediaCodecVideoDecoder::AssociateCurrentTimeWithPTS(base::TimeDelta pts) {
199 DCHECK(media_task_runner_->BelongsToCurrentThread()); 195 DCHECK(media_task_runner_->BelongsToCurrentThread());
200 196
201 DVLOG(1) << class_name() << "::" << __FUNCTION__ << " pts:" << pts; 197 DVLOG(1) << class_name() << "::" << __FUNCTION__ << " pts:" << pts;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 349
354 // |update_current_time_cb_| might be null if there is audio stream. 350 // |update_current_time_cb_| might be null if there is audio stream.
355 // Do not update current time for stand-alone EOS frames. 351 // Do not update current time for stand-alone EOS frames.
356 if (!update_current_time_cb_.is_null() && update_time) { 352 if (!update_current_time_cb_.is_null() && update_time) {
357 media_task_runner_->PostTask( 353 media_task_runner_->PostTask(
358 FROM_HERE, base::Bind(update_current_time_cb_, pts, pts, false)); 354 FROM_HERE, base::Bind(update_current_time_cb_, pts, pts, false));
359 } 355 }
360 } 356 }
361 357
362 } // namespace media 358 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_codec_video_decoder.h ('k') | media/base/android/media_player_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698