blob: 8e4e14763e90fbe8ab9ee23aaefb0f5ba6697e2c [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 Vongmasaac7d4122017-03-01 05:48:42 -080017#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 Vongmasaeeac97b2017-01-18 05:03:07 -080023
24namespace android {
25namespace hardware {
26namespace media {
27namespace omx {
28namespace V1_0 {
29namespace utils {
30
31// LWOmx
32LWOmx::LWOmx(sp<IOmx> const& base) : mBase(base) {
33}
34
35status_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
52status_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
66status_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 Vongmasaeeac97b2017-01-18 05:03:07 -080082} // namespace utils
83} // namespace V1_0
84} // namespace omx
85} // namespace media
86} // namespace hardware
87} // namespace android