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

Side by Side Diff: media/gpu/android_video_decode_accelerator.cc

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix several more bot-identified build issues Created 4 years, 8 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 "content/common/gpu/media/android_video_decode_accelerator.h" 5 #include "media/gpu/android_video_decode_accelerator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/task_runner_util.h" 18 #include "base/task_runner_util.h"
19 #include "base/trace_event/trace_event.h" 19 #include "base/trace_event/trace_event.h"
20 #include "content/common/gpu/media/android_copying_backing_strategy.h"
21 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h "
22 #include "content/common/gpu/media/avda_return_on_failure.h"
23 #include "content/common/gpu/media/shared_memory_region.h"
24 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 20 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
25 #include "gpu/command_buffer/service/mailbox_manager.h" 21 #include "gpu/command_buffer/service/mailbox_manager.h"
26 #include "gpu/ipc/service/gpu_channel.h" 22 #include "gpu/ipc/service/gpu_channel.h"
27 #include "media/base/android/media_codec_bridge.h" 23 #include "media/base/android/media_codec_bridge.h"
28 #include "media/base/android/media_codec_util.h" 24 #include "media/base/android/media_codec_util.h"
29 #include "media/base/bind_to_current_loop.h" 25 #include "media/base/bind_to_current_loop.h"
30 #include "media/base/bitstream_buffer.h" 26 #include "media/base/bitstream_buffer.h"
31 #include "media/base/limits.h" 27 #include "media/base/limits.h"
32 #include "media/base/media.h" 28 #include "media/base/media.h"
33 #include "media/base/timestamp_constants.h" 29 #include "media/base/timestamp_constants.h"
34 #include "media/base/video_decoder_config.h" 30 #include "media/base/video_decoder_config.h"
31 #include "media/gpu/android_copying_backing_strategy.h"
32 #include "media/gpu/android_deferred_rendering_backing_strategy.h"
33 #include "media/gpu/avda_return_on_failure.h"
34 #include "media/gpu/shared_memory_region.h"
35 #include "media/video/picture.h" 35 #include "media/video/picture.h"
36 #include "ui/gl/android/scoped_java_surface.h" 36 #include "ui/gl/android/scoped_java_surface.h"
37 #include "ui/gl/android/surface_texture.h" 37 #include "ui/gl/android/surface_texture.h"
38 #include "ui/gl/gl_bindings.h" 38 #include "ui/gl/gl_bindings.h"
39 39
40 #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) 40 #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
41 #include "media/mojo/services/mojo_cdm_service.h" 41 #include "media/mojo/services/mojo_cdm_service.h"
42 #endif 42 #endif
43 43
44 #define POST_ERROR(error_code, error_message) \ 44 #define POST_ERROR(error_code, error_message) \
45 do { \ 45 do { \
46 DLOG(ERROR) << error_message; \ 46 DLOG(ERROR) << error_message; \
47 PostError(FROM_HERE, media::VideoDecodeAccelerator::error_code); \ 47 PostError(FROM_HERE, media::VideoDecodeAccelerator::error_code); \
48 } while (0) 48 } while (0)
49 49
50 namespace content { 50 namespace media {
51 51
52 enum { kNumPictureBuffers = media::limits::kMaxVideoFrames + 1 }; 52 enum { kNumPictureBuffers = media::limits::kMaxVideoFrames + 1 };
53 53
54 // Max number of bitstreams notified to the client with 54 // Max number of bitstreams notified to the client with
55 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. 55 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream.
56 enum { kMaxBitstreamsNotifiedInAdvance = 32 }; 56 enum { kMaxBitstreamsNotifiedInAdvance = 32 };
57 57
58 // MediaCodec is only guaranteed to support baseline, but some devices may 58 // MediaCodec is only guaranteed to support baseline, but some devices may
59 // support others. Advertise support for all H264 profiles and let the 59 // support others. Advertise support for all H264 profiles and let the
60 // MediaCodec fail when decoding if it's not actually supported. It's assumed 60 // MediaCodec fail when decoding if it's not actually supported. It's assumed
61 // that consumers won't have software fallback for H264 on Android anyway. 61 // that consumers won't have software fallback for H264 on Android anyway.
62 static const media::VideoCodecProfile kSupportedH264Profiles[] = { 62 static const media::VideoCodecProfile kSupportedH264Profiles[] = {
63 media::H264PROFILE_BASELINE, 63 media::H264PROFILE_BASELINE,
64 media::H264PROFILE_MAIN, 64 media::H264PROFILE_MAIN,
65 media::H264PROFILE_EXTENDED, 65 media::H264PROFILE_EXTENDED,
66 media::H264PROFILE_HIGH, 66 media::H264PROFILE_HIGH,
67 media::H264PROFILE_HIGH10PROFILE, 67 media::H264PROFILE_HIGH10PROFILE,
68 media::H264PROFILE_HIGH422PROFILE, 68 media::H264PROFILE_HIGH422PROFILE,
69 media::H264PROFILE_HIGH444PREDICTIVEPROFILE, 69 media::H264PROFILE_HIGH444PREDICTIVEPROFILE,
70 media::H264PROFILE_SCALABLEBASELINE, 70 media::H264PROFILE_SCALABLEBASELINE,
71 media::H264PROFILE_SCALABLEHIGH, 71 media::H264PROFILE_SCALABLEHIGH,
72 media::H264PROFILE_STEREOHIGH, 72 media::H264PROFILE_STEREOHIGH,
73 media::H264PROFILE_MULTIVIEWHIGH 73 media::H264PROFILE_MULTIVIEWHIGH};
74 };
75 74
76 // Because MediaCodec is thread-hostile (must be poked on a single thread) and 75 // Because MediaCodec is thread-hostile (must be poked on a single thread) and
77 // has no callback mechanism (b/11990118), we must drive it by polling for 76 // has no callback mechanism (b/11990118), we must drive it by polling for
78 // complete frames (and available input buffers, when the codec is fully 77 // complete frames (and available input buffers, when the codec is fully
79 // saturated). This function defines the polling delay. The value used is an 78 // saturated). This function defines the polling delay. The value used is an
80 // arbitrary choice that trades off CPU utilization (spinning) against latency. 79 // arbitrary choice that trades off CPU utilization (spinning) against latency.
81 // Mirrors android_video_encode_accelerator.cc:EncodePollDelay(). 80 // Mirrors android_video_encode_accelerator.cc:EncodePollDelay().
82 static inline const base::TimeDelta DecodePollDelay() { 81 static inline const base::TimeDelta DecodePollDelay() {
83 // An alternative to this polling scheme could be to dedicate a new thread 82 // An alternative to this polling scheme could be to dedicate a new thread
84 // (instead of using the ChildThread) to run the MediaCodec, and make that 83 // (instead of using the ChildThread) to run the MediaCodec, and make that
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 SUPPORTS_DEFERRED_INITIALIZATION; 1321 SUPPORTS_DEFERRED_INITIALIZATION;
1323 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { 1322 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) {
1324 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: 1323 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities::
1325 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; 1324 SUPPORTS_EXTERNAL_OUTPUT_SURFACE;
1326 } 1325 }
1327 } 1326 }
1328 1327
1329 return capabilities; 1328 return capabilities;
1330 } 1329 }
1331 1330
1332 } // namespace content 1331 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698