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
17 #include <gui/bufferqueue/1.0/H2BGraphicBufferProducer.h>
18 #include <media/omx/1.0/WOmx.h>
19 #include <media/omx/1.0/WOmxNode.h>
20 #include <media/omx/1.0/WOmxObserver.h>
21 #include <media/omx/1.0/Conversion.h>
22
23 namespace android {
24 namespace hardware {
25 namespace media {
26 namespace omx {
27 namespace V1_0 {
28 namespace utils {
29
30 using ::android::hardware::graphics::bufferqueue::V1_0::utils::
31 H2BGraphicBufferProducer;
32 typedef ::android::hardware::graphics::bufferqueue::V1_0::IGraphicBufferProducer
33 HGraphicBufferProducer;
34
35 // LWOmx
LWOmx(sp<IOmx> const & base)36 LWOmx::LWOmx(sp<IOmx> const& base) : mBase(base) {
37 }
38
listNodes(List<IOMX::ComponentInfo> * list)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
allocateNode(char const * name,sp<IOMXObserver> const & observer,sp<IOMXNode> * omxNode)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
createInputSurface(sp<::android::IGraphicBufferProducer> * bufferProducer,sp<::android::hardware::media::omx::V1_0::IGraphicBufferSource> * bufferSource)70 status_t LWOmx::createInputSurface(
71 sp<::android::IGraphicBufferProducer>* bufferProducer,
72 sp<::android::hardware::media::omx::V1_0::IGraphicBufferSource>* bufferSource) {
73 status_t fnStatus;
74 status_t transStatus = toStatusT(mBase->createInputSurface(
75 [&fnStatus, bufferProducer, bufferSource] (
76 Status status,
77 sp<HGraphicBufferProducer> const& tProducer,
78 sp<IGraphicBufferSource> const& tSource) {
79 fnStatus = toStatusT(status);
80 *bufferProducer = new H2BGraphicBufferProducer(tProducer);
81 *bufferSource = tSource;
82 }));
83 return transStatus == NO_ERROR ? fnStatus : transStatus;
84 }
85
86 } // namespace utils
87 } // namespace V1_0
88 } // namespace omx
89 } // namespace media
90 } // namespace hardware
91 } // namespace android
92