Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / common / gpu / media / android_video_encode_accelerator.cc
index bc14aa1..f124b14 100644 (file)
@@ -86,7 +86,7 @@ AndroidVideoEncodeAccelerator::GetSupportedProfiles() {
   std::vector<SupportedProfile> profiles;
 
 #if defined(ENABLE_WEBRTC)
-  const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+  const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
   if (cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding))
     return profiles;
 #endif
@@ -100,7 +100,7 @@ AndroidVideoEncodeAccelerator::GetSupportedProfiles() {
       continue;
     }
     SupportedProfile profile;
-    profile.profile = media::VP8PROFILE_MAIN;
+    profile.profile = media::VP8PROFILE_ANY;
     // Wouldn't it be nice if MediaCodec exposed the maximum capabilities of the
     // encoder?  Sure would be.  Too bad it doesn't.  So we hard-code some
     // reasonable defaults.
@@ -112,7 +112,7 @@ AndroidVideoEncodeAccelerator::GetSupportedProfiles() {
   return profiles;
 }
 
-void AndroidVideoEncodeAccelerator::Initialize(
+bool AndroidVideoEncodeAccelerator::Initialize(
     VideoFrame::Format format,
     const gfx::Size& input_visible_size,
     media::VideoCodecProfile output_profile,
@@ -127,19 +127,21 @@ void AndroidVideoEncodeAccelerator::Initialize(
 
   client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
 
-  RETURN_ON_FAILURE(media::MediaCodecBridge::SupportsSetParameters() &&
-                        format == VideoFrame::I420 &&
-                        output_profile == media::VP8PROFILE_MAIN,
-                    "Unexpected combo: " << format << ", " << output_profile,
-                    kInvalidArgumentError);
+  if (!(media::MediaCodecBridge::SupportsSetParameters() &&
+        format == VideoFrame::I420 &&
+        output_profile == media::VP8PROFILE_ANY)) {
+    DLOG(ERROR) << "Unexpected combo: " << format << ", " << output_profile;
+    return false;
+  }
 
   last_set_bitrate_ = initial_bitrate;
 
   // Only consider using MediaCodec if it's likely backed by hardware.
-  RETURN_ON_FAILURE(!media::VideoCodecBridge::IsKnownUnaccelerated(
-                         media::kCodecVP8, media::MEDIA_CODEC_ENCODER),
-                    "No HW support",
-                    kPlatformFailureError);
+  if (media::VideoCodecBridge::IsKnownUnaccelerated(
+          media::kCodecVP8, media::MEDIA_CODEC_ENCODER)) {
+    DLOG(ERROR) << "No HW support";
+    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
@@ -153,15 +155,11 @@ void AndroidVideoEncodeAccelerator::Initialize(
                                              IFRAME_INTERVAL,
                                              COLOR_FORMAT_YUV420_SEMIPLANAR));
 
-  RETURN_ON_FAILURE(
-      media_codec_,
-      "Failed to create/start the codec: " << input_visible_size.ToString(),
-      kPlatformFailureError);
-
-  base::MessageLoop::current()->PostTask(
-      FROM_HERE,
-      base::Bind(&VideoEncodeAccelerator::Client::NotifyInitializeDone,
-                 client_ptr_factory_->GetWeakPtr()));
+  if (!media_codec_) {
+    DLOG(ERROR) << "Failed to create/start the codec: "
+                << input_visible_size.ToString();
+    return false;
+  }
 
   num_output_buffers_ = media_codec_->GetOutputBuffersCount();
   output_buffers_capacity_ = media_codec_->GetOutputBuffersCapacity();
@@ -172,6 +170,7 @@ void AndroidVideoEncodeAccelerator::Initialize(
                  num_output_buffers_,
                  input_visible_size,
                  output_buffers_capacity_));
+  return true;
 }
 
 void AndroidVideoEncodeAccelerator::MaybeStartIOTimer() {