OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ | 5 #ifndef MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ |
6 #define MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ | 6 #define MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ |
7 | 7 |
| 8 #include <CoreMedia/CoreMedia.h> |
| 9 #include <VideoToolbox/VideoToolbox.h> |
| 10 |
8 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
9 #include "media/base/mac/videotoolbox_glue.h" | |
10 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
11 | 13 |
12 namespace media { | 14 namespace media { |
13 | 15 |
14 namespace video_toolbox { | 16 namespace video_toolbox { |
15 | 17 |
16 // Create a CFDictionaryRef with the given keys and values. | 18 // Create a CFDictionaryRef with the given keys and values. |
17 MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef> | 19 MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef> |
18 DictionaryWithKeysAndValues(CFTypeRef* keys, CFTypeRef* values, size_t size); | 20 DictionaryWithKeysAndValues(CFTypeRef* keys, CFTypeRef* values, size_t size); |
19 | 21 |
20 // Create a CFDictionaryRef with the given key and value. | 22 // Create a CFDictionaryRef with the given key and value. |
21 MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef> DictionaryWithKeyValue( | 23 MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef> DictionaryWithKeyValue( |
22 CFTypeRef key, | 24 CFTypeRef key, |
23 CFTypeRef value); | 25 CFTypeRef value); |
24 | 26 |
25 // Create a CFArrayRef with the given array of integers. | 27 // Create a CFArrayRef with the given array of integers. |
26 MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegers(const int* v, | 28 MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegers(const int* v, |
27 size_t size); | 29 size_t size); |
28 | 30 |
29 // Create a CFArrayRef with the given int and float values. | 31 // Create a CFArrayRef with the given int and float values. |
30 MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegerAndFloat( | 32 MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegerAndFloat( |
31 int int_val, | 33 int int_val, |
32 float float_val); | 34 float float_val); |
33 | 35 |
34 // Copy a H.264 frame stored in a CM sample buffer to an Annex B buffer. Copies | 36 // Copy a H.264 frame stored in a CM sample buffer to an Annex B buffer. Copies |
35 // parameter sets for keyframes before the frame data as well. | 37 // parameter sets for keyframes before the frame data as well. |
36 MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer( | 38 MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer(CMSampleBufferRef sbuf, |
37 CoreMediaGlue::CMSampleBufferRef sbuf, | 39 bool keyframe, |
38 bool keyframe, | 40 std::string* annexb_buffer); |
39 std::string* annexb_buffer); | 41 MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer(CMSampleBufferRef sbuf, |
40 MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer( | 42 bool keyframe, |
41 CoreMediaGlue::CMSampleBufferRef sbuf, | 43 size_t annexb_buffer_size, |
42 bool keyframe, | 44 char* annexb_buffer, |
43 size_t annexb_buffer_size, | 45 size_t* used_buffer_size); |
44 char* annexb_buffer, | |
45 size_t* used_buffer_size); | |
46 | 46 |
47 // Helper class to add session properties to a VTCompressionSessionRef. | 47 // Helper class to add session properties to a VTCompressionSessionRef. |
48 class MEDIA_EXPORT SessionPropertySetter { | 48 class MEDIA_EXPORT SessionPropertySetter { |
49 public: | 49 public: |
50 SessionPropertySetter( | 50 SessionPropertySetter(base::ScopedCFTypeRef<VTCompressionSessionRef> session); |
51 base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session, | |
52 const VideoToolboxGlue* const glue); | |
53 ~SessionPropertySetter(); | 51 ~SessionPropertySetter(); |
54 | 52 |
55 bool Set(CFStringRef key, int32_t value); | 53 bool Set(CFStringRef key, int32_t value); |
56 bool Set(CFStringRef key, bool value); | 54 bool Set(CFStringRef key, bool value); |
57 bool Set(CFStringRef key, CFStringRef value); | 55 bool Set(CFStringRef key, CFStringRef value); |
58 bool Set(CFStringRef key, CFArrayRef value); | 56 bool Set(CFStringRef key, CFArrayRef value); |
59 | 57 |
60 private: | 58 private: |
61 base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session_; | 59 base::ScopedCFTypeRef<VTCompressionSessionRef> session_; |
62 const VideoToolboxGlue* glue_; | |
63 }; | 60 }; |
64 | 61 |
65 } // namespace video_toolbox | 62 } // namespace video_toolbox |
66 | 63 |
67 } // namespace media | 64 } // namespace media |
68 | 65 |
69 #endif // MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ | 66 #endif // MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ |
OLD | NEW |