Bug 1151378: Part3. Fix constness and remove use of reference to refcounted ptr. r=k17e

This commit is contained in:
Jean-Yves Avenard 2015-04-07 20:33:18 +10:00
parent 1d47a88bf2
commit d7cb635d09
5 changed files with 25 additions and 26 deletions

View File

@ -19,7 +19,7 @@ namespace mp4_demuxer
{
static int32_t
FindInt32(sp<MetaData>& mMetaData, uint32_t mKey)
FindInt32(const MetaData* mMetaData, uint32_t mKey)
{
int32_t value;
if (!mMetaData->findInt32(mKey, &value))
@ -28,7 +28,7 @@ FindInt32(sp<MetaData>& mMetaData, uint32_t mKey)
}
static int64_t
FindInt64(sp<MetaData>& mMetaData, uint32_t mKey)
FindInt64(const MetaData* mMetaData, uint32_t mKey)
{
int64_t value;
if (!mMetaData->findInt64(mKey, &value))
@ -38,7 +38,7 @@ FindInt64(sp<MetaData>& mMetaData, uint32_t mKey)
template <typename T, size_t N>
static bool
FindData(sp<MetaData>& aMetaData, uint32_t aKey, mozilla::Vector<T, N>* aDest)
FindData(const MetaData* aMetaData, uint32_t aKey, mozilla::Vector<T, N>* aDest)
{
const void* data;
size_t size;
@ -57,7 +57,7 @@ FindData(sp<MetaData>& aMetaData, uint32_t aKey, mozilla::Vector<T, N>* aDest)
template <typename T>
static bool
FindData(sp<MetaData>& aMetaData, uint32_t aKey, nsTArray<T>* aDest)
FindData(const MetaData* aMetaData, uint32_t aKey, nsTArray<T>* aDest)
{
const void* data;
size_t size;
@ -75,7 +75,7 @@ FindData(sp<MetaData>& aMetaData, uint32_t aKey, nsTArray<T>* aDest)
}
static bool
FindData(sp<MetaData>& aMetaData, uint32_t aKey, ByteBuffer* aDest)
FindData(const MetaData* aMetaData, uint32_t aKey, ByteBuffer* aDest)
{
return FindData(aMetaData, aKey, static_cast<nsTArray<uint8_t>*>(aDest));
}
@ -104,7 +104,7 @@ CryptoFile::DoUpdate(const uint8_t* aData, size_t aLength)
}
void
TrackConfig::Update(sp<MetaData>& aMetaData, const char* aMimeType)
TrackConfig::Update(const MetaData* aMetaData, const char* aMimeType)
{
mime_type = aMimeType;
duration = FindInt64(aMetaData, kKeyDuration);
@ -116,7 +116,7 @@ TrackConfig::Update(sp<MetaData>& aMetaData, const char* aMimeType)
}
void
AudioDecoderConfig::Update(sp<MetaData>& aMetaData, const char* aMimeType)
AudioDecoderConfig::Update(const MetaData* aMetaData, const char* aMimeType)
{
TrackConfig::Update(aMetaData, aMimeType);
channel_count = FindInt32(aMetaData, kKeyChannelCount);
@ -154,7 +154,7 @@ AudioDecoderConfig::IsValid()
}
void
VideoDecoderConfig::Update(sp<MetaData>& aMetaData, const char* aMimeType)
VideoDecoderConfig::Update(const MetaData* aMetaData, const char* aMimeType)
{
TrackConfig::Update(aMetaData, aMimeType);
display_width = FindInt32(aMetaData, kKeyDisplayWidth);

View File

@ -15,7 +15,6 @@
namespace stagefright
{
template <typename T> class sp;
class MetaData;
}
@ -113,7 +112,7 @@ public:
{
return mType == kVideoTrack;
}
void Update(stagefright::sp<stagefright::MetaData>& aMetaData,
void Update(const stagefright::MetaData* aMetaData,
const char* aMimeType);
};
@ -142,7 +141,7 @@ public:
nsRefPtr<ByteBuffer> extra_data;
nsRefPtr<ByteBuffer> audio_specific_config;
void Update(stagefright::sp<stagefright::MetaData>& aMetaData,
void Update(const stagefright::MetaData* aMetaData,
const char* aMimeType);
bool IsValid();
@ -171,7 +170,7 @@ public:
nsRefPtr<ByteBuffer> extra_data; // Unparsed AVCDecoderConfig payload.
void Update(stagefright::sp<stagefright::MetaData>& aMetaData,
void Update(const stagefright::MetaData* aMetaData,
const char* aMimeType);
bool IsValid();
};

View File

@ -117,7 +117,7 @@ MP4Demuxer::Init()
return false;
}
mPrivate->mAudio = track;
mAudioConfig.Update(metaData, mimeType);
mAudioConfig.Update(metaData.get(), mimeType);
nsRefPtr<Index> index = new Index(mPrivate->mAudio->exportIndex(),
mSource, mAudioConfig.mTrackId,
/* aIsAudio = */ true, mMonitor);
@ -129,7 +129,7 @@ MP4Demuxer::Init()
return false;
}
mPrivate->mVideo = track;
mVideoConfig.Update(metaData, mimeType);
mVideoConfig.Update(metaData.get(), mimeType);
nsRefPtr<Index> index = new Index(mPrivate->mVideo->exportIndex(),
mSource, mVideoConfig.mTrackId,
/* aIsAudio = */ false, mMonitor);

View File

@ -201,16 +201,16 @@ public:
int32_t left, int32_t top,
int32_t right, int32_t bottom);
bool findCString(uint32_t key, const char **value);
bool findInt32(uint32_t key, int32_t *value);
bool findInt64(uint32_t key, int64_t *value);
bool findFloat(uint32_t key, float *value);
bool findPointer(uint32_t key, void **value);
bool findCString(uint32_t key, const char **value) const;
bool findInt32(uint32_t key, int32_t *value) const;
bool findInt64(uint32_t key, int64_t *value) const;
bool findFloat(uint32_t key, float *value) const;
bool findPointer(uint32_t key, void **value) const;
bool findRect(
uint32_t key,
int32_t *left, int32_t *top,
int32_t *right, int32_t *bottom);
int32_t *right, int32_t *bottom) const;
bool setData(uint32_t key, uint32_t type, const void *data, size_t size);

View File

@ -90,7 +90,7 @@ bool MetaData::setRect(
return setData(key, TYPE_RECT, &r, sizeof(r));
}
bool MetaData::findCString(uint32_t key, const char **value) {
bool MetaData::findCString(uint32_t key, const char **value) const {
uint32_t type;
const void *data;
size_t size;
@ -103,7 +103,7 @@ bool MetaData::findCString(uint32_t key, const char **value) {
return true;
}
bool MetaData::findInt32(uint32_t key, int32_t *value) {
bool MetaData::findInt32(uint32_t key, int32_t *value) const {
uint32_t type;
const void *data;
size_t size;
@ -118,7 +118,7 @@ bool MetaData::findInt32(uint32_t key, int32_t *value) {
return true;
}
bool MetaData::findInt64(uint32_t key, int64_t *value) {
bool MetaData::findInt64(uint32_t key, int64_t *value) const {
uint32_t type;
const void *data;
size_t size;
@ -133,7 +133,7 @@ bool MetaData::findInt64(uint32_t key, int64_t *value) {
return true;
}
bool MetaData::findFloat(uint32_t key, float *value) {
bool MetaData::findFloat(uint32_t key, float *value) const {
uint32_t type;
const void *data;
size_t size;
@ -148,7 +148,7 @@ bool MetaData::findFloat(uint32_t key, float *value) {
return true;
}
bool MetaData::findPointer(uint32_t key, void **value) {
bool MetaData::findPointer(uint32_t key, void **value) const {
uint32_t type;
const void *data;
size_t size;
@ -166,7 +166,7 @@ bool MetaData::findPointer(uint32_t key, void **value) {
bool MetaData::findRect(
uint32_t key,
int32_t *left, int32_t *top,
int32_t *right, int32_t *bottom) {
int32_t *right, int32_t *bottom) const {
uint32_t type;
const void *data;
size_t size;