blob: ce624fa79655a4bfbba78825e51160e0a2ecc714 [file] [log] [blame]
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -08001/*
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 Vongmasa04563aa2017-03-09 07:02:01 -080017#include <gui/bufferqueue/1.0/H2BGraphicBufferProducer.h>
Pawin Vongmasaac7d4122017-03-01 05:48:42 -080018#include <media/omx/1.0/WOmx.h>
19#include <media/omx/1.0/WOmxNode.h>
20#include <media/omx/1.0/WOmxObserver.h>
Pawin Vongmasaac7d4122017-03-01 05:48:42 -080021#include <media/omx/1.0/WGraphicBufferSource.h>
22#include <media/omx/1.0/Conversion.h>
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080023
24namespace android {
25namespace hardware {
26namespace media {
27namespace omx {
28namespace V1_0 {
29namespace utils {
30
Pawin Vongmasa04563aa2017-03-09 07:02:01 -080031using ::android::hardware::graphics::bufferqueue::V1_0::utils::
32 H2BGraphicBufferProducer;
33typedef ::android::hardware::graphics::bufferqueue::V1_0::IGraphicBufferProducer
34 HGraphicBufferProducer;
35
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080036// LWOmx
37LWOmx::LWOmx(sp<IOmx> const& base) : mBase(base) {
38}
39
40status_t LWOmx::listNodes(List<IOMX::ComponentInfo>* list) {
41 status_t fnStatus;
42 status_t transStatus = toStatusT(mBase->listNodes(
43 [&fnStatus, list](
44 Status status,
45 hidl_vec<IOmx::ComponentInfo> const& nodeList) {
46 fnStatus = toStatusT(status);
47 list->clear();
48 for (size_t i = 0; i < nodeList.size(); ++i) {
49 auto newInfo = list->insert(
50 list->end(), IOMX::ComponentInfo());
51 convertTo(&*newInfo, nodeList[i]);
52 }
53 }));
54 return transStatus == NO_ERROR ? fnStatus : transStatus;
55}
56
57status_t LWOmx::allocateNode(
58 char const* name,
59 sp<IOMXObserver> const& observer,
60 sp<IOMXNode>* omxNode) {
61 status_t fnStatus;
62 status_t transStatus = toStatusT(mBase->allocateNode(
63 name, new TWOmxObserver(observer),
64 [&fnStatus, omxNode](Status status, sp<IOmxNode> const& node) {
65 fnStatus = toStatusT(status);
66 *omxNode = new LWOmxNode(node);
67 }));
68 return transStatus == NO_ERROR ? fnStatus : transStatus;
69}
70
71status_t LWOmx::createInputSurface(
72 sp<::android::IGraphicBufferProducer>* bufferProducer,
73 sp<::android::IGraphicBufferSource>* bufferSource) {
74 status_t fnStatus;
75 status_t transStatus = toStatusT(mBase->createInputSurface(
76 [&fnStatus, bufferProducer, bufferSource] (
77 Status status,
Pawin Vongmasa04563aa2017-03-09 07:02:01 -080078 sp<HGraphicBufferProducer> const& tProducer,
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080079 sp<IGraphicBufferSource> const& tSource) {
80 fnStatus = toStatusT(status);
Pawin Vongmasa04563aa2017-03-09 07:02:01 -080081 *bufferProducer = new H2BGraphicBufferProducer(tProducer);
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080082 *bufferSource = new LWGraphicBufferSource(tSource);
83 }));
84 return transStatus == NO_ERROR ? fnStatus : transStatus;
85}
86
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080087} // namespace utils
88} // namespace V1_0
89} // namespace omx
90} // namespace media
91} // namespace hardware
92} // namespace android