- Revision
- 231382
- Author
- [email protected]
- Date
- 2018-05-04 14:39:24 -0700 (Fri, 04 May 2018)
Log Message
Log media time range as JSON
https://bugs.webkit.org/show_bug.cgi?id=185321
<rdar://problem/39986746>
Reviewed by Youenn Fablet.
Source/WebCore:
No new tests, tested manually.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::addPlayedRange): Log as time range.
(WebCore::HTMLMediaElement::visibilityStateChanged): Cleanup.
* platform/graphics/MediaPlayer.h:
(WTF::LogArgument<MediaTime>::toString):
(WTF::LogArgument<MediaTimeRange>::toString):
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processAttributedStrings): Log error as time range.
Source/WTF:
* wtf/MediaTime.cpp:
(WTF::toJSONStringInternal): Extract guts of MediaTime::toJSONString to this static function
so it can be used by MediaTimeRange::toJSONString as well.
(WTF::MediaTime::toJSONString const):
(WTF::MediaTimeRange::toJSONString const):
* wtf/MediaTime.h:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (231381 => 231382)
--- trunk/Source/WTF/ChangeLog 2018-05-04 21:26:09 UTC (rev 231381)
+++ trunk/Source/WTF/ChangeLog 2018-05-04 21:39:24 UTC (rev 231382)
@@ -1,3 +1,18 @@
+2018-05-04 Eric Carlson <[email protected]>
+
+ Log media time range as JSON
+ https://bugs.webkit.org/show_bug.cgi?id=185321
+ <rdar://problem/39986746>
+
+ Reviewed by Youenn Fablet.
+
+ * wtf/MediaTime.cpp:
+ (WTF::toJSONStringInternal): Extract guts of MediaTime::toJSONString to this static function
+ so it can be used by MediaTimeRange::toJSONString as well.
+ (WTF::MediaTime::toJSONString const):
+ (WTF::MediaTimeRange::toJSONString const):
+ * wtf/MediaTime.h:
+
2018-05-04 Antti Koivisto <[email protected]>
OptionsSet initializer list constructor should be constexpr
Modified: trunk/Source/WTF/wtf/MediaTime.cpp (231381 => 231382)
--- trunk/Source/WTF/wtf/MediaTime.cpp 2018-05-04 21:26:09 UTC (rev 231381)
+++ trunk/Source/WTF/wtf/MediaTime.cpp 2018-05-04 21:39:24 UTC (rev 231382)
@@ -577,30 +577,35 @@
return builder.toString();
}
-String MediaTime::toJSONString() const
+static Ref<JSON::Object> toJSONStringInternal(const MediaTime& time)
{
auto object = JSON::Object::create();
- if (hasDoubleValue())
- object->setDouble(ASCIILiteral("value"), toDouble());
+ if (time.hasDoubleValue())
+ object->setDouble(ASCIILiteral("value"), time.toDouble());
else {
- if (isInvalid() || isIndefinite())
+ if (time.isInvalid() || time.isIndefinite())
object->setString(ASCIILiteral("value"), ASCIILiteral("NaN"));
- else if (isPositiveInfinite())
+ else if (time.isPositiveInfinite())
object->setString(ASCIILiteral("value"), ASCIILiteral("POSITIVE_INFINITY"));
- else if (isNegativeInfinite())
+ else if (time.isNegativeInfinite())
object->setString(ASCIILiteral("value"), ASCIILiteral("NEGATIVE_INFINITY"));
else
- object->setDouble(ASCIILiteral("value"), toDouble());
+ object->setDouble(ASCIILiteral("value"), time.toDouble());
- object->setInteger(ASCIILiteral("numerator"), static_cast<int>(m_timeValue));
- object->setInteger(ASCIILiteral("denominator"), m_timeScale);
- object->setInteger(ASCIILiteral("flags"), m_timeFlags);
+ object->setInteger(ASCIILiteral("numerator"), static_cast<int>(time.timeValue()));
+ object->setInteger(ASCIILiteral("denominator"), time.timeScale());
+ object->setInteger(ASCIILiteral("flags"), time.timeFlags());
}
- return object->toJSONString();
+ return object;
}
+String MediaTime::toJSONString() const
+{
+ return toJSONStringInternal(*this)->toJSONString();
+}
+
MediaTime abs(const MediaTime& rhs)
{
if (rhs.isInvalid())
@@ -615,5 +620,14 @@
return val;
}
+String MediaTimeRange::toJSONString() const
+{
+ auto object = JSON::Object::create();
+
+ object->setObject(ASCIILiteral("start"), toJSONStringInternal(start));
+ object->setObject(ASCIILiteral("end"), toJSONStringInternal(end));
+
+ return object->toJSONString();
}
+}
Modified: trunk/Source/WTF/wtf/MediaTime.h (231381 => 231382)
--- trunk/Source/WTF/wtf/MediaTime.h 2018-05-04 21:26:09 UTC (rev 231381)
+++ trunk/Source/WTF/wtf/MediaTime.h 2018-05-04 21:39:24 UTC (rev 231382)
@@ -98,6 +98,7 @@
bool isNegativeInfinite() const { return m_timeFlags & NegativeInfinite; }
bool isIndefinite() const { return m_timeFlags & Indefinite; }
bool hasDoubleValue() const { return m_timeFlags & DoubleValue; }
+ uint8_t timeFlags() const { return m_timeFlags; }
static const MediaTime& zeroTime();
static const MediaTime& invalidTime();
@@ -151,6 +152,13 @@
WTF_EXPORT_PRIVATE extern MediaTime abs(const MediaTime& rhs);
+struct WTF_EXPORT_PRIVATE MediaTimeRange {
+ String toJSONString() const;
+
+ const MediaTime start;
+ const MediaTime end;
+};
+
template<class Encoder>
void MediaTime::encode(Encoder& encoder) const
{
@@ -168,6 +176,7 @@
}
using WTF::MediaTime;
+using WTF::MediaTimeRange;
using WTF::abs;
#endif
Modified: trunk/Source/WebCore/ChangeLog (231381 => 231382)
--- trunk/Source/WebCore/ChangeLog 2018-05-04 21:26:09 UTC (rev 231381)
+++ trunk/Source/WebCore/ChangeLog 2018-05-04 21:39:24 UTC (rev 231382)
@@ -1,3 +1,24 @@
+2018-05-04 Eric Carlson <[email protected]>
+
+ Log media time range as JSON
+ https://bugs.webkit.org/show_bug.cgi?id=185321
+ <rdar://problem/39986746>
+
+ Reviewed by Youenn Fablet.
+
+ No new tests, tested manually.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::addPlayedRange): Log as time range.
+ (WebCore::HTMLMediaElement::visibilityStateChanged): Cleanup.
+
+ * platform/graphics/MediaPlayer.h:
+ (WTF::LogArgument<MediaTime>::toString):
+ (WTF::LogArgument<MediaTimeRange>::toString):
+
+ * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+ (WebCore::InbandTextTrackPrivateAVF::processAttributedStrings): Log error as time range.
+
2018-05-04 Zalan Bujtas <[email protected]>
Use the containing block to compute the pagination gap when the container is inline.
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (231381 => 231382)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2018-05-04 21:26:09 UTC (rev 231381)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2018-05-04 21:39:24 UTC (rev 231382)
@@ -2842,7 +2842,7 @@
void HTMLMediaElement::addPlayedRange(const MediaTime& start, const MediaTime& end)
{
- DEBUG_LOG(LOGIDENTIFIER, "[", start, ", ", end, "]");
+ DEBUG_LOG(LOGIDENTIFIER, MediaTimeRange { start, end });
if (!m_playedTimeRanges)
m_playedTimeRanges = TimeRanges::create();
m_playedTimeRanges->ranges().add(start, end);
@@ -5633,10 +5633,10 @@
bool isPlayingAudio = isPlaying() && hasAudio() && !muted() && volume();
if (!isPlayingAudio) {
if (m_elementIsHidden) {
- ALWAYS_LOG(LOGIDENTIFIER, "visibilityStateChanged() Suspending playback after going to the background");
+ ALWAYS_LOG(LOGIDENTIFIER, "Suspending playback after going to the background");
m_mediaSession->beginInterruption(PlatformMediaSession::EnteringBackground);
} else {
- ALWAYS_LOG(LOGIDENTIFIER, "visibilityStateChanged() Resuming playback after entering foreground");
+ ALWAYS_LOG(LOGIDENTIFIER, "Resuming playback after entering foreground");
m_mediaSession->endInterruption(PlatformMediaSession::MayResumePlaying);
}
}
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (231381 => 231382)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2018-05-04 21:26:09 UTC (rev 231381)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2018-05-04 21:39:24 UTC (rev 231382)
@@ -694,9 +694,18 @@
struct LogArgument<MediaTime> {
static String toString(const MediaTime& time)
{
- return time.toString();
+ return time.toJSONString();
}
};
+
+template <>
+struct LogArgument<MediaTimeRange> {
+ static String toString(const MediaTimeRange& range)
+ {
+ return range.toJSONString();
+ }
+};
+
}
#endif // ENABLE(VIDEO)
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (231381 => 231382)
--- trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp 2018-05-04 21:26:09 UTC (rev 231381)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp 2018-05-04 21:39:24 UTC (rev 231382)
@@ -383,7 +383,7 @@
}
}
} else
- ERROR_LOG(LOGIDENTIFIER, "negative length cue(s): start ", m_currentCueStartTime, ", end ", m_currentCueEndTime);
+ ERROR_LOG(LOGIDENTIFIER, "negative length cue(s): ", MediaTimeRange { m_currentCueStartTime, m_currentCueEndTime });
removeCompletedCues();
}