blob: 4bacdda3e0effe18036cfd8f7ab97d23bcdb1205 [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/Conversion.h>
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080022
23namespace android {
24namespace hardware {
25namespace media {
26namespace omx {
27namespace V1_0 {
28namespace utils {
29
Pawin Vongmasa04563aa2017-03-09 07:02:01 -080030using ::android::hardware::graphics::bufferqueue::V1_0::utils::
31 H2BGraphicBufferProducer;
32typedef ::android::hardware::graphics::bufferqueue::V1_0::IGraphicBufferProducer
33 HGraphicBufferProducer;
34
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080035// LWOmx
36LWOmx::LWOmx(sp<IOmx> const& base) : mBase(base) {
37}
38
39status_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
56status_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
70status_t LWOmx::createInputSurface(
71 sp<::android::IGraphicBufferProducer>* bufferProducer,
Wonsik Kim9917d4a2019-10-24 12:56:38 -070072 sp<::android::hardware::media::omx::V1_0::IGraphicBufferSource>* bufferSource) {
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080073 status_t fnStatus;
74 status_t transStatus = toStatusT(mBase->createInputSurface(
75 [&fnStatus, bufferProducer, bufferSource] (
76 Status status,
Pawin Vongmasa04563aa2017-03-09 07:02:01 -080077 sp<HGraphicBufferProducer> const& tProducer,
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080078 sp<IGraphicBufferSource> const& tSource) {
79 fnStatus = toStatusT(status);
Pawin Vongmasa04563aa2017-03-09 07:02:01 -080080 *bufferProducer = new H2BGraphicBufferProducer(tProducer);
Wonsik Kim9917d4a2019-10-24 12:56:38 -070081 *bufferSource = tSource;
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080082 }));
83 return transStatus == NO_ERROR ? fnStatus : transStatus;
84}
85
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080086} // namespace utils
87} // namespace V1_0
88} // namespace omx
89} // namespace media
90} // namespace hardware
91} // namespace android