You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

602 lines
20KB

  1. /*
  2. * Live HDS fragmenter
  3. * Copyright (c) 2013 Martin Storsjo
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "config.h"
  22. #include <float.h>
  23. #if HAVE_UNISTD_H
  24. #include <unistd.h>
  25. #endif
  26. #include "avformat.h"
  27. #include "internal.h"
  28. #include "os_support.h"
  29. #include "libavutil/avstring.h"
  30. #include "libavutil/base64.h"
  31. #include "libavutil/intreadwrite.h"
  32. #include "libavutil/mathematics.h"
  33. #include "libavutil/opt.h"
  34. typedef struct Fragment {
  35. char file[1024];
  36. int64_t start_time, duration;
  37. int n;
  38. } Fragment;
  39. typedef struct OutputStream {
  40. int bitrate;
  41. int first_stream;
  42. AVFormatContext *ctx;
  43. int ctx_inited;
  44. uint8_t iobuf[32768];
  45. char temp_filename[1024];
  46. int64_t frag_start_ts, last_ts;
  47. AVIOContext *out;
  48. int packets_written;
  49. int nb_fragments, fragments_size, fragment_index;
  50. Fragment **fragments;
  51. int has_audio, has_video;
  52. uint8_t *metadata;
  53. int metadata_size;
  54. uint8_t *extra_packets[2];
  55. int extra_packet_sizes[2];
  56. int nb_extra_packets;
  57. } OutputStream;
  58. typedef struct HDSContext {
  59. const AVClass *class; /* Class for private options. */
  60. int window_size;
  61. int extra_window_size;
  62. int min_frag_duration;
  63. int remove_at_exit;
  64. OutputStream *streams;
  65. int nb_streams;
  66. } HDSContext;
  67. static int parse_header(OutputStream *os, const uint8_t *buf, int buf_size)
  68. {
  69. if (buf_size < 13)
  70. return AVERROR_INVALIDDATA;
  71. if (memcmp(buf, "FLV", 3))
  72. return AVERROR_INVALIDDATA;
  73. buf += 13;
  74. buf_size -= 13;
  75. while (buf_size >= 11 + 4) {
  76. int type = buf[0];
  77. int size = AV_RB24(&buf[1]) + 11 + 4;
  78. if (size > buf_size)
  79. return AVERROR_INVALIDDATA;
  80. if (type == 8 || type == 9) {
  81. if (os->nb_extra_packets >= FF_ARRAY_ELEMS(os->extra_packets))
  82. return AVERROR_INVALIDDATA;
  83. os->extra_packet_sizes[os->nb_extra_packets] = size;
  84. os->extra_packets[os->nb_extra_packets] = av_malloc(size);
  85. if (!os->extra_packets[os->nb_extra_packets])
  86. return AVERROR(ENOMEM);
  87. memcpy(os->extra_packets[os->nb_extra_packets], buf, size);
  88. os->nb_extra_packets++;
  89. } else if (type == 0x12) {
  90. if (os->metadata)
  91. return AVERROR_INVALIDDATA;
  92. os->metadata_size = size - 11 - 4;
  93. os->metadata = av_malloc(os->metadata_size);
  94. if (!os->metadata)
  95. return AVERROR(ENOMEM);
  96. memcpy(os->metadata, buf + 11, os->metadata_size);
  97. }
  98. buf += size;
  99. buf_size -= size;
  100. }
  101. if (!os->metadata)
  102. return AVERROR_INVALIDDATA;
  103. return 0;
  104. }
  105. static int hds_write(void *opaque, uint8_t *buf, int buf_size)
  106. {
  107. OutputStream *os = opaque;
  108. if (os->out) {
  109. avio_write(os->out, buf, buf_size);
  110. } else {
  111. if (!os->metadata_size) {
  112. int ret;
  113. // Assuming the IO buffer is large enough to fit the
  114. // FLV header and all metadata and extradata packets
  115. if ((ret = parse_header(os, buf, buf_size)) < 0)
  116. return ret;
  117. }
  118. }
  119. return buf_size;
  120. }
  121. static void hds_free(AVFormatContext *s)
  122. {
  123. HDSContext *c = s->priv_data;
  124. int i, j;
  125. if (!c->streams)
  126. return;
  127. for (i = 0; i < s->nb_streams; i++) {
  128. OutputStream *os = &c->streams[i];
  129. if (os->out)
  130. avio_close(os->out);
  131. os->out = NULL;
  132. if (os->ctx && os->ctx_inited)
  133. av_write_trailer(os->ctx);
  134. if (os->ctx && os->ctx->pb)
  135. av_free(os->ctx->pb);
  136. if (os->ctx)
  137. avformat_free_context(os->ctx);
  138. av_free(os->metadata);
  139. for (j = 0; j < os->nb_extra_packets; j++)
  140. av_free(os->extra_packets[j]);
  141. for (j = 0; j < os->nb_fragments; j++)
  142. av_free(os->fragments[j]);
  143. av_free(os->fragments);
  144. }
  145. av_freep(&c->streams);
  146. }
  147. static int write_manifest(AVFormatContext *s, int final)
  148. {
  149. HDSContext *c = s->priv_data;
  150. AVIOContext *out;
  151. char filename[1024], temp_filename[1024];
  152. const char *write_filename;
  153. int ret, i;
  154. float duration = 0;
  155. if (c->nb_streams > 0)
  156. duration = c->streams[0].last_ts * av_q2d(s->streams[0]->time_base);
  157. snprintf(filename, sizeof(filename), "%s/index.f4m", s->filename);
  158. snprintf(temp_filename, sizeof(temp_filename), "%s/index.f4m.tmp", s->filename);
  159. write_filename = USE_RENAME_REPLACE ? temp_filename : filename;
  160. ret = avio_open2(&out, write_filename, AVIO_FLAG_WRITE,
  161. &s->interrupt_callback, NULL);
  162. if (ret < 0) {
  163. av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", write_filename);
  164. return ret;
  165. }
  166. avio_printf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
  167. avio_printf(out, "<manifest xmlns=\"http://ns.adobe.com/f4m/1.0\">\n");
  168. avio_printf(out, "\t<id>%s</id>\n", av_basename(s->filename));
  169. avio_printf(out, "\t<streamType>%s</streamType>\n",
  170. final ? "recorded" : "live");
  171. avio_printf(out, "\t<deliveryType>streaming</deliveryType>\n");
  172. if (final)
  173. avio_printf(out, "\t<duration>%f</duration>\n", duration);
  174. for (i = 0; i < c->nb_streams; i++) {
  175. OutputStream *os = &c->streams[i];
  176. int b64_size = AV_BASE64_SIZE(os->metadata_size);
  177. char *base64 = av_malloc(b64_size);
  178. if (!base64) {
  179. avio_close(out);
  180. return AVERROR(ENOMEM);
  181. }
  182. av_base64_encode(base64, b64_size, os->metadata, os->metadata_size);
  183. avio_printf(out, "\t<bootstrapInfo profile=\"named\" url=\"stream%d.abst\" id=\"bootstrap%d\" />\n", i, i);
  184. avio_printf(out, "\t<media bitrate=\"%d\" url=\"stream%d\" bootstrapInfoId=\"bootstrap%d\">\n", os->bitrate/1000, i, i);
  185. avio_printf(out, "\t\t<metadata>%s</metadata>\n", base64);
  186. avio_printf(out, "\t</media>\n");
  187. av_free(base64);
  188. }
  189. avio_printf(out, "</manifest>\n");
  190. avio_flush(out);
  191. avio_close(out);
  192. return USE_RENAME_REPLACE ? ff_rename(temp_filename, filename, s) : 0;
  193. }
  194. static void update_size(AVIOContext *out, int64_t pos)
  195. {
  196. int64_t end = avio_tell(out);
  197. avio_seek(out, pos, SEEK_SET);
  198. avio_wb32(out, end - pos);
  199. avio_seek(out, end, SEEK_SET);
  200. }
  201. /* Note, the .abst files need to be served with the "binary/octet"
  202. * mime type, otherwise at least the OSMF player can easily fail
  203. * with "stream not found" when polling for the next fragment. */
  204. static int write_abst(AVFormatContext *s, OutputStream *os, int final)
  205. {
  206. HDSContext *c = s->priv_data;
  207. AVIOContext *out;
  208. char filename[1024], temp_filename[1024];
  209. const char *write_filename;
  210. int i, ret;
  211. int64_t asrt_pos, afrt_pos;
  212. int start = 0, fragments;
  213. int index = s->streams[os->first_stream]->id;
  214. int64_t cur_media_time = 0;
  215. if (c->window_size)
  216. start = FFMAX(os->nb_fragments - c->window_size, 0);
  217. fragments = os->nb_fragments - start;
  218. if (final)
  219. cur_media_time = os->last_ts;
  220. else if (os->nb_fragments)
  221. cur_media_time = os->fragments[os->nb_fragments - 1]->start_time;
  222. snprintf(filename, sizeof(filename),
  223. "%s/stream%d.abst", s->filename, index);
  224. snprintf(temp_filename, sizeof(temp_filename),
  225. "%s/stream%d.abst.tmp", s->filename, index);
  226. write_filename = USE_RENAME_REPLACE ? temp_filename : filename;
  227. ret = avio_open2(&out, write_filename, AVIO_FLAG_WRITE,
  228. &s->interrupt_callback, NULL);
  229. if (ret < 0) {
  230. av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", write_filename);
  231. return ret;
  232. }
  233. avio_wb32(out, 0); // abst size
  234. avio_wl32(out, MKTAG('a','b','s','t'));
  235. avio_wb32(out, 0); // version + flags
  236. avio_wb32(out, os->fragment_index - 1); // BootstrapinfoVersion
  237. avio_w8(out, final ? 0 : 0x20); // profile, live, update
  238. avio_wb32(out, 1000); // timescale
  239. avio_wb64(out, cur_media_time);
  240. avio_wb64(out, 0); // SmpteTimeCodeOffset
  241. avio_w8(out, 0); // MovieIdentifer (null string)
  242. avio_w8(out, 0); // ServerEntryCount
  243. avio_w8(out, 0); // QualityEntryCount
  244. avio_w8(out, 0); // DrmData (null string)
  245. avio_w8(out, 0); // MetaData (null string)
  246. avio_w8(out, 1); // SegmentRunTableCount
  247. asrt_pos = avio_tell(out);
  248. avio_wb32(out, 0); // asrt size
  249. avio_wl32(out, MKTAG('a','s','r','t'));
  250. avio_wb32(out, 0); // version + flags
  251. avio_w8(out, 0); // QualityEntryCount
  252. avio_wb32(out, 1); // SegmentRunEntryCount
  253. avio_wb32(out, 1); // FirstSegment
  254. avio_wb32(out, final ? (os->fragment_index - 1) : 0xffffffff); // FragmentsPerSegment
  255. update_size(out, asrt_pos);
  256. avio_w8(out, 1); // FragmentRunTableCount
  257. afrt_pos = avio_tell(out);
  258. avio_wb32(out, 0); // afrt size
  259. avio_wl32(out, MKTAG('a','f','r','t'));
  260. avio_wb32(out, 0); // version + flags
  261. avio_wb32(out, 1000); // timescale
  262. avio_w8(out, 0); // QualityEntryCount
  263. avio_wb32(out, fragments); // FragmentRunEntryCount
  264. for (i = start; i < os->nb_fragments; i++) {
  265. avio_wb32(out, os->fragments[i]->n);
  266. avio_wb64(out, os->fragments[i]->start_time);
  267. avio_wb32(out, os->fragments[i]->duration);
  268. }
  269. update_size(out, afrt_pos);
  270. update_size(out, 0);
  271. avio_close(out);
  272. return USE_RENAME_REPLACE ? ff_rename(temp_filename, filename, s) : 0;
  273. }
  274. static int init_file(AVFormatContext *s, OutputStream *os, int64_t start_ts)
  275. {
  276. int ret, i;
  277. ret = avio_open2(&os->out, os->temp_filename, AVIO_FLAG_WRITE,
  278. &s->interrupt_callback, NULL);
  279. if (ret < 0)
  280. return ret;
  281. avio_wb32(os->out, 0);
  282. avio_wl32(os->out, MKTAG('m','d','a','t'));
  283. for (i = 0; i < os->nb_extra_packets; i++) {
  284. AV_WB24(os->extra_packets[i] + 4, start_ts);
  285. os->extra_packets[i][7] = (start_ts >> 24) & 0x7f;
  286. avio_write(os->out, os->extra_packets[i], os->extra_packet_sizes[i]);
  287. }
  288. return 0;
  289. }
  290. static void close_file(OutputStream *os)
  291. {
  292. int64_t pos = avio_tell(os->out);
  293. avio_seek(os->out, 0, SEEK_SET);
  294. avio_wb32(os->out, pos);
  295. avio_flush(os->out);
  296. avio_close(os->out);
  297. os->out = NULL;
  298. }
  299. static int hds_write_header(AVFormatContext *s)
  300. {
  301. HDSContext *c = s->priv_data;
  302. int ret = 0, i;
  303. AVOutputFormat *oformat;
  304. if (mkdir(s->filename, 0777) == -1 && errno != EEXIST) {
  305. ret = AVERROR(errno);
  306. av_log(s, AV_LOG_ERROR , "Failed to create directory %s\n", s->filename);
  307. goto fail;
  308. }
  309. oformat = av_guess_format("flv", NULL, NULL);
  310. if (!oformat) {
  311. ret = AVERROR_MUXER_NOT_FOUND;
  312. goto fail;
  313. }
  314. c->streams = av_mallocz_array(s->nb_streams, sizeof(*c->streams));
  315. if (!c->streams) {
  316. ret = AVERROR(ENOMEM);
  317. goto fail;
  318. }
  319. for (i = 0; i < s->nb_streams; i++) {
  320. OutputStream *os = &c->streams[c->nb_streams];
  321. AVFormatContext *ctx;
  322. AVStream *st = s->streams[i];
  323. if (!st->codec->bit_rate) {
  324. av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i);
  325. ret = AVERROR(EINVAL);
  326. goto fail;
  327. }
  328. if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
  329. if (os->has_video) {
  330. c->nb_streams++;
  331. os++;
  332. }
  333. os->has_video = 1;
  334. } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
  335. if (os->has_audio) {
  336. c->nb_streams++;
  337. os++;
  338. }
  339. os->has_audio = 1;
  340. } else {
  341. av_log(s, AV_LOG_ERROR, "Unsupported stream type in stream %d\n", i);
  342. ret = AVERROR(EINVAL);
  343. goto fail;
  344. }
  345. os->bitrate += s->streams[i]->codec->bit_rate;
  346. if (!os->ctx) {
  347. os->first_stream = i;
  348. ctx = avformat_alloc_context();
  349. if (!ctx) {
  350. ret = AVERROR(ENOMEM);
  351. goto fail;
  352. }
  353. os->ctx = ctx;
  354. ctx->oformat = oformat;
  355. ctx->interrupt_callback = s->interrupt_callback;
  356. ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf),
  357. AVIO_FLAG_WRITE, os,
  358. NULL, hds_write, NULL);
  359. if (!ctx->pb) {
  360. ret = AVERROR(ENOMEM);
  361. goto fail;
  362. }
  363. } else {
  364. ctx = os->ctx;
  365. }
  366. s->streams[i]->id = c->nb_streams;
  367. if (!(st = avformat_new_stream(ctx, NULL))) {
  368. ret = AVERROR(ENOMEM);
  369. goto fail;
  370. }
  371. avcodec_copy_context(st->codec, s->streams[i]->codec);
  372. st->codec->codec_tag = 0;
  373. st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
  374. st->time_base = s->streams[i]->time_base;
  375. }
  376. if (c->streams[c->nb_streams].ctx)
  377. c->nb_streams++;
  378. for (i = 0; i < c->nb_streams; i++) {
  379. OutputStream *os = &c->streams[i];
  380. int j;
  381. if ((ret = avformat_write_header(os->ctx, NULL)) < 0) {
  382. goto fail;
  383. }
  384. os->ctx_inited = 1;
  385. avio_flush(os->ctx->pb);
  386. for (j = 0; j < os->ctx->nb_streams; j++)
  387. s->streams[os->first_stream + j]->time_base = os->ctx->streams[j]->time_base;
  388. snprintf(os->temp_filename, sizeof(os->temp_filename),
  389. "%s/stream%d_temp", s->filename, i);
  390. ret = init_file(s, os, 0);
  391. if (ret < 0)
  392. goto fail;
  393. if (!os->has_video && c->min_frag_duration <= 0) {
  394. av_log(s, AV_LOG_WARNING,
  395. "No video stream in output stream %d and no min frag duration set\n", i);
  396. ret = AVERROR(EINVAL);
  397. }
  398. os->fragment_index = 1;
  399. write_abst(s, os, 0);
  400. }
  401. ret = write_manifest(s, 0);
  402. fail:
  403. if (ret)
  404. hds_free(s);
  405. return ret;
  406. }
  407. static int add_fragment(OutputStream *os, const char *file,
  408. int64_t start_time, int64_t duration)
  409. {
  410. Fragment *frag;
  411. if (duration == 0)
  412. duration = 1;
  413. if (os->nb_fragments >= os->fragments_size) {
  414. int ret;
  415. os->fragments_size = (os->fragments_size + 1) * 2;
  416. if ((ret = av_reallocp_array(&os->fragments, os->fragments_size,
  417. sizeof(*os->fragments))) < 0) {
  418. os->fragments_size = 0;
  419. os->nb_fragments = 0;
  420. return ret;
  421. }
  422. }
  423. frag = av_mallocz(sizeof(*frag));
  424. if (!frag)
  425. return AVERROR(ENOMEM);
  426. av_strlcpy(frag->file, file, sizeof(frag->file));
  427. frag->start_time = start_time;
  428. frag->duration = duration;
  429. frag->n = os->fragment_index;
  430. os->fragments[os->nb_fragments++] = frag;
  431. os->fragment_index++;
  432. return 0;
  433. }
  434. static int hds_flush(AVFormatContext *s, OutputStream *os, int final,
  435. int64_t end_ts)
  436. {
  437. HDSContext *c = s->priv_data;
  438. int i, ret = 0;
  439. char target_filename[1024];
  440. int index = s->streams[os->first_stream]->id;
  441. if (!os->packets_written)
  442. return 0;
  443. avio_flush(os->ctx->pb);
  444. os->packets_written = 0;
  445. close_file(os);
  446. snprintf(target_filename, sizeof(target_filename),
  447. "%s/stream%dSeg1-Frag%d", s->filename, index, os->fragment_index);
  448. ret = ff_rename(os->temp_filename, target_filename, s);
  449. if (ret < 0)
  450. return ret;
  451. add_fragment(os, target_filename, os->frag_start_ts, end_ts - os->frag_start_ts);
  452. if (!final) {
  453. ret = init_file(s, os, end_ts);
  454. if (ret < 0)
  455. return ret;
  456. }
  457. if (c->window_size || (final && c->remove_at_exit)) {
  458. int remove = os->nb_fragments - c->window_size - c->extra_window_size;
  459. if (final && c->remove_at_exit)
  460. remove = os->nb_fragments;
  461. if (remove > 0) {
  462. for (i = 0; i < remove; i++) {
  463. unlink(os->fragments[i]->file);
  464. av_free(os->fragments[i]);
  465. }
  466. os->nb_fragments -= remove;
  467. memmove(os->fragments, os->fragments + remove,
  468. os->nb_fragments * sizeof(*os->fragments));
  469. }
  470. }
  471. if (ret >= 0)
  472. ret = write_abst(s, os, final);
  473. return ret;
  474. }
  475. static int hds_write_packet(AVFormatContext *s, AVPacket *pkt)
  476. {
  477. HDSContext *c = s->priv_data;
  478. AVStream *st = s->streams[pkt->stream_index];
  479. OutputStream *os = &c->streams[s->streams[pkt->stream_index]->id];
  480. int64_t end_dts = os->fragment_index * (int64_t)c->min_frag_duration;
  481. int ret;
  482. if (st->first_dts == AV_NOPTS_VALUE)
  483. st->first_dts = pkt->dts;
  484. if ((!os->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
  485. av_compare_ts(pkt->dts - st->first_dts, st->time_base,
  486. end_dts, AV_TIME_BASE_Q) >= 0 &&
  487. pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) {
  488. if ((ret = hds_flush(s, os, 0, pkt->dts)) < 0)
  489. return ret;
  490. }
  491. // Note, these fragment start timestamps, that represent a whole
  492. // OutputStream, assume all streams in it have the same time base.
  493. if (!os->packets_written)
  494. os->frag_start_ts = pkt->dts;
  495. os->last_ts = pkt->dts;
  496. os->packets_written++;
  497. return ff_write_chained(os->ctx, pkt->stream_index - os->first_stream, pkt, s, 0);
  498. }
  499. static int hds_write_trailer(AVFormatContext *s)
  500. {
  501. HDSContext *c = s->priv_data;
  502. int i;
  503. for (i = 0; i < c->nb_streams; i++)
  504. hds_flush(s, &c->streams[i], 1, c->streams[i].last_ts);
  505. write_manifest(s, 1);
  506. if (c->remove_at_exit) {
  507. char filename[1024];
  508. snprintf(filename, sizeof(filename), "%s/index.f4m", s->filename);
  509. unlink(filename);
  510. for (i = 0; i < c->nb_streams; i++) {
  511. snprintf(filename, sizeof(filename), "%s/stream%d.abst", s->filename, i);
  512. unlink(filename);
  513. }
  514. rmdir(s->filename);
  515. }
  516. hds_free(s);
  517. return 0;
  518. }
  519. #define OFFSET(x) offsetof(HDSContext, x)
  520. #define E AV_OPT_FLAG_ENCODING_PARAM
  521. static const AVOption options[] = {
  522. { "window_size", "number of fragments kept in the manifest", OFFSET(window_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, E },
  523. { "extra_window_size", "number of fragments kept outside of the manifest before removing from disk", OFFSET(extra_window_size), AV_OPT_TYPE_INT, { .i64 = 5 }, 0, INT_MAX, E },
  524. { "min_frag_duration", "minimum fragment duration (in microseconds)", OFFSET(min_frag_duration), AV_OPT_TYPE_INT64, { .i64 = 10000000 }, 0, INT_MAX, E },
  525. { "remove_at_exit", "remove all fragments when finished", OFFSET(remove_at_exit), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, E },
  526. { NULL },
  527. };
  528. static const AVClass hds_class = {
  529. .class_name = "HDS muxer",
  530. .item_name = av_default_item_name,
  531. .option = options,
  532. .version = LIBAVUTIL_VERSION_INT,
  533. };
  534. AVOutputFormat ff_hds_muxer = {
  535. .name = "hds",
  536. .long_name = NULL_IF_CONFIG_SMALL("HDS Muxer"),
  537. .priv_data_size = sizeof(HDSContext),
  538. .audio_codec = AV_CODEC_ID_AAC,
  539. .video_codec = AV_CODEC_ID_H264,
  540. .flags = AVFMT_GLOBALHEADER | AVFMT_NOFILE,
  541. .write_header = hds_write_header,
  542. .write_packet = hds_write_packet,
  543. .write_trailer = hds_write_trailer,
  544. .priv_class = &hds_class,
  545. };