Bug 1332160 - use nsCString internally whenever possible.
MozReview-Commit-ID: 1DUaJWfbL88
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1442,17 +1442,19 @@ HTMLMediaElement::GetMozMediaSourceObjec
RefPtr<MediaSource> source = mMediaSource;
return source.forget();
}
void
HTMLMediaElement::GetMozDebugReaderData(nsAString& aString)
{
if (mDecoder && !mSrcStream) {
- mDecoder->GetMozDebugReaderData(aString);
+ nsAutoCString result;
+ mDecoder->GetMozDebugReaderData(result);
+ aString = NS_ConvertUTF8toUTF16(result);
}
}
void
HTMLMediaElement::MozDumpDebugInfo()
{
if (mDecoder) {
mDecoder->DumpDebugInfo();
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1733,20 +1733,20 @@ MediaDecoder::DumpDebugInfo()
{
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
DUMP_LOG("metadata: channels=%u rate=%u hasAudio=%d hasVideo=%d, "
"state: mPlayState=%s mdsm=%p",
mInfo ? mInfo->mAudio.mChannels : 0, mInfo ? mInfo->mAudio.mRate : 0,
mInfo ? mInfo->HasAudio() : 0, mInfo ? mInfo->HasVideo() : 0,
PlayStateStr(), GetStateMachine());
- nsString str;
+ nsAutoCString str;
GetMozDebugReaderData(str);
if (!str.IsEmpty()) {
- DUMP_LOG("reader data:\n%s", NS_ConvertUTF16toUTF8(str).get());
+ DUMP_LOG("reader data:\n%s", str.get());
}
if (GetStateMachine()) {
GetStateMachine()->DumpDebugInfo();
}
}
void
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -468,17 +468,17 @@ private:
mOwner->UpdateReadyState();
}
virtual MediaDecoderOwner::NextFrameStatus NextFrameStatus() { return mNextFrameStatus; }
virtual MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus();
// Returns a string describing the state of the media player internal
// data. Used for debugging purposes.
- virtual void GetMozDebugReaderData(nsAString& aString) {}
+ virtual void GetMozDebugReaderData(nsACString& aString) {}
virtual void DumpDebugInfo();
protected:
virtual ~MediaDecoder();
// Called when the first audio and/or video from the media file has been loaded
// by the state machine. Call on the main thread only.
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -2647,17 +2647,17 @@ MediaFormatReader::UpdateBuffered()
layers::ImageContainer*
MediaFormatReader::GetImageContainer()
{
return mVideoFrameContainer
? mVideoFrameContainer->GetImageContainer() : nullptr;
}
void
-MediaFormatReader::GetMozDebugReaderData(nsAString& aString)
+MediaFormatReader::GetMozDebugReaderData(nsACString& aString)
{
nsAutoCString result;
const char* audioName = "unavailable";
const char* videoName = audioName;
if (HasAudio()) {
MutexAutoLock lock(mAudio.mMutex);
audioName = mAudio.mDescription;
@@ -2707,17 +2707,17 @@ MediaFormatReader::GetMozDebugReaderData
? mVideo.mTimeThreshold.ref().mHasSeeked
: -1,
mVideo.mNumSamplesInput, mVideo.mNumSamplesOutput,
unsigned(size_t(mVideo.mSizeOfQueue)),
unsigned(mVideo.mOutput.Length()),
mVideo.mWaitingForData, mVideo.mWaitingForKey,
mVideo.mLastStreamSourceID);
}
- aString += NS_ConvertUTF8toUTF16(result);
+ aString += result;
}
void
MediaFormatReader::SetVideoBlankDecode(bool aIsBlankDecode)
{
MOZ_ASSERT(OnTaskQueue());
return SetBlankDecode(TrackType::kVideoTrack, aIsBlankDecode);
}
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -71,17 +71,17 @@ public:
{
return mTrackDemuxersMayBlock;
}
void SetCDMProxy(CDMProxy* aProxy) override;
// Returns a string describing the state of the decoder data.
// Used for debugging purposes.
- void GetMozDebugReaderData(nsAString& aString);
+ void GetMozDebugReaderData(nsACString& aString);
void SetVideoBlankDecode(bool aIsBlankDecode) override;
private:
nsresult InitInternal() override;
bool HasVideo() const { return mVideo.mTrackDemuxer; }
bool HasAudio() const { return mAudio.mTrackDemuxer; }
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -277,16 +277,16 @@ MP4Decoder::IsVideoAccelerated(layers::K
taskQueue->AwaitShutdownAndIdle();
promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to initialize H264 decoder"));
});
return promise.forget();
}
void
-MP4Decoder::GetMozDebugReaderData(nsAString& aString)
+MP4Decoder::GetMozDebugReaderData(nsACString& aString)
{
if (mReader) {
mReader->GetMozDebugReaderData(aString);
}
}
} // namespace mozilla
--- a/dom/media/fmp4/MP4Decoder.h
+++ b/dom/media/fmp4/MP4Decoder.h
@@ -47,17 +47,17 @@ public:
static bool IsAAC(const nsACString& aMimeType);
// Returns true if the MP4 backend is preffed on.
static bool IsEnabled();
static already_AddRefed<dom::Promise>
IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsIGlobalObject* aParent);
- void GetMozDebugReaderData(nsAString& aString) override;
+ void GetMozDebugReaderData(nsACString& aString) override;
private:
RefPtr<MediaFormatReader> mReader;
};
} // namespace mozilla
#endif
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -552,17 +552,19 @@ MediaSource::DurationChange(double aNewD
// 5. Update the media duration to new duration and run the HTMLMediaElement
// duration change algorithm.
mDecoder->SetMediaSourceDuration(aNewDuration);
}
void
MediaSource::GetMozDebugReaderData(nsAString& aString)
{
- mDecoder->GetMozDebugReaderData(aString);
+ nsAutoCString result;
+ mDecoder->GetMozDebugReaderData(result);
+ aString = NS_ConvertUTF8toUTF16(result);
}
nsPIDOMWindowInner*
MediaSource::GetParentObject() const
{
return GetOwner();
}
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -244,17 +244,17 @@ MediaSourceDecoder::SetMediaSourceDurati
}
SetExplicitDuration(aDuration);
} else {
SetExplicitDuration(PositiveInfinity<double>());
}
}
void
-MediaSourceDecoder::GetMozDebugReaderData(nsAString& aString)
+MediaSourceDecoder::GetMozDebugReaderData(nsACString& aString)
{
if (mReader && mDemuxer) {
mReader->GetMozDebugReaderData(aString);
mDemuxer->GetMozDebugReaderData(aString);
}
}
double
--- a/dom/media/mediasource/MediaSourceDecoder.h
+++ b/dom/media/mediasource/MediaSourceDecoder.h
@@ -60,17 +60,17 @@ public:
MediaSourceDemuxer* GetDemuxer()
{
return mDemuxer;
}
// Returns a string describing the state of the MediaSource internal
// buffered data. Used for debugging purposes.
- void GetMozDebugReaderData(nsAString& aString) override;
+ void GetMozDebugReaderData(nsACString& aString) override;
void AddSizeOfResources(ResourceSizes* aSizes) override;
MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus() override;
bool CanPlayThrough() override;
void NotifyWaitingForKey() override;
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -241,17 +241,17 @@ MediaSourceDemuxer::GetManager(TrackType
}
MediaSourceDemuxer::~MediaSourceDemuxer()
{
mInitPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
}
void
-MediaSourceDemuxer::GetMozDebugReaderData(nsAString& aString)
+MediaSourceDemuxer::GetMozDebugReaderData(nsACString& aString)
{
MonitorAutoLock mon(mMonitor);
nsAutoCString result;
result += nsPrintfCString("Dumping data for demuxer %p:\n", this);
if (mAudioTrack) {
result += nsPrintfCString("\tDumping Audio Track Buffer(%s): - mLastAudioTime: %f\n"
"\t\tNumSamples:%u Size:%u Evictable:%u NextGetSampleIndex:%u NextInsertionIndex:%d\n",
mAudioTrack->mAudioTracks.mInfo->mMimeType.get(),
@@ -274,17 +274,17 @@ MediaSourceDemuxer::GetMozDebugReaderDat
mVideoTrack->mVideoTracks.mSizeBuffer,
mVideoTrack->Evictable(TrackInfo::kVideoTrack),
mVideoTrack->mVideoTracks.mNextGetSampleIndex.valueOr(-1),
mVideoTrack->mVideoTracks.mNextInsertionIndex.valueOr(-1));
result += nsPrintfCString("\t\tBuffered: ranges=%s\n",
DumpTimeRanges(mVideoTrack->SafeBuffered(TrackInfo::kVideoTrack)).get());
}
- aString += NS_ConvertUTF8toUTF16(result);
+ aString += result;
}
MediaSourceTrackDemuxer::MediaSourceTrackDemuxer(MediaSourceDemuxer* aParent,
TrackInfo::TrackType aType,
TrackBuffersManager* aManager)
: mParent(aParent)
, mManager(aManager)
, mType(aType)
--- a/dom/media/mediasource/MediaSourceDemuxer.h
+++ b/dom/media/mediasource/MediaSourceDemuxer.h
@@ -47,17 +47,17 @@ public:
/* interface for TrackBuffersManager */
void AttachSourceBuffer(TrackBuffersManager* aSourceBuffer);
void DetachSourceBuffer(TrackBuffersManager* aSourceBuffer);
AutoTaskQueue* GetTaskQueue() { return mTaskQueue; }
// Returns a string describing the state of the MediaSource internal
// buffered data. Used for debugging purposes.
- void GetMozDebugReaderData(nsAString& aString);
+ void GetMozDebugReaderData(nsACString& aString);
void AddSizeOfResources(MediaSourceDecoder::ResourceSizes* aSizes);
// Gap allowed between frames.
static const media::TimeUnit EOS_FUZZ;
private:
~MediaSourceDemuxer();
--- a/dom/media/webm/WebMDecoder.cpp
+++ b/dom/media/webm/WebMDecoder.cpp
@@ -53,17 +53,17 @@ WebMDecoder::IsSupportedType(const Media
}
// Some unsupported codec.
return false;
}
return true;
}
void
-WebMDecoder::GetMozDebugReaderData(nsAString& aString)
+WebMDecoder::GetMozDebugReaderData(nsACString& aString)
{
if (mReader) {
mReader->GetMozDebugReaderData(aString);
}
}
} // namespace mozilla
--- a/dom/media/webm/WebMDecoder.h
+++ b/dom/media/webm/WebMDecoder.h
@@ -25,17 +25,17 @@ public:
}
MediaDecoderStateMachine* CreateStateMachine() override;
// Returns true if aContainerType is a WebM type that we think we can render
// with an enabled platform decoder backend.
// If provided, codecs are checked for support.
static bool IsSupportedType(const MediaContainerType& aContainerType);
- void GetMozDebugReaderData(nsAString& aString) override;
+ void GetMozDebugReaderData(nsACString& aString) override;
private:
RefPtr<MediaFormatReader> mReader;
};
} // namespace mozilla
#endif