Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2dbaf01a authored by Dongwon Kang's avatar Dongwon Kang Committed by Android (Google) Code Review
Browse files

Merge changes from topic "media-mainline-static"

* changes:
  Remove libcrypto dependency when building com.android.media
  media apex: statically link hidl libraries in mpeg2extractor.
parents 7e5e530d f11c6776
Loading
Loading
Loading
Loading
+25 −12
Original line number Diff line number Diff line
@@ -12,15 +12,10 @@ cc_library_shared {
    ],

    shared_libs: [
        "android.hardware.cas@1.0",
        "android.hardware.cas.native@1.0",
        "android.hidl.token@1.0-utils",
        "android.hidl.allocator@1.0",
        "libcrypto",
        "libhidlmemory",
        "libhidlbase",
        "liblog",
        "libmediandk",
        "libcgrouprc#29",
        "liblog#10000",
        "libmediandk#29",
        "libvndksupport#29",
    ],

    header_libs: [
@@ -31,11 +26,24 @@ cc_library_shared {
    ],

    static_libs: [
        "android.hardware.cas@1.0",
        "android.hardware.cas.native@1.0",
        "android.hidl.allocator@1.0",
        "android.hidl.memory@1.0",
        "android.hidl.token@1.0",
        "android.hidl.token@1.0-utils",
        "libbase",
        "libbinderthreadstate",
        "libcutils",
        "libhidlbase",
        "libhidlmemory",
        "libjsoncpp",
        "libprocessgroup",
        "libstagefright_esds",
        "libstagefright_foundation_without_imemory",
        "libstagefright_mpeg2extractor",
        "libstagefright_mpeg2support",
        "libutils",
        "libstagefright_mpeg2extractor",
        "libstagefright_esds",
    ],

    name: "libmpeg2extractor",
@@ -51,11 +59,16 @@ cc_library_shared {
    version_script: "exports.lds",

    sanitize: {
        cfi: true,
        // STOPSHIP: turn on cfi once b/139945549 is resolved.
        cfi: false,
        misc_undefined: [
            "unsigned-integer-overflow",
            "signed-integer-overflow",
        ],
    },

    apex_available: [
        "com.android.media",
        "test_com.android.media",
    ],
}
+11 −1
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@
#include <inttypes.h>
#include <netinet/in.h>

#ifndef __ANDROID_APEX__
#include "HlsSampleDecryptor.h"
#endif

namespace android {

ElementaryStreamQueue::ElementaryStreamQueue(Mode mode, uint32_t flags)
@@ -50,7 +54,13 @@ ElementaryStreamQueue::ElementaryStreamQueue(Mode mode, uint32_t flags)

    // Create the decryptor anyway since we don't know the use-case unless key is provided
    // Won't decrypt if key info not available (e.g., scanner/extractor just parsing ts files)
    mSampleDecryptor = isSampleEncrypted() ? new HlsSampleDecryptor : NULL;
    mSampleDecryptor = isSampleEncrypted() ?
#ifdef __ANDROID_APEX__
        new SampleDecryptor
#else
        new HlsSampleDecryptor
#endif
        : NULL;
}

sp<MetaData> ElementaryStreamQueue::getFormat() {
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
#include <utils/RefBase.h>
#include <vector>

#include "HlsSampleDecryptor.h"
#include "SampleDecryptor.h"

namespace android {

@@ -109,7 +109,7 @@ private:

    sp<MetaData> mFormat;

    sp<HlsSampleDecryptor> mSampleDecryptor;
    sp<SampleDecryptor> mSampleDecryptor;
    int mAUIndex;

    bool isSampleEncrypted() const {
+10 −8
Original line number Diff line number Diff line
@@ -14,9 +14,9 @@
 * limitations under the License.
 */

#ifndef SAMPLE_AES_PROCESSOR_H_
#ifndef HLS_SAMPLE_AES_PROCESSOR_H_

#define SAMPLE_AES_PROCESSOR_H_
#define HLS_SAMPLE_AES_PROCESSOR_H_

#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/AString.h>
@@ -28,18 +28,20 @@
#include <utils/RefBase.h>
#include <utils/Vector.h>

#include "SampleDecryptor.h"

namespace android {

struct HlsSampleDecryptor : RefBase {
struct HlsSampleDecryptor : SampleDecryptor {

    HlsSampleDecryptor();
    explicit HlsSampleDecryptor(const sp<AMessage> &sampleAesKeyItem);

    void signalNewSampleAesKey(const sp<AMessage> &sampleAesKeyItem);
    virtual void signalNewSampleAesKey(const sp<AMessage> &sampleAesKeyItem);

    size_t processNal(uint8_t *nalData, size_t nalSize);
    void processAAC(size_t adtsHdrSize, uint8_t *data, size_t size);
    void processAC3(uint8_t *data, size_t size);
    virtual size_t processNal(uint8_t *nalData, size_t nalSize);
    virtual void processAAC(size_t adtsHdrSize, uint8_t *data, size_t size);
    virtual void processAC3(uint8_t *data, size_t size);

    static AString aesBlockToStr(uint8_t block[AES_BLOCK_SIZE]);

@@ -60,4 +62,4 @@ private:

}  // namespace android

#endif // SAMPLE_AES_PROCESSOR_H_
#endif // HLS_SAMPLE_AES_PROCESSOR_H_
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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 SAMPLE_AES_PROCESSOR_H_

#define SAMPLE_AES_PROCESSOR_H_

#include <media/stagefright/foundation/AMessage.h>

#include <utils/RefBase.h>

namespace android {

// Base class of HlsSampleDecryptor which has dummy default implementation.
struct SampleDecryptor : RefBase {

    SampleDecryptor() { };

    virtual void signalNewSampleAesKey(const sp<AMessage> &) { };

    virtual size_t processNal(uint8_t *, size_t) { return -1; };
    virtual void processAAC(size_t, uint8_t *, size_t) { };
    virtual void processAC3(uint8_t *, size_t) { };

private:
    DISALLOW_EVIL_CONSTRUCTORS(SampleDecryptor);
};

}  // namespace android

#endif // SAMPLE_AES_PROCESSOR_H_