summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLStreamingMediaManager.m
blob: 72bbf969173989e3caaac4515cd94eed543116e4 (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//
//  SDLStreamingDataManager.m
//  SmartDeviceLink-iOS
//
//  Created by Joel Fischer on 8/11/15.
//  Copyright (c) 2015 smartdevicelink. All rights reserved.
//

#import "SDLStreamingMediaManager.h"

#import "SDLStreamingMediaLifecycleManager.h"
#import "SDLTouchManager.h"


NS_ASSUME_NONNULL_BEGIN

@interface SDLStreamingMediaManager ()

@property (strong, nonatomic) SDLStreamingMediaLifecycleManager *lifecycleManager;

@end


@implementation SDLStreamingMediaManager

#pragma mark - Public
#pragma mark Lifecycle

- (instancetype)init {
    return [self initWithEncryption:SDLStreamingEncryptionFlagAuthenticateAndEncrypt videoEncoderSettings:nil];
}

- (instancetype)initWithEncryption:(SDLStreamingEncryptionFlag)encryption videoEncoderSettings:(nullable NSDictionary<NSString *, id> *)videoEncoderSettings {
    self = [super init];
    if (!self) {
        return nil;
    }
    
    _lifecycleManager = [[SDLStreamingMediaLifecycleManager alloc] initWithEncryption:encryption videoEncoderSettings:videoEncoderSettings];

    return self;
}

- (void)startWithProtocol:(SDLAbstractProtocol *)protocol completionHandler:(void (^)(BOOL, NSError * _Nullable))completionHandler {
    [self.lifecycleManager startWithProtocol:protocol completionHandler:completionHandler];
}

- (void)stop {
    [self.lifecycleManager stop];
}

- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer {
    return [self.lifecycleManager sendVideoData:imageBuffer];
}

- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer presentationTimestamp:(CMTime)presentationTimestamp {
    return [self.lifecycleManager sendVideoData:imageBuffer presentationTimestamp:presentationTimestamp];
}

- (BOOL)sendAudioData:(NSData*)audioData {
    return [self.lifecycleManager sendAudioData:audioData];
}


#pragma mark - Getters

- (SDLTouchManager *)touchManager {
    return self.lifecycleManager.touchManager;
}

- (BOOL)isAudioStreamingSupported {
    return self.lifecycleManager.isAudioStreamingSupported;
}

- (BOOL)isVideoStreamingSupported {
    return self.lifecycleManager.isVideoStreamingSupported;
}

- (BOOL)isAudioConnected {
    return self.lifecycleManager.isAudioConnected;
}

- (BOOL)isVideoConnected {
    return self.lifecycleManager.isVideoConnected;
}

- (BOOL)isAudioEncrypted {
    return self.lifecycleManager.isAudioEncrypted;
}

- (BOOL)isVideoEncrypted {
    return self.lifecycleManager.isVideoEncrypted;
}
    
- (BOOL)isVideoStreamingPaused {
    return self.lifecycleManager.isVideoStreamingPaused;
}

- (CGSize)screenSize {
    return self.lifecycleManager.screenSize;
}

- (CVPixelBufferPoolRef __nullable)pixelBufferPool {
    return self.lifecycleManager.pixelBufferPool;
}

- (SDLStreamingEncryptionFlag)requestedEncryptionType {
    return self.lifecycleManager.requestedEncryptionType;
}

#pragma mark - Setters
- (void)setRequestedEncryptionType:(SDLStreamingEncryptionFlag)requestedEncryptionType {
    self.lifecycleManager.requestedEncryptionType = requestedEncryptionType;
}

@end

NS_ASSUME_NONNULL_END