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

Side by Side Diff: content/common/gpu/media/android_video_encode_accelerator.cc

Issue 1525003002: Revert of Refactor MediaCodecBridge to add support for NDK APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix rebase errors Created 5 years 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 "content/common/gpu/media/android_video_encode_accelerator.h" 5 #include "content/common/gpu/media/android_video_encode_accelerator.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "content/common/gpu/gpu_channel.h" 14 #include "content/common/gpu/gpu_channel.h"
15 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
17 #include "media/base/android/media_codec_util.h" 17 #include "media/base/android/media_codec_bridge.h"
18 #include "media/base/bitstream_buffer.h" 18 #include "media/base/bitstream_buffer.h"
19 #include "media/base/limits.h" 19 #include "media/base/limits.h"
20 #include "media/video/picture.h" 20 #include "media/video/picture.h"
21 #include "third_party/libyuv/include/libyuv/convert_from.h" 21 #include "third_party/libyuv/include/libyuv/convert_from.h"
22 #include "ui/gl/android/scoped_java_surface.h" 22 #include "ui/gl/android/scoped_java_surface.h"
23 #include "ui/gl/gl_bindings.h" 23 #include "ui/gl/gl_bindings.h"
24 24
25 using media::MediaCodecBridge;
25 using media::VideoCodecBridge; 26 using media::VideoCodecBridge;
26 using media::VideoFrame; 27 using media::VideoFrame;
27 28
28 namespace content { 29 namespace content {
29 30
30 // Limit default max video codec size for Android to avoid 31 // Limit default max video codec size for Android to avoid
31 // HW codec initialization failure for resolution higher than 720p. 32 // HW codec initialization failure for resolution higher than 720p.
32 // Default values are from Libjingle "jsepsessiondescription.cc". 33 // Default values are from Libjingle "jsepsessiondescription.cc".
33 const int kMaxEncodeFrameWidth = 1280; 34 const int kMaxEncodeFrameWidth = 1280;
34 const int kMaxEncodeFrameHeight = 720; 35 const int kMaxEncodeFrameHeight = 720;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 76
76 static inline const base::TimeDelta NoWaitTimeOut() { 77 static inline const base::TimeDelta NoWaitTimeOut() {
77 return base::TimeDelta::FromMicroseconds(0); 78 return base::TimeDelta::FromMicroseconds(0);
78 } 79 }
79 80
80 static bool GetSupportedColorFormatForMime(const std::string& mime, 81 static bool GetSupportedColorFormatForMime(const std::string& mime,
81 PixelFormat* pixel_format) { 82 PixelFormat* pixel_format) {
82 if (mime.empty()) 83 if (mime.empty())
83 return false; 84 return false;
84 85
85 std::set<int> formats = media::MediaCodecUtil::GetEncoderColorFormats(mime); 86 std::set<int> formats = MediaCodecBridge::GetEncoderColorFormats(mime);
86 if (formats.count(COLOR_FORMAT_YUV420_SEMIPLANAR) > 0) 87 if (formats.count(COLOR_FORMAT_YUV420_SEMIPLANAR) > 0)
87 *pixel_format = COLOR_FORMAT_YUV420_SEMIPLANAR; 88 *pixel_format = COLOR_FORMAT_YUV420_SEMIPLANAR;
88 else if (formats.count(COLOR_FORMAT_YUV420_PLANAR) > 0) 89 else if (formats.count(COLOR_FORMAT_YUV420_PLANAR) > 0)
89 *pixel_format = COLOR_FORMAT_YUV420_PLANAR; 90 *pixel_format = COLOR_FORMAT_YUV420_PLANAR;
90 else 91 else
91 return false; 92 return false;
92 93
93 return true; 94 return true;
94 } 95 }
95 96
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 Client* client) { 150 Client* client) {
150 DVLOG(3) << __PRETTY_FUNCTION__ << " format: " << format 151 DVLOG(3) << __PRETTY_FUNCTION__ << " format: " << format
151 << ", input_visible_size: " << input_visible_size.ToString() 152 << ", input_visible_size: " << input_visible_size.ToString()
152 << ", output_profile: " << output_profile 153 << ", output_profile: " << output_profile
153 << ", initial_bitrate: " << initial_bitrate; 154 << ", initial_bitrate: " << initial_bitrate;
154 DCHECK(!media_codec_); 155 DCHECK(!media_codec_);
155 DCHECK(thread_checker_.CalledOnValidThread()); 156 DCHECK(thread_checker_.CalledOnValidThread());
156 157
157 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); 158 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
158 159
159 if (!(media::MediaCodecUtil::SupportsSetParameters() && 160 if (!(media::MediaCodecBridge::SupportsSetParameters() &&
160 format == media::PIXEL_FORMAT_I420)) { 161 format == media::PIXEL_FORMAT_I420)) {
161 DLOG(ERROR) << "Unexpected combo: " << format << ", " << output_profile; 162 DLOG(ERROR) << "Unexpected combo: " << format << ", " << output_profile;
162 return false; 163 return false;
163 } 164 }
164 165
165 std::string mime_type; 166 std::string mime_type;
166 media::VideoCodec codec; 167 media::VideoCodec codec;
167 if (output_profile == media::VP8PROFILE_ANY) { 168 if (output_profile == media::VP8PROFILE_ANY) {
168 codec = media::kCodecVP8; 169 codec = media::kCodecVP8;
169 mime_type = "video/x-vnd.on2.vp8"; 170 mime_type = "video/x-vnd.on2.vp8";
170 } else if (output_profile == media::H264PROFILE_BASELINE || 171 } else if (output_profile == media::H264PROFILE_BASELINE ||
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 base::MessageLoop::current()->PostTask( 447 base::MessageLoop::current()->PostTask(
447 FROM_HERE, 448 FROM_HERE,
448 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady, 449 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady,
449 client_ptr_factory_->GetWeakPtr(), 450 client_ptr_factory_->GetWeakPtr(),
450 bitstream_buffer.id(), 451 bitstream_buffer.id(),
451 size, 452 size,
452 key_frame)); 453 key_frame));
453 } 454 }
454 455
455 } // namespace content 456 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/android_video_encode_accelerator.h ('k') | content/common/gpu/media/avda_shared_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698