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
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
/*
|
|
* Copyright (C) 2011 Google, Inc. All Rights Reserved
|
|
*/
|
|
|
|
#ifndef CLIENTCONTEXT_H_
|
|
#define CLIENTCONTEXT_H_
|
|
|
|
#include <utils/RefBase.h>
|
|
#include <media/stagefright/foundation/ABase.h>
|
|
|
|
namespace android {
|
|
|
|
class WVMMediaSource;
|
|
|
|
class ClientContext : public RefBase {
|
|
public:
|
|
ClientContext() : mUIDIsSet(false), mCryptoPluginMode(false) {}
|
|
|
|
void setUID(uid_t uid) { mUID = uid; mUIDIsSet = true; }
|
|
uid_t getUID() const { return mUID; }
|
|
bool haveUID() const { return mUIDIsSet; }
|
|
|
|
void setCryptoPluginMode(bool cryptoPluginMode) { mCryptoPluginMode = cryptoPluginMode; }
|
|
bool getCryptoPluginMode() const { return mCryptoPluginMode; }
|
|
|
|
void setAudioSource(sp<WVMMediaSource> const &audioSource) { mAudioSource = audioSource; }
|
|
void setVideoSource(sp<WVMMediaSource> const &videoSource) { mVideoSource = videoSource; }
|
|
|
|
sp<WVMMediaSource> getAudioSource() const { return mAudioSource.promote(); }
|
|
sp<WVMMediaSource> getVideoSource() const { return mVideoSource.promote(); }
|
|
|
|
private:
|
|
bool mUIDIsSet;;
|
|
uid_t mUID;
|
|
|
|
bool mCryptoPluginMode;
|
|
|
|
wp<WVMMediaSource> mAudioSource;
|
|
wp<WVMMediaSource> mVideoSource;
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(ClientContext);
|
|
};
|
|
};
|
|
|
|
#endif
|
|
|