Skip to content

Commit 5e66b1b

Browse files
Matthew ThompsonMatthew Thompson
authored andcommitted
adds empty bridging headers
1 parent 53ac480 commit 5e66b1b

File tree

8 files changed

+326
-1
lines changed

8 files changed

+326
-1
lines changed

ios/RNReactNativeReplaykit.xcodeproj/project.pbxproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
52ECF4762146088800301CC6 /* ScreenRecordBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 52ECF4752146088800301CC6 /* ScreenRecordBridge.m */; };
1011
B3E7B58A1CC2AC0600A0062D /* RNReactNativeReplaykit.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNReactNativeReplaykit.m */; };
1112
/* End PBXBuildFile section */
1213

@@ -24,6 +25,9 @@
2425

2526
/* Begin PBXFileReference section */
2627
134814201AA4EA6300B7C361 /* libRNReactNativeReplaykit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNReactNativeReplaykit.a; sourceTree = BUILT_PRODUCTS_DIR; };
28+
52ECF4742146084400301CC6 /* ScreenRecord */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ScreenRecord; sourceTree = "<group>"; };
29+
52ECF4752146088800301CC6 /* ScreenRecordBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScreenRecordBridge.m; sourceTree = "<group>"; };
30+
52ECF4772146089A00301CC6 /* ScreenRecordBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScreenRecordBridge.h; sourceTree = "<group>"; };
2731
B3E7B5881CC2AC0600A0062D /* RNReactNativeReplaykit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNReactNativeReplaykit.h; sourceTree = "<group>"; };
2832
B3E7B5891CC2AC0600A0062D /* RNReactNativeReplaykit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNReactNativeReplaykit.m; sourceTree = "<group>"; };
2933
/* End PBXFileReference section */
@@ -50,6 +54,9 @@
5054
58B511D21A9E6C8500147676 = {
5155
isa = PBXGroup;
5256
children = (
57+
52ECF4772146089A00301CC6 /* ScreenRecordBridge.h */,
58+
52ECF4752146088800301CC6 /* ScreenRecordBridge.m */,
59+
52ECF4742146084400301CC6 /* ScreenRecord */,
5360
B3E7B5881CC2AC0600A0062D /* RNReactNativeReplaykit.h */,
5461
B3E7B5891CC2AC0600A0062D /* RNReactNativeReplaykit.m */,
5562
134814211AA4EA7D00B7C361 /* Products */,
@@ -113,6 +120,7 @@
113120
buildActionMask = 2147483647;
114121
files = (
115122
B3E7B58A1CC2AC0600A0062D /* RNReactNativeReplaykit.m in Sources */,
123+
52ECF4762146088800301CC6 /* ScreenRecordBridge.m in Sources */,
116124
);
117125
runOnlyForDeploymentPostprocessing = 0;
118126
};
@@ -204,7 +212,7 @@
204212
isa = XCBuildConfiguration;
205213
buildSettings = {
206214
HEADER_SEARCH_PATHS = (
207-
"$(inherited)",
215+
"$(inherited)",
208216
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
209217
"$(SRCROOT)/../../../React/**",
210218
"$(SRCROOT)/../../react-native/React/**",

ios/ScreenRecord/FileUtil.swift

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// FileManager.swift
3+
// BugReporterTest
4+
//
5+
// Created by Giridhar on 20/06/17.
6+
// Copyright © 2017 Giridhar. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
class ReplayFileUtil
12+
{
13+
internal class func createReplaysFolder()
14+
{
15+
// path to documents directory
16+
let documentDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first
17+
if let documentDirectoryPath = documentDirectoryPath {
18+
// create the custom folder path
19+
let replayDirectoryPath = documentDirectoryPath.appending("/Replays")
20+
let fileManager = FileManager.default
21+
if !fileManager.fileExists(atPath: replayDirectoryPath) {
22+
do {
23+
try fileManager.createDirectory(atPath: replayDirectoryPath,
24+
withIntermediateDirectories: false,
25+
attributes: nil)
26+
} catch {
27+
print("Error creating Replays folder in documents dir: \(error)")
28+
}
29+
}
30+
}
31+
}
32+
33+
internal class func filePath(_ fileName: String) -> String
34+
{
35+
createReplaysFolder()
36+
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
37+
let documentsDirectory = paths[0] as String
38+
let filePath : String = "\(documentsDirectory)/Replays/\(fileName).mp4"
39+
return filePath
40+
}
41+
42+
internal class func fetchAllReplays() -> Array<URL>
43+
{
44+
let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first
45+
let replayPath = documentsDirectory?.appendingPathComponent("/Replays")
46+
let directoryContents = try! FileManager.default.contentsOfDirectory(at: replayPath!, includingPropertiesForKeys: nil, options: [])
47+
return directoryContents
48+
}
49+
50+
}
51+
52+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// ScreenRecordCoordinator.swift
3+
// BugReporterTest
4+
//
5+
// Created by Giridhar on 21/06/17.
6+
// Copyright © 2017 Giridhar. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
class ScreenRecordCoordinator: NSObject
12+
{
13+
let viewOverlay = WindowUtil()
14+
let screenRecorder = ScreenRecorder()
15+
var recordCompleted:((Error?) ->Void)?
16+
17+
override init()
18+
{
19+
super.init()
20+
21+
viewOverlay.onStopClick = {
22+
self.stopRecording()
23+
}
24+
25+
26+
}
27+
28+
func startRecording(withFileName fileName: String, recordingHandler: @escaping (Error?) -> Void,onCompletion: @escaping (Error?)->Void)
29+
{
30+
self.viewOverlay.show()
31+
screenRecorder.startRecording(withFileName: fileName) { (error) in
32+
recordingHandler(error)
33+
self.recordCompleted = onCompletion
34+
}
35+
}
36+
37+
func stopRecording()
38+
{
39+
screenRecorder.stopRecording { (error) in
40+
self.viewOverlay.hide()
41+
self.recordCompleted?(error)
42+
}
43+
}
44+
45+
class func listAllReplays() -> Array<URL>
46+
{
47+
return ReplayFileUtil.fetchAllReplays()
48+
}
49+
50+
51+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
//
2+
// ScreenRecorder.swift
3+
// BugReporterTest
4+
//
5+
// Created by Giridhar on 09/06/17.
6+
// Copyright © 2017 Giridhar. All rights reserved.
7+
//
8+
import Foundation
9+
import ReplayKit
10+
import AVKit
11+
12+
13+
class ScreenRecorder
14+
{
15+
var assetWriter:AVAssetWriter!
16+
var videoInput:AVAssetWriterInput!
17+
18+
let viewOverlay = WindowUtil()
19+
20+
//MARK: Screen Recording
21+
func startRecording(withFileName fileName: String, recordingHandler:@escaping (Error?)-> Void)
22+
{
23+
if #available(iOS 11.0, *)
24+
{
25+
26+
let fileURL = URL(fileURLWithPath: ReplayFileUtil.filePath(fileName))
27+
assetWriter = try! AVAssetWriter(outputURL: fileURL, fileType:
28+
AVFileType.mp4)
29+
let videoOutputSettings: Dictionary<String, Any> = [
30+
AVVideoCodecKey : AVVideoCodecType.h264,
31+
AVVideoWidthKey : UIScreen.main.bounds.size.width,
32+
AVVideoHeightKey : UIScreen.main.bounds.size.height
33+
];
34+
35+
videoInput = AVAssetWriterInput (mediaType: AVMediaType.video, outputSettings: videoOutputSettings)
36+
videoInput.expectsMediaDataInRealTime = true
37+
assetWriter.add(videoInput)
38+
39+
RPScreenRecorder.shared().startCapture(handler: { (sample, bufferType, error) in
40+
// print(sample,bufferType,error)
41+
42+
recordingHandler(error)
43+
44+
if CMSampleBufferDataIsReady(sample)
45+
{
46+
if self.assetWriter.status == AVAssetWriterStatus.unknown
47+
{
48+
self.assetWriter.startWriting()
49+
self.assetWriter.startSession(atSourceTime: CMSampleBufferGetPresentationTimeStamp(sample))
50+
}
51+
52+
if self.assetWriter.status == AVAssetWriterStatus.failed {
53+
print("Error occured, status = \(self.assetWriter.status.rawValue), \(self.assetWriter.error!.localizedDescription) \(String(describing: self.assetWriter.error))")
54+
return
55+
}
56+
57+
if (bufferType == .video)
58+
{
59+
if self.videoInput.isReadyForMoreMediaData
60+
{
61+
self.videoInput.append(sample)
62+
}
63+
}
64+
}
65+
66+
}) { (error) in
67+
recordingHandler(error)
68+
// debugPrint(error)
69+
}
70+
} else
71+
{
72+
// Fallback on earlier versions
73+
}
74+
}
75+
76+
func stopRecording(handler: @escaping (Error?) -> Void)
77+
{
78+
if #available(iOS 11.0, *)
79+
{
80+
RPScreenRecorder.shared().stopCapture
81+
{ (error) in
82+
handler(error)
83+
self.assetWriter.finishWriting
84+
{
85+
print(ReplayFileUtil.fetchAllReplays())
86+
87+
}
88+
}
89+
} else {
90+
// Fallback on earlier versions
91+
}
92+
}
93+
94+
95+
}

ios/ScreenRecord/WindowUtil.swift

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// WindowUtil.swift
3+
// BugReporterTest
4+
//
5+
// Created by Giridhar on 21/06/17.
6+
// Copyright © 2017 Giridhar. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import UIKit
11+
12+
protocol Overlayable
13+
{
14+
func show()
15+
func hide()
16+
}
17+
18+
class WindowUtil: Overlayable
19+
{
20+
var overlayWindow = UIWindow(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 30))
21+
var stopButton = UIButton(type: UIButtonType.custom)
22+
var stopButtonColor = UIColor(red:0.30, green:0.67, blue:0.99, alpha:1.00)
23+
var onStopClick:(() -> ())?
24+
25+
init ()
26+
{
27+
self.setupViews()
28+
}
29+
30+
func initViews()
31+
{
32+
overlayWindow = UIWindow(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 30))
33+
stopButton = UIButton(type: UIButtonType.custom)
34+
}
35+
36+
func hide()
37+
{
38+
DispatchQueue.main.async {
39+
40+
UIView.animate(withDuration: 0.3, animations: {
41+
self.stopButton.transform = CGAffineTransform(translationX:0, y: -30)
42+
}, completion: { (animated) in
43+
self.overlayWindow.backgroundColor = .clear
44+
self.overlayWindow.isHidden = true
45+
self.stopButton.isHidden = true
46+
self.stopButton.transform = CGAffineTransform.identity;
47+
})
48+
49+
}
50+
51+
}
52+
53+
func setupViews ()
54+
{
55+
initViews()
56+
stopButton.setTitle("Stop Recording", for: .normal)
57+
stopButton.titleLabel?.font = UIFont.systemFont(ofSize: UIFont.smallSystemFontSize)
58+
59+
stopButton.addTarget(self, action: #selector(stopRecording), for: UIControlEvents.touchDown)
60+
61+
62+
63+
stopButton.frame = overlayWindow.frame
64+
overlayWindow.addSubview(stopButton)
65+
overlayWindow.windowLevel = CGFloat.greatestFiniteMagnitude
66+
67+
}
68+
69+
70+
@objc func stopRecording()
71+
{
72+
onStopClick?()
73+
}
74+
75+
func show()
76+
{
77+
DispatchQueue.main.async {
78+
self.stopButton.transform = CGAffineTransform(translationX: 0, y: -30)
79+
self.stopButton.backgroundColor = self.stopButtonColor
80+
self.overlayWindow.makeKeyAndVisible()
81+
UIView.animate(withDuration: 0.3, animations: {
82+
self.stopButton.transform = CGAffineTransform.identity
83+
}, completion: { (animated) in
84+
85+
})
86+
}
87+
88+
}
89+
}

ios/ScreenRecordBridge.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// CalendarManager-Bridging-Header.h
2+
#import <React/RCTBridgeModule.h>

ios/ScreenRecordBridge.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import <React/RCTBridgeModule.h>
2+
3+
@interface RCT_EXTERN_MODULE(CalendarManager, NSObject)
4+
5+
// RCT_EXTERN_METHOD(addEvent:(NSString *)name location:(NSString *)location date:(nonnull NSNumber *)date)
6+
7+
@end

licences/SCREENRECORD

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Giridhar
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)