virtual float scoreFactory(const sp<IMediaPlayer>& /*client*/, int fd, int64_t offset, int64_t length, float /*curScore*/) { if (legacyDrm()) { sp<DataSource> source = new FileSource(dup(fd), offset, length); String8 mimeType; float confidence; if (SniffWVM(source, &mimeType, &confidence, NULL /* format */)) { return 1.0; } } if (getDefaultPlayerType() == STAGEFRIGHT_PLAYER) { char buf[20]; lseek(fd, offset, SEEK_SET); read(fd, buf, sizeof(buf)); lseek(fd, offset, SEEK_SET); uint32_t ident = *((uint32_t*)buf); // Ogg vorbis? if (ident == 0x5367674f) // 'OggS' return 1.0; } return 0.0; }
status_t NuMediaExtractor::setDataSource( const char *path, const KeyedVector<String8, String8> *headers) { Mutex::Autolock autoLock(mLock); if (mImpl != NULL) { return -EINVAL; } sp<DataSource> dataSource = DataSource::CreateFromURI(path, headers); if (dataSource == NULL) { return -ENOENT; } mIsWidevineExtractor = false; if (!strncasecmp("widevine://", path, 11)) { String8 mimeType; float confidence; sp<AMessage> dummy; bool success = SniffWVM(dataSource, &mimeType, &confidence, &dummy); if (!success || strcasecmp( mimeType.string(), MEDIA_MIMETYPE_CONTAINER_WVM)) { return ERROR_UNSUPPORTED; } sp<WVMExtractor> extractor = new WVMExtractor(dataSource); extractor->setAdaptiveStreamingMode(true); mImpl = extractor; mIsWidevineExtractor = true; } else { mImpl = MediaExtractor::Create(dataSource); } if (mImpl == NULL) { return ERROR_UNSUPPORTED; } sp<MetaData> fileMeta = mImpl->getMetaData(); const char *containerMime; if (fileMeta != NULL && fileMeta->findCString(kKeyMIMEType, &containerMime) && !strcasecmp(containerMime, "video/wvm")) { // We always want to use "cryptoPluginMode" when using the wvm // extractor. We can tell that it is this extractor by looking // at the container mime type. // The cryptoPluginMode ensures that the extractor will actually // give us data in a call to MediaSource::read(), unlike its // default mode that we use from AwesomePlayer. static_cast<WVMExtractor *>(mImpl.get())->setCryptoPluginMode(true); } else if (mImpl->getDrmFlag()) { // For all other drm content, we don't want to expose decrypted // content to Java application. mImpl.clear(); mImpl = NULL; return ERROR_UNSUPPORTED; } mDataSource = dataSource; updateDurationAndBitrate(); return OK; }