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

Unified Diff: media/base/mac/videotoolbox_helpers.h

Issue 1805723002: Reland: H264 HW encode using VideoToolbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/mac/videotoolbox_glue.mm ('k') | media/base/mac/videotoolbox_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/mac/videotoolbox_helpers.h
diff --git a/media/base/media_tracks.h b/media/base/mac/videotoolbox_helpers.h
similarity index 11%
copy from media/base/media_tracks.h
copy to media/base/mac/videotoolbox_helpers.h
index 4e0fbb0fc1f88195ce14cc05d14a424924be4d5d..87d769eef816020c81a1d3b8f11a10390517d34a 100644
--- a/media/base/media_tracks.h
+++ b/media/base/mac/videotoolbox_helpers.h
@@ -2,61 +2,68 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MEDIA_BASE_MEDIA_TRACKS_H_
-#define MEDIA_BASE_MEDIA_TRACKS_H_
+#ifndef MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_
+#define MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_
-#include <map>
-#include <string>
-#include <vector>
-
-#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"
-#include "media/base/media_track.h"
namespace media {
-class AudioDecoderConfig;
-class VideoDecoderConfig;
+namespace video_toolbox {
+
+// 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);
+
+// Create a CFArrayRef with the given array of integers.
+MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegers(const int* v,
+ size_t size);
+
+// Create a CFArrayRef with the given int and float values.
+MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegerAndFloat(
+ int int_val,
+ float float_val);
-class MEDIA_EXPORT MediaTracks {
+// 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:
- typedef std::vector<scoped_ptr<MediaTrack>> MediaTracksCollection;
-
- MediaTracks();
- ~MediaTracks();
-
- // Callers need to ensure that track id is unique.
- void AddAudioTrack(const AudioDecoderConfig& config,
- const std::string& id,
- const std::string& kind,
- const std::string& label,
- const std::string& language);
- // Callers need to ensure that track id is unique.
- void AddVideoTrack(const VideoDecoderConfig& config,
- const std::string& id,
- const std::string& kind,
- const std::string& label,
- const std::string& language);
-
- const MediaTracksCollection& tracks() const { return tracks_; }
-
- const AudioDecoderConfig& getAudioConfig(const std::string& id) const;
- const VideoDecoderConfig& getVideoConfig(const std::string& id) const;
-
- // TODO(servolk): These are temporary helpers useful until all code paths are
- // converted to properly handle multiple media tracks.
- const AudioDecoderConfig& getFirstAudioConfig() const;
- const VideoDecoderConfig& getFirstVideoConfig() const;
+ SessionPropertySetter(
+ base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session,
+ const VideoToolboxGlue* const glue);
+ ~SessionPropertySetter();
- private:
- MediaTracksCollection tracks_;
- std::map<std::string, AudioDecoderConfig> audio_configs_;
- std::map<std::string, VideoDecoderConfig> video_configs_;
+ bool Set(CFStringRef key, int32_t value);
+ bool Set(CFStringRef key, bool value);
+ bool Set(CFStringRef key, CFStringRef value);
+ bool Set(CFStringRef key, CFArrayRef value);
- DISALLOW_COPY_AND_ASSIGN(MediaTracks);
+ private:
+ base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session_;
+ const VideoToolboxGlue* glue_;
};
+} // namespace video_toolbox
+
} // namespace media
-#endif // MEDIA_BASE_MEDIA_TRACKS_H_
+#endif // MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_
« no previous file with comments | « media/base/mac/videotoolbox_glue.mm ('k') | media/base/mac/videotoolbox_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698