Index: media/base/mac/videotoolbox_helpers.h |
diff --git a/media/cdm/cdm_allocator.h b/media/base/mac/videotoolbox_helpers.h |
similarity index 11% |
copy from media/cdm/cdm_allocator.h |
copy to media/base/mac/videotoolbox_helpers.h |
index f8023a87e031c2b26f37db3bade9df915124b2c2..b91f368f1d7bd0f73a3dfe8b2312b043fdb58bad 100644 |
--- a/media/cdm/cdm_allocator.h |
+++ b/media/base/mac/videotoolbox_helpers.h |
@@ -2,41 +2,68 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef MEDIA_CDM_CDM_ALLOCATOR_H_ |
-#define MEDIA_CDM_CDM_ALLOCATOR_H_ |
+#ifndef MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ |
+#define MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ |
-#include <stdint.h> |
- |
-#include "base/macros.h" |
-#include "base/memory/scoped_ptr.h" |
+#include "base/mac/scoped_cftyperef.h" |
+#include "media/base/mac/videotoolbox_glue.h" |
#include "media/base/media_export.h" |
-namespace cdm { |
-class Buffer; |
-} |
- |
namespace media { |
-class VideoFrameImpl; |
+namespace video_toolbox { |
-class MEDIA_EXPORT CdmAllocator { |
- public: |
- virtual ~CdmAllocator(); |
+// Create a CFDictionaryRef with the given keys and values. |
+MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef> |
+DictionaryWithKeysAndValues(CFTypeRef* keys, CFTypeRef* values, size_t size); |
+ |
+// Create a CFDictionaryRef with the given key and value. |
+MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef> DictionaryWithKeyValue( |
+ CFTypeRef key, |
+ CFTypeRef value); |
- // Creates a buffer with at least |capacity| bytes. Caller is required to |
- // call Destroy() on the returned buffer when it is done with it. |
- virtual cdm::Buffer* CreateCdmBuffer(uint32_t capacity) = 0; |
+// Create a CFArrayRef with the given array of integers. |
+MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegers(const int* v, |
+ size_t size); |
- // Returns a new VideoFrameImpl. |
- virtual scoped_ptr<VideoFrameImpl> CreateCdmVideoFrame() = 0; |
+// Create a CFArrayRef with the given int and float values. |
+MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegerAndFloat( |
+ int int_val, |
+ float float_val); |
- protected: |
- CdmAllocator(); |
+// Copy a H.264 frame stored in a CM sample buffer to an Annex B buffer. Copies |
+// parameter sets for keyframes before the frame data as well. |
+MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer( |
+ CoreMediaGlue::CMSampleBufferRef sbuf, |
+ bool keyframe, |
+ std::string* annexb_buffer); |
+MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer( |
+ CoreMediaGlue::CMSampleBufferRef sbuf, |
+ bool keyframe, |
+ size_t annexb_buffer_size, |
+ char* annexb_buffer, |
+ size_t* used_buffer_size); |
+ |
+// Helper class to add session properties to a VTCompressionSessionRef. |
+class MEDIA_EXPORT SessionPropertySetter { |
+ public: |
+ SessionPropertySetter( |
+ base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session, |
+ const VideoToolboxGlue* const glue); |
+ ~SessionPropertySetter(); |
+ |
+ bool SetSessionProperty(CFStringRef key, int32_t value); |
+ bool SetSessionProperty(CFStringRef key, bool value); |
+ bool SetSessionProperty(CFStringRef key, CFStringRef value); |
+ bool SetSessionProperty(CFStringRef key, CFArrayRef value); |
private: |
- DISALLOW_COPY_AND_ASSIGN(CdmAllocator); |
+ base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session_; |
+ const VideoToolboxGlue* glue_; |
}; |
+} // namespace video_toolbox |
+ |
} // namespace media |
-#endif // MEDIA_CDM_CDM_ALLOCATOR_H_ |
+#endif // MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ |