[vlc-devel] [PATCH 09/13] VLCKit: migrate VLCStreamSession to ARC / modern Obj-C

Florent Pillet fpillet at gmail.com
Mon Jul 7 12:41:24 CEST 2014


---
 Headers/Public/VLCStreamSession.h | 15 ++++++---------
 Sources/VLCStreamSession.m        | 36 ++++++++++++++++++------------------
 2 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/Headers/Public/VLCStreamSession.h b/Headers/Public/VLCStreamSession.h
index c9be53e..8610317 100644
--- a/Headers/Public/VLCStreamSession.h
+++ b/Headers/Public/VLCStreamSession.h
@@ -27,19 +27,16 @@
 #import <VLCKit/VLCMedia.h>
 
 
- at interface VLCStreamSession : VLCMediaPlayer {
-    VLCStreamOutput * streamOutput;
-    VLCMedia * originalMedia;
-    NSUInteger reattemptedConnections;
-    BOOL isComplete;
-}
+ at interface VLCStreamSession : VLCMediaPlayer
 
 + (id)streamSession;
 
- at property (retain) VLCMedia * media;
- at property (retain) VLCStreamOutput * streamOutput;
- at property (readonly) BOOL isComplete;
+ at property (nonatomic, strong) VLCMedia * media;
+ at property (nonatomic, strong) VLCStreamOutput * streamOutput;
+ at property (nonatomic, readonly) BOOL isComplete;
+ at property (nonatomic, readonly) NSUInteger reattemptedConnections;
 
 - (void)startStreaming;
 - (void)stopStreaming;
+
 @end
diff --git a/Sources/VLCStreamSession.m b/Sources/VLCStreamSession.m
index b010f05..935f544 100644
--- a/Sources/VLCStreamSession.m
+++ b/Sources/VLCStreamSession.m
@@ -26,21 +26,19 @@
 #import "VLCLibVLCBridging.h"
 
 @interface VLCStreamSession ()
- at property (readwrite) BOOL isComplete;
+
+ at property (nonatomic, readwrite) BOOL isComplete;
+ at property (nonatomic, readwrite) NSUInteger reattemptedConnections;
+
 @end
 
 @implementation VLCStreamSession
- at synthesize media=originalMedia;
- at synthesize streamOutput;
- at synthesize isComplete;
 
 - (id)init
 {
     if( self = [super init] )
     {
-        reattemptedConnections = 0;
         [self addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];
-        self.isComplete = NO;
     }
     return self;
 }
@@ -48,12 +46,11 @@
 - (void)dealloc
 {
     [self removeObserver:self forKeyPath:@"state"];
-    [super dealloc];
 }
 
 + (id)streamSession
 {
-    return [[[self alloc] init] autorelease];
+    return [[self alloc] init];
 }
 
 
@@ -73,13 +70,15 @@
 {
     NSString * libvlcArgs;
     if( self.drawable )
-        libvlcArgs = [NSString stringWithFormat:@"#duplicate{dst=display,dst=\"%@\"}",[streamOutput representedLibVLCOptions]];
+        libvlcArgs = [NSString stringWithFormat:@"#duplicate{dst=display,dst=\"%@\"}",[_streamOutput representedLibVLCOptions]];
     else
-        libvlcArgs = [streamOutput representedLibVLCOptions];
+        libvlcArgs = [_streamOutput representedLibVLCOptions];
     if( libvlcArgs )
     {
-        [super setMedia: [VLCMedia mediaWithMedia:originalMedia andLibVLCOptions:
-                                [NSDictionary dictionaryWithObject: libvlcArgs forKey: @"sout"]]];
+        [super setMedia:[VLCMedia mediaWithMedia:_media
+								andLibVLCOptions:@{
+									@"sout" : libvlcArgs
+								}]];
     }
     else
     {
@@ -96,12 +95,13 @@
 
 - (NSString *)description
 {
-    if([self isComplete])
+    if ([self isComplete])
         return @"Done.";
-    else if([self state] == VLCMediaPlayerStateError)
+
+	if ([self state] == VLCMediaPlayerStateError)
         return @"Error while Converting. Open Console.app to diagnose.";
-    else
-        return @"Converting...";
+
+    return @"Converting...";
 }
 
 + (NSSet *)keyPathsForValuesAffectingEncounteredError
@@ -124,7 +124,7 @@
             self.isComplete = YES;
             return;
         }
-        if( reattemptedConnections > 4 )
+        if( _reattemptedConnections > 4 )
             return;
 
         /* Our media has in fact gained subitems, let's change our playing media */
@@ -133,7 +133,7 @@
             [self stop];
             self.media = [[super.media subitems] mediaAtIndex:0];
             [self play];
-            reattemptedConnections++;
+            _reattemptedConnections++;
         }
         return;
     }
-- 
1.8.5.2 (Apple Git-48)




More information about the vlc-devel mailing list