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

Commit b210c2aa authored by vivek mehta's avatar vivek mehta Committed by Ricardo Cerqueira
Browse files

libstagefright: Add support for fragmented MPEG4 container

- Stagefright parser dosent support parsing fragmented 3G2 clips
- add support to used mm-parser to parser fragmented 3G2 clips

(cherry picked from commit f1eb550a11bdc2a4534a89764f8c42008add90ae)

Change-Id: I9afcbd144dbbd50218b5ad8733b07d6c73f5f4d7
parent 273bce7a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 * Copyright (C) 2010-2012 Code Aurora Forum
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -77,7 +78,12 @@ public:
            const sp<DataSource> &source, String8 *mimeType,
            float *confidence, sp<AMessage> *meta);

#ifdef QCOM_HARDWARE
    //isExtendedExtractor if true, will store the location of the sniffer to register
    static void RegisterSniffer(SnifferFunc func, bool isExtendedExtractor = false);
#else
    static void RegisterSniffer(SnifferFunc func);
#endif
    static void RegisterDefaultSniffers();

    // for DRM
@@ -92,6 +98,7 @@ public:

    virtual String8 getMIMEType() const;


protected:
    virtual ~DataSource() {}

@@ -99,6 +106,10 @@ private:
    static Mutex gSnifferMutex;
    static List<SnifferFunc> gSniffers;

#ifdef QCOM_HARDWARE
    static List<SnifferFunc>::iterator extendedSnifferPosition;
#endif

    DataSource(const DataSource &);
    DataSource &operator=(const DataSource &);
};
+2 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 * Copyright (C) 2010-2012 Code Aurora Forum
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -68,6 +69,7 @@ extern const char *MEDIA_MIMETYPE_CONTAINER_QCP;
extern const char *MEDIA_MIMETYPE_VIDEO_DIVX311;
extern const char *MEDIA_MIMETYPE_VIDEO_DIVX4;
extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG2;
extern const char *MEDIA_MIMETYPE_CONTAINER_3G2;
#endif
}  // namespace android

+50 −2
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 * Copyright (C) 2010-2011 Code Aurora Forum
 * Copyright (C) 2010-2012 Code Aurora Forum
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -33,6 +33,8 @@
#include "include/AVIExtractor.h"
#endif

#include <media/stagefright/MediaDefs.h>

#include "matroska/MatroskaExtractor.h"

#include <media/stagefright/foundation/AMessage.h>
@@ -68,16 +70,26 @@ status_t DataSource::getSize(off64_t *size) {

Mutex DataSource::gSnifferMutex;
List<DataSource::SnifferFunc> DataSource::gSniffers;
#ifdef QCOM_HARDWARE
List<DataSource::SnifferFunc>::iterator DataSource::extendedSnifferPosition;
#endif

bool DataSource::sniff(
        String8 *mimeType, float *confidence, sp<AMessage> *meta) {

    *mimeType = "";
    *confidence = 0.0f;
    meta->clear();

    Mutex::Autolock autoLock(gSnifferMutex);
    for (List<SnifferFunc>::iterator it = gSniffers.begin();
         it != gSniffers.end(); ++it) {

#ifdef QCOM_HARDWARE
        //Dont call the first sniffer from extended extarctor
        if(it == extendedSnifferPosition)
            continue;
#endif

        String8 newMimeType;
        float newConfidence;
        sp<AMessage> newMeta;
@@ -88,7 +100,29 @@ bool DataSource::sniff(
                *meta = newMeta;
#ifdef QCOM_HARDWARE
                if(*confidence >= 0.6f) {

                    LOGV("Ignore other Sniffers - confidence = %f , mimeType = %s",*confidence,mimeType->string());

                    char value[PROPERTY_VALUE_MAX];
                    if( (!strcasecmp((*mimeType).string(), MEDIA_MIMETYPE_CONTAINER_MPEG4)) &&
                        (property_get("mmp.enable.3g2", value, NULL)) &&
                        (!strcasecmp(value, "true") || !strcmp(value, "1"))) {

                        //Incase of mimeType MPEG4 call the extended parser sniffer to check
                        //if this is fragmented or not.
                        LOGV("calling Extended Sniff if mimeType = %s ",(*mimeType).string());
                        String8 tmpMimeType;
                        float tmpConfidence;
                        sp<AMessage> tmpMeta;
                        (*extendedSnifferPosition)(this, &tmpMimeType, &tmpConfidence, &tmpMeta);
                        if (tmpConfidence > *confidence) {
                            *mimeType = tmpMimeType;
                            *confidence = tmpConfidence;
                            *meta = tmpMeta;
                            LOGV("Confidence of Extended sniffer greater than previous sniffer ");
                        }
                    }

                    break;
                }
#endif
@@ -100,7 +134,11 @@ bool DataSource::sniff(
}

// static
#ifdef QCOM_HARDWARE
void DataSource::RegisterSniffer(SnifferFunc func, bool isExtendedExtractor) {
#else
void DataSource::RegisterSniffer(SnifferFunc func) {
#endif
    Mutex::Autolock autoLock(gSnifferMutex);

    for (List<SnifferFunc>::iterator it = gSniffers.begin();
@@ -111,6 +149,16 @@ void DataSource::RegisterSniffer(SnifferFunc func) {
    }

    gSniffers.push_back(func);

#ifdef QCOM_HARDWARE
    if(isExtendedExtractor)
    {
        extendedSnifferPosition = gSniffers.end();
        extendedSnifferPosition--;
    }

    return;
#endif
}

// static
+7 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.

 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -135,9 +135,15 @@ void ExtendedExtractor::RegisterSniffers() {
        return;
    }

    bool flag= true;
    //Register the remote sniffers with the DataSource.
    for(int i=0; i<snifferCount; i++) {
#ifdef QCOM_HARDWARE
        DataSource::RegisterSniffer(snifferArray[i],flag);
        flag = false;
#else
        DataSource::RegisterSniffer(snifferArray[i]);
#endif
    }
}

+3 −3
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 * Copyright (C) 2010-2012 Code Aurora Forum
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -62,10 +63,9 @@ const char *MEDIA_MIMETYPE_CONTAINER_AAC = "audio/aac";
const char *MEDIA_MIMETYPE_CONTAINER_QCP = "audio/vnd.qcelp";
const char *MEDIA_MIMETYPE_VIDEO_DIVX311 = "video/divx311";
const char *MEDIA_MIMETYPE_VIDEO_DIVX4 = "video/divx4";
const char *MEDIA_MIMETYPE_CONTAINER_MPEG2 = "video/mp2";
const char *MEDIA_MIMETYPE_CONTAINER_3G2 = "video/3g2";
#endif
const char *MEDIA_MIMETYPE_TEXT_3GPP = "text/3gpp-tt";

#ifdef QCOM_HARDWARE
const char *MEDIA_MIMETYPE_CONTAINER_MPEG2 = "video/mp2";
#endif
}  // namespace android