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

Commit 3ecd658d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "Refactor GraphicBufferSource wrappers for OMX HAL""

parents e2986425 a6331ba3
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -190,19 +190,6 @@ inline ::android::binder::Status toBinderStatus(
            t.description().c_str());
}

/**
 * \brief Convert `Return<Status>` to `binder::Status`.
 *
 * \param[in] t The source `Return<Status>`.
 * \return The corresponding `binder::Status`.
 */
// convert: Return<Status> -> ::android::binder::Status
inline ::android::binder::Status toBinderStatus(
        Return<Status> const& t) {
    return ::android::binder::Status::fromStatusT(
            t.isOk() ? static_cast<status_t>(static_cast<Status>(t)) : UNKNOWN_ERROR);
}

/**
 * \brief Convert `Return<Status>` to `status_t`. This is for legacy binder
 * calls.
+29 −11
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;

using ::android::IOMXNode;

/**
@@ -59,7 +60,7 @@ using ::android::IOMXNode;
 * - TW = Treble Wrapper --- It wraps a legacy object inside a Treble object.
 */

typedef ::android::binder::Status BnStatus;
typedef ::android::IGraphicBufferSource LGraphicBufferSource;
typedef ::android::BnGraphicBufferSource BnGraphicBufferSource;
typedef ::android::hardware::media::omx::V1_0::IGraphicBufferSource
        TGraphicBufferSource;
@@ -67,19 +68,36 @@ typedef ::android::hardware::media::omx::V1_0::IGraphicBufferSource
struct LWGraphicBufferSource : public BnGraphicBufferSource {
    sp<TGraphicBufferSource> mBase;
    LWGraphicBufferSource(sp<TGraphicBufferSource> const& base);
    BnStatus configure(
    ::android::binder::Status configure(
            const sp<IOMXNode>& omxNode, int32_t dataSpace) override;
    BnStatus setSuspend(bool suspend, int64_t timeUs) override;
    BnStatus setRepeatPreviousFrameDelayUs(
    ::android::binder::Status setSuspend(bool suspend, int64_t timeUs) override;
    ::android::binder::Status setRepeatPreviousFrameDelayUs(
            int64_t repeatAfterUs) override;
    BnStatus setMaxFps(float maxFps) override;
    BnStatus setTimeLapseConfig(
    ::android::binder::Status setMaxFps(float maxFps) override;
    ::android::binder::Status setTimeLapseConfig(
            int64_t timePerFrameUs, int64_t timePerCaptureUs) override;
    ::android::binder::Status setStartTimeUs(int64_t startTimeUs) override;
    ::android::binder::Status setStopTimeUs(int64_t stopTimeUs) override;
    ::android::binder::Status setColorAspects(int32_t aspects) override;
    ::android::binder::Status setTimeOffsetUs(int64_t timeOffsetsUs) override;
    ::android::binder::Status signalEndOfInputStream() override;
};

struct TWGraphicBufferSource : public TGraphicBufferSource {
    sp<LGraphicBufferSource> mBase;
    TWGraphicBufferSource(sp<LGraphicBufferSource> const& base);
    Return<void> configure(
            const sp<IOmxNode>& omxNode, Dataspace dataspace) override;
    Return<void> setSuspend(bool suspend, int64_t timeUs) override;
    Return<void> setRepeatPreviousFrameDelayUs(int64_t repeatAfterUs) override;
    Return<void> setMaxFps(float maxFps) override;
    Return<void> setTimeLapseConfig(
            int64_t timePerFrameUs, int64_t timePerCaptureUs) override;
    BnStatus setStartTimeUs(int64_t startTimeUs) override;
    BnStatus setStopTimeUs(int64_t stopTimeUs) override;
    BnStatus setColorAspects(int32_t aspects) override;
    BnStatus setTimeOffsetUs(int64_t timeOffsetsUs) override;
    BnStatus signalEndOfInputStream() override;
    Return<void> setStartTimeUs(int64_t startTimeUs) override;
    Return<void> setStopTimeUs(int64_t stopTimeUs) override;
    Return<void> setColorAspects(const ColorAspects& aspects) override;
    Return<void> setTimeOffsetUs(int64_t timeOffsetUs) override;
    Return<void> signalEndOfInputStream() override;
};

}  // namespace utils
+12 −0
Original line number Diff line number Diff line
@@ -70,6 +70,18 @@ struct LWOmx : public BnOMX {
            sp<::android::IGraphicBufferSource>* bufferSource) override;
};

struct TWOmx : public IOmx {
    sp<IOMX> mBase;
    TWOmx(sp<IOMX> const& base);
    Return<void> listNodes(listNodes_cb _hidl_cb) override;
    Return<void> allocateNode(
            const hidl_string& name,
            const sp<IOmxObserver>& observer,
            allocateNode_cb _hidl_cb) override;
    Return<void> createInputSurface(createInputSurface_cb _hidl_cb) override;

};

}  // namespace utils
}  // namespace V1_0
}  // namespace omx
+74 −10
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 */

#include <stagefright/foundation/ColorUtils.h>

#include <media/omx/1.0/WGraphicBufferSource.h>
#include <media/omx/1.0/WOmxNode.h>
#include <media/omx/1.0/Conversion.h>
@@ -25,12 +27,14 @@ namespace omx {
namespace V1_0 {
namespace utils {

using android::ColorUtils;

// LWGraphicBufferSource
LWGraphicBufferSource::LWGraphicBufferSource(
        sp<TGraphicBufferSource> const& base) : mBase(base) {
}

BnStatus LWGraphicBufferSource::configure(
::android::binder::Status LWGraphicBufferSource::configure(
        const sp<IOMXNode>& omxNode, int32_t dataSpace) {
    sp<IOmxNode> hOmxNode = omxNode->getHalInterface();
    return toBinderStatus(mBase->configure(
@@ -38,51 +42,111 @@ BnStatus LWGraphicBufferSource::configure(
            toHardwareDataspace(dataSpace)));
}

BnStatus LWGraphicBufferSource::setSuspend(
::android::binder::Status LWGraphicBufferSource::setSuspend(
        bool suspend, int64_t timeUs) {
    return toBinderStatus(mBase->setSuspend(suspend, timeUs));
}

BnStatus LWGraphicBufferSource::setRepeatPreviousFrameDelayUs(
::android::binder::Status LWGraphicBufferSource::setRepeatPreviousFrameDelayUs(
        int64_t repeatAfterUs) {
    return toBinderStatus(mBase->setRepeatPreviousFrameDelayUs(repeatAfterUs));
}

BnStatus LWGraphicBufferSource::setMaxFps(float maxFps) {
::android::binder::Status LWGraphicBufferSource::setMaxFps(float maxFps) {
    return toBinderStatus(mBase->setMaxFps(maxFps));
}

BnStatus LWGraphicBufferSource::setTimeLapseConfig(
::android::binder::Status LWGraphicBufferSource::setTimeLapseConfig(
        int64_t timePerFrameUs, int64_t timePerCaptureUs) {
    return toBinderStatus(mBase->setTimeLapseConfig(
            timePerFrameUs, timePerCaptureUs));
}

BnStatus LWGraphicBufferSource::setStartTimeUs(
::android::binder::Status LWGraphicBufferSource::setStartTimeUs(
        int64_t startTimeUs) {
    return toBinderStatus(mBase->setStartTimeUs(startTimeUs));
}

BnStatus LWGraphicBufferSource::setStopTimeUs(
::android::binder::Status LWGraphicBufferSource::setStopTimeUs(
        int64_t stopTimeUs) {
    return toBinderStatus(mBase->setStopTimeUs(stopTimeUs));
}

BnStatus LWGraphicBufferSource::setColorAspects(
::android::binder::Status LWGraphicBufferSource::setColorAspects(
        int32_t aspects) {
    return toBinderStatus(mBase->setColorAspects(
            toHardwareColorAspects(aspects)));
}

BnStatus LWGraphicBufferSource::setTimeOffsetUs(
::android::binder::Status LWGraphicBufferSource::setTimeOffsetUs(
        int64_t timeOffsetsUs) {
    return toBinderStatus(mBase->setTimeOffsetUs(timeOffsetsUs));
}

BnStatus LWGraphicBufferSource::signalEndOfInputStream() {
::android::binder::Status LWGraphicBufferSource::signalEndOfInputStream() {
    return toBinderStatus(mBase->signalEndOfInputStream());
}

// TWGraphicBufferSource
TWGraphicBufferSource::TWGraphicBufferSource(
        sp<LGraphicBufferSource> const& base) : mBase(base) {
}

Return<void> TWGraphicBufferSource::configure(
        const sp<IOmxNode>& omxNode, Dataspace dataspace) {
    mBase->configure(new LWOmxNode(omxNode), toRawDataspace(dataspace));
    return Void();
}

Return<void> TWGraphicBufferSource::setSuspend(
        bool suspend, int64_t timeUs) {
    mBase->setSuspend(suspend, timeUs);
    return Void();
}

Return<void> TWGraphicBufferSource::setRepeatPreviousFrameDelayUs(
        int64_t repeatAfterUs) {
    mBase->setRepeatPreviousFrameDelayUs(repeatAfterUs);
    return Void();
}

Return<void> TWGraphicBufferSource::setMaxFps(float maxFps) {
    mBase->setMaxFps(maxFps);
    return Void();
}

Return<void> TWGraphicBufferSource::setTimeLapseConfig(
        int64_t timePerFrameUs, int64_t timePerCaptureUs) {
    mBase->setTimeLapseConfig(timePerFrameUs, timePerCaptureUs);
    return Void();
}

Return<void> TWGraphicBufferSource::setStartTimeUs(int64_t startTimeUs) {
    mBase->setStartTimeUs(startTimeUs);
    return Void();
}

Return<void> TWGraphicBufferSource::setStopTimeUs(int64_t stopTimeUs) {
    mBase->setStopTimeUs(stopTimeUs);
    return Void();
}

Return<void> TWGraphicBufferSource::setColorAspects(
        const ColorAspects& aspects) {
    mBase->setColorAspects(toCompactColorAspects(aspects));
    return Void();
}

Return<void> TWGraphicBufferSource::setTimeOffsetUs(int64_t timeOffsetUs) {
    mBase->setTimeOffsetUs(timeOffsetUs);
    return Void();
}

Return<void> TWGraphicBufferSource::signalEndOfInputStream() {
    mBase->signalEndOfInputStream();
    return Void();
}

}  // namespace utils
}  // namespace V1_0
}  // namespace omx
+39 −0
Original line number Diff line number Diff line
@@ -79,6 +79,45 @@ status_t LWOmx::createInputSurface(
    return transStatus == NO_ERROR ? fnStatus : transStatus;
}

// TWOmx
TWOmx::TWOmx(sp<IOMX> const& base) : mBase(base) {
}

Return<void> TWOmx::listNodes(listNodes_cb _hidl_cb) {
    List<IOMX::ComponentInfo> lList;
    Status status = toStatus(mBase->listNodes(&lList));

    hidl_vec<IOmx::ComponentInfo> tList;
    tList.resize(lList.size());
    size_t i = 0;
    for (auto const& lInfo : lList) {
        convertTo(&(tList[i++]), lInfo);
    }
    _hidl_cb(status, tList);
    return Void();
}

Return<void> TWOmx::allocateNode(
        const hidl_string& name,
        const sp<IOmxObserver>& observer,
        allocateNode_cb _hidl_cb) {
    sp<IOMXNode> omxNode;
    Status status = toStatus(mBase->allocateNode(
            name, new LWOmxObserver(observer), &omxNode));
    _hidl_cb(status, new TWOmxNode(omxNode));
    return Void();
}

Return<void> TWOmx::createInputSurface(createInputSurface_cb _hidl_cb) {
    sp<::android::IGraphicBufferProducer> lProducer;
    sp<::android::IGraphicBufferSource> lSource;
    status_t status = mBase->createInputSurface(&lProducer, &lSource);
    _hidl_cb(toStatus(status),
             new TWOmxBufferProducer(lProducer),
             new TWGraphicBufferSource(lSource));
    return Void();
}

}  // namespace utils
}  // namespace V1_0
}  // namespace omx
Loading