Files
android/proprietary/wvm/include/WVMExtractorImpl.h
Jeff Tinker e9c40a625c Fix native fault in WVMMediaSource::DecryptCallback
This change resolves a lifetime issue between the media extractor
and media sources.  The extractor was being passed as a context
object to a callout in the WV libs.  In some cases, a pointer to
the extractor would be delivered to the callout after the extractor
had been released.  This change assigns the responsibility of the
lifetime of the context object to the media source, to ensure that
a ref is always held on the context object during the lifetime of
the media source.

Change-Id: Ic7a57a1c8496a4798fe590ec356b8a19a4f69967
related-to-bug: 6502322
2012-05-16 19:08:25 -07:00

90 lines
2.3 KiB
C++

/*
* Copyright (C) 2011 Google, Inc. All Rights Reserved
*/
#ifndef WVMEXTRACTOR_H_
#define WVMEXTRACTOR_H_
#include "AndroidConfig.h"
#include "WVStreamControlAPI.h"
#include "WVMInfoListener.h"
#include "WVMExtractor.h"
#include <media/stagefright/DataSource.h>
#include <utils/RefBase.h>
// DLL entry - given a data source, instantiate a WVMExtractor object
namespace android {
WVMLoadableExtractor *GetInstance(sp<DataSource> dataSource);
bool IsWidevineMedia(const sp<DataSource>& dataSource);
class WVMMediaSource;
class WVMFileSource;
class WVMExtractorImpl : public WVMLoadableExtractor {
public:
WVMExtractorImpl(sp<DataSource> dataSource);
virtual size_t countTracks();
virtual sp<MediaSource> getTrack(size_t index);
virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
virtual sp<MetaData> getMetaData();
virtual int64_t getCachedDurationUs(status_t *finalStatus);
virtual void setAdaptiveStreamingMode(bool adaptive);
bool getAdaptiveStreamingMode() const;
//
// if in CryptoPlugin mode, the extractor doesn't decrypt,
// it just accumulates the ranges of data requiring decryption
// into the MediaBuffer's metadata, the decryption happens
// later via the CryptoPlugin
//
virtual void setCryptoPluginMode(bool cryptoPluginMode);
virtual void setUID(uid_t uid);
static void SocketInfoCallback(int fd, int op, void *context);
static void cleanup();
protected:
virtual ~WVMExtractorImpl();
void Initialize();
private:
status_t readAVCCMetaData(sp<MetaData> videoMetaData);
status_t readESDSMetaData(sp<MetaData> audioMetaData);
sp<WVMMediaSource> mAudioSource;
sp<WVMMediaSource> mVideoSource;
sp<MetaData> mFileMetaData;
sp<WVMFileSource> mFileSource;
sp<DataSource> mDataSource;
sp<WVMInfoListener> mInfoListener;
sp<ClientContext> mClientContext;
bool mHaveMetaData;
bool mUseAdaptiveStreaming;
bool mIsLiveStream;
bool mAdaptivePrefetching;
WVSession *mSession;
status_t mSetupStatus;
status_t readMetaData();
const static size_t kStreamCacheSize = 10 * 1024 * 1024;
WVMExtractorImpl(const WVMExtractorImpl &);
WVMExtractorImpl &operator=(const WVMExtractorImpl &);
};
} // namespace android
#endif // WVMEXTRACTOR_H_