Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: media/base/win/mf_helpers.h

Issue 2058413003: H264 HW encode using MediaFoundation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 return ret; \
23 } \
24 } while (0)
25
26 #define RETURN_ON_HR_FAILURE(result, log, ret) \
27 RETURN_ON_FAILURE(SUCCEEDED(result), \
28 log << ", HRESULT: 0x" << std::hex << result, ret);
29
30 #define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \
31 do { \
32 if (!(result)) { \
33 DVLOG(1) << log; \
34 StopOnError(error_code); \
35 return ret; \
36 } \
37 } while (0)
38
39 #define RETURN_AND_NOTIFY_ON_HR_FAILURE(result, log, error_code, ret) \
40 RETURN_AND_NOTIFY_ON_FAILURE(SUCCEEDED(result), \
41 log << ", HRESULT: 0x" << std::hex << result, \
42 error_code, ret);
43
44 // Creates a Media Foundation sample with one buffer of length |buffer_length|
45 // on a |align|-byte boundary. Alignment must be a perfect power of 2 or 0.
46 MF_INITIALIZER_EXPORT IMFSample* CreateEmptySampleWithBuffer(
47 uint32_t buffer_length, int align);
48
49 // Provides scoped access to the underlying buffer in an IMFMediaBuffer
50 // instance.
51 class MF_INITIALIZER_EXPORT MediaBufferScopedPointer {
52 public:
53 MediaBufferScopedPointer(IMFMediaBuffer* media_buffer);
54 ~MediaBufferScopedPointer();
55
56 uint8_t* get() { return buffer_; }
57 DWORD current_length() const { return current_length_; }
58
59 private:
60 base::win::ScopedComPtr<IMFMediaBuffer> media_buffer_;
61 uint8_t* buffer_;
62 DWORD max_length_;
63 DWORD current_length_;
64
65 DISALLOW_COPY_AND_ASSIGN(MediaBufferScopedPointer);
66 };
67
68 } // namespace mf
69
70 } // namespace media
71
72 #endif // MEDIA_BASE_WIN_MF_HELPERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698