pospass.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /*
  2. * Filter Seeking and Control Interfaces
  3. *
  4. * Copyright 2003 Robert Shearman
  5. * Copyright 2012 Aric Stewart, CodeWeavers
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  20. */
  21. /* FIXME: critical sections */
  22. #include "strmbase_private.h"
  23. WINE_DEFAULT_DEBUG_CHANNEL(quartz);
  24. static struct strmbase_passthrough *impl_from_ISeekingPassThru(ISeekingPassThru *iface)
  25. {
  26. return CONTAINING_RECORD(iface, struct strmbase_passthrough, ISeekingPassThru_iface);
  27. }
  28. static struct strmbase_passthrough *impl_from_IMediaSeeking(IMediaSeeking *iface)
  29. {
  30. return CONTAINING_RECORD(iface, struct strmbase_passthrough, IMediaSeeking_iface);
  31. }
  32. static struct strmbase_passthrough *impl_from_IMediaPosition(IMediaPosition *iface)
  33. {
  34. return CONTAINING_RECORD(iface, struct strmbase_passthrough, IMediaPosition_iface);
  35. }
  36. static HRESULT WINAPI SeekingPassThru_QueryInterface(ISeekingPassThru *iface, REFIID iid, void **out)
  37. {
  38. struct strmbase_passthrough *passthrough = impl_from_ISeekingPassThru(iface);
  39. return IUnknown_QueryInterface(passthrough->outer_unk, iid, out);
  40. }
  41. static ULONG WINAPI SeekingPassThru_AddRef(ISeekingPassThru *iface)
  42. {
  43. struct strmbase_passthrough *passthrough = impl_from_ISeekingPassThru(iface);
  44. return IUnknown_AddRef(passthrough->outer_unk);
  45. }
  46. static ULONG WINAPI SeekingPassThru_Release(ISeekingPassThru *iface)
  47. {
  48. struct strmbase_passthrough *passthrough = impl_from_ISeekingPassThru(iface);
  49. return IUnknown_Release(passthrough->outer_unk);
  50. }
  51. static HRESULT WINAPI SeekingPassThru_Init(ISeekingPassThru *iface, BOOL renderer, IPin *pin)
  52. {
  53. struct strmbase_passthrough *This = impl_from_ISeekingPassThru(iface);
  54. TRACE("(%p/%p)->(%d, %p)\n", This, iface, renderer, pin);
  55. if (This->pin)
  56. FIXME("Re-initializing?\n");
  57. This->renderer = renderer;
  58. This->pin = pin;
  59. return S_OK;
  60. }
  61. static const ISeekingPassThruVtbl ISeekingPassThru_Vtbl =
  62. {
  63. SeekingPassThru_QueryInterface,
  64. SeekingPassThru_AddRef,
  65. SeekingPassThru_Release,
  66. SeekingPassThru_Init
  67. };
  68. static HRESULT WINAPI MediaSeekingPassThru_QueryInterface(IMediaSeeking *iface, REFIID iid, void **out)
  69. {
  70. struct strmbase_passthrough *passthrough = impl_from_IMediaSeeking(iface);
  71. return IUnknown_QueryInterface(passthrough->outer_unk, iid, out);
  72. }
  73. static ULONG WINAPI MediaSeekingPassThru_AddRef(IMediaSeeking *iface)
  74. {
  75. struct strmbase_passthrough *passthrough = impl_from_IMediaSeeking(iface);
  76. return IUnknown_AddRef(passthrough->outer_unk);
  77. }
  78. static ULONG WINAPI MediaSeekingPassThru_Release(IMediaSeeking *iface)
  79. {
  80. struct strmbase_passthrough *passthrough = impl_from_IMediaSeeking(iface);
  81. return IUnknown_Release(passthrough->outer_unk);
  82. }
  83. static HRESULT get_connected(struct strmbase_passthrough *This, REFIID riid, void **ppvObj)
  84. {
  85. HRESULT hr;
  86. IPin *pin;
  87. *ppvObj = NULL;
  88. hr = IPin_ConnectedTo(This->pin, &pin);
  89. if (FAILED(hr))
  90. return VFW_E_NOT_CONNECTED;
  91. hr = IPin_QueryInterface(pin, riid, ppvObj);
  92. IPin_Release(pin);
  93. if (FAILED(hr))
  94. hr = E_NOTIMPL;
  95. return hr;
  96. }
  97. static HRESULT WINAPI MediaSeekingPassThru_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities)
  98. {
  99. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  100. IMediaSeeking *seek;
  101. HRESULT hr;
  102. TRACE("(%p/%p)->(%p)\n", iface, This, pCapabilities);
  103. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  104. if (SUCCEEDED(hr)) {
  105. hr = IMediaSeeking_GetCapabilities(seek, pCapabilities);
  106. IMediaSeeking_Release(seek);
  107. }
  108. else
  109. return E_NOTIMPL;
  110. return hr;
  111. }
  112. static HRESULT WINAPI MediaSeekingPassThru_CheckCapabilities(IMediaSeeking * iface, DWORD * pCapabilities)
  113. {
  114. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  115. IMediaSeeking *seek;
  116. HRESULT hr;
  117. TRACE("(%p/%p)->(%p)\n", iface, This, pCapabilities);
  118. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  119. if (SUCCEEDED(hr)) {
  120. hr = IMediaSeeking_CheckCapabilities(seek, pCapabilities);
  121. IMediaSeeking_Release(seek);
  122. }
  123. else
  124. return E_NOTIMPL;
  125. return hr;
  126. }
  127. static HRESULT WINAPI MediaSeekingPassThru_IsFormatSupported(IMediaSeeking * iface, const GUID * pFormat)
  128. {
  129. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  130. IMediaSeeking *seek;
  131. HRESULT hr;
  132. TRACE("(%p/%p)->(%s)\n", iface, This, debugstr_guid(pFormat));
  133. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  134. if (SUCCEEDED(hr)) {
  135. hr = IMediaSeeking_IsFormatSupported(seek, pFormat);
  136. IMediaSeeking_Release(seek);
  137. }
  138. else
  139. return E_NOTIMPL;
  140. return hr;
  141. }
  142. static HRESULT WINAPI MediaSeekingPassThru_QueryPreferredFormat(IMediaSeeking * iface, GUID * pFormat)
  143. {
  144. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  145. IMediaSeeking *seek;
  146. HRESULT hr;
  147. TRACE("(%p/%p)->(%p)\n", iface, This, pFormat);
  148. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  149. if (SUCCEEDED(hr)) {
  150. hr = IMediaSeeking_QueryPreferredFormat(seek, pFormat);
  151. IMediaSeeking_Release(seek);
  152. }
  153. else
  154. return E_NOTIMPL;
  155. return hr;
  156. }
  157. static HRESULT WINAPI MediaSeekingPassThru_GetTimeFormat(IMediaSeeking * iface, GUID * pFormat)
  158. {
  159. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  160. IMediaSeeking *seek;
  161. HRESULT hr;
  162. TRACE("(%p/%p)->(%p)\n", iface, This, pFormat);
  163. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  164. if (SUCCEEDED(hr)) {
  165. hr = IMediaSeeking_GetTimeFormat(seek, pFormat);
  166. IMediaSeeking_Release(seek);
  167. }
  168. else
  169. return E_NOTIMPL;
  170. return hr;
  171. }
  172. static HRESULT WINAPI MediaSeekingPassThru_IsUsingTimeFormat(IMediaSeeking * iface, const GUID * pFormat)
  173. {
  174. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  175. IMediaSeeking *seek;
  176. HRESULT hr;
  177. TRACE("(%p/%p)->(%s)\n", iface, This, debugstr_guid(pFormat));
  178. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  179. if (SUCCEEDED(hr)) {
  180. hr = IMediaSeeking_IsUsingTimeFormat(seek, pFormat);
  181. IMediaSeeking_Release(seek);
  182. }
  183. else
  184. return E_NOTIMPL;
  185. return hr;
  186. }
  187. static HRESULT WINAPI MediaSeekingPassThru_SetTimeFormat(IMediaSeeking * iface, const GUID * pFormat)
  188. {
  189. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  190. IMediaSeeking *seek;
  191. HRESULT hr;
  192. TRACE("(%p/%p)->(%s)\n", iface, This, debugstr_guid(pFormat));
  193. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  194. if (SUCCEEDED(hr)) {
  195. hr = IMediaSeeking_SetTimeFormat(seek, pFormat);
  196. IMediaSeeking_Release(seek);
  197. }
  198. else
  199. return E_NOTIMPL;
  200. return hr;
  201. }
  202. static HRESULT WINAPI MediaSeekingPassThru_GetDuration(IMediaSeeking * iface, LONGLONG * pDuration)
  203. {
  204. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  205. IMediaSeeking *seek;
  206. HRESULT hr;
  207. TRACE("(%p/%p)->(%p)\n", iface, This, pDuration);
  208. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  209. if (SUCCEEDED(hr)) {
  210. hr = IMediaSeeking_GetDuration(seek, pDuration);
  211. IMediaSeeking_Release(seek);
  212. }
  213. else
  214. return E_NOTIMPL;
  215. return hr;
  216. }
  217. static HRESULT WINAPI MediaSeekingPassThru_GetStopPosition(IMediaSeeking * iface, LONGLONG * pStop)
  218. {
  219. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  220. IMediaSeeking *seek;
  221. HRESULT hr;
  222. TRACE("(%p/%p)->(%p)\n", iface, This, pStop);
  223. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  224. if (SUCCEEDED(hr)) {
  225. hr = IMediaSeeking_GetStopPosition(seek, pStop);
  226. IMediaSeeking_Release(seek);
  227. }
  228. else
  229. return E_NOTIMPL;
  230. return hr;
  231. }
  232. static HRESULT WINAPI MediaSeekingPassThru_GetCurrentPosition(IMediaSeeking * iface, LONGLONG * pCurrent)
  233. {
  234. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  235. IMediaSeeking *seek;
  236. HRESULT hr = S_OK;
  237. TRACE("(%p/%p)->(%p)\n", iface, This, pCurrent);
  238. if (!pCurrent)
  239. return E_POINTER;
  240. EnterCriticalSection(&This->time_cs);
  241. if (This->timevalid)
  242. *pCurrent = This->time_earliest;
  243. else
  244. hr = E_FAIL;
  245. LeaveCriticalSection(&This->time_cs);
  246. if (SUCCEEDED(hr)) {
  247. hr = IMediaSeeking_ConvertTimeFormat(iface, pCurrent, NULL, *pCurrent, &TIME_FORMAT_MEDIA_TIME);
  248. return hr;
  249. }
  250. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  251. if (SUCCEEDED(hr)) {
  252. hr = IMediaSeeking_GetCurrentPosition(seek, pCurrent);
  253. IMediaSeeking_Release(seek);
  254. }
  255. else
  256. return E_NOTIMPL;
  257. return hr;
  258. }
  259. static HRESULT WINAPI MediaSeekingPassThru_ConvertTimeFormat(IMediaSeeking * iface, LONGLONG * pTarget, const GUID * pTargetFormat, LONGLONG Source, const GUID * pSourceFormat)
  260. {
  261. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  262. IMediaSeeking *seek;
  263. HRESULT hr;
  264. TRACE("(%p/%p)->(%p,%s,%x%08x,%s)\n", iface, This, pTarget, debugstr_guid(pTargetFormat), (DWORD)(Source>>32), (DWORD)Source, debugstr_guid(pSourceFormat));
  265. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  266. if (SUCCEEDED(hr)) {
  267. hr = IMediaSeeking_ConvertTimeFormat(seek, pTarget, pTargetFormat, Source, pSourceFormat);
  268. IMediaSeeking_Release(seek);
  269. }
  270. else
  271. return E_NOTIMPL;
  272. return hr;
  273. }
  274. static HRESULT WINAPI MediaSeekingPassThru_SetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, DWORD dwCurrentFlags, LONGLONG * pStop, DWORD dwStopFlags)
  275. {
  276. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  277. IMediaSeeking *seek;
  278. HRESULT hr;
  279. TRACE("(%p/%p)->(%p,%x,%p,%x)\n", iface, This, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
  280. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  281. if (SUCCEEDED(hr)) {
  282. hr = IMediaSeeking_SetPositions(seek, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
  283. IMediaSeeking_Release(seek);
  284. } else if (hr == VFW_E_NOT_CONNECTED)
  285. hr = S_OK;
  286. return hr;
  287. }
  288. static HRESULT WINAPI MediaSeekingPassThru_GetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, LONGLONG * pStop)
  289. {
  290. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  291. IMediaSeeking *seek;
  292. HRESULT hr;
  293. TRACE("(%p/%p)->(%p, %p)\n", iface, This, pCurrent, pStop);
  294. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  295. if (SUCCEEDED(hr)) {
  296. hr = IMediaSeeking_GetPositions(seek, pCurrent, pStop);
  297. IMediaSeeking_Release(seek);
  298. }
  299. else
  300. return E_NOTIMPL;
  301. return hr;
  302. }
  303. static HRESULT WINAPI MediaSeekingPassThru_GetAvailable(IMediaSeeking * iface, LONGLONG * pEarliest, LONGLONG * pLatest)
  304. {
  305. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  306. IMediaSeeking *seek;
  307. HRESULT hr;
  308. TRACE("(%p/%p)->(%p,%p)\n", iface, This, pEarliest, pLatest);
  309. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  310. if (SUCCEEDED(hr)) {
  311. hr = IMediaSeeking_GetAvailable(seek, pEarliest, pLatest);
  312. IMediaSeeking_Release(seek);
  313. }
  314. else
  315. return E_NOTIMPL;
  316. return hr;
  317. }
  318. static HRESULT WINAPI MediaSeekingPassThru_SetRate(IMediaSeeking * iface, double dRate)
  319. {
  320. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  321. IMediaSeeking *seek;
  322. HRESULT hr;
  323. TRACE("(%p/%p)->(%e)\n", iface, This, dRate);
  324. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  325. if (SUCCEEDED(hr)) {
  326. hr = IMediaSeeking_SetRate(seek, dRate);
  327. IMediaSeeking_Release(seek);
  328. }
  329. else
  330. return E_NOTIMPL;
  331. return hr;
  332. }
  333. static HRESULT WINAPI MediaSeekingPassThru_GetRate(IMediaSeeking * iface, double * dRate)
  334. {
  335. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  336. IMediaSeeking *seek;
  337. HRESULT hr;
  338. TRACE("(%p/%p)->(%p)\n", iface, This, dRate);
  339. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  340. if (SUCCEEDED(hr)) {
  341. hr = IMediaSeeking_GetRate(seek, dRate);
  342. IMediaSeeking_Release(seek);
  343. }
  344. else
  345. return E_NOTIMPL;
  346. return hr;
  347. }
  348. static HRESULT WINAPI MediaSeekingPassThru_GetPreroll(IMediaSeeking * iface, LONGLONG * pPreroll)
  349. {
  350. struct strmbase_passthrough *This = impl_from_IMediaSeeking(iface);
  351. IMediaSeeking *seek;
  352. HRESULT hr;
  353. TRACE("(%p)\n", pPreroll);
  354. hr = get_connected(This, &IID_IMediaSeeking, (LPVOID*)&seek);
  355. if (SUCCEEDED(hr)) {
  356. hr = IMediaSeeking_GetPreroll(seek, pPreroll);
  357. IMediaSeeking_Release(seek);
  358. }
  359. else
  360. return E_NOTIMPL;
  361. return hr;
  362. }
  363. static const IMediaSeekingVtbl IMediaSeekingPassThru_Vtbl =
  364. {
  365. MediaSeekingPassThru_QueryInterface,
  366. MediaSeekingPassThru_AddRef,
  367. MediaSeekingPassThru_Release,
  368. MediaSeekingPassThru_GetCapabilities,
  369. MediaSeekingPassThru_CheckCapabilities,
  370. MediaSeekingPassThru_IsFormatSupported,
  371. MediaSeekingPassThru_QueryPreferredFormat,
  372. MediaSeekingPassThru_GetTimeFormat,
  373. MediaSeekingPassThru_IsUsingTimeFormat,
  374. MediaSeekingPassThru_SetTimeFormat,
  375. MediaSeekingPassThru_GetDuration,
  376. MediaSeekingPassThru_GetStopPosition,
  377. MediaSeekingPassThru_GetCurrentPosition,
  378. MediaSeekingPassThru_ConvertTimeFormat,
  379. MediaSeekingPassThru_SetPositions,
  380. MediaSeekingPassThru_GetPositions,
  381. MediaSeekingPassThru_GetAvailable,
  382. MediaSeekingPassThru_SetRate,
  383. MediaSeekingPassThru_GetRate,
  384. MediaSeekingPassThru_GetPreroll
  385. };
  386. static HRESULT WINAPI MediaPositionPassThru_QueryInterface(IMediaPosition *iface, REFIID iid, void **out)
  387. {
  388. struct strmbase_passthrough *passthrough = impl_from_IMediaPosition(iface);
  389. return IUnknown_QueryInterface(passthrough->outer_unk, iid, out);
  390. }
  391. static ULONG WINAPI MediaPositionPassThru_AddRef(IMediaPosition *iface)
  392. {
  393. struct strmbase_passthrough *passthrough = impl_from_IMediaPosition(iface);
  394. return IUnknown_AddRef(passthrough->outer_unk);
  395. }
  396. static ULONG WINAPI MediaPositionPassThru_Release(IMediaPosition *iface)
  397. {
  398. struct strmbase_passthrough *passthrough = impl_from_IMediaPosition(iface);
  399. return IUnknown_Release(passthrough->outer_unk);
  400. }
  401. static HRESULT WINAPI MediaPositionPassThru_GetTypeInfoCount(IMediaPosition *iface, UINT *count)
  402. {
  403. TRACE("iface %p, count %p.\n", iface, count);
  404. *count = 1;
  405. return S_OK;
  406. }
  407. static HRESULT WINAPI MediaPositionPassThru_GetTypeInfo(IMediaPosition *iface, UINT index,
  408. LCID lcid, ITypeInfo **typeinfo)
  409. {
  410. TRACE("iface %p, index %u, lcid %#x, typeinfo %p.\n", iface, index, lcid, typeinfo);
  411. return strmbase_get_typeinfo(IMediaPosition_tid, typeinfo);
  412. }
  413. static HRESULT WINAPI MediaPositionPassThru_GetIDsOfNames(IMediaPosition *iface, REFIID iid,
  414. LPOLESTR *names, UINT count, LCID lcid, DISPID *ids)
  415. {
  416. ITypeInfo *typeinfo;
  417. HRESULT hr;
  418. TRACE("iface %p, iid %s, names %p, count %u, lcid %#x, ids %p.\n",
  419. iface, debugstr_guid(iid), names, count, lcid, ids);
  420. if (SUCCEEDED(hr = strmbase_get_typeinfo(IMediaPosition_tid, &typeinfo)))
  421. {
  422. hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, ids);
  423. ITypeInfo_Release(typeinfo);
  424. }
  425. return hr;
  426. }
  427. static HRESULT WINAPI MediaPositionPassThru_Invoke(IMediaPosition *iface, DISPID id, REFIID iid, LCID lcid,
  428. WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *error_arg)
  429. {
  430. ITypeInfo *typeinfo;
  431. HRESULT hr;
  432. TRACE("iface %p, id %d, iid %s, lcid %#x, flags %#x, params %p, result %p, excepinfo %p, error_arg %p.\n",
  433. iface, id, debugstr_guid(iid), lcid, flags, params, result, excepinfo, error_arg);
  434. if (SUCCEEDED(hr = strmbase_get_typeinfo(IMediaPosition_tid, &typeinfo)))
  435. {
  436. hr = ITypeInfo_Invoke(typeinfo, iface, id, flags, params, result, excepinfo, error_arg);
  437. ITypeInfo_Release(typeinfo);
  438. }
  439. return hr;
  440. }
  441. static HRESULT WINAPI MediaPositionPassThru_get_Duration(IMediaPosition *iface, REFTIME *plength)
  442. {
  443. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  444. IMediaPosition *pos;
  445. HRESULT hr;
  446. TRACE("(%p)\n", plength);
  447. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  448. if (SUCCEEDED(hr)) {
  449. hr = IMediaPosition_get_Duration(pos, plength);
  450. IMediaPosition_Release(pos);
  451. }
  452. else
  453. return E_NOTIMPL;
  454. return hr;
  455. }
  456. static HRESULT WINAPI MediaPositionPassThru_put_CurrentPosition(IMediaPosition *iface, REFTIME llTime)
  457. {
  458. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  459. IMediaPosition *pos;
  460. HRESULT hr;
  461. TRACE("iface %p, time %.16e.\n", iface, llTime);
  462. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  463. if (SUCCEEDED(hr)) {
  464. hr = IMediaPosition_put_CurrentPosition(pos, llTime);
  465. IMediaPosition_Release(pos);
  466. }
  467. else
  468. return E_NOTIMPL;
  469. return hr;
  470. }
  471. static HRESULT WINAPI MediaPositionPassThru_get_CurrentPosition(IMediaPosition *iface, REFTIME *pllTime)
  472. {
  473. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  474. IMediaPosition *pos;
  475. HRESULT hr;
  476. TRACE("(%p)\n", pllTime);
  477. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  478. if (SUCCEEDED(hr)) {
  479. hr = IMediaPosition_get_CurrentPosition(pos, pllTime);
  480. IMediaPosition_Release(pos);
  481. }
  482. else
  483. return E_NOTIMPL;
  484. return hr;
  485. }
  486. static HRESULT WINAPI MediaPositionPassThru_get_StopTime(IMediaPosition *iface, REFTIME *pllTime)
  487. {
  488. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  489. IMediaPosition *pos;
  490. HRESULT hr;
  491. TRACE("(%p)\n", pllTime);
  492. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  493. if (SUCCEEDED(hr)) {
  494. hr = IMediaPosition_get_StopTime(pos, pllTime);
  495. IMediaPosition_Release(pos);
  496. }
  497. else
  498. return E_NOTIMPL;
  499. return hr;
  500. }
  501. static HRESULT WINAPI MediaPositionPassThru_put_StopTime(IMediaPosition *iface, REFTIME llTime)
  502. {
  503. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  504. IMediaPosition *pos;
  505. HRESULT hr;
  506. TRACE("iface %p, time %.16e.\n", iface, llTime);
  507. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  508. if (SUCCEEDED(hr)) {
  509. hr = IMediaPosition_put_StopTime(pos, llTime);
  510. IMediaPosition_Release(pos);
  511. }
  512. else
  513. return E_NOTIMPL;
  514. return hr;
  515. }
  516. static HRESULT WINAPI MediaPositionPassThru_get_PrerollTime(IMediaPosition *iface, REFTIME *pllTime)
  517. {
  518. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  519. IMediaPosition *pos;
  520. HRESULT hr;
  521. TRACE("(%p)\n", pllTime);
  522. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  523. if (SUCCEEDED(hr)) {
  524. hr = IMediaPosition_get_PrerollTime(pos, pllTime);
  525. IMediaPosition_Release(pos);
  526. }
  527. else
  528. return E_NOTIMPL;
  529. return hr;
  530. }
  531. static HRESULT WINAPI MediaPositionPassThru_put_PrerollTime(IMediaPosition *iface, REFTIME llTime)
  532. {
  533. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  534. IMediaPosition *pos;
  535. HRESULT hr;
  536. TRACE("iface %p, time %.16e.\n", iface, llTime);
  537. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  538. if (SUCCEEDED(hr)) {
  539. hr = IMediaPosition_put_PrerollTime(pos, llTime);
  540. IMediaPosition_Release(pos);
  541. }
  542. else
  543. return E_NOTIMPL;
  544. return hr;
  545. }
  546. static HRESULT WINAPI MediaPositionPassThru_put_Rate(IMediaPosition *iface, double dRate)
  547. {
  548. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  549. IMediaPosition *pos;
  550. HRESULT hr;
  551. TRACE("(%f)\n", dRate);
  552. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  553. if (SUCCEEDED(hr)) {
  554. hr = IMediaPosition_put_Rate(pos, dRate);
  555. IMediaPosition_Release(pos);
  556. }
  557. else
  558. return E_NOTIMPL;
  559. return hr;
  560. }
  561. static HRESULT WINAPI MediaPositionPassThru_get_Rate(IMediaPosition *iface, double *pdRate)
  562. {
  563. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  564. IMediaPosition *pos;
  565. HRESULT hr;
  566. TRACE("(%p)\n", pdRate);
  567. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  568. if (SUCCEEDED(hr)) {
  569. hr = IMediaPosition_get_Rate(pos, pdRate);
  570. IMediaPosition_Release(pos);
  571. }
  572. else
  573. return E_NOTIMPL;
  574. return hr;
  575. }
  576. static HRESULT WINAPI MediaPositionPassThru_CanSeekForward(IMediaPosition *iface, LONG *pCanSeekForward)
  577. {
  578. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  579. IMediaPosition *pos;
  580. HRESULT hr;
  581. TRACE("(%p)\n", pCanSeekForward);
  582. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  583. if (SUCCEEDED(hr)) {
  584. hr = IMediaPosition_CanSeekForward(pos, pCanSeekForward);
  585. IMediaPosition_Release(pos);
  586. }
  587. else
  588. return E_NOTIMPL;
  589. return hr;
  590. }
  591. static HRESULT WINAPI MediaPositionPassThru_CanSeekBackward(IMediaPosition *iface, LONG *pCanSeekBackward)
  592. {
  593. struct strmbase_passthrough *This = impl_from_IMediaPosition(iface);
  594. IMediaPosition *pos;
  595. HRESULT hr;
  596. TRACE("(%p)\n", pCanSeekBackward);
  597. hr = get_connected(This, &IID_IMediaPosition, (LPVOID*)&pos);
  598. if (SUCCEEDED(hr)) {
  599. hr = IMediaPosition_CanSeekBackward(pos, pCanSeekBackward);
  600. IMediaPosition_Release(pos);
  601. }
  602. else
  603. return E_NOTIMPL;
  604. return hr;
  605. }
  606. static const IMediaPositionVtbl IMediaPositionPassThru_Vtbl =
  607. {
  608. MediaPositionPassThru_QueryInterface,
  609. MediaPositionPassThru_AddRef,
  610. MediaPositionPassThru_Release,
  611. MediaPositionPassThru_GetTypeInfoCount,
  612. MediaPositionPassThru_GetTypeInfo,
  613. MediaPositionPassThru_GetIDsOfNames,
  614. MediaPositionPassThru_Invoke,
  615. MediaPositionPassThru_get_Duration,
  616. MediaPositionPassThru_put_CurrentPosition,
  617. MediaPositionPassThru_get_CurrentPosition,
  618. MediaPositionPassThru_get_StopTime,
  619. MediaPositionPassThru_put_StopTime,
  620. MediaPositionPassThru_get_PrerollTime,
  621. MediaPositionPassThru_put_PrerollTime,
  622. MediaPositionPassThru_put_Rate,
  623. MediaPositionPassThru_get_Rate,
  624. MediaPositionPassThru_CanSeekForward,
  625. MediaPositionPassThru_CanSeekBackward
  626. };
  627. void strmbase_passthrough_init(struct strmbase_passthrough *passthrough, IUnknown *outer)
  628. {
  629. memset(passthrough, 0, sizeof(*passthrough));
  630. passthrough->outer_unk = outer;
  631. passthrough->IMediaPosition_iface.lpVtbl = &IMediaPositionPassThru_Vtbl;
  632. passthrough->IMediaSeeking_iface.lpVtbl = &IMediaSeekingPassThru_Vtbl;
  633. passthrough->ISeekingPassThru_iface.lpVtbl = &ISeekingPassThru_Vtbl;
  634. InitializeCriticalSection(&passthrough->time_cs);
  635. passthrough->time_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": strmbase_passthrough.time_cs" );
  636. }
  637. void strmbase_passthrough_cleanup(struct strmbase_passthrough *passthrough)
  638. {
  639. passthrough->time_cs.DebugInfo->Spare[0] = 0;
  640. DeleteCriticalSection(&passthrough->time_cs);
  641. }
  642. void strmbase_passthrough_update_time(struct strmbase_passthrough *passthrough, REFERENCE_TIME time)
  643. {
  644. EnterCriticalSection(&passthrough->time_cs);
  645. passthrough->time_earliest = time;
  646. passthrough->timevalid = TRUE;
  647. LeaveCriticalSection(&passthrough->time_cs);
  648. }
  649. void strmbase_passthrough_invalidate_time(struct strmbase_passthrough *passthrough)
  650. {
  651. EnterCriticalSection(&passthrough->time_cs);
  652. passthrough->timevalid = FALSE;
  653. LeaveCriticalSection(&passthrough->time_cs);
  654. }
  655. void strmbase_passthrough_eos(struct strmbase_passthrough *passthrough)
  656. {
  657. REFERENCE_TIME time;
  658. HRESULT hr;
  659. hr = IMediaSeeking_GetStopPosition(&passthrough->IMediaSeeking_iface, &time);
  660. EnterCriticalSection(&passthrough->time_cs);
  661. if (SUCCEEDED(hr))
  662. {
  663. passthrough->timevalid = TRUE;
  664. passthrough->time_earliest = time;
  665. }
  666. else
  667. passthrough->timevalid = FALSE;
  668. LeaveCriticalSection(&passthrough->time_cs);
  669. }