record.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <stdbool.h>
  4. #include "drv_dtv_external.h"
  5. #include "time.h"
  6. #ifndef TRUE
  7. #define TRUE 1
  8. #endif
  9. #ifndef FALSE
  10. #define FALSE 0
  11. #endif
  12. #ifndef BOOL
  13. #define BOOL unsigned char
  14. #endif
  15. #ifndef UINT64
  16. #define UINT64 unsigned long long
  17. #endif
  18. #ifndef UINT32
  19. #define UINT32 unsigned int
  20. #endif
  21. #ifndef UINT16
  22. #define UINT16 unsigned short
  23. #endif
  24. #ifndef UINT8
  25. #define UINT8 unsigned char
  26. #endif
  27. #define MAX_PATH_NAME_LEN 768
  28. #define FILE_NAME_LEN 512
  29. #define SHORT_FILE_NAME_LEN 256
  30. #define EXT_FILE_NAME_LEN 8
  31. #ifndef REC_MAX_MAP_PIDS_NUM
  32. #define REC_MAX_MAP_PIDS_NUM 16
  33. #endif
  34. #ifndef PVR_FILE_EXT_STR
  35. #define PVR_FILE_EXT_STR ".ts"
  36. #endif
  37. #define RECORD_FILE_MAX_SIZE 0xFF000000 // 4080MB
  38. #define SUPPORT_REWIND_BY_USER_SETTING 1
  39. #define SUPPORT_PRE_OPEN_FILE 0
  40. #define SUPPORT_MONITOR_MEM 0
  41. typedef struct _tagRecTimeInfo
  42. {
  43. UINT16 m_nYear;
  44. UINT8 m_nMonth;
  45. UINT8 m_nDay;
  46. UINT8 m_nHour;
  47. UINT8 m_nMinute;
  48. UINT8 m_nSecond;
  49. UINT8 m_nMode;
  50. }REC_TIME_INFO,*PREC_TIME_INFO;
  51. typedef struct _tagRecTime
  52. {
  53. union
  54. {
  55. UINT32 m_dwRecTime;
  56. REC_TIME_INFO m_sRecTimeInfo;
  57. };
  58. }REC_TIME,*PREC_TIME;
  59. #ifdef CONFIG_CIPLUS_SUPPORT_PVR
  60. typedef struct _tagRecCIInfo
  61. {
  62. UINT8 mIsRCD;
  63. UINT8 mIndex;
  64. UINT32 mFileSize;
  65. }__attribute__ ((packed))REC_CI_File_Info,*PREC_CI_File_Info;
  66. typedef struct RecCITSPLHeader
  67. {
  68. UINT8 ModuleName[6]; //6
  69. UINT32 Cidata_length;
  70. UINT16 FileCnt;
  71. REC_TIME_INFO rec_time; //8
  72. UINT32 HeaderPkt[26];
  73. UINT32 HeaderSize;
  74. }__attribute__ ((packed))CITSPLREC_UNIT,RecCITSPLHeader; //remove padding & alignment
  75. #endif
  76. typedef struct _FACTORY_RECORD_CONFIG
  77. {
  78. char szFileName[MAX_PATH_NAME_LEN]; /*!< recorded filename*/
  79. char szFileExtName[EXT_FILE_NAME_LEN]; /*!< recorded file ext name, mpg, mp3, ac3,...*/
  80. }FACTORY_RECORD_CONFIG;
  81. typedef struct _RECORD_CONFIG
  82. {
  83. // autocut config
  84. UINT32 dwAutocutSize; /*!< autocut size, set 0 to disable autocut for infinite timeshifting or NTFS HDD.*/
  85. // pids mapping config
  86. UINT16 usVideoPid; /*!< video mapping pid, 0x1fff means no video pid packets*/
  87. UINT16 usAudioPid; /*!< audio mapping pid, 0x1fff means no audio pid packets*/
  88. UINT16 usVidStrmType; /*!< video stream type */
  89. UINT16 usAudStrmType; /*!< audio stream type */
  90. UINT16 usProgNum; /*!< program number */
  91. UINT16 usPcrPid; /*!< pcr mapping pid, 0xffff means no pcr pid packets*/
  92. UINT16 usPatPid; /*!< PAT mapping pid, 0xffff means no pat pid packets*/
  93. UINT16 usPmtPid; /*!< PMT mapping pid, 0xffff means no pmt pid packets*/
  94. UINT16 usOtherPesPids[REC_MAX_MAP_PIDS_NUM]; /*!< other mapping pid, 0xffff entry means end of other PES pids array*/
  95. UINT16 usOtherPsiPids[REC_MAX_MAP_PIDS_NUM]; /*!< other mapping pid, 0xffff entry means end of other PSI pids array*/
  96. // user pack
  97. UINT8 ucUserPack; /*!< Add user pack at the first of file, only used for TV/Audio service type*/
  98. // record service type config
  99. UINT8 ucServiceType; /*!< MID_REC_SERVICE_TV, MID_REC_SERVICE_RADIO, MID_REC_SERVICE_TS(transport stream packets)*/
  100. // autocut num
  101. UINT8 ucAutocutExtNum; /*!< autocut start number for file ext name */
  102. // pcr discontinunity config
  103. UINT8 ucPcrDiscLimit; /*!< source PCR discontinunity ignore limit times, set 0 for not ignoring.*/
  104. UINT32 dwPcrDiscTolerance; /*!< tolerance difference between 2 consecutive PCR values, set 0 for using 9000(100ms) defined by spec.*/
  105. UINT64 *pllStartSCR; /*!< SCR start time of the first PS pack. NULL pointer indicates no defined.*/
  106. // ring buffer
  107. UINT32 u32RingBuffer; /*!< Ring buffer size in minutes for TSPB*/
  108. // file name
  109. char szFileName[MAX_PATH_NAME_LEN]; /*!< recorded filename*/
  110. char szFileExtName[EXT_FILE_NAME_LEN]; /*!< recorded file ext name, mpg, mp3, ac3,...*/
  111. // new services user added //Mika_101109: mantis 109499 //Mika_101223: mantis 118634
  112. UINT8 bNewService; /*!< dvb-s new services added*/
  113. UINT8 AudioIndex; //switch audio track
  114. UINT16 CurSubtitlePid; /*!< from PES pids, switch to current subtitle PID*/
  115. UINT16 CurADPid; /*switch to current AD PID*/
  116. UINT8 parental_rating; //parental rating
  117. char ci_pin[5]; //ci cam pin, 4 digits with null terminated
  118. UINT8 CAServiceType;
  119. #ifdef CONFIG_SUPPORT_PVR_DATA_ENCRYPTION
  120. UINT8 bHAS_HDCPKSV;
  121. UINT8 HDCPKSV[5];
  122. #endif
  123. }RECORD_CONFIG;
  124. typedef enum _RECTYPE
  125. {
  126. MID_REC_MODE_MANUAL = 0, //pvr
  127. MID_REC_MODE_AUTO, //timeshoft
  128. MID_REC_MODE_TIMESHIFT_AFTER_REC, //timeshift
  129. MID_REC_MODE_UNATTENDED, //unattended record mode
  130. MID_REC_MODE_TIMESHIFT_AUTOREWIND,
  131. MID_REC_MODE_PVR_AUTOPLAY, //file exist mode
  132. MID_REC_MODE_MAX,
  133. } RECTYPE,MID_REC_MODE;
  134. typedef enum _CAServiceType
  135. {
  136. FTA, //free to air
  137. CI_SCRAMBLED,
  138. BISS_SCRAMBLED,
  139. }SERVICETYPE,MID_CA_SERVICE_TYPE;
  140. typedef enum
  141. {
  142. TS_TSHIFT_SIGNAL_HAS_DATA = 0,
  143. TS_TSHIFT_SIGNAL_HAS_NO_DATA,
  144. }TSHIFT_CALLBK_TYPE;
  145. typedef void ( * TSHIFT_CALLBACK_FUNC )( UINT16 wParam , UINT32 dwParam);
  146. void TS_SetTShiftCallBackFunc(void( * pCallBackFunc )( UINT16 wParam , UINT32 dwParam) );
  147. typedef void ( * REC_CALLBACK_FUNC )( UINT16 wParam , UINT32 dwParam);
  148. void TS_SetCallBackFunc(void( * pCallBackFunc )( UINT16 wParam , UINT32 dwParam) );
  149. UINT32 TS_Get_USB_WriteSize(void);
  150. BOOL TSPidRemap(RECORD_CONFIG *gRecConfig);
  151. BOOL TSSetConfig(RECORD_CONFIG *gRecConfig);
  152. BOOL TSStart(char *szUSBFlashRootDir, int AvailSizeInMB);
  153. BOOL TSStop();
  154. void TSPause();
  155. BOOL TS_IsRecording();
  156. BOOL TS_IsPause();
  157. void TSResume();
  158. BOOL TSGetParserRecordingTime(long *recDurTime);
  159. BOOL TSGetRecordingDuration(long *recDurTime);
  160. void TSSwitchCurMode(int RecMode);
  161. int GetRecordFolder(char *folder);
  162. UINT32 TSGetByteRate();
  163. UINT32 TSGetRecordFileSize();
  164. void TSGetCurIndexAndSize(UINT32 *Index , UINT64 *singleSize);
  165. UINT32 TSGetFrameRate();
  166. int TSGetRecordFileIndex();
  167. BOOL TSIsRewind(long *buffertime);
  168. BOOL TSPlaybackAttachPE();
  169. BOOL TSPlaybackDetachDTV();
  170. BOOL AttachDTV();
  171. int GetRecordName(char *recordName);
  172. BOOL TSGetCurRWPos(UINT32 *Wptr , int64_t *Rptr);
  173. BOOL TSSetFactoryConfig(FACTORY_RECORD_CONFIG *gRecConfig);
  174. BOOL TSRecordModeChange(int mode);
  175. UINT32 TSGetByteRate();
  176. UINT32 TSGetAvaiableTime();
  177. #if SUPPORT_PRE_OPEN_FILE
  178. BOOL TSScheOpenFile(char *szUSBFlashRootDir ,char * filename , char * filename_ext);
  179. BOOL TSScheDeletFile();
  180. #endif
  181. void TSSetRecRewindMode(char mode);
  182. UINT16 TSGetParserProgId();
  183. BOOL TSRecordContiProgram();