Make the MediaSample::toJSONString method generic
authorphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Mar 2020 14:25:09 +0000 (14:25 +0000)
committerphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Mar 2020 14:25:09 +0000 (14:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209287

Reviewed by Eric Carlson.

It is generic and thus can be shared to sub-classes.

* platform/MediaSample.h:
(WebCore::MediaSample::toJSONString const):
* platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258807 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/MediaSample.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm

index eb49197..18ffe11 100644 (file)
@@ -1,3 +1,17 @@
+2020-03-21  Philippe Normand  <pnormand@igalia.com>
+
+        Make the MediaSample::toJSONString method generic
+        https://bugs.webkit.org/show_bug.cgi?id=209287
+
+        Reviewed by Eric Carlson.
+
+        It is generic and thus can be shared to sub-classes.
+
+        * platform/MediaSample.h:
+        (WebCore::MediaSample::toJSONString const):
+        * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
+
 2020-03-21  Zalan Bujtas  <zalan@apple.com>
 
         telerik.com: Placeholder text is misaligned in search text box
index 7fc9de1..1e44279 100644 (file)
@@ -98,7 +98,18 @@ public:
     bool hasAlpha() const { return flags() & HasAlpha; }
 
     virtual void dump(PrintStream&) const = 0;
-    virtual String toJSONString() const { return { }; }
+    String toJSONString() const
+    {
+        auto object = JSON::Object::create();
+
+        object->setObject("pts"_s, presentationTime().toJSONObject());
+        object->setObject("dts"_s, decodeTime().toJSONObject());
+        object->setObject("duration"_s, duration().toJSONObject());
+        object->setInteger("flags"_s, static_cast<unsigned>(flags()));
+        object->setObject("presentationSize"_s, presentationSize().toJSONObject());
+
+        return object->toJSONString();
+    }
 };
 
 } // namespace WebCore
index 2436268..2119048 100644 (file)
@@ -68,8 +68,6 @@ public:
 
     CMSampleBufferRef sampleBuffer() const { return m_sample.get(); }
 
-    String toJSONString() const override;
-
 protected:
     MediaSampleAVFObjC(RetainPtr<CMSampleBufferRef>&& sample)
         : m_sample(WTFMove(sample))
index 530879d..e6f38f7 100644 (file)
@@ -316,17 +316,4 @@ void MediaSampleAVFObjC::setAsDisplayImmediately(MediaSample& sample)
     }
 }
 
-String MediaSampleAVFObjC::toJSONString() const
-{
-    auto object = JSON::Object::create();
-
-    object->setObject("pts"_s, presentationTime().toJSONObject());
-    object->setObject("dts"_s, decodeTime().toJSONObject());
-    object->setObject("duration"_s, duration().toJSONObject());
-    object->setInteger("flags"_s, static_cast<unsigned>(flags()));
-    object->setObject("presentationSize"_s, presentationSize().toJSONObject());
-
-    return object->toJSONString();
-}
-
 }