Guest User

Seb

a guest
Jan 24th, 2010
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.12 KB | None | 0 0
  1. Index: DSPlayer/DSConfig.cpp
  2. ===================================================================
  3. --- DSPlayer/DSConfig.cpp (revision 27111)
  4. +++ DSPlayer/DSConfig.cpp (working copy)
  5. @@ -93,6 +93,17 @@
  6.  
  7. CLog::Log(LOGDEBUG, "%s Looking for audio streams in %s splitter", __FUNCTION__, splitterName.c_str());
  8.  
  9. + /* Regex to rename audio stream */
  10. + std::vector<CRegExp *> regex;
  11. +
  12. + CRegExp *reg = new CRegExp(true);
  13. + reg->RegComp("(.*?)(\\(audio.*?\\)|\\(subtitle.*?\\))"); // mkv source audio / subtitle
  14. + regex.push_back(reg);
  15. +
  16. + reg = new CRegExp(true);
  17. + reg->RegComp(".* - (.*),.*\\(.*\\)"); // mpeg source audio / subtitle
  18. + regex.push_back(reg);
  19. +
  20. /* Does the splitter support IAMStreamSelect ?*/
  21. HRESULT hr = m_pSplitter->QueryInterface(__uuidof(m_pIAMStreamSelect), (void **) &m_pIAMStreamSelect);
  22. if (SUCCEEDED(hr))
  23. @@ -107,7 +118,7 @@
  24. m_pIAMStreamSelect->Count(&nStreams);
  25.  
  26. AM_MEDIA_TYPE * mediaType = NULL;
  27. - for(long i = 0; i < nStreams; i++)
  28. + for(int i = 0; i < nStreams; i++)
  29. {
  30. infos = new IAMStreamSelectInfos();
  31. infos->group = 0; infos->lcid = 0; infos->pObj = 0; infos->pUnk = 0; infos->flags = 0;
  32. @@ -116,13 +127,23 @@
  33. g_charsetConverter.wToUTF8(wname, infos->name);
  34. CoTaskMemFree(wname);
  35.  
  36. + /* Apply regex */
  37. + for (std::vector<CRegExp *>::const_iterator it = regex.begin(); it != regex.end(); ++it)
  38. + {
  39. + if ( (*it)->RegFind(infos->name) > -1 )
  40. + {
  41. + infos->name = (*it)->GetMatch(1);
  42. + break;
  43. + }
  44. + }
  45. +
  46. if (mediaType->majortype == MEDIATYPE_Audio)
  47. {
  48. /* Audio stream */
  49. m_pAudioStreams.insert( std::pair<long, IAMStreamSelectInfos *>(i, infos) );
  50. CLog::Log(LOGNOTICE, "%s Audio stream found : %s", __FUNCTION__, infos->name.c_str());
  51.  
  52. - } else if (mediaType->majortype == MEDIATYPE_Subtitle || mediaType->majortype == GUID_NULL)
  53. + } else if (mediaType->majortype == MEDIATYPE_Subtitle)
  54. {
  55. /* Embed subtitles */
  56. m_pEmbedSubtitles.insert( std::pair<long, IAMStreamSelectInfos *>(i, infos) );
  57. @@ -136,110 +157,119 @@
  58.  
  59. // Enumerate output pins
  60. PIN_DIRECTION dir;
  61. - AM_MEDIA_TYPE mediaType;
  62. int i = 0, j = 0;
  63. - CStdStringW pinName;
  64. + CStdStringW pinNameW;
  65. + CStdString pinName;
  66. IAMStreamSelectInfos *infos;
  67. bool pinConnected = FALSE;
  68. bool audioPinAlreadyConnected = FALSE, subtitlePinAlreadyConnected = FALSE;
  69. - //the regex for removing the (audio #) in the name
  70. - CRegExp reAudioName(true);
  71. - reAudioName.RegComp("(.*?)(\\(audio.*?\\)\|\\(subtitle.*?\\))");
  72.  
  73. + int nIn = 0, nOut = 0, nInC = 0, nOutC = 0;
  74. + DShowUtil::CountPins(m_pSplitter, nIn, nOut, nInC, nOutC);
  75. + CLog::Log(LOGDEBUG, "%s The splitter has %d output pins", __FUNCTION__, nOut);
  76. +
  77. BeginEnumPins(m_pSplitter, pEP, pPin)
  78. {
  79. if (SUCCEEDED(pPin->QueryDirection(&dir)) && ( dir == PINDIR_OUTPUT ))
  80. {
  81. - if (SUCCEEDED(pPin->ConnectionMediaType(&mediaType))
  82. - && ( mediaType.majortype == MEDIATYPE_Audio ))
  83. +
  84. + pinNameW = DShowUtil::GetPinName(pPin);
  85. + g_charsetConverter.wToUTF8(pinNameW, pinName);
  86. + CLog::Log(LOGDEBUG, "%s Output pin found : %s", __FUNCTION__, pinName.c_str());
  87. +
  88. + /* TODO: Ne pas utiliser ConnectionMediaType. Renvois false si la pin n'est pas connect� -> probl�me.
  89. + Utiliser BeginEnumMediaTypes comme en dessous pour TOUTES les pins */
  90. +
  91. + BeginEnumMediaTypes(pPin, pET, pMediaType)
  92. {
  93. - pinName = DShowUtil::GetPinName(pPin);
  94. -
  95. +
  96. + CLog::Log(LOGDEBUG, "%s Output pin major type : %s", __FUNCTION__, GuidNames[pMediaType->majortype]);
  97. + CLog::Log(LOGDEBUG, "%s Output pin sub type : %s", __FUNCTION__, GuidNames[pMediaType->subtype]);
  98. + CLog::Log(LOGDEBUG, "%s Output pin format type : %s", __FUNCTION__, GuidNames[pMediaType->formattype]);
  99. +
  100. + if (pMediaType->majortype != MEDIATYPE_Audio &&
  101. + pMediaType->majortype != MEDIATYPE_Subtitle)
  102. + continue;
  103. +
  104. infos = new IAMStreamSelectInfos();
  105. infos->group = 0; infos->lcid = 0; infos->pObj = 0; infos->pUnk = 0; infos->flags = 0;
  106. pinConnected = FALSE;
  107.  
  108. - g_charsetConverter.wToUTF8(pinName, infos->name);
  109. - if ( reAudioName.RegFind(infos->name) > -1 )
  110. - {
  111. - // "English, 3/2 (Audio 1)" should be renamed to "English, 3/2" - Treat also subtitles
  112. - infos->name = reAudioName.GetMatch(1);
  113. - }
  114. + infos->name = pinName;
  115.  
  116. - infos->pObj = pPin;
  117. -
  118. - if (SUCCEEDED(DShowUtil::IsPinConnected(pPin)))
  119. + /* Apply regex */
  120. + for (std::vector<CRegExp *>::const_iterator it = regex.begin(); it != regex.end(); ++it)
  121. {
  122. - if (audioPinAlreadyConnected)
  123. - { // Prevent multiple audio stream at the same time
  124. - IPin *pin = NULL;
  125. - pPin->ConnectedTo(&pin);
  126. - m_pGraphBuilder->Disconnect(pPin);
  127. - m_pGraphBuilder->Disconnect(pin);
  128. - SAFE_RELEASE(pin);
  129. - }
  130. - else
  131. + if ( (*it)->RegFind(infos->name) > -1 )
  132. {
  133. - infos->flags = AMSTREAMSELECTINFO_ENABLED;
  134. - audioPinAlreadyConnected = TRUE;
  135. + infos->name = (*it)->GetMatch(1);
  136. + break;
  137. }
  138. }
  139.  
  140. - m_pAudioStreams.insert( std::pair<long, IAMStreamSelectInfos *>(i, infos) );
  141. - CLog::Log(LOGNOTICE, "%s Audio stream found : %s", __FUNCTION__, infos->name.c_str());
  142. - i++;
  143. + infos->pObj = pPin;
  144.  
  145. - } else {
  146. -
  147. - BeginEnumMediaTypes(pPin, pET, pMediaType)
  148. + if (pMediaType->majortype == MEDIATYPE_Audio)
  149. {
  150. - if (pMediaType->majortype == MEDIATYPE_Subtitle)
  151. + if (SUCCEEDED(DShowUtil::IsPinConnected(pPin)))
  152. {
  153. - pinName = DShowUtil::GetPinName(pPin);
  154. -
  155. - infos = new IAMStreamSelectInfos();
  156. - infos->group = 0; infos->lcid = 0; infos->pObj = 0; infos->pUnk = 0; infos->flags = 0;
  157. - pinConnected = FALSE;
  158. -
  159. - g_charsetConverter.wToUTF8(pinName, infos->name);
  160. - if ( reAudioName.RegFind(infos->name) > -1 )
  161. + if (audioPinAlreadyConnected)
  162. + { // Prevent multiple audio stream at the same time
  163. + IPin *pin = NULL;
  164. + pPin->ConnectedTo(&pin);
  165. + m_pGraphBuilder->Disconnect(pPin);
  166. + m_pGraphBuilder->Disconnect(pin);
  167. + SAFE_RELEASE(pin);
  168. + }
  169. + else
  170. {
  171. - // "English, 3/2 (Audio 1)" should be renamed to "English, 3/2" - Treat also subtitles
  172. - infos->name = reAudioName.GetMatch(1);
  173. + infos->flags = AMSTREAMSELECTINFO_ENABLED;
  174. + audioPinAlreadyConnected = TRUE;
  175. }
  176. + }
  177.  
  178. - infos->pObj = pPin;
  179. + m_pAudioStreams.insert( std::pair<long, IAMStreamSelectInfos *>(i, infos) );
  180. + CLog::Log(LOGNOTICE, "%s Audio stream found : %s", __FUNCTION__, infos->name.c_str());
  181. + i++;
  182. + } else {
  183.  
  184. - if (SUCCEEDED(DShowUtil::IsPinConnected(pPin)))
  185. + if (SUCCEEDED(DShowUtil::IsPinConnected(pPin)))
  186. + {
  187. + if (subtitlePinAlreadyConnected)
  188. + { // Prevent multiple audio stream at the same time
  189. + IPin *pin = NULL;
  190. + pPin->ConnectedTo(&pin);
  191. + m_pGraphBuilder->Disconnect(pPin);
  192. + m_pGraphBuilder->Disconnect(pin);
  193. + SAFE_RELEASE(pin);
  194. + }
  195. + else
  196. {
  197. - if (subtitlePinAlreadyConnected)
  198. - { // Prevent multiple audio stream at the same time
  199. - IPin *pin = NULL;
  200. - pPin->ConnectedTo(&pin);
  201. - m_pGraphBuilder->Disconnect(pPin);
  202. - m_pGraphBuilder->Disconnect(pin);
  203. - SAFE_RELEASE(pin);
  204. - }
  205. - else
  206. - {
  207. - infos->flags = AMSTREAMSELECTINFO_ENABLED;
  208. - subtitlePinAlreadyConnected = TRUE;
  209. - }
  210. + infos->flags = AMSTREAMSELECTINFO_ENABLED;
  211. + subtitlePinAlreadyConnected = TRUE;
  212. }
  213. + }
  214.  
  215. - m_pEmbedSubtitles.insert( std::pair<long, IAMStreamSelectInfos *>(j, infos) );
  216. - CLog::Log(LOGNOTICE, "%s Embed subtitle found : %s", __FUNCTION__, infos->name.c_str());
  217. - j++;
  218. - }
  219. + m_pEmbedSubtitles.insert( std::pair<long, IAMStreamSelectInfos *>(j, infos) );
  220. + CLog::Log(LOGNOTICE, "%s Embed subtitle found : %s", __FUNCTION__, infos->name.c_str());
  221. + j++;
  222. +
  223. }
  224. - EndEnumMediaTypes(pMediaType)
  225.  
  226. }
  227. - DeleteMediaType(&mediaType);
  228. + EndEnumMediaTypes(pMediaType)
  229. }
  230. }
  231. EndEnumPins
  232. }
  233. +
  234. + /* Delete regex */
  235. + while (! regex.empty())
  236. + {
  237. + delete regex.back();
  238. + regex.pop_back();
  239. + }
  240. +
  241. return false;
  242. }
  243.  
  244. @@ -277,6 +307,8 @@
  245. if ( (*it).second->flags == AMSTREAMSELECTINFO_ENABLED)
  246. return i;
  247. }
  248. +
  249. + return -1;
  250. }
  251.  
  252. void CDSConfig::GetAudioStreamName(int iStream, CStdString &strStreamName)
  253. @@ -335,6 +367,8 @@
  254. if ( (*it).second->flags == AMSTREAMSELECTINFO_ENABLED)
  255. return i;
  256. }
  257. +
  258. + return -1;
  259. }
  260.  
  261. void CDSConfig::GetSubtitleName(int iStream, CStdString &strStreamName)
  262. Index: DSPlayer/DSGraph.cpp
  263. ===================================================================
  264. --- DSPlayer/DSGraph.cpp (revision 27111)
  265. +++ DSPlayer/DSGraph.cpp (working copy)
  266. @@ -96,8 +96,7 @@
  267. hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pMediaControl),(void **)&m_pMediaControl);
  268. hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pMediaEvent),(void **)&m_pMediaEvent);
  269. hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pBasicAudio),(void **)&m_pBasicAudio);
  270. - hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pBasicVideo),(void **)&m_pBasicVideo);
  271. -
  272. + hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pBasicVideo),(void **)&m_pBasicVideo);
  273.  
  274. LONGLONG tmestamp;
  275. tmestamp = CTimeUtils::GetTimeMS();
  276. Index: DSPlayer/DSPlayer.cpp
  277. ===================================================================
  278. --- DSPlayer/DSPlayer.cpp (revision 27111)
  279. +++ DSPlayer/DSPlayer.cpp (working copy)
  280. @@ -43,7 +43,6 @@
  281. {
  282. m_hReadyEvent = CreateEvent(NULL, true, false, NULL);
  283. m_bAbortRequest = false;
  284. -
  285. }
  286.  
  287. CDSPlayer::~CDSPlayer()
  288. Index: DSPlayer/FGLoader.cpp
  289. ===================================================================
  290. --- DSPlayer/FGLoader.cpp (revision 27111)
  291. +++ DSPlayer/FGLoader.cpp (working copy)
  292. @@ -195,7 +195,7 @@
  293. HRESULT CFGLoader::InsertVideoDecoder(TiXmlElement *pRule)
  294. {
  295. HRESULT hr = S_OK;
  296. - IBaseFilter* ppBF;
  297. + IBaseFilter* ppBF = NULL;
  298. for (list<CFGFilterFile*>::iterator it = m_configFilter.begin(); it != m_configFilter.end(); it++)
  299. {
  300. if ( ((CStdString)pRule->Attribute("videodec")).Equals((*it)->GetXFilterName().c_str(),false) )
  301. Index: DSPlayer/Filters/EVRPresentEngine.cpp
  302. ===================================================================
  303. --- DSPlayer/Filters/EVRPresentEngine.cpp (revision 27111)
  304. +++ DSPlayer/Filters/EVRPresentEngine.cpp (working copy)
  305. @@ -185,12 +185,29 @@
  306. SAFE_DELETE(m_pVideoTexture);
  307.  
  308. m_pVideoTexture = new CD3DTexture();
  309. -
  310. +
  311. + D3DFORMAT d3dFormat;
  312. + GUID subtype = GUID_NULL;
  313. + /* Get D3DFORMAT from MEDIA_SubType*/
  314. +
  315. + pFormat->GetGUID(MF_MT_SUBTYPE, & subtype);
  316. +
  317. + if (subtype == MFVideoFormat_RGB565)
  318. + d3dFormat = D3DFMT_R5G6B5;
  319. + else if (subtype == MFVideoFormat_RGB555)
  320. + d3dFormat = D3DFMT_X1R5G5B5;
  321. + else if (subtype == MFVideoFormat_RGB24)
  322. + d3dFormat = D3DFMT_R8G8B8;
  323. + else if (subtype == MFVideoFormat_ARGB32)
  324. + d3dFormat = D3DFMT_A8R8G8B8;
  325. + else
  326. + d3dFormat = D3DFMT_X8R8G8B8;
  327. +
  328. if (!m_pVideoTexture->Create(m_iVideoWidth ,
  329. m_iVideoHeight ,
  330. 1 ,
  331. D3DUSAGE_RENDERTARGET,
  332. - D3DFMT_X8R8G8B8,
  333. + d3dFormat,
  334. D3DPOOL_DEFAULT))
  335. {
  336. CLog::Log(LOGERROR,"%s Error while creating the video texture",__FUNCTION__);
  337. @@ -206,7 +223,7 @@
  338. m_iVideoHeight ,
  339. 1 ,
  340. D3DUSAGE_RENDERTARGET ,
  341. - D3DFMT_X8R8G8B8 ,
  342. + d3dFormat ,
  343. D3DPOOL_DEFAULT ,
  344. &m_pInternalVideoTexture[i] ,
  345. NULL);
  346.  
Advertisement
Add Comment
Please, Sign In to add comment