blob: a5b35e356970a42e0d54c8f9d486908f91b52dde [file] [log] [blame]
/**
* Copyright (C) 2020 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.
*/
#include <dlfcn.h>
#include <media/IMediaHTTPService.h>
#include <media/DataSource.h>
#include <media/stagefright/DataSourceFactory.h>
#include <media/MediaExtractor.h>
#include <media/stagefright/MetaData.h>
#include <media/IMediaExtractor.h>
#include <media/DataSourceBase.h>
#include "../includes/memutils_track.h"
#include "../includes/common.h"
#define LIB_NAME "/system/lib64/extractors/libmp4extractor.so"
#define PSSH_BOX_SIZE 1048576
char enable_selective_overload = ENABLE_NONE;
using namespace android;
bool is_tracking_required(size_t size) {
return (size == PSSH_BOX_SIZE);
}
int main(int argc, char* argv[]) {
(void)argc;
(void)argv;
#if _64_BIT
if (argc < 2) {
return EXIT_FAILURE;
}
void *libHandle = dlopen(LIB_NAME, RTLD_NOW | RTLD_LOCAL);
if (!libHandle) {
return EXIT_FAILURE;
}
sp < DataSource > dataSource = DataSourceFactory::CreateFromURI(NULL,
argv[1]);
if (dataSource == nullptr) {
dlclose(libHandle);
return EXIT_FAILURE;
}
MediaExtractor::GetExtractorDef getDef =
(MediaExtractor::GetExtractorDef) dlsym(libHandle,
"GETEXTRACTORDEF");
if (!getDef) {
dlclose(libHandle);
return EXIT_FAILURE;
}
void *meta = nullptr;
MediaExtractor::CreatorFunc creator = NULL;
MediaExtractor::FreeMetaFunc freeMeta = nullptr;
float confidence;
creator = getDef().sniff(dataSource.get(), &confidence, &meta, &freeMeta);
if (!creator) {
dlclose(libHandle);
return EXIT_FAILURE;
}
MediaExtractor *ret = creator(dataSource.get(), meta);
if (ret == nullptr) {
dlclose(libHandle);
return EXIT_FAILURE;
}
if (meta != nullptr && freeMeta != nullptr) {
freeMeta(meta);
}
sp < MetaData > metaData = new MetaData();
enable_selective_overload = ENABLE_MALLOC_CHECK;
ret->getTrackMetaData(*metaData.get(), 0, 1);
enable_selective_overload = ENABLE_NONE;
dlclose(libHandle);
#endif /* _64_BIT */
return EXIT_SUCCESS;
}