Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 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 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 17 | #include <stagefright/foundation/ColorUtils.h> |
| 18 | |
Pawin Vongmasa | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame^] | 19 | #include <media/omx/1.0/WGraphicBufferSource.h> |
| 20 | #include <media/omx/1.0/WOmxNode.h> |
| 21 | #include <media/omx/1.0/Conversion.h> |
Pawin Vongmasa | 0d3a5ed | 2017-02-22 03:19:35 -0800 | [diff] [blame] | 22 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 23 | namespace android { |
| 24 | namespace hardware { |
| 25 | namespace media { |
| 26 | namespace omx { |
| 27 | namespace V1_0 { |
| 28 | namespace utils { |
| 29 | |
| 30 | using android::ColorUtils; |
| 31 | |
| 32 | // LWGraphicBufferSource |
| 33 | LWGraphicBufferSource::LWGraphicBufferSource( |
| 34 | sp<TGraphicBufferSource> const& base) : mBase(base) { |
| 35 | } |
| 36 | |
| 37 | ::android::binder::Status LWGraphicBufferSource::configure( |
| 38 | const sp<IOMXNode>& omxNode, int32_t dataSpace) { |
Pawin Vongmasa | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame^] | 39 | sp<IOmxNode> hOmxNode = omxNode->getHalInterface(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 40 | return toBinderStatus(mBase->configure( |
Pawin Vongmasa | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame^] | 41 | hOmxNode == nullptr ? new TWOmxNode(omxNode) : hOmxNode, |
| 42 | toHardwareDataspace(dataSpace))); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 43 | } |
| 44 | |
Hangyu Kuang | 764d945 | 2016-12-13 13:07:45 -0800 | [diff] [blame] | 45 | ::android::binder::Status LWGraphicBufferSource::setSuspend( |
| 46 | bool suspend, int64_t timeUs) { |
| 47 | return toBinderStatus(mBase->setSuspend(suspend, timeUs)); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | ::android::binder::Status LWGraphicBufferSource::setRepeatPreviousFrameDelayUs( |
| 51 | int64_t repeatAfterUs) { |
| 52 | return toBinderStatus(mBase->setRepeatPreviousFrameDelayUs(repeatAfterUs)); |
| 53 | } |
| 54 | |
| 55 | ::android::binder::Status LWGraphicBufferSource::setMaxFps(float maxFps) { |
| 56 | return toBinderStatus(mBase->setMaxFps(maxFps)); |
| 57 | } |
| 58 | |
| 59 | ::android::binder::Status LWGraphicBufferSource::setTimeLapseConfig( |
| 60 | int64_t timePerFrameUs, int64_t timePerCaptureUs) { |
| 61 | return toBinderStatus(mBase->setTimeLapseConfig( |
| 62 | timePerFrameUs, timePerCaptureUs)); |
| 63 | } |
| 64 | |
| 65 | ::android::binder::Status LWGraphicBufferSource::setStartTimeUs( |
| 66 | int64_t startTimeUs) { |
| 67 | return toBinderStatus(mBase->setStartTimeUs(startTimeUs)); |
| 68 | } |
| 69 | |
Hangyu Kuang | 764d945 | 2016-12-13 13:07:45 -0800 | [diff] [blame] | 70 | ::android::binder::Status LWGraphicBufferSource::setStopTimeUs( |
| 71 | int64_t stopTimeUs) { |
| 72 | return toBinderStatus(mBase->setStopTimeUs(stopTimeUs)); |
| 73 | } |
| 74 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 75 | ::android::binder::Status LWGraphicBufferSource::setColorAspects( |
| 76 | int32_t aspects) { |
| 77 | return toBinderStatus(mBase->setColorAspects( |
| 78 | toHardwareColorAspects(aspects))); |
| 79 | } |
| 80 | |
| 81 | ::android::binder::Status LWGraphicBufferSource::setTimeOffsetUs( |
| 82 | int64_t timeOffsetsUs) { |
| 83 | return toBinderStatus(mBase->setTimeOffsetUs(timeOffsetsUs)); |
| 84 | } |
| 85 | |
| 86 | ::android::binder::Status LWGraphicBufferSource::signalEndOfInputStream() { |
| 87 | return toBinderStatus(mBase->signalEndOfInputStream()); |
| 88 | } |
| 89 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 90 | // TWGraphicBufferSource |
| 91 | TWGraphicBufferSource::TWGraphicBufferSource( |
| 92 | sp<LGraphicBufferSource> const& base) : mBase(base) { |
| 93 | } |
| 94 | |
| 95 | Return<void> TWGraphicBufferSource::configure( |
| 96 | const sp<IOmxNode>& omxNode, Dataspace dataspace) { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 97 | mBase->configure(new LWOmxNode(omxNode), toRawDataspace(dataspace)); |
| 98 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 99 | } |
| 100 | |
Pawin Vongmasa | 0d3a5ed | 2017-02-22 03:19:35 -0800 | [diff] [blame] | 101 | Return<void> TWGraphicBufferSource::setSuspend( |
| 102 | bool suspend, int64_t timeUs) { |
Hangyu Kuang | 764d945 | 2016-12-13 13:07:45 -0800 | [diff] [blame] | 103 | mBase->setSuspend(suspend, timeUs); |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 104 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | Return<void> TWGraphicBufferSource::setRepeatPreviousFrameDelayUs( |
| 108 | int64_t repeatAfterUs) { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 109 | mBase->setRepeatPreviousFrameDelayUs(repeatAfterUs); |
| 110 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | Return<void> TWGraphicBufferSource::setMaxFps(float maxFps) { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 114 | mBase->setMaxFps(maxFps); |
| 115 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | Return<void> TWGraphicBufferSource::setTimeLapseConfig( |
| 119 | int64_t timePerFrameUs, int64_t timePerCaptureUs) { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 120 | mBase->setTimeLapseConfig(timePerFrameUs, timePerCaptureUs); |
| 121 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | Return<void> TWGraphicBufferSource::setStartTimeUs(int64_t startTimeUs) { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 125 | mBase->setStartTimeUs(startTimeUs); |
| 126 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 127 | } |
| 128 | |
Hangyu Kuang | 764d945 | 2016-12-13 13:07:45 -0800 | [diff] [blame] | 129 | Return<void> TWGraphicBufferSource::setStopTimeUs(int64_t stopTimeUs) { |
Pawin Vongmasa | 223b8e3 | 2017-02-22 20:32:25 -0800 | [diff] [blame] | 130 | mBase->setStopTimeUs(stopTimeUs); |
| 131 | return Void(); |
Hangyu Kuang | 764d945 | 2016-12-13 13:07:45 -0800 | [diff] [blame] | 132 | } |
| 133 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 134 | Return<void> TWGraphicBufferSource::setColorAspects( |
| 135 | const ColorAspects& aspects) { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 136 | mBase->setColorAspects(toCompactColorAspects(aspects)); |
| 137 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | Return<void> TWGraphicBufferSource::setTimeOffsetUs(int64_t timeOffsetUs) { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 141 | mBase->setTimeOffsetUs(timeOffsetUs); |
| 142 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | Return<void> TWGraphicBufferSource::signalEndOfInputStream() { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 146 | mBase->signalEndOfInputStream(); |
| 147 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | } // namespace utils |
| 151 | } // namespace V1_0 |
| 152 | } // namespace omx |
| 153 | } // namespace media |
| 154 | } // namespace hardware |
| 155 | } // namespace android |