From d7cb635d093e7e5473467e0d215910104d2d9284 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 7 Apr 2015 20:33:18 +1000 Subject: [PATCH] Bug 1151378: Part3. Fix constness and remove use of reference to refcounted ptr. r=k17e --- media/libstagefright/binding/DecoderData.cpp | 16 ++++++++-------- .../binding/include/mp4_demuxer/DecoderData.h | 7 +++---- media/libstagefright/binding/mp4_demuxer.cpp | 4 ++-- .../av/include/media/stagefright/MetaData.h | 12 ++++++------ .../av/media/libstagefright/MetaData.cpp | 12 ++++++------ 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/media/libstagefright/binding/DecoderData.cpp b/media/libstagefright/binding/DecoderData.cpp index beb2641519b5..824c47669a22 100644 --- a/media/libstagefright/binding/DecoderData.cpp +++ b/media/libstagefright/binding/DecoderData.cpp @@ -19,7 +19,7 @@ namespace mp4_demuxer { static int32_t -FindInt32(sp& 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& mMetaData, uint32_t mKey) } static int64_t -FindInt64(sp& 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& mMetaData, uint32_t mKey) template static bool -FindData(sp& aMetaData, uint32_t aKey, mozilla::Vector* aDest) +FindData(const MetaData* aMetaData, uint32_t aKey, mozilla::Vector* aDest) { const void* data; size_t size; @@ -57,7 +57,7 @@ FindData(sp& aMetaData, uint32_t aKey, mozilla::Vector* aDest) template static bool -FindData(sp& aMetaData, uint32_t aKey, nsTArray* aDest) +FindData(const MetaData* aMetaData, uint32_t aKey, nsTArray* aDest) { const void* data; size_t size; @@ -75,7 +75,7 @@ FindData(sp& aMetaData, uint32_t aKey, nsTArray* aDest) } static bool -FindData(sp& aMetaData, uint32_t aKey, ByteBuffer* aDest) +FindData(const MetaData* aMetaData, uint32_t aKey, ByteBuffer* aDest) { return FindData(aMetaData, aKey, static_cast*>(aDest)); } @@ -104,7 +104,7 @@ CryptoFile::DoUpdate(const uint8_t* aData, size_t aLength) } void -TrackConfig::Update(sp& 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& aMetaData, const char* aMimeType) } void -AudioDecoderConfig::Update(sp& 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& aMetaData, const char* aMimeType) +VideoDecoderConfig::Update(const MetaData* aMetaData, const char* aMimeType) { TrackConfig::Update(aMetaData, aMimeType); display_width = FindInt32(aMetaData, kKeyDisplayWidth); diff --git a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h index adac32868836..d87700450109 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h +++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h @@ -15,7 +15,6 @@ namespace stagefright { -template class sp; class MetaData; } @@ -113,7 +112,7 @@ public: { return mType == kVideoTrack; } - void Update(stagefright::sp& aMetaData, + void Update(const stagefright::MetaData* aMetaData, const char* aMimeType); }; @@ -142,7 +141,7 @@ public: nsRefPtr extra_data; nsRefPtr audio_specific_config; - void Update(stagefright::sp& aMetaData, + void Update(const stagefright::MetaData* aMetaData, const char* aMimeType); bool IsValid(); @@ -171,7 +170,7 @@ public: nsRefPtr extra_data; // Unparsed AVCDecoderConfig payload. - void Update(stagefright::sp& aMetaData, + void Update(const stagefright::MetaData* aMetaData, const char* aMimeType); bool IsValid(); }; diff --git a/media/libstagefright/binding/mp4_demuxer.cpp b/media/libstagefright/binding/mp4_demuxer.cpp index d5952ac18e07..b2763fc4d63f 100644 --- a/media/libstagefright/binding/mp4_demuxer.cpp +++ b/media/libstagefright/binding/mp4_demuxer.cpp @@ -117,7 +117,7 @@ MP4Demuxer::Init() return false; } mPrivate->mAudio = track; - mAudioConfig.Update(metaData, mimeType); + mAudioConfig.Update(metaData.get(), mimeType); nsRefPtr 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 = new Index(mPrivate->mVideo->exportIndex(), mSource, mVideoConfig.mTrackId, /* aIsAudio = */ false, mMonitor); diff --git a/media/libstagefright/frameworks/av/include/media/stagefright/MetaData.h b/media/libstagefright/frameworks/av/include/media/stagefright/MetaData.h index 30d969d29fda..2eb898be7109 100644 --- a/media/libstagefright/frameworks/av/include/media/stagefright/MetaData.h +++ b/media/libstagefright/frameworks/av/include/media/stagefright/MetaData.h @@ -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); diff --git a/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp b/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp index c832c9694cb2..7486aca3d29a 100644 --- a/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp +++ b/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp @@ -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;