subtitles.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef NSVPLAY_SUBTITLES_H
  2. #define NSVPLAY_SUBTITLES_H
  3. #include "main.h"
  4. #include "../nsvbs.h"
  5. class SubsItem {
  6. public:
  7. SubsItem(unsigned int ptimestart, unsigned int ptimeend, const char *ptext) :
  8. timestart(ptimestart) , timeend(ptimeend) {
  9. text=_strdup(ptext);
  10. xPos=128;
  11. yPos=255;
  12. colorRed=colorGreen=colorBlue=0xff;
  13. extraDataSize=0;
  14. extraData=0;
  15. muxed_subtitle=0;
  16. fontSize=origFontSize=0;
  17. }
  18. ~SubsItem() {
  19. free((void*)text);
  20. if(extraDataSize) free((void *)extraData);
  21. }
  22. unsigned int timestart;
  23. unsigned int timeend;
  24. const char *text;
  25. unsigned char xPos, yPos;
  26. unsigned char colorRed, colorGreen, colorBlue;
  27. int extraDataSize;
  28. const void *extraData;
  29. int muxed_subtitle; //so we free it when we seek/display
  30. int fontSize;
  31. int origFontSize;
  32. };
  33. class Subtitles {
  34. public:
  35. Subtitles(const char *filename);
  36. SubsItem *getSubtitle(unsigned int time, unsigned int frame); // time in ms
  37. void addSubtitlePacket(SUBTITLE_INFO *sti);
  38. void setFontSizeModifier(int size) { m_font_size_mod=size; }
  39. private:
  40. void decodeSrtFile(char *text);
  41. unsigned int getTimeFromSrtText(const char *text);
  42. void decodeSubFile(char *text);
  43. ClassList<SubsItem> m_subs;
  44. int m_frame_based;
  45. int m_last_sub;
  46. int m_font_size_mod;
  47. };
  48. #endif