Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9524e82e authored by Carlos Martinez Romero's avatar Carlos Martinez Romero Committed by Android (Google) Code Review
Browse files

Merge "Add media flag with dependencies." into main

parents 8002ffa7 bc1e1375
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -79,11 +79,68 @@ sp<SurfaceType> convertParcelableSurfaceTypeToSurface(const ParcelableSurfaceTyp
} // namespace flagtools
namespace mediaflagtools {
sp<MediaSurfaceType> igbpToSurfaceType(const sp<IGraphicBufferProducer>& igbp) {
    if (igbp == nullptr) {
        return nullptr;
    }
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_MEDIA_MIGRATION)
    return new Surface(igbp);
#else
    return igbp;
#endif
}

sp<IGraphicBufferProducer> surfaceTypeToIGBP(const sp<MediaSurfaceType>& mst) {
    if (mst == nullptr) {
        return nullptr;
    }
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_MEDIA_MIGRATION)
    return mst->getIGraphicBufferProducer();
#else
    return mst;
#endif
}

sp<SurfaceType> mediaSurfaceToCameraSurfaceType(const sp<MediaSurfaceType>& mst,
                                                [[maybe_unused]] bool controlledByApp) {
    if (mst == nullptr) {
        return nullptr;
    }
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_MEDIA_MIGRATION)
#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
    return mst;
#else
    return mst->getGraphicBufferProducer();
#endif
#else
#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
    return sp<Surface>::make(mst, controlledByApp);
#else
    return mst;
#endif
#endif
}

sp<Surface> surfaceTypeToSurface(const sp<MediaSurfaceType>& mst,
                                 [[maybe_unused]] bool controlledByApp) {
    if (mst == nullptr) {
        return nullptr;
    }
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_MEDIA_MIGRATION)
    return mst;
#else
    return sp<Surface>::make(mst, controlledByApp);
#endif
}

sp<MediaSurfaceType> surfaceToSurfaceType(const sp<Surface>& surface) {
    if (surface == nullptr) {
        return nullptr;
    }
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_MEDIA_MIGRATION)
    return surface;
#else
    return surface->getIGraphicBufferProducer();
#endif
}
} // namespace mediaflagtools
} // namespace android
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -60,5 +60,10 @@ typedef android::sp<android::IGraphicBufferProducer> MediaParcelableSurfaceType;

namespace mediaflagtools {
sp<MediaSurfaceType> igbpToSurfaceType(const sp<IGraphicBufferProducer>& igbp);
sp<IGraphicBufferProducer> surfaceTypeToIGBP(const sp<MediaSurfaceType>& mst);
sp<SurfaceType> mediaSurfaceToCameraSurfaceType(const sp<MediaSurfaceType>& mst,
                                                bool controlledByApp = false);
sp<Surface> surfaceTypeToSurface(const sp<MediaSurfaceType>& mst, bool controlledByApp = false);
sp<MediaSurfaceType> surfaceToSurfaceType(const sp<Surface>& surface);
} // namespace mediaflagtools
} // namespace android
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ class Surface : public Parcelable {

    // functions used to convert to a parcelable Surface so it can be passed over binder.
    static Surface fromSurface(const sp<android::Surface>& surface);
    sp<android::Surface> toSurface() const;
    sp<android::Surface> toSurface(bool controlledByApp = false) const;

    status_t getUniqueId(/* out */ uint64_t* id) const;

+2 −2
Original line number Diff line number Diff line
@@ -134,9 +134,9 @@ Surface Surface::fromSurface(const sp<android::Surface>& surface) {
    return s;
}

sp<android::Surface> Surface::toSurface() const {
sp<android::Surface> Surface::toSurface(bool controlledByApp) const {
    if (graphicBufferProducer == nullptr) return nullptr;
    return new android::Surface(graphicBufferProducer, false, surfaceControlHandle);
    return new android::Surface(graphicBufferProducer, controlledByApp, surfaceControlHandle);
}

status_t Surface::getUniqueId(uint64_t* out_id) const {