Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Camera Hals And Dolby support #6

Open
wants to merge 18 commits into
base: 14
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
dbcf285
Add group audio to vendor.media.omx service
lweiss-fairphone Feb 2, 2022
878b613
audiopolicy: Disable sonification on WFD sink
Jul 18, 2014
dc4e00b
codec2: add smoothfactor when checking n-th work
Aug 5, 2021
0ebb716
Revert "stagefright: remove Miracast sender code"
vladimiroltean Jan 8, 2019
e414ac6
Revert "Removed unused class and its test"
vladimiroltean Jan 9, 2019
ee39206
libstagefright: Remove libmediaextractor dependency
adithya2306 Dec 13, 2019
4db3292
libstagefright_wfd: compilation fixes
vladimiroltean Jan 8, 2019
675a214
stagefright: Fix SurfaceMediaSource getting handle from wrong positio…
May 11, 2017
d70578a
stagefright: Fix buffer handle retrieval in signalBufferReturned
kholk Apr 30, 2017
014af94
libstagefright_wfd: video encoder does not actually release MediaBuff…
vladimiroltean Jan 20, 2019
1a800f7
audioflinger: Fix audio for WifiDisplay
myfluxi Apr 16, 2020
693e3ac
Partial revert "Move unused classes out of stagefright foundataion"
nicorg2515 Nov 1, 2019
6c45508
fixup! Revert "stagefright: remove Miracast sender code"
AmeChanRain Oct 5, 2023
da8309d
cameraservice: fix deadlock in onewayhidl onPhysicalCameraStatusChanged
Aug 31, 2022
1edfe05
CameraService: Fix deadlock in binder death cleanup
May 22, 2018
a773e17
media: OMXStore: Import loading libstagefrightdolby
johnmart19 Dec 24, 2022
c16e3bf
libstagefright: omx: Add support for loading prebuilt ddp and ac4 dec…
javelinanddart May 6, 2022
d27c1a1
OMX: Remove support for prebuilt ac4 decoder
adithya2306 Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/media/IHDCP.h
2 changes: 1 addition & 1 deletion media/codec2/sfplugin/CCodecBufferChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ PipelineWatcher::Clock::duration CCodecBufferChannel::elapsed() {
size_t outputDelay = mOutput.lock()->outputDelay;
{
Mutexed<Input>::Locked input(mInput);
n = input->inputDelay + input->pipelineDelay + outputDelay;
n = input->inputDelay + input->pipelineDelay + outputDelay + kSmoothnessFactor;
}
return mPipelineWatcher.lock()->elapsed(PipelineWatcher::Clock::now(), n);
}
Expand Down
2 changes: 2 additions & 0 deletions media/libmedia/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ cc_library {
srcs: [
":mediaextractorservice_aidl",
"IDataSource.cpp",
"IHDCP.cpp",
"BufferingSettings.cpp",
"mediaplayer.cpp",
"IMediaHTTPConnection.cpp",
Expand Down Expand Up @@ -374,6 +375,7 @@ cc_library {
"libcamera_client",
"libstagefright_foundation",
"libgui",
"libui",
"libdl",
"libaudioclient",
"libmedia_codeclist",
Expand Down
359 changes: 359 additions & 0 deletions media/libmedia/IHDCP.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,359 @@
/*
* Copyright (C) 2012 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_NDEBUG 0
#define LOG_TAG "IHDCP"
#include <utils/Log.h>

#include <binder/Parcel.h>
#include <media/IHDCP.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/foundation/ADebug.h>

namespace android {

enum {
OBSERVER_NOTIFY = IBinder::FIRST_CALL_TRANSACTION,
HDCP_SET_OBSERVER,
HDCP_INIT_ASYNC,
HDCP_SHUTDOWN_ASYNC,
HDCP_GET_CAPS,
HDCP_ENCRYPT,
HDCP_ENCRYPT_NATIVE,
HDCP_DECRYPT,
};

struct BpHDCPObserver : public BpInterface<IHDCPObserver> {
explicit BpHDCPObserver(const sp<IBinder> &impl)
: BpInterface<IHDCPObserver>(impl) {
}

virtual void notify(
int msg, int ext1, int ext2, const Parcel *obj) {
Parcel data, reply;
data.writeInterfaceToken(IHDCPObserver::getInterfaceDescriptor());
data.writeInt32(msg);
data.writeInt32(ext1);
data.writeInt32(ext2);
if (obj && obj->dataSize() > 0) {
data.appendFrom(const_cast<Parcel *>(obj), 0, obj->dataSize());
}
remote()->transact(OBSERVER_NOTIFY, data, &reply, IBinder::FLAG_ONEWAY);
}
};

DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(HDCPObserver, "android.hardware.IHDCPObserver");

struct BpHDCP : public BpInterface<IHDCP> {
explicit BpHDCP(const sp<IBinder> &impl)
: BpInterface<IHDCP>(impl) {
}

virtual status_t setObserver(const sp<IHDCPObserver> &observer) {
Parcel data, reply;
data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
data.writeStrongBinder(IInterface::asBinder(observer));
remote()->transact(HDCP_SET_OBSERVER, data, &reply);
return reply.readInt32();
}

virtual status_t initAsync(const char *host, unsigned port) {
Parcel data, reply;
data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
data.writeCString(host);
data.writeInt32(port);
remote()->transact(HDCP_INIT_ASYNC, data, &reply);
return reply.readInt32();
}

virtual status_t shutdownAsync() {
Parcel data, reply;
data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
remote()->transact(HDCP_SHUTDOWN_ASYNC, data, &reply);
return reply.readInt32();
}

virtual uint32_t getCaps() {
Parcel data, reply;
data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
remote()->transact(HDCP_GET_CAPS, data, &reply);
return reply.readInt32();
}

virtual status_t encrypt(
const void *inData, size_t size, uint32_t streamCTR,
uint64_t *outInputCTR, void *outData) {
Parcel data, reply;
data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
data.writeInt32(size);
data.write(inData, size);
data.writeInt32(streamCTR);
remote()->transact(HDCP_ENCRYPT, data, &reply);

status_t err = reply.readInt32();

if (err != OK) {
*outInputCTR = 0;

return err;
}

*outInputCTR = reply.readInt64();
reply.read(outData, size);

return err;
}

virtual status_t encryptNative(
const sp<GraphicBuffer> &graphicBuffer,
size_t offset, size_t size, uint32_t streamCTR,
uint64_t *outInputCTR, void *outData) {
Parcel data, reply;
data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
data.write(*graphicBuffer);
data.writeInt32(offset);
data.writeInt32(size);
data.writeInt32(streamCTR);
remote()->transact(HDCP_ENCRYPT_NATIVE, data, &reply);

status_t err = reply.readInt32();

if (err != OK) {
*outInputCTR = 0;
return err;
}

*outInputCTR = reply.readInt64();
reply.read(outData, size);

return err;
}

virtual status_t decrypt(
const void *inData, size_t size,
uint32_t streamCTR, uint64_t inputCTR,
void *outData) {
Parcel data, reply;
data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
data.writeInt32(size);
data.write(inData, size);
data.writeInt32(streamCTR);
data.writeInt64(inputCTR);
remote()->transact(HDCP_DECRYPT, data, &reply);

status_t err = reply.readInt32();

if (err != OK) {
return err;
}

reply.read(outData, size);

return err;
}
};

DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(HDCP, "android.hardware.IHDCP");

status_t BnHDCPObserver::onTransact(
uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
switch (code) {
case OBSERVER_NOTIFY:
{
CHECK_INTERFACE(IHDCPObserver, data, reply);

int msg = data.readInt32();
int ext1 = data.readInt32();
int ext2 = data.readInt32();

Parcel obj;
if (data.dataAvail() > 0) {
obj.appendFrom(
const_cast<Parcel *>(&data),
data.dataPosition(),
data.dataAvail());
}

notify(msg, ext1, ext2, &obj);

return OK;
}

default:
return BBinder::onTransact(code, data, reply, flags);
}
}

status_t BnHDCP::onTransact(
uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
switch (code) {
case HDCP_SET_OBSERVER:
{
CHECK_INTERFACE(IHDCP, data, reply);

sp<IHDCPObserver> observer =
interface_cast<IHDCPObserver>(data.readStrongBinder());

reply->writeInt32(setObserver(observer));
return OK;
}

case HDCP_INIT_ASYNC:
{
CHECK_INTERFACE(IHDCP, data, reply);

const char *host = data.readCString();
unsigned port = data.readInt32();

reply->writeInt32(initAsync(host, port));
return OK;
}

case HDCP_SHUTDOWN_ASYNC:
{
CHECK_INTERFACE(IHDCP, data, reply);

reply->writeInt32(shutdownAsync());
return OK;
}

case HDCP_GET_CAPS:
{
CHECK_INTERFACE(IHDCP, data, reply);

reply->writeInt32(getCaps());
return OK;
}

case HDCP_ENCRYPT:
{
CHECK_INTERFACE(IHDCP, data, reply);

size_t size = data.readInt32();
void *inData = NULL;
// watch out for overflow
if (size <= SIZE_MAX / 2) {
inData = malloc(2 * size);
}
if (inData == NULL) {
reply->writeInt32(ERROR_OUT_OF_RANGE);
return OK;
}

void *outData = (uint8_t *)inData + size;

status_t err = data.read(inData, size);
if (err != OK) {
free(inData);
reply->writeInt32(err);
return OK;
}

uint32_t streamCTR = data.readInt32();
uint64_t inputCTR;
err = encrypt(inData, size, streamCTR, &inputCTR, outData);

reply->writeInt32(err);

if (err == OK) {
reply->writeInt64(inputCTR);
reply->write(outData, size);
}

free(inData);
inData = outData = NULL;

return OK;
}

case HDCP_ENCRYPT_NATIVE:
{
CHECK_INTERFACE(IHDCP, data, reply);

sp<GraphicBuffer> graphicBuffer = new GraphicBuffer();
data.read(*graphicBuffer);
size_t offset = data.readInt32();
size_t size = data.readInt32();
uint32_t streamCTR = data.readInt32();
void *outData = NULL;
uint64_t inputCTR;

status_t err = ERROR_OUT_OF_RANGE;

outData = malloc(size);

if (outData != NULL) {
err = encryptNative(graphicBuffer, offset, size,
streamCTR, &inputCTR, outData);
}

reply->writeInt32(err);

if (err == OK) {
reply->writeInt64(inputCTR);
reply->write(outData, size);
}

free(outData);
outData = NULL;

return OK;
}

case HDCP_DECRYPT:
{
CHECK_INTERFACE(IHDCP, data, reply);

size_t size = data.readInt32();
size_t bufSize = 2 * size;

// watch out for overflow
void *inData = NULL;
if (bufSize > size) {
inData = malloc(bufSize);
}

if (inData == NULL) {
reply->writeInt32(ERROR_OUT_OF_RANGE);
return OK;
}

void *outData = (uint8_t *)inData + size;

data.read(inData, size);

uint32_t streamCTR = data.readInt32();
uint64_t inputCTR = data.readInt64();
status_t err = decrypt(inData, size, streamCTR, inputCTR, outData);

reply->writeInt32(err);

if (err == OK) {
reply->write(outData, size);
}

free(inData);
inData = outData = NULL;

return OK;
}

default:
return BBinder::onTransact(code, data, reply, flags);
}
}

} // namespace android
Loading