| Index: content/common/gpu/media/android_video_encode_accelerator.cc
|
| diff --git a/content/common/gpu/media/android_video_encode_accelerator.cc b/content/common/gpu/media/android_video_encode_accelerator.cc
|
| index 2507ea41c1f9b3c6782adc3681186827433da991..9b703d70f975c0734951d596bab1f933e605e2e3 100644
|
| --- a/content/common/gpu/media/android_video_encode_accelerator.cc
|
| +++ b/content/common/gpu/media/android_video_encode_accelerator.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "content/common/gpu/media/android_video_encode_accelerator.h"
|
|
|
| +#include <set>
|
| +
|
| #include "base/bind.h"
|
| #include "base/command_line.h"
|
| #include "base/logging.h"
|
| @@ -26,8 +28,9 @@ using media::VideoFrame;
|
|
|
| namespace content {
|
|
|
| -enum {
|
| +enum PixelFormat {
|
| // Subset of MediaCodecInfo.CodecCapabilities.
|
| + COLOR_FORMAT_YUV420_PLANAR = 19,
|
| COLOR_FORMAT_YUV420_SEMIPLANAR = 21,
|
| };
|
|
|
| @@ -67,6 +70,19 @@ static inline const base::TimeDelta NoWaitTimeOut() {
|
| return base::TimeDelta::FromMicroseconds(0);
|
| }
|
|
|
| +static bool GetSupportedColorFormatForMime(const std::string& mime,
|
| + PixelFormat* pixel_format) {
|
| + std::set<int> formats = MediaCodecBridge::GetEncoderColorFormats(mime);
|
| + if (formats.count(COLOR_FORMAT_YUV420_SEMIPLANAR) > 0)
|
| + *pixel_format = COLOR_FORMAT_YUV420_SEMIPLANAR;
|
| + else if (formats.count(COLOR_FORMAT_YUV420_PLANAR) > 0)
|
| + *pixel_format = COLOR_FORMAT_YUV420_PLANAR;
|
| + else
|
| + return false;
|
| +
|
| + return true;
|
| +}
|
| +
|
| AndroidVideoEncodeAccelerator::AndroidVideoEncodeAccelerator()
|
| : num_buffers_at_codec_(0),
|
| num_output_buffers_(-1),
|
| @@ -142,17 +158,17 @@ bool AndroidVideoEncodeAccelerator::Initialize(
|
| return false;
|
| }
|
|
|
| - // TODO(fischman): when there is more HW out there with different color-space
|
| - // support, this should turn into a negotiation with the codec for supported
|
| - // formats. For now we use the only format supported by the only available
|
| - // HW.
|
| - media_codec_.reset(
|
| - media::VideoCodecBridge::CreateEncoder(media::kCodecVP8,
|
| - input_visible_size,
|
| - initial_bitrate,
|
| - INITIAL_FRAMERATE,
|
| - IFRAME_INTERVAL,
|
| - COLOR_FORMAT_YUV420_SEMIPLANAR));
|
| + PixelFormat pixel_format = COLOR_FORMAT_YUV420_SEMIPLANAR;
|
| + if (!GetSupportedColorFormatForMime("video/x-vnd.on2.vp8", &pixel_format)) {
|
| + DLOG(ERROR) << "No color format support.";
|
| + return false;
|
| + }
|
| + media_codec_.reset(media::VideoCodecBridge::CreateEncoder(media::kCodecVP8,
|
| + input_visible_size,
|
| + initial_bitrate,
|
| + INITIAL_FRAMERATE,
|
| + IFRAME_INTERVAL,
|
| + pixel_format));
|
|
|
| if (!media_codec_) {
|
| DLOG(ERROR) << "Failed to create/start the codec: "
|
|
|