Bug 1062666 - Add a debug-only dump method to MediaSource for debugging issues with appended data. r=cajbir

This commit is contained in:
Matthew Gregan 2014-09-12 10:47:06 +12:00
Родитель 32faa289a1
Коммит 0f85a12a74
11 изменённых файлов: 101 добавлений и 1 удалений

Просмотреть файл

@ -507,6 +507,20 @@ MediaSource::InitializationEvent()
}
}
#if defined(DEBUG)
void
MediaSource::Dump(const char* aPath)
{
char buf[255];
PR_snprintf(buf, sizeof(buf), "%s/mediasource-%p", aPath, this);
PR_MkDir(buf, 0700);
if (mSourceBuffers) {
mSourceBuffers->Dump(buf);
}
}
#endif
nsPIDOMWindow*
MediaSource::GetParentObject() const
{

Просмотреть файл

@ -98,6 +98,12 @@ public:
// initialization.
void QueueInitializationEvent();
#if defined(DEBUG)
// Dump the contents of each SourceBuffer to a series of files under aPath.
// aPath must exist. Debug only, invoke from your favourite debugger.
void Dump(const char* aPath);
#endif
private:
~MediaSource();

Просмотреть файл

@ -134,6 +134,23 @@ public:
return size;
}
#if defined(DEBUG)
void Dump(const char* aPath) {
for (uint32_t i = 0; i < uint32_t(GetSize()); ++i) {
ResourceItem* item = ResourceAt(i);
char buf[255];
PR_snprintf(buf, sizeof(buf), "%s/%08u.bin", aPath, i);
FILE* fp = fopen(buf, "wb");
if (!fp) {
return;
}
fwrite(item->mData.Elements(), item->mData.Length(), 1, fp);
fclose(fp);
}
}
#endif
private:
ResourceItem* ResourceAt(uint32_t aIndex) const {
return static_cast<ResourceItem*>(ObjectAt(aIndex));
@ -173,6 +190,5 @@ private:
uint64_t mOffset;
};
} // namespace mozilla
#endif /* MOZILLA_RESOURCEQUEUE_H_ */

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@ -687,6 +688,16 @@ SourceBuffer::Evict(double aStart, double aEnd)
mTrackBuffer->EvictBefore(evictTime);
}
#if defined(DEBUG)
void
SourceBuffer::Dump(const char* aPath)
{
if (mTrackBuffer) {
mTrackBuffer->Dump(aPath);
}
}
#endif
NS_IMPL_CYCLE_COLLECTION_INHERITED(SourceBuffer, DOMEventTargetHelper,
mMediaSource)

Просмотреть файл

@ -109,6 +109,10 @@ public:
double GetBufferedStart();
double GetBufferedEnd();
#if defined(DEBUG)
void Dump(const char* aPath);
#endif
private:
~SourceBuffer();

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this

Просмотреть файл

@ -167,6 +167,16 @@ SourceBufferList::QueueAsyncSimpleEvent(const char* aName)
NS_DispatchToMainThread(event);
}
#if defined(DEBUG)
void
SourceBufferList::Dump(const char* aPath)
{
for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
mSourceBuffers[i]->Dump(aPath);
}
}
#endif
SourceBufferList::SourceBufferList(MediaSource* aMediaSource)
: DOMEventTargetHelper(aMediaSource->GetParentObject())
, mMediaSource(aMediaSource)

Просмотреть файл

@ -79,6 +79,10 @@ public:
// Returns the highest end time of any of the Sourcebuffers.
double GetHighestBufferedEndTime();
#if defined(DEBUG)
void Dump(const char* aPath);
#endif
private:
~SourceBufferList();

Просмотреть файл

@ -120,6 +120,12 @@ public:
// Remove data from resource before the given offset.
void EvictBefore(uint64_t aOffset);
#if defined(DEBUG)
void Dump(const char* aPath) {
mInputBuffer.Dump(aPath);
}
#endif
private:
~SourceBufferResource();
nsresult SeekInternal(int64_t aOffset);

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@ -19,6 +20,11 @@
#include "nsThreadUtils.h"
#include "prlog.h"
#if defined(DEBUG)
#include <sys/stat.h>
#include <sys/types.h>
#endif
struct JSContext;
class JSObject;
@ -349,4 +355,22 @@ TrackBuffer::Decoders()
return mInitializedDecoders;
}
#if defined(DEBUG)
void
TrackBuffer::Dump(const char* aPath)
{
char path[255];
PR_snprintf(path, sizeof(path), "%s/trackbuffer-%p", aPath, this);
PR_MkDir(path, 0700);
for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
char buf[255];
PR_snprintf(buf, sizeof(buf), "%s/reader-%p", path, mDecoders[i]->GetReader());
PR_MkDir(buf, 0700);
mDecoders[i]->GetResource()->Dump(buf);
}
}
#endif
} // namespace mozilla

Просмотреть файл

@ -82,6 +82,10 @@ public:
// TODO: Refactor to a cleaner interface between TrackBuffer and MediaSourceReader.
const nsTArray<nsRefPtr<SourceBufferDecoder>>& Decoders();
#if defined(DEBUG)
void Dump(const char* aPath);
#endif
private:
~TrackBuffer();