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

Side by Side Diff: media/base/mac/videotoolbox_helpers.h

Issue 1636083003: H264 HW encode using VideoToolbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jfroy@ comments. Created 4 years, 9 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
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_CDM_CDM_ALLOCATOR_H_ 5 #ifndef MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_
6 #define MEDIA_CDM_CDM_ALLOCATOR_H_ 6 #define MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_
7 7
8 #include <stdint.h> 8 #include "base/mac/scoped_cftyperef.h"
9 9 #include "media/base/mac/videotoolbox_glue.h"
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
13 11
14 namespace cdm {
15 class Buffer;
16 }
17
18 namespace media { 12 namespace media {
19 13
20 class VideoFrameImpl; 14 namespace video_toolbox {
21 15
22 class MEDIA_EXPORT CdmAllocator { 16 // Create a CFDictionaryRef with the given keys and values.
17 MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef>
18 DictionaryWithKeysAndValues(CFTypeRef* keys, CFTypeRef* values, size_t size);
19
20 // Create a CFDictionaryRef with the given key and value.
21 MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef> DictionaryWithKeyValue(
22 CFTypeRef key,
23 CFTypeRef value);
24
25 // Create a CFArrayRef with the given array of integers.
26 MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegers(const int* v,
27 size_t size);
28
29 // Create a CFArrayRef with the given int and float values.
30 MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegerAndFloat(
31 int int_val,
32 float float_val);
33
34 // 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.
36 MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer(
37 CoreMediaGlue::CMSampleBufferRef sbuf,
38 bool keyframe,
39 std::string* annexb_buffer);
40 MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer(
41 CoreMediaGlue::CMSampleBufferRef sbuf,
42 bool keyframe,
43 size_t annexb_buffer_size,
44 char* annexb_buffer,
45 size_t* used_buffer_size);
46
47 // Helper class to add session properties to a VTCompressionSessionRef.
48 class MEDIA_EXPORT SessionPropertySetter {
23 public: 49 public:
24 virtual ~CdmAllocator(); 50 SessionPropertySetter(
51 base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session,
52 const VideoToolboxGlue* const glue);
53 ~SessionPropertySetter();
25 54
26 // Creates a buffer with at least |capacity| bytes. Caller is required to 55 bool SetSessionProperty(CFStringRef key, int32_t value);
miu 2016/03/08 22:36:05 nit suggestion: When I was reading the code callin
emircan 2016/03/09 01:13:35 Done.
27 // call Destroy() on the returned buffer when it is done with it. 56 bool SetSessionProperty(CFStringRef key, bool value);
28 virtual cdm::Buffer* CreateCdmBuffer(uint32_t capacity) = 0; 57 bool SetSessionProperty(CFStringRef key, CFStringRef value);
29 58 bool SetSessionProperty(CFStringRef key, CFArrayRef value);
30 // Returns a new VideoFrameImpl.
31 virtual scoped_ptr<VideoFrameImpl> CreateCdmVideoFrame() = 0;
32
33 protected:
34 CdmAllocator();
35 59
36 private: 60 private:
37 DISALLOW_COPY_AND_ASSIGN(CdmAllocator); 61 base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session_;
62 const VideoToolboxGlue* glue_;
38 }; 63 };
39 64
65 } // namespace video_toolbox
66
40 } // namespace media 67 } // namespace media
41 68
42 #endif // MEDIA_CDM_CDM_ALLOCATOR_H_ 69 #endif // MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698