[Merge to 108][Cast Streaming] Disable HW VP8 on ChromeOS

This patch disables hardware VP8 encoding for cast streaming on all
ChromeOS devices, regardless of what receiver we are connected to.

This is the next step in fixing major artifacting and other issues
introduced by hardware encoding being enabled.

(cherry picked from commit 17e5bc9781e521c22009ddd302b2e6d41794a88d)

Bug: 1382591
Change-Id: Ic6df7baadc7a65cccc0af168c005dbef241407ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4014988
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1069966}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4032012
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5359@{#869}
Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933}
diff --git a/media/cast/BUILD.gn b/media/cast/BUILD.gn
index 259ee46f..83605423 100644
--- a/media/cast/BUILD.gn
+++ b/media/cast/BUILD.gn
@@ -183,10 +183,6 @@
 
     deps += [ "//third_party/libaom" ]
   }
-
-  if (is_chromeos) {
-    deps += [ "//third_party/re2" ]
-  }
 }
 
 # TODO(https://crbug.com/1327074): should be split into multiple source sets
diff --git a/media/cast/encoding/external_video_encoder.cc b/media/cast/encoding/external_video_encoder.cc
index 59be09a..2d6dfc3 100644
--- a/media/cast/encoding/external_video_encoder.cc
+++ b/media/cast/encoding/external_video_encoder.cc
@@ -13,7 +13,6 @@
 #if BUILDFLAG(IS_CHROMEOS)
 #include "base/cpu.h"                     // nogncheck
 #include "base/no_destructor.h"           // nogncheck
-#include "third_party/re2/src/re2/re2.h"  // nogncheck
 #endif
 
 #include "base/bind.h"
@@ -25,7 +24,6 @@
 #include "base/metrics/histogram_macros.h"
 #include "base/numerics/safe_conversions.h"
 #include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
 #include "base/time/time.h"
 #include "base/trace_event/trace_event.h"
 #include "build/build_config.h"
@@ -76,39 +74,16 @@
     base::StringPiece receiver_model_name,
     const std::vector<media::VideoEncodeAccelerator::SupportedProfile>&
         profiles) {
-#if BUILDFLAG(IS_CHROMEOS)
-  // NOTE: the hardware encoder on some Chrome OS devices does not play well
-  // with Vizio TVs. See https://crbug.com/1238774 for more information.
-  // Vizio uses the TV model string for the receiver model name.
-  const char* kVizioRegex =
-      R"(^(?i)(([DEMPV]|OLED)\d\d\w*-[A-Z]\w*)|(.*Vizio.*)$)";
-
-  if (RE2::FullMatch(re2::StringPiece(receiver_model_name.data(),
-                                      receiver_model_name.size()),
-                     RE2(kVizioRegex))) {
-    return false;
-  }
-#endif
-
-#if (BUILDFLAG(IS_CHROMEOS) && ARCH_CPU_X86_64) || \
-    (BUILDFLAG(IS_CHROMEOS_ASH) && ARCH_CPU_ARM_FAMILY)
-  // The encoder also doesn't work well with some first party Chromecast
-  // devices. See https://crbug.com/1342276 for more information.
-  if (base::StartsWith(receiver_model_name, "Chromecast")) {
-    return false;
-  }
-  // Sabrina devices sometimes advertise as Eureka Dongle
-  if (base::StartsWith(receiver_model_name, "Eureka Dongle")) {
-    return false;
-  }
-#endif
-
+// The hardware encoder on ChromeOS has major issues when connecting to a
+// variety of first and third party devices. See https://crbug.com/1382591.
+#if !BUILDFLAG(IS_CHROMEOS)
   for (const auto& vea_profile : profiles) {
     if (vea_profile.profile >= media::VP8PROFILE_MIN &&
         vea_profile.profile <= media::VP8PROFILE_MAX) {
       return true;
     }
   }
+#endif
 
   return false;
 }  // namespace
diff --git a/media/cast/encoding/external_video_encoder_unittest.cc b/media/cast/encoding/external_video_encoder_unittest.cc
index a70aa95..3f5070c 100644
--- a/media/cast/encoding/external_video_encoder_unittest.cc
+++ b/media/cast/encoding/external_video_encoder_unittest.cc
@@ -114,14 +114,14 @@
 }
 
 TEST(ExternalVideoEncoderTest, RecommendsExternalVp8EncoderForChromecast) {
-#if BUILDFLAG(IS_CHROMEOS) && ARCH_CPU_X86_64
+#if BUILDFLAG(IS_CHROMEOS)
   EXPECT_FALSE(ExternalVideoEncoder::IsRecommended(
       CODEC_VIDEO_VP8, "Eureka Dongle", kValidVeaProfiles));
   EXPECT_FALSE(ExternalVideoEncoder::IsRecommended(
       CODEC_VIDEO_VP8, "Chromecast", kValidVeaProfiles));
   EXPECT_FALSE(ExternalVideoEncoder::IsRecommended(
       CODEC_VIDEO_VP8, "Chromecast Ultra", kValidVeaProfiles));
-  EXPECT_TRUE(ExternalVideoEncoder::IsRecommended(
+  EXPECT_FALSE(ExternalVideoEncoder::IsRecommended(
       CODEC_VIDEO_VP8, "Google Home", kValidVeaProfiles));
 #else
   for (const char* model_name : kFirstPartyModelNames) {