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 | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame] | 17 | #include <media/omx/1.0/WOmx.h> |
| 18 | #include <media/omx/1.0/WOmxNode.h> |
| 19 | #include <media/omx/1.0/WOmxObserver.h> |
| 20 | #include <media/omx/1.0/WOmxBufferProducer.h> |
| 21 | #include <media/omx/1.0/WGraphicBufferSource.h> |
| 22 | #include <media/omx/1.0/Conversion.h> |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace media { |
| 27 | namespace omx { |
| 28 | namespace V1_0 { |
| 29 | namespace utils { |
| 30 | |
| 31 | // LWOmx |
| 32 | LWOmx::LWOmx(sp<IOmx> const& base) : mBase(base) { |
| 33 | } |
| 34 | |
| 35 | status_t LWOmx::listNodes(List<IOMX::ComponentInfo>* list) { |
| 36 | status_t fnStatus; |
| 37 | status_t transStatus = toStatusT(mBase->listNodes( |
| 38 | [&fnStatus, list]( |
| 39 | Status status, |
| 40 | hidl_vec<IOmx::ComponentInfo> const& nodeList) { |
| 41 | fnStatus = toStatusT(status); |
| 42 | list->clear(); |
| 43 | for (size_t i = 0; i < nodeList.size(); ++i) { |
| 44 | auto newInfo = list->insert( |
| 45 | list->end(), IOMX::ComponentInfo()); |
| 46 | convertTo(&*newInfo, nodeList[i]); |
| 47 | } |
| 48 | })); |
| 49 | return transStatus == NO_ERROR ? fnStatus : transStatus; |
| 50 | } |
| 51 | |
| 52 | status_t LWOmx::allocateNode( |
| 53 | char const* name, |
| 54 | sp<IOMXObserver> const& observer, |
| 55 | sp<IOMXNode>* omxNode) { |
| 56 | status_t fnStatus; |
| 57 | status_t transStatus = toStatusT(mBase->allocateNode( |
| 58 | name, new TWOmxObserver(observer), |
| 59 | [&fnStatus, omxNode](Status status, sp<IOmxNode> const& node) { |
| 60 | fnStatus = toStatusT(status); |
| 61 | *omxNode = new LWOmxNode(node); |
| 62 | })); |
| 63 | return transStatus == NO_ERROR ? fnStatus : transStatus; |
| 64 | } |
| 65 | |
| 66 | status_t LWOmx::createInputSurface( |
| 67 | sp<::android::IGraphicBufferProducer>* bufferProducer, |
| 68 | sp<::android::IGraphicBufferSource>* bufferSource) { |
| 69 | status_t fnStatus; |
| 70 | status_t transStatus = toStatusT(mBase->createInputSurface( |
| 71 | [&fnStatus, bufferProducer, bufferSource] ( |
| 72 | Status status, |
| 73 | sp<IOmxBufferProducer> const& tProducer, |
| 74 | sp<IGraphicBufferSource> const& tSource) { |
| 75 | fnStatus = toStatusT(status); |
| 76 | *bufferProducer = new LWOmxBufferProducer(tProducer); |
| 77 | *bufferSource = new LWGraphicBufferSource(tSource); |
| 78 | })); |
| 79 | return transStatus == NO_ERROR ? fnStatus : transStatus; |
| 80 | } |
| 81 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 82 | } // namespace utils |
| 83 | } // namespace V1_0 |
| 84 | } // namespace omx |
| 85 | } // namespace media |
| 86 | } // namespace hardware |
| 87 | } // namespace android |