Merge "Disable our fancy logic to respect both sink and source's native formats" into jb-mr2-dev
diff --git a/media/libstagefright/wifi-display/VideoFormats.cpp b/media/libstagefright/wifi-display/VideoFormats.cpp
index 9ad8c3c..d171c6f 100644
--- a/media/libstagefright/wifi-display/VideoFormats.cpp
+++ b/media/libstagefright/wifi-display/VideoFormats.cpp
@@ -256,7 +256,7 @@
     return GetConfiguration(mNativeType, mNativeIndex, NULL, NULL, NULL, NULL);
 }
 
-AString VideoFormats::getFormatSpec() const {
+AString VideoFormats::getFormatSpec(bool forM4Message) const {
     CHECK_EQ(kNumResolutionTypes, 3);
 
     // wfd_video_formats:
@@ -277,7 +277,7 @@
 
     return StringPrintf(
             "%02x 00 02 02 %08x %08x %08x 00 0000 0000 00 none none",
-            (mNativeIndex << 3) | mNativeType,
+            forM4Message ? 0x00 : ((mNativeIndex << 3) | mNativeType),
             mResolutionEnabled[0],
             mResolutionEnabled[1],
             mResolutionEnabled[2]);
@@ -289,6 +289,10 @@
         const VideoFormats &sourceSupported,
         ResolutionType *chosenType,
         size_t *chosenIndex) {
+#if 0
+    // Support for the native format is a great idea, the spec includes
+    // these features, but nobody supports it and the tests don't validate it.
+
     ResolutionType nativeType;
     size_t nativeIndex;
     sinkSupported.getNativeResolution(&nativeType, &nativeIndex);
@@ -316,6 +320,7 @@
         ALOGW("Source advertised native resolution that it doesn't "
               "actually support... ignoring");
     }
+#endif
 
     bool first = true;
     uint32_t bestScore = 0;
diff --git a/media/libstagefright/wifi-display/VideoFormats.h b/media/libstagefright/wifi-display/VideoFormats.h
index a84407a..69e2197 100644
--- a/media/libstagefright/wifi-display/VideoFormats.h
+++ b/media/libstagefright/wifi-display/VideoFormats.h
@@ -60,7 +60,7 @@
             bool *interlaced);
 
     bool parseFormatSpec(const char *spec);
-    AString getFormatSpec() const;
+    AString getFormatSpec(bool forM4Message = false) const;
 
     static bool PickBestFormat(
             const VideoFormats &sinkSupported,
diff --git a/media/libstagefright/wifi-display/sink/WifiDisplaySink.cpp b/media/libstagefright/wifi-display/sink/WifiDisplaySink.cpp
index a6f58cd..158c2da 100644
--- a/media/libstagefright/wifi-display/sink/WifiDisplaySink.cpp
+++ b/media/libstagefright/wifi-display/sink/WifiDisplaySink.cpp
@@ -47,19 +47,11 @@
       mSessionID(0),
       mNextCSeq(1),
       mIDRFrameRequestPending(false) {
-#if 1
     // We support any and all resolutions, but prefer 720p30
     mSinkSupportedVideoFormats.setNativeResolution(
             VideoFormats::RESOLUTION_CEA, 5);  // 1280 x 720 p30
 
     mSinkSupportedVideoFormats.enableAll();
-#else
-    // We only support 640 x 360 p30.
-    mSinkSupportedVideoFormats.disableAll();
-
-    mSinkSupportedVideoFormats.setNativeResolution(
-            VideoFormats::RESOLUTION_HH, 6);  // 640 x 360 p30
-#endif
 }
 
 WifiDisplaySink::~WifiDisplaySink() {
diff --git a/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp b/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp
index 07eb237..b8524f6 100644
--- a/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp
+++ b/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp
@@ -59,18 +59,10 @@
       mHDCPPort(0),
       mHDCPInitializationComplete(false),
       mSetupTriggerDeferred(false) {
-    mSupportedSourceVideoFormats.enableAll();
+    mSupportedSourceVideoFormats.disableAll();
 
     mSupportedSourceVideoFormats.setNativeResolution(
             VideoFormats::RESOLUTION_CEA, 5);  // 1280x720 p30
-
-    // Disable resolutions above 1080p since the encoder won't be able to
-    // handle them.
-    mSupportedSourceVideoFormats.setResolutionEnabled(
-            VideoFormats::RESOLUTION_VESA, 28, false);  // 1920x1200 p30
-
-    mSupportedSourceVideoFormats.setResolutionEnabled(
-            VideoFormats::RESOLUTION_VESA, 29, false);  // 1920x1200 p60
 }
 
 WifiDisplaySource::~WifiDisplaySource() {
@@ -607,7 +599,7 @@
         chosenVideoFormat.setNativeResolution(
                 mChosenVideoResolutionType, mChosenVideoResolutionIndex);
 
-        body.append(chosenVideoFormat.getFormatSpec());
+        body.append(chosenVideoFormat.getFormatSpec(true /* forM4Message */));
         body.append("\r\n");
     }