OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_WIN_MF_HELPERS_H_ | |
6 #define MEDIA_BASE_WIN_MF_HELPERS_H_ | |
7 | |
8 #include <mfapi.h> | |
9 #include <stdint.h> | |
10 | |
11 #include "base/win/scoped_comptr.h" | |
12 #include "media/base/win/mf_initializer_export.h" | |
13 | |
14 namespace media { | |
15 | |
16 namespace mf { | |
17 | |
18 #define RETURN_ON_FAILURE(result, log, ret) \ | |
19 do { \ | |
20 if (!(result)) { \ | |
21 DLOG(ERROR) << log; \ | |
22 mf::LogDXVAError(__LINE__); \ | |
23 return ret; \ | |
24 } \ | |
25 } while (0) | |
26 | |
27 #define RETURN_ON_HR_FAILURE(result, log, ret) \ | |
28 RETURN_ON_FAILURE(SUCCEEDED(result), \ | |
29 log << ", HRESULT: 0x" << std::hex << result, ret); | |
30 | |
31 #define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \ | |
32 do { \ | |
33 if (!(result)) { \ | |
34 DVLOG(1) << log; \ | |
35 mf::LogDXVAError(__LINE__); \ | |
36 StopOnError(error_code); \ | |
37 return ret; \ | |
38 } \ | |
39 } while (0) | |
40 | |
41 #define RETURN_AND_NOTIFY_ON_HR_FAILURE(result, log, error_code, ret) \ | |
42 RETURN_AND_NOTIFY_ON_FAILURE(SUCCEEDED(result), \ | |
43 log << ", HRESULT: 0x" << std::hex << result, \ | |
44 error_code, ret); | |
45 | |
46 MF_INITIALIZER_EXPORT void LogDXVAError(int line); | |
47 | |
48 // Creates a Media Foundation sample with one buffer of length |buffer_length| | |
49 // on a |align|-byte boundary. Alignment must be a perfect power of 2 or 0. | |
50 MF_INITIALIZER_EXPORT IMFSample* CreateEmptySampleWithBuffer( | |
51 uint32_t buffer_length, | |
52 int align); | |
53 | |
54 // Provides scoped access to the underlying buffer in an IMFMediaBuffer | |
55 // instance. | |
56 class MF_INITIALIZER_EXPORT MediaBufferScopedPointer { | |
57 public: | |
58 MediaBufferScopedPointer(IMFMediaBuffer* media_buffer); | |
59 ~MediaBufferScopedPointer(); | |
60 | |
61 uint8_t* get() { return buffer_; } | |
62 DWORD current_length() const { return current_length_; } | |
63 | |
64 private: | |
65 base::win::ScopedComPtr<IMFMediaBuffer> media_buffer_; | |
66 uint8_t* buffer_; | |
67 DWORD max_length_; | |
68 DWORD current_length_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(MediaBufferScopedPointer); | |
71 }; | |
72 | |
73 } // namespace mf | |
74 | |
75 } // namespace media | |
76 | |
77 #endif // MEDIA_BASE_WIN_MF_HELPERS_H_ | |
OLD | NEW |