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 | 26f2026 | 2017-02-16 17:02:59 -0800 | [diff] [blame] | 17 | #define LOG_TAG "WOmxObserver-utils" |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 18 | |
| 19 | #include <vector> |
| 20 | |
Pawin Vongmasa | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame^] | 21 | #include <utils/Log.h> |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 22 | #include <cutils/native_handle.h> |
Pawin Vongmasa | 0d3a5ed | 2017-02-22 03:19:35 -0800 | [diff] [blame] | 23 | #include <binder/Binder.h> |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 24 | |
Pawin Vongmasa | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame^] | 25 | #include <media/omx/1.0/WOmxObserver.h> |
| 26 | #include <media/omx/1.0/Conversion.h> |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | namespace hardware { |
| 30 | namespace media { |
| 31 | namespace omx { |
| 32 | namespace V1_0 { |
| 33 | namespace utils { |
| 34 | |
| 35 | // LWOmxObserver |
| 36 | LWOmxObserver::LWOmxObserver(sp<IOmxObserver> const& base) : mBase(base) { |
| 37 | } |
| 38 | |
| 39 | void LWOmxObserver::onMessages(std::list<omx_message> const& lMessages) { |
| 40 | hidl_vec<Message> tMessages; |
| 41 | std::vector<native_handle_t*> handles(lMessages.size()); |
| 42 | tMessages.resize(lMessages.size()); |
| 43 | size_t i = 0; |
| 44 | for (auto const& message : lMessages) { |
| 45 | wrapAs(&tMessages[i], &handles[i], message); |
| 46 | ++i; |
| 47 | } |
Pawin Vongmasa | 26f2026 | 2017-02-16 17:02:59 -0800 | [diff] [blame] | 48 | auto transResult = mBase->onMessages(tMessages); |
| 49 | if (!transResult.isOk()) { |
Pawin Vongmasa | ac7d412 | 2017-03-01 05:48:42 -0800 | [diff] [blame^] | 50 | ALOGE("LWOmxObserver::onMessages - Transaction failed"); |
Pawin Vongmasa | 26f2026 | 2017-02-16 17:02:59 -0800 | [diff] [blame] | 51 | } |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 52 | for (auto& handle : handles) { |
Pawin Vongmasa | 8a21c01 | 2016-12-27 04:30:54 +0700 | [diff] [blame] | 53 | native_handle_close(handle); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 54 | native_handle_delete(handle); |
| 55 | } |
| 56 | } |
| 57 | |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 58 | // TWOmxObserver |
| 59 | TWOmxObserver::TWOmxObserver(sp<IOMXObserver> const& base) : mBase(base) { |
| 60 | } |
| 61 | |
| 62 | Return<void> TWOmxObserver::onMessages(const hidl_vec<Message>& tMessages) { |
| 63 | std::list<omx_message> lMessages; |
| 64 | for (size_t i = 0; i < tMessages.size(); ++i) { |
| 65 | lMessages.push_back(omx_message{}); |
Pawin Vongmasa | 8a21c01 | 2016-12-27 04:30:54 +0700 | [diff] [blame] | 66 | convertTo(&lMessages.back(), tMessages[i]); |
Pawin Vongmasa | eeac97b | 2017-01-18 05:03:07 -0800 | [diff] [blame] | 67 | } |
| 68 | mBase->onMessages(lMessages); |
| 69 | return Return<void>(); |
| 70 | } |
| 71 | |
| 72 | } // namespace utils |
| 73 | } // namespace V1_0 |
| 74 | } // namespace omx |
| 75 | } // namespace media |
| 76 | } // namespace hardware |
| 77 | } // namespace android |