srt.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**********************************************************************************************/
  2. /* The MIT License */
  3. /* */
  4. /* Copyright 2016-2017 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
  5. /* */
  6. /* Permission is hereby granted, free of charge, to any person obtaining a copy */
  7. /* of this software and associated documentation files (the "Software"), to deal */
  8. /* in the Software without restriction, including without limitation the rights */
  9. /* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
  10. /* copies of the Software, and to permit persons to whom the Software is */
  11. /* furnished to do so, subject to the following conditions: */
  12. /* */
  13. /* The above copyright notice and this permission notice shall be included in */
  14. /* all copies or substantial portions of the Software. */
  15. /* */
  16. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
  17. /* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
  18. /* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
  19. /* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
  20. /* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
  21. /* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
  22. /* THE SOFTWARE. */
  23. /**********************************************************************************************/
  24. #ifndef LIBCAPTION_SRT_H
  25. #define LIBCAPTION_SRT_H
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #include "caption.h"
  30. #include "eia608.h"
  31. #include "vtt.h"
  32. // timestamp and duration are in seconds
  33. typedef vtt_t srt_t;
  34. typedef vtt_block_t srt_cue_t;
  35. /*! \brief
  36. \param
  37. */
  38. srt_t* srt_new();
  39. /*! \brief
  40. \param
  41. */
  42. srt_t* srt_free_head(srt_t* head);
  43. // returns the head of the link list. must bee freed when done
  44. /*! \brief
  45. \param
  46. */
  47. srt_t* srt_parse(const utf8_char_t* data, size_t size);
  48. /*! \brief
  49. \param
  50. */
  51. void srt_free(srt_t* srt);
  52. /*! \brief
  53. \param
  54. */
  55. static inline vtt_block_t* srt_next(vtt_block_t* srt) { return srt->next; }
  56. /*! \brief
  57. \param
  58. */
  59. static inline utf8_char_t* srt_cue_data(srt_cue_t* cue) { return vtt_block_data(cue); }
  60. /*! \brief
  61. \param
  62. */
  63. static inline srt_cue_t* srt_cue_from_caption_frame(caption_frame_t* frame, srt_t* srt) { return vtt_cue_from_caption_frame(frame, srt); };
  64. /*! \brief
  65. \param
  66. */
  67. static inline void srt_cue_free_head(srt_t* srt) { vtt_cue_free_head(srt); };
  68. /*! \brief
  69. \param
  70. */
  71. static inline srt_cue_t* srt_cue_new(srt_t* srt, const utf8_char_t* data, size_t size) { return vtt_block_new(srt, data, size, VTT_CUE); };
  72. /*! \brief
  73. \param
  74. */
  75. static inline int srt_cue_to_caption_frame(srt_cue_t* cue, caption_frame_t* frame) { return vtt_cue_to_caption_frame(cue, frame); };
  76. void srt_dump(srt_t* srt);
  77. /*! \brief
  78. \param
  79. */
  80. void vtt_dump(srt_t* srt);
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif