mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:11:03 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1150437 - Make gmp-clearkey consistently Apache2 licensed. r=edwin,jwwang,kentuckyfriedtakahe (3c954c73dd) - Bug 1223486 - Ensure WrapTexCoord returns 0.0 instead of 1.0 when given a negative whole number. r=Bas (b4af8eb524) - Bug 1160914 - Make gmp-clearkey's decoders threadsafe refcounted, to handle DecodingComplete while GMPVideoHost::CreateFrame() is waiting. r=edwin (03359c7730) - Bug 1206763 - Enable SkiaGL canvas on gonk r=mattwoodrow (1588079b23) - Decouple CairoImage from ImageContainer. (bug 1222910, r=roc) (a93a4dad82) - Decouple D3D11ShareHandleImage from ImageContainer. (bug 1222910, r=mattwoodrow) (9642ef1c53) - Bug 1194753 - Wait longer when decoding the first frame of D3D9 DXVA video before deciding it is invalid. r=cpearce (865fe1d2f3) - Decouple D3D9SurfaceImage from ImageContainer. (bug 1222910, r=mattwoodrow) (55bc5abffc) - Bug 1191534 - Implement BlitImageToFramebuffer for IOSurface. r=jgilbert (0da6aff77f) - Decouple EGLImageImage from ImageContainer. (bug 1222910, r=snorp) (cffb7aadcb) - Decouple SurfaceTextureImage from ImageContainer. (bug 1222910, r=snorp) (5b920014d0) - Decouple MacIOSurfaceImage from ImageContainer. (bug 1222910, r=mstange) (ffab69155c) - Decouple SharedRGBImage and PlanarYCbCrImage from ImageContainer. (bug 1222910, r=mattwoodrow) (a9f6e23788) - Remove Gonk usage of ImageContainer::CreateImage. (bug 1222910, r=sotaro) (3f460b901d) - Remove CreateImage() from ImageContainer, ImageFactory, and ImageClient. (bug 1222910, r=roc) (873d5d5e47) - Bug 1212795: P1. Ensure the check if HW acceleration is allowed is performed on the main thread. r=jwwang (7cac257e5a) - Bug 1137529: Prefer Apple's VDA hardware acceleration for Hi-Def videos. r=rillian (a3ffc48e5e) - Bug 1212795: P2. Ensure all frameworks required for video decoding on mac are loaded. r=jwwang (b903b94c60) - Bug 1212795: P3. Make AppleDecoderModule detects if the required modules are loaded. r=jwwang (fb132e36b0) - Bug 1221991 - [1.3] Make SupportsMimeType a const function. r=jya (2450030808) - Bug 1221991 - [2.3] Split DecoderLoop into functions, simplify decoding state and clean up style. r=snorp (7c0e665cf7) - Bug 1221991 - [3.1] Manage module state via accessor functions. r=snorp (491b00f74b) - Bug 1221991 - [4.2] Add AndroidDecoderModule logging. r=snorp (7213505016) - Bug 1153110: Don't prefer VDA for 720p and above. r=rillian (50d5fbfa7c) - remove PR_LOGGING (44f4efbaa2) - Bug 1169653 - Limit use of the speech recognition API in JS to certified apps or apps with the proper flags set. r=smaug (c93a8949b8) - Bug 1133633: Part2. Enable async decoding on mac. r=mattmoodrow (c9740168bd) - Bug 1154896: Report decoding errors back to MP4Reader. r=rillian (26291f72e1) - Bug 1154896: Part2. Ignore kVTDecodeInfo_FrameDropped flag. r=rillian (bfca4c264e) - Bug 1198094: P1. Limit rate at which InputExhausted could be called by mac decoder. r=rillian (e5819c1666) - Bug 1214678 - Allow Apple media decoders to work on iOS r=jya (c475eff0be) - Bug 1219140 - Remove AskMediaCodecAndWait() r=bwu (dbe8d364ec) - fix includes (432c3419b0) - adapted Bug 1159509 - Support audio AMR-NB for Gonk in MP4Reader. r=jya (adaddc5c21) - Bug 1154512 - Remove MediaTaskQueue::SyncDispatch() from PDM. r=cpearce (5bddd082bd) - Bug 1204622 - release codec listener at reader task queue. r=jya (72b062b5d7) - Bug 1097498 - Wait fence for the graphic buffer. r=sotaro (c72f301939) - Bug 1198664 - Refactor: move common behaviors to base class. r=bwu,jya (a754813c5b) - Bug 1198664 - Use looper to process decoder tasks. r=bwu (768315de13) - Bug 1174721 - Use AudioCompactor for GonkAudioDecoderManager. r=sotaro (768e68c946) - Bug 1199809 - Refactor: use RAII to help manage output buffer lifecycle. r=sotaro (9a6e0dceb7) - Bug 1133955 - Record the last seek time to decide the direction to seek. r=sotaro (d0bcdbe68b) - Bug 1210045 - Fix GonkVideoDecoderManager shutdown during initialization r=bwu (b379248ff1) - Bug 1214997 - Use MozPromise in MediaCodecProxy and OMXCodecProxy r=bwu (ab9a92d640) - Bug 1199809 - Make a copy of output buffer after flush(). r=sotaro (17465ecaea) - Bug 1216895 - assert that decoder methods are run on correct thread. r=jya (b8c106c2ca) - Bug 1185018 - Part 1 of 1 - Made speech recognition services language dependent and removed assumption of a single service. r=smaug (f83acf82b4) - Bug 1207416: Add Telemetry for time spent in different Load states in WebRTC r=gcp (e3959b6760) - Bug 1219480 - Replace PRLogModuleInfo with LazyLogModule in the media directory. r=rillian (a9b13ef334) - Bug 1196558: Don't assert should output task not be dispatched. r=edwin (a2569bca73) - Bug 1199193: Ensure DrainComplete() is called once all decoded frames have been output. r=rillian (760fb42753) - Bug 1079621 - Change non-fatal errors to warnings. r=rillian (20c85e7e56) - Bug 1185234 - Implement SpeechRecognition::interimResults. r=smaug (b3d635d8c0) - Bug 1171850 - Remove 'models' dir from MODELSPS_DEST as the dir 'models' now comes from MODELSPS_FILES. r=gps (5515511e3a) - Bug 1183503 - Rename model and dictionary files for recognition in preparation for localization. r=smaug (32c78610af) - Bug 1185235 - Implement SpeechRecognition::maxAlternatives. r=smaug (91eac7f30f) - Bug 1177514 - Remove final text of 'ERROR' on recognition error, should be signaled by SpeechRecognitionError. r=smaug (c8d7b198e0) - Bug 1187791 - Part 1 of 1 - SpeechRecognition::maxAlternatives can't throw; so, rm webidl throws specifier. r=smaug (e295b2bde5) - Bug 1213131: [vpx] Configure libvpx decoder to use multi-threads decoding. r=kentuckyfriedtakahe (f38ba0ef82) - Bug 1206845: Prevent overflows in MediaCache. r=roc (e8a228dcd3) - Bug 1205825 - part 1 - don't reacquire the media cache's monitor in MediaCacheStream::FlushPartialBlockInternal; r=roc (6342592be3) - Bug 1205825 - part 2 - call Get*CachedData*Internal variants from MediaCacheStream::GetCachedRanges; r=roc (f229c8f757)
This commit is contained in:
+1
-2
@@ -945,7 +945,7 @@ pref("devtools.debugger.unix-domain-socket", "/data/local/debugger-socket");
|
||||
// falling back to Skia/software for smaller canvases
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
pref("gfx.canvas.azure.backends", "skia");
|
||||
pref("gfx.canvas.azure.accelerated", false);
|
||||
pref("gfx.canvas.azure.accelerated", true);
|
||||
#endif
|
||||
|
||||
// Turn on dynamic cache size for Skia
|
||||
@@ -980,7 +980,6 @@ pref("media.webspeech.synth.enabled", true);
|
||||
|
||||
// Enable Web Speech recognition API
|
||||
pref("media.webspeech.recognition.enable", true);
|
||||
pref("media.webspeech.service.default", "pocketsphinx");
|
||||
|
||||
// Downloads API
|
||||
pref("dom.mozDownloads.enabled", true);
|
||||
|
||||
@@ -2388,15 +2388,11 @@ void
|
||||
nsGonkCameraControl::OnNewPreviewFrame(layers::TextureClient* aBuffer)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
RefPtr<Image> frame = mImageContainer->CreateImage(ImageFormat::GRALLOC_PLANAR_YCBCR);
|
||||
RefPtr<GrallocImage> frame = new GrallocImage();
|
||||
|
||||
GrallocImage* videoImage = static_cast<GrallocImage*>(frame.get());
|
||||
|
||||
GrallocImage::GrallocData data;
|
||||
data.mGraphicBuffer = aBuffer;
|
||||
data.mPicSize = IntSize(mCurrentConfiguration.mPreviewSize.width,
|
||||
mCurrentConfiguration.mPreviewSize.height);
|
||||
videoImage->SetData(data);
|
||||
IntSize picSize(mCurrentConfiguration.mPreviewSize.width,
|
||||
mCurrentConfiguration.mPreviewSize.height);
|
||||
frame->SetData(aBuffer, picSize);
|
||||
|
||||
if (mCapturePoster.exchange(false)) {
|
||||
CreatePoster(frame,
|
||||
|
||||
@@ -5590,6 +5590,8 @@ CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
|
||||
|
||||
data.mGLContext = glue->GetGLContext();
|
||||
data.mFrontbufferGLTex = skiaGLTex;
|
||||
PersistentBufferProvider *provider = GetBufferProvider(aManager);
|
||||
data.mBufferProvider = provider;
|
||||
} else {
|
||||
PersistentBufferProvider *provider = GetBufferProvider(aManager);
|
||||
data.mBufferProvider = provider;
|
||||
@@ -5640,6 +5642,8 @@ CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
|
||||
|
||||
data.mGLContext = glue->GetGLContext();
|
||||
data.mFrontbufferGLTex = skiaGLTex;
|
||||
PersistentBufferProvider *provider = GetBufferProvider(aManager);
|
||||
data.mBufferProvider = provider;
|
||||
} else {
|
||||
PersistentBufferProvider *provider = GetBufferProvider(aManager);
|
||||
data.mBufferProvider = provider;
|
||||
|
||||
@@ -86,15 +86,7 @@ static already_AddRefed<layers::Image>
|
||||
CreateImageFromSurface(SourceSurface* aSurface, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(aSurface);
|
||||
|
||||
layers::CairoImage::Data cairoData;
|
||||
cairoData.mSize = aSurface->GetSize();
|
||||
cairoData.mSourceSurface = aSurface;
|
||||
|
||||
RefPtr<layers::CairoImage> image = new layers::CairoImage();
|
||||
|
||||
image->SetData(cairoData);
|
||||
|
||||
RefPtr<layers::CairoImage> image = new layers::CairoImage(aSurface->GetSize(), aSurface);
|
||||
return image.forget();
|
||||
}
|
||||
|
||||
|
||||
@@ -1173,13 +1173,7 @@ void
|
||||
HTMLCanvasElement::SetFrameCapture(already_AddRefed<SourceSurface> aSurface)
|
||||
{
|
||||
RefPtr<SourceSurface> surface = aSurface;
|
||||
|
||||
CairoImage::Data imageData;
|
||||
imageData.mSize = surface->GetSize();
|
||||
imageData.mSourceSurface = surface;
|
||||
|
||||
RefPtr<CairoImage> image = new CairoImage();
|
||||
image->SetData(imageData);
|
||||
RefPtr<CairoImage> image = new CairoImage(surface->GetSize(), surface);
|
||||
|
||||
// Loop backwards to allow removing elements in the loop.
|
||||
for (int i = mRequestedFrameListeners.Length() - 1; i >= 0; --i) {
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
PRLogModuleInfo* gAudioStreamLog = nullptr;
|
||||
LazyLogModule gAudioStreamLog("AudioStream");
|
||||
// For simple logs
|
||||
#define LOG(x) MOZ_LOG(gAudioStreamLog, mozilla::LogLevel::Debug, x)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ uint32_t sPreferredSampleRate;
|
||||
|
||||
} // namespace
|
||||
|
||||
extern PRLogModuleInfo* gAudioStreamLog;
|
||||
extern LazyLogModule gAudioStreamLog;
|
||||
|
||||
static const uint32_t CUBEB_NORMAL_LATENCY_MS = 100;
|
||||
|
||||
@@ -126,7 +126,6 @@ bool CubebLatencyPrefSet()
|
||||
|
||||
void InitLibrary()
|
||||
{
|
||||
gAudioStreamLog = PR_NewLogModule("AudioStream");
|
||||
PrefChanged(PREF_VOLUME_SCALE, nullptr);
|
||||
Preferences::RegisterCallback(PrefChanged, PREF_VOLUME_SCALE);
|
||||
PrefChanged(PREF_CUBEB_LATENCY, nullptr);
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
static PRLogModuleInfo* gMediaStreamLog;
|
||||
#define LOG(type, msg) MOZ_LOG(gMediaStreamLog, type, msg)
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::layers;
|
||||
|
||||
static LazyLogModule gMediaStreamLog("MediaStream");
|
||||
#define LOG(type, msg) MOZ_LOG(gMediaStreamLog, type, msg)
|
||||
|
||||
const TrackID TRACK_VIDEO_PRIMARY = 1;
|
||||
|
||||
|
||||
@@ -318,10 +318,6 @@ DOMMediaStream::DOMMediaStream()
|
||||
nsCOMPtr<nsIUUIDGenerator> uuidgen =
|
||||
do_GetService("@mozilla.org/uuid-generator;1", &rv);
|
||||
|
||||
if (!gMediaStreamLog) {
|
||||
gMediaStreamLog = PR_NewLogModule("MediaStream");
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && uuidgen) {
|
||||
nsID uuid;
|
||||
memset(&uuid, 0, sizeof(uuid));
|
||||
@@ -1048,10 +1044,9 @@ DOMHwMediaStream::DOMHwMediaStream()
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
mImageContainer = LayerManager::CreateImageContainer(ImageContainer::ASYNCHRONOUS_OVERLAY);
|
||||
RefPtr<Image> img = mImageContainer->CreateImage(ImageFormat::OVERLAY_IMAGE);
|
||||
mOverlayImage = static_cast<layers::OverlayImage*>(img.get());
|
||||
mOverlayImage = mImageContainer->CreateOverlayImage();
|
||||
nsAutoTArray<ImageContainer::NonOwningImage,1> images;
|
||||
images.AppendElement(ImageContainer::NonOwningImage(img));
|
||||
images.AppendElement(ImageContainer::NonOwningImage(mOverlayImage));
|
||||
mImageContainer->SetCurrentImages(images);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
extern PRLogModuleInfo* gMediaStreamGraphLog;
|
||||
extern mozilla::LazyLogModule gMediaStreamGraphLog;
|
||||
#define STREAM_LOG(type, msg) MOZ_LOG(gMediaStreamGraphLog, type, msg)
|
||||
|
||||
// We don't use NSPR log here because we want this interleaved with adb logcat
|
||||
|
||||
@@ -37,17 +37,13 @@ const char* LatencyLogIndex2Strings[] = {
|
||||
|
||||
static StaticRefPtr<AsyncLatencyLogger> gAsyncLogger;
|
||||
|
||||
PRLogModuleInfo*
|
||||
LogModule*
|
||||
GetLatencyLog()
|
||||
{
|
||||
static PRLogModuleInfo* sLog;
|
||||
if (!sLog) {
|
||||
sLog = PR_NewLogModule("MediaLatency");
|
||||
}
|
||||
static LazyLogModule sLog("MediaLatency");
|
||||
return sLog;
|
||||
}
|
||||
|
||||
|
||||
class LogEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
@@ -111,6 +107,8 @@ void LogLatency(uint32_t aIndex, uint64_t aID, int64_t aValue)
|
||||
void AsyncLatencyLogger::InitializeStatics()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Main thread only");
|
||||
|
||||
//Make sure that the underlying logger is allocated.
|
||||
GetLatencyLog();
|
||||
gAsyncLogger = new AsyncLatencyLogger();
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
|
||||
class AsyncLatencyLogger;
|
||||
|
||||
PRLogModuleInfo* GetLatencyLog();
|
||||
mozilla::LogModule* GetLatencyLog();
|
||||
|
||||
// This class is a singleton. It is refcounted.
|
||||
class AsyncLatencyLogger : public nsIObserver
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "prenv.h"
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PRLogModuleInfo* gMP3DemuxerLog;
|
||||
mozilla::LazyLogModule gMP3DemuxerLog("MP3Demuxer");
|
||||
#define MP3LOG(msg, ...) \
|
||||
MOZ_LOG(gMP3DemuxerLog, LogLevel::Debug, ("MP3Demuxer " msg, ##__VA_ARGS__))
|
||||
#define MP3LOGV(msg, ...) \
|
||||
@@ -112,12 +112,6 @@ MP3TrackDemuxer::MP3TrackDemuxer(MediaResource* aSource)
|
||||
, mChannels(0)
|
||||
{
|
||||
Reset();
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (!gMP3DemuxerLog) {
|
||||
gMP3DemuxerLog = PR_NewLogModule("MP3Demuxer");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
+11
-18
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
PRLogModuleInfo* gMediaCacheLog;
|
||||
LazyLogModule gMediaCacheLog("MediaCache");
|
||||
#define CACHE_LOG(type, msg) MOZ_LOG(gMediaCacheLog, type, msg)
|
||||
|
||||
// Readahead blocks for non-seekable streams will be limited to this
|
||||
@@ -104,9 +104,7 @@ class MediaCache {
|
||||
public:
|
||||
friend class MediaCacheStream::BlockList;
|
||||
typedef MediaCacheStream::BlockList BlockList;
|
||||
enum {
|
||||
BLOCK_SIZE = MediaCacheStream::BLOCK_SIZE
|
||||
};
|
||||
static const int64_t BLOCK_SIZE = MediaCacheStream::BLOCK_SIZE;
|
||||
|
||||
MediaCache() : mNextResourceID(1),
|
||||
mReentrantMonitor("MediaCache.mReentrantMonitor"),
|
||||
@@ -582,10 +580,6 @@ MediaCache::Init()
|
||||
rv = mFileCache->Open(fileDesc);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (!gMediaCacheLog) {
|
||||
gMediaCacheLog = PR_NewLogModule("MediaCache");
|
||||
}
|
||||
|
||||
MediaCacheFlusher::Init();
|
||||
|
||||
return NS_OK;
|
||||
@@ -1834,12 +1828,11 @@ MediaCacheStream::NotifyDataReceived(int64_t aSize, const char* aData,
|
||||
}
|
||||
|
||||
void
|
||||
MediaCacheStream::FlushPartialBlockInternal(bool aNotifyAll)
|
||||
MediaCacheStream::FlushPartialBlockInternal(bool aNotifyAll,
|
||||
ReentrantMonitorAutoEnter& aReentrantMonitor)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
|
||||
|
||||
int32_t blockOffset = int32_t(mChannelOffset%BLOCK_SIZE);
|
||||
if (blockOffset > 0) {
|
||||
CACHE_LOG(LogLevel::Debug,
|
||||
@@ -1861,7 +1854,7 @@ MediaCacheStream::FlushPartialBlockInternal(bool aNotifyAll)
|
||||
// that will never come.
|
||||
if ((blockOffset > 0 || mChannelOffset == 0) && aNotifyAll) {
|
||||
// Wake up readers who may be waiting for this data
|
||||
mon.NotifyAll();
|
||||
aReentrantMonitor.NotifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1876,7 +1869,7 @@ MediaCacheStream::FlushPartialBlock()
|
||||
// Note: This writes a full block, so if data is not at the end of the
|
||||
// stream, the decoder must subsequently choose correct start and end offsets
|
||||
// for reading/seeking.
|
||||
FlushPartialBlockInternal(false);
|
||||
FlushPartialBlockInternal(false, mon);
|
||||
|
||||
gMediaCache->QueueUpdate();
|
||||
}
|
||||
@@ -1897,7 +1890,7 @@ MediaCacheStream::NotifyDataEnded(nsresult aStatus)
|
||||
|
||||
// It is prudent to update channel/cache status before calling
|
||||
// CacheClientNotifyDataEnded() which will read |mChannelEnded|.
|
||||
FlushPartialBlockInternal(true);
|
||||
FlushPartialBlockInternal(true, mon);
|
||||
mChannelEnded = true;
|
||||
gMediaCache->QueueUpdate();
|
||||
|
||||
@@ -2224,7 +2217,7 @@ MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||
uint32_t streamBlock = uint32_t(mStreamOffset/BLOCK_SIZE);
|
||||
uint32_t offsetInStreamBlock =
|
||||
uint32_t(mStreamOffset - streamBlock*BLOCK_SIZE);
|
||||
int64_t size = std::min(aCount - count, BLOCK_SIZE - offsetInStreamBlock);
|
||||
int64_t size = std::min<int64_t>(aCount - count, BLOCK_SIZE - offsetInStreamBlock);
|
||||
|
||||
if (mStreamLength >= 0) {
|
||||
// Don't try to read beyond the end of the stream
|
||||
@@ -2461,13 +2454,13 @@ nsresult MediaCacheStream::GetCachedRanges(nsTArray<MediaByteRange>& aRanges)
|
||||
// shrink while we're trying to loop over them.
|
||||
NS_ASSERTION(mPinCount > 0, "Must be pinned");
|
||||
|
||||
int64_t startOffset = GetNextCachedData(0);
|
||||
int64_t startOffset = GetNextCachedDataInternal(0);
|
||||
while (startOffset >= 0) {
|
||||
int64_t endOffset = GetCachedDataEnd(startOffset);
|
||||
int64_t endOffset = GetCachedDataEndInternal(startOffset);
|
||||
NS_ASSERTION(startOffset < endOffset, "Buffered range must end after its start");
|
||||
// Bytes [startOffset..endOffset] are cached.
|
||||
aRanges.AppendElement(MediaByteRange(startOffset, endOffset));
|
||||
startOffset = GetNextCachedData(endOffset);
|
||||
startOffset = GetNextCachedDataInternal(endOffset);
|
||||
NS_ASSERTION(startOffset == -1 || startOffset > endOffset,
|
||||
"Must have advanced to start of next range, or hit end of stream");
|
||||
}
|
||||
|
||||
@@ -183,10 +183,9 @@ class MediaCache;
|
||||
*/
|
||||
class MediaCacheStream {
|
||||
public:
|
||||
enum {
|
||||
// This needs to be a power of two
|
||||
BLOCK_SIZE = 32768
|
||||
};
|
||||
// This needs to be a power of two
|
||||
static const int64_t BLOCK_SIZE = 32768;
|
||||
|
||||
enum ReadMode {
|
||||
MODE_METADATA,
|
||||
MODE_PLAYBACK
|
||||
@@ -425,7 +424,7 @@ private:
|
||||
// Used by |NotifyDataEnded| and |FlushPartialBlock|.
|
||||
// If |aNotifyAll| is true, this function will wake up readers who may be
|
||||
// waiting on the media cache monitor. Called on the main thread only.
|
||||
void FlushPartialBlockInternal(bool aNotify);
|
||||
void FlushPartialBlockInternal(bool aNotify, ReentrantMonitorAutoEnter& aReentrantMonitor);
|
||||
// A helper function to do the work of closing the stream. Assumes
|
||||
// that the cache monitor is held. Main thread only.
|
||||
// aReentrantMonitor is the nsAutoReentrantMonitor wrapper holding the cache monitor.
|
||||
|
||||
+9
-21
@@ -312,11 +312,11 @@ VideoData::Create(const VideoInfo& aInfo,
|
||||
// format.
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (IsYV12Format(Y, Cb, Cr) && !IsInEmulator()) {
|
||||
v->mImage = aContainer->CreateImage(ImageFormat::GRALLOC_PLANAR_YCBCR);
|
||||
v->mImage = new layers::GrallocImage();
|
||||
}
|
||||
#endif
|
||||
if (!v->mImage) {
|
||||
v->mImage = aContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
|
||||
v->mImage = aContainer->CreatePlanarYCbCrImage();
|
||||
}
|
||||
} else {
|
||||
v->mImage = aImage;
|
||||
@@ -328,7 +328,8 @@ VideoData::Create(const VideoInfo& aInfo,
|
||||
NS_ASSERTION(v->mImage->GetFormat() == ImageFormat::PLANAR_YCBCR ||
|
||||
v->mImage->GetFormat() == ImageFormat::GRALLOC_PLANAR_YCBCR,
|
||||
"Wrong format?");
|
||||
PlanarYCbCrImage* videoImage = static_cast<PlanarYCbCrImage*>(v->mImage.get());
|
||||
PlanarYCbCrImage* videoImage = v->mImage->AsPlanarYCbCrImage();
|
||||
MOZ_ASSERT(videoImage);
|
||||
|
||||
bool shouldCopyData = (aImage == nullptr);
|
||||
if (!VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
|
||||
@@ -339,11 +340,11 @@ VideoData::Create(const VideoInfo& aInfo,
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (!videoImage->IsValid() && !aImage && IsYV12Format(Y, Cb, Cr)) {
|
||||
// Failed to allocate gralloc. Try fallback.
|
||||
v->mImage = aContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
|
||||
v->mImage = aContainer->CreatePlanarYCbCrImage();
|
||||
if (!v->mImage) {
|
||||
return nullptr;
|
||||
}
|
||||
videoImage = static_cast<PlanarYCbCrImage*>(v->mImage.get());
|
||||
videoImage = v->mImage->AsPlanarYCbCrImage();
|
||||
if(!VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
|
||||
true /* aCopyData */)) {
|
||||
return nullptr;
|
||||
@@ -460,22 +461,9 @@ VideoData::Create(const VideoInfo& aInfo,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
|
||||
v->mImage = aContainer->CreateImage(ImageFormat::GRALLOC_PLANAR_YCBCR);
|
||||
if (!v->mImage) {
|
||||
return nullptr;
|
||||
}
|
||||
NS_ASSERTION(v->mImage->GetFormat() == ImageFormat::GRALLOC_PLANAR_YCBCR,
|
||||
"Wrong format?");
|
||||
typedef mozilla::layers::GrallocImage GrallocImage;
|
||||
GrallocImage* videoImage = static_cast<GrallocImage*>(v->mImage.get());
|
||||
GrallocImage::GrallocData data;
|
||||
|
||||
data.mPicSize = aPicture.Size();
|
||||
data.mGraphicBuffer = aBuffer;
|
||||
|
||||
if (!videoImage->SetData(data)) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<layers::GrallocImage> image = new layers::GrallocImage();
|
||||
image->SetData(aBuffer, aPicture.Size());
|
||||
v->mImage = image;
|
||||
|
||||
return v.forget();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ static const uint64_t ESTIMATED_DURATION_FUZZ_FACTOR_USECS = USECS_PER_S / 2;
|
||||
// avoid redefined macro in unified build
|
||||
#undef DECODER_LOG
|
||||
|
||||
PRLogModuleInfo* gMediaDecoderLog;
|
||||
LazyLogModule gMediaDecoderLog("MediaDecoder");
|
||||
#define DECODER_LOG(x, ...) \
|
||||
MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, ("Decoder=%p " x, this, ##__VA_ARGS__))
|
||||
|
||||
@@ -113,21 +113,14 @@ public:
|
||||
StaticRefPtr<MediaMemoryTracker> MediaMemoryTracker::sUniqueInstance;
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
PRLogModuleInfo* gMediaTimerLog;
|
||||
PRLogModuleInfo* gMediaSampleLog;
|
||||
LazyLogModule gMediaTimerLog("MediaTimer");
|
||||
LazyLogModule gMediaSampleLog("MediaSample");
|
||||
#endif
|
||||
|
||||
void
|
||||
MediaDecoder::InitStatics()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
// Log modules.
|
||||
gMediaDecoderLog = PR_NewLogModule("MediaDecoder");
|
||||
gMediaTimerLog = PR_NewLogModule("MediaTimer");
|
||||
gMediaSampleLog = PR_NewLogModule("MediaSample");
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(MediaMemoryTracker, nsIMemoryReporter)
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace mozilla {
|
||||
// Un-comment to enable logging of seek bisections.
|
||||
//#define SEEK_LOGGING
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define DECODER_LOG(x, ...) \
|
||||
MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, ("Decoder=%p " x, mDecoder, ##__VA_ARGS__))
|
||||
|
||||
|
||||
@@ -107,8 +107,8 @@ class AudioSegment;
|
||||
class DecodedStream;
|
||||
class TaskQueue;
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern PRLogModuleInfo* gMediaSampleLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaSampleLog;
|
||||
|
||||
/*
|
||||
The state machine class. This manages the decoding and seeking in the
|
||||
|
||||
@@ -24,20 +24,10 @@ using mozilla::layers::Image;
|
||||
using mozilla::layers::LayerManager;
|
||||
using mozilla::layers::LayersBackend;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PRLogModuleInfo* GetFormatDecoderLog() {
|
||||
static PRLogModuleInfo* log = nullptr;
|
||||
if (!log) {
|
||||
log = PR_NewLogModule("MediaFormatReader");
|
||||
}
|
||||
return log;
|
||||
}
|
||||
#define LOG(arg, ...) MOZ_LOG(GetFormatDecoderLog(), mozilla::LogLevel::Debug, ("MediaFormatReader(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
#define LOGV(arg, ...) MOZ_LOG(GetFormatDecoderLog(), mozilla::LogLevel::Verbose, ("MediaFormatReader(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
#else
|
||||
#define LOG(...)
|
||||
#define LOGV(...)
|
||||
#endif
|
||||
static mozilla::LazyLogModule sFormatDecoderLog("MediaFormatReader");
|
||||
|
||||
#define LOG(arg, ...) MOZ_LOG(sFormatDecoderLog, mozilla::LogLevel::Debug, ("MediaFormatReader(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
#define LOGV(arg, ...) MOZ_LOG(sFormatDecoderLog, mozilla::LogLevel::Verbose, ("MediaFormatReader(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
||||
@@ -104,12 +104,10 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
PRLogModuleInfo*
|
||||
LogModule*
|
||||
GetMediaManagerLog()
|
||||
{
|
||||
static PRLogModuleInfo *sLog;
|
||||
if (!sLog)
|
||||
sLog = PR_NewLogModule("MediaManager");
|
||||
static LazyLogModule sLog("MediaManager");
|
||||
return sLog;
|
||||
}
|
||||
#define LOG(msg) MOZ_LOG(GetMediaManagerLog(), mozilla::LogLevel::Debug, msg)
|
||||
|
||||
@@ -51,7 +51,7 @@ struct MediaTrackConstraints;
|
||||
struct MediaTrackConstraintSet;
|
||||
} // namespace dom
|
||||
|
||||
extern PRLogModuleInfo* GetMediaManagerLog();
|
||||
extern LogModule* GetMediaManagerLog();
|
||||
#define MM_LOG(msg) MOZ_LOG(GetMediaManagerLog(), mozilla::LogLevel::Debug, msg)
|
||||
|
||||
class MediaDevice : public nsIMediaDevice
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
PRLogModuleInfo* gMediaRecorderLog;
|
||||
mozilla::LazyLogModule gMediaRecorderLog("MediaRecorder");
|
||||
#define LOG(type, msg) MOZ_LOG(gMediaRecorderLog, type, msg)
|
||||
|
||||
namespace mozilla {
|
||||
@@ -747,9 +747,7 @@ MediaRecorder::MediaRecorder(DOMMediaStream& aSourceMediaStream,
|
||||
MOZ_ASSERT(aOwnerWindow);
|
||||
MOZ_ASSERT(aOwnerWindow->IsInnerWindow());
|
||||
mDOMStream = &aSourceMediaStream;
|
||||
if (!gMediaRecorderLog) {
|
||||
gMediaRecorderLog = PR_NewLogModule("MediaRecorder");
|
||||
}
|
||||
|
||||
RegisterActivityObserver();
|
||||
}
|
||||
|
||||
@@ -780,9 +778,7 @@ MediaRecorder::MediaRecorder(AudioNode& aSrcAudioNode,
|
||||
}
|
||||
}
|
||||
mAudioNode = &aSrcAudioNode;
|
||||
if (!gMediaRecorderLog) {
|
||||
gMediaRecorderLog = PR_NewLogModule("MediaRecorder");
|
||||
}
|
||||
|
||||
RegisterActivityObserver();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
using mozilla::media::TimeUnit;
|
||||
|
||||
PRLogModuleInfo* gMediaResourceLog;
|
||||
mozilla::LazyLogModule gMediaResourceLog("MediaResource");
|
||||
#define RESOURCE_LOG(msg, ...) MOZ_LOG(gMediaResourceLog, mozilla::LogLevel::Debug, \
|
||||
(msg, ##__VA_ARGS__))
|
||||
// Debug logging macro with object pointer and class name.
|
||||
@@ -78,9 +78,6 @@ ChannelMediaResource::ChannelMediaResource(MediaResourceCallback* aCallback,
|
||||
mIsTransportSeekable(true),
|
||||
mSuspendAgent(mChannel)
|
||||
{
|
||||
if (!gMediaResourceLog) {
|
||||
gMediaResourceLog = PR_NewLogModule("MediaResource");
|
||||
}
|
||||
}
|
||||
|
||||
ChannelMediaResource::~ChannelMediaResource()
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define DECODER_LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
||||
|
||||
NS_IMPL_ISUPPORTS(MediaShutdownManager, nsIObserver)
|
||||
|
||||
@@ -39,7 +39,7 @@ using namespace mozilla::gfx;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
PRLogModuleInfo* gMediaStreamGraphLog;
|
||||
LazyLogModule gMediaStreamGraphLog("MediaStreamGraph");
|
||||
#define STREAM_LOG(type, msg) MOZ_LOG(gMediaStreamGraphLog, type, msg)
|
||||
|
||||
// #define ENABLE_LIFECYCLE_LOG
|
||||
@@ -847,13 +847,11 @@ MediaStreamGraphImpl::PlayVideo(MediaStream* aStream)
|
||||
|
||||
if (frame->GetForceBlack()) {
|
||||
if (!blackImage) {
|
||||
blackImage = aStream->mVideoOutputs[0]->
|
||||
GetImageContainer()->CreateImage(ImageFormat::PLANAR_YCBCR);
|
||||
blackImage = aStream->mVideoOutputs[0]->GetImageContainer()->CreatePlanarYCbCrImage();
|
||||
if (blackImage) {
|
||||
// Sets the image to a single black pixel, which will be scaled to
|
||||
// fill the rendered size.
|
||||
SetImageToBlackPixel(static_cast<PlanarYCbCrImage*>
|
||||
(blackImage.get()));
|
||||
SetImageToBlackPixel(blackImage->AsPlanarYCbCrImage());
|
||||
}
|
||||
}
|
||||
if (blackImage) {
|
||||
@@ -2662,10 +2660,6 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(GraphDriverType aDriverRequested,
|
||||
#endif
|
||||
, mAudioChannel(aChannel)
|
||||
{
|
||||
if (!gMediaStreamGraphLog) {
|
||||
gMediaStreamGraphLog = PR_NewLogModule("MediaStreamGraph");
|
||||
}
|
||||
|
||||
if (mRealtime) {
|
||||
if (aDriverRequested == AUDIO_THREAD_DRIVER) {
|
||||
AudioCallbackDriver* driver = new AudioCallbackDriver(this);
|
||||
|
||||
@@ -35,7 +35,7 @@ class nsAutoRefTraits<SpeexResamplerState> : public nsPointerRefTraits<SpeexResa
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaStreamGraphLog;
|
||||
extern LazyLogModule gMediaStreamGraphLog;
|
||||
|
||||
namespace dom {
|
||||
enum class AudioContextOperation;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaTimerLog;
|
||||
extern LazyLogModule gMediaTimerLog;
|
||||
|
||||
#define TIMER_LOG(x, ...) \
|
||||
MOZ_ASSERT(gMediaTimerLog); \
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
using namespace mozilla::net;
|
||||
using namespace mozilla::media;
|
||||
|
||||
PRLogModuleInfo* gRtspMediaResourceLog;
|
||||
mozilla::LazyLogModule gRtspMediaResourceLog("RtspMediaResource");
|
||||
#define RTSP_LOG(msg, ...) MOZ_LOG(gRtspMediaResourceLog, mozilla::LogLevel::Debug, \
|
||||
(msg, ##__VA_ARGS__))
|
||||
// Debug logging macro with object pointer and class name.
|
||||
@@ -500,9 +500,6 @@ RtspMediaResource::RtspMediaResource(MediaResourceCallback* aCallback,
|
||||
MOZ_ASSERT(mMediaStreamController);
|
||||
mListener = new Listener(this);
|
||||
mMediaStreamController->AsyncOpen(mListener);
|
||||
if (!gRtspMediaResourceLog) {
|
||||
gRtspMediaResourceLog = PR_NewLogModule("RtspMediaResource");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaStreamGraphLog;
|
||||
extern LazyLogModule gMediaStreamGraphLog;
|
||||
#define STREAM_LOG(type, msg) MOZ_LOG(gMediaStreamGraphLog, type, msg)
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -42,15 +42,12 @@ namespace mozilla {
|
||||
#undef STREAM_LOG
|
||||
#endif
|
||||
|
||||
PRLogModuleInfo* gTrackUnionStreamLog;
|
||||
LazyLogModule gTrackUnionStreamLog("TrackUnionStream");
|
||||
#define STREAM_LOG(type, msg) MOZ_LOG(gTrackUnionStreamLog, type, msg)
|
||||
|
||||
TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) :
|
||||
ProcessedMediaStream(aWrapper), mNextAvailableTrackID(1)
|
||||
{
|
||||
if (!gTrackUnionStreamLog) {
|
||||
gTrackUnionStreamLog = PR_NewLogModule("TrackUnionStream");
|
||||
}
|
||||
}
|
||||
|
||||
void TrackUnionStream::RemoveInput(MediaInputPort* aPort)
|
||||
|
||||
@@ -43,17 +43,14 @@ VideoFrame::TakeFrom(VideoFrame* aFrame)
|
||||
/* static */ already_AddRefed<Image>
|
||||
VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
|
||||
{
|
||||
RefPtr<ImageContainer> container;
|
||||
RefPtr<Image> image;
|
||||
container = LayerManager::CreateImageContainer();
|
||||
image = container->CreateImage(ImageFormat::PLANAR_YCBCR);
|
||||
RefPtr<ImageContainer> container = LayerManager::CreateImageContainer();
|
||||
RefPtr<PlanarYCbCrImage> image = container->CreatePlanarYCbCrImage();
|
||||
if (!image) {
|
||||
MOZ_ASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int len = ((aSize.width * aSize.height) * 3 / 2);
|
||||
PlanarYCbCrImage* planar = static_cast<PlanarYCbCrImage*>(image.get());
|
||||
|
||||
// Generate a black image.
|
||||
ScopedDeletePtr<uint8_t> frame(new uint8_t[len]);
|
||||
@@ -80,7 +77,7 @@ VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
|
||||
data.mStereoMode = StereoMode::MONO;
|
||||
|
||||
// SetData copies data, so we can free data.
|
||||
if (!planar->SetData(data)) {
|
||||
if (!image->SetData(data)) {
|
||||
MOZ_ASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -28,16 +28,13 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebVTTListener)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebVTTListener)
|
||||
|
||||
PRLogModuleInfo* gTextTrackLog;
|
||||
LazyLogModule gTextTrackLog("TextTrack");
|
||||
# define VTT_LOG(...) MOZ_LOG(gTextTrackLog, LogLevel::Debug, (__VA_ARGS__))
|
||||
|
||||
WebVTTListener::WebVTTListener(HTMLTrackElement* aElement)
|
||||
: mElement(aElement)
|
||||
{
|
||||
MOZ_ASSERT(mElement, "Must pass an element to the callback");
|
||||
if (!gTextTrackLog) {
|
||||
gTextTrackLog = PR_NewLogModule("TextTrack");
|
||||
}
|
||||
VTT_LOG("WebVTTListener created.");
|
||||
}
|
||||
|
||||
|
||||
@@ -388,8 +388,8 @@ uint8_t *
|
||||
AndroidMediaReader::ImageBufferCallback::CreateI420Image(size_t aWidth,
|
||||
size_t aHeight)
|
||||
{
|
||||
mImage = mImageContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
|
||||
PlanarYCbCrImage *yuvImage = static_cast<PlanarYCbCrImage *>(mImage.get());
|
||||
RefPtr<PlanarYCbCrImage> yuvImage = mImageContainer->CreatePlanarYCbCrImage();
|
||||
mImage = yuvImage;
|
||||
|
||||
if (!yuvImage) {
|
||||
NS_WARNING("Could not create I420 image");
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace mozilla::media;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define LOGE(...) MOZ_LOG(gMediaDecoderLog, mozilla::LogLevel::Error, (__VA_ARGS__))
|
||||
#define LOGW(...) MOZ_LOG(gMediaDecoderLog, mozilla::LogLevel::Warning, (__VA_ARGS__))
|
||||
#define LOGD(...) MOZ_LOG(gMediaDecoderLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
|
||||
@@ -431,9 +431,10 @@ AppleMP3Reader::SetupDecoder()
|
||||
// Set output format
|
||||
#if defined(MOZ_SAMPLE_TYPE_FLOAT32)
|
||||
outputFormat.mBitsPerChannel = 32;
|
||||
outputFormat.mFormatFlags =
|
||||
kLinearPCMFormatFlagIsFloat |
|
||||
0;
|
||||
outputFormat.mFormatFlags = kLinearPCMFormatFlagIsFloat;
|
||||
#elif defined(MOZ_SAMPLE_TYPE_S16)
|
||||
outputFormat.mBitsPerChannel = 32;
|
||||
outputFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
|
||||
#else
|
||||
#error Unknown audio sample type
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace mozilla::media;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
PRLogModuleInfo* GetDirectShowLog();
|
||||
extern LogModule* GetDirectShowLog();
|
||||
#define LOG(...) MOZ_LOG(GetDirectShowLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
|
||||
|
||||
AudioSinkFilter::AudioSinkFilter(const wchar_t* aObjectName, HRESULT* aOutResult)
|
||||
|
||||
@@ -15,7 +15,7 @@ using namespace mozilla::media;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
PRLogModuleInfo* GetDirectShowLog();
|
||||
extern LogModule* GetDirectShowLog();
|
||||
#define LOG(...) MOZ_LOG(GetDirectShowLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
|
||||
|
||||
AudioSinkInputPin::AudioSinkInputPin(wchar_t* aObjectName,
|
||||
|
||||
@@ -18,13 +18,9 @@ using namespace mozilla::media;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
||||
PRLogModuleInfo*
|
||||
LogModule*
|
||||
GetDirectShowLog() {
|
||||
static PRLogModuleInfo* log = nullptr;
|
||||
if (!log) {
|
||||
log = PR_NewLogModule("DirectShowDecoder");
|
||||
}
|
||||
static LazyLogModule log("DirectShowDecoder");
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace mozilla::media;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
PRLogModuleInfo* GetDirectShowLog();
|
||||
extern LogModule* GetDirectShowLog();
|
||||
#define LOG(...) MOZ_LOG(GetDirectShowLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
|
||||
|
||||
SampleSink::SampleSink()
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace mozilla {
|
||||
//#define DEBUG_SOURCE_TRACE 1
|
||||
|
||||
#if defined (DEBUG_SOURCE_TRACE)
|
||||
PRLogModuleInfo* GetDirectShowLog();
|
||||
extern LogModule* GetDirectShowLog();
|
||||
#define DIRECTSHOW_LOG(...) MOZ_LOG(GetDirectShowLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
|
||||
#else
|
||||
#define DIRECTSHOW_LOG(...)
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
PRLogModuleInfo* gMediaEncoderLog;
|
||||
mozilla::LazyLogModule gMediaEncoderLog("MediaEncoder");
|
||||
#define LOG(type, msg) MOZ_LOG(gMediaEncoderLog, type, msg)
|
||||
|
||||
namespace mozilla {
|
||||
@@ -79,9 +79,6 @@ MediaEncoder::CreateEncoder(const nsAString& aMIMEType, uint32_t aAudioBitrate,
|
||||
uint32_t aVideoBitrate, uint32_t aBitrate,
|
||||
uint8_t aTrackTypes)
|
||||
{
|
||||
if (!gMediaEncoderLog) {
|
||||
gMediaEncoderLog = PR_NewLogModule("MediaEncoder");
|
||||
}
|
||||
PROFILER_LABEL("MediaEncoder", "CreateEncoder",
|
||||
js::ProfileEntry::Category::OTHER);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
PRLogModuleInfo* gTrackEncoderLog;
|
||||
LazyLogModule gTrackEncoderLog("TrackEncoder");
|
||||
#define TRACK_LOG(type, msg) MOZ_LOG(gTrackEncoderLog, type, msg)
|
||||
|
||||
static const int DEFAULT_CHANNELS = 1;
|
||||
@@ -37,9 +37,6 @@ TrackEncoder::TrackEncoder()
|
||||
, mAudioInitCounter(0)
|
||||
, mVideoInitCounter(0)
|
||||
{
|
||||
if (!gTrackEncoderLog) {
|
||||
gTrackEncoderLog = PR_NewLogModule("TrackEncoder");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
PRLogModuleInfo* gVP8TrackEncoderLog;
|
||||
LazyLogModule gVP8TrackEncoderLog("VP8TrackEncoder");
|
||||
#define VP8LOG(msg, ...) MOZ_LOG(gVP8TrackEncoderLog, mozilla::LogLevel::Debug, \
|
||||
(msg, ##__VA_ARGS__))
|
||||
// Debug logging macro with object pointer and class name.
|
||||
@@ -37,9 +37,6 @@ VP8TrackEncoder::VP8TrackEncoder()
|
||||
, mVPXImageWrapper(new vpx_image_t())
|
||||
{
|
||||
MOZ_COUNT_CTOR(VP8TrackEncoder);
|
||||
if (!gVP8TrackEncoderLog) {
|
||||
gVP8TrackEncoderLog = PR_NewLogModule("VP8TrackEncoder");
|
||||
}
|
||||
}
|
||||
|
||||
VP8TrackEncoder::~VP8TrackEncoder()
|
||||
|
||||
@@ -17,7 +17,7 @@ static const float BASE_QUALITY = 0.4f;
|
||||
namespace mozilla {
|
||||
|
||||
#undef LOG
|
||||
PRLogModuleInfo* gVorbisTrackEncoderLog;
|
||||
LazyLogModule gVorbisTrackEncoderLog("VorbisTrackEncoder");
|
||||
#define VORBISLOG(msg, ...) MOZ_LOG(gVorbisTrackEncoderLog, mozilla::LogLevel::Debug, \
|
||||
(msg, ##__VA_ARGS__))
|
||||
|
||||
@@ -25,9 +25,6 @@ VorbisTrackEncoder::VorbisTrackEncoder()
|
||||
: AudioTrackEncoder()
|
||||
{
|
||||
MOZ_COUNT_CTOR(VorbisTrackEncoder);
|
||||
if (!gVorbisTrackEncoderLog) {
|
||||
gVorbisTrackEncoderLog = PR_NewLogModule("VorbisTrackEncoder");
|
||||
}
|
||||
}
|
||||
|
||||
VorbisTrackEncoder::~VorbisTrackEncoder()
|
||||
|
||||
@@ -20,11 +20,8 @@
|
||||
#include "mp4_demuxer/AnnexB.h"
|
||||
#include "mp4_demuxer/H264.h"
|
||||
|
||||
PRLogModuleInfo* GetDemuxerLog() {
|
||||
static PRLogModuleInfo* log = nullptr;
|
||||
if (!log) {
|
||||
log = PR_NewLogModule("MP4Demuxer");
|
||||
}
|
||||
mozilla::LogModule* GetDemuxerLog() {
|
||||
static mozilla::LazyLogModule log("MP4Demuxer");
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
|
||||
#define LOGV(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Verbose, msg)
|
||||
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#undef LOGD
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
#define LOG(level, x, ...) MOZ_LOG(GetGMPLog(), (level), (x, ##__VA_ARGS__))
|
||||
#define LOGD(x, ...) LOG(mozilla::LogLevel::Debug, "GMPChild[pid=%d] " x, (int)base::GetCurrentProcId(), ##__VA_ARGS__)
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
|
||||
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
|
||||
#define LOG(level, msg) MOZ_LOG(GetGMPLog(), (level), msg)
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
|
||||
#define LOGV(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Verbose, msg)
|
||||
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#undef LOGD
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
#define LOG(level, x, ...) MOZ_LOG(GetGMPLog(), (level), (x, ##__VA_ARGS__))
|
||||
#define LOGD(x, ...) LOG(mozilla::LogLevel::Debug, "GMPParent[%p|childPid=%d] " x, this, mChildPid, ##__VA_ARGS__)
|
||||
|
||||
|
||||
@@ -43,12 +43,10 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
PRLogModuleInfo*
|
||||
LogModule*
|
||||
GetGMPLog()
|
||||
{
|
||||
static PRLogModuleInfo *sLog;
|
||||
if (!sLog)
|
||||
sLog = PR_NewLogModule("GMP");
|
||||
static LazyLogModule sLog("GMP");
|
||||
return sLog;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ template <class> struct already_AddRefed;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
|
||||
namespace gmp {
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
|
||||
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
|
||||
#define LOG(level, msg) MOZ_LOG(GetGMPLog(), (level), msg)
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
|
||||
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
|
||||
#define LOG(level, msg) MOZ_LOG(GetGMPLog(), (level), msg)
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
|
||||
#define LOGV(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Verbose, msg)
|
||||
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace mozilla {
|
||||
#undef LOG
|
||||
#endif
|
||||
|
||||
extern PRLogModuleInfo* GetGMPLog();
|
||||
extern LogModule* GetGMPLog();
|
||||
|
||||
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
|
||||
#define LOG(level, msg) MOZ_LOG(GetGMPLog(), (level), msg)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define LOG(msg, ...) \
|
||||
MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, ("GStreamerFormatHelper " msg, ##__VA_ARGS__))
|
||||
|
||||
|
||||
@@ -45,8 +45,7 @@ GstFlowReturn GStreamerReader::AllocateVideoBufferFull(GstPad* aPad,
|
||||
if (container == nullptr) {
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
RefPtr<PlanarYCbCrImage> image =
|
||||
container->CreateImage(ImageFormat::PLANAR_YCBCR).downcast<PlanarYCbCrImage>();
|
||||
RefPtr<PlanarYCbCrImage> image = container->CreatePlanarYCbCrImage();
|
||||
|
||||
/* prepare a GstBuffer pointing to the underlying PlanarYCbCrImage buffer */
|
||||
GstBuffer* buf = GST_BUFFER(gst_moz_video_buffer_new());
|
||||
|
||||
@@ -29,7 +29,7 @@ using namespace media;
|
||||
// Un-comment to enable logging of seek bisections.
|
||||
//#define SEEK_LOGGING
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define LOG(type, msg, ...) \
|
||||
MOZ_LOG(gMediaDecoderLog, type, ("GStreamerReader(%p) " msg, this, ##__VA_ARGS__))
|
||||
|
||||
|
||||
@@ -18,12 +18,9 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
PRLogModuleInfo* GetICLog()
|
||||
LogModule* GetICLog()
|
||||
{
|
||||
static PRLogModuleInfo* log = nullptr;
|
||||
if (!log) {
|
||||
log = PR_NewLogModule("ImageCapture");
|
||||
}
|
||||
static LazyLogModule log("ImageCapture");
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace mozilla {
|
||||
|
||||
#ifndef IC_LOG
|
||||
PRLogModuleInfo* GetICLog();
|
||||
LogModule* GetICLog();
|
||||
#define IC_LOG(...) MOZ_LOG(GetICLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define SINK_LOG(msg, ...) \
|
||||
MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, \
|
||||
("DecodedAudioDataSink=%p " msg, this, ##__VA_ARGS__))
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define VSINK_LOG(msg, ...) \
|
||||
MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, \
|
||||
("VideoSink=%p " msg, this, ##__VA_ARGS__))
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#endif
|
||||
#include "SourceBufferResource.h"
|
||||
|
||||
extern PRLogModuleInfo* GetMediaSourceSamplesLog();
|
||||
extern mozilla::LogModule* GetMediaSourceSamplesLog();
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
|
||||
@@ -36,21 +36,15 @@
|
||||
struct JSContext;
|
||||
class JSObject;
|
||||
|
||||
PRLogModuleInfo* GetMediaSourceLog()
|
||||
mozilla::LogModule* GetMediaSourceLog()
|
||||
{
|
||||
static PRLogModuleInfo* sLogModule = nullptr;
|
||||
if (!sLogModule) {
|
||||
sLogModule = PR_NewLogModule("MediaSource");
|
||||
}
|
||||
static mozilla::LazyLogModule sLogModule("MediaSource");
|
||||
return sLogModule;
|
||||
}
|
||||
|
||||
PRLogModuleInfo* GetMediaSourceAPILog()
|
||||
mozilla::LogModule* GetMediaSourceAPILog()
|
||||
{
|
||||
static PRLogModuleInfo* sLogModule = nullptr;
|
||||
if (!sLogModule) {
|
||||
sLogModule = PR_NewLogModule("MediaSource");
|
||||
}
|
||||
static mozilla::LazyLogModule sLogModule("MediaSource");
|
||||
return sLogModule;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "SourceBufferList.h"
|
||||
#include <algorithm>
|
||||
|
||||
extern PRLogModuleInfo* GetMediaSourceLog();
|
||||
extern mozilla::LogModule* GetMediaSourceLog();
|
||||
|
||||
#define MSE_DEBUG(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Debug, ("MediaSourceDecoder(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
#define MSE_DEBUGV(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Verbose, ("MediaSourceDecoder(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/Logging.h"
|
||||
|
||||
extern PRLogModuleInfo* GetMediaSourceLog();
|
||||
extern mozilla::LogModule* GetMediaSourceLog();
|
||||
|
||||
#define MSE_DEBUG(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Debug, ("MediaSourceResource(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Logging.h"
|
||||
|
||||
extern PRLogModuleInfo* GetSourceBufferResourceLog();
|
||||
extern mozilla::LogModule* GetSourceBufferResourceLog();
|
||||
|
||||
#define SBR_DEBUG(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Debug, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
#define SBR_DEBUGV(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Verbose, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
struct JSContext;
|
||||
class JSObject;
|
||||
|
||||
extern PRLogModuleInfo* GetMediaSourceLog();
|
||||
extern PRLogModuleInfo* GetMediaSourceAPILog();
|
||||
extern mozilla::LogModule* GetMediaSourceLog();
|
||||
extern mozilla::LogModule* GetMediaSourceAPILog();
|
||||
|
||||
#define MSE_DEBUG(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Debug, ("SourceBuffer(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
|
||||
#define MSE_DEBUGV(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Verbose, ("SourceBuffer(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/Logging.h"
|
||||
|
||||
extern PRLogModuleInfo* GetMediaSourceLog();
|
||||
extern PRLogModuleInfo* GetMediaSourceAPILog();
|
||||
extern mozilla::LogModule* GetMediaSourceLog();
|
||||
extern mozilla::LogModule* GetMediaSourceAPILog();
|
||||
|
||||
#define MSE_API(arg, ...) MOZ_LOG(GetMediaSourceAPILog(), mozilla::LogLevel::Debug, ("SourceBufferList(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
#define MSE_DEBUG(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Debug, ("SourceBufferList(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
|
||||
@@ -13,12 +13,9 @@
|
||||
#include "mozilla/Logging.h"
|
||||
#include "MediaData.h"
|
||||
|
||||
PRLogModuleInfo* GetSourceBufferResourceLog()
|
||||
mozilla::LogModule* GetSourceBufferResourceLog()
|
||||
{
|
||||
static PRLogModuleInfo* sLogModule = nullptr;
|
||||
if (!sLogModule) {
|
||||
sLogModule = PR_NewLogModule("SourceBufferResource");
|
||||
}
|
||||
static mozilla::LazyLogModule sLogModule("SourceBufferResource");
|
||||
return sLogModule;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,22 +23,14 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
extern PRLogModuleInfo* GetMediaSourceLog();
|
||||
extern mozilla::LogModule* GetMediaSourceLog();
|
||||
|
||||
#define MSE_DEBUG(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Debug, ("TrackBuffersManager(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
|
||||
#define MSE_DEBUGV(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Verbose, ("TrackBuffersManager(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
|
||||
#else
|
||||
#define MSE_DEBUG(...)
|
||||
#define MSE_DEBUGV(...)
|
||||
#endif
|
||||
|
||||
PRLogModuleInfo* GetMediaSourceSamplesLog()
|
||||
mozilla::LogModule* GetMediaSourceSamplesLog()
|
||||
{
|
||||
static PRLogModuleInfo* sLogModule = nullptr;
|
||||
if (!sLogModule) {
|
||||
sLogModule = PR_NewLogModule("MediaSourceSamples");
|
||||
}
|
||||
static mozilla::LazyLogModule sLogModule("MediaSourceSamples");
|
||||
return sLogModule;
|
||||
}
|
||||
#define SAMPLE_DEBUG(arg, ...) MOZ_LOG(GetMediaSourceSamplesLog(), mozilla::LogLevel::Debug, ("TrackBuffersManager(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
||||
|
||||
/** Decoder base class for Ogg-encapsulated streams. */
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace mozilla {
|
||||
// Un-comment to enable logging of seek bisections.
|
||||
//#define SEEK_LOGGING
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
||||
#ifdef SEEK_LOGGING
|
||||
#define SEEK_LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
||||
|
||||
@@ -24,7 +24,7 @@ extern "C" {
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define OPUS_LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
||||
|
||||
OpusParser::OpusParser():
|
||||
|
||||
@@ -42,7 +42,7 @@ using namespace android;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
PRLogModuleInfo* gAudioOffloadPlayerLog;
|
||||
LazyLogModule gAudioOffloadPlayerLog("AudioOffloadPlayer");
|
||||
#define AUDIO_OFFLOAD_LOG(type, msg) \
|
||||
MOZ_LOG(gAudioOffloadPlayerLog, type, msg)
|
||||
|
||||
@@ -63,10 +63,6 @@ AudioOffloadPlayer::AudioOffloadPlayer(MediaOmxCommonDecoder* aObserver) :
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!gAudioOffloadPlayerLog) {
|
||||
gAudioOffloadPlayerLog = PR_NewLogModule("AudioOffloadPlayer");
|
||||
}
|
||||
|
||||
CHECK(aObserver);
|
||||
#if ANDROID_VERSION >= 21
|
||||
mSessionId = AudioSystem::newAudioUniqueId();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gAudioOffloadPlayerLog;
|
||||
extern LazyLogModule gAudioOffloadPlayerLog;
|
||||
#define AUDIO_OFFLOAD_LOG(type, msg) \
|
||||
MOZ_LOG(gAudioOffloadPlayerLog, type, msg)
|
||||
|
||||
@@ -37,9 +37,6 @@ AudioOutput::AudioOutput(int aSessionId, int aUid) :
|
||||
mUid(aUid),
|
||||
mSessionId(aSessionId)
|
||||
{
|
||||
if (!gAudioOffloadPlayerLog) {
|
||||
gAudioOffloadPlayerLog = PR_NewLogModule("AudioOffloadPlayer");
|
||||
}
|
||||
}
|
||||
|
||||
AudioOutput::~AudioOutput()
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
|
||||
PRLogModuleInfo *gI420ColorConverterHelperLog;
|
||||
mozilla::LazyLogModule gI420ColorConverterHelperLog("I420ColorConverterHelper");
|
||||
#define LOG(msg...) MOZ_LOG(gI420ColorConverterHelperLog, mozilla::LogLevel::Warning, (msg))
|
||||
|
||||
namespace android {
|
||||
@@ -19,9 +19,6 @@ I420ColorConverterHelper::I420ColorConverterHelper()
|
||||
: mHandle(nullptr)
|
||||
, mConverter({nullptr, nullptr, nullptr, nullptr, nullptr})
|
||||
{
|
||||
if (!gI420ColorConverterHelperLog) {
|
||||
gI420ColorConverterHelperLog = PR_NewLogModule("I420ColorConverterHelper");
|
||||
}
|
||||
}
|
||||
|
||||
I420ColorConverterHelper::~I420ColorConverterHelper()
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <android/log.h>
|
||||
#define MCP_LOG(...) __android_log_print(ANDROID_LOG_DEBUG, "MediaCodecProxy", __VA_ARGS__)
|
||||
#define TIMEOUT_DEQUEUE_INPUTBUFFER_MS 1000000ll
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -77,24 +76,20 @@ struct MediaCodecInterfaceWrapper
|
||||
sp<MediaCodecProxy>
|
||||
MediaCodecProxy::CreateByType(sp<ALooper> aLooper,
|
||||
const char *aMime,
|
||||
bool aEncoder,
|
||||
wp<CodecResourceListener> aListener)
|
||||
bool aEncoder)
|
||||
{
|
||||
sp<MediaCodecProxy> codec = new MediaCodecProxy(aLooper,
|
||||
aMime,
|
||||
aEncoder,
|
||||
aListener);
|
||||
aEncoder);
|
||||
return codec;
|
||||
}
|
||||
|
||||
MediaCodecProxy::MediaCodecProxy(sp<ALooper> aLooper,
|
||||
const char *aMime,
|
||||
bool aEncoder,
|
||||
wp<CodecResourceListener> aListener)
|
||||
bool aEncoder)
|
||||
: mCodecLooper(aLooper)
|
||||
, mCodecMime(aMime)
|
||||
, mCodecEncoder(aEncoder)
|
||||
, mListener(aListener)
|
||||
, mMediaCodecLock("MediaCodecProxy::mMediaCodecLock")
|
||||
, mPendingRequestMediaResource(false)
|
||||
{
|
||||
@@ -107,50 +102,29 @@ MediaCodecProxy::~MediaCodecProxy()
|
||||
}
|
||||
|
||||
bool
|
||||
MediaCodecProxy::AskMediaCodecAndWait()
|
||||
MediaCodecProxy::AllocateAudioMediaCodec()
|
||||
{
|
||||
if (mResourceClient || mCodec.get()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strncasecmp(mCodecMime.get(), "video/", 6) == 0) {
|
||||
mozilla::MediaSystemResourceType type =
|
||||
mCodecEncoder ? mozilla::MediaSystemResourceType::VIDEO_ENCODER :
|
||||
mozilla::MediaSystemResourceType::VIDEO_DECODER;
|
||||
mResourceClient = new mozilla::MediaSystemResourceClient(type);
|
||||
mResourceClient->SetListener(this);
|
||||
} else if (strncasecmp(mCodecMime.get(), "audio/", 6) == 0) {
|
||||
if (strncasecmp(mCodecMime.get(), "audio/", 6) == 0) {
|
||||
if (allocateCodec()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mResourceClient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mozilla::MonitorAutoLock mon(mMediaCodecLock);
|
||||
mPendingRequestMediaResource = true;
|
||||
// request video codec
|
||||
mResourceClient->Acquire();
|
||||
|
||||
while (mPendingRequestMediaResource) {
|
||||
mMediaCodecLock.Wait();
|
||||
}
|
||||
MCP_LOG("AskMediaCodecAndWait complete");
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
MediaCodecProxy::AsyncAskMediaCodec()
|
||||
RefPtr<MediaCodecProxy::CodecPromise>
|
||||
MediaCodecProxy::AsyncAllocateVideoMediaCodec()
|
||||
{
|
||||
if (mResourceClient || mCodec.get()) {
|
||||
return false;
|
||||
return CodecPromise::CreateAndReject(true, __func__);
|
||||
}
|
||||
|
||||
if (strncasecmp(mCodecMime.get(), "video/", 6) != 0) {
|
||||
return false;
|
||||
return CodecPromise::CreateAndReject(true, __func__);
|
||||
}
|
||||
// request video codec
|
||||
mozilla::MediaSystemResourceType type =
|
||||
@@ -160,12 +134,14 @@ MediaCodecProxy::AsyncAskMediaCodec()
|
||||
mResourceClient->SetListener(this);
|
||||
mResourceClient->Acquire();
|
||||
|
||||
return true;
|
||||
RefPtr<CodecPromise> p = mCodecPromise.Ensure(__func__);
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
void
|
||||
MediaCodecProxy::ReleaseMediaCodec()
|
||||
{
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
releaseCodec();
|
||||
|
||||
if (!mResourceClient) {
|
||||
@@ -500,11 +476,7 @@ MediaCodecProxy::ResourceReserved()
|
||||
// Create MediaCodec
|
||||
if (!allocateCodec()) {
|
||||
ReleaseMediaCodec();
|
||||
// Notification
|
||||
sp<CodecResourceListener> listener = mListener.promote();
|
||||
if (listener != nullptr) {
|
||||
listener->codecCanceled();
|
||||
}
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -513,11 +485,7 @@ MediaCodecProxy::ResourceReserved()
|
||||
mPendingRequestMediaResource = false;
|
||||
mon.NotifyAll();
|
||||
|
||||
// Notification
|
||||
sp<CodecResourceListener> listener = mListener.promote();
|
||||
if (listener != nullptr) {
|
||||
listener->codecReserved();
|
||||
}
|
||||
mCodecPromise.ResolveIfExists(true, __func__);
|
||||
}
|
||||
|
||||
// Called on ImageBridge thread
|
||||
@@ -525,11 +493,7 @@ void
|
||||
MediaCodecProxy::ResourceReserveFailed()
|
||||
{
|
||||
ReleaseMediaCodec();
|
||||
// Notification
|
||||
sp<CodecResourceListener> listener = mListener.promote();
|
||||
if (listener != nullptr) {
|
||||
listener->codecCanceled();
|
||||
}
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
}
|
||||
|
||||
bool MediaCodecProxy::Prepare()
|
||||
@@ -571,7 +535,8 @@ bool MediaCodecProxy::UpdateOutputBuffers()
|
||||
}
|
||||
|
||||
status_t MediaCodecProxy::Input(const uint8_t* aData, uint32_t aDataSize,
|
||||
int64_t aTimestampUsecs, uint64_t aflags)
|
||||
int64_t aTimestampUsecs, uint64_t aflags,
|
||||
int64_t aTimeoutUs)
|
||||
{
|
||||
// Read Lock for mCodec
|
||||
{
|
||||
@@ -583,9 +548,11 @@ status_t MediaCodecProxy::Input(const uint8_t* aData, uint32_t aDataSize,
|
||||
}
|
||||
|
||||
size_t index;
|
||||
status_t err = dequeueInputBuffer(&index, TIMEOUT_DEQUEUE_INPUTBUFFER_MS);
|
||||
status_t err = dequeueInputBuffer(&index, aTimeoutUs);
|
||||
if (err != OK) {
|
||||
MCP_LOG("dequeueInputBuffer returned %d", err);
|
||||
if (err != -EAGAIN) {
|
||||
MCP_LOG("dequeueInputBuffer returned %d", err);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
#include "mozilla/media/MediaSystemResourceClient.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "RefPtr.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
namespace android {
|
||||
// This class is intended to be a proxy for MediaCodec with codec resource
|
||||
@@ -27,20 +28,7 @@ class MediaCodecProxy : public RefBase
|
||||
, public mozilla::MediaSystemResourceReservationListener
|
||||
{
|
||||
public:
|
||||
/* Codec resource notification listener.
|
||||
* All functions are called on the Binder thread.
|
||||
*/
|
||||
struct CodecResourceListener : public virtual RefBase {
|
||||
/* The codec resource is reserved and can be granted.
|
||||
* The client can allocate the requested resource.
|
||||
*/
|
||||
virtual void codecReserved() = 0;
|
||||
/* The codec resource is not reserved any more.
|
||||
* The client should release the resource as soon as possible if the
|
||||
* resource is still being held.
|
||||
*/
|
||||
virtual void codecCanceled() = 0;
|
||||
};
|
||||
typedef mozilla::MozPromise<bool /* aIgnored */, bool /* aIgnored */, /* IsExclusive = */ true> CodecPromise;
|
||||
|
||||
enum Capability {
|
||||
kEmptyCapability = 0x00000000,
|
||||
@@ -58,8 +46,7 @@ public:
|
||||
// Only support MediaCodec::CreateByType()
|
||||
static sp<MediaCodecProxy> CreateByType(sp<ALooper> aLooper,
|
||||
const char *aMime,
|
||||
bool aEncoder,
|
||||
wp<CodecResourceListener> aListener=nullptr);
|
||||
bool aEncoder);
|
||||
|
||||
// MediaCodec methods
|
||||
status_t configure(const sp<AMessage> &aFormat,
|
||||
@@ -129,7 +116,7 @@ public:
|
||||
|
||||
// If aData is null, will notify decoder input EOS
|
||||
status_t Input(const uint8_t* aData, uint32_t aDataSize,
|
||||
int64_t aTimestampUsecs, uint64_t flags);
|
||||
int64_t aTimestampUsecs, uint64_t flags, int64_t aTimeoutUs = 0);
|
||||
status_t Output(MediaBuffer** aBuffer, int64_t aTimeoutUs);
|
||||
bool Prepare();
|
||||
void ReleaseMediaResources();
|
||||
@@ -138,14 +125,11 @@ public:
|
||||
|
||||
void ReleaseMediaBuffer(MediaBuffer* abuffer);
|
||||
|
||||
// It asks for the OMX codec and blocked until the resource is grant to be
|
||||
// allocated.
|
||||
// Audio codec allocation should use this.
|
||||
bool AskMediaCodecAndWait();
|
||||
// It allocates audio MediaCodec synchronously.
|
||||
bool AllocateAudioMediaCodec();
|
||||
|
||||
// It asks for the OMX codec asynchronously.
|
||||
// Only video codec is supported.
|
||||
bool AsyncAskMediaCodec();
|
||||
// It allocates video MediaCodec asynchronously.
|
||||
RefPtr<CodecPromise> AsyncAllocateVideoMediaCodec();
|
||||
|
||||
// Free the OMX codec so others can allocate it.
|
||||
void ReleaseMediaCodec();
|
||||
@@ -166,8 +150,7 @@ private:
|
||||
// Constructor for MediaCodecProxy::CreateByType
|
||||
MediaCodecProxy(sp<ALooper> aLooper,
|
||||
const char *aMime,
|
||||
bool aEncoder,
|
||||
wp<CodecResourceListener> aListener);
|
||||
bool aEncoder);
|
||||
|
||||
// Allocate Codec Resource
|
||||
bool allocateCodec();
|
||||
@@ -179,8 +162,7 @@ private:
|
||||
nsCString mCodecMime;
|
||||
bool mCodecEncoder;
|
||||
|
||||
// Codec Resource Notification Listener
|
||||
wp<CodecResourceListener> mListener;
|
||||
mozilla::MozPromiseHolder<CodecPromise> mCodecPromise;
|
||||
|
||||
// Media Resource Management
|
||||
RefPtr<mozilla::MediaSystemResourceClient> mResourceClient;
|
||||
|
||||
@@ -68,33 +68,6 @@ IsValidTimestampUs(int64_t aTimestamp)
|
||||
return aTimestamp >= INT64_C(0);
|
||||
}
|
||||
|
||||
MediaCodecReader::VideoResourceListener::VideoResourceListener(
|
||||
MediaCodecReader* aReader)
|
||||
: mReader(aReader)
|
||||
{
|
||||
}
|
||||
|
||||
MediaCodecReader::VideoResourceListener::~VideoResourceListener()
|
||||
{
|
||||
mReader = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
MediaCodecReader::VideoResourceListener::codecReserved()
|
||||
{
|
||||
if (mReader) {
|
||||
mReader->VideoCodecReserved();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MediaCodecReader::VideoResourceListener::codecCanceled()
|
||||
{
|
||||
if (mReader) {
|
||||
mReader->VideoCodecCanceled();
|
||||
}
|
||||
}
|
||||
|
||||
MediaCodecReader::TrackInputCopier::~TrackInputCopier()
|
||||
{
|
||||
}
|
||||
@@ -276,7 +249,6 @@ MediaCodecReader::MediaCodecReader(AbstractMediaDecoder* aDecoder)
|
||||
, mNextParserPosition(INT64_C(0))
|
||||
, mParsedDataLength(INT64_C(0))
|
||||
{
|
||||
mVideoListener = new VideoResourceListener(this);
|
||||
}
|
||||
|
||||
MediaCodecReader::~MediaCodecReader()
|
||||
@@ -1111,6 +1083,7 @@ MediaCodecReader::ReleaseCriticalResources()
|
||||
mMediaResourceRequest.DisconnectIfExists();
|
||||
mMediaResourcePromise.RejectIfExists(true, __func__);
|
||||
mMetadataPromise.RejectIfExists(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mVideoCodecRequest.DisconnectIfExists();
|
||||
|
||||
ResetDecode();
|
||||
// Before freeing a video codec, all video buffers needed to be released
|
||||
@@ -1313,12 +1286,12 @@ MediaCodecReader::CreateMediaCodecs()
|
||||
bool isWaiting = false;
|
||||
RefPtr<MediaResourcePromise> p = mMediaResourcePromise.Ensure(__func__);
|
||||
|
||||
if (!CreateMediaCodec(mLooper, mAudioTrack, false, isWaiting, nullptr)) {
|
||||
if (!CreateMediaCodec(mLooper, mAudioTrack, isWaiting)) {
|
||||
mMediaResourcePromise.Reject(true, __func__);
|
||||
return p;
|
||||
}
|
||||
|
||||
if (!CreateMediaCodec(mLooper, mVideoTrack, true, isWaiting, mVideoListener)) {
|
||||
if (!CreateMediaCodec(mLooper, mVideoTrack, isWaiting)) {
|
||||
mMediaResourcePromise.Reject(true, __func__);
|
||||
return p;
|
||||
}
|
||||
@@ -1334,16 +1307,14 @@ MediaCodecReader::CreateMediaCodecs()
|
||||
bool
|
||||
MediaCodecReader::CreateMediaCodec(sp<ALooper>& aLooper,
|
||||
Track& aTrack,
|
||||
bool aAsync,
|
||||
bool& aIsWaiting,
|
||||
wp<MediaCodecProxy::CodecResourceListener> aListener)
|
||||
bool& aIsWaiting)
|
||||
{
|
||||
if (aTrack.mSource != nullptr && aTrack.mCodec == nullptr) {
|
||||
sp<MetaData> sourceFormat = aTrack.mSource->getFormat();
|
||||
|
||||
const char* mime;
|
||||
if (sourceFormat->findCString(kKeyMIMEType, &mime)) {
|
||||
aTrack.mCodec = MediaCodecProxy::CreateByType(aLooper, mime, false, aListener);
|
||||
aTrack.mCodec = MediaCodecProxy::CreateByType(aLooper, mime, false);
|
||||
}
|
||||
|
||||
if (aTrack.mCodec == nullptr) {
|
||||
@@ -1372,7 +1343,7 @@ MediaCodecReader::CreateMediaCodec(sp<ALooper>& aLooper,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!aAsync && aTrack.mCodec->AskMediaCodecAndWait()) {
|
||||
if (aTrack.mType == Track::kAudio && aTrack.mCodec->AllocateAudioMediaCodec()) {
|
||||
// Pending configure() and start() to codecReserved() if the creation
|
||||
// should be asynchronous.
|
||||
if (!aTrack.mCodec->allocated() || !ConfigureMediaCodec(aTrack)){
|
||||
@@ -1380,14 +1351,18 @@ MediaCodecReader::CreateMediaCodec(sp<ALooper>& aLooper,
|
||||
DestroyMediaCodec(aTrack);
|
||||
return false;
|
||||
}
|
||||
} else if (aAsync) {
|
||||
if (aTrack.mCodec->AsyncAskMediaCodec()) {
|
||||
aIsWaiting = true;
|
||||
} else {
|
||||
NS_WARNING("Couldn't request MediaCodec asynchronously");
|
||||
DestroyMediaCodec(aTrack);
|
||||
return false;
|
||||
}
|
||||
} else if (aTrack.mType == Track::kVideo) {
|
||||
aIsWaiting = true;
|
||||
RefPtr<MediaCodecReader> self = this;
|
||||
mVideoCodecRequest.Begin(aTrack.mCodec->AsyncAllocateVideoMediaCodec()
|
||||
->Then(OwnerThread(), __func__,
|
||||
[self] (bool) -> void {
|
||||
self->mVideoCodecRequest.Complete();
|
||||
self->mMediaResourcePromise.ResolveIfExists(true, __func__);
|
||||
}, [self] (bool) -> void {
|
||||
self->mVideoCodecRequest.Complete();
|
||||
self->mMediaResourcePromise.RejectIfExists(true, __func__);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1949,18 +1924,5 @@ MediaCodecReader::ClearColorConverterBuffer()
|
||||
mColorConverterBufferSize = 0;
|
||||
}
|
||||
|
||||
// Called on Binder thread.
|
||||
void
|
||||
MediaCodecReader::VideoCodecReserved()
|
||||
{
|
||||
mMediaResourcePromise.ResolveIfExists(true, __func__);
|
||||
}
|
||||
|
||||
// Called on Binder thread.
|
||||
void
|
||||
MediaCodecReader::VideoCodecCanceled()
|
||||
{
|
||||
mMediaResourcePromise.RejectIfExists(true, __func__);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -161,11 +161,6 @@ protected:
|
||||
// Called on MediaCodecReader::mLooper thread.
|
||||
void onMessageReceived(const android::sp<android::AMessage>& aMessage);
|
||||
|
||||
// Receive a notify from ResourceListener.
|
||||
// Called on Binder thread.
|
||||
virtual void VideoCodecReserved();
|
||||
virtual void VideoCodecCanceled();
|
||||
|
||||
virtual bool CreateExtractor();
|
||||
|
||||
virtual void HandleResourceAllocated();
|
||||
@@ -177,31 +172,12 @@ protected:
|
||||
MozPromiseRequestHolder<MediaResourcePromise> mMediaResourceRequest;
|
||||
MozPromiseHolder<MediaResourcePromise> mMediaResourcePromise;
|
||||
|
||||
MozPromiseRequestHolder<android::MediaCodecProxy::CodecPromise> mVideoCodecRequest;
|
||||
|
||||
private:
|
||||
virtual bool HasAudio() override;
|
||||
virtual bool HasVideo() override;
|
||||
|
||||
// An intermediary class that can be managed by android::sp<T>.
|
||||
// Redirect codecReserved() and codecCanceled() to MediaCodecReader.
|
||||
class VideoResourceListener : public android::MediaCodecProxy::CodecResourceListener
|
||||
{
|
||||
public:
|
||||
VideoResourceListener(MediaCodecReader* aReader);
|
||||
~VideoResourceListener();
|
||||
|
||||
virtual void codecReserved();
|
||||
virtual void codecCanceled();
|
||||
|
||||
private:
|
||||
// Forbidden
|
||||
VideoResourceListener() = delete;
|
||||
VideoResourceListener(const VideoResourceListener& rhs) = delete;
|
||||
const VideoResourceListener& operator=(const VideoResourceListener& rhs) = delete;
|
||||
|
||||
MediaCodecReader* mReader;
|
||||
};
|
||||
friend class VideoResourceListener;
|
||||
|
||||
class VorbisInputCopier : public TrackInputCopier
|
||||
{
|
||||
virtual bool Copy(android::MediaBuffer* aSourceBuffer,
|
||||
@@ -338,11 +314,9 @@ private:
|
||||
void DestroyMediaSources();
|
||||
|
||||
RefPtr<MediaResourcePromise> CreateMediaCodecs();
|
||||
static bool CreateMediaCodec(android::sp<android::ALooper>& aLooper,
|
||||
Track& aTrack,
|
||||
bool aAsync,
|
||||
bool& aIsWaiting,
|
||||
android::wp<android::MediaCodecProxy::CodecResourceListener> aListener);
|
||||
bool CreateMediaCodec(android::sp<android::ALooper>& aLooper,
|
||||
Track& aTrack,
|
||||
bool& aIsWaiting);
|
||||
static bool ConfigureMediaCodec(Track& aTrack);
|
||||
void DestroyMediaCodecs();
|
||||
static void DestroyMediaCodec(Track& aTrack);
|
||||
@@ -397,8 +371,6 @@ private:
|
||||
|
||||
void ReleaseAllTextureClients();
|
||||
|
||||
android::sp<VideoResourceListener> mVideoListener;
|
||||
|
||||
android::sp<android::ALooper> mLooper;
|
||||
android::sp<android::MetaData> mMetaData;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace android;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define DECODER_LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
||||
|
||||
MediaOmxCommonDecoder::MediaOmxCommonDecoder(MediaDecoderOwner* aOwner)
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace android;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define DECODER_LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
||||
|
||||
MediaOmxCommonReader::MediaOmxCommonReader(AbstractMediaDecoder *aDecoder)
|
||||
|
||||
@@ -28,7 +28,7 @@ using namespace android;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaDecoderLog;
|
||||
#define DECODER_LOG(type, msg) MOZ_LOG(gMediaDecoderLog, type, msg)
|
||||
|
||||
class MediaOmxReader::ProcessCachedDataTask : public Task
|
||||
@@ -204,7 +204,7 @@ nsresult MediaOmxReader::InitOmxDecoder()
|
||||
if (!mExtractor.get()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mOmxDecoder = new OmxDecoder(mDecoder);
|
||||
mOmxDecoder = new OmxDecoder(mDecoder, OwnerThread());
|
||||
if (!mOmxDecoder->Init(mExtractor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ OMXCodecProxy::OMXCodecProxy(
|
||||
OMXCodecProxy::~OMXCodecProxy()
|
||||
{
|
||||
mState = ResourceState::END;
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
|
||||
if (mOMXCodec.get()) {
|
||||
wp<MediaSource> tmp = mOMXCodec;
|
||||
@@ -87,34 +88,13 @@ OMXCodecProxy::~OMXCodecProxy()
|
||||
mComponentName = nullptr;
|
||||
}
|
||||
|
||||
void OMXCodecProxy::setListener(const wp<CodecResourceListener>& listener)
|
||||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
void OMXCodecProxy::notifyResourceReserved()
|
||||
{
|
||||
sp<CodecResourceListener> listener = mListener.promote();
|
||||
if (listener != nullptr) {
|
||||
listener->codecReserved();
|
||||
}
|
||||
}
|
||||
|
||||
void OMXCodecProxy::notifyResourceCanceled()
|
||||
{
|
||||
sp<CodecResourceListener> listener = mListener.promote();
|
||||
if (listener != nullptr) {
|
||||
listener->codecCanceled();
|
||||
}
|
||||
}
|
||||
|
||||
void OMXCodecProxy::requestResource()
|
||||
RefPtr<OMXCodecProxy::CodecPromise>
|
||||
OMXCodecProxy::requestResource()
|
||||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
if (mResourceClient) {
|
||||
return;
|
||||
return CodecPromise::CreateAndReject(true, __func__);
|
||||
}
|
||||
mState = ResourceState::WAITING;
|
||||
|
||||
@@ -123,6 +103,9 @@ void OMXCodecProxy::requestResource()
|
||||
mResourceClient = new mozilla::MediaSystemResourceClient(type);
|
||||
mResourceClient->SetListener(this);
|
||||
mResourceClient->Acquire();
|
||||
|
||||
RefPtr<CodecPromise> p = mCodecPromise.Ensure(__func__);
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
// Called on ImageBridge thread
|
||||
@@ -132,13 +115,14 @@ OMXCodecProxy::ResourceReserved()
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
if (mState != ResourceState::WAITING) {
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *mime;
|
||||
if (!mSrcMeta->findCString(kKeyMIMEType, &mime)) {
|
||||
mState = ResourceState::END;
|
||||
notifyResourceCanceled();
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,7 +131,7 @@ OMXCodecProxy::ResourceReserved()
|
||||
mOMXCodec = OMXCodec::Create(mOMX, mSrcMeta, mIsEncoder, mSource, mComponentName, mFlags, mNativeWindow);
|
||||
if (mOMXCodec == nullptr) {
|
||||
mState = ResourceState::END;
|
||||
notifyResourceCanceled();
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
return;
|
||||
}
|
||||
// Check if this video is sized such that we're comfortable
|
||||
@@ -168,7 +152,7 @@ OMXCodecProxy::ResourceReserved()
|
||||
width, height, maxWidth, maxHeight);
|
||||
mOMXCodec.clear();
|
||||
mState = ResourceState::END;
|
||||
notifyResourceCanceled();
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -176,13 +160,13 @@ OMXCodecProxy::ResourceReserved()
|
||||
NS_WARNING("Couldn't start OMX video source");
|
||||
mOMXCodec.clear();
|
||||
mState = ResourceState::END;
|
||||
notifyResourceCanceled();
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mState = ResourceState::ACQUIRED;
|
||||
notifyResourceReserved();
|
||||
mCodecPromise.ResolveIfExists(true, __func__);
|
||||
}
|
||||
|
||||
// Called on ImageBridge thread
|
||||
@@ -191,9 +175,11 @@ OMXCodecProxy::ResourceReserveFailed()
|
||||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
mState = ResourceState::NOT_ACQUIRED;
|
||||
mCodecPromise.RejectIfExists(true, __func__);
|
||||
}
|
||||
|
||||
status_t OMXCodecProxy::start(MetaData *params)
|
||||
status_t
|
||||
OMXCodecProxy::start(MetaData *params)
|
||||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
@@ -204,7 +190,8 @@ status_t OMXCodecProxy::start(MetaData *params)
|
||||
return mOMXCodec->start();
|
||||
}
|
||||
|
||||
status_t OMXCodecProxy::stop()
|
||||
status_t
|
||||
OMXCodecProxy::stop()
|
||||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
@@ -215,7 +202,8 @@ status_t OMXCodecProxy::stop()
|
||||
return mOMXCodec->stop();
|
||||
}
|
||||
|
||||
sp<MetaData> OMXCodecProxy::getFormat()
|
||||
sp<MetaData>
|
||||
OMXCodecProxy::getFormat()
|
||||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
@@ -227,7 +215,8 @@ sp<MetaData> OMXCodecProxy::getFormat()
|
||||
return mOMXCodec->getFormat();
|
||||
}
|
||||
|
||||
status_t OMXCodecProxy::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
status_t
|
||||
OMXCodecProxy::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
@@ -238,7 +227,8 @@ status_t OMXCodecProxy::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
return mOMXCodec->read(buffer, options);
|
||||
}
|
||||
|
||||
status_t OMXCodecProxy::pause()
|
||||
status_t
|
||||
OMXCodecProxy::pause()
|
||||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#include <utils/threads.h>
|
||||
|
||||
#include "mozilla/media/MediaSystemResourceClient.h"
|
||||
#include "RefPtr.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -24,20 +25,7 @@ class OMXCodecProxy : public MediaSource
|
||||
, public mozilla::MediaSystemResourceReservationListener
|
||||
{
|
||||
public:
|
||||
/* Codec resource notification listener.
|
||||
* All functions are called on the Binder thread.
|
||||
*/
|
||||
struct CodecResourceListener : public virtual RefBase {
|
||||
/* The codec resource is reserved and can be granted.
|
||||
* The client can allocate the requested resource.
|
||||
*/
|
||||
virtual void codecReserved() = 0;
|
||||
/* The codec resource is not reserved any more.
|
||||
* The client should release the resource as soon as possible if the
|
||||
* resource is still being held.
|
||||
*/
|
||||
virtual void codecCanceled() = 0;
|
||||
};
|
||||
typedef mozilla::MozPromise<bool /* aIgnored */, bool /* aIgnored */, /* IsExclusive = */ true> CodecPromise;
|
||||
|
||||
// Enumeration for the valid resource allcoation states
|
||||
enum class ResourceState : int8_t {
|
||||
@@ -56,9 +44,7 @@ public:
|
||||
uint32_t flags = 0,
|
||||
const sp<ANativeWindow> &nativeWindow = nullptr);
|
||||
|
||||
void setListener(const wp<CodecResourceListener>& listener);
|
||||
|
||||
void requestResource();
|
||||
RefPtr<CodecPromise> requestResource();
|
||||
|
||||
// MediaSystemResourceReservationListener
|
||||
void ResourceReserved() override;
|
||||
@@ -87,11 +73,6 @@ protected:
|
||||
|
||||
virtual ~OMXCodecProxy();
|
||||
|
||||
void notifyResourceReserved();
|
||||
void notifyResourceCanceled();
|
||||
|
||||
void notifyStatusChangedLocked();
|
||||
|
||||
private:
|
||||
OMXCodecProxy(const OMXCodecProxy &);
|
||||
OMXCodecProxy &operator=(const OMXCodecProxy &);
|
||||
@@ -112,9 +93,7 @@ private:
|
||||
|
||||
RefPtr<mozilla::MediaSystemResourceClient> mResourceClient;
|
||||
ResourceState mState;
|
||||
|
||||
// Codec Resource Notification Listener
|
||||
wp<CodecResourceListener> mListener;
|
||||
mozilla::MozPromiseHolder<CodecPromise> mCodecPromise;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#define OD_LOG(...) __android_log_print(ANDROID_LOG_DEBUG, "OmxDecoder", __VA_ARGS__)
|
||||
|
||||
#undef LOG
|
||||
PRLogModuleInfo *gOmxDecoderLog;
|
||||
mozilla::LazyLogModule gOmxDecoderLog("OmxDecoder");
|
||||
#define LOG(type, msg...) MOZ_LOG(gOmxDecoderLog, type, (msg))
|
||||
|
||||
using namespace MPAPI;
|
||||
@@ -46,7 +46,8 @@ using namespace mozilla::gfx;
|
||||
using namespace mozilla::layers;
|
||||
using namespace android;
|
||||
|
||||
OmxDecoder::OmxDecoder(AbstractMediaDecoder *aDecoder) :
|
||||
OmxDecoder::OmxDecoder(AbstractMediaDecoder *aDecoder,
|
||||
mozilla::TaskQueue* aTaskQueue) :
|
||||
mDecoder(aDecoder),
|
||||
mDisplayWidth(0),
|
||||
mDisplayHeight(0),
|
||||
@@ -59,11 +60,12 @@ OmxDecoder::OmxDecoder(AbstractMediaDecoder *aDecoder) :
|
||||
mAudioChannels(-1),
|
||||
mAudioSampleRate(-1),
|
||||
mDurationUs(-1),
|
||||
mVideoLastFrameTime(-1),
|
||||
mLastSeekTime(-1),
|
||||
mVideoBuffer(nullptr),
|
||||
mAudioBuffer(nullptr),
|
||||
mIsVideoSeeking(false),
|
||||
mAudioMetadataRead(false),
|
||||
mTaskQueue(aTaskQueue),
|
||||
mAudioPaused(false),
|
||||
mVideoPaused(false)
|
||||
{
|
||||
@@ -89,15 +91,6 @@ OmxDecoder::~OmxDecoder()
|
||||
mLooper->stop();
|
||||
}
|
||||
|
||||
void OmxDecoder::codecReserved()
|
||||
{
|
||||
mMediaResourcePromise.ResolveIfExists(true, __func__);
|
||||
}
|
||||
void OmxDecoder::codecCanceled()
|
||||
{
|
||||
mMediaResourcePromise.RejectIfExists(true, __func__);
|
||||
}
|
||||
|
||||
static sp<IOMX> sOMX = nullptr;
|
||||
static sp<IOMX> GetOMX()
|
||||
{
|
||||
@@ -107,11 +100,8 @@ static sp<IOMX> GetOMX()
|
||||
return sOMX;
|
||||
}
|
||||
|
||||
bool OmxDecoder::Init(sp<MediaExtractor>& extractor) {
|
||||
if (!gOmxDecoderLog) {
|
||||
gOmxDecoderLog = PR_NewLogModule("OmxDecoder");
|
||||
}
|
||||
|
||||
bool
|
||||
OmxDecoder::Init(sp<MediaExtractor>& extractor) {
|
||||
sp<MetaData> meta = extractor->getMetaData();
|
||||
|
||||
ssize_t audioTrackIndex = -1;
|
||||
@@ -157,7 +147,8 @@ bool OmxDecoder::Init(sp<MediaExtractor>& extractor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OmxDecoder::EnsureMetadata() {
|
||||
bool
|
||||
OmxDecoder::EnsureMetadata() {
|
||||
// calculate duration
|
||||
int64_t totalDurationUs = 0;
|
||||
int64_t durationUs = 0;
|
||||
@@ -217,7 +208,8 @@ static bool isInEmulator()
|
||||
return !strncmp(propQemu, "1", 1);
|
||||
}
|
||||
|
||||
RefPtr<mozilla::MediaOmxCommonReader::MediaResourcePromise> OmxDecoder::AllocateMediaResources()
|
||||
RefPtr<mozilla::MediaOmxCommonReader::MediaResourcePromise>
|
||||
OmxDecoder::AllocateMediaResources()
|
||||
{
|
||||
RefPtr<MediaResourcePromise> p = mMediaResourcePromise.Ensure(__func__);
|
||||
|
||||
@@ -274,9 +266,16 @@ RefPtr<mozilla::MediaOmxCommonReader::MediaResourcePromise> OmxDecoder::Allocate
|
||||
mMediaResourcePromise.Reject(true, __func__);
|
||||
return p;
|
||||
} else {
|
||||
sp<OMXCodecProxy::CodecResourceListener> listener = this;
|
||||
mVideoSource->setListener(listener);
|
||||
mVideoSource->requestResource();
|
||||
sp<OmxDecoder> self = this;
|
||||
mVideoCodecRequest.Begin(mVideoSource->requestResource()
|
||||
->Then(OwnerThread(), __func__,
|
||||
[self] (bool) -> void {
|
||||
self->mVideoCodecRequest.Complete();
|
||||
self->mMediaResourcePromise.ResolveIfExists(true, __func__);
|
||||
}, [self] (bool) -> void {
|
||||
self->mVideoCodecRequest.Complete();
|
||||
self->mMediaResourcePromise.RejectIfExists(true, __func__);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +336,9 @@ RefPtr<mozilla::MediaOmxCommonReader::MediaResourcePromise> OmxDecoder::Allocate
|
||||
}
|
||||
|
||||
|
||||
void OmxDecoder::ReleaseMediaResources() {
|
||||
void
|
||||
OmxDecoder::ReleaseMediaResources() {
|
||||
mVideoCodecRequest.DisconnectIfExists();
|
||||
mMediaResourcePromise.RejectIfExists(true, __func__);
|
||||
|
||||
ReleaseVideoBuffer();
|
||||
@@ -381,9 +382,14 @@ void OmxDecoder::ReleaseMediaResources() {
|
||||
|
||||
mNativeWindowClient.clear();
|
||||
mNativeWindow.clear();
|
||||
|
||||
// Reset this variable to make the first seek go to the previous keyframe
|
||||
// when resuming
|
||||
mLastSeekTime = -1;
|
||||
}
|
||||
|
||||
bool OmxDecoder::SetVideoFormat() {
|
||||
bool
|
||||
OmxDecoder::SetVideoFormat() {
|
||||
const char *componentName;
|
||||
|
||||
if (!mVideoSource->getFormat()->findInt32(kKeyWidth, &mVideoWidth) ||
|
||||
@@ -439,7 +445,8 @@ bool OmxDecoder::SetVideoFormat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OmxDecoder::SetAudioFormat() {
|
||||
bool
|
||||
OmxDecoder::SetAudioFormat() {
|
||||
// If the format changed, update our cached info.
|
||||
if (!mAudioSource->getFormat()->findInt32(kKeyChannelCount, &mAudioChannels) ||
|
||||
!mAudioSource->getFormat()->findInt32(kKeySampleRate, &mAudioSampleRate)) {
|
||||
@@ -452,26 +459,30 @@ bool OmxDecoder::SetAudioFormat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void OmxDecoder::ReleaseDecoder()
|
||||
void
|
||||
OmxDecoder::ReleaseDecoder()
|
||||
{
|
||||
mDecoder = nullptr;
|
||||
}
|
||||
|
||||
void OmxDecoder::ReleaseVideoBuffer() {
|
||||
void
|
||||
OmxDecoder::ReleaseVideoBuffer() {
|
||||
if (mVideoBuffer) {
|
||||
mVideoBuffer->release();
|
||||
mVideoBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void OmxDecoder::ReleaseAudioBuffer() {
|
||||
void
|
||||
OmxDecoder::ReleaseAudioBuffer() {
|
||||
if (mAudioBuffer) {
|
||||
mAudioBuffer->release();
|
||||
mAudioBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void OmxDecoder::PlanarYUV420Frame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
void
|
||||
OmxDecoder::PlanarYUV420Frame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
void *y = aData;
|
||||
void *u = static_cast<uint8_t *>(y) + mVideoStride * mVideoSliceHeight;
|
||||
void *v = static_cast<uint8_t *>(u) + mVideoStride/2 * mVideoSliceHeight/2;
|
||||
@@ -483,7 +494,8 @@ void OmxDecoder::PlanarYUV420Frame(VideoFrame *aFrame, int64_t aTimeUs, void *aD
|
||||
v, mVideoStride/2, mVideoWidth/2, mVideoHeight/2, 0, 0);
|
||||
}
|
||||
|
||||
void OmxDecoder::CbYCrYFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
void
|
||||
OmxDecoder::CbYCrYFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
aFrame->Set(aTimeUs, aKeyFrame,
|
||||
aData, aSize, mVideoStride, mVideoSliceHeight, mVideoRotation,
|
||||
aData, mVideoStride, mVideoWidth, mVideoHeight, 1, 1,
|
||||
@@ -491,7 +503,8 @@ void OmxDecoder::CbYCrYFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, s
|
||||
aData, mVideoStride, mVideoWidth/2, mVideoHeight/2, 2, 3);
|
||||
}
|
||||
|
||||
void OmxDecoder::SemiPlanarYUV420Frame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
void
|
||||
OmxDecoder::SemiPlanarYUV420Frame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
void *y = aData;
|
||||
void *uv = static_cast<uint8_t *>(y) + (mVideoStride * mVideoSliceHeight);
|
||||
|
||||
@@ -502,13 +515,15 @@ void OmxDecoder::SemiPlanarYUV420Frame(VideoFrame *aFrame, int64_t aTimeUs, void
|
||||
uv, mVideoStride, mVideoWidth/2, mVideoHeight/2, 1, 1);
|
||||
}
|
||||
|
||||
void OmxDecoder::SemiPlanarYVU420Frame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
void
|
||||
OmxDecoder::SemiPlanarYVU420Frame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
SemiPlanarYUV420Frame(aFrame, aTimeUs, aData, aSize, aKeyFrame);
|
||||
aFrame->Cb.mOffset = 1;
|
||||
aFrame->Cr.mOffset = 0;
|
||||
}
|
||||
|
||||
bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
bool
|
||||
OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame) {
|
||||
const int OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00;
|
||||
|
||||
aFrame->mGraphicBuffer = nullptr;
|
||||
@@ -533,13 +548,15 @@ bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OmxDecoder::ToAudioFrame(AudioFrame *aFrame, int64_t aTimeUs, void *aData, size_t aDataOffset, size_t aSize, int32_t aAudioChannels, int32_t aAudioSampleRate)
|
||||
bool
|
||||
OmxDecoder::ToAudioFrame(AudioFrame *aFrame, int64_t aTimeUs, void *aData, size_t aDataOffset, size_t aSize, int32_t aAudioChannels, int32_t aAudioSampleRate)
|
||||
{
|
||||
aFrame->Set(aTimeUs, static_cast<char *>(aData) + aDataOffset, aSize, aAudioChannels, aAudioSampleRate);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
|
||||
bool
|
||||
OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
|
||||
bool aKeyframeSkip, bool aDoSeek)
|
||||
{
|
||||
if (!mVideoSource.get())
|
||||
@@ -559,12 +576,13 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
|
||||
MediaSource::ReadOptions::SeekMode seekMode;
|
||||
// If the last timestamp of decoded frame is smaller than seekTime,
|
||||
// seek to next key frame. Otherwise seek to the previos one.
|
||||
if (mVideoLastFrameTime > aTimeUs || mVideoLastFrameTime == -1) {
|
||||
OD_LOG("SeekTime: %lld, mLastSeekTime:%lld", aTimeUs, mLastSeekTime);
|
||||
if (mLastSeekTime == -1 || mLastSeekTime > aTimeUs) {
|
||||
seekMode = MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC;
|
||||
} else {
|
||||
seekMode = MediaSource::ReadOptions::SEEK_NEXT_SYNC;
|
||||
}
|
||||
|
||||
mLastSeekTime = aTimeUs;
|
||||
bool findNextBuffer = true;
|
||||
while (findNextBuffer) {
|
||||
options.setSeekTo(aTimeUs, seekMode);
|
||||
@@ -576,7 +594,7 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
|
||||
PostReleaseVideoBuffer(nullptr, FenceHandle());
|
||||
}
|
||||
else {
|
||||
err = mVideoSource->read(&mVideoBuffer);
|
||||
err = mVideoSource->read(&mVideoBuffer);
|
||||
}
|
||||
|
||||
// If there is no next Keyframe, jump to the previous key frame.
|
||||
@@ -670,7 +688,6 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
|
||||
if ((aKeyframeSkip && timeUs < aTimeUs) || length == 0) {
|
||||
aFrame->mShouldSkip = true;
|
||||
}
|
||||
mVideoLastFrameTime = timeUs;
|
||||
}
|
||||
else if (err == INFO_FORMAT_CHANGED) {
|
||||
// If the format changed, update our cached info.
|
||||
@@ -697,7 +714,8 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OmxDecoder::ReadAudio(AudioFrame *aFrame, int64_t aSeekTimeUs)
|
||||
bool
|
||||
OmxDecoder::ReadAudio(AudioFrame *aFrame, int64_t aSeekTimeUs)
|
||||
{
|
||||
status_t err;
|
||||
|
||||
@@ -756,7 +774,8 @@ bool OmxDecoder::ReadAudio(AudioFrame *aFrame, int64_t aSeekTimeUs)
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult OmxDecoder::Play()
|
||||
nsresult
|
||||
OmxDecoder::Play()
|
||||
{
|
||||
if (!mVideoPaused && !mAudioPaused) {
|
||||
return NS_OK;
|
||||
@@ -783,7 +802,8 @@ nsresult OmxDecoder::Play()
|
||||
// implement the OMXCodec::Pause() and need a following OMXCodec::Read() with
|
||||
// seek option (define in MediaSource.h) then it is still not supported here.
|
||||
// We need to fix it until it is really happened.
|
||||
void OmxDecoder::Pause()
|
||||
void
|
||||
OmxDecoder::Pause()
|
||||
{
|
||||
/* The implementation of OMXCodec::pause is flawed.
|
||||
* OMXCodec::start will not restore from the paused state and result in
|
||||
@@ -809,7 +829,8 @@ void OmxDecoder::Pause()
|
||||
}
|
||||
|
||||
// Called on ALooper thread.
|
||||
void OmxDecoder::onMessageReceived(const sp<AMessage> &msg)
|
||||
void
|
||||
OmxDecoder::onMessageReceived(const sp<AMessage> &msg)
|
||||
{
|
||||
switch (msg->what()) {
|
||||
case kNotifyPostReleaseVideoBuffer:
|
||||
@@ -828,7 +849,8 @@ void OmxDecoder::onMessageReceived(const sp<AMessage> &msg)
|
||||
}
|
||||
}
|
||||
|
||||
void OmxDecoder::PostReleaseVideoBuffer(MediaBuffer *aBuffer, const FenceHandle& aReleaseFenceHandle)
|
||||
void
|
||||
OmxDecoder::PostReleaseVideoBuffer(MediaBuffer *aBuffer, const FenceHandle& aReleaseFenceHandle)
|
||||
{
|
||||
{
|
||||
Mutex::Autolock autoLock(mPendingVideoBuffersLock);
|
||||
@@ -843,7 +865,8 @@ void OmxDecoder::PostReleaseVideoBuffer(MediaBuffer *aBuffer, const FenceHandle&
|
||||
notify->post();
|
||||
}
|
||||
|
||||
void OmxDecoder::ReleaseAllPendingVideoBuffersLocked()
|
||||
void
|
||||
OmxDecoder::ReleaseAllPendingVideoBuffersLocked()
|
||||
{
|
||||
Vector<BufferItem> releasingVideoBuffers;
|
||||
{
|
||||
@@ -883,7 +906,8 @@ void OmxDecoder::ReleaseAllPendingVideoBuffersLocked()
|
||||
releasingVideoBuffers.clear();
|
||||
}
|
||||
|
||||
void OmxDecoder::RecycleCallbackImp(TextureClient* aClient)
|
||||
void
|
||||
OmxDecoder::RecycleCallbackImp(TextureClient* aClient)
|
||||
{
|
||||
aClient->ClearRecycleCallback();
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ class OmxDecoder;
|
||||
|
||||
namespace android {
|
||||
|
||||
class OmxDecoder : public OMXCodecProxy::CodecResourceListener {
|
||||
class OmxDecoder : public RefBase {
|
||||
typedef MPAPI::AudioFrame AudioFrame;
|
||||
typedef MPAPI::VideoFrame VideoFrame;
|
||||
typedef mozilla::MP3FrameParser MP3FrameParser;
|
||||
@@ -59,7 +59,7 @@ class OmxDecoder : public OMXCodecProxy::CodecResourceListener {
|
||||
int32_t mAudioChannels;
|
||||
int32_t mAudioSampleRate;
|
||||
int64_t mDurationUs;
|
||||
int64_t mVideoLastFrameTime;
|
||||
int64_t mLastSeekTime;
|
||||
|
||||
VideoFrame mVideoFrame;
|
||||
AudioFrame mAudioFrame;
|
||||
@@ -119,6 +119,9 @@ class OmxDecoder : public OMXCodecProxy::CodecResourceListener {
|
||||
// 'true' if a read from the audio stream was done while reading the metadata
|
||||
bool mAudioMetadataRead;
|
||||
|
||||
RefPtr<mozilla::TaskQueue> mTaskQueue;
|
||||
|
||||
mozilla::MozPromiseRequestHolder<OMXCodecProxy::CodecPromise> mVideoCodecRequest;
|
||||
mozilla::MozPromiseHolder<MediaResourcePromise> mMediaResourcePromise;
|
||||
|
||||
void ReleaseVideoBuffer();
|
||||
@@ -138,13 +141,14 @@ class OmxDecoder : public OMXCodecProxy::CodecResourceListener {
|
||||
bool mAudioPaused;
|
||||
bool mVideoPaused;
|
||||
|
||||
public:
|
||||
explicit OmxDecoder(AbstractMediaDecoder *aDecoder);
|
||||
~OmxDecoder();
|
||||
mozilla::TaskQueue* OwnerThread() const
|
||||
{
|
||||
return mTaskQueue;
|
||||
}
|
||||
|
||||
// OMXCodecProxy::CodecResourceListener
|
||||
virtual void codecReserved();
|
||||
virtual void codecCanceled();
|
||||
public:
|
||||
explicit OmxDecoder(AbstractMediaDecoder *aDecoder, mozilla::TaskQueue* aTaskQueue);
|
||||
~OmxDecoder();
|
||||
|
||||
// The MediaExtractor provides essential information for creating OMXCodec
|
||||
// instance. Such as video/audio codec, we can retrieve them through the
|
||||
|
||||
@@ -24,7 +24,7 @@ nsresult RtspOmxReader::InitOmxDecoder()
|
||||
NS_ASSERTION(mDecoder->GetResource(),
|
||||
"RtspOmxReader mDecoder->GetResource() is null.");
|
||||
mExtractor = new RtspExtractor(mRtspResource);
|
||||
mOmxDecoder = new OmxDecoder(mDecoder);
|
||||
mOmxDecoder = new OmxDecoder(mDecoder, OwnerThread());
|
||||
if (!mOmxDecoder->Init(mExtractor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ PDMFactory::CreateDecoderWithPDM(PlatformDecoderModule* aPDM,
|
||||
}
|
||||
|
||||
bool
|
||||
PDMFactory::SupportsMimeType(const nsACString& aMimeType)
|
||||
PDMFactory::SupportsMimeType(const nsACString& aMimeType) const
|
||||
{
|
||||
if (mEMEPDM) {
|
||||
return mEMEPDM->SupportsMimeType(aMimeType);
|
||||
@@ -305,7 +305,7 @@ PDMFactory::StartupPDM(PlatformDecoderModule* aPDM)
|
||||
}
|
||||
|
||||
already_AddRefed<PlatformDecoderModule>
|
||||
PDMFactory::GetDecoder(const nsACString& aMimeType)
|
||||
PDMFactory::GetDecoder(const nsACString& aMimeType) const
|
||||
{
|
||||
RefPtr<PlatformDecoderModule> pdm;
|
||||
for (auto& current : mCurrentPDMs) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
layers::LayersBackend aLayersBackend = layers::LayersBackend::LAYERS_NONE,
|
||||
layers::ImageContainer* aImageContainer = nullptr);
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType);
|
||||
bool SupportsMimeType(const nsACString& aMimeType) const;
|
||||
|
||||
#ifdef MOZ_EME
|
||||
// Creates a PlatformDecoderModule that uses a CDMProxy to decrypt or
|
||||
@@ -52,7 +52,9 @@ private:
|
||||
// Startup the provided PDM and add it to our list if successful.
|
||||
bool StartupPDM(PlatformDecoderModule* aPDM);
|
||||
// Returns the first PDM in our list supporting the mimetype.
|
||||
already_AddRefed<PlatformDecoderModule> GetDecoder(const nsACString& aMimeType);
|
||||
already_AddRefed<PlatformDecoderModule>
|
||||
GetDecoder(const nsACString& aMimeType) const;
|
||||
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
CreateDecoderWithPDM(PlatformDecoderModule* aPDM,
|
||||
const TrackInfo& aConfig,
|
||||
|
||||
@@ -6,10 +6,7 @@
|
||||
|
||||
#include "PlatformDecoderModule.h"
|
||||
|
||||
PRLogModuleInfo* GetPDMLog() {
|
||||
static PRLogModuleInfo* log = nullptr;
|
||||
if (!log) {
|
||||
log = PR_NewLogModule("PlatformDecoderModule");
|
||||
}
|
||||
mozilla::LogModule* GetPDMLog() {
|
||||
static mozilla::LazyLogModule log("PlatformDecoderModule");
|
||||
return log;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
virtual nsresult Startup() { return NS_OK; };
|
||||
|
||||
// Indicates if the PlatformDecoderModule supports decoding of aMimeType.
|
||||
virtual bool SupportsMimeType(const nsACString& aMimeType) = 0;
|
||||
virtual bool SupportsMimeType(const nsACString& aMimeType) const = 0;
|
||||
|
||||
enum ConversionRequired {
|
||||
kNeedNone,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace mozilla {
|
||||
|
||||
bool
|
||||
AgnosticDecoderModule::SupportsMimeType(const nsACString& aMimeType)
|
||||
AgnosticDecoderModule::SupportsMimeType(const nsACString& aMimeType) const
|
||||
{
|
||||
return VPXDecoder::IsVPX(aMimeType) ||
|
||||
OpusDataDecoder::IsOpus(aMimeType) ||
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
AgnosticDecoderModule() = default;
|
||||
virtual ~AgnosticDecoderModule() = default;
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType) override;
|
||||
bool SupportsMimeType(const nsACString& aMimeType) const override;
|
||||
|
||||
ConversionRequired
|
||||
DecoderNeedsConversion(const TrackInfo& aConfig) const override
|
||||
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
}
|
||||
|
||||
bool
|
||||
SupportsMimeType(const nsACString& aMimeType) override
|
||||
SupportsMimeType(const nsACString& aMimeType) const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h> // For PRId64
|
||||
|
||||
extern PRLogModuleInfo* GetPDMLog();
|
||||
extern mozilla::LogModule* GetPDMLog();
|
||||
#define OPUS_DEBUG(arg, ...) MOZ_LOG(GetPDMLog(), mozilla::LogLevel::Debug, \
|
||||
("OpusDataDecoder(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
#include "nsError.h"
|
||||
#include "TimeUnits.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "prsystem.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#undef LOG
|
||||
extern PRLogModuleInfo* GetPDMLog();
|
||||
extern mozilla::LogModule* GetPDMLog();
|
||||
#define LOG(arg, ...) MOZ_LOG(GetPDMLog(), mozilla::LogLevel::Debug, ("VPXDecoder(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||
|
||||
namespace mozilla {
|
||||
@@ -56,13 +57,26 @@ VPXDecoder::Shutdown()
|
||||
RefPtr<MediaDataDecoder::InitPromise>
|
||||
VPXDecoder::Init()
|
||||
{
|
||||
int decode_threads = 2;
|
||||
|
||||
vpx_codec_iface_t* dx = nullptr;
|
||||
if (mCodec == Codec::VP8) {
|
||||
dx = vpx_codec_vp8_dx();
|
||||
} else if (mCodec == Codec::VP9) {
|
||||
dx = vpx_codec_vp9_dx();
|
||||
if (mInfo.mDisplay.width >= 2048) {
|
||||
decode_threads = 8;
|
||||
} else if (mInfo.mDisplay.width >= 1024) {
|
||||
decode_threads = 4;
|
||||
}
|
||||
}
|
||||
if (!dx || vpx_codec_dec_init(&mVPX, dx, nullptr, 0)) {
|
||||
decode_threads = std::min(decode_threads, PR_GetNumberOfProcessors());
|
||||
|
||||
vpx_codec_dec_cfg_t config;
|
||||
config.threads = decode_threads;
|
||||
config.w = config.h = 0; // set after decode
|
||||
|
||||
if (!dx || vpx_codec_dec_init(&mVPX, dx, &config, 0)) {
|
||||
return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__);
|
||||
}
|
||||
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
#undef LOG
|
||||
extern PRLogModuleInfo* GetPDMLog();
|
||||
extern mozilla::LogModule* GetPDMLog();
|
||||
#define LOG(type, msg) MOZ_LOG(GetPDMLog(), type, msg)
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@@ -228,7 +228,7 @@ GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType,
|
||||
}
|
||||
|
||||
bool
|
||||
GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType)
|
||||
GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType) const
|
||||
{
|
||||
return SupportsMimeType(aMimeType, PreferredGMP(aMimeType));
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user