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 | 0d3a5ed | 2017-02-22 03:19:35 -0800 | [diff] [blame] | 17 | #include <utils/String8.h> |
| 18 | |
Pawin Vongmasa | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame^] | 19 | #include <media/omx/1.0/WOmxBufferSource.h> |
| 20 | #include <media/omx/1.0/Conversion.h> |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 21 | |
| 22 | namespace android { |
| 23 | namespace hardware { |
| 24 | namespace media { |
| 25 | namespace omx { |
| 26 | namespace V1_0 { |
| 27 | namespace utils { |
| 28 | |
| 29 | // LWOmxBufferSource |
| 30 | LWOmxBufferSource::LWOmxBufferSource(sp<IOmxBufferSource> const& base) : |
| 31 | mBase(base) { |
| 32 | } |
| 33 | |
| 34 | ::android::binder::Status LWOmxBufferSource::onOmxExecuting() { |
| 35 | return toBinderStatus(mBase->onOmxExecuting()); |
| 36 | } |
| 37 | |
| 38 | ::android::binder::Status LWOmxBufferSource::onOmxIdle() { |
| 39 | return toBinderStatus(mBase->onOmxIdle()); |
| 40 | } |
| 41 | |
| 42 | ::android::binder::Status LWOmxBufferSource::onOmxLoaded() { |
| 43 | return toBinderStatus(mBase->onOmxLoaded()); |
| 44 | } |
| 45 | |
| 46 | ::android::binder::Status LWOmxBufferSource::onInputBufferAdded( |
| 47 | int32_t bufferId) { |
| 48 | return toBinderStatus(mBase->onInputBufferAdded( |
| 49 | static_cast<uint32_t>(bufferId))); |
| 50 | } |
| 51 | |
| 52 | ::android::binder::Status LWOmxBufferSource::onInputBufferEmptied( |
| 53 | int32_t bufferId, OMXFenceParcelable const& fenceParcel) { |
| 54 | hidl_handle fence; |
| 55 | native_handle_t* fenceNh; |
| 56 | if (!wrapAs(&fence, &fenceNh, fenceParcel)) { |
| 57 | return ::android::binder::Status::fromExceptionCode( |
| 58 | ::android::binder::Status::EX_BAD_PARCELABLE, |
| 59 | "Invalid fence"); |
| 60 | } |
| 61 | ::android::binder::Status status = toBinderStatus( |
| 62 | mBase->onInputBufferEmptied( |
| 63 | static_cast<uint32_t>(bufferId), fence)); |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 64 | native_handle_close(fenceNh); |
| 65 | native_handle_delete(fenceNh); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 66 | return status; |
| 67 | } |
| 68 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 69 | // TWOmxBufferSource |
| 70 | TWOmxBufferSource::TWOmxBufferSource(sp<IOMXBufferSource> const& base) : |
| 71 | mBase(base) { |
| 72 | } |
| 73 | |
| 74 | Return<void> TWOmxBufferSource::onOmxExecuting() { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 75 | mBase->onOmxExecuting(); |
| 76 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | Return<void> TWOmxBufferSource::onOmxIdle() { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 80 | mBase->onOmxIdle(); |
| 81 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | Return<void> TWOmxBufferSource::onOmxLoaded() { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 85 | mBase->onOmxLoaded(); |
| 86 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | Return<void> TWOmxBufferSource::onInputBufferAdded(uint32_t buffer) { |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 90 | mBase->onInputBufferAdded(int32_t(buffer)); |
| 91 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | Return<void> TWOmxBufferSource::onInputBufferEmptied( |
| 95 | uint32_t buffer, hidl_handle const& fence) { |
| 96 | OMXFenceParcelable fenceParcelable; |
| 97 | if (!convertTo(&fenceParcelable, fence)) { |
Pawin Vongmasa | 223b8e3 | 2017-02-22 20:32:25 -0800 | [diff] [blame] | 98 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 99 | } |
Pawin Vongmasa | 8ff4018 | 2017-02-07 02:22:34 -0800 | [diff] [blame] | 100 | mBase->onInputBufferEmptied(int32_t(buffer), fenceParcelable); |
| 101 | return Void(); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | } // namespace utils |
| 105 | } // namespace V1_0 |
| 106 | } // namespace omx |
| 107 | } // namespace media |
| 108 | } // namespace hardware |
| 109 | } // namespace android |