blob: 247c540998fffcb83c2e483f18d40053c872426a [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
Rachad Alaoa6331ba2017-03-10 20:54:33 +000017#include <stagefright/foundation/ColorUtils.h>
18
Pawin Vongmasaac7d4122017-03-01 05:48:42 -080019#include <media/omx/1.0/WGraphicBufferSource.h>
20#include <media/omx/1.0/WOmxNode.h>
21#include <media/omx/1.0/Conversion.h>
Pawin Vongmasa0d3a5ed2017-02-22 03:19:35 -080022
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080023namespace android {
24namespace hardware {
25namespace media {
26namespace omx {
27namespace V1_0 {
28namespace utils {
29
Rachad Alaoa6331ba2017-03-10 20:54:33 +000030using android::ColorUtils;
31
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080032// LWGraphicBufferSource
33LWGraphicBufferSource::LWGraphicBufferSource(
34 sp<TGraphicBufferSource> const& base) : mBase(base) {
35}
36
Rachad Alaoa6331ba2017-03-10 20:54:33 +000037::android::binder::Status LWGraphicBufferSource::configure(
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080038 const sp<IOMXNode>& omxNode, int32_t dataSpace) {
Pawin Vongmasaac7d4122017-03-01 05:48:42 -080039 sp<IOmxNode> hOmxNode = omxNode->getHalInterface();
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080040 return toBinderStatus(mBase->configure(
Pawin Vongmasaac7d4122017-03-01 05:48:42 -080041 hOmxNode == nullptr ? new TWOmxNode(omxNode) : hOmxNode,
42 toHardwareDataspace(dataSpace)));
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080043}
44
Rachad Alaoa6331ba2017-03-10 20:54:33 +000045::android::binder::Status LWGraphicBufferSource::setSuspend(
Hangyu Kuang764d9452016-12-13 13:07:45 -080046 bool suspend, int64_t timeUs) {
47 return toBinderStatus(mBase->setSuspend(suspend, timeUs));
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080048}
49
Rachad Alaoa6331ba2017-03-10 20:54:33 +000050::android::binder::Status LWGraphicBufferSource::setRepeatPreviousFrameDelayUs(
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080051 int64_t repeatAfterUs) {
52 return toBinderStatus(mBase->setRepeatPreviousFrameDelayUs(repeatAfterUs));
53}
54
Rachad Alaoa6331ba2017-03-10 20:54:33 +000055::android::binder::Status LWGraphicBufferSource::setMaxFps(float maxFps) {
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080056 return toBinderStatus(mBase->setMaxFps(maxFps));
57}
58
Rachad Alaoa6331ba2017-03-10 20:54:33 +000059::android::binder::Status LWGraphicBufferSource::setTimeLapseConfig(
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080060 int64_t timePerFrameUs, int64_t timePerCaptureUs) {
61 return toBinderStatus(mBase->setTimeLapseConfig(
62 timePerFrameUs, timePerCaptureUs));
63}
64
Rachad Alaoa6331ba2017-03-10 20:54:33 +000065::android::binder::Status LWGraphicBufferSource::setStartTimeUs(
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080066 int64_t startTimeUs) {
67 return toBinderStatus(mBase->setStartTimeUs(startTimeUs));
68}
69
Rachad Alaoa6331ba2017-03-10 20:54:33 +000070::android::binder::Status LWGraphicBufferSource::setStopTimeUs(
Hangyu Kuang764d9452016-12-13 13:07:45 -080071 int64_t stopTimeUs) {
72 return toBinderStatus(mBase->setStopTimeUs(stopTimeUs));
73}
74
Rachad Alaoa6331ba2017-03-10 20:54:33 +000075::android::binder::Status LWGraphicBufferSource::setColorAspects(
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080076 int32_t aspects) {
77 return toBinderStatus(mBase->setColorAspects(
78 toHardwareColorAspects(aspects)));
79}
80
Rachad Alaoa6331ba2017-03-10 20:54:33 +000081::android::binder::Status LWGraphicBufferSource::setTimeOffsetUs(
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080082 int64_t timeOffsetsUs) {
83 return toBinderStatus(mBase->setTimeOffsetUs(timeOffsetsUs));
84}
85
Rachad Alaoa6331ba2017-03-10 20:54:33 +000086::android::binder::Status LWGraphicBufferSource::signalEndOfInputStream() {
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080087 return toBinderStatus(mBase->signalEndOfInputStream());
88}
89
Rachad Alaoa6331ba2017-03-10 20:54:33 +000090// TWGraphicBufferSource
91TWGraphicBufferSource::TWGraphicBufferSource(
92 sp<LGraphicBufferSource> const& base) : mBase(base) {
93}
94
95Return<void> TWGraphicBufferSource::configure(
96 const sp<IOmxNode>& omxNode, Dataspace dataspace) {
97 mBase->configure(new LWOmxNode(omxNode), toRawDataspace(dataspace));
98 return Void();
99}
100
101Return<void> TWGraphicBufferSource::setSuspend(
102 bool suspend, int64_t timeUs) {
103 mBase->setSuspend(suspend, timeUs);
104 return Void();
105}
106
107Return<void> TWGraphicBufferSource::setRepeatPreviousFrameDelayUs(
108 int64_t repeatAfterUs) {
109 mBase->setRepeatPreviousFrameDelayUs(repeatAfterUs);
110 return Void();
111}
112
113Return<void> TWGraphicBufferSource::setMaxFps(float maxFps) {
114 mBase->setMaxFps(maxFps);
115 return Void();
116}
117
118Return<void> TWGraphicBufferSource::setTimeLapseConfig(
119 int64_t timePerFrameUs, int64_t timePerCaptureUs) {
120 mBase->setTimeLapseConfig(timePerFrameUs, timePerCaptureUs);
121 return Void();
122}
123
124Return<void> TWGraphicBufferSource::setStartTimeUs(int64_t startTimeUs) {
125 mBase->setStartTimeUs(startTimeUs);
126 return Void();
127}
128
129Return<void> TWGraphicBufferSource::setStopTimeUs(int64_t stopTimeUs) {
130 mBase->setStopTimeUs(stopTimeUs);
131 return Void();
132}
133
134Return<void> TWGraphicBufferSource::setColorAspects(
135 const ColorAspects& aspects) {
136 mBase->setColorAspects(toCompactColorAspects(aspects));
137 return Void();
138}
139
140Return<void> TWGraphicBufferSource::setTimeOffsetUs(int64_t timeOffsetUs) {
141 mBase->setTimeOffsetUs(timeOffsetUs);
142 return Void();
143}
144
145Return<void> TWGraphicBufferSource::signalEndOfInputStream() {
146 mBase->signalEndOfInputStream();
147 return Void();
148}
149
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -0800150} // namespace utils
151} // namespace V1_0
152} // namespace omx
153} // namespace media
154} // namespace hardware
155} // namespace android