OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/tools/mfplayer/mfplayer.h" | 5 #include "media/tools/mfplayer/mfplayer.h" |
6 | 6 |
7 #include <mfapi.h> | 7 #include <mfapi.h> |
8 #include <mferror.h> | 8 #include <mferror.h> |
9 #include <shlwapi.h> | 9 #include <shlwapi.h> |
10 #include <strsafe.h> | 10 #include <strsafe.h> |
11 | 11 |
12 #include <cassert> | 12 #include <cassert> |
13 | 13 |
14 namespace { | |
15 | |
16 template <class T> | 14 template <class T> |
17 void SafeRelease(T** pptr) { | 15 static void SafeRelease(T** pptr) { |
18 if (pptr && *pptr) { | 16 if (pptr && *pptr) { |
19 (*pptr)->Release(); | 17 (*pptr)->Release(); |
20 *pptr = NULL; | 18 *pptr = NULL; |
21 } | 19 } |
22 } | 20 } |
23 | 21 |
24 HRESULT ProbeTopology(IMFMediaEvent* event, IMFTopology** topology_ptr) { | 22 static HRESULT ProbeTopology(IMFMediaEvent* event, |
| 23 IMFTopology** topology_ptr) { |
25 HRESULT hr = S_OK; | 24 HRESULT hr = S_OK; |
26 PROPVARIANT var; | 25 PROPVARIANT var; |
27 PropVariantInit(&var); | 26 PropVariantInit(&var); |
28 hr = event->GetValue(&var); | 27 hr = event->GetValue(&var); |
29 if (SUCCEEDED(hr)) { | 28 if (SUCCEEDED(hr)) { |
30 if (var.vt != VT_UNKNOWN) | 29 if (var.vt != VT_UNKNOWN) |
31 hr = E_UNEXPECTED; | 30 hr = E_UNEXPECTED; |
32 } | 31 } |
33 if (SUCCEEDED(hr)) | 32 if (SUCCEEDED(hr)) |
34 hr = var.punkVal->QueryInterface(IID_PPV_ARGS(topology_ptr)); | 33 hr = var.punkVal->QueryInterface(IID_PPV_ARGS(topology_ptr)); |
35 PropVariantClear(&var); | 34 PropVariantClear(&var); |
36 return hr; | 35 return hr; |
37 } | 36 } |
38 | 37 |
39 } // namespace | |
40 | |
41 namespace mfplayer { | 38 namespace mfplayer { |
42 | 39 |
43 // Public methods | 40 // Public methods |
44 | 41 |
45 bool MFPlayer::CreateInstance(HWND video_window, HWND event_window, | 42 bool MFPlayer::CreateInstance(HWND video_window, HWND event_window, |
46 bool render_to_window, MFPlayer** player) { | 43 bool render_to_window, MFPlayer** player) { |
47 if (!player) | 44 if (!player) |
48 return false; | 45 return false; |
49 | 46 |
50 HRESULT hr = S_OK; | 47 HRESULT hr = S_OK; |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 if (FAILED(hr)) | 814 if (FAILED(hr)) |
818 break; | 815 break; |
819 SafeRelease(&event); | 816 SafeRelease(&event); |
820 } | 817 } |
821 // Release the last MESessionClosed event. | 818 // Release the last MESessionClosed event. |
822 SafeRelease(&event); | 819 SafeRelease(&event); |
823 return SUCCEEDED(hr); | 820 return SUCCEEDED(hr); |
824 } | 821 } |
825 | 822 |
826 } // namespace mfplayer | 823 } // namespace mfplayer |
OLD | NEW |