Merge changes from topic "aidlize-aps"
* changes:
Convert IAudioPolicyService to AIDL
Small changes around AIDL conversion code
diff --git a/drm/libmediadrm/DrmHal.cpp b/drm/libmediadrm/DrmHal.cpp
index 295c459..501471c 100644
--- a/drm/libmediadrm/DrmHal.cpp
+++ b/drm/libmediadrm/DrmHal.cpp
@@ -1585,4 +1585,15 @@
return mPluginV1_4->requiresSecureDecoder(hidl_string(mime), hLevel);
}
+status_t DrmHal::setPlaybackId(Vector<uint8_t> const &sessionId, const char *playbackId) {
+ Mutex::Autolock autoLock(mLock);
+ if (mPluginV1_4 == NULL) {
+ return ERROR_UNSUPPORTED;
+ }
+ drm::V1_0::Status err = mPluginV1_4->setPlaybackId(
+ toHidlVec(sessionId),
+ hidl_string(playbackId));
+ return toStatusT(err);
+}
+
} // namespace android
diff --git a/drm/libmediadrm/include/mediadrm/DrmHal.h b/drm/libmediadrm/include/mediadrm/DrmHal.h
index 4705de0..2fd4d81 100644
--- a/drm/libmediadrm/include/mediadrm/DrmHal.h
+++ b/drm/libmediadrm/include/mediadrm/DrmHal.h
@@ -184,6 +184,10 @@
const char *mime,
DrmPlugin::SecurityLevel securityLevel) const;
+ virtual status_t setPlaybackId(
+ Vector<uint8_t> const &sessionId,
+ const char *playbackId);
+
// Methods of IDrmPluginListener
Return<void> sendEvent(EventType eventType,
const hidl_vec<uint8_t>& sessionId, const hidl_vec<uint8_t>& data);
diff --git a/drm/libmediadrm/include/mediadrm/IDrm.h b/drm/libmediadrm/include/mediadrm/IDrm.h
index c117cec..ed71eee 100644
--- a/drm/libmediadrm/include/mediadrm/IDrm.h
+++ b/drm/libmediadrm/include/mediadrm/IDrm.h
@@ -152,6 +152,10 @@
const char *mime,
DrmPlugin::SecurityLevel securityLevel) const = 0;
+ virtual status_t setPlaybackId(
+ Vector<uint8_t> const &sessionId,
+ const char *playbackId) = 0;
+
protected:
IDrm() {}
diff --git a/media/codec2/components/base/Android.bp b/media/codec2/components/base/Android.bp
index 0c8f4a4..cfdb9e7 100644
--- a/media/codec2/components/base/Android.bp
+++ b/media/codec2/components/base/Android.bp
@@ -102,9 +102,6 @@
config: {
cfi_assembly_support: true,
},
- diag: {
- cfi: true,
- },
},
}
diff --git a/media/codec2/components/hevc/Android.bp b/media/codec2/components/hevc/Android.bp
index 2858212..1be0cfc 100644
--- a/media/codec2/components/hevc/Android.bp
+++ b/media/codec2/components/hevc/Android.bp
@@ -3,6 +3,7 @@
defaults: [
"libcodec2_soft-defaults",
"libcodec2_soft_sanitize_signed-defaults",
+ "libcodec2_soft_sanitize_cfi-defaults",
],
srcs: ["C2SoftHevcDec.cpp"],
@@ -16,6 +17,7 @@
defaults: [
"libcodec2_soft-defaults",
"libcodec2_soft_sanitize_signed-defaults",
+ "libcodec2_soft_sanitize_cfi-defaults",
],
srcs: ["C2SoftHevcEnc.cpp"],
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index 8c1e712..c697b80 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -245,6 +245,14 @@
"buffer starvation on component.", mName);
}
}
+ int32_t cvo = 0;
+ if (buffer->meta()->findInt32("cvo", &cvo)) {
+ int32_t rotation = cvo % 360;
+ // change rotation to counter-clock wise.
+ rotation = ((rotation <= 0) ? 0 : 360) - rotation;
+ Mutexed<OutputSurface>::Locked output(mOutputSurface);
+ output->rotation[queuedFrameIndex] = rotation;
+ }
work->input.buffers.push_back(c2buffer);
queuedBuffers.push_back(c2buffer);
} else if (eos) {
@@ -695,6 +703,22 @@
c2Buffer->getInfo(C2StreamRotationInfo::output::PARAM_TYPE));
bool flip = rotation && (rotation->flip & 1);
uint32_t quarters = ((rotation ? rotation->value : 0) / 90) & 3;
+
+ {
+ Mutexed<OutputSurface>::Locked output(mOutputSurface);
+ if (output->surface == nullptr) {
+ ALOGI("[%s] cannot render buffer without surface", mName);
+ return OK;
+ }
+ int64_t frameIndex;
+ buffer->meta()->findInt64("frameIndex", &frameIndex);
+ if (output->rotation.count(frameIndex) != 0) {
+ auto it = output->rotation.find(frameIndex);
+ quarters = (it->second / 90) & 3;
+ output->rotation.erase(it);
+ }
+ }
+
uint32_t transform = 0;
switch (quarters) {
case 0: // no rotation
@@ -738,14 +762,6 @@
hdr10PlusInfo.reset();
}
- {
- Mutexed<OutputSurface>::Locked output(mOutputSurface);
- if (output->surface == nullptr) {
- ALOGI("[%s] cannot render buffer without surface", mName);
- return OK;
- }
- }
-
std::vector<C2ConstGraphicBlock> blocks = c2Buffer->data().graphicBlocks();
if (blocks.size() != 1u) {
ALOGD("[%s] expected 1 graphic block, but got %zu", mName, blocks.size());
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.h b/media/codec2/sfplugin/CCodecBufferChannel.h
index e2c9aaa..1ef21aa 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.h
+++ b/media/codec2/sfplugin/CCodecBufferChannel.h
@@ -288,6 +288,7 @@
sp<Surface> surface;
uint32_t generation;
int maxDequeueBuffers;
+ std::map<uint64_t, int> rotation;
};
Mutexed<OutputSurface> mOutputSurface;
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index dd28b6a..d656350 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -324,6 +324,7 @@
// Append information from the front stash entry to outBuffer.
(*outBuffer)->meta()->setInt64("timeUs", entry.timestamp);
(*outBuffer)->meta()->setInt32("flags", entry.flags);
+ (*outBuffer)->meta()->setInt64("frameIndex", entry.ordinal.frameIndex.peekll());
if (outputFormat) {
ALOGD("[%s] popFromStashAndRegister: output format changed to %s",
mName, outputFormat->debugString().c_str());
diff --git a/media/codecs/amrnb/enc/src/cor_h_x2.cpp b/media/codecs/amrnb/enc/src/cor_h_x2.cpp
index b4fd867..e32eb4a 100644
--- a/media/codecs/amrnb/enc/src/cor_h_x2.cpp
+++ b/media/codecs/amrnb/enc/src/cor_h_x2.cpp
@@ -240,7 +240,7 @@
Word16 j;
Word16 k;
Word32 s;
- Word32 y32[L_CODE];
+ Word32 y32[L_CODE]{};
Word32 max;
Word32 tot;
diff --git a/media/codecs/m4v_h263/enc/src/mp4enc_api.cpp b/media/codecs/m4v_h263/enc/src/mp4enc_api.cpp
index 30e4fda..4ea3c69 100644
--- a/media/codecs/m4v_h263/enc/src/mp4enc_api.cpp
+++ b/media/codecs/m4v_h263/enc/src/mp4enc_api.cpp
@@ -1582,7 +1582,7 @@
if (currLayer == 0)
{
video->forwardRefVop = tempForwRefVop; /* For P-Vop base only */
- video->forwardRefVop->refSelectCode = tempRefSelCode;
+ if (video->forwardRefVop != NULL) video->forwardRefVop->refSelectCode = tempRefSelCode;
}
return status;
diff --git a/media/libmedia/CharacterEncodingDetector.cpp b/media/libmedia/CharacterEncodingDetector.cpp
index 5c6b981..64ba977 100644
--- a/media/libmedia/CharacterEncodingDetector.cpp
+++ b/media/libmedia/CharacterEncodingDetector.cpp
@@ -268,7 +268,7 @@
ucnv_convertEx(mUtf8Conv, conv, &target, target + targetLength,
&source, source + strlen(source),
- NULL, NULL, NULL, NULL, TRUE, TRUE, &status);
+ NULL, NULL, NULL, NULL, true, true, &status);
if (U_FAILURE(status)) {
ALOGE("ucnv_convertEx failed: %d", status);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 8628edc..5b60bbf 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -746,9 +746,15 @@
mOutputBuffers.editItemAt(index) = buffer;
+ int64_t frameIndex;
+ bool frameIndexFound = buffer->meta()->findInt64("frameIndex", &frameIndex);
+
buffer->setRange(offset, size);
buffer->meta()->clear();
buffer->meta()->setInt64("timeUs", timeUs);
+ if (frameIndexFound) {
+ buffer->meta()->setInt64("frameIndex", frameIndex);
+ }
bool eos = flags & MediaCodec::BUFFER_FLAG_EOS;
// we do not expect CODECCONFIG or SYNCFRAME for decoder
diff --git a/media/libmediatranscoding/TranscodingClientManager.cpp b/media/libmediatranscoding/TranscodingClientManager.cpp
index 09afb1f..adc8bdb 100644
--- a/media/libmediatranscoding/TranscodingClientManager.cpp
+++ b/media/libmediatranscoding/TranscodingClientManager.cpp
@@ -135,12 +135,12 @@
} else if (in_clientUid < 0) {
return Status::ok();
} else if (in_clientUid != callingUid && !owner->isTrustedCaller(callingPid, callingUid)) {
- ALOGE("MediaTranscodingService::registerClient rejected (clientPid %d, clientUid %d) "
+ ALOGE("submitRequest rejected (clientPid %d, clientUid %d) "
"(don't trust callingUid %d)",
in_clientPid, in_clientUid, callingUid);
return STATUS_ERROR_FMT(
IMediaTranscodingService::ERROR_PERMISSION_DENIED,
- "MediaTranscodingService::registerClient rejected (clientPid %d, clientUid %d) "
+ "submitRequest rejected (clientPid %d, clientUid %d) "
"(don't trust callingUid %d)",
in_clientPid, in_clientUid, callingUid);
}
@@ -152,12 +152,12 @@
} else if (in_clientPid < 0) {
return Status::ok();
} else if (in_clientPid != callingPid && !owner->isTrustedCaller(callingPid, callingUid)) {
- ALOGE("MediaTranscodingService::registerClient rejected (clientPid %d, clientUid %d) "
+ ALOGE("submitRequest rejected (clientPid %d, clientUid %d) "
"(don't trust callingUid %d)",
in_clientPid, in_clientUid, callingUid);
return STATUS_ERROR_FMT(
IMediaTranscodingService::ERROR_PERMISSION_DENIED,
- "MediaTranscodingService::registerClient rejected (clientPid %d, clientUid %d) "
+ "submitRequest rejected (clientPid %d, clientUid %d) "
"(don't trust callingUid %d)",
in_clientPid, in_clientUid, callingUid);
}
diff --git a/media/libmediatranscoding/aidl/android/media/TranscodingRequestParcel.aidl b/media/libmediatranscoding/aidl/android/media/TranscodingRequestParcel.aidl
index 4b19f6a..7047073 100644
--- a/media/libmediatranscoding/aidl/android/media/TranscodingRequestParcel.aidl
+++ b/media/libmediatranscoding/aidl/android/media/TranscodingRequestParcel.aidl
@@ -33,11 +33,25 @@
*/
@utf8InCpp String sourceFilePath;
+ /*
+ * The filedescrptor of the sourceFilePath. If the source Fd is provided, transcoding service
+ * will use this fd instead of calling back to client side to open the sourceFilePath.
+ * -1 means not available.
+ */
+ int sourceFd = -1;
+
/**
* The absolute file path of the destination file.
*/
@utf8InCpp String destinationFilePath;
+ /*
+ * The filedescrptor of the destinationFilePath. If the destination Fd is provided, transcoding
+ * service will use this fd instead of calling back to client side to open the sourceFilePath.
+ * -1 means not available.
+ */
+ int destinationFd = -1;
+
/**
* The UID of the client that this transcoding request is for. Only privileged caller could
* set this Uid as only they could do the transcoding on behalf of the client.
diff --git a/media/libmediatranscoding/include/media/TranscodingRequest.h b/media/libmediatranscoding/include/media/TranscodingRequest.h
index 485403f..e782386 100644
--- a/media/libmediatranscoding/include/media/TranscodingRequest.h
+++ b/media/libmediatranscoding/include/media/TranscodingRequest.h
@@ -36,7 +36,9 @@
private:
void setTo(const TranscodingRequestParcel& parcel) {
sourceFilePath = parcel.sourceFilePath;
+ sourceFd = parcel.sourceFd;
destinationFilePath = parcel.destinationFilePath;
+ destinationFd = parcel.destinationFd;
clientUid = parcel.clientUid;
clientPid = parcel.clientPid;
clientPackageName = parcel.clientPackageName;
diff --git a/media/libstagefright/codecs/avcdec/Android.bp b/media/libstagefright/codecs/avcdec/Android.bp
index 61379d2..7ee3119 100644
--- a/media/libstagefright/codecs/avcdec/Android.bp
+++ b/media/libstagefright/codecs/avcdec/Android.bp
@@ -16,9 +16,6 @@
"signed-integer-overflow",
],
cfi: true,
- diag: {
- cfi: true,
- },
config: {
cfi_assembly_support: true,
},
diff --git a/media/libstagefright/codecs/avcenc/Android.bp b/media/libstagefright/codecs/avcenc/Android.bp
index aceaebf..94f214d 100644
--- a/media/libstagefright/codecs/avcenc/Android.bp
+++ b/media/libstagefright/codecs/avcenc/Android.bp
@@ -10,9 +10,6 @@
"signed-integer-overflow",
],
cfi: true,
- diag: {
- cfi: true,
- },
config: {
cfi_assembly_support: true,
},
diff --git a/media/libstagefright/codecs/hevcdec/Android.bp b/media/libstagefright/codecs/hevcdec/Android.bp
index ec436ce..ffad18c 100644
--- a/media/libstagefright/codecs/hevcdec/Android.bp
+++ b/media/libstagefright/codecs/hevcdec/Android.bp
@@ -17,6 +17,9 @@
"signed-integer-overflow",
],
cfi: true,
+ config: {
+ cfi_assembly_support: true,
+ },
},
// We need this because the current asm generates the following link error:
diff --git a/media/libstagefright/codecs/xaacdec/Android.bp b/media/libstagefright/codecs/xaacdec/Android.bp
index 2d90910..2706665 100644
--- a/media/libstagefright/codecs/xaacdec/Android.bp
+++ b/media/libstagefright/codecs/xaacdec/Android.bp
@@ -14,9 +14,6 @@
// integer_overflow: true,
misc_undefined: [ "signed-integer-overflow", "unsigned-integer-overflow", ],
cfi: true,
- diag: {
- cfi: true,
- },
config: {
cfi_assembly_support: true,
},
diff --git a/media/libstagefright/rtsp/AAVCAssembler.cpp b/media/libstagefright/rtsp/AAVCAssembler.cpp
index a0b66a7..cccb63a 100644
--- a/media/libstagefright/rtsp/AAVCAssembler.cpp
+++ b/media/libstagefright/rtsp/AAVCAssembler.cpp
@@ -25,6 +25,7 @@
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/avc_utils.h>
#include <media/stagefright/foundation/hexdump.h>
#include <stdint.h>
@@ -39,7 +40,9 @@
mNextExpectedSeqNo(0),
mAccessUnitDamaged(false),
mFirstIFrameProvided(false),
- mLastIFrameProvidedAtMs(0) {
+ mLastIFrameProvidedAtMs(0),
+ mWidth(0),
+ mHeight(0) {
}
AAVCAssembler::~AAVCAssembler() {
@@ -115,6 +118,8 @@
sp<ABuffer> buffer = *queue->begin();
uint32_t rtpTime;
CHECK(buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));
+ buffer->meta()->setObject("source", source);
+
int64_t startTime = source->mFirstSysTime / 1000;
int64_t nowTime = ALooper::GetNowUs() / 1000;
int64_t playedTime = nowTime - startTime;
@@ -224,6 +229,21 @@
}
}
+void AAVCAssembler::checkSpsUpdated(const sp<ABuffer> &buffer) {
+ const uint8_t *data = buffer->data();
+ unsigned nalType = data[0] & 0x1f;
+ if (nalType == 0x7) {
+ int32_t width = 0, height = 0;
+ FindAVCDimensions(buffer, &width, &height);
+ if (width != mWidth || height != mHeight) {
+ mFirstIFrameProvided = false;
+ mWidth = width;
+ mHeight = height;
+ ALOGD("found a new resolution (%u x %u)", mWidth, mHeight);
+ }
+ }
+}
+
void AAVCAssembler::checkIFrameProvided(const sp<ABuffer> &buffer) {
if (buffer->size() == 0) {
return;
@@ -231,26 +251,50 @@
const uint8_t *data = buffer->data();
unsigned nalType = data[0] & 0x1f;
if (nalType == 0x5) {
- mFirstIFrameProvided = true;
mLastIFrameProvidedAtMs = ALooper::GetNowUs() / 1000;
+ if (!mFirstIFrameProvided) {
+ mFirstIFrameProvided = true;
- uint32_t rtpTime;
- CHECK(buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));
- ALOGD("got First I-frame to be decoded. rtpTime=%u, size=%zu", rtpTime, buffer->size());
+ uint32_t rtpTime;
+ CHECK(buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));
+ ALOGD("got First I-frame to be decoded. rtpTime=%d, size=%zu", rtpTime, buffer->size());
+ }
}
}
+bool AAVCAssembler::dropFramesUntilIframe(const sp<ABuffer> &buffer) {
+ const uint8_t *data = buffer->data();
+ unsigned nalType = data[0] & 0x1f;
+ if (!mFirstIFrameProvided && nalType < 0x5) {
+ return true;
+ }
+
+ return false;
+}
+
void AAVCAssembler::addSingleNALUnit(const sp<ABuffer> &buffer) {
ALOGV("addSingleNALUnit of size %zu", buffer->size());
#if !LOG_NDEBUG
hexdump(buffer->data(), buffer->size());
#endif
+ checkSpsUpdated(buffer);
checkIFrameProvided(buffer);
uint32_t rtpTime;
CHECK(buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));
+ if (dropFramesUntilIframe(buffer)) {
+ sp<ARTPSource> source = nullptr;
+ buffer->meta()->findObject("source", (sp<android::RefBase>*)&source);
+ if (source != nullptr) {
+ ALOGD("Issued FIR to get the I-frame");
+ source->onIssueFIRByAssembler();
+ }
+ ALOGV("Dropping P-frame till I-frame provided. rtpTime %u", rtpTime);
+ return;
+ }
+
if (!mNALUnits.empty() && rtpTime != mAccessUnitRTPTime) {
submitAccessUnit();
}
@@ -431,6 +475,7 @@
size_t offset = 1;
int32_t cvo = -1;
+ sp<ARTPSource> source = nullptr;
List<sp<ABuffer> >::iterator it = queue->begin();
for (size_t i = 0; i < totalCount; ++i) {
const sp<ABuffer> &buffer = *it;
@@ -442,6 +487,7 @@
memcpy(unit->data() + offset, buffer->data() + 2, buffer->size() - 2);
+ buffer->meta()->findObject("source", (sp<android::RefBase>*)&source);
buffer->meta()->findInt32("cvo", &cvo);
offset += buffer->size() - 2;
@@ -453,6 +499,9 @@
if (cvo >= 0) {
unit->meta()->setInt32("cvo", cvo);
}
+ if (source != nullptr) {
+ unit->meta()->setObject("source", source);
+ }
addSingleNALUnit(unit);
diff --git a/media/libstagefright/rtsp/AAVCAssembler.h b/media/libstagefright/rtsp/AAVCAssembler.h
index 913a868..79fc7c2 100644
--- a/media/libstagefright/rtsp/AAVCAssembler.h
+++ b/media/libstagefright/rtsp/AAVCAssembler.h
@@ -48,10 +48,14 @@
bool mAccessUnitDamaged;
bool mFirstIFrameProvided;
uint64_t mLastIFrameProvidedAtMs;
+ int32_t mWidth;
+ int32_t mHeight;
List<sp<ABuffer> > mNALUnits;
int32_t addNack(const sp<ARTPSource> &source);
+ void checkSpsUpdated(const sp<ABuffer> &buffer);
void checkIFrameProvided(const sp<ABuffer> &buffer);
+ bool dropFramesUntilIframe(const sp<ABuffer> &buffer);
AssemblyStatus addNALUnit(const sp<ARTPSource> &source);
void addSingleNALUnit(const sp<ABuffer> &buffer);
AssemblyStatus addFragmentedNALUnit(List<sp<ABuffer> > *queue);
diff --git a/media/libstagefright/rtsp/ARTPConnection.cpp b/media/libstagefright/rtsp/ARTPConnection.cpp
index 07f9dd3..97a9bbb 100644
--- a/media/libstagefright/rtsp/ARTPConnection.cpp
+++ b/media/libstagefright/rtsp/ARTPConnection.cpp
@@ -678,14 +678,14 @@
const uint8_t *extensionData = &data[payloadOffset];
size_t extensionLength =
- 4 * (extensionData[2] << 8 | extensionData[3]);
+ (4 * (extensionData[2] << 8 | extensionData[3])) + 4;
- if (size < payloadOffset + 4 + extensionLength) {
+ if (size < payloadOffset + extensionLength) {
return -1;
}
parseRTPExt(s, (const uint8_t *)extensionData, extensionLength, &cvoDegrees);
- payloadOffset += 4 + extensionLength;
+ payloadOffset += extensionLength;
}
uint32_t srcId = u32at(&data[8]);
@@ -699,8 +699,9 @@
meta->setInt32("rtp-time", rtpTime);
meta->setInt32("PT", data[1] & 0x7f);
meta->setInt32("M", data[1] >> 7);
- if (cvoDegrees >= 0)
+ if (cvoDegrees >= 0) {
meta->setInt32("cvo", cvoDegrees);
+ }
buffer->setInt32Data(u16at(&data[2]));
buffer->setRange(payloadOffset, size - payloadOffset);
diff --git a/media/libstagefright/rtsp/ARTPSource.cpp b/media/libstagefright/rtsp/ARTPSource.cpp
index 6303fc4..c611f6f 100644
--- a/media/libstagefright/rtsp/ARTPSource.cpp
+++ b/media/libstagefright/rtsp/ARTPSource.cpp
@@ -226,7 +226,7 @@
// Send it if last FIR is not sent within a sec.
send = true;
} else if (mIssueFIRRequests && (usecsSinceLastFIR > 5000000)) {
- // A FIR issued periodically reagardless packet loss.
+ // A FIR issued periodically regardless packet loss.
// Send it if last FIR is not sent within 5 secs.
send = true;
}
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index d0ad22c..a92848c 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -794,22 +794,18 @@
struct stat sstat;
uint64_t finalsize;
bool transcode = android::base::GetBoolProperty("sys.fuse.transcode_mtp", true);
- if (!transcode) {
- ALOGD("Mtp transcode disabled");
- mfr.fd = mDatabase->openFilePath(filePath, false);
- // Doing this here because we want to update fileLength only for this case and leave the
- // regular path as unchanged as possible.
- if (mfr.fd >= 0) {
- fstat(mfr.fd, &sstat);
- finalsize = sstat.st_size;
- fileLength = finalsize;
- } else {
- ALOGW("Mtp open with no transcoding failed for %s. Falling back to the original",
- filePath);
- }
- }
+ ALOGD("Mtp transcode = %d", transcode);
+ mfr.fd = mDatabase->openFilePath(filePath, transcode);
+ // Doing this here because we want to update fileLength only for this case and leave the
+ // regular path as unchanged as possible.
+ if (mfr.fd >= 0) {
+ fstat(mfr.fd, &sstat);
+ finalsize = sstat.st_size;
+ fileLength = finalsize;
+ } else {
+ ALOGW("Mtp open via IMtpDatabase failed for %s. Falling back to the original",
+ filePath);
- if (transcode || mfr.fd < 0) {
mfr.fd = open(filePath, O_RDONLY);
if (mfr.fd < 0) {
return MTP_RESPONSE_GENERAL_ERROR;
diff --git a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
index 3d338ea..82cd6cf 100644
--- a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
@@ -65,6 +65,9 @@
bool supportsFormat(audio_format_t format);
+ void setDynamic() { mIsDynamic = true; }
+ bool isDynamic() const { return mIsDynamic; }
+
// PolicyAudioPortConfig
virtual sp<PolicyAudioPort> getPolicyAudioPort() const {
return static_cast<PolicyAudioPort*>(const_cast<DeviceDescriptor*>(this));
@@ -105,6 +108,8 @@
std::string mTagName; // Unique human readable identifier for a device port found in conf file.
FormatVector mEncodedFormats;
audio_format_t mCurrentEncodedFormat;
+ bool mIsDynamic = false;
+ const std::string mDeclaredAddress; // Original device address
};
class DeviceVector : public SortedVector<sp<DeviceDescriptor> >
diff --git a/services/audiopolicy/common/managerdefinitions/include/HwModule.h b/services/audiopolicy/common/managerdefinitions/include/HwModule.h
index 23f0c9a..9ba745a 100644
--- a/services/audiopolicy/common/managerdefinitions/include/HwModule.h
+++ b/services/audiopolicy/common/managerdefinitions/include/HwModule.h
@@ -52,8 +52,12 @@
devices.merge(mDynamicDevices);
return devices;
}
+ std::string getTagForDevice(audio_devices_t device,
+ const String8 &address = String8(),
+ audio_format_t codec = AUDIO_FORMAT_DEFAULT);
void addDynamicDevice(const sp<DeviceDescriptor> &device)
{
+ device->setDynamic();
mDynamicDevices.add(device);
}
@@ -131,8 +135,17 @@
public:
sp<HwModule> getModuleFromName(const char *name) const;
+ /**
+ * @brief getModuleForDeviceType try to get a device from type / format on all modules
+ * @param device type to consider
+ * @param encodedFormat to consider
+ * @param[out] tagName if not null, if a matching device is found, will return the tagName
+ * of original device from XML file so that audio routes matchin rules work.
+ * @return valid module if considered device found, nullptr otherwise.
+ */
sp<HwModule> getModuleForDeviceType(audio_devices_t device,
- audio_format_t encodedFormat) const;
+ audio_format_t encodedFormat,
+ std::string *tagName = nullptr) const;
sp<HwModule> getModuleForDevice(const sp<DeviceDescriptor> &device,
audio_format_t encodedFormat) const;
diff --git a/services/audiopolicy/common/managerdefinitions/include/IOProfile.h b/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
index a5cd534..a74cefa 100644
--- a/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
+++ b/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
@@ -112,6 +112,19 @@
}
/**
+ * @brief getTag
+ * @param deviceTypes to be considered
+ * @return tagName of first matching device for the considered types, empty string otherwise.
+ */
+ std::string getTag(const DeviceTypeSet& deviceTypes) const
+ {
+ if (supportsDeviceTypes(deviceTypes)) {
+ return mSupportedDevices.getDevicesFromTypes(deviceTypes).itemAt(0)->getTagName();
+ }
+ return {};
+ }
+
+ /**
* @brief supportsDevice
* @param device to be checked against
* forceCheckOnAddress if true, check on type and address whatever the type, otherwise
@@ -152,6 +165,12 @@
}
void removeSupportedDevice(const sp<DeviceDescriptor> &device)
{
+ ssize_t ret = mSupportedDevices.indexOf(device);
+ if (ret >= 0 && !mSupportedDevices.itemAt(ret)->isDynamic()) {
+ // devices equality checks only type, address, name and format
+ // Prevents from removing non dynamically added devices
+ return;
+ }
mSupportedDevices.remove(device);
}
void setSupportedDevices(const DeviceVector &devices)
diff --git a/services/audiopolicy/common/managerdefinitions/include/PolicyAudioPort.h b/services/audiopolicy/common/managerdefinitions/include/PolicyAudioPort.h
index d2f6297..e6eef24 100644
--- a/services/audiopolicy/common/managerdefinitions/include/PolicyAudioPort.h
+++ b/services/audiopolicy/common/managerdefinitions/include/PolicyAudioPort.h
@@ -42,6 +42,11 @@
virtual const std::string getTagName() const = 0;
+ bool equals(const sp<PolicyAudioPort> &right) const
+ {
+ return getTagName() == right->getTagName();
+ }
+
virtual sp<AudioPort> asAudioPort() const = 0;
virtual void setFlags(uint32_t flags)
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioRoute.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioRoute.cpp
index 2a18f19..c8e4e76 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioRoute.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioRoute.cpp
@@ -39,12 +39,12 @@
bool AudioRoute::supportsPatch(const sp<PolicyAudioPort> &srcPort,
const sp<PolicyAudioPort> &dstPort) const
{
- if (mSink == 0 || dstPort == 0 || dstPort != mSink) {
+ if (mSink == 0 || dstPort == 0 || !dstPort->equals(mSink)) {
return false;
}
ALOGV("%s: sinks %s matching", __FUNCTION__, mSink->getTagName().c_str());
for (const auto &sourcePort : mSources) {
- if (sourcePort == srcPort) {
+ if (sourcePort->equals(srcPort)) {
ALOGV("%s: sources %s matching", __FUNCTION__, sourcePort->getTagName().c_str());
return true;
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
index 6c31b79..3cfceba 100644
--- a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
@@ -49,10 +49,13 @@
{
}
+// Let DeviceDescriptorBase initialize the address since it handles specific cases like
+// legacy remote submix where "0" is added as default address.
DeviceDescriptor::DeviceDescriptor(const AudioDeviceTypeAddr &deviceTypeAddr,
const std::string &tagName,
const FormatVector &encodedFormats) :
- DeviceDescriptorBase(deviceTypeAddr), mTagName(tagName), mEncodedFormats(encodedFormats)
+ DeviceDescriptorBase(deviceTypeAddr), mTagName(tagName), mEncodedFormats(encodedFormats),
+ mDeclaredAddress(DeviceDescriptorBase::address())
{
mCurrentEncodedFormat = AUDIO_FORMAT_DEFAULT;
/* If framework runs against a pre 5.0 Audio HAL, encoded formats are absent from the config.
@@ -75,6 +78,10 @@
void DeviceDescriptor::detach() {
mId = AUDIO_PORT_HANDLE_NONE;
PolicyAudioPort::detach();
+ // The device address may have been overwritten on device connection
+ setAddress(mDeclaredAddress);
+ // Device Port does not have a name unless provided by setDeviceConnectionState
+ setName("");
}
template<typename T>
diff --git a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
index d31e443..3a143b0 100644
--- a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
@@ -41,6 +41,14 @@
}
}
+std::string HwModule::getTagForDevice(audio_devices_t device, const String8 &address,
+ audio_format_t codec)
+{
+ DeviceVector declaredDevices = getDeclaredDevices();
+ sp<DeviceDescriptor> deviceDesc = declaredDevices.getDevice(device, address, codec);
+ return deviceDesc ? deviceDesc->getTagName() : std::string{};
+}
+
status_t HwModule::addOutputProfile(const std::string& name, const audio_config_t *config,
audio_devices_t device, const String8& address)
{
@@ -49,7 +57,8 @@
profile->addAudioProfile(new AudioProfile(config->format, config->channel_mask,
config->sample_rate));
- sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device, "" /*tagName*/, address.string());
+ sp<DeviceDescriptor> devDesc =
+ new DeviceDescriptor(device, getTagForDevice(device), address.string());
addDynamicDevice(devDesc);
// Reciprocally attach the device to the module
devDesc->attach(this);
@@ -116,7 +125,8 @@
profile->addAudioProfile(new AudioProfile(config->format, config->channel_mask,
config->sample_rate));
- sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device, "" /*tagName*/, address.string());
+ sp<DeviceDescriptor> devDesc =
+ new DeviceDescriptor(device, getTagForDevice(device), address.string());
addDynamicDevice(devDesc);
// Reciprocally attach the device to the module
devDesc->attach(this);
@@ -271,8 +281,9 @@
return nullptr;
}
-sp <HwModule> HwModuleCollection::getModuleForDeviceType(audio_devices_t type,
- audio_format_t encodedFormat) const
+sp<HwModule> HwModuleCollection::getModuleForDeviceType(audio_devices_t type,
+ audio_format_t encodedFormat,
+ std::string *tagName) const
{
for (const auto& module : *this) {
const auto& profiles = audio_is_output_device(type) ?
@@ -284,9 +295,15 @@
sp <DeviceDescriptor> deviceDesc =
declaredDevices.getDevice(type, String8(), encodedFormat);
if (deviceDesc) {
+ if (tagName != nullptr) {
+ *tagName = deviceDesc->getTagName();
+ }
return module;
}
} else {
+ if (tagName != nullptr) {
+ *tagName = profile->getTag({type});
+ }
return module;
}
}
@@ -325,15 +342,32 @@
}
for (const auto& hwModule : *this) {
+ if (!allowToCreate) {
+ auto dynamicDevices = hwModule->getDynamicDevices();
+ auto dynamicDevice = dynamicDevices.getDevice(deviceType, devAddress, encodedFormat);
+ if (dynamicDevice) {
+ return dynamicDevice;
+ }
+ }
DeviceVector moduleDevices = hwModule->getAllDevices();
auto moduleDevice = moduleDevices.getDevice(deviceType, devAddress, encodedFormat);
+
+ // Prevent overwritting moduleDevice address if connected device does not have the same
+ // address (since getDevice with empty address ignores match on address), use dynamic device
+ if (moduleDevice && allowToCreate &&
+ (!moduleDevice->address().empty() &&
+ (moduleDevice->address().compare(devAddress.c_str()) != 0))) {
+ break;
+ }
if (moduleDevice) {
if (encodedFormat != AUDIO_FORMAT_DEFAULT) {
moduleDevice->setEncodedFormat(encodedFormat);
}
if (allowToCreate) {
moduleDevice->attach(hwModule);
+ // Name may be overwritten, restored on detach.
moduleDevice->setAddress(devAddress.string());
+ // Name may be overwritten, restored on detach.
moduleDevice->setName(name);
}
return moduleDevice;
@@ -352,18 +386,19 @@
const char *name,
const audio_format_t encodedFormat) const
{
- sp<HwModule> hwModule = getModuleForDeviceType(type, encodedFormat);
+ std::string tagName = {};
+ sp<HwModule> hwModule = getModuleForDeviceType(type, encodedFormat, &tagName);
if (hwModule == 0) {
ALOGE("%s: could not find HW module for device %04x address %s", __FUNCTION__, type,
address);
return nullptr;
}
- sp<DeviceDescriptor> device = new DeviceDescriptor(type, name, address);
+ sp<DeviceDescriptor> device = new DeviceDescriptor(type, tagName, address);
device->setName(name);
device->setEncodedFormat(encodedFormat);
-
- // Add the device to the list of dynamic devices
+ device->setDynamic();
+ // Add the device to the list of dynamic devices
hwModule->addDynamicDevice(device);
// Reciprocally attach the device to the module
device->attach(hwModule);
@@ -375,7 +410,7 @@
for (const auto &profile : profiles) {
// Add the device as supported to all profile supporting "weakly" or not the device
// according to its type
- if (profile->supportsDevice(device, false /*matchAdress*/)) {
+ if (profile->supportsDevice(device, false /*matchAddress*/)) {
// @todo quid of audio profile? import the profile from device of the same type?
const auto &isoTypeDeviceForProfile =
@@ -406,10 +441,9 @@
device->detach();
// Only remove from dynamic list, not from declared list!!!
- if (!hwModule->getDynamicDevices().contains(device)) {
+ if (!hwModule->removeDynamicDevice(device)) {
return;
}
- hwModule->removeDynamicDevice(device);
ALOGV("%s: removed dynamic device %s from module %s", __FUNCTION__,
device->toString().c_str(), hwModule->getName());
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index e80404b..db6d3cf 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -4694,6 +4694,10 @@
buffer.status = CAMERA_BUFFER_STATUS_OK;
buffer.acquire_fence = -1;
buffer.release_fence = -1;
+ // Mark the output stream as unpreparable to block clients from calling
+ // 'prepare' after this request reaches CameraHal and before the respective
+ // buffers are requested.
+ outputStream->markUnpreparable();
} else {
res = outputStream->getBuffer(&outputBuffers->editItemAt(j),
waitDuration,
diff --git a/services/camera/libcameraservice/device3/Camera3Stream.cpp b/services/camera/libcameraservice/device3/Camera3Stream.cpp
index 8d72b4c..ffdb90b 100644
--- a/services/camera/libcameraservice/device3/Camera3Stream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Stream.cpp
@@ -417,6 +417,13 @@
return mStreamUnpreparable;
}
+void Camera3Stream::markUnpreparable() {
+ ATRACE_CALL();
+
+ Mutex::Autolock l(mLock);
+ mStreamUnpreparable = true;
+}
+
status_t Camera3Stream::startPrepare(int maxCount, bool blockRequest) {
ATRACE_CALL();
diff --git a/services/camera/libcameraservice/device3/Camera3Stream.h b/services/camera/libcameraservice/device3/Camera3Stream.h
index 47dc252..72914f8 100644
--- a/services/camera/libcameraservice/device3/Camera3Stream.h
+++ b/services/camera/libcameraservice/device3/Camera3Stream.h
@@ -223,6 +223,11 @@
bool isUnpreparable();
/**
+ * Mark the stream as unpreparable.
+ */
+ void markUnpreparable() override;
+
+ /**
* Start stream preparation. May only be called in the CONFIGURED state,
* when no valid buffers have yet been returned to this stream. Prepares
* up to maxCount buffers, or the maximum number of buffers needed by the
diff --git a/services/camera/libcameraservice/device3/Camera3StreamInterface.h b/services/camera/libcameraservice/device3/Camera3StreamInterface.h
index b48636e..d417252 100644
--- a/services/camera/libcameraservice/device3/Camera3StreamInterface.h
+++ b/services/camera/libcameraservice/device3/Camera3StreamInterface.h
@@ -207,6 +207,11 @@
virtual bool isUnpreparable() = 0;
/**
+ * Mark the stream as unpreparable.
+ */
+ virtual void markUnpreparable() = 0;
+
+ /**
* Start stream preparation. May only be called in the CONFIGURED state,
* when no valid buffers have yet been returned to this stream. Prepares
* up to maxCount buffers, or the maximum number of buffers needed by the
diff --git a/services/tuner/Android.bp b/services/tuner/Android.bp
index edccbf7..6a21b0e 100644
--- a/services/tuner/Android.bp
+++ b/services/tuner/Android.bp
@@ -64,8 +64,7 @@
name: "libtunerservice",
srcs: [
- "TunerService.cpp",
- "TunerFrontend.cpp"
+ "Tuner*.cpp",
],
shared_libs: [
@@ -87,7 +86,7 @@
],
include_dirs: [
- "frameworks/av/include"
+ "frameworks/av/include"
],
cflags: [
diff --git a/services/tuner/TunerDemux.cpp b/services/tuner/TunerDemux.cpp
new file mode 100644
index 0000000..edd1802
--- /dev/null
+++ b/services/tuner/TunerDemux.cpp
@@ -0,0 +1,103 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "TunerDemux"
+
+#include "TunerDemux.h"
+#include "TunerFilter.h"
+
+using ::android::hardware::tv::tuner::V1_0::DemuxAlpFilterType;
+using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
+using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
+using ::android::hardware::tv::tuner::V1_0::DemuxIpFilterType;
+using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
+using ::android::hardware::tv::tuner::V1_0::DemuxTlvFilterType;
+using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
+using ::android::hardware::tv::tuner::V1_0::Result;
+
+namespace android {
+
+TunerDemux::TunerDemux(sp<IDemux> demux, int id) {
+ mDemux = demux;
+ mDemuxId = id;
+}
+
+TunerDemux::~TunerDemux() {
+ mDemux = nullptr;
+}
+
+Status TunerDemux::setFrontendDataSource(const std::shared_ptr<ITunerFrontend>& frontend) {
+ if (mDemux == nullptr) {
+ ALOGE("IDemux is not initialized");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ int frontendId;
+ frontend->getFrontendId(&frontendId);
+ Result res = mDemux->setFrontendDataSource(frontendId);
+ if (res != Result::SUCCESS) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
+ }
+ return Status::ok();
+}
+
+Status TunerDemux::openFilter(
+ int type, int subType, int bufferSize, const std::shared_ptr<ITunerFilterCallback>& cb,
+ std::shared_ptr<ITunerFilter>* _aidl_return) {
+ if (mDemux == nullptr) {
+ ALOGE("IDemux is not initialized.");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ DemuxFilterMainType mainType = static_cast<DemuxFilterMainType>(type);
+ DemuxFilterType filterType {
+ .mainType = mainType,
+ };
+
+ switch(mainType) {
+ case DemuxFilterMainType::TS:
+ filterType.subType.tsFilterType(static_cast<DemuxTsFilterType>(subType));
+ break;
+ case DemuxFilterMainType::MMTP:
+ filterType.subType.mmtpFilterType(static_cast<DemuxMmtpFilterType>(subType));
+ break;
+ case DemuxFilterMainType::IP:
+ filterType.subType.ipFilterType(static_cast<DemuxIpFilterType>(subType));
+ break;
+ case DemuxFilterMainType::TLV:
+ filterType.subType.tlvFilterType(static_cast<DemuxTlvFilterType>(subType));
+ break;
+ case DemuxFilterMainType::ALP:
+ filterType.subType.alpFilterType(static_cast<DemuxAlpFilterType>(subType));
+ break;
+ }
+ Result status;
+ sp<IFilter> filterSp;
+ sp<IFilterCallback> cbSp = new TunerFilter::FilterCallback(cb);
+ mDemux->openFilter(filterType, bufferSize, cbSp,
+ [&](Result r, const sp<IFilter>& filter) {
+ filterSp = filter;
+ status = r;
+ });
+ if (status != Result::SUCCESS) {
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ }
+
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerFilter>(filterSp, cbSp);
+ return Status::ok();
+}
+
+} // namespace android
diff --git a/services/tuner/TunerDemux.h b/services/tuner/TunerDemux.h
new file mode 100644
index 0000000..6eca8ab
--- /dev/null
+++ b/services/tuner/TunerDemux.h
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MEDIA_TUNERDEMUX_H
+#define ANDROID_MEDIA_TUNERDEMUX_H
+
+#include <aidl/android/media/tv/tuner/BnTunerDemux.h>
+#include <android/hardware/tv/tuner/1.0/ITuner.h>
+
+using Status = ::ndk::ScopedAStatus;
+using ::aidl::android::media::tv::tuner::BnTunerDemux;
+using ::aidl::android::media::tv::tuner::ITunerFilter;
+using ::aidl::android::media::tv::tuner::ITunerFilterCallback;
+using ::aidl::android::media::tv::tuner::ITunerFrontend;
+using ::android::hardware::tv::tuner::V1_0::IDemux;
+
+
+namespace android {
+
+class TunerDemux : public BnTunerDemux {
+
+public:
+ TunerDemux(sp<IDemux> demux, int demuxId);
+ virtual ~TunerDemux();
+ Status setFrontendDataSource(const std::shared_ptr<ITunerFrontend>& frontend) override;
+ Status openFilter(
+ int mainType, int subtype, int bufferSize, const std::shared_ptr<ITunerFilterCallback>& cb,
+ std::shared_ptr<ITunerFilter>* _aidl_return);
+
+private:
+ sp<IDemux> mDemux;
+ int mDemuxId;
+};
+
+} // namespace android
+
+#endif // ANDROID_MEDIA_TUNERDEMUX_H
diff --git a/services/tuner/TunerFilter.cpp b/services/tuner/TunerFilter.cpp
new file mode 100644
index 0000000..5a2f404
--- /dev/null
+++ b/services/tuner/TunerFilter.cpp
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "TunerFilter"
+
+#include "TunerFilter.h"
+
+using ::android::hardware::tv::tuner::V1_0::Result;
+
+namespace android {
+
+TunerFilter::TunerFilter(sp<IFilter> filter, sp<IFilterCallback> callback) {
+ mFilter = filter;
+ mFilterCallback = callback;
+}
+
+TunerFilter::~TunerFilter() {
+ mFilter = nullptr;
+ mFilterCallback = nullptr;
+}
+
+Status TunerFilter::getId(int32_t* _aidl_return) {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ Result res;
+ mFilter->getId([&](Result r, uint32_t filterId) {
+ res = r;
+ mId = filterId;
+ });
+ if (res != Result::SUCCESS) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
+ }
+ *_aidl_return = mId;
+ return Status::ok();
+}
+
+/////////////// FilterCallback ///////////////////////
+
+Return<void> TunerFilter::FilterCallback::onFilterStatus(DemuxFilterStatus status) {
+ mTunerFilterCallback->onFilterStatus((int)status);
+ return Void();
+}
+
+Return<void> TunerFilter::FilterCallback::onFilterEvent(const DemuxFilterEvent&) {
+ return Void();
+}
+
+} // namespace android
diff --git a/services/tuner/TunerFilter.h b/services/tuner/TunerFilter.h
new file mode 100644
index 0000000..54c618e
--- /dev/null
+++ b/services/tuner/TunerFilter.h
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MEDIA_TUNERFILTER_H
+#define ANDROID_MEDIA_TUNERFILTER_H
+
+#include <aidl/android/media/tv/tuner/BnTunerFilter.h>
+#include <aidl/android/media/tv/tuner/ITunerFilterCallback.h>
+#include <android/hardware/tv/tuner/1.0/ITuner.h>
+#include <media/stagefright/foundation/ADebug.h>
+
+using Status = ::ndk::ScopedAStatus;
+using ::aidl::android::media::tv::tuner::BnTunerFilter;
+using ::aidl::android::media::tv::tuner::ITunerFilterCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
+using ::android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
+using ::android::hardware::tv::tuner::V1_0::IFilter;
+using ::android::hardware::tv::tuner::V1_0::IFilterCallback;
+
+
+namespace android {
+
+class TunerFilter : public BnTunerFilter {
+
+public:
+ TunerFilter(sp<IFilter> filter, sp<IFilterCallback> callback);
+ virtual ~TunerFilter();
+ Status getId(int32_t* _aidl_return) override;
+
+ struct FilterCallback : public IFilterCallback {
+ FilterCallback(const std::shared_ptr<ITunerFilterCallback> tunerFilterCallback)
+ : mTunerFilterCallback(tunerFilterCallback) {};
+
+ virtual Return<void> onFilterEvent(const DemuxFilterEvent& filterEvent);
+ virtual Return<void> onFilterStatus(DemuxFilterStatus status);
+
+ std::shared_ptr<ITunerFilterCallback> mTunerFilterCallback;
+ };
+
+private:
+ sp<IFilter> mFilter;
+ sp<IFilterCallback> mFilterCallback;
+ int32_t mId;
+};
+
+} // namespace android
+
+#endif // ANDROID_MEDIA_TUNERFILTER_H
diff --git a/services/tuner/TunerFrontend.cpp b/services/tuner/TunerFrontend.cpp
index 17c60c0..e92489d 100644
--- a/services/tuner/TunerFrontend.cpp
+++ b/services/tuner/TunerFrontend.cpp
@@ -17,7 +17,6 @@
#define LOG_TAG "TunerFrontend"
#include "TunerFrontend.h"
-#include "TunerService.h"
using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3PlpSettings;
using ::aidl::android::media::tv::tuner::TunerFrontendScanAtsc3PlpInfo;
@@ -73,26 +72,19 @@
namespace android {
-TunerFrontend::TunerFrontend(sp<ITuner> tuner, int id) {
- mTuner = tuner;
+TunerFrontend::TunerFrontend(sp<IFrontend> frontend, int id) {
+ mFrontend = frontend;
+ mFrontend_1_1 = ::android::hardware::tv::tuner::V1_1::IFrontend::castFrom(mFrontend);
mId = id;
-
- if (mTuner != NULL) {
- Result status;
- mTuner->openFrontendById(mId, [&](Result result, const sp<IFrontend>& frontend) {
- mFrontend = frontend;
- status = result;
- });
- if (status != Result::SUCCESS) {
- mFrontend = NULL;
- }
- }
}
-TunerFrontend::~TunerFrontend() {}
+TunerFrontend::~TunerFrontend() {
+ mFrontend = NULL;
+ mId = -1;
+}
Status TunerFrontend::setCallback(
- const std::shared_ptr<ITunerFrontendCallback>& tunerFrontendCallback) {
+ const shared_ptr<ITunerFrontendCallback>& tunerFrontendCallback) {
if (mFrontend == NULL) {
ALOGE("IFrontend is not initialized");
return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
@@ -125,6 +117,7 @@
return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
}
+ // TODO: extend TunerFrontendSettings to use 1.1 types
FrontendSettings frontendSettings;
switch (settings.getTag()) {
case TunerFrontendSettings::analog:
@@ -308,8 +301,8 @@
return Status::ok();
}
-Status TunerFrontend::getStatus(const std::vector<int32_t>& /*statusTypes*/,
- std::vector<TunerFrontendStatus>* /*_aidl_return*/) {
+Status TunerFrontend::getStatus(const vector<int32_t>& /*statusTypes*/,
+ vector<TunerFrontendStatus>* /*_aidl_return*/) {
return Status::ok();
}
@@ -317,6 +310,7 @@
*_aidl_return = mId;
return Status::ok();
}
+
/////////////// FrontendCallback ///////////////////////
Return<void> TunerFrontend::FrontendCallback::onEvent(FrontendEventType frontendEventType) {
@@ -344,13 +338,13 @@
}
case FrontendScanMessageType::FREQUENCY: {
auto f = message.frequencies();
- std::vector<int> frequencies(std::begin(f), std::end(f));
+ vector<int> frequencies(begin(f), end(f));
scanMessage.set<TunerFrontendScanMessage::frequencies>(frequencies);
break;
}
case FrontendScanMessageType::SYMBOL_RATE: {
auto s = message.symbolRates();
- std::vector<int> symbolRates(std::begin(s), std::end(s));
+ vector<int> symbolRates(begin(s), end(s));
scanMessage.set<TunerFrontendScanMessage::symbolRates>(symbolRates);
break;
}
@@ -364,19 +358,19 @@
}
case FrontendScanMessageType::PLP_IDS: {
auto p = message.plpIds();
- std::vector<uint8_t> plpIds(std::begin(p), std::end(p));
+ vector<uint8_t> plpIds(begin(p), end(p));
scanMessage.set<TunerFrontendScanMessage::plpIds>(plpIds);
break;
}
case FrontendScanMessageType::GROUP_IDS: {
auto g = message.groupIds();
- std::vector<uint8_t> groupIds(std::begin(g), std::end(g));
+ vector<uint8_t> groupIds(begin(g), end(g));
scanMessage.set<TunerFrontendScanMessage::groupIds>(groupIds);
break;
}
case FrontendScanMessageType::INPUT_STREAM_IDS: {
auto i = message.inputStreamIds();
- std::vector<char16_t> streamIds(std::begin(i), std::end(i));
+ vector<char16_t> streamIds(begin(i), end(i));
scanMessage.set<TunerFrontendScanMessage::inputStreamIds>(streamIds);
break;
}
@@ -396,8 +390,8 @@
break;
}
case FrontendScanMessageType::ATSC3_PLP_INFO: {
- std::vector<FrontendScanAtsc3PlpInfo> plpInfos = message.atsc3PlpInfos();
- std::vector<TunerFrontendScanAtsc3PlpInfo> tunerPlpInfos;
+ vector<FrontendScanAtsc3PlpInfo> plpInfos = message.atsc3PlpInfos();
+ vector<TunerFrontendScanAtsc3PlpInfo> tunerPlpInfos;
for (int i = 0; i < plpInfos.size(); i++) {
auto info = plpInfos[i];
int plpId = (int) info.plpId;
@@ -463,7 +457,7 @@
return Void();
}
-////////////////////////////////////////////////////////////////////////////////
+/////////////// TunerFrontend Helper Methods ///////////////////////
hidl_vec<FrontendAtsc3PlpSettings> TunerFrontend::getAtsc3PlpSettings(
const TunerFrontendAtsc3Settings& settings) {
diff --git a/services/tuner/TunerFrontend.h b/services/tuner/TunerFrontend.h
index f1f66e7..99cdcdf 100644
--- a/services/tuner/TunerFrontend.h
+++ b/services/tuner/TunerFrontend.h
@@ -19,6 +19,7 @@
#include <aidl/android/media/tv/tuner/BnTunerFrontend.h>
#include <android/hardware/tv/tuner/1.0/ITuner.h>
+#include <android/hardware/tv/tuner/1.1/IFrontend.h>
#include <android/hardware/tv/tuner/1.1/IFrontendCallback.h>
#include <media/stagefright/foundation/ADebug.h>
#include <utils/Log.h>
@@ -41,20 +42,21 @@
using ::android::hardware::tv::tuner::V1_0::FrontendScanMessage;
using ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
using ::android::hardware::tv::tuner::V1_0::IFrontend;
-using ::android::hardware::tv::tuner::V1_0::ITuner;
using ::android::hardware::tv::tuner::V1_1::IFrontendCallback;
using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageExt1_1;
using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageTypeExt1_1;
+using namespace std;
+
namespace android {
class TunerFrontend : public BnTunerFrontend {
public:
- TunerFrontend(sp<ITuner> tuner, int id);
+ TunerFrontend(sp<IFrontend> frontend, int id);
virtual ~TunerFrontend();
Status setCallback(
- const std::shared_ptr<ITunerFrontendCallback>& tunerFrontendCallback) override;
+ const shared_ptr<ITunerFrontendCallback>& tunerFrontendCallback) override;
Status tune(const TunerFrontendSettings& settings) override;
Status stopTune() override;
Status scan(const TunerFrontendSettings& settings, int frontendScanType) override;
@@ -62,12 +64,12 @@
Status setLnb(int lnbHandle) override;
Status setLna(bool bEnable) override;
Status close() override;
- Status getStatus(const std::vector<int32_t>& statusTypes,
- std::vector<TunerFrontendStatus>* _aidl_return) override;
+ Status getStatus(const vector<int32_t>& statusTypes,
+ vector<TunerFrontendStatus>* _aidl_return) override;
Status getFrontendId(int* _aidl_return) override;
struct FrontendCallback : public IFrontendCallback {
- FrontendCallback(const std::shared_ptr<ITunerFrontendCallback> tunerFrontendCallback)
+ FrontendCallback(const shared_ptr<ITunerFrontendCallback> tunerFrontendCallback)
: mTunerFrontendCallback(tunerFrontendCallback) {};
virtual Return<void> onEvent(FrontendEventType frontendEventType);
@@ -76,16 +78,17 @@
virtual Return<void> onScanMessageExt1_1(
FrontendScanMessageTypeExt1_1 type, const FrontendScanMessageExt1_1& message);
- std::shared_ptr<ITunerFrontendCallback> mTunerFrontendCallback;
+ shared_ptr<ITunerFrontendCallback> mTunerFrontendCallback;
};
private:
hidl_vec<FrontendAtsc3PlpSettings> getAtsc3PlpSettings(
const TunerFrontendAtsc3Settings& settings);
FrontendDvbsCodeRate getDvbsCodeRate(const TunerFrontendDvbsCodeRate& codeRate);
+
int mId;
- sp<ITuner> mTuner;
sp<IFrontend> mFrontend;
+ sp<::android::hardware::tv::tuner::V1_1::IFrontend> mFrontend_1_1;
};
} // namespace android
diff --git a/services/tuner/TunerLnb.cpp b/services/tuner/TunerLnb.cpp
new file mode 100644
index 0000000..0bfa3fd
--- /dev/null
+++ b/services/tuner/TunerLnb.cpp
@@ -0,0 +1,120 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "TunerLnb"
+
+#include "TunerLnb.h"
+
+using ::android::hardware::tv::tuner::V1_0::LnbPosition;
+using ::android::hardware::tv::tuner::V1_0::LnbTone;
+using ::android::hardware::tv::tuner::V1_0::LnbVoltage;
+using ::android::hardware::tv::tuner::V1_0::Result;
+
+namespace android {
+
+TunerLnb::TunerLnb(sp<ILnb> lnb, int id) {
+ mLnb = lnb;
+ mId = id;
+}
+
+TunerLnb::~TunerLnb() {
+ mLnb = NULL;
+ mId = -1;
+}
+
+Status TunerLnb::setCallback(
+ const shared_ptr<ITunerLnbCallback>& tunerLnbCallback) {
+ if (mLnb == NULL) {
+ ALOGE("ILnb is not initialized");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ if (tunerLnbCallback == NULL) {
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ }
+
+ sp<ILnbCallback> lnbCallback = new LnbCallback(tunerLnbCallback);
+ Result status = mLnb->setCallback(lnbCallback);
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+}
+
+Status TunerLnb::setVoltage(int voltage) {
+ if (mLnb == NULL) {
+ ALOGE("ILnb is not initialized");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ Result status = mLnb->setVoltage(static_cast<LnbVoltage>(voltage));
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+}
+
+Status TunerLnb::setTone(int tone) {
+ if (mLnb == NULL) {
+ ALOGE("ILnb is not initialized");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ Result status = mLnb->setTone(static_cast<LnbTone>(tone));
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+}
+
+Status TunerLnb::setSatellitePosition(int position) {
+ if (mLnb == NULL) {
+ ALOGE("ILnb is not initialized");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ Result status = mLnb->setSatellitePosition(static_cast<LnbPosition>(position));
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+}
+
+Status TunerLnb::sendDiseqcMessage(const vector<uint8_t>& diseqcMessage) {
+ if (mLnb == NULL) {
+ ALOGE("ILnb is not initialized");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ Result status = mLnb->sendDiseqcMessage(diseqcMessage);
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+}
+
+Status TunerLnb::close() {
+ if (mLnb == NULL) {
+ ALOGE("ILnb is not initialized");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ Result status = mLnb->close();
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+}
+
+/////////////// ILnbCallback ///////////////////////
+
+Return<void> TunerLnb::LnbCallback::onEvent(const LnbEventType lnbEventType) {
+ if (mTunerLnbCallback != NULL) {
+ mTunerLnbCallback->onEvent((int)lnbEventType);
+ }
+ return Void();
+}
+
+Return<void> TunerLnb::LnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
+ if (mTunerLnbCallback != NULL && diseqcMessage != NULL) {
+ vector<uint8_t> msg(begin(diseqcMessage), end(diseqcMessage));
+ mTunerLnbCallback->onDiseqcMessage(msg);
+ }
+ return Void();
+}
+} // namespace android
diff --git a/services/tuner/TunerLnb.h b/services/tuner/TunerLnb.h
new file mode 100644
index 0000000..e80b97e
--- /dev/null
+++ b/services/tuner/TunerLnb.h
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MEDIA_TUNERFLNB_H
+#define ANDROID_MEDIA_TUNERFLNB_H
+
+#include <aidl/android/media/tv/tuner/BnTunerLnb.h>
+#include <android/hardware/tv/tuner/1.0/ILnb.h>
+#include <android/hardware/tv/tuner/1.0/ILnbCallback.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <utils/Log.h>
+
+using Status = ::ndk::ScopedAStatus;
+using ::aidl::android::media::tv::tuner::BnTunerLnb;
+using ::aidl::android::media::tv::tuner::ITunerLnbCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::tv::tuner::V1_0::ILnb;
+using ::android::hardware::tv::tuner::V1_0::ILnbCallback;
+using ::android::hardware::tv::tuner::V1_0::LnbEventType;
+
+using namespace std;
+
+namespace android {
+
+class TunerLnb : public BnTunerLnb {
+
+public:
+ TunerLnb(sp<ILnb> lnb, int id);
+ virtual ~TunerLnb();
+ Status setCallback(const shared_ptr<ITunerLnbCallback>& tunerLnbCallback) override;
+ Status setVoltage(int voltage) override;
+ Status setTone(int tone) override;
+ Status setSatellitePosition(int position) override;
+ Status sendDiseqcMessage(const vector<uint8_t>& diseqcMessage) override;
+ Status close() override;
+
+ struct LnbCallback : public ILnbCallback {
+ LnbCallback(const shared_ptr<ITunerLnbCallback> tunerLnbCallback)
+ : mTunerLnbCallback(tunerLnbCallback) {};
+
+ virtual Return<void> onEvent(const LnbEventType lnbEventType);
+ virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
+
+ shared_ptr<ITunerLnbCallback> mTunerLnbCallback;
+ };
+
+private:
+ int mId;
+ sp<ILnb> mLnb;
+};
+
+} // namespace android
+
+#endif // ANDROID_MEDIA_TUNERFLNB_H
diff --git a/services/tuner/TunerService.cpp b/services/tuner/TunerService.cpp
index c34ddf6..cbcea91 100644
--- a/services/tuner/TunerService.cpp
+++ b/services/tuner/TunerService.cpp
@@ -17,9 +17,12 @@
#define LOG_TAG "TunerService"
#include <android/binder_manager.h>
+#include <fmq/ConvertMQDescriptors.h>
#include <utils/Log.h>
-#include "TunerFrontend.h"
#include "TunerService.h"
+#include "TunerFrontend.h"
+#include "TunerLnb.h"
+#include "TunerDemux.h"
using ::aidl::android::media::tv::tuner::TunerFrontendAnalogCapabilities;
using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3Capabilities;
@@ -39,6 +42,9 @@
using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
using ::android::hardware::tv::tuner::V1_0::FrontendId;
using ::android::hardware::tv::tuner::V1_0::FrontendType;
+using ::android::hardware::tv::tuner::V1_0::IFrontend;
+using ::android::hardware::tv::tuner::V1_0::ILnb;
+using ::android::hardware::tv::tuner::V1_0::LnbId;
using ::android::hardware::tv::tuner::V1_0::Result;
namespace android {
@@ -47,55 +53,11 @@
TunerService::~TunerService() {}
void TunerService::instantiate() {
- std::shared_ptr<TunerService> service =
+ shared_ptr<TunerService> service =
::ndk::SharedRefBase::make<TunerService>();
AServiceManager_addService(service->asBinder().get(), getServiceName());
}
-template <typename HidlPayload, typename AidlPayload, typename AidlFlavor>
-bool TunerService::unsafeHidlToAidlMQDescriptor(
- const hardware::MQDescriptor<HidlPayload, FlavorTypeToValue<AidlFlavor>::value>& hidlDesc,
- MQDescriptor<AidlPayload, AidlFlavor>* aidlDesc) {
- // TODO: use the builtin coversion method when it's merged.
- ALOGD("unsafeHidlToAidlMQDescriptor");
- static_assert(sizeof(HidlPayload) == sizeof(AidlPayload), "Payload types are incompatible");
- static_assert(
- has_typedef_fixed_size<AidlPayload>::value == true ||
- std::is_fundamental<AidlPayload>::value ||
- std::is_enum<AidlPayload>::value,
- "Only fundamental types, enums, and AIDL parcelables annotated with @FixedSize "
- "and built for the NDK backend are supported as AIDL payload types.");
- aidlDesc->fileDescriptor = ndk::ScopedFileDescriptor(dup(hidlDesc.handle()->data[0]));
- for (const auto& grantor : hidlDesc.grantors()) {
- if (static_cast<int32_t>(grantor.offset) < 0 || static_cast<int64_t>(grantor.extent) < 0) {
- ALOGD("Unsafe static_cast of grantor fields. offset=%d, extend=%ld",
- static_cast<int32_t>(grantor.offset), static_cast<long>(grantor.extent));
- logError(
- "Unsafe static_cast of grantor fields. Either the hardware::MQDescriptor is "
- "invalid, or the MessageQueue is too large to be described by AIDL.");
- return false;
- }
- aidlDesc->grantors.push_back(
- GrantorDescriptor {
- .offset = static_cast<int32_t>(grantor.offset),
- .extent = static_cast<int64_t>(grantor.extent)
- });
- }
- if (static_cast<int32_t>(hidlDesc.getQuantum()) < 0 ||
- static_cast<int32_t>(hidlDesc.getFlags()) < 0) {
- ALOGD("Unsafe static_cast of quantum or flags. Quantum=%d, flags=%d",
- static_cast<int32_t>(hidlDesc.getQuantum()),
- static_cast<int32_t>(hidlDesc.getFlags()));
- logError(
- "Unsafe static_cast of quantum or flags. Either the hardware::MQDescriptor is "
- "invalid, or the MessageQueue is too large to be described by AIDL.");
- return false;
- }
- aidlDesc->quantum = static_cast<int32_t>(hidlDesc.getQuantum());
- aidlDesc->flags = static_cast<int32_t>(hidlDesc.getFlags());
- return true;
-}
-
bool TunerService::getITuner() {
ALOGD("getITuner");
if (mTuner != nullptr) {
@@ -109,17 +71,19 @@
return true;
}
-Result TunerService::openDemux() {
+Status TunerService::openDemux(
+ int /* demuxHandle */, std::shared_ptr<ITunerDemux>* _aidl_return) {
ALOGD("openDemux");
if (!getITuner()) {
- return Result::NOT_INITIALIZED;
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::NOT_INITIALIZED));
}
if (mDemux != nullptr) {
- return Result::SUCCESS;
+ *_aidl_return = mDemux->ref<ITunerDemux>();
+ return Status::ok();
}
Result res;
uint32_t id;
- sp<IDemux> demuxSp;
+ sp<IDemux> demuxSp = nullptr;
mTuner->openDemux([&](Result r, uint32_t demuxId, const sp<IDemux>& demux) {
demuxSp = demux;
id = demuxId;
@@ -127,37 +91,14 @@
ALOGD("open demux, id = %d", demuxId);
});
if (res == Result::SUCCESS) {
- mDemux = demuxSp;
- } else {
- ALOGD("open demux failed, res = %d", res);
- }
- return res;
-}
-
-Result TunerService::openFilter() {
- ALOGD("openFilter");
- if (!getITuner()) {
- return Result::NOT_INITIALIZED;
- }
- DemuxFilterMainType mainType = DemuxFilterMainType::TS;
- DemuxFilterType filterType {
- .mainType = mainType,
- };
- filterType.subType.tsFilterType(DemuxTsFilterType::VIDEO);
-
- sp<FilterCallback> callback = new FilterCallback();
- Result res;
- mDemux->openFilter(filterType, 16000000, callback,
- [&](Result r, const sp<IFilter>& filter) {
- mFilter = filter;
- res = r;
- });
- if (res != Result::SUCCESS || mFilter == NULL) {
- ALOGD("Failed to open filter, type = %d", filterType.mainType);
- return res;
+ mDemux = ::ndk::SharedRefBase::make<TunerDemux>(demuxSp, id);
+ *_aidl_return = mDemux->ref<ITunerDemux>();
+ return Status::ok();
}
- return Result::SUCCESS;
+ ALOGD("open demux failed, res = %d", res);
+ mDemux = nullptr;
+ return Status::fromServiceSpecificError(static_cast<int32_t>(res));
}
Result TunerService::configFilter() {
@@ -192,7 +133,7 @@
if (getQueueDescResult == Result::SUCCESS) {
unsafeHidlToAidlMQDescriptor<uint8_t, int8_t, SynchronizedReadWrite>(
mFilterMQDesc, &mAidlMQDesc);
- mAidlMq = new (std::nothrow) AidlMessageQueue(mAidlMQDesc);
+ mAidlMq = new (nothrow) AidlMessageQueue(mAidlMQDesc);
EventFlag::createEventFlag(mAidlMq->getEventFlagWord(), &mEventFlag);
} else {
ALOGD("get MQDesc failed, res = %d", getQueueDescResult);
@@ -200,9 +141,9 @@
return getQueueDescResult;
}
-Status TunerService::getFrontendIds(std::vector<int32_t>* ids, int32_t* /* _aidl_return */) {
+Status TunerService::getFrontendIds(vector<int32_t>* ids, int32_t* /* _aidl_return */) {
if (!getITuner()) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ return Status::fromServiceSpecificError(
static_cast<int32_t>(Result::NOT_INITIALIZED));
}
hidl_vec<FrontendId> feIds;
@@ -212,10 +153,10 @@
res = r;
});
if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
+ return Status::fromServiceSpecificError(static_cast<int32_t>(res));
}
ids->resize(feIds.size());
- std::copy(feIds.begin(), feIds.end(), ids->begin());
+ copy(feIds.begin(), feIds.end(), ids->begin());
return Status::ok();
}
@@ -230,7 +171,7 @@
Result res;
FrontendInfo info;
- int feId = getResourceIdFromHandle(frontendHandle);
+ int feId = getResourceIdFromHandle(frontendHandle, FRONTEND);
mTuner->getFrontendInfo(feId, [&](Result r, const FrontendInfo& feInfo) {
info = feInfo;
res = r;
@@ -245,15 +186,83 @@
}
Status TunerService::openFrontend(
- int32_t frontendHandle, std::shared_ptr<ITunerFrontend>* _aidl_return) {
+ int32_t frontendHandle, shared_ptr<ITunerFrontend>* _aidl_return) {
if (mTuner == nullptr) {
ALOGE("ITuner service is not init.");
- return ::ndk::ScopedAStatus::fromServiceSpecificError(
- static_cast<int32_t>(Result::UNAVAILABLE));
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
}
- int id = getResourceIdFromHandle(frontendHandle);
- *_aidl_return = ::ndk::SharedRefBase::make<TunerFrontend>(mTuner, id);
+ Result status;
+ sp<IFrontend> frontend;
+ int id = getResourceIdFromHandle(frontendHandle, FRONTEND);
+ mTuner->openFrontendById(id, [&](Result result, const sp<IFrontend>& fe) {
+ frontend = fe;
+ status = result;
+ });
+ if (status != Result::SUCCESS) {
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ }
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerFrontend>(frontend, id);
+ return Status::ok();
+}
+
+Status TunerService::getFmqSyncReadWrite(
+ MQDescriptor<int8_t, SynchronizedReadWrite>* mqDesc, bool* _aidl_return) {
+ ALOGD("getFmqSyncReadWrite");
+ // TODO: put the following methods AIDL, and should be called from clients.
+ configFilter();
+ mFilter->start();
+ if (mqDesc == nullptr) {
+ ALOGD("getFmqSyncReadWrite null MQDescriptor.");
+ *_aidl_return = false;
+ } else {
+ ALOGD("getFmqSyncReadWrite true");
+ *_aidl_return = true;
+ *mqDesc = move(mAidlMQDesc);
+ }
+ return ndk::ScopedAStatus::ok();
+}
+
+Status TunerService::openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) {
+ if (mTuner == nullptr) {
+ ALOGE("ITuner service is not init.");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ Result status;
+ sp<ILnb> lnb;
+ int id = getResourceIdFromHandle(lnbHandle, LNB);
+ mTuner->openLnbById(id, [&](Result result, const sp<ILnb>& lnbSp){
+ lnb = lnbSp;
+ status = result;
+ });
+ if (status != Result::SUCCESS) {
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ }
+
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, id);
+ return Status::ok();
+}
+
+Status TunerService::openLnbByName(const string& lnbName, shared_ptr<ITunerLnb>* _aidl_return) {
+ if (mTuner == nullptr) {
+ ALOGE("ITuner service is not init.");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ int lnbId;
+ Result status;
+ sp<ILnb> lnb;
+ mTuner->openLnbByName(lnbName, [&](Result r, LnbId id, const sp<ILnb>& lnbSp) {
+ status = r;
+ lnb = lnbSp;
+ lnbId = (int)id;
+ });
+ if (status != Result::SUCCESS) {
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ }
+
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, lnbId);
return Status::ok();
}
@@ -367,24 +376,4 @@
info.caps = caps;
return info;
}
-
-Status TunerService::getFmqSyncReadWrite(
- MQDescriptor<int8_t, SynchronizedReadWrite>* mqDesc, bool* _aidl_return) {
- ALOGD("getFmqSyncReadWrite");
- // TODO: put the following methods AIDL, and should be called from clients.
- openDemux();
- openFilter();
- configFilter();
- mFilter->start();
- if (mqDesc == nullptr) {
- ALOGD("getFmqSyncReadWrite null MQDescriptor.");
- *_aidl_return = false;
- } else {
- ALOGD("getFmqSyncReadWrite true");
- *_aidl_return = true;
- *mqDesc = std::move(mAidlMQDesc);
- }
- return ndk::ScopedAStatus::ok();
-}
-
} // namespace android
diff --git a/services/tuner/TunerService.h b/services/tuner/TunerService.h
index 021ed26..856b54a 100644
--- a/services/tuner/TunerService.h
+++ b/services/tuner/TunerService.h
@@ -27,7 +27,9 @@
using ::aidl::android::hardware::common::fmq::MQDescriptor;
using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
using ::aidl::android::media::tv::tuner::BnTunerService;
+using ::aidl::android::media::tv::tuner::ITunerDemux;
using ::aidl::android::media::tv::tuner::ITunerFrontend;
+using ::aidl::android::media::tv::tuner::ITunerLnb;
using ::aidl::android::media::tv::tuner::TunerFrontendInfo;
using ::android::hardware::details::logError;
@@ -55,8 +57,16 @@
using Status = ::ndk::ScopedAStatus;
+using namespace std;
+
namespace android {
+typedef enum {
+ FRONTEND,
+ LNB,
+ DEMUX,
+ DESCRAMBLER,
+} TunerResourceType;
struct FilterCallback : public IFilterCallback {
~FilterCallback() {}
@@ -80,30 +90,26 @@
virtual ~TunerService();
// TODO: create a map between resource id and handles.
- static int getResourceIdFromHandle(int resourceHandle) {
+ static int getResourceIdFromHandle(int resourceHandle, int /*type*/) {
return (resourceHandle & 0x00ff0000) >> 16;
}
- Status getFrontendIds(std::vector<int32_t>* ids, int32_t* _aidl_return) override;
+ Status getFrontendIds(vector<int32_t>* ids, int32_t* _aidl_return) override;
Status getFrontendInfo(int32_t frontendHandle, TunerFrontendInfo* _aidl_return) override;
Status openFrontend(
- int32_t frontendHandle, std::shared_ptr<ITunerFrontend>* _aidl_return) override;
+ int32_t frontendHandle, shared_ptr<ITunerFrontend>* _aidl_return) override;
Status getFmqSyncReadWrite(
MQDescriptor<int8_t, SynchronizedReadWrite>* mqDesc, bool* _aidl_return) override;
+ Status openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) override;
+ Status openLnbByName(const string& lnbName, shared_ptr<ITunerLnb>* _aidl_return) override;
+ Status openDemux(int32_t demuxHandle, std::shared_ptr<ITunerDemux>* _aidl_return) override;
private:
- template <typename HidlPayload, typename AidlPayload, typename AidlFlavor>
- bool unsafeHidlToAidlMQDescriptor(
- const hardware::MQDescriptor<HidlPayload, FlavorTypeToValue<AidlFlavor>::value>& hidl,
- MQDescriptor<AidlPayload, AidlFlavor>* aidl);
-
bool getITuner();
- Result openFilter();
- Result openDemux();
Result configFilter();
sp<ITuner> mTuner;
- sp<IDemux> mDemux;
+ std::shared_ptr<ITunerDemux> mDemux;
sp<IFilter> mFilter;
AidlMessageQueue* mAidlMq;
MQDescriptorSync<uint8_t> mFilterMQDesc;
diff --git a/services/tuner/TunerTimeFilter.cpp b/services/tuner/TunerTimeFilter.cpp
new file mode 100644
index 0000000..dce76d2
--- /dev/null
+++ b/services/tuner/TunerTimeFilter.cpp
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "TunerTimeFilter"
+
+#include "TunerTimeFilter.h"
+
+namespace android {
+
+TunerTimeFilter::TunerTimeFilter(sp<ITimeFilter> timeFilter) {
+ mTimeFilter = timeFilter;
+}
+
+TunerTimeFilter::~TunerTimeFilter() {
+ mTimeFilter = NULL;
+}
+
+Status TunerTimeFilter::setTimeStamp(int64_t /*timeStamp*/) {
+ return Status::ok();
+}
+
+Status TunerTimeFilter::clearTimeStamp() {
+ return Status::ok();
+}
+
+Status TunerTimeFilter::getSourceTime(int64_t* /*_aidl_return*/) {
+ return Status::ok();
+}
+
+Status TunerTimeFilter::getTimeStamp(int64_t* /*_aidl_return*/) {
+ return Status::ok();
+}
+
+Status TunerTimeFilter::close() {
+ return Status::ok();
+}
+} // namespace android
diff --git a/services/tuner/TunerTimeFilter.h b/services/tuner/TunerTimeFilter.h
new file mode 100644
index 0000000..50b8f54
--- /dev/null
+++ b/services/tuner/TunerTimeFilter.h
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MEDIA_TUNERFTIMEFILTER_H
+#define ANDROID_MEDIA_TUNERFTIMEFILTER_H
+
+#include <aidl/android/media/tv/tuner/BnTunerTimeFilter.h>
+#include <android/hardware/tv/tuner/1.0/ITimeFilter.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <utils/Log.h>
+
+using Status = ::ndk::ScopedAStatus;
+using ::aidl::android::media::tv::tuner::BnTunerTimeFilter;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::tv::tuner::V1_0::ITimeFilter;
+
+using namespace std;
+
+namespace android {
+
+class TunerTimeFilter : public BnTunerTimeFilter {
+
+public:
+ TunerTimeFilter(sp<ITimeFilter> timeFilter);
+ virtual ~TunerTimeFilter();
+ Status setTimeStamp(int64_t timeStamp) override;
+ Status clearTimeStamp() override;
+ Status getSourceTime(int64_t* _aidl_return) override;
+ Status getTimeStamp(int64_t* _aidl_return) override;
+ Status close() override;
+
+private:
+ sp<ITimeFilter> mTimeFilter;
+};
+
+} // namespace android
+
+#endif // ANDROID_MEDIA_TUNERFTIMEFILTER_H
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerDemux.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerDemux.aidl
new file mode 100644
index 0000000..0e4e99c
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerDemux.aidl
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.ITunerFilter;
+import android.media.tv.tuner.ITunerFilterCallback;
+import android.media.tv.tuner.ITunerFrontend;
+
+/**
+ * Tuner Demux interface handles tuner related operations.
+ *
+ * {@hide}
+ */
+interface ITunerDemux {
+
+ /**
+ * Set a frontend resource as data input of the demux
+ */
+ void setFrontendDataSource(in ITunerFrontend frontend);
+
+ /**
+ * Open a new filter in the demux
+ */
+ ITunerFilter openFilter(
+ in int mainType, in int subtype, in int bufferSize, in ITunerFilterCallback cb);
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerFilter.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerFilter.aidl
new file mode 100644
index 0000000..24c6289
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerFilter.aidl
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * Tuner Filter interface handles tuner related operations.
+ *
+ * {@hide}
+ */
+interface ITunerFilter {
+ /**
+ * Get the filter Id.
+ */
+ int getId();
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerFilterCallback.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerFilterCallback.aidl
new file mode 100644
index 0000000..2733d3c
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerFilterCallback.aidl
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * TunerFilterCallback interface handles tuner filter related callbacks.
+ *
+ * {@hide}
+ */
+interface ITunerFilterCallback {
+ /**
+ * Notify the client a new status of a filter.
+ */
+ void onFilterStatus(int status);
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerFrontend.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerFrontend.aidl
index 2a54dc6..bfc3e30 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerFrontend.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerFrontend.aidl
@@ -21,7 +21,7 @@
import android.media.tv.tuner.TunerFrontendStatus;
/**
- * Tuner Frontend interface handles tuner related operations.
+ * Tuner Frontend interface handles frontend related operations.
*
* {@hide}
*/
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerLnb.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerLnb.aidl
new file mode 100644
index 0000000..d62145e
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerLnb.aidl
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.ITunerLnbCallback;
+
+/**
+ * Tuner Lnb interface handles Lnb related operations.
+ *
+ * {@hide}
+ */
+interface ITunerLnb {
+ /**
+ * Set the lnb callback.
+ */
+ void setCallback(in ITunerLnbCallback tunerLnbCallback);
+
+ /**
+ * Set the lnb's power voltage.
+ */
+ void setVoltage(in int voltage);
+
+ /**
+ * Set the lnb's tone mode.
+ */
+ void setTone(in int tone);
+
+ /**
+ * Select the lnb's position.
+ */
+ void setSatellitePosition(in int position);
+
+ /**
+ * Sends DiSEqC (Digital Satellite Equipment Control) message.
+ */
+ void sendDiseqcMessage(in byte[] diseqcMessage);
+
+ /**
+ * Releases the LNB instance.
+ */
+ void close();
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerLnbCallback.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerLnbCallback.aidl
new file mode 100644
index 0000000..117352f
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerLnbCallback.aidl
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * TuneLnbCallback interface handles tuner lnb related callbacks.
+ *
+ * {@hide}
+ */
+interface ITunerLnbCallback {
+ /**
+ * Notify the client that a new event happened on the Lnb.
+ */
+ void onEvent(in int lnbEventType);
+
+ /**
+ * notify the client of new DiSEqC message.
+ */
+ void onDiseqcMessage(in byte[] diseqcMessage);
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerService.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerService.aidl
index 205e222..ac6eaab 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerService.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerService.aidl
@@ -19,7 +19,9 @@
import android.hardware.common.fmq.MQDescriptor;
import android.hardware.common.fmq.SynchronizedReadWrite;
import android.hardware.common.fmq.UnsynchronizedWrite;
+import android.media.tv.tuner.ITunerDemux;
import android.media.tv.tuner.ITunerFrontend;
+import android.media.tv.tuner.ITunerLnb;
import android.media.tv.tuner.TunerFrontendInfo;
/**
@@ -59,4 +61,25 @@
* @return true if succeeds, false otherwise.
*/
boolean getFmqSyncReadWrite(out MQDescriptor<byte, SynchronizedReadWrite> mqDesc);
+
+ /**
+ * Open a new interface of ITunerLnb given a lnbHandle.
+ *
+ * @param lnbHandle the handle of the LNB granted by TRM.
+ * @return a newly created ITunerLnb interface.
+ */
+ ITunerLnb openLnb(in int lnbHandle);
+
+ /**
+ * Open a new interface of ITunerLnb given a LNB name.
+ *
+ * @param lnbName the name for an external LNB to be opened.
+ * @return a newly created ITunerLnb interface.
+ */
+ ITunerLnb openLnbByName(in String lnbName);
+
+ /**
+ * Create a new instance of Demux.
+ */
+ ITunerDemux openDemux(in int demuxHandle);
}
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerTimeFilter.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerTimeFilter.aidl
new file mode 100644
index 0000000..f84b9bf
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerTimeFilter.aidl
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * Tuner Time Filter interface handles time filter related operations.
+ *
+ * {@hide}
+ */
+interface ITunerTimeFilter {
+ /**
+ * Set time stamp for time based filter.
+ */
+ void setTimeStamp(in long timeStamp);
+
+ /**
+ * Clear the time stamp in the time filter.
+ */
+ void clearTimeStamp();
+
+ /**
+ * Get the time from the beginning of current data source.
+ */
+ long getSourceTime();
+
+ /**
+ * Get the current time in the time filter.
+ */
+ long getTimeStamp();
+
+ /**
+ * Close the Time Filter instance.
+ */
+ void close();
+}