Skip to content

Commit

Permalink
[MSE] Bring back some useful SourceBuffer logs
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=247122

Follow up patch for https://commits.webkit.org/256224@main, this time applying
Jer Noble's suggestions to use StringConcatenation instead of a printf-like
syntax.

Reviewed by Jer Noble.

* Source/WebCore/Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::appendBufferInternal): Use string concatenation.
(WebCore::SourceBuffer::sourceBufferPrivateAppendComplete): Ditto.
* Source/WebCore/platform/graphics/PlatformTimeRanges.cpp:
(WebCore::PlatformTimeRanges::toString const): Added String conversion method.
* Source/WebCore/platform/graphics/PlatformTimeRanges.h:
(WTF::LogArgument<PlatformTimeRanges>::toString): Ditto.

Canonical link: https://commits.webkit.org/256317@main
  • Loading branch information
eocanha committed Nov 4, 2022
1 parent 7fecf96 commit 4456698
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Expand Up @@ -493,9 +493,7 @@ ExceptionOr<void> SourceBuffer::appendBufferInternal(const unsigned char* data,
if (isRemoved() || m_updating)
return Exception { InvalidStateError };

StringPrintStream message;
message.printf("SourceBuffer::appendBufferInternal(%p) - append size = %u, buffered = %s\n", this, size, toString(m_private->buffered()->ranges()).utf8().data());
DEBUG_LOG(LOGIDENTIFIER, message.toString());
DEBUG_LOG(LOGIDENTIFIER, "size = ", size, ", buffered = ", m_private->buffered()->ranges());

// 3. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
// 3.1. Set the readyState attribute of the parent media source to "open"
Expand Down Expand Up @@ -592,9 +590,7 @@ void SourceBuffer::sourceBufferPrivateAppendComplete(AppendResult result)
m_source->monitorSourceBuffers();
m_private->reenqueueMediaIfNeeded(m_source->currentTime());

StringPrintStream message;
message.printf("SourceBuffer::sourceBufferPrivateAppendComplete(%p) - buffered = %s", this, toString(m_private->buffered()->ranges()).utf8().data());
DEBUG_LOG(LOGIDENTIFIER, message.toString());
DEBUG_LOG(LOGIDENTIFIER, "buffered = ", m_private->buffered()->ranges());
}

void SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(int64_t error)
Expand Down
11 changes: 11 additions & 0 deletions Source/WebCore/platform/graphics/PlatformTimeRanges.cpp
Expand Up @@ -28,6 +28,7 @@

#include <math.h>
#include <wtf/PrintStream.h>
#include <wtf/text/StringBuilder.h>

namespace WebCore {

Expand Down Expand Up @@ -279,4 +280,14 @@ void PlatformTimeRanges::dump(PrintStream& out) const
out.print("[", start(i), "..", end(i), "] ");
}

String PlatformTimeRanges::toString() const
{
StringBuilder result;

for (size_t i = 0; i < length(); ++i)
result.append("[", start(i).toString(), "..", end(i).toString(), "] ");

return result.toString();
}

}
10 changes: 10 additions & 0 deletions Source/WebCore/platform/graphics/PlatformTimeRanges.h
Expand Up @@ -70,6 +70,7 @@ class WEBCORE_EXPORT PlatformTimeRanges {
MediaTime totalDuration() const;

void dump(PrintStream&) const;
String toString() const;

template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<PlatformTimeRanges> decode(Decoder&);
Expand Down Expand Up @@ -165,4 +166,13 @@ std::optional<PlatformTimeRanges> PlatformTimeRanges::decode(Decoder& decoder)

} // namespace WebCore

namespace WTF {
template<typename> struct LogArgument;

template<> struct LogArgument<WebCore::PlatformTimeRanges> {
static String toString(const WebCore::PlatformTimeRanges& platformTimeRanges) { return platformTimeRanges.toString(); }
};

} // namespace WTF

#endif

0 comments on commit 4456698

Please sign in to comment.