зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1344649 - part 3: rename DurationMap and turn it into a generic class. r=jya
MozReview-Commit-ID: AMMxMPkuYXk --HG-- extra : rebase_source : 438100efafb883c8cd67895657877da9fb6f54ce
This commit is contained in:
Родитель
a5d3bc8a18
Коммит
2f58c785e9
|
@ -2,37 +2,38 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_DurationMap_h
|
||||
#define mozilla_DurationMap_h
|
||||
#ifndef mozilla_SimpleMap_h
|
||||
#define mozilla_SimpleMap_h
|
||||
|
||||
#include "mozilla/Pair.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DurationMap
|
||||
template<typename T>
|
||||
class SimpleMap
|
||||
{
|
||||
public:
|
||||
typedef Pair<int64_t, int64_t> DurationElement;
|
||||
typedef Pair<int64_t, T> Element;
|
||||
|
||||
DurationMap() : mMutex("DurationMap") { }
|
||||
SimpleMap() : mMutex("SimpleMap") { }
|
||||
|
||||
// Insert Key and Duration pair at the end of our map.
|
||||
void Insert(int64_t aKey, int64_t aDuration)
|
||||
// Insert Key and Value pair at the end of our map.
|
||||
void Insert(int64_t aKey, const T& aValue)
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
mMap.AppendElement(MakePair(aKey, aDuration));
|
||||
mMap.AppendElement(MakePair(aKey, aValue));
|
||||
}
|
||||
// Sets aDuration matching aKey and remove it from the map if found.
|
||||
// Sets aValue matching aKey and remove it from the map if found.
|
||||
// The element returned is the first one found.
|
||||
// Returns true if found, false otherwise.
|
||||
bool Find(int64_t aKey, int64_t& aDuration)
|
||||
bool Find(int64_t aKey, T& aValue)
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
for (uint32_t i = 0; i < mMap.Length(); i++) {
|
||||
DurationElement& element = mMap[i];
|
||||
Element& element = mMap[i];
|
||||
if (element.first() == aKey) {
|
||||
aDuration = element.second();
|
||||
aValue = element.second();
|
||||
mMap.RemoveElementAt(i);
|
||||
return true;
|
||||
}
|
||||
|
@ -48,9 +49,9 @@ public:
|
|||
|
||||
private:
|
||||
Mutex mMutex; // To protect mMap.
|
||||
AutoTArray<DurationElement, 16> mMap;
|
||||
AutoTArray<Element, 16> mMap;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_DurationMap_h
|
||||
#endif // mozilla_SimpleMap_h
|
|
@ -5,7 +5,7 @@
|
|||
#include "AndroidBridge.h"
|
||||
#include "AndroidDecoderModule.h"
|
||||
#include "AndroidSurfaceTexture.h"
|
||||
#include "DurationMap.h"
|
||||
#include "SimpleMap.h"
|
||||
#include "FennecJNINatives.h"
|
||||
#include "GLImages.h"
|
||||
#include "MediaData.h"
|
||||
|
@ -285,7 +285,7 @@ public:
|
|||
private:
|
||||
layers::ImageContainer* mImageContainer;
|
||||
RefPtr<AndroidSurfaceTexture> mSurfaceTexture;
|
||||
DurationMap mInputDurations;
|
||||
SimpleMap<int64_t> mInputDurations;
|
||||
bool mIsCodecSupportAdaptivePlayback = false;
|
||||
Mutex mMutex; // Protects mConfig
|
||||
VideoInfo mConfig;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "FFmpegLibWrapper.h"
|
||||
#include "FFmpegDataDecoder.h"
|
||||
#include "DurationMap.h"
|
||||
#include "SimpleMap.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ class FFmpegVideoDecoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>
|
|||
{
|
||||
typedef mozilla::layers::Image Image;
|
||||
typedef mozilla::layers::ImageContainer ImageContainer;
|
||||
typedef SimpleMap<int64_t> DurationMap;
|
||||
|
||||
public:
|
||||
FFmpegVideoDecoder(FFmpegLibWrapper* aLib, TaskQueue* aTaskQueue,
|
||||
|
|
|
@ -11,10 +11,10 @@ EXPORTS += [
|
|||
'agnostic/TheoraDecoder.h',
|
||||
'agnostic/VorbisDecoder.h',
|
||||
'agnostic/VPXDecoder.h',
|
||||
'DurationMap.h',
|
||||
'MediaTelemetryConstants.h',
|
||||
'PDMFactory.h',
|
||||
'PlatformDecoderModule.h',
|
||||
'SimpleMap.h',
|
||||
'wrappers/H264Converter.h',
|
||||
'wrappers/MediaDataDecoderProxy.h'
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче