stagefright: remove OMXNodeInstance usage from GraphicBufferSource

This is a preliminary to separate GraphicBufferSource from IOMX.

- Use IOMX instead of internal OMXNodeInstance.

- Keep track of codec buffers by buffer_id, do not write to the
  OMX buffer headers directly

- Upon data space change, notify IOMX to handle it

bug: 31399200

Change-Id: I86534d7602294f70da582457b5af2eb9b6a58eda
diff --git a/include/media/IOMX.h b/include/media/IOMX.h
index 15d691f..88371ed 100644
--- a/include/media/IOMX.h
+++ b/include/media/IOMX.h
@@ -39,6 +39,7 @@
 class IOMXRenderer;
 class NativeHandle;
 class Surface;
+struct omx_message;
 
 class IOMX : public IInterface {
 public:
@@ -179,6 +180,12 @@
             OMX_U32 range_offset, OMX_U32 range_length,
             OMX_U32 flags, OMX_TICKS timestamp, int fenceFd = -1) = 0;
 
+    virtual status_t emptyGraphicBuffer(
+            node_id node,
+            buffer_id buffer,
+            const sp<GraphicBuffer> &graphicBuffer,
+            OMX_U32 flags, OMX_TICKS timestamp, int fenceFd) = 0;
+
     virtual status_t getExtensionIndex(
             node_id node,
             const char *parameter_name,
@@ -199,6 +206,8 @@
             InternalOptionType type,
             const void *data,
             size_t size) = 0;
+
+    virtual status_t dispatchMessage(const omx_message &msg) = 0;
 };
 
 struct omx_message {
@@ -218,6 +227,8 @@
             OMX_EVENTTYPE event;
             OMX_U32 data1;
             OMX_U32 data2;
+            OMX_U32 data3;
+            OMX_U32 data4;
         } event_data;
 
         // if type == EMPTY_BUFFER_DONE
diff --git a/include/media/stagefright/foundation/ColorUtils.h b/include/media/stagefright/foundation/ColorUtils.h
index 2368b82..b889a02 100644
--- a/include/media/stagefright/foundation/ColorUtils.h
+++ b/include/media/stagefright/foundation/ColorUtils.h
@@ -138,6 +138,12 @@
             int32_t primaries, int32_t transfer, int32_t coeffs, bool fullRange,
             ColorAspects &aspects);
 
+    // unpack a uint32_t to a full ColorAspects struct
+    static ColorAspects unpackToColorAspects(uint32_t packed);
+
+    // pack a full ColorAspects struct into a uint32_t
+    static uint32_t packToU32(const ColorAspects &aspects);
+
     // updates Unspecified color aspects to their defaults based on the video size
     static void setDefaultCodecColorAspectsIfNeeded(
             ColorAspects &aspects, int32_t width, int32_t height);