forked from crow-misia/libwebrtc-bin
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
RTCYUVHelper
for iOS and macOS (#107)
- Loading branch information
1 parent
3a006e1
commit 8df0e8a
Showing
4 changed files
with
350 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,344 @@ | ||
diff --git a/src/sdk/BUILD.gn b/src/sdk/BUILD.gn | ||
index 4fe4bff..e3d2d44 100644 | ||
--- a/src/sdk/BUILD.gn | ||
+++ b/src/sdk/BUILD.gn | ||
@@ -146,11 +146,14 @@ if (is_ios || is_mac) { | ||
"objc/helpers/RTCDispatcher.h", | ||
"objc/helpers/RTCDispatcher.m", | ||
"objc/helpers/scoped_cftyperef.h", | ||
+ "objc/helpers/RTCYUVHelper.h", | ||
+ "objc/helpers/RTCYUVHelper.mm", | ||
] | ||
|
||
deps = [ | ||
":base_objc", | ||
"../rtc_base:checks", | ||
+ "//third_party/libyuv", | ||
] | ||
|
||
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] | ||
@@ -1303,6 +1306,7 @@ if (is_ios || is_mac) { | ||
"objc/components/video_frame_buffer/RTCCVPixelBuffer.h", | ||
"objc/helpers/RTCCameraPreviewView.h", | ||
"objc/helpers/RTCDispatcher.h", | ||
+ "objc/helpers/RTCYUVHelper.h", | ||
"objc/helpers/UIDevice+RTCDevice.h", | ||
"objc/api/peerconnection/RTCAudioSource.h", | ||
"objc/api/peerconnection/RTCAudioTrack.h", | ||
@@ -1503,6 +1507,7 @@ if (is_ios || is_mac) { | ||
"objc/components/video_codec/RTCVideoEncoderH264.h", | ||
"objc/components/video_frame_buffer/RTCCVPixelBuffer.h", | ||
"objc/helpers/RTCDispatcher.h", | ||
+ "objc/helpers/RTCYUVHelper.h", | ||
] | ||
if (!build_with_chromium) { | ||
sources += [ | ||
diff --git a/src/sdk/objc/helpers/RTCYUVHelper.h b/src/sdk/objc/helpers/RTCYUVHelper.h | ||
new file mode 100644 | ||
index 0000000..2e6309c | ||
--- /dev/null | ||
+++ b/src/sdk/objc/helpers/RTCYUVHelper.h | ||
@@ -0,0 +1,118 @@ | ||
+/* | ||
+ * Copyright 2016 The WebRTC project authors. All Rights Reserved. | ||
+ * | ||
+ * Use of this source code is governed by a BSD-style license | ||
+ * that can be found in the LICENSE file in the root of the source | ||
+ * tree. An additional intellectual property rights grant can be found | ||
+ * in the file PATENTS. All contributing project authors may | ||
+ * be found in the AUTHORS file in the root of the source tree. | ||
+ */ | ||
+ | ||
+#import <Foundation/Foundation.h> | ||
+ | ||
+#import "RTCMacros.h" | ||
+#import "RTCVideoFrame.h" | ||
+ | ||
+RTC_OBJC_EXPORT | ||
+@interface RTC_OBJC_TYPE (RTCYUVHelper) : NSObject | ||
+ | ||
+- (instancetype)init NS_UNAVAILABLE; | ||
+ | ||
++ (void)I420Rotate:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstY:(uint8_t*)dstY | ||
+ dstStrideY:(int)dstStrideY | ||
+ dstU:(uint8_t*)dstU | ||
+ dstStrideU:(int)dstStrideU | ||
+ dstV:(uint8_t*)dstV | ||
+ dstStrideV:(int)dstStrideV | ||
+ width:(int)width | ||
+ width:(int)height | ||
+ mode:(RTCVideoRotation)mode; | ||
+ | ||
++ (int)I420ToNV12:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstY:(uint8_t*)dstY | ||
+ dstStrideY:(int)dstStrideY | ||
+ dstUV:(uint8_t*)dstUV | ||
+ dstStrideUV:(int)dstStrideUV | ||
+ width:(int)width | ||
+ width:(int)height; | ||
+ | ||
++ (int)I420ToNV21:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstY:(uint8_t*)dstY | ||
+ dstStrideY:(int)dstStrideY | ||
+ dstUV:(uint8_t*)dstUV | ||
+ dstStrideUV:(int)dstStrideUV | ||
+ width:(int)width | ||
+ width:(int)height; | ||
+ | ||
++ (int)I420ToARGB:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstARGB:(uint8_t*)dstARGB | ||
+ dstStrideARGB:(int)dstStrideARGB | ||
+ width:(int)width | ||
+ height:(int)height; | ||
+ | ||
++ (int)I420ToBGRA:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstBGRA:(uint8_t*)dstBGRA | ||
+ dstStrideBGRA:(int)dstStrideBGRA | ||
+ width:(int)width | ||
+ height:(int)height; | ||
+ | ||
++ (int)I420ToABGR:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstABGR:(uint8_t*)dstABGR | ||
+ dstStrideABGR:(int)dstStrideABGR | ||
+ width:(int)width | ||
+ height:(int)height; | ||
+ | ||
++ (int)I420ToRGBA:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstRGBA:(uint8_t*)dstRGBA | ||
+ dstStrideRGBA:(int)dstStrideRGBA | ||
+ width:(int)width | ||
+ height:(int)height; | ||
+ | ||
++ (int)I420ToRGB24:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstRGB24:(uint8_t*)dstRGB24 | ||
+ dstStrideRGB24:(int)dstStrideRGB24 | ||
+ width:(int)width | ||
+ height:(int)height; | ||
+ | ||
+@end | ||
diff --git a/src/sdk/objc/helpers/RTCYUVHelper.mm b/src/sdk/objc/helpers/RTCYUVHelper.mm | ||
new file mode 100644 | ||
index 0000000..3f610ff | ||
--- /dev/null | ||
+++ b/src/sdk/objc/helpers/RTCYUVHelper.mm | ||
@@ -0,0 +1,179 @@ | ||
+/* | ||
+ * Copyright 2016 The WebRTC project authors. All Rights Reserved. | ||
+ * | ||
+ * Use of this source code is governed by a BSD-style license | ||
+ * that can be found in the LICENSE file in the root of the source | ||
+ * tree. An additional intellectual property rights grant can be found | ||
+ * in the file PATENTS. All contributing project authors may | ||
+ * be found in the AUTHORS file in the root of the source tree. | ||
+ */ | ||
+ | ||
+#import "RTCYUVHelper.h" | ||
+ | ||
+#include "third_party/libyuv/include/libyuv.h" | ||
+ | ||
+@implementation RTC_OBJC_TYPE (RTCYUVHelper) | ||
+ | ||
++ (void)I420Rotate:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstY:(uint8_t*)dstY | ||
+ dstStrideY:(int)dstStrideY | ||
+ dstU:(uint8_t*)dstU | ||
+ dstStrideU:(int)dstStrideU | ||
+ dstV:(uint8_t*)dstV | ||
+ dstStrideV:(int)dstStrideV | ||
+ width:(int)width | ||
+ width:(int)height | ||
+ mode:(RTCVideoRotation)mode { | ||
+ libyuv::I420Rotate(srcY, | ||
+ srcStrideY, | ||
+ srcU, | ||
+ srcStrideU, | ||
+ srcV, | ||
+ srcStrideV, | ||
+ dstY, | ||
+ dstStrideY, | ||
+ dstU, | ||
+ dstStrideU, | ||
+ dstV, | ||
+ dstStrideV, | ||
+ width, | ||
+ height, | ||
+ (libyuv::RotationMode)mode); | ||
+} | ||
+ | ||
++ (int)I420ToNV12:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstY:(uint8_t*)dstY | ||
+ dstStrideY:(int)dstStrideY | ||
+ dstUV:(uint8_t*)dstUV | ||
+ dstStrideUV:(int)dstStrideUV | ||
+ width:(int)width | ||
+ width:(int)height { | ||
+ return libyuv::I420ToNV12(srcY, | ||
+ srcStrideY, | ||
+ srcU, | ||
+ srcStrideU, | ||
+ srcV, | ||
+ srcStrideV, | ||
+ dstY, | ||
+ dstStrideY, | ||
+ dstUV, | ||
+ dstStrideUV, | ||
+ width, | ||
+ height); | ||
+} | ||
+ | ||
++ (int)I420ToNV21:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstY:(uint8_t*)dstY | ||
+ dstStrideY:(int)dstStrideY | ||
+ dstUV:(uint8_t*)dstUV | ||
+ dstStrideUV:(int)dstStrideUV | ||
+ width:(int)width | ||
+ width:(int)height { | ||
+ return libyuv::I420ToNV21(srcY, | ||
+ srcStrideY, | ||
+ srcU, | ||
+ srcStrideU, | ||
+ srcV, | ||
+ srcStrideV, | ||
+ dstY, | ||
+ dstStrideY, | ||
+ dstUV, | ||
+ dstStrideUV, | ||
+ width, | ||
+ height); | ||
+} | ||
+ | ||
++ (int)I420ToARGB:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstARGB:(uint8_t*)dstARGB | ||
+ dstStrideARGB:(int)dstStrideARGB | ||
+ width:(int)width | ||
+ height:(int)height { | ||
+ return libyuv::I420ToARGB( | ||
+ srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstARGB, dstStrideARGB, width, height); | ||
+} | ||
+ | ||
++ (int)I420ToBGRA:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstBGRA:(uint8_t*)dstBGRA | ||
+ dstStrideBGRA:(int)dstStrideBGRA | ||
+ width:(int)width | ||
+ height:(int)height { | ||
+ return libyuv::I420ToBGRA( | ||
+ srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstBGRA, dstStrideBGRA, width, height); | ||
+} | ||
+ | ||
++ (int)I420ToABGR:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstABGR:(uint8_t*)dstABGR | ||
+ dstStrideABGR:(int)dstStrideABGR | ||
+ width:(int)width | ||
+ height:(int)height { | ||
+ return libyuv::I420ToABGR( | ||
+ srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstABGR, dstStrideABGR, width, height); | ||
+} | ||
+ | ||
++ (int)I420ToRGBA:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstRGBA:(uint8_t*)dstRGBA | ||
+ dstStrideRGBA:(int)dstStrideRGBA | ||
+ width:(int)width | ||
+ height:(int)height { | ||
+ return libyuv::I420ToRGBA( | ||
+ srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstRGBA, dstStrideRGBA, width, height); | ||
+} | ||
+ | ||
++ (int)I420ToRGB24:(const uint8_t*)srcY | ||
+ srcStrideY:(int)srcStrideY | ||
+ srcU:(const uint8_t*)srcU | ||
+ srcStrideU:(int)srcStrideU | ||
+ srcV:(const uint8_t*)srcV | ||
+ srcStrideV:(int)srcStrideV | ||
+ dstRGB24:(uint8_t*)dstRGB24 | ||
+ dstStrideRGB24:(int)dstStrideRGB24 | ||
+ width:(int)width | ||
+ height:(int)height { | ||
+ return libyuv::I420ToRGB24(srcY, | ||
+ srcStrideY, | ||
+ srcU, | ||
+ srcStrideU, | ||
+ srcV, | ||
+ srcStrideV, | ||
+ dstRGB24, | ||
+ dstStrideRGB24, | ||
+ width, | ||
+ height); | ||
+} | ||
+ | ||
+@end |