| 1 | /****************************************************************************** |
|---|
| 2 | *_Copyright (c) 2009 Digital Stream Technology Inc. All Rights Reserved. |
|---|
| 3 | * |
|---|
| 4 | * Module: dstdddmx.c |
|---|
| 5 | * |
|---|
| 6 | * Description |
|---|
| 7 | * |
|---|
| 8 | * @author |
|---|
| 9 | * @version $Revision: 1.1 $ |
|---|
| 10 | * |
|---|
| 11 | ******************************************************************************/ |
|---|
| 12 | |
|---|
| 13 | #include <stdlib.h> |
|---|
| 14 | #include <fcntl.h> |
|---|
| 15 | #include <getopt.h> |
|---|
| 16 | #include <sys/ioctl.h> |
|---|
| 17 | #include <sys/time.h> |
|---|
| 18 | |
|---|
| 19 | #include "dsthalcommon.h" |
|---|
| 20 | #include "dsthalcfg.h" |
|---|
| 21 | #include "dstdddmx.h" |
|---|
| 22 | #include "dstdddtv.h" |
|---|
| 23 | #include "dstddsys.h" |
|---|
| 24 | |
|---|
| 25 | /* |
|---|
| 26 | * Device Driver includes. |
|---|
| 27 | */ |
|---|
| 28 | #include "pd_dmx.h" |
|---|
| 29 | |
|---|
| 30 | #ifdef DMALLOC |
|---|
| 31 | #include <dmalloc.h> |
|---|
| 32 | #endif |
|---|
| 33 | |
|---|
| 34 | /****************************************************************************** |
|---|
| 35 | * Global variable declaration |
|---|
| 36 | ******************************************************************************/ |
|---|
| 37 | int gddDmxDbgLvl = 2; |
|---|
| 38 | |
|---|
| 39 | /****************************************************************************** |
|---|
| 40 | * Imported variable declaration |
|---|
| 41 | ******************************************************************************/ |
|---|
| 42 | |
|---|
| 43 | /****************************************************************************** |
|---|
| 44 | * Imported function declaration |
|---|
| 45 | ******************************************************************************/ |
|---|
| 46 | |
|---|
| 47 | /****************************************************************************** |
|---|
| 48 | * Local definitions |
|---|
| 49 | ******************************************************************************/ |
|---|
| 50 | |
|---|
| 51 | /****************************************************************************** |
|---|
| 52 | * Local typedefs |
|---|
| 53 | ******************************************************************************/ |
|---|
| 54 | |
|---|
| 55 | /****************************************************************************** |
|---|
| 56 | * Local variables declaration |
|---|
| 57 | ******************************************************************************/ |
|---|
| 58 | static int g_bAudioScrambled = 0; // ScrambleÀ̸é, 1¾¿ Áõ°¡. |
|---|
| 59 | static int g_bVideoScrambled = 0; |
|---|
| 60 | static int g_ScrVPid=-1, g_ScrAPid=-1; |
|---|
| 61 | |
|---|
| 62 | /****************************************************************************** |
|---|
| 63 | * Local function prototypes |
|---|
| 64 | ******************************************************************************/ |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | #if 0 |
|---|
| 68 | ___Common_Functions___() |
|---|
| 69 | #endif |
|---|
| 70 | DHL_RESULT DD_DMX_Init(void) |
|---|
| 71 | { |
|---|
| 72 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 73 | int retVal = PD_DMX_SUCCESS; |
|---|
| 74 | |
|---|
| 75 | retVal = PD_DMX_SetDemuxFile( "/Stream/CC_CAMP_1SEG_FULLSEG_27122007.trp", DS_TRUE ); |
|---|
| 76 | SysASSERT( PD_DMX_OK(retVal) ); |
|---|
| 77 | |
|---|
| 78 | retVal = PD_DMX_OpenDemux(); |
|---|
| 79 | SysASSERT( PD_DMX_OK(retVal) ); |
|---|
| 80 | |
|---|
| 81 | if ( !PD_DMX_OK(retVal) ) |
|---|
| 82 | dhlResult = DHL_FAIL; |
|---|
| 83 | |
|---|
| 84 | return dhlResult; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | DHL_RESULT DD_DMX_Start(void) |
|---|
| 88 | { |
|---|
| 89 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 90 | |
|---|
| 91 | int retVal = PD_DMX_SUCCESS; |
|---|
| 92 | |
|---|
| 93 | retVal = PD_DMX_StartDemux(); |
|---|
| 94 | SysASSERT( PD_DMX_OK(retVal) ); |
|---|
| 95 | |
|---|
| 96 | if ( !PD_DMX_OK(retVal) ) |
|---|
| 97 | dhlResult = DHL_FAIL; |
|---|
| 98 | |
|---|
| 99 | return dhlResult; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | DHL_RESULT DD_DMX_Stop(void) |
|---|
| 103 | { |
|---|
| 104 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 105 | |
|---|
| 106 | int retVal = PD_DMX_SUCCESS; |
|---|
| 107 | |
|---|
| 108 | retVal = PD_DMX_StopDemux(); |
|---|
| 109 | SysASSERT( PD_DMX_OK(retVal) ); |
|---|
| 110 | |
|---|
| 111 | if ( !PD_DMX_OK(retVal) ) |
|---|
| 112 | dhlResult = DHL_FAIL; |
|---|
| 113 | |
|---|
| 114 | return dhlResult; |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | DHL_RESULT DD_DMX_Close(void) |
|---|
| 118 | { |
|---|
| 119 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 120 | int retVal = PD_DMX_SUCCESS; |
|---|
| 121 | |
|---|
| 122 | retVal = PD_DMX_CloseDemux(); |
|---|
| 123 | SysASSERT( PD_DMX_OK(retVal) ); |
|---|
| 124 | |
|---|
| 125 | if ( !PD_DMX_OK(retVal) ) |
|---|
| 126 | dhlResult = DHL_FAIL; |
|---|
| 127 | |
|---|
| 128 | return dhlResult; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | DHL_RESULT DD_DMX_StartScrambleCheck(void) |
|---|
| 132 | { |
|---|
| 133 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 134 | |
|---|
| 135 | g_bAudioScrambled = 0; |
|---|
| 136 | g_bVideoScrambled = 0; |
|---|
| 137 | |
|---|
| 138 | return dhlResult; |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | DS_BOOL DD_DMX_IsScrambled(void) |
|---|
| 142 | { |
|---|
| 143 | if (g_bAudioScrambled>=4) |
|---|
| 144 | return _TRUE_; |
|---|
| 145 | |
|---|
| 146 | if (g_bVideoScrambled>=4) |
|---|
| 147 | return _TRUE_; |
|---|
| 148 | |
|---|
| 149 | return _FALSE_; |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | DHL_RESULT DD_DMX_SetPID4DetectScramble( DS_U16 vPid, DS_U16 aPid ) |
|---|
| 153 | { |
|---|
| 154 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 155 | |
|---|
| 156 | DHL_ASSERT( DD_DMX_StartScrambleCheck(), dhlResult ); |
|---|
| 157 | |
|---|
| 158 | // |
|---|
| 159 | // Call the API to start monitoring PID. |
|---|
| 160 | // |
|---|
| 161 | |
|---|
| 162 | g_ScrVPid = vPid; |
|---|
| 163 | g_ScrAPid = aPid; |
|---|
| 164 | |
|---|
| 165 | return dhlResult; |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | DHL_RESULT DD_DMX_ResetPID4DetectScramble(void) |
|---|
| 169 | { |
|---|
| 170 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 171 | |
|---|
| 172 | g_ScrVPid = -1; |
|---|
| 173 | g_ScrAPid = -1; |
|---|
| 174 | |
|---|
| 175 | return dhlResult; |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | DHL_RESULT DD_DMX_SetPID4DetectScrambleEx( DS_U16 vPid ) |
|---|
| 179 | { |
|---|
| 180 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 181 | |
|---|
| 182 | DHL_ASSERT( DD_DMX_StartScrambleCheck(), dhlResult ); |
|---|
| 183 | |
|---|
| 184 | // |
|---|
| 185 | // Call the API to start monitoring PID. |
|---|
| 186 | // |
|---|
| 187 | |
|---|
| 188 | g_ScrVPid = vPid; |
|---|
| 189 | |
|---|
| 190 | return dhlResult; |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | DHL_RESULT DD_DMX_ResetPID4DetectScrambleEx(void) |
|---|
| 194 | { |
|---|
| 195 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 196 | |
|---|
| 197 | // |
|---|
| 198 | // If scramble detection is started, then call the API to reset scramble detection. |
|---|
| 199 | // |
|---|
| 200 | if ( g_ScrVPid != -1 ) |
|---|
| 201 | { |
|---|
| 202 | g_ScrVPid = -1; |
|---|
| 203 | } |
|---|
| 204 | |
|---|
| 205 | return dhlResult; |
|---|
| 206 | } |
|---|