Advertisement
Guest User

Seb

a guest
Jan 23rd, 2010
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.07 KB | None | 0 0
  1. Index: DSConfig.cpp
  2. ===================================================================
  3. --- DSConfig.cpp (revision 27106)
  4. +++ 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. @@ -138,32 +159,52 @@
  58. PIN_DIRECTION dir;
  59. AM_MEDIA_TYPE mediaType;
  60. int i = 0, j = 0;
  61. - CStdStringW pinName;
  62. + CStdStringW pinNameW;
  63. + CStdString pinName;
  64. IAMStreamSelectInfos *infos;
  65. bool pinConnected = FALSE;
  66. bool audioPinAlreadyConnected = FALSE, subtitlePinAlreadyConnected = FALSE;
  67. //the regex for removing the (audio #) in the name
  68. - CRegExp reAudioName(true);
  69. - reAudioName.RegComp("(.*?)(\\(audio.*?\\)\|\\(subtitle.*?\\))");
  70. + int nIn = 0, nOut = 0, nInC = 0, nOutC = 0;
  71. + DShowUtil::CountPins(m_pSplitter, nIn, nOut, nInC, nOutC);
  72. + CLog::Log(LOGDEBUG, "%s The splitter has %d output pins", __FUNCTION__, nOut);
  73.  
  74. BeginEnumPins(m_pSplitter, pEP, pPin)
  75. {
  76. if (SUCCEEDED(pPin->QueryDirection(&dir)) && ( dir == PINDIR_OUTPUT ))
  77. {
  78. - if (SUCCEEDED(pPin->ConnectionMediaType(&mediaType))
  79. - && ( mediaType.majortype == MEDIATYPE_Audio ))
  80. +
  81. + pinNameW = DShowUtil::GetPinName(pPin);
  82. + g_charsetConverter.wToUTF8(pinNameW, pinName);
  83. + CLog::Log(LOGDEBUG, "%s Output pin found : %s", __FUNCTION__, pinName.c_str());
  84. + ZeroMemory(&mediaType, sizeof(mediaType));
  85. +
  86. + if (SUCCEEDED(pPin->ConnectionMediaType(&mediaType)))
  87. {
  88. - pinName = DShowUtil::GetPinName(pPin);
  89. + CLog::Log(LOGDEBUG, "%s Output pin major type : %s", __FUNCTION__, GuidNames[mediaType.majortype]);
  90. + CLog::Log(LOGDEBUG, "%s Output pin sub type : %s", __FUNCTION__, GuidNames[mediaType.subtype]);
  91. + CLog::Log(LOGDEBUG, "%s Output pin format type : %s", __FUNCTION__, GuidNames[mediaType.formattype]);
  92. + } else {
  93. + CLog::Log(LOGDEBUG, "%s ConnectionMediaType failed", __FUNCTION__);
  94. + }
  95. +
  96. + if (mediaType.majortype == MEDIATYPE_Audio)
  97. + {
  98.  
  99. infos = new IAMStreamSelectInfos();
  100. infos->group = 0; infos->lcid = 0; infos->pObj = 0; infos->pUnk = 0; infos->flags = 0;
  101. pinConnected = FALSE;
  102.  
  103. - g_charsetConverter.wToUTF8(pinName, infos->name);
  104. - if ( reAudioName.RegFind(infos->name) > -1 )
  105. + infos->name = pinName;
  106. +
  107. + /* Apply regex */
  108. + for (std::vector<CRegExp *>::const_iterator it = regex.begin(); it != regex.end(); ++it)
  109. {
  110. - // "English, 3/2 (Audio 1)" should be renamed to "English, 3/2" - Treat also subtitles
  111. - infos->name = reAudioName.GetMatch(1);
  112. + if ( (*it)->RegFind(infos->name) > -1 )
  113. + {
  114. + infos->name = (*it)->GetMatch(1);
  115. + break;
  116. + }
  117. }
  118.  
  119. infos->pObj = pPin;
  120. @@ -202,10 +243,15 @@
  121. pinConnected = FALSE;
  122.  
  123. g_charsetConverter.wToUTF8(pinName, infos->name);
  124. - if ( reAudioName.RegFind(infos->name) > -1 )
  125. +
  126. + /* Apply regex */
  127. + for (std::vector<CRegExp *>::const_iterator it = regex.begin(); it != regex.end(); ++it)
  128. {
  129. - // "English, 3/2 (Audio 1)" should be renamed to "English, 3/2" - Treat also subtitles
  130. - infos->name = reAudioName.GetMatch(1);
  131. + if ( (*it)->RegFind(infos->name) > -1 )
  132. + {
  133. + infos->name = (*it)->GetMatch(1);
  134. + break;
  135. + }
  136. }
  137.  
  138. infos->pObj = pPin;
  139. @@ -240,6 +286,14 @@
  140. }
  141. EndEnumPins
  142. }
  143. +
  144. + /* Delete regex */
  145. + while (! regex.empty())
  146. + {
  147. + delete regex.back();
  148. + regex.pop_back();
  149. + }
  150. +
  151. return false;
  152. }
  153.  
  154. @@ -277,6 +331,8 @@
  155. if ( (*it).second->flags == AMSTREAMSELECTINFO_ENABLED)
  156. return i;
  157. }
  158. +
  159. + return -1;
  160. }
  161.  
  162. void CDSConfig::GetAudioStreamName(int iStream, CStdString &strStreamName)
  163. @@ -335,6 +391,8 @@
  164. if ( (*it).second->flags == AMSTREAMSELECTINFO_ENABLED)
  165. return i;
  166. }
  167. +
  168. + return -1;
  169. }
  170.  
  171. void CDSConfig::GetSubtitleName(int iStream, CStdString &strStreamName)
  172. Index: DSGraph.cpp
  173. ===================================================================
  174. --- DSGraph.cpp (revision 27106)
  175. +++ DSGraph.cpp (working copy)
  176. @@ -96,8 +96,7 @@
  177. hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pMediaControl),(void **)&m_pMediaControl);
  178. hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pMediaEvent),(void **)&m_pMediaEvent);
  179. hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pBasicAudio),(void **)&m_pBasicAudio);
  180. - hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pBasicVideo),(void **)&m_pBasicVideo);
  181. -
  182. + hr = m_pGraphBuilder->QueryInterface(__uuidof(m_pBasicVideo),(void **)&m_pBasicVideo);
  183.  
  184. LONGLONG tmestamp;
  185. tmestamp = CTimeUtils::GetTimeMS();
  186. Index: DSPlayer.cpp
  187. ===================================================================
  188. --- DSPlayer.cpp (revision 27106)
  189. +++ DSPlayer.cpp (working copy)
  190. @@ -43,7 +43,6 @@
  191. {
  192. m_hReadyEvent = CreateEvent(NULL, true, false, NULL);
  193. m_bAbortRequest = false;
  194. -
  195. }
  196.  
  197. CDSPlayer::~CDSPlayer()
  198.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement