21 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/GCD/Documentation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Welcome to the CocoaAsyncSocket project!
5 |
6 |
7 | A wealth of documentation can be found on the Google Code homepage:
8 | https://github.com/robbiehanson/CocoaAsyncSocket
9 |
10 |
11 |
12 | If you are new to networking, it is recommended you start by reading the Intro page:
13 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/Intro
14 |
15 |
16 |
17 | If you are a seasoned networking professional, with 10+ years of experience writing low-level socket code,
18 | and detailed knowledge of the underlying BSD networking stack, then you can skip the CommonPitfalls page.
19 | Otherwise, it should be considered mandatory reading:
20 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/CommonPitfalls
21 |
22 |
23 |
24 | A little bit of investment in your knowledge and understanding of networking fundamentals can go a long way.
25 | And it can save you a LOT of time and frustration in the long run.
26 |
27 |
28 |
29 | Your first goto for reference should ALWAYS be the header files. They are extremely well documented. Please read them.
30 |
31 |
32 |
33 | Did I mention you should read the headers? They're docemented very nicely, in plain english.
34 |
35 |
36 |
37 | If you have any questions you are welcome to post to the CocoaAsyncSocket mailing list:
38 | http://groups.google.com/group/cocoaasyncsocket
39 |
40 | The list is archived, and available for browsing online.
41 | You may be able to instantly find the answer you're looking for with a quick search.
42 |
43 |
44 | We hope the CocoaAsyncSocket project can provide you with powerful and easy to use networking libraries.
45 |
46 |
47 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/RunLoop/Documentation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Welcome to the CocoaAsyncSocket project!
5 |
6 |
7 | A wealth of documentation can be found on the Google Code homepage:
8 | https://github.com/robbiehanson/CocoaAsyncSocket
9 |
10 |
11 |
12 | If you are new to networking, it is recommended you start by reading the Intro page:
13 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/Intro
14 |
15 |
16 |
17 | If you are a seasoned networking professional, with 10+ years of experience writing low-level socket code,
18 | and detailed knowledge of the underlying BSD networking stack, then you can skip the CommonPitfalls page.
19 | Otherwise, it should be considered mandatory reading:
20 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/CommonPitfalls
21 |
22 |
23 |
24 | A little bit of investment in your knowledge and understanding of networking fundamentals can go a long way.
25 | And it can save you a LOT of time and frustration in the long run.
26 |
27 |
28 |
29 | Your first goto for reference should ALWAYS be the header files. They are extremely well documented. Please read them.
30 |
31 |
32 |
33 | Did I mention you should read the headers? They're docemented very nicely, in plain english.
34 |
35 |
36 |
37 | If you have any questions you are welcome to post to the CocoaAsyncSocket mailing list:
38 | http://groups.google.com/group/cocoaasyncsocket
39 |
40 | The list is archived, and available for browsing online.
41 | You may be able to instantly find the answer you're looking for with a quick search.
42 |
43 |
44 | We hope the CocoaAsyncSocket project can provide you with powerful and easy to use networking libraries.
45 |
46 |
47 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/DDASLLogger.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import "DDLog.h"
5 |
6 | /**
7 | * Welcome to Cocoa Lumberjack!
8 | *
9 | * The project page has a wealth of documentation if you have any questions.
10 | * https://github.com/CocoaLumberjack/CocoaLumberjack
11 | *
12 | * If you're new to the project you may wish to read the "Getting Started" wiki.
13 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
14 | *
15 | *
16 | * This class provides a logger for the Apple System Log facility.
17 | *
18 | * As described in the "Getting Started" page,
19 | * the traditional NSLog() function directs it's output to two places:
20 | *
21 | * - Apple System Log
22 | * - StdErr (if stderr is a TTY) so log statements show up in Xcode console
23 | *
24 | * To duplicate NSLog() functionality you can simply add this logger and a tty logger.
25 | * However, if you instead choose to use file logging (for faster performance),
26 | * you may choose to use a file logger and a tty logger.
27 | **/
28 |
29 | @interface DDASLLogger : DDAbstractLogger
30 | {
31 | aslclient client;
32 | }
33 |
34 | + (instancetype)sharedInstance;
35 |
36 | // Inherited from DDAbstractLogger
37 |
38 | // - (id )logFormatter;
39 | // - (void)setLogFormatter:(id )formatter;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/DDASLLogger.m:
--------------------------------------------------------------------------------
1 | #import "DDASLLogger.h"
2 |
3 | #import
4 |
5 | /**
6 | * Welcome to Cocoa Lumberjack!
7 | *
8 | * The project page has a wealth of documentation if you have any questions.
9 | * https://github.com/CocoaLumberjack/CocoaLumberjack
10 | *
11 | * If you're new to the project you may wish to read the "Getting Started" wiki.
12 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
13 | **/
14 |
15 | #if ! __has_feature(objc_arc)
16 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
17 | #endif
18 |
19 |
20 | @implementation DDASLLogger
21 |
22 | static DDASLLogger *sharedInstance;
23 |
24 | /**
25 | * The runtime sends initialize to each class in a program exactly one time just before the class,
26 | * or any class that inherits from it, is sent its first message from within the program. (Thus the
27 | * method may never be invoked if the class is not used.) The runtime sends the initialize message to
28 | * classes in a thread-safe manner. Superclasses receive this message before their subclasses.
29 | *
30 | * This method may also be called directly (assumably by accident), hence the safety mechanism.
31 | **/
32 | + (void)initialize
33 | {
34 | static BOOL initialized = NO;
35 | if (!initialized)
36 | {
37 | initialized = YES;
38 |
39 | sharedInstance = [[[self class] alloc] init];
40 | }
41 | }
42 |
43 | + (instancetype)sharedInstance
44 | {
45 | return sharedInstance;
46 | }
47 |
48 | - (id)init
49 | {
50 | if (sharedInstance != nil)
51 | {
52 | return nil;
53 | }
54 |
55 | if ((self = [super init]))
56 | {
57 | // A default asl client is provided for the main thread,
58 | // but background threads need to create their own client.
59 |
60 | client = asl_open(NULL, "com.apple.console", 0);
61 | }
62 | return self;
63 | }
64 |
65 | - (void)logMessage:(DDLogMessage *)logMessage
66 | {
67 | NSString *logMsg = logMessage->logMsg;
68 |
69 | if (formatter)
70 | {
71 | logMsg = [formatter formatLogMessage:logMessage];
72 | }
73 |
74 | if (logMsg)
75 | {
76 | const char *msg = [logMsg UTF8String];
77 |
78 | int aslLogLevel;
79 | switch (logMessage->logFlag)
80 | {
81 | // Note: By default ASL will filter anything above level 5 (Notice).
82 | // So our mappings shouldn't go above that level.
83 |
84 | case LOG_FLAG_ERROR : aslLogLevel = ASL_LEVEL_ALERT; break;
85 | case LOG_FLAG_WARN : aslLogLevel = ASL_LEVEL_CRIT; break;
86 | case LOG_FLAG_INFO : aslLogLevel = ASL_LEVEL_ERR; break;
87 | case LOG_FLAG_DEBUG : aslLogLevel = ASL_LEVEL_WARNING; break;
88 | default : aslLogLevel = ASL_LEVEL_NOTICE; break;
89 | }
90 |
91 | asl_log(client, NULL, aslLogLevel, "%s", msg);
92 | }
93 | }
94 |
95 | - (NSString *)loggerName
96 | {
97 | return @"cocoa.lumberjack.aslLogger";
98 | }
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "DDLog.h"
4 |
5 | /**
6 | * Welcome to Cocoa Lumberjack!
7 | *
8 | * The project page has a wealth of documentation if you have any questions.
9 | * https://github.com/CocoaLumberjack/CocoaLumberjack
10 | *
11 | * If you're new to the project you may wish to read the "Getting Started" wiki.
12 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
13 | *
14 | *
15 | * This class provides an abstract implementation of a database logger.
16 | *
17 | * That is, it provides the base implementation for a database logger to build atop of.
18 | * All that is needed for a concrete database logger is to extend this class
19 | * and override the methods in the implementation file that are prefixed with "db_".
20 | **/
21 |
22 | @interface DDAbstractDatabaseLogger : DDAbstractLogger {
23 | @protected
24 | NSUInteger saveThreshold;
25 | NSTimeInterval saveInterval;
26 | NSTimeInterval maxAge;
27 | NSTimeInterval deleteInterval;
28 | BOOL deleteOnEverySave;
29 |
30 | BOOL saveTimerSuspended;
31 | NSUInteger unsavedCount;
32 | dispatch_time_t unsavedTime;
33 | dispatch_source_t saveTimer;
34 | dispatch_time_t lastDeleteTime;
35 | dispatch_source_t deleteTimer;
36 | }
37 |
38 | /**
39 | * Specifies how often to save the data to disk.
40 | * Since saving is an expensive operation (disk io) it is not done after every log statement.
41 | * These properties allow you to configure how/when the logger saves to disk.
42 | *
43 | * A save is done when either (whichever happens first):
44 | *
45 | * - The number of unsaved log entries reaches saveThreshold
46 | * - The amount of time since the oldest unsaved log entry was created reaches saveInterval
47 | *
48 | * You can optionally disable the saveThreshold by setting it to zero.
49 | * If you disable the saveThreshold you are entirely dependent on the saveInterval.
50 | *
51 | * You can optionally disable the saveInterval by setting it to zero (or a negative value).
52 | * If you disable the saveInterval you are entirely dependent on the saveThreshold.
53 | *
54 | * It's not wise to disable both saveThreshold and saveInterval.
55 | *
56 | * The default saveThreshold is 500.
57 | * The default saveInterval is 60 seconds.
58 | **/
59 | @property (assign, readwrite) NSUInteger saveThreshold;
60 | @property (assign, readwrite) NSTimeInterval saveInterval;
61 |
62 | /**
63 | * It is likely you don't want the log entries to persist forever.
64 | * Doing so would allow the database to grow infinitely large over time.
65 | *
66 | * The maxAge property provides a way to specify how old a log statement can get
67 | * before it should get deleted from the database.
68 | *
69 | * The deleteInterval specifies how often to sweep for old log entries.
70 | * Since deleting is an expensive operation (disk io) is is done on a fixed interval.
71 | *
72 | * An alternative to the deleteInterval is the deleteOnEverySave option.
73 | * This specifies that old log entries should be deleted during every save operation.
74 | *
75 | * You can optionally disable the maxAge by setting it to zero (or a negative value).
76 | * If you disable the maxAge then old log statements are not deleted.
77 | *
78 | * You can optionally disable the deleteInterval by setting it to zero (or a negative value).
79 | *
80 | * If you disable both deleteInterval and deleteOnEverySave then old log statements are not deleted.
81 | *
82 | * It's not wise to enable both deleteInterval and deleteOnEverySave.
83 | *
84 | * The default maxAge is 7 days.
85 | * The default deleteInterval is 5 minutes.
86 | * The default deleteOnEverySave is NO.
87 | **/
88 | @property (assign, readwrite) NSTimeInterval maxAge;
89 | @property (assign, readwrite) NSTimeInterval deleteInterval;
90 | @property (assign, readwrite) BOOL deleteOnEverySave;
91 |
92 | /**
93 | * Forces a save of any pending log entries (flushes log entries to disk).
94 | **/
95 | - (void)savePendingLogEntries;
96 |
97 | /**
98 | * Removes any log entries that are older than maxAge.
99 | **/
100 | - (void)deleteOldLogEntries;
101 |
102 | @end
103 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/DDLog+LOGV.h:
--------------------------------------------------------------------------------
1 | //
2 | // DDLog+LOGV.h
3 | // Lumberjack
4 | //
5 | // Created by Mike Pontillo on 11/20/12.
6 | //
7 | //
8 |
9 | #ifndef Lumberjack_DDLog_LOGV_h
10 | #define Lumberjack_DDLog_LOGV_h
11 |
12 | #import "DDLog.h"
13 |
14 |
15 | #define LOGV_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, avalist) \
16 | [DDLog log:isAsynchronous \
17 | level:lvl \
18 | flag:flg \
19 | context:ctx \
20 | file:__FILE__ \
21 | function:fnct \
22 | line:__LINE__ \
23 | tag:atag \
24 | format:frmt \
25 | args:avalist]
26 |
27 | #define LOGV_OBJC_MACRO(async, lvl, flg, ctx, frmt, avalist) \
28 | LOGV_MACRO(async, lvl, flg, ctx, nil, sel_getName(_cmd), frmt, avalist)
29 |
30 | #define LOGV_C_MACRO(async, lvl, flg, ctx, frmt, avalist) \
31 | LOGV_MACRO(async, lvl, flg, ctx, nil, __FUNCTION__, frmt, avalist)
32 |
33 |
34 |
35 | #define SYNC_LOGV_OBJC_MACRO(lvl, flg, ctx, frmt, avalist) \
36 | LOGV_OBJC_MACRO( NO, lvl, flg, ctx, frmt, avalist)
37 |
38 | #define ASYNC_LOGV_OBJC_MACRO(lvl, flg, ctx, frmt, avalist) \
39 | LOGV_OBJC_MACRO(YES, lvl, flg, ctx, frmt, avalist)
40 |
41 | #define SYNC_LOGV_C_MACRO(lvl, flg, ctx, frmt, avalist) \
42 | LOGV_C_MACRO( NO, lvl, flg, ctx, frmt, avalist)
43 |
44 | #define ASYNC_LOGV_C_MACRO(lvl, flg, ctx, frmt, avalist) \
45 | LOGV_C_MACRO(YES, lvl, flg, ctx, frmt, avalist)
46 |
47 |
48 |
49 | #define LOGV_MAYBE(async, lvl, flg, ctx, fnct, frmt, avalist) \
50 | do { if(lvl & flg) LOGV_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, avalist); } while(0)
51 |
52 | #define LOGV_OBJC_MAYBE(async, lvl, flg, ctx, frmt, avalist) \
53 | LOGV_MAYBE(async, lvl, flg, ctx, sel_getName(_cmd), frmt, avalist)
54 |
55 | #define LOGV_C_MAYBE(async, lvl, flg, ctx, frmt, avalist) \
56 | LOGV_MAYBE(async, lvl, flg, ctx, __FUNCTION__, frmt, avalist)
57 |
58 | #define SYNC_LOGV_OBJC_MAYBE(lvl, flg, ctx, frmt, avalist) \
59 | LOGV_OBJC_MAYBE( NO, lvl, flg, ctx, frmt, avalist)
60 |
61 | #define ASYNC_LOGV_OBJC_MAYBE(lvl, flg, ctx, frmt, avalist) \
62 | LOGV_OBJC_MAYBE(YES, lvl, flg, ctx, frmt, avalist)
63 |
64 | #define SYNC_LOGV_C_MAYBE(lvl, flg, ctx, frmt, avalist) \
65 | LOGV_C_MAYBE( NO, lvl, flg, ctx, frmt, avalist)
66 |
67 | #define ASYNC_LOGV_C_MAYBE(lvl, flg, ctx, frmt, avalist) \
68 | LOGV_C_MAYBE(YES, lvl, flg, ctx, frmt, avalist)
69 |
70 |
71 |
72 | #define LOGV_OBJC_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, avalist) \
73 | LOGV_MACRO(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, avalist)
74 |
75 | #define LOGV_C_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, avalist) \
76 | LOGV_MACRO(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, avalist)
77 |
78 | #define LOGV_TAG_MAYBE(async, lvl, flg, ctx, tag, fnct, frmt, avalist) \
79 | do { if(lvl & flg) LOGV_MACRO(async, lvl, flg, ctx, tag, fnct, frmt, avalist); } while(0)
80 |
81 | #define LOGV_OBJC_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, avalist) \
82 | LOGV_TAG_MAYBE(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, avalist)
83 |
84 | #define LOGV_C_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, avalist) \
85 | LOGV_TAG_MAYBE(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, avalist)
86 |
87 |
88 |
89 | #define DDLogvError(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, avalist)
90 | #define DDLogvWarn(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, avalist)
91 | #define DDLogvInfo(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, avalist)
92 | #define DDLogvVerbose(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, avalist)
93 |
94 | #define DDLogvCError(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, avalist)
95 | #define DDLogvCWarn(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, avalist)
96 | #define DDLogvCInfo(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, avalist)
97 | #define DDLogvCVerbose(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, avalist)
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/DDContextFilterLogFormatter.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "DDLog.h"
3 |
4 | /**
5 | * Welcome to Cocoa Lumberjack!
6 | *
7 | * The project page has a wealth of documentation if you have any questions.
8 | * https://github.com/CocoaLumberjack/CocoaLumberjack
9 | *
10 | * If you're new to the project you may wish to read the "Getting Started" page.
11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
12 | *
13 | *
14 | * This class provides a log formatter that filters log statements from a logging context not on the whitelist.
15 | *
16 | * A log formatter can be added to any logger to format and/or filter its output.
17 | * You can learn more about log formatters here:
18 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters
19 | *
20 | * You can learn more about logging context's here:
21 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomContext
22 | *
23 | * But here's a quick overview / refresher:
24 | *
25 | * Every log statement has a logging context.
26 | * These come from the underlying logging macros defined in DDLog.h.
27 | * The default logging context is zero.
28 | * You can define multiple logging context's for use in your application.
29 | * For example, logically separate parts of your app each have a different logging context.
30 | * Also 3rd party frameworks that make use of Lumberjack generally use their own dedicated logging context.
31 | **/
32 | @interface DDContextWhitelistFilterLogFormatter : NSObject
33 |
34 | - (id)init;
35 |
36 | - (void)addToWhitelist:(int)loggingContext;
37 | - (void)removeFromWhitelist:(int)loggingContext;
38 |
39 | - (NSArray *)whitelist;
40 |
41 | - (BOOL)isOnWhitelist:(int)loggingContext;
42 |
43 | @end
44 |
45 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
46 | #pragma mark -
47 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48 |
49 | /**
50 | * This class provides a log formatter that filters log statements from a logging context on the blacklist.
51 | **/
52 | @interface DDContextBlacklistFilterLogFormatter : NSObject
53 |
54 | - (id)init;
55 |
56 | - (void)addToBlacklist:(int)loggingContext;
57 | - (void)removeFromBlacklist:(int)loggingContext;
58 |
59 | - (NSArray *)blacklist;
60 |
61 | - (BOOL)isOnBlacklist:(int)loggingContext;
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/DDContextFilterLogFormatter.m:
--------------------------------------------------------------------------------
1 | #import "DDContextFilterLogFormatter.h"
2 | #import
3 |
4 | /**
5 | * Welcome to Cocoa Lumberjack!
6 | *
7 | * The project page has a wealth of documentation if you have any questions.
8 | * https://github.com/CocoaLumberjack/CocoaLumberjack
9 | *
10 | * If you're new to the project you may wish to read the "Getting Started" wiki.
11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
12 | **/
13 |
14 | #if ! __has_feature(objc_arc)
15 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
16 | #endif
17 |
18 | @interface DDLoggingContextSet : NSObject
19 |
20 | - (void)addToSet:(int)loggingContext;
21 | - (void)removeFromSet:(int)loggingContext;
22 |
23 | - (NSArray *)currentSet;
24 |
25 | - (BOOL)isInSet:(int)loggingContext;
26 |
27 | @end
28 |
29 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
30 | #pragma mark -
31 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
32 |
33 | @implementation DDContextWhitelistFilterLogFormatter
34 | {
35 | DDLoggingContextSet *contextSet;
36 | }
37 |
38 | - (id)init
39 | {
40 | if ((self = [super init]))
41 | {
42 | contextSet = [[DDLoggingContextSet alloc] init];
43 | }
44 | return self;
45 | }
46 |
47 |
48 | - (void)addToWhitelist:(int)loggingContext
49 | {
50 | [contextSet addToSet:loggingContext];
51 | }
52 |
53 | - (void)removeFromWhitelist:(int)loggingContext
54 | {
55 | [contextSet removeFromSet:loggingContext];
56 | }
57 |
58 | - (NSArray *)whitelist
59 | {
60 | return [contextSet currentSet];
61 | }
62 |
63 | - (BOOL)isOnWhitelist:(int)loggingContext
64 | {
65 | return [contextSet isInSet:loggingContext];
66 | }
67 |
68 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage
69 | {
70 | if ([self isOnWhitelist:logMessage->logContext])
71 | return logMessage->logMsg;
72 | else
73 | return nil;
74 | }
75 |
76 | @end
77 |
78 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
79 | #pragma mark -
80 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
81 |
82 | @implementation DDContextBlacklistFilterLogFormatter
83 | {
84 | DDLoggingContextSet *contextSet;
85 | }
86 |
87 | - (id)init
88 | {
89 | if ((self = [super init]))
90 | {
91 | contextSet = [[DDLoggingContextSet alloc] init];
92 | }
93 | return self;
94 | }
95 |
96 |
97 | - (void)addToBlacklist:(int)loggingContext
98 | {
99 | [contextSet addToSet:loggingContext];
100 | }
101 |
102 | - (void)removeFromBlacklist:(int)loggingContext
103 | {
104 | [contextSet removeFromSet:loggingContext];
105 | }
106 |
107 | - (NSArray *)blacklist
108 | {
109 | return [contextSet currentSet];
110 | }
111 |
112 | - (BOOL)isOnBlacklist:(int)loggingContext
113 | {
114 | return [contextSet isInSet:loggingContext];
115 | }
116 |
117 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage
118 | {
119 | if ([self isOnBlacklist:logMessage->logContext])
120 | return nil;
121 | else
122 | return logMessage->logMsg;
123 | }
124 |
125 | @end
126 |
127 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
128 | #pragma mark -
129 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
130 |
131 | @implementation DDLoggingContextSet
132 | {
133 | OSSpinLock lock;
134 | NSMutableSet *set;
135 | }
136 |
137 | - (id)init
138 | {
139 | if ((self = [super init]))
140 | {
141 | set = [[NSMutableSet alloc] init];
142 | }
143 | return self;
144 | }
145 |
146 |
147 | - (void)addToSet:(int)loggingContext
148 | {
149 | OSSpinLockLock(&lock);
150 | {
151 | [set addObject:@(loggingContext)];
152 | }
153 | OSSpinLockUnlock(&lock);
154 | }
155 |
156 | - (void)removeFromSet:(int)loggingContext
157 | {
158 | OSSpinLockLock(&lock);
159 | {
160 | [set removeObject:@(loggingContext)];
161 | }
162 | OSSpinLockUnlock(&lock);
163 | }
164 |
165 | - (NSArray *)currentSet
166 | {
167 | NSArray *result = nil;
168 |
169 | OSSpinLockLock(&lock);
170 | {
171 | result = [set allObjects];
172 | }
173 | OSSpinLockUnlock(&lock);
174 |
175 | return result;
176 | }
177 |
178 | - (BOOL)isInSet:(int)loggingContext
179 | {
180 | BOOL result = NO;
181 |
182 | OSSpinLockLock(&lock);
183 | {
184 | result = [set containsObject:@(loggingContext)];
185 | }
186 | OSSpinLockUnlock(&lock);
187 |
188 | return result;
189 | }
190 |
191 | @end
192 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/DDMultiFormatter.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "DDLog.h"
3 |
4 | /**
5 | * Welcome to Cocoa Lumberjack!
6 | *
7 | * The project page has a wealth of documentation if you have any questions.
8 | * https://github.com/CocoaLumberjack/CocoaLumberjack
9 | *
10 | * If you're new to the project you may wish to read the "Getting Started" page.
11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
12 | *
13 | *
14 | * This formatter can be used to chain different formatters together.
15 | * The log message will processed in the order of the formatters added.
16 | **/
17 |
18 | @interface DDMultiFormatter : NSObject
19 |
20 | /**
21 | * Array of chained formatters
22 | */
23 | @property (readonly) NSArray *formatters;
24 |
25 | - (void)addFormatter:(id)formatter;
26 | - (void)removeFormatter:(id)formatter;
27 | - (void)removeAllFormatters;
28 | - (BOOL)isFormattingWithFormatter:(id)formatter;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/DDMultiFormatter.m:
--------------------------------------------------------------------------------
1 | #import "DDMultiFormatter.h"
2 |
3 | /**
4 | * Welcome to Cocoa Lumberjack!
5 | *
6 | * The project page has a wealth of documentation if you have any questions.
7 | * https://github.com/CocoaLumberjack/CocoaLumberjack
8 | *
9 | * If you're new to the project you may wish to read the "Getting Started" page.
10 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
11 | **/
12 |
13 | #if TARGET_OS_IPHONE
14 | // Compiling for iOS
15 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
16 | #define NEEDS_DISPATCH_RETAIN_RELEASE 0
17 | #else // iOS 5.X or earlier
18 | #define NEEDS_DISPATCH_RETAIN_RELEASE 1
19 | #endif
20 | #else
21 | // Compiling for Mac OS X
22 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
23 | #define NEEDS_DISPATCH_RETAIN_RELEASE 0
24 | #else // Mac OS X 10.7 or earlier
25 | #define NEEDS_DISPATCH_RETAIN_RELEASE 1
26 | #endif
27 | #endif
28 |
29 |
30 | @interface DDMultiFormatter ()
31 |
32 | - (DDLogMessage *)logMessageForLine:(NSString *)line originalMessage:(DDLogMessage *)message;
33 |
34 | @end
35 |
36 |
37 | @implementation DDMultiFormatter {
38 | dispatch_queue_t _queue;
39 | NSMutableArray *_formatters;
40 | }
41 |
42 | - (id)init {
43 | self = [super init];
44 | if (self) {
45 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
46 | _queue = dispatch_queue_create("cocoa.lumberjack.multiformatter", DISPATCH_QUEUE_CONCURRENT);
47 | #else
48 | _queue = dispatch_queue_create("cocoa.lumberjack.multiformatter", NULL);
49 | #endif
50 | _formatters = [NSMutableArray new];
51 | }
52 |
53 | return self;
54 | }
55 |
56 | #if NEEDS_DISPATCH_RETAIN_RELEASE
57 | - (void)dealloc {
58 | dispatch_release(_queue);
59 | }
60 | #endif
61 |
62 | #pragma mark Processing
63 |
64 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage {
65 | __block NSString *line = logMessage->logMsg;
66 |
67 | dispatch_sync(_queue, ^{
68 | for (id formatter in _formatters) {
69 | DDLogMessage *message = [self logMessageForLine:line originalMessage:logMessage];
70 | line = [formatter formatLogMessage:message];
71 |
72 | if (!line) {
73 | break;
74 | }
75 | }
76 | });
77 |
78 | return line;
79 | }
80 |
81 | - (DDLogMessage *)logMessageForLine:(NSString *)line originalMessage:(DDLogMessage *)message {
82 | DDLogMessage *newMessage = [message copy];
83 | newMessage->logMsg = line;
84 | return newMessage;
85 | }
86 |
87 | #pragma mark Formatters
88 |
89 | - (NSArray *)formatters {
90 | __block NSArray *formatters;
91 |
92 | dispatch_sync(_queue, ^{
93 | formatters = [_formatters copy];
94 | });
95 |
96 | return formatters;
97 | }
98 |
99 | - (void)addFormatter:(id)formatter {
100 | dispatch_barrier_async(_queue, ^{
101 | [_formatters addObject:formatter];
102 | });
103 | }
104 |
105 | - (void)removeFormatter:(id)formatter {
106 | dispatch_barrier_async(_queue, ^{
107 | [_formatters removeObject:formatter];
108 | });
109 | }
110 |
111 | - (void)removeAllFormatters {
112 | dispatch_barrier_async(_queue, ^{
113 | [_formatters removeAllObjects];
114 | });
115 | }
116 |
117 | - (BOOL)isFormattingWithFormatter:(id)formatter {
118 | __block BOOL hasFormatter;
119 |
120 | dispatch_sync(_queue, ^{
121 | hasFormatter = [_formatters containsObject:formatter];
122 | });
123 |
124 | return hasFormatter;
125 | }
126 |
127 | @end
128 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/README.txt:
--------------------------------------------------------------------------------
1 | This folder contains some sample formatters that may be helpful.
2 |
3 | Feel free to change them, extend them, or use them as the basis for your own custom formatter(s).
4 |
5 | More information about creating your own custom formatters can be found on the wiki:
6 | https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters
7 |
8 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/CocoaAsyncSocketTestsMac.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
86 |
87 |
88 |
89 |
91 |
92 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/CocoaAsyncSocketTestsiOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
86 |
87 |
88 |
89 |
91 |
92 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/Mac/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.chrisballinger.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/Podfile:
--------------------------------------------------------------------------------
1 | source 'https://github.com/CocoaPods/Specs.git'
2 |
3 | use_frameworks!
4 |
5 | target :CocoaAsyncSocketTestsMac do
6 | platform :osx, '10.8'
7 | pod 'CocoaAsyncSocket', :path => '../CocoaAsyncSocket.podspec'
8 | end
9 |
10 | target :CocoaAsyncSocketTestsiOS do
11 | platform :ios, '8.0'
12 | pod 'CocoaAsyncSocket', :path => '../CocoaAsyncSocket.podspec'
13 | end
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - CocoaAsyncSocket (7.4.2)
3 |
4 | DEPENDENCIES:
5 | - CocoaAsyncSocket (from `../CocoaAsyncSocket.podspec`)
6 |
7 | EXTERNAL SOURCES:
8 | CocoaAsyncSocket:
9 | :path: ../CocoaAsyncSocket.podspec
10 |
11 | SPEC CHECKSUMS:
12 | CocoaAsyncSocket: f5783bdedd232d91b89769bc4b5a1580aed518ad
13 |
14 | COCOAPODS: 0.38.2
15 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/Shared/GCDAsyncSocketConnectionTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // GCDAsyncSocketConnectionTests.m
3 | // GCDAsyncSocketConnectionTests
4 | //
5 | // Created by Christopher Ballinger on 10/31/14.
6 | //
7 | //
8 |
9 | #import
10 | #import
11 | @import CocoaAsyncSocket;
12 |
13 | static const uint16_t kTestPort = 30301;
14 |
15 | @interface GCDAsyncSocketConnectionTests : XCTestCase
16 | @property (nonatomic, strong) GCDAsyncSocket *clientSocket;
17 | @property (nonatomic, strong) GCDAsyncSocket *serverSocket;
18 | @property (nonatomic, strong) GCDAsyncSocket *acceptedServerSocket;
19 |
20 | @property (nonatomic, strong) XCTestExpectation *expectation;
21 | @end
22 |
23 | @implementation GCDAsyncSocketConnectionTests
24 |
25 | - (void)setUp {
26 | [super setUp];
27 | // Put setup code here. This method is called before the invocation of each test method in the class.
28 | self.clientSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
29 | self.serverSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
30 | }
31 |
32 | - (void)tearDown {
33 | // Put teardown code here. This method is called after the invocation of each test method in the class.
34 | [super tearDown];
35 | [self.clientSocket disconnect];
36 | [self.serverSocket disconnect];
37 | [self.acceptedServerSocket disconnect];
38 | self.clientSocket = nil;
39 | self.serverSocket = nil;
40 | self.acceptedServerSocket = nil;
41 | }
42 |
43 | - (void)testFullConnection {
44 | NSError *error = nil;
45 | BOOL success = NO;
46 | success = [self.serverSocket acceptOnPort:kTestPort error:&error];
47 | XCTAssertTrue(success, @"Server failed setting up socket on port %d %@", kTestPort, error);
48 | success = [self.clientSocket connectToHost:@"127.0.0.1" onPort:kTestPort error:&error];
49 | XCTAssertTrue(success, @"Client failed connecting to up server socket on port %d %@", kTestPort, error);
50 |
51 | self.expectation = [self expectationWithDescription:@"Test Full Connection"];
52 | [self waitForExpectationsWithTimeout:30 handler:^(NSError *error) {
53 | if (error) {
54 | NSLog(@"Error establishing test connection");
55 | }
56 | }];
57 | }
58 |
59 | #pragma mark GCDAsyncSocketDelegate methods
60 |
61 | /**
62 | * Called when a socket accepts a connection.
63 | * Another socket is automatically spawned to handle it.
64 | *
65 | * You must retain the newSocket if you wish to handle the connection.
66 | * Otherwise the newSocket instance will be released and the spawned connection will be closed.
67 | *
68 | * By default the new socket will have the same delegate and delegateQueue.
69 | * You may, of course, change this at any time.
70 | **/
71 | - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket {
72 | NSLog(@"didAcceptNewSocket %@ %@", sock, newSocket);
73 | self.acceptedServerSocket = newSocket;
74 | }
75 |
76 | /**
77 | * Called when a socket connects and is ready for reading and writing.
78 | * The host parameter will be an IP address, not a DNS name.
79 | **/
80 | - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port {
81 | NSLog(@"didConnectToHost %@ %@ %d", sock, host, port);
82 | [self.expectation fulfill];
83 | }
84 |
85 |
86 | @end
87 |
--------------------------------------------------------------------------------
/CocoaAsyncSocket/Tests/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.chrisballinger.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Core/CameraEncoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // CameraEncoder.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeong-uk Park on 2016. 2. 10..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | #import "H264HWEncoder.h"
13 |
14 | #if TARGET_OS_IPHONE
15 | #import
16 | #import "AACEncoder.h"
17 | #endif
18 |
19 | #if TARGET_OS_IPHONE
20 | @interface CameraEncoder : NSObject
21 | #else
22 | @interface CameraEncoder : NSObject
23 | #endif
24 |
25 | @property (weak, nonatomic) AVCaptureVideoPreviewLayer *previewLayer;
26 |
27 | - (void) initCameraWithOutputSize:(CGSize)size;
28 | - (void) startCamera;
29 | - (void) stopCamera;
30 |
31 | @end
32 |
33 |
--------------------------------------------------------------------------------
/Core/Codec/AACEncoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // AACEncoder.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Park on 2016. 1. 8..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 | // AAC Software Encoder
9 |
10 | #import
11 | #import
12 |
13 | @protocol AACEncoderDelegate
14 |
15 | @required
16 | - (void)gotAACEncodedData:(NSData*)data timestamp:(CMTime)timestamp error:(NSError*)error;
17 |
18 | @end
19 |
20 | @interface AACEncoder : NSObject
21 |
22 | @property (weak, nonatomic) id delegate;
23 |
24 | @property (nonatomic) dispatch_queue_t encoderQueue;
25 | @property (nonatomic) dispatch_queue_t callbackQueue;
26 |
27 | - (void) encode:(CMSampleBufferRef)sampleBuffer;
28 |
29 | @end
--------------------------------------------------------------------------------
/Core/Codec/H264HWDecoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // H264HWDecoder.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Park on 2016. 1. 5..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 | // http://stackoverflow.com/questions/29525000/how-to-use-videotoolbox-to-decompress-h-264-video-stream/
9 |
10 | #import
11 | #import
12 |
13 | @protocol H264HWDecoderDelegate
14 |
15 | - (void)displayDecodedFrame:(CVImageBufferRef)imageBuffer;
16 |
17 | @end
18 |
19 | @interface H264HWDecoder : NSObject
20 |
21 | @property (weak, nonatomic) id delegate;
22 |
23 | -(void) receivedRawVideoFrame:(uint8_t *)frame withSize:(uint32_t)frameSize isIFrame:(int)isIFrame;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/Core/Codec/H264HWEncoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // H264HWEncoder.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Park on 2016. 1. 7..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 | // https://github.com/manishganvir/iOS-h264Hw-Toolbox
9 |
10 | #import
11 | #import
12 | #import "H264Packet.h"
13 |
14 | @protocol H264HWEncoderDelegate
15 |
16 | @required
17 | - (void)gotH264EncodedData:(NSData *)packet timestamp:(CMTime)timestamp;
18 |
19 | @end
20 |
21 | @interface H264HWEncoder : NSObject
22 |
23 | - (void) invalidate;
24 | - (void) setOutputSize:(CGSize)size;
25 | - (void) encode:(CMSampleBufferRef )sampleBuffer;
26 |
27 | @property (weak, nonatomic) id delegate;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/Core/Codec/H264Packet.h:
--------------------------------------------------------------------------------
1 | //
2 | // H264Packet.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeong-uk Park on 2016. 2. 25..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface H264Packet : NSObject
13 |
14 | @property (strong, nonatomic) NSMutableData *packet;
15 |
16 | - (id)initWithCMSampleBuffer:(CMSampleBufferRef)sample;
17 |
18 | - (void)packetizeAVC:(CMSampleBufferRef)sample;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/Core/Codec/H264Packet.m:
--------------------------------------------------------------------------------
1 | //
2 | // H264Packet.m
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeong-uk Park on 2016. 2. 25..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import "H264Packet.h"
10 |
11 | @interface H264Packet ()
12 | {
13 | }
14 |
15 | @end
16 |
17 | @implementation H264Packet
18 |
19 | - (id)initWithCMSampleBuffer:(CMSampleBufferRef)sample
20 | {
21 | self = [super init];
22 | if(self)
23 | {
24 | [self packetizeAVC:sample];
25 | }
26 | return self;
27 | }
28 |
29 | - (void)packetizeAVC:(CMSampleBufferRef)sample
30 | {
31 | self.packet = [NSMutableData data];
32 |
33 | NSData *sps, *pps;
34 |
35 | CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(sample);
36 | // CFDictionaryRef extensionDict = CMFormatDescriptionGetExtensions(format);
37 | // Get the extensions
38 | // From the extensions get the dictionary with key "SampleDescriptionExtensionAtoms"
39 | // From the dict, get the value for the key "avcC"
40 |
41 | size_t sparameterSetSize, sparameterSetCount;
42 | const uint8_t *sparameterSet;
43 | OSStatus statusCode = CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, 0, &sparameterSet, &sparameterSetSize, &sparameterSetCount, 0 );
44 | if (statusCode == noErr)
45 | {
46 | // Found sps and now check for pps
47 | size_t pparameterSetSize, pparameterSetCount;
48 | const uint8_t *pparameterSet;
49 | OSStatus statusCode = CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, 1, &pparameterSet, &pparameterSetSize, &pparameterSetCount, 0 );
50 | if (statusCode == noErr)
51 | {
52 | // Found pps
53 | sps = [NSData dataWithBytes:sparameterSet length:sparameterSetSize];
54 | pps = [NSData dataWithBytes:pparameterSet length:pparameterSetSize];
55 |
56 | const char bytes[] = "\x00\x00\x00\x01"; // SPS PPS Header
57 | size_t length = (sizeof bytes) - 1; //string literals have implicit trailing '\0'
58 | NSData *byteHeader = [NSData dataWithBytes:bytes length:length];
59 | NSMutableData *fullSPSData = [NSMutableData dataWithData:byteHeader];
60 | NSMutableData *fullPPSData = [NSMutableData dataWithData:byteHeader];
61 |
62 | [fullSPSData appendData:sps];
63 | [fullPPSData appendData:pps];
64 |
65 | sps = fullSPSData;
66 | pps = fullPPSData;
67 | }
68 | }
69 |
70 | CMBlockBufferRef dataBuffer = CMSampleBufferGetDataBuffer(sample);
71 | size_t length, totalLength;
72 | char *dataPointer;
73 | OSStatus statusCodeRet = CMBlockBufferGetDataPointer(dataBuffer, 0, &length, &totalLength, &dataPointer);
74 | if (statusCodeRet == noErr) {
75 |
76 | size_t bufferOffset = 0;
77 | static const int AVCCHeaderLength = 4;
78 | while (bufferOffset < totalLength - AVCCHeaderLength) {
79 | // Read the NAL unit length
80 | uint32_t NALUnitLength = 0;
81 | memcpy(&NALUnitLength, dataPointer + bufferOffset, AVCCHeaderLength);
82 |
83 | // Convert the length value from Big-endian to Little-endian
84 | NALUnitLength = CFSwapInt32BigToHost(NALUnitLength);
85 |
86 | NSData* data = [[NSData alloc] initWithBytes:(dataPointer + bufferOffset + AVCCHeaderLength) length:NALUnitLength];
87 |
88 | const char bytes[] = "\x00\x00\x00\x01"; // AVC Header
89 | size_t length = (sizeof bytes) - 1; //string literals have implicit trailing '\0'
90 | NSData *byteHeader = [NSData dataWithBytes:bytes length:length];
91 | NSMutableData *fullAVCData = [NSMutableData dataWithData:byteHeader];
92 |
93 | [fullAVCData appendData:data];
94 |
95 | [self.packet appendData:sps];
96 | [self.packet appendData:pps];
97 | [self.packet appendData:fullAVCData];
98 |
99 | // Move to the next NAL unit in the block buffer
100 | bufferOffset += AVCCHeaderLength + NALUnitLength;
101 | }
102 | }
103 | }
104 |
105 | @end
106 |
--------------------------------------------------------------------------------
/Core/RTP/RTPClient.h:
--------------------------------------------------------------------------------
1 | //
2 | // RTPClient.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Park on 2016. 1. 14..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RTPClient : NSObject
13 |
14 | @property (weak, nonatomic) NSString *address;
15 | @property (nonatomic) NSInteger port;
16 |
17 | - (void)reset;
18 | - (void)publish:(NSData *)data timestamp:(CMTime)timestamp payloadType:(NSInteger)payloadType;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/Core/RTP/RTPClient.m:
--------------------------------------------------------------------------------
1 | //
2 | // TSClient.mm
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Park on 2016. 1. 14..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 | // https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol
9 | // http://stackoverflow.com/questions/17896008/can-ffmpeg-library-send-the-live-h264-ios-camera-stream-to-wowza-using-rtsp
10 | // https://github.com/goertzenator/lwip/blob/master/contrib-1.4.0/apps/rtp/rtp.c
11 |
12 | #import "RTPClient.h"
13 | #import
14 |
15 | struct rtp_header {
16 | u_int16_t v:2; /* protocol version */
17 | u_int16_t p:1; /* padding flag */
18 | u_int16_t x:1; /* header extension flag */
19 | u_int16_t cc:4; /* CSRC count */
20 | u_int16_t m:1; /* marker bit */
21 | u_int16_t pt:7; /* payload type */
22 | u_int16_t seq:16; /* sequence number */
23 | u_int32_t ts; /* timestamp */
24 | u_int32_t ssrc; /* synchronization source */
25 | };
26 |
27 | @interface RTPClient()
28 | {
29 | GCDAsyncUdpSocket *socket_rtp;
30 |
31 | uint16_t seqNum;
32 |
33 | dispatch_queue_t queue;
34 |
35 | uint32_t start_t;
36 | }
37 | @end
38 |
39 | @implementation RTPClient
40 |
41 | - (instancetype)init
42 | {
43 | self = [super init];
44 | if (self)
45 | {
46 | queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
47 | socket_rtp = [[GCDAsyncUdpSocket alloc] init];
48 | [socket_rtp setDelegateQueue:queue];
49 | self.address = nil;
50 | self.port = 554;
51 | seqNum = 0;
52 | start_t = 0;
53 | }
54 | return self;
55 | }
56 |
57 | - (void)dealloc {
58 | [self reset];
59 | [socket_rtp closeAfterSending];
60 | }
61 |
62 | - (void)reset
63 | {
64 | start_t = 0;
65 | seqNum = 0;
66 | }
67 |
68 | #pragma mark - Publish
69 |
70 | - (void)publish:(NSData *)data timestamp:(CMTime)timestamp payloadType:(NSInteger)payloadType
71 | {
72 | int32_t t = ((float)timestamp.value / timestamp.timescale) * 1000;
73 | if(start_t == 0) start_t = t;
74 |
75 | struct rtp_header header;
76 |
77 | //fill the header array of byte with RTP header fields
78 | header.v = 2;
79 | header.p = 0;
80 | header.x = 0;
81 | header.cc = 0;
82 | header.m = 0;
83 | header.pt = payloadType;
84 | header.seq = seqNum;
85 | header.ts = t - start_t;
86 | header.ssrc = (u_int32_t)self.port;
87 |
88 | /* send RTP stream packet */
89 | NSMutableData *packet = [NSMutableData dataWithBytes:&header length:12];
90 | [packet appendData:data];
91 |
92 | [socket_rtp sendData:(NSData *)packet toHost:self.address port:self.port withTimeout:-1 tag:0];
93 |
94 | seqNum++;
95 | }
96 |
97 | @end
98 |
--------------------------------------------------------------------------------
/Core/RTSP/RTSPClient.h:
--------------------------------------------------------------------------------
1 | //
2 | // RTSPClient.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeong-uk Park on 2016. 1. 26..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RTSPClient;
12 |
13 | @protocol RTSPClientDelegate
14 | - (void)onRTSPDidConnectedOK:(RTSPClient *)rtsp;
15 | - (void)onRTSPDidConnectedFailed:(RTSPClient *)rtsp;
16 | - (void)onRTSPDidDisConnected:(RTSPClient *)rtsp;
17 | @optional
18 | - (void)onRTSP:(RTSPClient *)rtsp didSETUPWithServerPort:(NSNumber *)server_port;
19 | - (void)onRTSP:(RTSPClient *)rtsp didSETUP_AUDIOWithServerPort:(NSNumber *)server_port;
20 | - (void)onRTSP:(RTSPClient *)rtsp didSETUP_VIDEOWithServerPort:(NSNumber *)server_port;
21 | @end
22 |
23 | @interface RTSPClient : NSObject
24 |
25 | @property (weak, nonatomic) NSString *host; // ip address
26 | @property (weak, nonatomic) NSString *address;
27 | @property (nonatomic) NSInteger port;
28 | @property (weak, nonatomic) NSString *instance;
29 | @property (weak, nonatomic) NSString *streamName;
30 | @property (weak, nonatomic) NSString *sessionid;
31 | @property (weak, nonatomic) id delegate;
32 |
33 | - (void)connect:(NSString *)address port:(NSInteger)port instance:(NSString *)instance stream:(NSString *)stream;
34 | - (void)close;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/HLSforOSX/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // HLSforOSX
4 | //
5 | // Created by Byeong-uk Park on 2016. 2. 9..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/HLSforOSX/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // HLSforOSX
4 | //
5 | // Created by Byeong-uk Park on 2016. 2. 9..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
22 | // Insert code here to tear down your application
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/HLSforOSX/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/HLSforOSX/CameraViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // HLSforOSX
4 | //
5 | // Created by Byeong-uk Park on 2016. 2. 9..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CameraViewController : NSViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/HLSforOSX/CameraViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // HLSforOSX
4 | //
5 | // Created by Byeong-uk Park on 2016. 2. 9..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import "CameraViewController.h"
10 | #import "CameraEncoder.h"
11 |
12 | @interface CameraViewController ()
13 | {
14 | CameraEncoder *encoder;
15 | bool startCalled;
16 | }
17 | @property (weak, nonatomic) IBOutlet NSButton *StartStopButton;
18 | @property (weak, nonatomic) IBOutlet NSView *preview;
19 | @end
20 |
21 | @implementation CameraViewController
22 |
23 | - (void)viewDidLoad {
24 | [super viewDidLoad];
25 | // Do any additional setup after loading the view.
26 |
27 | encoder = [[CameraEncoder alloc] init];
28 |
29 | [encoder initCameraWithOutputSize:CGSizeMake(640, 360)];
30 | startCalled = true;
31 |
32 | [self.preview setWantsLayer:YES];
33 |
34 | encoder.previewLayer.frame = self.preview.bounds;
35 | [self.preview.layer addSublayer:encoder.previewLayer];
36 | }
37 |
38 | - (void)setRepresentedObject:(id)representedObject {
39 | [super setRepresentedObject:representedObject];
40 |
41 | // Update the view, if already loaded.
42 | }
43 |
44 | // Called when start/stop button is pressed
45 | - (IBAction)OnStartStop:(id)sender {
46 | if (startCalled)
47 | {
48 | [encoder startCamera];
49 | startCalled = false;
50 | [_StartStopButton setTitle:@"Stop"];
51 | }
52 | else
53 | {
54 | [_StartStopButton setTitle:@"Start"];
55 | startCalled = true;
56 | [encoder stopCamera];
57 | }
58 | }
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/HLSforOSX/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSMinimumSystemVersion
26 | $(MACOSX_DEPLOYMENT_TARGET)
27 | NSHumanReadableCopyright
28 | Copyright © 2016년 . All rights reserved.
29 | NSMainStoryboardFile
30 | Main
31 | NSPrincipalClass
32 | NSApplication
33 |
34 |
35 |
--------------------------------------------------------------------------------
/HLSforOSX/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // HLSforOSX
4 | //
5 | // Created by Byeong-uk Park on 2016. 2. 9..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming.xcodeproj/project.xcworkspace/xcuserdata/MOBIUS.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whiteblue3/HTTPLiveStreaming/2c991a42b114bc82890183ba96a23e6592859120/HTTPLiveStreaming.xcodeproj/project.xcworkspace/xcuserdata/MOBIUS.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/HTTPLiveStreaming.xcodeproj/xcuserdata/MOBIUS.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming.xcodeproj/xcuserdata/MOBIUS.xcuserdatad/xcschemes/HLSforOSX.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming.xcodeproj/xcuserdata/MOBIUS.xcuserdatad/xcschemes/HTTPLiveStreaming.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming.xcodeproj/xcuserdata/MOBIUS.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | HLSforOSX.xcscheme
8 |
9 | orderHint
10 | 4
11 |
12 | HTTPLiveStreaming.xcscheme
13 |
14 | orderHint
15 | 0
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | A81535421C677F920085E2FC
21 |
22 | primary
23 |
24 |
25 | A81535771C6788D80085E2FC
26 |
27 | primary
28 |
29 |
30 | A87435BD1C46219B0010D438
31 |
32 | primary
33 |
34 |
35 | A8B0EFAF1C69A30C0019EB1B
36 |
37 | primary
38 |
39 |
40 | A8BCAEF91C3B49CB000229C3
41 |
42 | primary
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/AAPLPlayerView.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2015 Apple Inc. All Rights Reserved.
3 | See LICENSE.txt for this sample’s licensing information
4 |
5 | Abstract:
6 | View containing an AVPlayerLayer.
7 | */
8 |
9 | @import UIKit;
10 |
11 | @class AVPlayer;
12 |
13 | @interface AAPLPlayerView : UIView
14 | @property AVPlayer *player;
15 | @property (readonly) AVPlayerLayer *playerLayer;
16 | @end
17 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/AAPLPlayerView.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2015 Apple Inc. All Rights Reserved.
3 | See LICENSE.txt for this sample’s licensing information
4 |
5 | Abstract:
6 | View containing an AVPlayerLayer.
7 | */
8 |
9 | @import Foundation;
10 | @import AVFoundation;
11 | #import "AAPLPlayerView.h"
12 |
13 |
14 | @implementation AAPLPlayerView
15 |
16 | - (AVPlayer *)player {
17 | return self.playerLayer.player;
18 | }
19 |
20 | - (void)setPlayer:(AVPlayer *)player {
21 | self.playerLayer.player = player;
22 | }
23 |
24 | // override UIView
25 | + (Class)layerClass {
26 | return [AVPlayerLayer class];
27 | }
28 |
29 | - (AVPlayerLayer *)playerLayer {
30 | return (AVPlayerLayer *)self.layer;
31 | }
32 |
33 | @end
34 |
35 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/AAPLPlayerViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // AAPLPlayerViewController.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Park on 2016. 1. 5..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @class AAPLPlayerView;
13 |
14 | @interface AAPLPlayerViewController : UIViewController
15 |
16 | @property (readonly) AVQueuePlayer *player;
17 |
18 | @property CMTime currentTime;
19 | @property (readonly) CMTime duration;
20 | @property float rate;
21 |
22 | @end
23 |
24 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Parl on 2016. 1. 5..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Parl on 2016. 1. 5..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "83.5x83.5",
66 | "scale" : "2x"
67 | }
68 | ],
69 | "info" : {
70 | "version" : 1,
71 | "author" : "xcode"
72 | }
73 | }
--------------------------------------------------------------------------------
/HTTPLiveStreaming/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/CameraViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CameraViewController.h
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Park on 2016. 1. 7..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CameraViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/CameraViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CameraViewController.m
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Park on 2016. 1. 7..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import "CameraViewController.h"
10 | #import "CameraEncoder.h"
11 |
12 | @interface CameraViewController ()
13 | {
14 | CameraEncoder *encoder;
15 | bool startCalled;
16 | }
17 | @property (weak, nonatomic) IBOutlet UIButton *StartStopButton;
18 | @end
19 |
20 | @implementation CameraViewController
21 |
22 | - (void)viewDidLoad {
23 | [super viewDidLoad];
24 | // Do any additional setup after loading the view.
25 |
26 | encoder = [[CameraEncoder alloc] init];
27 |
28 | [encoder initCameraWithOutputSize:CGSizeMake(360, 640)];
29 |
30 | startCalled = true;
31 |
32 | encoder.previewLayer.frame = self.view.bounds;
33 | [self.view.layer addSublayer:encoder.previewLayer];
34 | }
35 |
36 | - (void)didReceiveMemoryWarning {
37 | [super didReceiveMemoryWarning];
38 | // Dispose of any resources that can be recreated.
39 | }
40 |
41 | /*
42 | #pragma mark - Navigation
43 |
44 | // In a storyboard-based application, you will often want to do a little preparation before navigation
45 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
46 | // Get the new view controller using [segue destinationViewController].
47 | // Pass the selected object to the new view controller.
48 | }
49 | */
50 |
51 | // Called when start/stop button is pressed
52 | - (IBAction)OnStartStop:(id)sender {
53 | if (startCalled)
54 | {
55 | encoder.previewLayer.hidden = NO;
56 | [encoder startCamera];
57 | startCalled = false;
58 | [_StartStopButton setTitle:@"Stop" forState:UIControlStateNormal];
59 | }
60 | else
61 | {
62 | encoder.previewLayer.hidden = YES;
63 | [_StartStopButton setTitle:@"Start" forState:UIControlStateNormal];
64 | startCalled = true;
65 | [encoder stopCamera];
66 | }
67 | }
68 |
69 | @end
70 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | ko_KR
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UIFileSharingEnabled
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationLandscapeLeft
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeRight
40 |
41 | UISupportedInterfaceOrientations~ipad
42 |
43 | UIInterfaceOrientationPortrait
44 | UIInterfaceOrientationPortraitUpsideDown
45 | UIInterfaceOrientationLandscapeLeft
46 | UIInterfaceOrientationLandscapeRight
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/en.lproj/Localizable.strings:
--------------------------------------------------------------------------------
1 | /*
2 |
3 |
4 | Localizable strings.
5 |
6 |
7 | */
8 |
9 | // Alert title for errors.
10 | "alert.error.title" = "Error";
11 |
12 | // OK action on error alert
13 | "alert.error.actions.OK" = "OK";
14 |
15 | // Queue is empty.
16 | "label.queue.empty" = "Media queue is empty";
17 |
18 | // Queue of n item(s).
19 | "label.queue.%lu items" = "Queue of %n media items";
20 |
21 | // Title on button to clear the queue.
22 | "button.title.clear" = "Clear Queue";
23 |
24 | // Title of popover that clears the queue.
25 | "popover.title.clear" = "Clear";
26 |
27 | // Message on popover that clears the queue.
28 | "popover.message.clear" = "Remove all media from the queue?";
29 |
30 | // Title of popover cancel action.
31 | "popover.title.cancel" = "Cancel";
32 |
33 | // Title of popover that adds items to the queue.
34 | "popover.title.addItem" = "Add Media";
35 |
36 | // Message on popover that adds items to the queue.
37 | "popover.message.addItem" = "Select a media type to add to the queue";
38 |
39 | // Can't use this AVAsset because one of it's keys failed to load.
40 | "error.asset_%@_key_%@_failed.description" = "Media \"%@\" failed to load key \"%@\"";
41 |
42 | // Can't use this AVAsset because it isn't playable or has protected content.
43 | "error.asset_%@_not_playable.description" = "Media \"%@\" isn't playable or has protected content";
44 |
45 | // Failed to parse the assets manifest JSON.
46 | "error.json_parse_failed.description" = "Failed to parse the manifest";
47 |
48 | // Failed to open the assets manifest JSON.
49 | "error.json_open_failed.description" = "Failed to open the manifest";
50 |
51 | // Default error message when no NSError provided.
52 | "error.default.description" = "Unknown error";
53 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/en.lproj/Localizable.stringsdict:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | label.queue.%lu items
6 |
7 | NSStringLocalizedFormatKey
8 | Queue of %#@lu_items@
9 | lu_items
10 |
11 | NSStringFormatSpecTypeKey
12 | NSStringPluralRuleType
13 | NSStringFormatValueTypeKey
14 | lu
15 | one
16 | %lu item
17 | other
18 | %lu items
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/HTTPLiveStreaming/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // HTTPLiveStreaming
4 | //
5 | // Created by Byeongwook Parl on 2016. 1. 5..
6 | // Copyright © 2016년 . All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # README #
2 |
3 | This project is stop the developing now. Will restart later.
4 |
5 | This project is streaming H.264/AAC using iOS Video Tool Box to encode and send packet over RTP / RTSP
6 |
7 | This project is association with Wowza Media Server 4.3 over.
8 |
9 |
10 | # Known Issue #
11 |
12 | - H264 Hardware Encoding working on iOS. Mac OS X is not working perfectly.
13 |
14 | - for Mac OS X, AVFoundation is using hardware encoding. I using it.
15 |
16 | - AAC Hardware Encoding is not working on iOS (Software Encoding). Mac OS X only (AVFoundation)
17 |
18 | - H264 Hardware Decoder is working perfectly.
19 |
20 | - H264 MaxSlice option is not working. I use packetization mode 0 (Single NAL)
21 |
22 | - H264 kVTCompressionPropertyKey_ExpectedFrameRate is not working on Mac OS X. (15 fps static only)
23 |
24 | - H264 bitrate is only working iOS. not Mac OS X.
25 |
26 | - RTSP Client is only working for stream publisher.
27 |
28 |
29 | # TODO #
30 |
31 | - MPEG4 container format support
32 |
33 | - MPEG2-TS container format support
34 |
35 |
36 | # LICENSE #
37 |
38 | This project is under GPLv2
39 |
--------------------------------------------------------------------------------