+{
+ if (encoding == Stream::STREAM_ENCODING_RAW) {
+ add_data_raw(data, bytes);
+ } else if (encoding == STREAM_ENCODING_METACUBE) {
+ metacube_block_header hdr;
+ memcpy(hdr.sync, METACUBE_SYNC, sizeof(hdr.sync));
+ hdr.size = htonl(bytes);
+ hdr.flags = htonl(0);
+
+ char *block = new char[bytes + sizeof(hdr)];
+ memcpy(block, &hdr, sizeof(hdr));
+ memcpy(block + sizeof(hdr), data, bytes);
+ add_data_raw(block, bytes + sizeof(hdr));
+ delete[] block;
+ } else {
+ assert(false);
+ }
+}
+
+void Stream::add_data_raw(const char *data, ssize_t bytes)