@@ -81,9 +81,12 @@ namespace RTC
8181 * Update the buffer length of the Serializable.
8282 **
8383 * @remarks
84- * The child class must invoke this method after parsing completes in case
85- * it couldn't anticipate its expected exact length. Specially useful when
86- * parsing variable-length items within a packet.
84+ * - The child class must invoke this method after parsing completes in
85+ * case it couldn't anticipate its expected exact length. Specially
86+ * useful when parsing variable-length items within a packet.
87+ * - The application can also invoke this method on the Serializable if
88+ * it has expanded or reduced the length of the buffer currently assigned
89+ * to the Serializable.
8790 *
8891 * @throw MediaSoupError - If given `bufferLength` is lower than the
8992 * current exact length of the Serializable.
@@ -100,7 +103,8 @@ namespace RTC
100103 *
101104 * @remarks
102105 * - Subclasses must override this method if they hold pointers or allocated
103- * memory.
106+ * memory. In that case, the subclass should manually invoke `SetBuffer()`
107+ * and `SetBufferLenght()` methods.
104108 * - Anyway, if subclasses override this method they still need to invoke
105109 * it in the parent too.
106110 *
@@ -109,14 +113,28 @@ namespace RTC
109113 */
110114 virtual void Serialize (const uint8_t * buffer, size_t bufferLength);
111115
116+ /* *
117+ * TODO
118+ */
119+ // virtual std::unique_ptr<Serializable> Clone(const uint8_t* buffer, size_t bufferLength) const;
120+
112121 /* *
113122 * Methods to be used by classes inheriting from Serializable.
114123 */
115124 protected:
125+ /* *
126+ * Method to be called by the child class in case it overrides the
127+ * `Serialize()` method.
128+ */
129+ virtual void SetBuffer (const uint8_t * buffer) final
130+ {
131+ this ->buffer = const_cast <uint8_t *>(buffer);
132+ }
133+
116134 /* *
117135 * Method to be called by the child class to update the current exact
118136 * length of the Serializable.
119- **
137+ *
120138 * @remarks
121139 * The child class must invoke this method after parsing completes and
122140 * after every change in the Serializable content that affects its current
0 commit comments