From b19f3604b0abc7d3b835acb11c8dbc37fee8fe3d Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Mon, 28 Dec 2015 13:08:26 -0800 Subject: stagefright: Those who cannot remember history are doomed to repeat it * A new sniffer might want to defer it's work based on the knowledge already gained by those who have already sniffed. * This is the case for our FFMPEG sniffer, which is pretty awesome in that it is able to fill in all the gaps and detect almost anything, however the cost is additional latency during scanning and startup. * As we cycle thru each sniffer, feed the current score to the next. It is up to the extractor to use this knowledge wisely. * Additionally, print some metrics on how long the sniff took. Change-Id: I5dc8de11ed4939a01eabb0cae0b4e1e71d991eea --- media/libstagefright/DataSource.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'media/libstagefright/DataSource.cpp') diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp index 3d8688f..b833f9e 100644 --- a/media/libstagefright/DataSource.cpp +++ b/media/libstagefright/DataSource.cpp @@ -136,6 +136,7 @@ bool DataSource::gSniffersRegistered = false; bool DataSource::sniff( String8 *mimeType, float *confidence, sp *meta) { + *mimeType = ""; *confidence = 0.0f; meta->clear(); @@ -147,11 +148,18 @@ bool DataSource::sniff( } } + String8 newMimeType; + if (mimeType != NULL) { + newMimeType.setTo(*mimeType); + } + float newConfidence = *confidence; + for (List::iterator it = gSniffers.begin(); it != gSniffers.end(); ++it) { - String8 newMimeType; - float newConfidence; - sp newMeta; + int64_t sniffStart = ALooper::GetNowUs(); + String8 newMimeType = *mimeType; + float newConfidence = *confidence; + sp newMeta = *meta; if ((*it)(this, &newMimeType, &newConfidence, &newMeta)) { if (newConfidence > *confidence) { *mimeType = newMimeType; @@ -159,6 +167,9 @@ bool DataSource::sniff( *meta = newMeta; } } + ALOGV("Sniffer (%p) completed in %.2f ms (mime=%s confidence=%.2f", + this, ((float)(ALooper::GetNowUs() - sniffStart) / 1000.0f), + mimeType == NULL ? NULL : (*mimeType).string(), *confidence); } return *confidence > 0.0; -- cgit v1.1