Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016, The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Pawin Vongmasa | 04563aa | 2017-03-09 07:02:01 -0800 | [diff] [blame] | 17 | #include <gui/bufferqueue/1.0/H2BGraphicBufferProducer.h> |
Pawin Vongmasa | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame] | 18 | #include <media/omx/1.0/WOmx.h> |
| 19 | #include <media/omx/1.0/WOmxNode.h> |
| 20 | #include <media/omx/1.0/WOmxObserver.h> |
Pawin Vongmasa | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame] | 21 | #include <media/omx/1.0/Conversion.h> |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | namespace hardware { |
| 25 | namespace media { |
| 26 | namespace omx { |
| 27 | namespace V1_0 { |
| 28 | namespace utils { |
| 29 | |
Pawin Vongmasa | 04563aa | 2017-03-09 07:02:01 -0800 | [diff] [blame] | 30 | using ::android::hardware::graphics::bufferqueue::V1_0::utils:: |
| 31 | H2BGraphicBufferProducer; |
| 32 | typedef ::android::hardware::graphics::bufferqueue::V1_0::IGraphicBufferProducer |
| 33 | HGraphicBufferProducer; |
| 34 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 35 | // LWOmx |
| 36 | LWOmx::LWOmx(sp<IOmx> const& base) : mBase(base) { |
| 37 | } |
| 38 | |
| 39 | status_t LWOmx::listNodes(List<IOMX::ComponentInfo>* list) { |
| 40 | status_t fnStatus; |
| 41 | status_t transStatus = toStatusT(mBase->listNodes( |
| 42 | [&fnStatus, list]( |
| 43 | Status status, |
| 44 | hidl_vec<IOmx::ComponentInfo> const& nodeList) { |
| 45 | fnStatus = toStatusT(status); |
| 46 | list->clear(); |
| 47 | for (size_t i = 0; i < nodeList.size(); ++i) { |
| 48 | auto newInfo = list->insert( |
| 49 | list->end(), IOMX::ComponentInfo()); |
| 50 | convertTo(&*newInfo, nodeList[i]); |
| 51 | } |
| 52 | })); |
| 53 | return transStatus == NO_ERROR ? fnStatus : transStatus; |
| 54 | } |
| 55 | |
| 56 | status_t LWOmx::allocateNode( |
| 57 | char const* name, |
| 58 | sp<IOMXObserver> const& observer, |
| 59 | sp<IOMXNode>* omxNode) { |
| 60 | status_t fnStatus; |
| 61 | status_t transStatus = toStatusT(mBase->allocateNode( |
| 62 | name, new TWOmxObserver(observer), |
| 63 | [&fnStatus, omxNode](Status status, sp<IOmxNode> const& node) { |
| 64 | fnStatus = toStatusT(status); |
| 65 | *omxNode = new LWOmxNode(node); |
| 66 | })); |
| 67 | return transStatus == NO_ERROR ? fnStatus : transStatus; |
| 68 | } |
| 69 | |
| 70 | status_t LWOmx::createInputSurface( |
| 71 | sp<::android::IGraphicBufferProducer>* bufferProducer, |
Wonsik Kim | 9917d4a | 2019-10-24 12:56:38 -0700 | [diff] [blame] | 72 | sp<::android::hardware::media::omx::V1_0::IGraphicBufferSource>* bufferSource) { |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 73 | status_t fnStatus; |
| 74 | status_t transStatus = toStatusT(mBase->createInputSurface( |
| 75 | [&fnStatus, bufferProducer, bufferSource] ( |
| 76 | Status status, |
Pawin Vongmasa | 04563aa | 2017-03-09 07:02:01 -0800 | [diff] [blame] | 77 | sp<HGraphicBufferProducer> const& tProducer, |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 78 | sp<IGraphicBufferSource> const& tSource) { |
| 79 | fnStatus = toStatusT(status); |
Pawin Vongmasa | 04563aa | 2017-03-09 07:02:01 -0800 | [diff] [blame] | 80 | *bufferProducer = new H2BGraphicBufferProducer(tProducer); |
Wonsik Kim | 9917d4a | 2019-10-24 12:56:38 -0700 | [diff] [blame] | 81 | *bufferSource = tSource; |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 82 | })); |
| 83 | return transStatus == NO_ERROR ? fnStatus : transStatus; |
| 84 | } |
| 85 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 86 | } // namespace utils |
| 87 | } // namespace V1_0 |
| 88 | } // namespace omx |
| 89 | } // namespace media |
| 90 | } // namespace hardware |
| 91 | } // namespace android |