Amy Zhang | 6bfeaa0 | 2020-11-30 15:16:39 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2020 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 | #define LOG_TAG "FrontendClient" |
| 18 | |
| 19 | #include <android-base/logging.h> |
| 20 | #include <utils/Log.h> |
| 21 | |
| 22 | #include "DemuxClient.h" |
| 23 | |
| 24 | using ::aidl::android::media::tv::tuner::TunerFrontendSettings; |
| 25 | |
| 26 | using ::android::hardware::tv::tuner::V1_0::Result; |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | /////////////// DemuxClient /////////////////////// |
| 31 | |
| 32 | // TODO: pending aidl interface |
| 33 | DemuxClient::DemuxClient() { |
| 34 | //mTunerDemux = tunerDemux; |
| 35 | } |
| 36 | |
| 37 | DemuxClient::~DemuxClient() { |
| 38 | //mTunerDemux = NULL; |
| 39 | mDemux = NULL; |
| 40 | } |
| 41 | |
| 42 | // TODO: remove after migration to Tuner Service is done. |
| 43 | void DemuxClient::setHidlDemux(sp<IDemux> demux) { |
| 44 | mDemux = demux; |
| 45 | } |
| 46 | |
| 47 | Result DemuxClient::setFrontendDataSource(sp<FrontendClient> tunerFrontend) { |
| 48 | // TODO: pending aidl interface |
| 49 | /*if (mTunerDemux != NULL) { |
| 50 | // TODO: handle error message |
| 51 | mTunerDemux->setFrontendDataSource(tunerFrontend->getAidlFrontend()); |
| 52 | return (int) Result::SUCCESS; |
| 53 | }*/ |
| 54 | |
| 55 | if (mDemux != NULL) { |
| 56 | Result res = mDemux->setFrontendDataSource(tunerFrontend->getId()); |
| 57 | return res; |
| 58 | } |
| 59 | |
| 60 | return Result::INVALID_STATE; |
| 61 | } |
| 62 | |
| 63 | //FilterClient openFilter(int mainType, int subType, int bufferSize, FilterClientCallback cb); |
| 64 | |
| 65 | int DemuxClient::getAvSyncHwId(FilterClient /*tunerFilter*/) { |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | long DemuxClient::getAvSyncTime(int avSyncHwId) { |
| 70 | // pending aidl interface |
| 71 | |
| 72 | if (mDemux != NULL) { |
| 73 | uint64_t time; |
| 74 | Result res; |
| 75 | mDemux->getAvSyncTime(static_cast<uint32_t>(avSyncHwId), |
| 76 | [&](Result r, uint64_t ts) { |
| 77 | res = r; |
| 78 | time = ts; |
| 79 | }); |
| 80 | if (res == Result::SUCCESS) { |
| 81 | return (long) time; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | return -1; |
| 86 | } |
| 87 | |
| 88 | //DvrClient openDvr(int dvbType, int bufferSize, DvrClientCallback cb); |
| 89 | |
| 90 | Result DemuxClient::connectCiCam(int ciCamId) { |
| 91 | // pending aidl interface |
| 92 | |
| 93 | if (mDemux != NULL) { |
| 94 | return mDemux->connectCiCam(static_cast<uint32_t>(ciCamId)); |
| 95 | } |
| 96 | |
| 97 | return Result::INVALID_STATE; |
| 98 | } |
| 99 | |
| 100 | Result DemuxClient::disconnectCiCam() { |
| 101 | // pending aidl interface |
| 102 | |
| 103 | if (mDemux != NULL) { |
| 104 | return mDemux->disconnectCiCam(); |
| 105 | } |
| 106 | |
| 107 | return Result::INVALID_STATE; |
| 108 | } |
| 109 | |
| 110 | Result DemuxClient::close() { |
| 111 | // pending aidl interface |
| 112 | |
| 113 | if (mDemux != NULL) { |
| 114 | Result res = mDemux->close(); |
| 115 | if (res == Result::SUCCESS) { |
| 116 | mDemux = NULL; |
| 117 | } |
| 118 | return res; |
| 119 | } |
| 120 | |
| 121 | return Result::INVALID_STATE; |
| 122 | } |
| 123 | } // namespace android |