Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

938 lines
20 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: vcdplyer.cpp
  3. *
  4. * A simple Video CD player
  5. *
  6. *
  7. * Created: 30-10-95
  8. * Author: Stephen Estrop [StephenE]
  9. *
  10. * Copyright (c) 1994 - 1999 Microsoft Corporation. All Rights Reserved.
  11. \**************************************************************************/
  12. #include <streams.h>
  13. #include <mmreg.h>
  14. #include <commctrl.h>
  15. #include "project.h"
  16. #include "mpgcodec.h"
  17. #include <stdarg.h>
  18. #include <stdio.h>
  19. /******************************Public*Routine******************************\
  20. * CMpegMovie
  21. *
  22. * Constructors and destructors
  23. *
  24. * History:
  25. * 30-10-95 - StephenE - Created
  26. *
  27. \**************************************************************************/
  28. CMpegMovie::CMpegMovie(HWND hwndApplication)
  29. : m_hwndApp(hwndApplication),
  30. m_MediaEvent(NULL),
  31. m_Mode(MOVIE_NOTOPENED),
  32. m_Fg(NULL),
  33. m_Gb(NULL),
  34. m_Mc(NULL),
  35. m_Ms(NULL),
  36. m_Me(NULL),
  37. m_Vw(NULL),
  38. m_pStreamSelect(NULL),
  39. m_bFullScreen(FALSE),
  40. pMpegDecoder(NULL),
  41. pMpegAudioDecoder(NULL),
  42. pVideoRenderer(NULL),
  43. m_TimeFormat(TIME_FORMAT_MEDIA_TIME)
  44. {}
  45. CMpegMovie::~CMpegMovie() {}
  46. /******************************Public*Routine******************************\
  47. * OpenMovie
  48. *
  49. *
  50. *
  51. * History:
  52. * 30-10-95 - StephenE - Created
  53. *
  54. \**************************************************************************/
  55. HRESULT
  56. CMpegMovie::OpenMovie(
  57. TCHAR *lpFileName
  58. )
  59. {
  60. IUnknown *pUnk;
  61. HRESULT hres;
  62. WCHAR FileName[MAX_PATH];
  63. #ifdef UNICODE
  64. lstrcpy(FileName, lpFileName);
  65. #else
  66. swprintf(FileName, L"%hs", lpFileName);
  67. #endif
  68. hres = CoInitialize(NULL);
  69. if (hres == S_FALSE) {
  70. CoUninitialize();
  71. }
  72. hres = CoCreateInstance(
  73. g_bUseThreadedGraph ?
  74. CLSID_FilterGraph :
  75. CLSID_FilterGraphNoThread,
  76. NULL,
  77. CLSCTX_INPROC,
  78. IID_IUnknown,
  79. (LPVOID *)&pUnk);
  80. if (SUCCEEDED(hres)) {
  81. m_Mode = MOVIE_OPENED;
  82. hres = pUnk->QueryInterface(IID_IFilterGraph, (LPVOID *)&m_Fg);
  83. if (FAILED(hres)) {
  84. pUnk->Release();
  85. return hres;
  86. }
  87. hres = pUnk->QueryInterface(IID_IGraphBuilder, (LPVOID *)&m_Gb);
  88. if (FAILED(hres)) {
  89. pUnk->Release();
  90. m_Fg->Release(); m_Fg = NULL;
  91. return hres;
  92. }
  93. if (hRenderLog!=INVALID_HANDLE_VALUE) {
  94. m_Gb->SetLogFile((DWORD_PTR) hRenderLog);
  95. }
  96. hres = m_Gb->RenderFile(FileName, NULL);
  97. if (FAILED(hres)) {
  98. pUnk->Release();
  99. m_Fg->Release(); m_Fg = NULL;
  100. m_Gb->Release(); m_Gb = NULL;
  101. return hres;
  102. }
  103. if (hRenderLog!=INVALID_HANDLE_VALUE) {
  104. CloseHandle(hRenderLog);
  105. hRenderLog = INVALID_HANDLE_VALUE;
  106. }
  107. hres = pUnk->QueryInterface(IID_IMediaControl, (LPVOID *)&m_Mc);
  108. if (FAILED(hres)) {
  109. pUnk->Release();
  110. m_Fg->Release(); m_Fg = NULL;
  111. m_Gb->Release(); m_Gb = NULL;
  112. return hres;
  113. }
  114. //
  115. // Not being able to get the IMediaEvent interface does
  116. // necessarly mean that we can't play the graph.
  117. //
  118. pUnk->QueryInterface(IID_IMediaEvent, (LPVOID *)&m_Me);
  119. GetMovieEventHandle();
  120. pUnk->QueryInterface(IID_IMediaSeeking, (LPVOID *)&m_Ms);
  121. GetPerformanceInterfaces();
  122. if (SUCCEEDED(pUnk->QueryInterface(IID_IVideoWindow, (LPVOID *)&m_Vw))) {
  123. m_Vw->put_Caption(FileName);
  124. m_Vw->put_AutoShow(0);
  125. }
  126. hres = FindInterfaceFromFilterGraph(IID_IAMStreamSelect, (LPVOID *)&m_pStreamSelect);
  127. if (SUCCEEDED(hres)) {
  128. DWORD cStreams;
  129. m_pStreamSelect->Count(&cStreams);
  130. DWORD i;
  131. int iMenuItemsAdded = 0;
  132. HMENU hmenu = GetMenu(m_hwndApp);
  133. hmenu = GetSubMenu(hmenu, 3);
  134. RemoveMenu(hmenu, 0, MF_BYPOSITION);
  135. DWORD dwLastGroup;
  136. for (i = 0; i < cStreams; i++) {
  137. WCHAR *pwszName;
  138. DWORD dwGroup;
  139. DWORD dwFlags;
  140. m_pStreamSelect->Info(i, NULL, &dwFlags, NULL, &dwGroup, &pwszName, NULL, NULL);
  141. if (iMenuItemsAdded > 0 && dwGroup != dwLastGroup)
  142. InsertMenu(hmenu, iMenuItemsAdded++,
  143. MF_SEPARATOR | MF_BYPOSITION, -1, NULL);
  144. dwLastGroup = dwGroup;
  145. TCHAR ach[200];
  146. if (pwszName) {
  147. #ifndef UNICODE
  148. WideCharToMultiByte(CP_ACP,0,pwszName,-1,ach,200,NULL,NULL);
  149. CoTaskMemFree(pwszName);
  150. #else
  151. lstrcpyW(ach, pwszName);
  152. #endif
  153. } else {
  154. wsprintf(ach, TEXT("Stream %d"), i);
  155. }
  156. DWORD dwMenuFlags = MF_STRING | MF_BYPOSITION;
  157. if (dwFlags & AMSTREAMSELECTINFO_ENABLED)
  158. dwMenuFlags |= MF_CHECKED;
  159. InsertMenu(hmenu, iMenuItemsAdded++, dwMenuFlags, 2000+i, ach);
  160. }
  161. }
  162. pUnk->Release();
  163. return S_OK;
  164. }
  165. else {
  166. m_Fg = NULL;
  167. }
  168. return hres;
  169. }
  170. /******************************Public*Routine******************************\
  171. * CloseMovie
  172. *
  173. *
  174. *
  175. * History:
  176. * 30-10-95 - StephenE - Created
  177. *
  178. \**************************************************************************/
  179. DWORD
  180. CMpegMovie::CloseMovie(
  181. )
  182. {
  183. m_Mode = MOVIE_NOTOPENED;
  184. m_bFullScreen = FALSE;
  185. if (m_Mc) {
  186. if (pMpegDecoder) {
  187. pMpegDecoder->Release();
  188. pMpegDecoder = NULL;
  189. }
  190. if (pMpegAudioDecoder) {
  191. pMpegAudioDecoder->Release();
  192. pMpegAudioDecoder = NULL;
  193. }
  194. if (pVideoRenderer) {
  195. pVideoRenderer->Release();
  196. pVideoRenderer = NULL;
  197. }
  198. if (m_Me) {
  199. m_MediaEvent = NULL;
  200. m_Me->Release();
  201. m_Me = NULL;
  202. }
  203. if (m_Ms) {
  204. m_Ms->Release();
  205. m_Ms = NULL;
  206. }
  207. if (m_Vw) {
  208. m_Vw->Release();
  209. m_Vw = NULL;
  210. }
  211. if (m_pStreamSelect) {
  212. HMENU hmenu = GetMenu(m_hwndApp);
  213. hmenu = GetSubMenu(hmenu, 3);
  214. while (RemoveMenu(hmenu, 0, MF_BYPOSITION));
  215. InsertMenu(hmenu, 0, MF_BYPOSITION | MF_STRING | MF_GRAYED,
  216. -1, TEXT("(not available)"));
  217. m_pStreamSelect->Release();
  218. m_pStreamSelect = NULL;
  219. }
  220. m_Mc->Release();
  221. m_Mc = NULL;
  222. if (m_Gb) {
  223. m_Gb->Release();
  224. m_Gb = NULL;
  225. }
  226. if (m_Fg) {
  227. m_Fg->Release();
  228. m_Fg = NULL;
  229. }
  230. }
  231. QzUninitialize();
  232. return 0L;
  233. }
  234. /******************************Public*Routine******************************\
  235. * GetMoviePosition
  236. *
  237. *
  238. *
  239. * History:
  240. * dd-mm-95 - StephenE - Created
  241. *
  242. \**************************************************************************/
  243. BOOL
  244. CMpegMovie::GetMoviePosition(
  245. LONG *x,
  246. LONG *y,
  247. LONG *cx,
  248. LONG *cy
  249. )
  250. {
  251. BOOL bRet = FALSE;
  252. if (m_Vw) {
  253. bRet = (m_Vw->GetWindowPosition(x, y, cx, cy) == S_OK);
  254. }
  255. return bRet;
  256. }
  257. /******************************Public*Routine******************************\
  258. * PutMoviePosition
  259. *
  260. *
  261. *
  262. * History:
  263. * dd-mm-95 - StephenE - Created
  264. *
  265. \**************************************************************************/
  266. BOOL
  267. CMpegMovie::PutMoviePosition(
  268. LONG x,
  269. LONG y,
  270. LONG cx,
  271. LONG cy
  272. )
  273. {
  274. BOOL bRet = FALSE;
  275. if (m_Vw) {
  276. bRet = (m_Vw->SetWindowPosition(x, y, cx, cy) == S_OK);
  277. }
  278. return bRet;
  279. }
  280. /******************************Public*Routine******************************\
  281. * SetMovieWindowState
  282. *
  283. *
  284. *
  285. * History:
  286. * dd-mm-95 - StephenE - Created
  287. *
  288. \**************************************************************************/
  289. BOOL
  290. CMpegMovie::SetMovieWindowState(
  291. long uState
  292. )
  293. {
  294. return SUCCEEDED(m_Vw->put_WindowState(uState));
  295. }
  296. /******************************Public*Routine******************************\
  297. * SetWindowForeground
  298. *
  299. *
  300. *
  301. * History:
  302. * dd-mm-95 - Anthonyp - Created
  303. *
  304. \**************************************************************************/
  305. BOOL
  306. CMpegMovie::SetWindowForeground(
  307. long Focus
  308. )
  309. {
  310. return SUCCEEDED(m_Vw->SetWindowForeground(Focus));
  311. }
  312. /******************************Public*Routine******************************\
  313. * GetMovieWindowState
  314. *
  315. *
  316. *
  317. * History:
  318. * dd-mm-95 - StephenE - Created
  319. *
  320. \**************************************************************************/
  321. BOOL
  322. CMpegMovie::GetMovieWindowState(
  323. long *lpuState
  324. )
  325. {
  326. return S_OK == m_Vw->get_WindowState(lpuState);
  327. }
  328. /******************************Public*Routine******************************\
  329. * PlayMovie
  330. *
  331. *
  332. *
  333. * History:
  334. * 30-10-95 - StephenE - Created
  335. *
  336. \**************************************************************************/
  337. BOOL
  338. CMpegMovie::PlayMovie(
  339. )
  340. {
  341. REFTIME rt;
  342. REFTIME rtAbs;
  343. REFTIME rtDur;
  344. rt = GetCurrentPosition();
  345. rtDur = GetDuration();
  346. //
  347. // If we are near the end of the movie seek to the start, otherwise
  348. // stay where we are.
  349. //
  350. rtAbs = rt - rtDur;
  351. if (rtAbs < (REFTIME)0) {
  352. rtAbs = -rtAbs;
  353. }
  354. if (rtAbs < (REFTIME)1) {
  355. SeekToPosition((REFTIME)0,FALSE);
  356. }
  357. //
  358. // Start playing from the begining of the movie
  359. //
  360. if (pMpegDecoder) {
  361. pMpegDecoder->ResetFrameStatistics();
  362. }
  363. if (m_Vw) {
  364. long lVis;
  365. m_Vw->get_Visible(&lVis);
  366. if (lVis == OAFALSE) {
  367. m_Vw->put_Visible(OATRUE);
  368. }
  369. }
  370. //
  371. // Change mode after setting m_Mode but before starting the graph
  372. //
  373. m_Mode = MOVIE_PLAYING;
  374. SetFullScreenMode(m_bFullScreen);
  375. m_Mc->Run();
  376. return TRUE;
  377. }
  378. /******************************Public*Routine******************************\
  379. * PauseMovie
  380. *
  381. *
  382. *
  383. * History:
  384. * 30-10-95 - StephenE - Created
  385. *
  386. \**************************************************************************/
  387. BOOL
  388. CMpegMovie::PauseMovie(
  389. )
  390. {
  391. m_Mode = MOVIE_PAUSED;
  392. m_Mc->Pause();
  393. return TRUE;
  394. }
  395. /******************************Public*Routine******************************\
  396. * GetStateMovie
  397. *
  398. *
  399. *
  400. * History:
  401. * 15-04-96 - AnthonyP - Created
  402. *
  403. \**************************************************************************/
  404. OAFilterState
  405. CMpegMovie::GetStateMovie(
  406. )
  407. {
  408. OAFilterState State;
  409. m_Mc->GetState(INFINITE,&State);
  410. return State;
  411. }
  412. /******************************Public*Routine******************************\
  413. * StopMovie
  414. *
  415. *
  416. *
  417. * History:
  418. * dd-mm-95 - StephenE - Created
  419. *
  420. \**************************************************************************/
  421. BOOL
  422. CMpegMovie::StopMovie(
  423. )
  424. {
  425. m_Mode = MOVIE_STOPPED;
  426. m_Mc->Stop();
  427. return TRUE;
  428. }
  429. /******************************Public*Routine******************************\
  430. * StatusMovie
  431. *
  432. *
  433. *
  434. * History:
  435. * 30-10-95 - StephenE - Created
  436. *
  437. \**************************************************************************/
  438. EMpegMovieMode
  439. CMpegMovie::StatusMovie(
  440. )
  441. {
  442. if (m_Mc) {
  443. FILTER_STATE fs;
  444. HRESULT hr;
  445. hr = m_Mc->GetState(100, (OAFilterState *)&fs);
  446. // Don't know what the state is so just stay at old state.
  447. if (hr == VFW_S_STATE_INTERMEDIATE) {
  448. return m_Mode;
  449. }
  450. switch (fs) {
  451. case State_Stopped:
  452. m_Mode = MOVIE_STOPPED;
  453. break;
  454. case State_Paused:
  455. m_Mode = MOVIE_PAUSED;
  456. break;
  457. case State_Running:
  458. m_Mode = MOVIE_PLAYING;
  459. break;
  460. }
  461. }
  462. return m_Mode;
  463. }
  464. /******************************Public*Routine******************************\
  465. * GetMediaEventHandle
  466. *
  467. * Returns the IMediaEvent event hamdle for the filter graph iff the
  468. * filter graph exists.
  469. *
  470. * History:
  471. * 30-10-95 - StephenE - Created
  472. *
  473. \**************************************************************************/
  474. HANDLE
  475. CMpegMovie::GetMovieEventHandle(
  476. )
  477. {
  478. HRESULT hr;
  479. if (m_Me != NULL) {
  480. if ( m_MediaEvent == NULL) {
  481. hr = m_Me->GetEventHandle((OAEVENT *)&m_MediaEvent);
  482. }
  483. }
  484. else {
  485. m_MediaEvent = NULL;
  486. }
  487. return m_MediaEvent;
  488. }
  489. /******************************Public*Routine******************************\
  490. * GetMovieEventCode
  491. *
  492. *
  493. *
  494. * History:
  495. * 30-10-95 - StephenE - Created
  496. *
  497. \**************************************************************************/
  498. long
  499. CMpegMovie::GetMovieEventCode()
  500. {
  501. HRESULT hr;
  502. long lEventCode;
  503. LONG_PTR lParam1, lParam2;
  504. if (m_Me != NULL) {
  505. hr = m_Me->GetEvent(&lEventCode, &lParam1, &lParam2, 0);
  506. if (SUCCEEDED(hr)) {
  507. return lEventCode;
  508. }
  509. }
  510. return 0L;
  511. }
  512. /******************************Public*Routine******************************\
  513. * GetDuration
  514. *
  515. * Returns the duration of the current movie
  516. *
  517. * History:
  518. * 30-10-95 - StephenE - Created
  519. *
  520. \**************************************************************************/
  521. REFTIME
  522. CMpegMovie::GetDuration()
  523. {
  524. HRESULT hr;
  525. LONGLONG Duration;
  526. // Should we seek using IMediaSelection
  527. if (m_TimeFormat != TIME_FORMAT_MEDIA_TIME) {
  528. hr = m_Ms->GetDuration(&Duration);
  529. if (SUCCEEDED(hr)) {
  530. return double(Duration);
  531. }
  532. } else if (m_Ms != NULL) {
  533. hr = m_Ms->GetDuration(&Duration);
  534. if (SUCCEEDED(hr)) {
  535. return double(Duration) / UNITS;
  536. }
  537. }
  538. return 0;
  539. }
  540. /******************************Public*Routine******************************\
  541. * GetCurrentPosition
  542. *
  543. * Returns the duration of the current movie
  544. *
  545. * History:
  546. * 30-10-95 - StephenE - Created
  547. *
  548. \**************************************************************************/
  549. REFTIME
  550. CMpegMovie::GetCurrentPosition()
  551. {
  552. REFTIME rt = (REFTIME)0;
  553. HRESULT hr;
  554. LONGLONG Position;
  555. // Should we return a media position
  556. if (m_TimeFormat != TIME_FORMAT_MEDIA_TIME) {
  557. hr = m_Ms->GetPositions(&Position, NULL);
  558. if (SUCCEEDED(hr)) {
  559. return double(Position);
  560. }
  561. } else if (m_Ms != NULL) {
  562. hr = m_Ms->GetPositions(&Position, NULL);
  563. if (SUCCEEDED(hr)) {
  564. return double(Position) / UNITS;
  565. }
  566. }
  567. return rt;
  568. }
  569. /*****************************Private*Routine******************************\
  570. * SeekToPosition
  571. *
  572. *
  573. *
  574. * History:
  575. * 30-10-95 - StephenE - Created
  576. *
  577. \**************************************************************************/
  578. BOOL
  579. CMpegMovie::SeekToPosition(
  580. REFTIME rt,
  581. BOOL bFlushData
  582. )
  583. {
  584. HRESULT hr;
  585. LONGLONG llTime = LONGLONG( m_TimeFormat == TIME_FORMAT_MEDIA_TIME ? rt * double(UNITS) : rt );
  586. if (m_Ms != NULL) {
  587. FILTER_STATE fs;
  588. m_Mc->GetState(100, (OAFilterState *)&fs);
  589. m_Ms->SetPositions(&llTime, AM_SEEKING_AbsolutePositioning, NULL, 0);
  590. // This gets new data through to the renderers
  591. if (fs == State_Stopped && bFlushData){
  592. m_Mc->Pause();
  593. hr = m_Mc->GetState(INFINITE, (OAFilterState *)&fs);
  594. m_Mc->Stop();
  595. }
  596. if (SUCCEEDED(hr)) {
  597. return TRUE;
  598. }
  599. }
  600. return FALSE;
  601. }
  602. /*****************************Private*Routine******************************\
  603. * GetPerformanceInterfaces
  604. *
  605. *
  606. *
  607. * History:
  608. * 31-10-95 - StephenE - Created
  609. *
  610. \**************************************************************************/
  611. void
  612. CMpegMovie::GetPerformanceInterfaces(
  613. )
  614. {
  615. FindInterfaceFromFilterGraph(IID_IMpegVideoDecoder, (LPVOID *)&pMpegDecoder);
  616. FindInterfaceFromFilterGraph(IID_IMpegAudioDecoder, (LPVOID *)&pMpegAudioDecoder);
  617. FindInterfaceFromFilterGraph(IID_IQualProp, (LPVOID *)&pVideoRenderer);
  618. }
  619. HRESULT
  620. CMpegMovie::FindInterfaceFromFilterGraph(
  621. REFIID iid, // interface to look for
  622. LPVOID *lp // place to return interface pointer in
  623. )
  624. {
  625. IEnumFilters* pEF;
  626. IBaseFilter* pFilter;
  627. // Grab an enumerator for the filter graph.
  628. HRESULT hr = m_Fg->EnumFilters(&pEF);
  629. if (FAILED(hr)) {
  630. return hr;
  631. }
  632. // Check out each filter.
  633. while (pEF->Next(1, &pFilter, NULL) == S_OK)
  634. {
  635. hr = pFilter->QueryInterface(iid, lp);
  636. pFilter->Release();
  637. if (SUCCEEDED(hr)) {
  638. break;
  639. }
  640. }
  641. pEF->Release();
  642. return hr;
  643. }
  644. /*****************************Public*Routine******************************\
  645. * SetFullScreenMode
  646. *
  647. *
  648. *
  649. * History:
  650. * 17-03-96 - AnthonyP - Created
  651. *
  652. \**************************************************************************/
  653. void
  654. CMpegMovie::SetFullScreenMode(BOOL bMode)
  655. {
  656. m_bFullScreen = bMode;
  657. // Defer until we activate the movie
  658. if (m_Mode != MOVIE_PLAYING) {
  659. if (bMode == TRUE) {
  660. return;
  661. }
  662. }
  663. // Make the change now
  664. if (bMode == FALSE) {
  665. m_Vw->put_FullScreenMode(OAFALSE);
  666. m_Vw->put_MessageDrain((OAHWND) NULL);
  667. } else {
  668. m_Vw->put_MessageDrain((OAHWND) hwndApp);
  669. m_Vw->put_FullScreenMode(OATRUE);
  670. }
  671. }
  672. /*****************************Public*Routine******************************\
  673. * IsFullScreenMode
  674. *
  675. *
  676. *
  677. * History:
  678. * 17-03-96 - AnthonyP - Created
  679. *
  680. \**************************************************************************/
  681. BOOL
  682. CMpegMovie::IsFullScreenMode()
  683. {
  684. return m_bFullScreen;
  685. }
  686. /*****************************Public*Routine******************************\
  687. * IsTimeFormatSupported
  688. *
  689. *
  690. *
  691. * History:
  692. * 12-04-96 - AnthonyP - Created
  693. *
  694. \**************************************************************************/
  695. BOOL
  696. CMpegMovie::IsTimeFormatSupported(GUID Format)
  697. {
  698. return m_Ms != NULL && m_Ms->IsFormatSupported(&Format) == S_OK;
  699. }
  700. /*****************************Public*Routine******************************\
  701. * IsTimeSupported
  702. *
  703. *
  704. *
  705. * History:
  706. * 12-04-96 - AnthonyP - Created
  707. *
  708. \**************************************************************************/
  709. BOOL
  710. CMpegMovie::IsTimeSupported()
  711. {
  712. return m_Ms != NULL && m_Ms->IsFormatSupported(&TIME_FORMAT_MEDIA_TIME) == S_OK;
  713. }
  714. /*****************************Public*Routine******************************\
  715. * GetTimeFormat
  716. *
  717. *
  718. *
  719. * History:
  720. * 12-04-96 - AnthonyP - Created
  721. *
  722. \**************************************************************************/
  723. GUID
  724. CMpegMovie::GetTimeFormat()
  725. {
  726. return m_TimeFormat;
  727. }
  728. /*****************************Public*Routine******************************\
  729. * SetTimeFormat
  730. *
  731. *
  732. *
  733. * History:
  734. * 12-04-96 - AnthonyP - Created
  735. *
  736. \**************************************************************************/
  737. BOOL
  738. CMpegMovie::SetTimeFormat(GUID Format)
  739. {
  740. HRESULT hr = m_Ms->SetTimeFormat(&Format);
  741. if (SUCCEEDED(hr)) {
  742. m_TimeFormat = Format;
  743. }
  744. return SUCCEEDED(hr);
  745. }
  746. /******************************Public*Routine******************************\
  747. * SetFocus
  748. *
  749. *
  750. *
  751. * History:
  752. * 18-09-96 - SteveDav - Created
  753. *
  754. \**************************************************************************/
  755. void
  756. CMpegMovie::SetFocus()
  757. {
  758. if (m_Fg) {
  759. // Tell the resource manager that we are being made active. This
  760. // will then cause the sound to switch to us. This is especially
  761. // important when playing audio only files as there is no other
  762. // playback window.
  763. IResourceManager* pResourceManager;
  764. HRESULT hr = m_Fg->QueryInterface(IID_IResourceManager, (void**)&pResourceManager);
  765. if (SUCCEEDED(hr)) {
  766. IUnknown* pUnknown;
  767. hr = m_Fg->QueryInterface(IID_IUnknown, (void**)&pUnknown);
  768. if (SUCCEEDED(hr)) {
  769. pResourceManager->SetFocus(pUnknown);
  770. pUnknown->Release();
  771. }
  772. pResourceManager->Release();
  773. }
  774. }
  775. }
  776. BOOL CMpegMovie::SelectStream(int iStream)
  777. {
  778. HRESULT hr = E_NOINTERFACE;
  779. if (m_pStreamSelect) {
  780. hr = m_pStreamSelect->Enable(iStream, AMSTREAMSELECTENABLE_ENABLE);
  781. }
  782. return SUCCEEDED(hr);
  783. }