forked from CommercialTribe/react-native-opentok
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RCTOpenTokPublisherViewManager.m
81 lines (70 loc) · 2.49 KB
/
RCTOpenTokPublisherViewManager.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* Copyright (c) 2015-present, Callstack Sp z o.o.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "RCTOpenTokPublisherViewManager.h"
#import "RCTOpenTokPublisherView.h"
#import "RCTComponent.h"
#import <OpenTok/OpenTok.h>
@implementation RCTOpenTokPublisherViewManager {
RCTOpenTokPublisherView *_recorderView;
}
- (UIView *)view
{
// Alloc UI element
if (_recorderView == nil) {
_recorderView = [RCTOpenTokPublisherView new];
}
return _recorderView;
}
- (NSDictionary *)constantsToExport
{
return @{
@"CameraCaptureResolution": @{
@"Low": @(OTCameraCaptureResolutionLow),
@"Medium": @(OTCameraCaptureResolutionMedium),
@"High": @(OTCameraCaptureResolutionHigh)
},
@"CameraCaptureFrameRate": @{
@"FR30FPS": @(OTCameraCaptureFrameRate30FPS),
@"FR15FPS": @(OTCameraCaptureFrameRate15FPS),
@"FR7FPS": @(OTCameraCaptureFrameRate7FPS),
@"FR1FPS": @(OTCameraCaptureFrameRate1FPS),
},
};
}
RCT_EXPORT_MODULE()
RCT_EXPORT_VIEW_PROPERTY(apiKey, NSString)
RCT_EXPORT_VIEW_PROPERTY(sessionId, NSString)
RCT_EXPORT_VIEW_PROPERTY(token, NSString)
RCT_EXPORT_VIEW_PROPERTY(cameraResolution, NSInteger)
RCT_EXPORT_VIEW_PROPERTY(cameraFrameRate, NSInteger)
RCT_EXPORT_VIEW_PROPERTY(videoEnabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(onPublishStart, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPublishError, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPublishStop, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onClientConnected, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onClientDisconnected, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onSessionDidConnect, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onSessionDidDisconnect, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onArchiveStarted, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onArchiveStopped, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onThumbnailReady, RCTDirectEventBlock)
RCT_EXPORT_METHOD(resumePublish)
{
[_recorderView resumePublish];
}
RCT_EXPORT_METHOD(pausePublish)
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[_recorderView pausePublish];
});
}
RCT_EXPORT_METHOD(stopPublish)
{
[_recorderView stopPublish];
}
@end