subtitles.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2012 Clément Bœsch
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVFORMAT_SUBTITLES_H
  21. #define AVFORMAT_SUBTITLES_H
  22. #include <stdint.h>
  23. #include "avformat.h"
  24. #include "libavutil/bprint.h"
  25. typedef struct {
  26. AVPacket *subs; ///< array of subtitles packets
  27. int nb_subs; ///< number of subtitles packets
  28. int allocated_size; ///< allocated size for subs
  29. int current_sub_idx; ///< current position for the read packet callback
  30. } FFDemuxSubtitlesQueue;
  31. /**
  32. * Insert a new subtitle event.
  33. *
  34. * @param event the subtitle line, may not be zero terminated
  35. * @param len the length of the event (in strlen() sense, so without '\0')
  36. * @param merge set to 1 if the current event should be concatenated with the
  37. * previous one instead of adding a new entry, 0 otherwise
  38. */
  39. AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q,
  40. const uint8_t *event, int len, int merge);
  41. /**
  42. * Set missing durations and sort subtitles by PTS, and then byte position.
  43. */
  44. void ff_subtitles_queue_finalize(FFDemuxSubtitlesQueue *q);
  45. /**
  46. * Generic read_packet() callback for subtitles demuxers using this queue
  47. * system.
  48. */
  49. int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt);
  50. /**
  51. * Remove and destroy all the subtitles packets.
  52. */
  53. void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q);
  54. /**
  55. * SMIL helper to load next chunk ("<...>" or untagged content) in buf.
  56. *
  57. * @param c cached character, to avoid a backward seek
  58. */
  59. int ff_smil_extract_next_chunk(AVIOContext *pb, AVBPrint *buf, char *c);
  60. /**
  61. * SMIL helper to point on the value of an attribute in the given tag.
  62. *
  63. * @param s SMIL tag ("<...>")
  64. * @param attr the attribute to look for
  65. */
  66. const char *ff_smil_get_attr_ptr(const char *s, const char *attr);
  67. #endif /* AVFORMAT_SUBTITLES_H */