├── Pods ├── Headers │ ├── Private │ │ ├── AFNetworking │ │ │ ├── AFNetworking.h │ │ │ ├── AFSecurityPolicy.h │ │ │ ├── AFHTTPSessionManager.h │ │ │ ├── AFImageDownloader.h │ │ │ ├── AFURLSessionManager.h │ │ │ ├── AFCompatibilityMacros.h │ │ │ ├── UIKit+AFNetworking.h │ │ │ ├── AFURLRequestSerialization.h │ │ │ ├── UIButton+AFNetworking.h │ │ │ ├── UIImage+AFNetworking.h │ │ │ ├── UIWebView+AFNetworking.h │ │ │ ├── AFAutoPurgingImageCache.h │ │ │ ├── AFURLResponseSerialization.h │ │ │ ├── UIImageView+AFNetworking.h │ │ │ ├── AFNetworkReachabilityManager.h │ │ │ ├── UIProgressView+AFNetworking.h │ │ │ ├── UIRefreshControl+AFNetworking.h │ │ │ ├── AFNetworkActivityIndicatorManager.h │ │ │ └── UIActivityIndicatorView+AFNetworking.h │ │ └── GCDWebServer │ │ │ ├── GCDWebServer.h │ │ │ ├── GCDWebServerPrivate.h │ │ │ ├── GCDWebServerRequest.h │ │ │ ├── GCDWebServerResponse.h │ │ │ ├── GCDWebServerConnection.h │ │ │ ├── GCDWebServerFunctions.h │ │ │ ├── GCDWebServerDataRequest.h │ │ │ ├── GCDWebServerFileRequest.h │ │ │ ├── GCDWebServerDataResponse.h │ │ │ ├── GCDWebServerErrorResponse.h │ │ │ ├── GCDWebServerFileResponse.h │ │ │ ├── GCDWebServerHTTPStatusCodes.h │ │ │ ├── GCDWebServerStreamedResponse.h │ │ │ ├── GCDWebServerMultiPartFormRequest.h │ │ │ └── GCDWebServerURLEncodedFormRequest.h │ └── Public │ │ ├── AFNetworking │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFHTTPSessionManager.h │ │ ├── AFImageDownloader.h │ │ ├── AFURLSessionManager.h │ │ ├── AFCompatibilityMacros.h │ │ ├── UIImage+AFNetworking.h │ │ ├── UIKit+AFNetworking.h │ │ ├── AFURLRequestSerialization.h │ │ ├── UIButton+AFNetworking.h │ │ ├── UIWebView+AFNetworking.h │ │ ├── AFAutoPurgingImageCache.h │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFURLResponseSerialization.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.h │ │ ├── AFNetworkActivityIndicatorManager.h │ │ └── UIActivityIndicatorView+AFNetworking.h │ │ └── GCDWebServer │ │ ├── GCDWebServer.h │ │ ├── GCDWebServerRequest.h │ │ ├── GCDWebServerResponse.h │ │ ├── GCDWebServerConnection.h │ │ ├── GCDWebServerFunctions.h │ │ ├── GCDWebServerDataRequest.h │ │ ├── GCDWebServerFileRequest.h │ │ ├── GCDWebServerDataResponse.h │ │ ├── GCDWebServerErrorResponse.h │ │ ├── GCDWebServerFileResponse.h │ │ ├── GCDWebServerHTTPStatusCodes.h │ │ ├── GCDWebServerStreamedResponse.h │ │ ├── GCDWebServerMultiPartFormRequest.h │ │ └── GCDWebServerURLEncodedFormRequest.h ├── Target Support Files │ ├── AFNetworking │ │ ├── AFNetworking-dummy.m │ │ ├── AFNetworking-prefix.pch │ │ ├── AFNetworking.xcconfig │ │ ├── AFNetworking.debug.xcconfig │ │ └── AFNetworking.release.xcconfig │ ├── GCDWebServer │ │ ├── GCDWebServer-dummy.m │ │ ├── GCDWebServer-prefix.pch │ │ ├── GCDWebServer.xcconfig │ │ ├── GCDWebServer.debug.xcconfig │ │ └── GCDWebServer.release.xcconfig │ └── Pods-BNM3u8Cache │ │ ├── Pods-BNM3u8Cache-dummy.m │ │ ├── Pods-BNM3u8Cache.debug.xcconfig │ │ ├── Pods-BNM3u8Cache.release.xcconfig │ │ ├── Pods-BNM3u8Cache-acknowledgements.markdown │ │ └── Pods-BNM3u8Cache-acknowledgements.plist ├── Pods.xcodeproj │ └── xcuserdata │ │ ├── Bennie.xcuserdatad │ │ └── xcschemes │ │ │ ├── xcschememanagement.plist │ │ │ ├── AFNetworking.xcscheme │ │ │ ├── GCDWebServer.xcscheme │ │ │ └── Pods-BNM3u8Cache.xcscheme │ │ ├── zengbailiang.xcuserdatad │ │ └── xcschemes │ │ │ ├── xcschememanagement.plist │ │ │ ├── AFNetworking.xcscheme │ │ │ ├── GCDWebServer.xcscheme │ │ │ └── Pods-BNM3u8Cache.xcscheme │ │ └── zego.xcuserdatad │ │ └── xcschemes │ │ ├── AFNetworking.xcscheme │ │ ├── GCDWebServer.xcscheme │ │ └── Pods-BNM3u8Cache.xcscheme ├── Manifest.lock ├── AFNetworking │ ├── LICENSE │ ├── UIKit+AFNetworking │ │ ├── UIImage+AFNetworking.h │ │ ├── UIKit+AFNetworking.h │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIWebView+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.m │ │ ├── UIActivityIndicatorView+AFNetworking.m │ │ ├── UIProgressView+AFNetworking.m │ │ └── AFNetworkActivityIndicatorManager.h │ └── AFNetworking │ │ ├── AFCompatibilityMacros.h │ │ └── AFNetworking.h └── GCDWebServer │ ├── LICENSE │ └── GCDWebServer │ ├── Requests │ ├── GCDWebServerFileRequest.h │ ├── GCDWebServerURLEncodedFormRequest.h │ ├── GCDWebServerURLEncodedFormRequest.m │ ├── GCDWebServerDataRequest.h │ ├── GCDWebServerDataRequest.m │ ├── GCDWebServerFileRequest.m │ └── GCDWebServerMultiPartFormRequest.h │ ├── Responses │ ├── GCDWebServerStreamedResponse.m │ ├── GCDWebServerStreamedResponse.h │ ├── GCDWebServerErrorResponse.h │ ├── GCDWebServerDataResponse.h │ ├── GCDWebServerFileResponse.h │ └── GCDWebServerDataResponse.m │ └── Core │ ├── GCDWebServerFunctions.h │ └── GCDWebServerHTTPStatusCodes.h ├── Classes ├── Assets.xcassets │ ├── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── m3u8 │ ├── entity │ │ ├── BNM3U8PlistInfo.m │ │ ├── BNM3U8fileInfo.m │ │ ├── BNM3U8FileDownloadProtocol.h │ │ ├── BNM3U8fileInfo.h │ │ └── BNM3U8PlistInfo.h │ ├── BNM3U8DownloadConfig.m │ ├── BNM3u8Cache.h │ ├── BNM3U8DownloadConfig.h │ ├── BNHttpLocalServer.h │ ├── category │ │ ├── NSString+m3u8.h │ │ └── NSString+m3u8.m │ ├── BNM3U8AnalysisService.h │ ├── BNM3U8FileDownLoadOperation.h │ ├── BNM3U8DownloadOperation.h │ ├── BNFileManager.h │ ├── BNHttpLocalServer.m │ ├── BNM3U8Manager.h │ ├── BNFileManager.m │ ├── BNM3U8FileDownLoadOperation.m │ └── BNM3U8Manager.m ├── ViewController.h ├── AppDelegate.h ├── main.m ├── Info.plist ├── Base.lproj │ ├── Main.storyboard │ └── LaunchScreen.storyboard └── AppDelegate.m ├── BNM3u8Cache.xcodeproj ├── xcuserdata │ ├── zengbailiang.xcuserdatad │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ └── Bennie.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ ├── IDEWorkspaceChecks.plist │ └── WorkspaceSettings.xcsettings │ └── xcuserdata │ ├── Bennie.xcuserdatad │ └── WorkspaceSettings.xcsettings │ └── zengbailiang.xcuserdatad │ └── WorkspaceSettings.xcsettings ├── BNM3u8Cache.xcworkspace ├── xcuserdata │ ├── zego.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ ├── Bennie.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── zengbailiang.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── Podfile ├── LICENSE ├── Podfile.lock ├── README.md └── BNM3u8Cache.podspec /Pods/Headers/Private/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServer.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServer.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServer.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServer.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFCompatibilityMacros.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFCompatibilityMacros.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerPrivate.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerPrivate.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFCompatibilityMacros.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFCompatibilityMacros.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerResponse.h -------------------------------------------------------------------------------- /Classes/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerConnection.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerConnection.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerFunctions.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerFunctions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerConnection.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerConnection.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerFunctions.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerFunctions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerDataRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerDataRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerFileRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerFileRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFAutoPurgingImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerDataRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerDataRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerFileRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerFileRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerDataResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerDataResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerErrorResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerErrorResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerFileResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerFileResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerHTTPStatusCodes.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerHTTPStatusCodes.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerDataResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerDataResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerErrorResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerErrorResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerFileResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerFileResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerHTTPStatusCodes.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerHTTPStatusCodes.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerStreamedResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerStreamedResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerStreamedResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerStreamedResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerMultiPartFormRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerMultiPartFormRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerURLEncodedFormRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerURLEncodedFormRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerMultiPartFormRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerMultiPartFormRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerURLEncodedFormRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerURLEncodedFormRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /BNM3u8Cache.xcodeproj/xcuserdata/zengbailiang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_AFNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_AFNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/GCDWebServer/GCDWebServer-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_GCDWebServer : NSObject 3 | @end 4 | @implementation PodsDummy_GCDWebServer 5 | @end 6 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcworkspace/xcuserdata/zego.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmubai/BNM3u8Cache/HEAD/BNM3u8Cache.xcworkspace/xcuserdata/zego.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /BNM3u8Cache.xcworkspace/xcuserdata/Bennie.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmubai/BNM3u8Cache/HEAD/BNM3u8Cache.xcworkspace/xcuserdata/Bennie.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-BNM3u8Cache/Pods-BNM3u8Cache-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_BNM3u8Cache : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_BNM3u8Cache 5 | @end 6 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcworkspace/xcuserdata/zengbailiang.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmubai/BNM3u8Cache/HEAD/BNM3u8Cache.xcworkspace/xcuserdata/zengbailiang.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /BNM3u8Cache.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcworkspace/xcuserdata/zego.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /Classes/m3u8/entity/BNM3U8PlistInfo.m: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8PlistInfo.m 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import "BNM3U8PlistInfo.h" 10 | 11 | @implementation BNM3U8PlistInfo 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Classes/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Pods/Target Support Files/GCDWebServer/GCDWebServer-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Classes/m3u8/BNM3U8DownloadConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8DownloadCofig.m 3 | // m3u8Demo 4 | // 5 | // Created by zengbailiang on 2019/7/20. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import "BNM3U8DownloadConfig.h" 10 | 11 | @implementation BNM3U8DownloadConfig 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Original 7 | 8 | 9 | -------------------------------------------------------------------------------- /Classes/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. 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 | -------------------------------------------------------------------------------- /Classes/m3u8/BNM3u8Cache.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3u8Cache.h 3 | // BNM3u8Cache 4 | // 5 | // Created by liangzeng on 12/11/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #ifndef BNM3u8Cache_h 10 | #define BNM3u8Cache_h 11 | #import "BNM3U8Manager.h" 12 | #import "BNHttpLocalServer.h" 13 | #import "BNFileManager.h" 14 | #endif /* BNM3u8Cache_h */ 15 | -------------------------------------------------------------------------------- /Classes/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. 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 | -------------------------------------------------------------------------------- /Classes/m3u8/entity/BNM3U8fileInfo.m: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8fileInfo.m 3 | // m3u8Demo 4 | // 5 | // Created by zengbailiang on 2019/8/3. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import "BNM3U8fileInfo.h" 10 | 11 | @implementation BNM3U8fileInfo 12 | - (NSString *)downloadUrl{ 13 | return _oriUrlString; 14 | } 15 | 16 | - (NSString *)dstFilePath{ 17 | return _diskPath; 18 | } 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /Classes/m3u8/entity/BNM3U8FileDownloadProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8FileDownloadProtocol.h 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol BNM3U8FileDownloadProtocol 14 | @required 15 | - (NSString *)downloadUrl; 16 | - (NSString *)dstFilePath; 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | platform :ios, '8.0' 3 | 4 | source 'https://github.com/CocoaPods/Specs.git' 5 | #source 'https://cdn.cocoapods.org/' 6 | install! 'cocoapods', :deterministic_uuids => false 7 | inhibit_all_warnings! 8 | 9 | target 'BNM3u8Cache' do 10 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks 11 | 12 | 13 | pod 'AFNetworking', '~> 3.0' 14 | pod "GCDWebServer", "~> 3.5.3" 15 | end 16 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #ifndef TARGET_OS_IOS 14 | #define TARGET_OS_IOS TARGET_OS_IPHONE 15 | #endif 16 | 17 | #ifndef TARGET_OS_WATCH 18 | #define TARGET_OS_WATCH 0 19 | #endif 20 | 21 | #ifndef TARGET_OS_TV 22 | #define TARGET_OS_TV 0 23 | #endif 24 | -------------------------------------------------------------------------------- /Classes/m3u8/BNM3U8DownloadConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8DownloadCofig.h 3 | // m3u8Demo 4 | // 5 | // Created by zengbailiang on 2019/7/20. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | 14 | @interface BNM3U8DownloadConfig : NSObject 15 | @property (nonatomic, copy) NSString *url; 16 | @property (nonatomic, assign) NSInteger maxConcurrenceCount; 17 | @property (nonatomic, copy) NSString *localhost; 18 | @end 19 | 20 | NS_ASSUME_NONNULL_END 21 | -------------------------------------------------------------------------------- /Classes/m3u8/BNHttpLocalServer.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNHttpLocalServer.h 3 | // m3u8DownloadSimpleDemo 4 | // 5 | // Created by liangzeng on 2019/4/29. 6 | // Copyright © 2019年 liangzeng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface BNHttpLocalServer : NSObject 14 | @property (strong, nonatomic) NSString *documentRoot; 15 | @property (assign, nonatomic) NSInteger port; 16 | + (instancetype)shareInstance; 17 | - (void)tryStart; 18 | - (void)tryStop; 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /Classes/m3u8/category/NSString+m3u8.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+m3u8.h 3 | // M3U8DownLoadTest 4 | // 5 | // Created by zengbailiang on 10/5/17. 6 | // Copyright © 2017 controling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (m3u8) 12 | - (NSString*)subStringFrom:(NSString *)startString to:(NSString *)endString; 13 | - (NSString*)subStringForm:(NSString *)string offset:(NSInteger) offset; 14 | - (NSString*)subStringTo:(NSString *)string; 15 | - (NSString*)removeSpaceAndNewline; 16 | - (NSString*)md5; 17 | @end 18 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcodeproj/xcuserdata/Bennie.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BNM3u8Cache.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 3 11 | 12 | m3u8Demo.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 3 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcodeproj/project.xcworkspace/xcuserdata/Bennie.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildLocationStyle 6 | UseAppPreferences 7 | CustomBuildLocationType 8 | RelativeToDerivedData 9 | DerivedDataLocationStyle 10 | Default 11 | EnabledFullIndexStoreVisibility 12 | 13 | IssueFilterStyle 14 | ShowActiveSchemeOnly 15 | LiveSourceIssuesEnabled 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcodeproj/project.xcworkspace/xcuserdata/zengbailiang.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildLocationStyle 6 | UseAppPreferences 7 | CustomBuildLocationType 8 | RelativeToDerivedData 9 | DerivedDataLocationStyle 10 | Default 11 | EnabledFullIndexStoreVisibility 12 | 13 | IssueFilterStyle 14 | ShowActiveSchemeOnly 15 | LiveSourceIssuesEnabled 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/GCDWebServer/GCDWebServer.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/GCDWebServer 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/GCDWebServer" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/GCDWebServer" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/GCDWebServer 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /BNM3u8Cache.xcodeproj/xcuserdata/zengbailiang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BNM3u8Cache.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 3 11 | 12 | m3u8Demo.xcscheme 13 | 14 | orderHint 15 | 0 16 | 17 | m3u8Demo.xcscheme_^#shared#^_ 18 | 19 | orderHint 20 | 2 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking.release.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/GCDWebServer/GCDWebServer.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/GCDWebServer 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/GCDWebServer" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/GCDWebServer" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/GCDWebServer 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/GCDWebServer/GCDWebServer.release.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/GCDWebServer 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/GCDWebServer" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/GCDWebServer" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/GCDWebServer 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Classes/m3u8/BNM3U8AnalysisService.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8AnalysisService.h 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | @class BNM3U8PlistInfo; 13 | typedef void(^BNM3U8AnalysisServiceResultBlock)(NSError * _Nullable error, BNM3U8PlistInfo * _Nullable plistInfo); 14 | @interface BNM3U8AnalysisService : NSObject 15 | + (void)analysisWithURL:(NSString *)url rootPath:(NSString *)rootPath resultBlock:(BNM3U8AnalysisServiceResultBlock)resultBlock; 16 | + (NSString*)synthesisLocalM3u8Withm3u8Info:(BNM3U8PlistInfo *)m3u8Info withLocaHost:(NSString *)localhost; 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /Classes/m3u8/BNM3U8FileDownLoadOperation.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8FileDownLoadOperation.h 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BNM3U8FileDownloadProtocol.h" 11 | #import "AFNetworking.h" 12 | 13 | /* 一个 fileOperation 只负责下载一个文件*/ 14 | NS_ASSUME_NONNULL_BEGIN 15 | typedef void(^BNM3U8FileDownLoadOperationResultBlock)(NSError * _Nullable error,id _Nullable info); 16 | @interface BNM3U8FileDownLoadOperation : NSOperation 17 | - (instancetype)initWithFileInfo:(NSObject *)fileInfo sessionManager:(AFURLSessionManager*)sessionManager resultBlock:(BNM3U8FileDownLoadOperationResultBlock)resultBlock; 18 | - (void)suspend; 19 | - (void)resume; 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /Classes/m3u8/entity/BNM3U8fileInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8fileInfo.h 3 | // m3u8Demo 4 | // 5 | // Created by zengbailiang on 2019/8/3. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BNM3U8FileDownloadProtocol.h" 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface BNM3U8fileInfo : NSObject 14 | @property (nonatomic, copy) NSString *duration; 15 | @property (nonatomic, copy) NSString *oriUrlString; 16 | @property (nonatomic, copy) NSString *localUrlString;///该字段废弃, 替换为 relativeUrl 17 | @property (nonatomic, copy) NSString *relativeUrl;//相对路径 18 | @property (nonatomic, assign) NSInteger index; 19 | @property (nonatomic, copy) NSString *diskPath; 20 | @property (nonatomic, assign,getter = isHasDiscontiunity) BOOL hasDiscontiunity; 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /Classes/m3u8/entity/BNM3U8PlistInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8PlistInfo.h 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BNM3U8fileInfo.h" 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface BNM3U8PlistInfo : NSObject 14 | @property (nonatomic, copy) NSString *targetduration; 15 | @property (nonatomic, copy) NSString *version; 16 | @property (nonatomic, copy) NSString *mediaSequence; 17 | 18 | ///key 19 | @property (nonatomic, copy) NSString *keyMethod; 20 | @property (nonatomic, copy) NSString *keyUri; 21 | @property (nonatomic, copy) NSString *keyLocalUri;/// 废弃 22 | @property (nonatomic, copy) NSString *keyIv; 23 | ///contain the key file info if exit key. 24 | @property (nonatomic, strong) NSMutableArray *fileInfos; 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/Bennie.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AFNetworking.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | GCDWebServer.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 1 20 | 21 | Pods-BNM3u8Cache.xcscheme 22 | 23 | isShown 24 | 25 | orderHint 26 | 2 27 | 28 | 29 | SuppressBuildableAutocreation 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/zengbailiang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AFNetworking.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | GCDWebServer.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 1 20 | 21 | Pods-BNM3u8Cache.xcscheme 22 | 23 | isShown 24 | 25 | orderHint 26 | 2 27 | 28 | 29 | SuppressBuildableAutocreation 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-BNM3u8Cache/Pods-BNM3u8Cache.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/GCDWebServer" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/GCDWebServer" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/GCDWebServer" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"GCDWebServer" -l"z" -framework "CFNetwork" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Classes/m3u8/BNM3U8DownloadOperation.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8DownloadOperation.h 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BNM3U8DownloadConfig.h" 11 | #import "AFNetworking.h" 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | 15 | typedef void(^BNM3U8DownloadOperationResultBlock)( NSError * _Nullable error, NSString * _Nullable relativeUrl); 16 | typedef void(^BNM3U8DownloadOperationProgressBlock)(CGFloat progress); 17 | /* 18 | 继承 NSOperation 需实相关方法,包括状态控制 19 | 20 | 上层使用NSOperationQueue去控制并发,全局控制 21 | */ 22 | @interface BNM3U8DownloadOperation : NSOperation 23 | - (instancetype)initWithConfig:(BNM3U8DownloadConfig *)config downloadDstRootPath:(NSString *)path sessionManager:(AFURLSessionManager *)sessionManager progressBlock:(BNM3U8DownloadOperationProgressBlock)progressBlock resultBlock:(BNM3U8DownloadOperationResultBlock)resultBlock; 24 | - (void)suspend; 25 | - (void)resume; 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-BNM3u8Cache/Pods-BNM3u8Cache.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/GCDWebServer" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/GCDWebServer" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/GCDWebServer" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"GCDWebServer" -l"z" -framework "CFNetwork" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 zmubai 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. 22 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (3.2.1): 3 | - AFNetworking/NSURLSession (= 3.2.1) 4 | - AFNetworking/Reachability (= 3.2.1) 5 | - AFNetworking/Security (= 3.2.1) 6 | - AFNetworking/Serialization (= 3.2.1) 7 | - AFNetworking/UIKit (= 3.2.1) 8 | - AFNetworking/NSURLSession (3.2.1): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (3.2.1) 13 | - AFNetworking/Security (3.2.1) 14 | - AFNetworking/Serialization (3.2.1) 15 | - AFNetworking/UIKit (3.2.1): 16 | - AFNetworking/NSURLSession 17 | - GCDWebServer (3.5.3): 18 | - GCDWebServer/Core (= 3.5.3) 19 | - GCDWebServer/Core (3.5.3) 20 | 21 | DEPENDENCIES: 22 | - AFNetworking (~> 3.0) 23 | - GCDWebServer (~> 3.5.3) 24 | 25 | SPEC REPOS: 26 | https://github.com/CocoaPods/Specs.git: 27 | - AFNetworking 28 | - GCDWebServer 29 | 30 | SPEC CHECKSUMS: 31 | AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057 32 | GCDWebServer: c0ab22c73e1b84f358d1e2f74bf6afd1c60829f2 33 | 34 | PODFILE CHECKSUM: 207175ca68fa40aad5e0794ed5ae1adbeedc7dec 35 | 36 | COCOAPODS: 1.9.3 37 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (3.2.1): 3 | - AFNetworking/NSURLSession (= 3.2.1) 4 | - AFNetworking/Reachability (= 3.2.1) 5 | - AFNetworking/Security (= 3.2.1) 6 | - AFNetworking/Serialization (= 3.2.1) 7 | - AFNetworking/UIKit (= 3.2.1) 8 | - AFNetworking/NSURLSession (3.2.1): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (3.2.1) 13 | - AFNetworking/Security (3.2.1) 14 | - AFNetworking/Serialization (3.2.1) 15 | - AFNetworking/UIKit (3.2.1): 16 | - AFNetworking/NSURLSession 17 | - GCDWebServer (3.5.3): 18 | - GCDWebServer/Core (= 3.5.3) 19 | - GCDWebServer/Core (3.5.3) 20 | 21 | DEPENDENCIES: 22 | - AFNetworking (~> 3.0) 23 | - GCDWebServer (~> 3.5.3) 24 | 25 | SPEC REPOS: 26 | https://github.com/CocoaPods/Specs.git: 27 | - AFNetworking 28 | - GCDWebServer 29 | 30 | SPEC CHECKSUMS: 31 | AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057 32 | GCDWebServer: c0ab22c73e1b84f358d1e2f74bf6afd1c60829f2 33 | 34 | PODFILE CHECKSUM: 207175ca68fa40aad5e0794ed5ae1adbeedc7dec 35 | 36 | COCOAPODS: 1.9.3 37 | -------------------------------------------------------------------------------- /Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2016 Alamofire Software Foundation (http://alamofire.org/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Classes/m3u8/BNFileManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZBLM3u8FileManager.h 3 | // M3U8DownLoadTest 4 | // 5 | // Created by zengbailiang on 10/5/17. 6 | // Copyright © 2017 controling. All rights reserved. 7 | // 8 | 9 | #import 10 | /*目录创建,目录校验,文件校验,文件写入...*/ 11 | 12 | typedef void (^BNFileManagerCompletaionHandler)(NSError *error); 13 | 14 | @interface BNFileManager : NSObject 15 | 16 | + (instancetype)shareInstance; 17 | 18 | - (instancetype)initWithIoQueue:(dispatch_queue_t)ioQueue; 19 | 20 | + (BOOL)tryGreateDir:(NSString *)dir; 21 | 22 | + (BOOL)exitItemWithPath:(NSString*)path; 23 | 24 | - (void)saveDate:(NSData*) aData pathUrl:(NSURL*)pathUrl completaionHandler:(BNFileManagerCompletaionHandler)completaionHandler; 25 | 26 | - (void)saveDate:(NSData*) aData ToFile:(NSString *)file completaionHandler:(BNFileManagerCompletaionHandler)completaionHandler; 27 | 28 | - (void)moveItemAtURL:(NSURL *)srcURL toURL:(NSURL *)dstURL completaionHandler:(BNFileManagerCompletaionHandler)completaionHandler; 29 | 30 | - (void)tryCreateDictionaryWithPath:(NSString*)path completaionHandler:(BNFileManagerCompletaionHandler)completaionHandler; 31 | 32 | - (void)removeFileWithPath:(NSString *)path; 33 | 34 | FOUNDATION_EXPORT NSString * const BNM3u8FileManagerWriteErrorDomain; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Classes/m3u8/BNHttpLocalServer.m: -------------------------------------------------------------------------------- 1 | // 2 | // BNHttpLocalServer.m 3 | // m3u8DownloadSimpleDemo 4 | // 5 | // Created by liangzeng on 2019/4/29. 6 | // Copyright © 2019年 liangzeng. All rights reserved. 7 | // 8 | 9 | #import "BNHttpLocalServer.h" 10 | #import 11 | 12 | @interface BNHttpLocalServer () 13 | @property (strong, nonatomic) GCDWebServer *webServer; 14 | @end 15 | 16 | @implementation BNHttpLocalServer 17 | + (instancetype)shareInstance 18 | { 19 | static BNHttpLocalServer *sharedInstance = nil; 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | sharedInstance = [[self alloc] init]; 23 | }); 24 | return sharedInstance; 25 | } 26 | #pragma mark - service 27 | - (void)tryStart 28 | { 29 | /*多线程不可重入*/ 30 | @synchronized (self) { 31 | if(!_webServer){ 32 | _webServer = [[GCDWebServer alloc] init]; 33 | [GCDWebServer setLogLevel:4]; 34 | [_webServer addGETHandlerForBasePath:@"/" directoryPath:[_documentRoot stringByAppendingString:@"/"] indexFilename:nil cacheAge:INT_MAX allowRangeRequests:YES]; 35 | [_webServer startWithPort:8080 bonjourName:nil]; 36 | } else if (![_webServer isRunning]) { 37 | [_webServer startWithPort:8080 bonjourName:nil]; 38 | } 39 | } 40 | } 41 | 42 | - (void)tryStop 43 | { 44 | @synchronized (self) { 45 | [_webServer stop]; 46 | } 47 | } 48 | @end 49 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+AFNetworking.h 3 | // 4 | // 5 | // Created by Paulo Ferreira on 08/07/15. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #if TARGET_OS_IOS || TARGET_OS_TV 26 | 27 | #import 28 | 29 | @interface UIImage (AFNetworking) 30 | 31 | + (UIImage*) safeImageWithData:(NSData*)data; 32 | 33 | @end 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2014, Pierre-Olivier Latour 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * The name of Pierre-Olivier Latour may not be used to endorse 12 | or promote products derived from this software without specific 13 | prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /Classes/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Classes/Base.lproj/Main.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 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h: -------------------------------------------------------------------------------- 1 | // AFCompatibilityMacros.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #ifndef AFCompatibilityMacros_h 23 | #define AFCompatibilityMacros_h 24 | 25 | #ifdef API_UNAVAILABLE 26 | #define AF_API_UNAVAILABLE(x) API_UNAVAILABLE(x) 27 | #else 28 | #define AF_API_UNAVAILABLE(x) 29 | #endif // API_UNAVAILABLE 30 | 31 | #if __has_warning("-Wunguarded-availability-new") 32 | #define AF_CAN_USE_AT_AVAILABLE 1 33 | #else 34 | #define AF_CAN_USE_AT_AVAILABLE 0 35 | #endif 36 | 37 | #endif /* AFCompatibilityMacros_h */ 38 | -------------------------------------------------------------------------------- /Classes/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 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/) 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 13 | // all 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 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | #import 26 | 27 | #ifndef _AFNETWORKING_ 28 | #define _AFNETWORKING_ 29 | 30 | #import "AFURLRequestSerialization.h" 31 | #import "AFURLResponseSerialization.h" 32 | #import "AFSecurityPolicy.h" 33 | 34 | #if !TARGET_OS_WATCH 35 | #import "AFNetworkReachabilityManager.h" 36 | #endif 37 | 38 | #import "AFURLSessionManager.h" 39 | #import "AFHTTPSessionManager.h" 40 | 41 | #endif /* _AFNETWORKING_ */ 42 | -------------------------------------------------------------------------------- /Classes/m3u8/BNM3U8Manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8Manager.h 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | /* 10 | cannel 之后只能通过downloadVideoWithConfig 重新发起 11 | 12 | suspend 之后可以通过resume恢复,挂起的恢复下载。下载失败的不能恢复重新下载 13 | 14 | **/ 15 | #import 16 | #import "BNM3U8DownloadOperation.h" 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | //typedef NS_OPTIONS(NSUInteger, BNM3U8DownloadSupportNetOption) { 21 | // BNM3U8DownloadSupportNetOptionNone = 0, 22 | // BNM3U8DownloadSupportNetOptionWifi = 1 <<0, 23 | // BNM3U8DownloadSupportNetOptionMobile = 1 << 1, 24 | // BNM3U8DownloadSupportNetOptionAll = BNM3U8DownloadSupportNetOptionWifi | BNM3U8DownloadSupportNetOptionMobile, 25 | //}; 26 | 27 | ///rootPath 对应的是local http service 的 root path 28 | typedef void(^BNM3U8DownloadResultBlock)(NSError * _Nullable error, NSString * _Nullable localPlayUrl); 29 | typedef void(^BNM3U8DownloadProgressBlock)(CGFloat progress); 30 | 31 | @interface BNM3U8ManagerConfig : NSObject 32 | @property (nonatomic, copy) NSString *downloadDstRootPath; 33 | @property (nonatomic, assign) NSInteger videoMaxConcurrenceCount; 34 | /*允许下载的网络类型支持(移动网络,wifi)*/ 35 | //@property (nonatomic, assign) BNM3U8DownloadSupportNetOption netOption; 36 | @end 37 | 38 | @interface BNM3U8Manager : NSObject 39 | 40 | + (instancetype)shareInstance; 41 | 42 | ///设置配置,不可以重新赋值 43 | - (void)fillConfig:(BNM3U8ManagerConfig*)config; 44 | 45 | /*下载队列中添加 46 | 创建operation 添加到queue中。 系统控制执行 47 | */ 48 | - (void)downloadVideoWithConfig:(BNM3U8DownloadConfig *)config progressBlock:(BNM3U8DownloadProgressBlock)progressBlock resultBlock:(BNM3U8DownloadResultBlock)resultBlock; 49 | 50 | - (void)cannel:(NSString *)url; 51 | 52 | - (void)cancelAll; 53 | 54 | - (void)suspend; 55 | 56 | - (void)resume; 57 | @end 58 | 59 | NS_ASSUME_NONNULL_END 60 | 61 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIKit+AFNetworking.h 2 | // 3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 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 13 | // all 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 21 | // THE SOFTWARE. 22 | 23 | #if TARGET_OS_IOS || TARGET_OS_TV 24 | #import 25 | 26 | #ifndef _UIKIT_AFNETWORKING_ 27 | #define _UIKIT_AFNETWORKING_ 28 | 29 | #if TARGET_OS_IOS 30 | #import "AFAutoPurgingImageCache.h" 31 | #import "AFImageDownloader.h" 32 | #import "AFNetworkActivityIndicatorManager.h" 33 | #import "UIRefreshControl+AFNetworking.h" 34 | #import "UIWebView+AFNetworking.h" 35 | #endif 36 | 37 | #import "UIActivityIndicatorView+AFNetworking.h" 38 | #import "UIButton+AFNetworking.h" 39 | #import "UIImageView+AFNetworking.h" 40 | #import "UIProgressView+AFNetworking.h" 41 | #endif /* _UIKIT_AFNETWORKING_ */ 42 | #endif 43 | -------------------------------------------------------------------------------- /Classes/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Classes/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. 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 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | /** 31 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task. 32 | */ 33 | @interface UIActivityIndicatorView (AFNetworking) 34 | 35 | ///---------------------------------- 36 | /// @name Animating for Session Tasks 37 | ///---------------------------------- 38 | 39 | /** 40 | Binds the animating state to the state of the specified task. 41 | 42 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 43 | */ 44 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; 45 | 46 | @end 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 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 13 | // all 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 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if TARGET_OS_IOS 28 | 29 | #import 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task. 35 | */ 36 | @interface UIRefreshControl (AFNetworking) 37 | 38 | ///----------------------------------- 39 | /// @name Refreshing for Session Tasks 40 | ///----------------------------------- 41 | 42 | /** 43 | Binds the refreshing state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 46 | */ 47 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 48 | 49 | @end 50 | 51 | NS_ASSUME_NONNULL_END 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerFileRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerRequest.h" 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | * The GCDWebServerFileRequest subclass of GCDWebServerRequest stores the body 34 | * of the HTTP request to a file on disk. 35 | */ 36 | @interface GCDWebServerFileRequest : GCDWebServerRequest 37 | 38 | /** 39 | * Returns the path to the temporary file containing the request body. 40 | * 41 | * @warning This temporary file will be automatically deleted when the 42 | * GCDWebServerFileRequest is deallocated. If you want to preserve this file, 43 | * you must move it to a different location beforehand. 44 | */ 45 | @property(nonatomic, readonly) NSString* temporaryPath; 46 | 47 | @end 48 | 49 | NS_ASSUME_NONNULL_END 50 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/zego.xcuserdatad/xcschemes/AFNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/zego.xcuserdatad/xcschemes/GCDWebServer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/Bennie.xcuserdatad/xcschemes/AFNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/Bennie.xcuserdatad/xcschemes/GCDWebServer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/zengbailiang.xcuserdatad/xcschemes/AFNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/zengbailiang.xcuserdatad/xcschemes/GCDWebServer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/Bennie.xcuserdatad/xcschemes/Pods-BNM3u8Cache.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/zego.xcuserdatad/xcschemes/Pods-BNM3u8Cache.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/zengbailiang.xcuserdatad/xcschemes/Pods-BNM3u8Cache.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerURLEncodedFormRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerDataRequest.h" 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | * The GCDWebServerURLEncodedFormRequest subclass of GCDWebServerRequest 34 | * parses the body of the HTTP request as a URL encoded form using 35 | * GCDWebServerParseURLEncodedForm(). 36 | */ 37 | @interface GCDWebServerURLEncodedFormRequest : GCDWebServerDataRequest 38 | 39 | /** 40 | * Returns the unescaped control names and values for the URL encoded form. 41 | * 42 | * The text encoding used to interpret the data is extracted from the 43 | * "Content-Type" header or defaults to UTF-8. 44 | */ 45 | @property(nonatomic, readonly) NSDictionary* arguments; 46 | 47 | /** 48 | * Returns the MIME type for URL encoded forms 49 | * i.e. "application/x-www-form-urlencoded". 50 | */ 51 | + (NSString*)mimeType; 52 | 53 | @end 54 | 55 | NS_ASSUME_NONNULL_END 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # BNM3u8Cache 3 | 4 | 使用operation的方式实现m3u8本地缓存和播放。可控制媒体并发数,单个媒体文件下载并发数;支持任务挂起恢复、支持任务取消。 5 | 6 | #### 使用cocoaPods安装 7 | 8 | 首先在Podfild中添加以下内容并保存 9 | 10 | ```ruby 11 | pod 'BNM3u8Cache' 12 | ``` 13 | 14 | 然后命令行执行 15 | 16 | ```bash 17 | $ pod install 18 | ``` 19 | 20 | #### 使用方式 21 | ```Objective-C 22 | // 1.全局配置BNM3U8Manager 23 | NSString *rootPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES) objectAtIndex:0] stringByAppendingPathComponent:@"m3u8files"]; 24 | BNM3U8ManagerConfig *config = BNM3U8ManagerConfig.new; 25 | /*媒体下载并发数控制*/ 26 | config.videoMaxConcurrenceCount = 5; 27 | config.downloadDstRootPath = rootPath; 28 | [[BNM3U8Manager shareInstance] fillConfig:config]; 29 | 30 | // 2. 发起下载 31 | BNM3U8DownloadConfig *dlConfig = BNM3U8DownloadConfig.new; 32 | dlConfig.url = @"https://bitmovin-a.akamaihd.net/content/playhouse-vr/m3u8s/105560_video_360_1000000.m3u8"; 33 | /*单个媒体ts文件并发数控制*/ 34 | dlConfig.maxConcurrenceCount = 5; 35 | dlConfig.localhost = @"http://127.0.0.1:8080/"; 36 | [BNM3U8Manager.shareInstance downloadVideoWithConfig:dlConfig progressBlock:^(CGFloat progress) { 37 | dispatch_async(dispatch_get_main_queue(), ^{ 38 | //显示下载进度 39 | label.text = [NSString stringWithFormat:@"%.00f%%",progress * 100]; 40 | }); 41 | }resultBlock:^(NSError * _Nullable error, NSString * _Nullable localPlayUrl) { 42 | if(localPlayUrl) 43 | { 44 | dispatch_async(dispatch_get_main_queue(), ^{ 45 | // 3. 配置本地服务,开启并播放 46 | BNHttpLocalServer.shareInstance.documentRoot = rootPath; 47 | BNHttpLocalServer.shareInstance.port = 8080; 48 | [BNHttpLocalServer.shareInstance tryStart]; 49 | [self playWithUrlString:localPlayUrl]; 50 | }); 51 | } 52 | }]; 53 | 54 | ``` 55 | 56 | #### 关于并发数的设置 57 | 根据苹果官方文档关于电耗的说明,网络模块的长时间低效运行,会大大的增加动态成本,导致电耗变大。而合理的使用并发,把网络请求集中快速的处理,虽然会增大固定成本,但长期来说,动态成本会大大降低,减少了电耗。从这个角度来说不应该采用单线程下载,应该尽量的采取多并发。考虑发热和效率,合理的设置并发数(建议>=2)。 58 | 59 | #### 二级界面进度的无法回调 60 | 由于是使用单例来下载,回调block也是与一个下载任务绑定的。当界面退出了,如果没有保存当前这个回调函数,那么就再也获取不到回调。需要把任务全部取消,重新发起,这样就能重新赋值所有回调。因为是多个小文件的下载,重复文件不会重复下载,所以全部取消,重新发起,对流量的浪费使用并不会增大很多。 61 | 62 | #### 索引文件解析失败 63 | m3u8格式形式比较多,没有兼容到。只能慢慢兼容,更新,做到兼容大部分格式(主流/常用-》非主流/不常用)。 64 | 65 | 66 | #### 更新list 67 | 1. 添加相对路径的索引文件解析 68 | 2. 本地服务 CocoaHTTPServer(年久失修) 切换到 GCDWebServer(持续更新)。2019-12-09 69 | 3. version:1.1.0。detail:1.修正key组装路径错误、iv非空处理等。2.添加suspend resume等功能、梳理任务执行流程、完善cannel、suspend功能、多线程死锁问题修正。2020-7-24 70 | ## 欢迎issues和指正。 71 | -------------------------------------------------------------------------------- /Classes/m3u8/category/NSString+m3u8.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+m3u8.m 3 | // M3U8DownLoadTest 4 | // 5 | // Created by zengbailiang on 10/5/17. 6 | // Copyright © 2017 controling. All rights reserved. 7 | // 8 | 9 | #import "NSString+m3u8.h" 10 | #import 11 | 12 | @implementation NSString (m3u8) 13 | - (NSString *)subStringFrom:(NSString *)startString to:(NSString *)endString 14 | { 15 | NSRange startRange = [self rangeOfString:startString]; 16 | if (startRange.location == NSNotFound) { 17 | return nil; 18 | } 19 | NSString *newStr = [self substringWithRange:NSMakeRange(startRange.location + startRange.length, self.length - startRange.location - startRange.length)]; 20 | 21 | NSRange kEndRange = [newStr rangeOfString:endString]; 22 | if (kEndRange.location == NSNotFound) { 23 | return nil; 24 | } 25 | NSRange endRange = NSMakeRange(kEndRange.location + startRange.location + startRange.length, kEndRange.length); 26 | 27 | NSRange range = NSMakeRange(startRange.location + startRange.length, endRange.location - startRange.location - startRange.length); 28 | return [self substringWithRange:range]; 29 | } 30 | 31 | - (NSString *)subStringForm:(NSString *)string offset:(NSInteger) offset 32 | { 33 | NSRange startRange = [self rangeOfString:string]; 34 | if (startRange.location != NSNotFound) { 35 | return [self substringFromIndex:startRange.location + offset]; 36 | } 37 | return nil; 38 | } 39 | 40 | - (NSString *)subStringTo:(NSString *)string 41 | { 42 | NSRange startRange = [self rangeOfString:string]; 43 | return [self substringWithRange:NSMakeRange(0, startRange.location)]; 44 | } 45 | 46 | - (NSString *)removeSpaceAndNewline 47 | { 48 | NSString *temp = [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; 49 | NSString *text = [temp stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet ]]; 50 | return text; 51 | } 52 | 53 | #define CC_MD5_DIGEST_LENGTH 16 54 | + (NSString*)getmd5WithString:(NSString *)string 55 | { 56 | const char* original_str=[string UTF8String]; 57 | unsigned char digist[CC_MD5_DIGEST_LENGTH]; 58 | CC_MD5(original_str, (uint)strlen(original_str), digist); 59 | NSMutableString* outPutStr = [NSMutableString stringWithCapacity:10]; 60 | for(int i =0; i 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task. 35 | */ 36 | @interface UIProgressView (AFNetworking) 37 | 38 | ///------------------------------------ 39 | /// @name Setting Session Task Progress 40 | ///------------------------------------ 41 | 42 | /** 43 | Binds the progress to the upload progress of the specified session task. 44 | 45 | @param task The session task. 46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 47 | */ 48 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 49 | animated:(BOOL)animated; 50 | 51 | /** 52 | Binds the progress to the download progress of the specified session task. 53 | 54 | @param task The session task. 55 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 56 | */ 57 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 58 | animated:(BOOL)animated; 59 | 60 | @end 61 | 62 | NS_ASSUME_NONNULL_END 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-BNM3u8Cache/Pods-BNM3u8Cache-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2011-2016 Alamofire Software Foundation (http://alamofire.org/) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | 27 | ## GCDWebServer 28 | 29 | Copyright (c) 2012-2014, Pierre-Olivier Latour 30 | All rights reserved. 31 | 32 | Redistribution and use in source and binary forms, with or without 33 | modification, are permitted provided that the following conditions are met: 34 | * Redistributions of source code must retain the above copyright 35 | notice, this list of conditions and the following disclaimer. 36 | * Redistributions in binary form must reproduce the above copyright 37 | notice, this list of conditions and the following disclaimer in the 38 | documentation and/or other materials provided with the distribution. 39 | * The name of Pierre-Olivier Latour may not be used to endorse 40 | or promote products derived from this software without specific 41 | prior written permission. 42 | 43 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 44 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 45 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 46 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 47 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 48 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 49 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 50 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 51 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 52 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 | 54 | Generated by CocoaPods - https://cocoapods.org 55 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerStreamedResponse.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @implementation GCDWebServerStreamedResponse { 35 | GCDWebServerAsyncStreamBlock _block; 36 | } 37 | 38 | @dynamic contentType; 39 | 40 | + (instancetype)responseWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block { 41 | return [(GCDWebServerStreamedResponse*)[[self class] alloc] initWithContentType:type streamBlock:block]; 42 | } 43 | 44 | + (instancetype)responseWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block { 45 | return [(GCDWebServerStreamedResponse*)[[self class] alloc] initWithContentType:type asyncStreamBlock:block]; 46 | } 47 | 48 | - (instancetype)initWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block { 49 | return [self initWithContentType:type 50 | asyncStreamBlock:^(GCDWebServerBodyReaderCompletionBlock completionBlock) { 51 | NSError* error = nil; 52 | NSData* data = block(&error); 53 | completionBlock(data, error); 54 | }]; 55 | } 56 | 57 | - (instancetype)initWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block { 58 | if ((self = [super init])) { 59 | _block = [block copy]; 60 | 61 | self.contentType = type; 62 | } 63 | return self; 64 | } 65 | 66 | - (void)asyncReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block { 67 | _block(block); 68 | } 69 | 70 | - (NSString*)description { 71 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 72 | [description appendString:@"\n\n"]; 73 | return description; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerStreamedResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerResponse.h" 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | * The GCDWebServerStreamBlock is called to stream the data for the HTTP body. 34 | * The block must return either a chunk of data, an empty NSData when done, or 35 | * nil on error and set the "error" argument which is guaranteed to be non-NULL. 36 | */ 37 | typedef NSData* _Nullable (^GCDWebServerStreamBlock)(NSError** error); 38 | 39 | /** 40 | * The GCDWebServerAsyncStreamBlock works like the GCDWebServerStreamBlock 41 | * except the streamed data can be returned at a later time allowing for 42 | * truly asynchronous generation of the data. 43 | * 44 | * The block must call "completionBlock" passing the new chunk of data when ready, 45 | * an empty NSData when done, or nil on error and pass a NSError. 46 | * 47 | * The block cannot call "completionBlock" more than once per invocation. 48 | */ 49 | typedef void (^GCDWebServerAsyncStreamBlock)(GCDWebServerBodyReaderCompletionBlock completionBlock); 50 | 51 | /** 52 | * The GCDWebServerStreamedResponse subclass of GCDWebServerResponse streams 53 | * the body of the HTTP response using a GCD block. 54 | */ 55 | @interface GCDWebServerStreamedResponse : GCDWebServerResponse 56 | @property(nonatomic, copy) NSString* contentType; // Redeclare as non-null 57 | 58 | /** 59 | * Creates a response with streamed data and a given content type. 60 | */ 61 | + (instancetype)responseWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block; 62 | 63 | /** 64 | * Creates a response with async streamed data and a given content type. 65 | */ 66 | + (instancetype)responseWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block; 67 | 68 | /** 69 | * Initializes a response with streamed data and a given content type. 70 | */ 71 | - (instancetype)initWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block; 72 | 73 | /** 74 | * This method is the designated initializer for the class. 75 | */ 76 | - (instancetype)initWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block; 77 | 78 | @end 79 | 80 | NS_ASSUME_NONNULL_END 81 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerDataRequest.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @interface GCDWebServerDataRequest () 35 | @property(nonatomic) NSMutableData* data; 36 | @end 37 | 38 | @implementation GCDWebServerDataRequest { 39 | NSString* _text; 40 | id _jsonObject; 41 | } 42 | 43 | - (BOOL)open:(NSError**)error { 44 | if (self.contentLength != NSUIntegerMax) { 45 | _data = [[NSMutableData alloc] initWithCapacity:self.contentLength]; 46 | } else { 47 | _data = [[NSMutableData alloc] init]; 48 | } 49 | if (_data == nil) { 50 | if (error) { 51 | *error = [NSError errorWithDomain:kGCDWebServerErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Failed allocating memory"}]; 52 | } 53 | return NO; 54 | } 55 | return YES; 56 | } 57 | 58 | - (BOOL)writeData:(NSData*)data error:(NSError**)error { 59 | [_data appendData:data]; 60 | return YES; 61 | } 62 | 63 | - (BOOL)close:(NSError**)error { 64 | return YES; 65 | } 66 | 67 | - (NSString*)description { 68 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 69 | if (_data) { 70 | [description appendString:@"\n\n"]; 71 | [description appendString:GCDWebServerDescribeData(_data, (NSString*)self.contentType)]; 72 | } 73 | return description; 74 | } 75 | 76 | @end 77 | 78 | @implementation GCDWebServerDataRequest (Extensions) 79 | 80 | - (NSString*)text { 81 | if (_text == nil) { 82 | if ([self.contentType hasPrefix:@"text/"]) { 83 | NSString* charset = GCDWebServerExtractHeaderValueParameter(self.contentType, @"charset"); 84 | _text = [[NSString alloc] initWithData:self.data encoding:GCDWebServerStringEncodingFromCharset(charset)]; 85 | } else { 86 | GWS_DNOT_REACHED(); 87 | } 88 | } 89 | return _text; 90 | } 91 | 92 | - (id)jsonObject { 93 | if (_jsonObject == nil) { 94 | NSString* mimeType = GCDWebServerTruncateHeaderValue(self.contentType); 95 | if ([mimeType isEqualToString:@"application/json"] || [mimeType isEqualToString:@"text/json"] || [mimeType isEqualToString:@"text/javascript"]) { 96 | _jsonObject = [NSJSONSerialization JSONObjectWithData:_data options:0 error:NULL]; 97 | } else { 98 | GWS_DNOT_REACHED(); 99 | } 100 | } 101 | return _jsonObject; 102 | } 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-BNM3u8Cache/Pods-BNM3u8Cache-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011-2016 Alamofire Software Foundation (http://alamofire.org/) 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | License 38 | MIT 39 | Title 40 | AFNetworking 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Copyright (c) 2012-2014, Pierre-Olivier Latour 47 | All rights reserved. 48 | 49 | Redistribution and use in source and binary forms, with or without 50 | modification, are permitted provided that the following conditions are met: 51 | * Redistributions of source code must retain the above copyright 52 | notice, this list of conditions and the following disclaimer. 53 | * Redistributions in binary form must reproduce the above copyright 54 | notice, this list of conditions and the following disclaimer in the 55 | documentation and/or other materials provided with the distribution. 56 | * The name of Pierre-Olivier Latour may not be used to endorse 57 | or promote products derived from this software without specific 58 | prior written permission. 59 | 60 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 61 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 62 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 63 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 64 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 65 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 66 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 67 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 68 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 69 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 70 | 71 | License 72 | BSD 73 | Title 74 | GCDWebServer 75 | Type 76 | PSGroupSpecifier 77 | 78 | 79 | FooterText 80 | Generated by CocoaPods - https://cocoapods.org 81 | Title 82 | 83 | Type 84 | PSGroupSpecifier 85 | 86 | 87 | StringsTable 88 | Acknowledgements 89 | Title 90 | Acknowledgements 91 | 92 | 93 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerFileRequest.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @implementation GCDWebServerFileRequest { 35 | int _file; 36 | } 37 | 38 | - (instancetype)initWithMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers path:(NSString*)path query:(NSDictionary*)query { 39 | if ((self = [super initWithMethod:method url:url headers:headers path:path query:query])) { 40 | _temporaryPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]]; 41 | } 42 | return self; 43 | } 44 | 45 | - (void)dealloc { 46 | unlink([_temporaryPath fileSystemRepresentation]); 47 | } 48 | 49 | - (BOOL)open:(NSError**)error { 50 | _file = open([_temporaryPath fileSystemRepresentation], O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); 51 | if (_file <= 0) { 52 | if (error) { 53 | *error = GCDWebServerMakePosixError(errno); 54 | } 55 | return NO; 56 | } 57 | return YES; 58 | } 59 | 60 | - (BOOL)writeData:(NSData*)data error:(NSError**)error { 61 | if (write(_file, data.bytes, data.length) != (ssize_t)data.length) { 62 | if (error) { 63 | *error = GCDWebServerMakePosixError(errno); 64 | } 65 | return NO; 66 | } 67 | return YES; 68 | } 69 | 70 | - (BOOL)close:(NSError**)error { 71 | if (close(_file) < 0) { 72 | if (error) { 73 | *error = GCDWebServerMakePosixError(errno); 74 | } 75 | return NO; 76 | } 77 | #ifdef __GCDWEBSERVER_ENABLE_TESTING__ 78 | NSString* creationDateHeader = [self.headers objectForKey:@"X-GCDWebServer-CreationDate"]; 79 | if (creationDateHeader) { 80 | NSDate* date = GCDWebServerParseISO8601(creationDateHeader); 81 | if (!date || ![[NSFileManager defaultManager] setAttributes:@{NSFileCreationDate : date} ofItemAtPath:_temporaryPath error:error]) { 82 | return NO; 83 | } 84 | } 85 | NSString* modifiedDateHeader = [self.headers objectForKey:@"X-GCDWebServer-ModifiedDate"]; 86 | if (modifiedDateHeader) { 87 | NSDate* date = GCDWebServerParseRFC822(modifiedDateHeader); 88 | if (!date || ![[NSFileManager defaultManager] setAttributes:@{NSFileModificationDate : date} ofItemAtPath:_temporaryPath error:error]) { 89 | return NO; 90 | } 91 | } 92 | #endif 93 | return YES; 94 | } 95 | 96 | - (NSString*)description { 97 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 98 | [description appendFormat:@"\n\n{%@}", _temporaryPath]; 99 | return description; 100 | } 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerErrorResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerDataResponse.h" 29 | #import "GCDWebServerHTTPStatusCodes.h" 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | /** 34 | * The GCDWebServerDataResponse subclass of GCDWebServerDataResponse generates 35 | * an HTML body from an HTTP status code and an error message. 36 | */ 37 | @interface GCDWebServerErrorResponse : GCDWebServerDataResponse 38 | 39 | /** 40 | * Creates a client error response with the corresponding HTTP status code. 41 | */ 42 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2, 3); 43 | 44 | /** 45 | * Creates a server error response with the corresponding HTTP status code. 46 | */ 47 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2, 3); 48 | 49 | /** 50 | * Creates a client error response with the corresponding HTTP status code 51 | * and an underlying NSError. 52 | */ 53 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(nullable NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3, 4); 54 | 55 | /** 56 | * Creates a server error response with the corresponding HTTP status code 57 | * and an underlying NSError. 58 | */ 59 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(nullable NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3, 4); 60 | 61 | /** 62 | * Initializes a client error response with the corresponding HTTP status code. 63 | */ 64 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2, 3); 65 | 66 | /** 67 | * Initializes a server error response with the corresponding HTTP status code. 68 | */ 69 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2, 3); 70 | 71 | /** 72 | * Initializes a client error response with the corresponding HTTP status code 73 | * and an underlying NSError. 74 | */ 75 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(nullable NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3, 4); 76 | 77 | /** 78 | * Initializes a server error response with the corresponding HTTP status code 79 | * and an underlying NSError. 80 | */ 81 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(nullable NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3, 4); 82 | 83 | @end 84 | 85 | NS_ASSUME_NONNULL_END 86 | -------------------------------------------------------------------------------- /Classes/m3u8/BNFileManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // BNFileManager.m 3 | // M3U8DownLoadTest 4 | // 5 | // Created by zengbailiang on 10/5/17. 6 | // Copyright © 2017 controling. All rights reserved. 7 | // 8 | 9 | #import "BNFileManager.h" 10 | 11 | @interface BNFileManager() 12 | @property (nonatomic, strong) NSFileManager *fileManager; 13 | @property (nonatomic, strong) dispatch_queue_t ioQueue; 14 | @end 15 | 16 | NSString * const BNFileManagerWriteErrorDomain = @"error.m3u8.fileManager.write"; 17 | 18 | @implementation BNFileManager 19 | 20 | + (instancetype)shareInstance 21 | { 22 | static BNFileManager *sharedInstance = nil; 23 | static dispatch_once_t onceToken; 24 | dispatch_once(&onceToken, ^{ 25 | sharedInstance = [[self alloc] init]; 26 | sharedInstance.ioQueue = dispatch_queue_create("m3u8.write.serial.queue", DISPATCH_QUEUE_SERIAL); 27 | dispatch_async(sharedInstance.ioQueue, ^{ 28 | sharedInstance.fileManager = [NSFileManager new]; 29 | }); 30 | }); 31 | return sharedInstance; 32 | } 33 | 34 | - (instancetype)initWithIoQueue:(dispatch_queue_t)ioQueue 35 | { 36 | self = [super init]; 37 | if (self) { 38 | _ioQueue = ioQueue != nil ? ioQueue : dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 39 | dispatch_async(_ioQueue, ^{ 40 | self.fileManager = [NSFileManager new]; 41 | }); 42 | } 43 | return self; 44 | } 45 | 46 | #pragma mark - check exit 47 | + (BOOL)exitItemWithPath:(NSString*)path 48 | { 49 | return [[NSFileManager defaultManager] fileExistsAtPath:path]; 50 | } 51 | 52 | #pragma mark save/create 53 | + (BOOL)tryGreateDir:(NSString *)dir 54 | { 55 | if([[NSFileManager defaultManager] fileExistsAtPath:dir]) 56 | { 57 | return YES; 58 | } 59 | else 60 | { 61 | return [[NSFileManager defaultManager] createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:nil]; 62 | } 63 | } 64 | 65 | - (void)saveDate:(NSData*) aData pathUrl:(NSURL*)pathUrl completaionHandler:(BNFileManagerCompletaionHandler)completaionHandler 66 | { 67 | dispatch_async(_ioQueue, ^{ 68 | if ([aData writeToURL:pathUrl atomically:YES]) { 69 | if (completaionHandler) { 70 | completaionHandler(nil); 71 | } 72 | } 73 | else 74 | { 75 | if (completaionHandler) { 76 | completaionHandler([[NSError alloc]initWithDomain:BNFileManagerWriteErrorDomain code:NSURLErrorCannotCreateFile userInfo:nil]); 77 | } 78 | } 79 | }); 80 | } 81 | - (void)saveDate:(NSData*) aData ToFile:(NSString *)file completaionHandler:(BNFileManagerCompletaionHandler)completaionHandler 82 | { 83 | dispatch_async(_ioQueue, ^{ 84 | if ([aData writeToFile:file atomically:YES]) { 85 | if (completaionHandler) { 86 | completaionHandler(nil); 87 | } 88 | } 89 | else 90 | { 91 | if (completaionHandler) { 92 | completaionHandler([[NSError alloc]initWithDomain:BNFileManagerWriteErrorDomain code:NSURLErrorCannotCreateFile userInfo:nil]); 93 | } 94 | } 95 | }); 96 | } 97 | 98 | - (void)moveItemAtURL:(NSURL *)srcURL toURL:(NSURL *)dstURL completaionHandler:(BNFileManagerCompletaionHandler)completaionHandler 99 | { 100 | dispatch_async(_ioQueue, ^{ 101 | NSError *error = nil; 102 | [self.fileManager moveItemAtURL:srcURL toURL:dstURL error:&error]; 103 | if (completaionHandler) { 104 | completaionHandler(error); 105 | } 106 | }); 107 | } 108 | 109 | - (void)removeFileWithPath:(NSString *)path 110 | { 111 | dispatch_async(_ioQueue, ^{ 112 | [self.fileManager removeItemAtPath:path error:nil]; 113 | }); 114 | } 115 | 116 | - (void)tryCreateDictionaryWithPath:(NSString*)path completaionHandler:(BNFileManagerCompletaionHandler)completaionHandler 117 | { 118 | if ([_fileManager fileExistsAtPath:path]) completaionHandler(nil); 119 | 120 | NSError *error = nil; 121 | [_fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]; 122 | if (completaionHandler) { 123 | completaionHandler(error); 124 | } 125 | } 126 | @end 127 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerDataResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerResponse.h" 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | * The GCDWebServerDataResponse subclass of GCDWebServerResponse reads the body 34 | * of the HTTP response from memory. 35 | */ 36 | @interface GCDWebServerDataResponse : GCDWebServerResponse 37 | @property(nonatomic, copy) NSString* contentType; // Redeclare as non-null 38 | 39 | /** 40 | * Creates a response with data in memory and a given content type. 41 | */ 42 | + (instancetype)responseWithData:(NSData*)data contentType:(NSString*)type; 43 | 44 | /** 45 | * This method is the designated initializer for the class. 46 | */ 47 | - (instancetype)initWithData:(NSData*)data contentType:(NSString*)type; 48 | 49 | @end 50 | 51 | @interface GCDWebServerDataResponse (Extensions) 52 | 53 | /** 54 | * Creates a data response from text encoded using UTF-8. 55 | */ 56 | + (nullable instancetype)responseWithText:(NSString*)text; 57 | 58 | /** 59 | * Creates a data response from HTML encoded using UTF-8. 60 | */ 61 | + (nullable instancetype)responseWithHTML:(NSString*)html; 62 | 63 | /** 64 | * Creates a data response from an HTML template encoded using UTF-8. 65 | * See -initWithHTMLTemplate:variables: for details. 66 | */ 67 | + (nullable instancetype)responseWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables; 68 | 69 | /** 70 | * Creates a data response from a serialized JSON object and the default 71 | * "application/json" content type. 72 | */ 73 | + (nullable instancetype)responseWithJSONObject:(id)object; 74 | 75 | /** 76 | * Creates a data response from a serialized JSON object and a custom 77 | * content type. 78 | */ 79 | + (nullable instancetype)responseWithJSONObject:(id)object contentType:(NSString*)type; 80 | 81 | /** 82 | * Initializes a data response from text encoded using UTF-8. 83 | */ 84 | - (nullable instancetype)initWithText:(NSString*)text; 85 | 86 | /** 87 | * Initializes a data response from HTML encoded using UTF-8. 88 | */ 89 | - (nullable instancetype)initWithHTML:(NSString*)html; 90 | 91 | /** 92 | * Initializes a data response from an HTML template encoded using UTF-8. 93 | * 94 | * All occurences of "%variable%" within the HTML template are replaced with 95 | * their corresponding values. 96 | */ 97 | - (nullable instancetype)initWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables; 98 | 99 | /** 100 | * Initializes a data response from a serialized JSON object and the default 101 | * "application/json" content type. 102 | */ 103 | - (nullable instancetype)initWithJSONObject:(id)object; 104 | 105 | /** 106 | * Initializes a data response from a serialized JSON object and a custom 107 | * content type. 108 | */ 109 | - (nullable instancetype)initWithJSONObject:(id)object contentType:(NSString*)type; 110 | 111 | @end 112 | 113 | NS_ASSUME_NONNULL_END 114 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Core/GCDWebServerFunctions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /** 37 | * Converts a file extension to the corresponding MIME type. 38 | * If there is no match, "application/octet-stream" is returned. 39 | * 40 | * Overrides allow to customize the built-in mapping from extensions to MIME 41 | * types. Keys of the dictionary must be lowercased file extensions without 42 | * the period, and the values must be the corresponding MIME types. 43 | */ 44 | NSString* GCDWebServerGetMimeTypeForExtension(NSString* extension, NSDictionary* _Nullable overrides); 45 | 46 | /** 47 | * Add percent-escapes to a string so it can be used in a URL. 48 | * The legal characters ":@/?&=+" are also escaped to ensure compatibility 49 | * with URL encoded forms and URL queries. 50 | */ 51 | NSString* _Nullable GCDWebServerEscapeURLString(NSString* string); 52 | 53 | /** 54 | * Unescapes a URL percent-encoded string. 55 | */ 56 | NSString* _Nullable GCDWebServerUnescapeURLString(NSString* string); 57 | 58 | /** 59 | * Extracts the unescaped names and values from an 60 | * "application/x-www-form-urlencoded" form. 61 | * http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1 62 | */ 63 | NSDictionary* GCDWebServerParseURLEncodedForm(NSString* form); 64 | 65 | /** 66 | * On OS X, returns the IPv4 or IPv6 address as a string of the primary 67 | * connected service or nil if not available. 68 | * 69 | * On iOS, returns the IPv4 or IPv6 address as a string of the WiFi 70 | * interface if connected or nil otherwise. 71 | */ 72 | NSString* _Nullable GCDWebServerGetPrimaryIPAddress(BOOL useIPv6); 73 | 74 | /** 75 | * Converts a date into a string using RFC822 formatting. 76 | * https://tools.ietf.org/html/rfc822#section-5 77 | * https://tools.ietf.org/html/rfc1123#section-5.2.14 78 | */ 79 | NSString* GCDWebServerFormatRFC822(NSDate* date); 80 | 81 | /** 82 | * Converts a RFC822 formatted string into a date. 83 | * https://tools.ietf.org/html/rfc822#section-5 84 | * https://tools.ietf.org/html/rfc1123#section-5.2.14 85 | * 86 | * @warning Timezones other than GMT are not supported by this function. 87 | */ 88 | NSDate* _Nullable GCDWebServerParseRFC822(NSString* string); 89 | 90 | /** 91 | * Converts a date into a string using IOS 8601 formatting. 92 | * http://tools.ietf.org/html/rfc3339#section-5.6 93 | */ 94 | NSString* GCDWebServerFormatISO8601(NSDate* date); 95 | 96 | /** 97 | * Converts a ISO 8601 formatted string into a date. 98 | * http://tools.ietf.org/html/rfc3339#section-5.6 99 | * 100 | * @warning Only "calendar" variant is supported at this time and timezones 101 | * other than GMT are not supported either. 102 | */ 103 | NSDate* _Nullable GCDWebServerParseISO8601(NSString* string); 104 | 105 | /** 106 | * Removes "//", "/./" and "/../" components from path as well as any trailing slash. 107 | */ 108 | NSString* GCDWebServerNormalizePath(NSString* path); 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | 114 | NS_ASSUME_NONNULL_END 115 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFHTTPSessionManager; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. 36 | 37 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. 38 | */ 39 | @interface UIWebView (AFNetworking) 40 | 41 | /** 42 | The session manager used to download all requests. 43 | */ 44 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager; 45 | 46 | /** 47 | Asynchronously loads the specified request. 48 | 49 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 50 | @param progress A progress object monitoring the current download progress. 51 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. 52 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 53 | */ 54 | - (void)loadRequest:(NSURLRequest *)request 55 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 56 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 57 | failure:(nullable void (^)(NSError *error))failure; 58 | 59 | /** 60 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. 61 | 62 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 63 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. 64 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. 65 | @param progress A progress object monitoring the current download progress. 66 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. 67 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 68 | */ 69 | - (void)loadRequest:(NSURLRequest *)request 70 | MIMEType:(nullable NSString *)MIMEType 71 | textEncodingName:(nullable NSString *)textEncodingName 72 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 73 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 74 | failure:(nullable void (^)(NSError *error))failure; 75 | 76 | @end 77 | 78 | NS_ASSUME_NONNULL_END 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Classes/m3u8/BNM3U8FileDownLoadOperation.m: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8FileDownLoadOperation.m 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import "BNM3U8FileDownLoadOperation.h" 10 | #import "BNFileManager.h" 11 | 12 | @interface BNM3U8FileDownLoadOperation () 13 | @property (nonatomic, strong) NSObject *fileInfo; 14 | @property (nonatomic, strong) BNM3U8FileDownLoadOperationResultBlock resultBlock; 15 | @property (nonatomic, strong) AFURLSessionManager *sessionManager; 16 | @property (assign, nonatomic, getter = isExecuting) BOOL executing; 17 | @property (assign, nonatomic, getter = isFinished) BOOL finished; 18 | @property (nonatomic, strong) NSURLSessionDownloadTask *dataTask; 19 | @end 20 | 21 | @implementation BNM3U8FileDownLoadOperation 22 | 23 | @synthesize executing = _executing; 24 | @synthesize finished = _finished; 25 | 26 | - (instancetype)initWithFileInfo:(NSObject *)fileInfo sessionManager:(AFURLSessionManager*)sessionManager resultBlock:(BNM3U8FileDownLoadOperationResultBlock)resultBlock{ 27 | NSParameterAssert(fileInfo); 28 | self = [super init]; 29 | if (self) { 30 | _fileInfo = fileInfo; 31 | _resultBlock = resultBlock; 32 | _sessionManager = sessionManager; 33 | } 34 | return self; 35 | } 36 | 37 | #pragma mark - 38 | - (void)start 39 | { 40 | @synchronized (self) { 41 | if (self.isCancelled) { 42 | self.finished = YES; 43 | [self reset]; 44 | return; 45 | } 46 | 47 | if([BNFileManager exitItemWithPath:_fileInfo.dstFilePath]){ 48 | _resultBlock(nil,_fileInfo); 49 | [self done]; 50 | return; 51 | } 52 | 53 | NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_fileInfo.downloadUrl]]; 54 | __block NSData *data = nil; 55 | __weak __typeof(self) weakSelf = self; 56 | NSURLSessionDownloadTask *downloadTask = [self.sessionManager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) { 57 | #if DEBUG 58 | NSLog(@"%@:%0.2lf%%\n",weakSelf.fileInfo.downloadUrl, (float)downloadProgress.completedUnitCount / (float)downloadProgress.totalUnitCount * 100); 59 | #endif 60 | } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { 61 | data = [NSData dataWithContentsOfURL:targetPath]; 62 | return nil; 63 | } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) { 64 | if (!error) { 65 | [weakSelf saveData:data]; 66 | } 67 | else 68 | { 69 | weakSelf.resultBlock(error,self.fileInfo); 70 | [self done]; 71 | } 72 | }]; 73 | self.dataTask = downloadTask; 74 | [downloadTask resume]; 75 | self.executing = YES; 76 | } 77 | } 78 | 79 | - (void)cancel{ 80 | @synchronized (self) { 81 | if(self.isFinished) return; 82 | [super cancel]; 83 | [self.dataTask cancel]; 84 | if (self.isExecuting) self.executing = NO; 85 | if (!self.isFinished) self.finished = YES; 86 | [self reset]; 87 | } 88 | } 89 | 90 | #pragma mark - 91 | - (void)done { 92 | self.finished = YES; 93 | self.executing = NO; 94 | [self reset]; 95 | } 96 | 97 | - (void)reset { 98 | @synchronized (self) { 99 | self.dataTask = nil; 100 | } 101 | } 102 | 103 | - (void)saveData:(NSData *)data 104 | { 105 | [[BNFileManager shareInstance] saveDate:data ToFile:[_fileInfo dstFilePath] completaionHandler:^(NSError *error) { 106 | if(self.resultBlock) self.resultBlock(error, self.fileInfo); 107 | [self done]; 108 | }]; 109 | } 110 | 111 | - (void)suspend { 112 | @synchronized (self) { 113 | [self.dataTask suspend]; 114 | NSLog(@"[self.dataTask suspend]"); 115 | } 116 | } 117 | 118 | - (void)resume { 119 | @synchronized (self) { 120 | [self.dataTask resume]; 121 | NSLog(@"[self.dataTask resume]"); 122 | } 123 | } 124 | 125 | #pragma mark - 126 | - (void)setFinished:(BOOL)finished { 127 | [self willChangeValueForKey:@"isFinished"]; 128 | _finished = finished; 129 | [self didChangeValueForKey:@"isFinished"]; 130 | } 131 | 132 | - (void)setExecuting:(BOOL)executing { 133 | [self willChangeValueForKey:@"isExecuting"]; 134 | _executing = executing; 135 | [self didChangeValueForKey:@"isExecuting"]; 136 | } 137 | 138 | - (BOOL)isConcurrent { 139 | return YES; 140 | } 141 | 142 | @end 143 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 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 13 | // all 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 21 | // THE SOFTWARE. 22 | 23 | #import "UIRefreshControl+AFNetworking.h" 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import "AFURLSessionManager.h" 29 | 30 | @interface AFRefreshControlNotificationObserver : NSObject 31 | @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; 32 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; 33 | 34 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 35 | 36 | @end 37 | 38 | @implementation UIRefreshControl (AFNetworking) 39 | 40 | - (AFRefreshControlNotificationObserver *)af_notificationObserver { 41 | AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 42 | if (notificationObserver == nil) { 43 | notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; 44 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | } 46 | return notificationObserver; 47 | } 48 | 49 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 50 | [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; 51 | } 52 | 53 | @end 54 | 55 | @implementation AFRefreshControlNotificationObserver 56 | 57 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl 58 | { 59 | self = [super init]; 60 | if (self) { 61 | _refreshControl = refreshControl; 62 | } 63 | return self; 64 | } 65 | 66 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 67 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 68 | 69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 71 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 72 | 73 | if (task) { 74 | UIRefreshControl *refreshControl = self.refreshControl; 75 | if (task.state == NSURLSessionTaskStateRunning) { 76 | [refreshControl beginRefreshing]; 77 | 78 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; 79 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; 80 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; 81 | } else { 82 | [refreshControl endRefreshing]; 83 | } 84 | } 85 | } 86 | 87 | #pragma mark - 88 | 89 | - (void)af_beginRefreshing { 90 | dispatch_async(dispatch_get_main_queue(), ^{ 91 | [self.refreshControl beginRefreshing]; 92 | }); 93 | } 94 | 95 | - (void)af_endRefreshing { 96 | dispatch_async(dispatch_get_main_queue(), ^{ 97 | [self.refreshControl endRefreshing]; 98 | }); 99 | } 100 | 101 | #pragma mark - 102 | 103 | - (void)dealloc { 104 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 105 | 106 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 107 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 108 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 109 | } 110 | 111 | @end 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerFileResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerResponse.h" 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | * The GCDWebServerFileResponse subclass of GCDWebServerResponse reads the body 34 | * of the HTTP response from a file on disk. 35 | * 36 | * It will automatically set the contentType, lastModifiedDate and eTag 37 | * properties of the GCDWebServerResponse according to the file extension and 38 | * metadata. 39 | */ 40 | @interface GCDWebServerFileResponse : GCDWebServerResponse 41 | @property(nonatomic, copy) NSString* contentType; // Redeclare as non-null 42 | @property(nonatomic) NSDate* lastModifiedDate; // Redeclare as non-null 43 | @property(nonatomic, copy) NSString* eTag; // Redeclare as non-null 44 | 45 | /** 46 | * Creates a response with the contents of a file. 47 | */ 48 | + (nullable instancetype)responseWithFile:(NSString*)path; 49 | 50 | /** 51 | * Creates a response like +responseWithFile: and sets the "Content-Disposition" 52 | * HTTP header for a download if the "attachment" argument is YES. 53 | */ 54 | + (nullable instancetype)responseWithFile:(NSString*)path isAttachment:(BOOL)attachment; 55 | 56 | /** 57 | * Creates a response like +responseWithFile: but restricts the file contents 58 | * to a specific byte range. 59 | * 60 | * See -initWithFile:byteRange: for details. 61 | */ 62 | + (nullable instancetype)responseWithFile:(NSString*)path byteRange:(NSRange)range; 63 | 64 | /** 65 | * Creates a response like +responseWithFile:byteRange: and sets the 66 | * "Content-Disposition" HTTP header for a download if the "attachment" 67 | * argument is YES. 68 | */ 69 | + (nullable instancetype)responseWithFile:(NSString*)path byteRange:(NSRange)range isAttachment:(BOOL)attachment; 70 | 71 | /** 72 | * Initializes a response with the contents of a file. 73 | */ 74 | - (nullable instancetype)initWithFile:(NSString*)path; 75 | 76 | /** 77 | * Initializes a response like +responseWithFile: and sets the 78 | * "Content-Disposition" HTTP header for a download if the "attachment" 79 | * argument is YES. 80 | */ 81 | - (nullable instancetype)initWithFile:(NSString*)path isAttachment:(BOOL)attachment; 82 | 83 | /** 84 | * Initializes a response like -initWithFile: but restricts the file contents 85 | * to a specific byte range. This range should be set to (NSUIntegerMax, 0) for 86 | * the full file, (offset, length) if expressed from the beginning of the file, 87 | * or (NSUIntegerMax, length) if expressed from the end of the file. The "offset" 88 | * and "length" values will be automatically adjusted to be compatible with the 89 | * actual size of the file. 90 | * 91 | * This argument would typically be set to the value of the byteRange property 92 | * of the current GCDWebServerRequest. 93 | */ 94 | - (nullable instancetype)initWithFile:(NSString*)path byteRange:(NSRange)range; 95 | 96 | /** 97 | * This method is the designated initializer for the class. 98 | * 99 | * If MIME type overrides are specified, they allow to customize the built-in 100 | * mapping from extensions to MIME types. Keys of the dictionary must be lowercased 101 | * file extensions without the period, and the values must be the corresponding 102 | * MIME types. 103 | */ 104 | - (nullable instancetype)initWithFile:(NSString*)path byteRange:(NSRange)range isAttachment:(BOOL)attachment mimeTypeOverrides:(nullable NSDictionary*)overrides; 105 | 106 | @end 107 | 108 | NS_ASSUME_NONNULL_END 109 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerMultiPartFormRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerRequest.h" 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | * The GCDWebServerMultiPart class is an abstract class that wraps the content 34 | * of a part. 35 | */ 36 | @interface GCDWebServerMultiPart : NSObject 37 | 38 | /** 39 | * Returns the control name retrieved from the part headers. 40 | */ 41 | @property(nonatomic, readonly) NSString* controlName; 42 | 43 | /** 44 | * Returns the content type retrieved from the part headers or "text/plain" 45 | * if not available (per HTTP specifications). 46 | */ 47 | @property(nonatomic, readonly) NSString* contentType; 48 | 49 | /** 50 | * Returns the MIME type component of the content type for the part. 51 | */ 52 | @property(nonatomic, readonly) NSString* mimeType; 53 | 54 | @end 55 | 56 | /** 57 | * The GCDWebServerMultiPartArgument subclass of GCDWebServerMultiPart wraps 58 | * the content of a part as data in memory. 59 | */ 60 | @interface GCDWebServerMultiPartArgument : GCDWebServerMultiPart 61 | 62 | /** 63 | * Returns the data for the part. 64 | */ 65 | @property(nonatomic, readonly) NSData* data; 66 | 67 | /** 68 | * Returns the data for the part interpreted as text. If the content 69 | * type of the part is not a text one, or if an error occurs, nil is returned. 70 | * 71 | * The text encoding used to interpret the data is extracted from the 72 | * "Content-Type" header or defaults to UTF-8. 73 | */ 74 | @property(nonatomic, readonly, nullable) NSString* string; 75 | 76 | @end 77 | 78 | /** 79 | * The GCDWebServerMultiPartFile subclass of GCDWebServerMultiPart wraps 80 | * the content of a part as a file on disk. 81 | */ 82 | @interface GCDWebServerMultiPartFile : GCDWebServerMultiPart 83 | 84 | /** 85 | * Returns the file name retrieved from the part headers. 86 | */ 87 | @property(nonatomic, readonly) NSString* fileName; 88 | 89 | /** 90 | * Returns the path to the temporary file containing the part data. 91 | * 92 | * @warning This temporary file will be automatically deleted when the 93 | * GCDWebServerMultiPartFile is deallocated. If you want to preserve this file, 94 | * you must move it to a different location beforehand. 95 | */ 96 | @property(nonatomic, readonly) NSString* temporaryPath; 97 | 98 | @end 99 | 100 | /** 101 | * The GCDWebServerMultiPartFormRequest subclass of GCDWebServerRequest 102 | * parses the body of the HTTP request as a multipart encoded form. 103 | */ 104 | @interface GCDWebServerMultiPartFormRequest : GCDWebServerRequest 105 | 106 | /** 107 | * Returns the argument parts from the multipart encoded form as 108 | * name / GCDWebServerMultiPartArgument pairs. 109 | */ 110 | @property(nonatomic, readonly) NSArray* arguments; 111 | 112 | /** 113 | * Returns the files parts from the multipart encoded form as 114 | * name / GCDWebServerMultiPartFile pairs. 115 | */ 116 | @property(nonatomic, readonly) NSArray* files; 117 | 118 | /** 119 | * Returns the MIME type for multipart encoded forms 120 | * i.e. "multipart/form-data". 121 | */ 122 | + (NSString*)mimeType; 123 | 124 | /** 125 | * Returns the first argument for a given control name or nil if not found. 126 | */ 127 | - (nullable GCDWebServerMultiPartArgument*)firstArgumentForControlName:(NSString*)name; 128 | 129 | /** 130 | * Returns the first file for a given control name or nil if not found. 131 | */ 132 | - (nullable GCDWebServerMultiPartFile*)firstFileForControlName:(NSString*)name; 133 | 134 | @end 135 | 136 | NS_ASSUME_NONNULL_END 137 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIActivityIndicatorView+AFNetworking.h" 23 | #import 24 | 25 | #if TARGET_OS_IOS || TARGET_OS_TV 26 | 27 | #import "AFURLSessionManager.h" 28 | 29 | @interface AFActivityIndicatorViewNotificationObserver : NSObject 30 | @property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; 31 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; 32 | 33 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; 34 | 35 | @end 36 | 37 | @implementation UIActivityIndicatorView (AFNetworking) 38 | 39 | - (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { 40 | AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 41 | if (notificationObserver == nil) { 42 | notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; 43 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | } 45 | return notificationObserver; 46 | } 47 | 48 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 49 | [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; 50 | } 51 | 52 | @end 53 | 54 | @implementation AFActivityIndicatorViewNotificationObserver 55 | 56 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView 57 | { 58 | self = [super init]; 59 | if (self) { 60 | _activityIndicatorView = activityIndicatorView; 61 | } 62 | return self; 63 | } 64 | 65 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 66 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 67 | 68 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 71 | 72 | if (task) { 73 | if (task.state != NSURLSessionTaskStateCompleted) { 74 | UIActivityIndicatorView *activityIndicatorView = self.activityIndicatorView; 75 | if (task.state == NSURLSessionTaskStateRunning) { 76 | [activityIndicatorView startAnimating]; 77 | } else { 78 | [activityIndicatorView stopAnimating]; 79 | } 80 | 81 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; 82 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; 83 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; 84 | } 85 | } 86 | } 87 | 88 | #pragma mark - 89 | 90 | - (void)af_startAnimating { 91 | dispatch_async(dispatch_get_main_queue(), ^{ 92 | [self.activityIndicatorView startAnimating]; 93 | }); 94 | } 95 | 96 | - (void)af_stopAnimating { 97 | dispatch_async(dispatch_get_main_queue(), ^{ 98 | [self.activityIndicatorView stopAnimating]; 99 | }); 100 | } 101 | 102 | #pragma mark - 103 | 104 | - (void)dealloc { 105 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 106 | 107 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 108 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 109 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 110 | } 111 | 112 | @end 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerDataResponse.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @implementation GCDWebServerDataResponse { 35 | NSData* _data; 36 | BOOL _done; 37 | } 38 | 39 | @dynamic contentType; 40 | 41 | + (instancetype)responseWithData:(NSData*)data contentType:(NSString*)type { 42 | return [(GCDWebServerDataResponse*)[[self class] alloc] initWithData:data contentType:type]; 43 | } 44 | 45 | - (instancetype)initWithData:(NSData*)data contentType:(NSString*)type { 46 | if ((self = [super init])) { 47 | _data = data; 48 | 49 | self.contentType = type; 50 | self.contentLength = data.length; 51 | } 52 | return self; 53 | } 54 | 55 | - (NSData*)readData:(NSError**)error { 56 | NSData* data; 57 | if (_done) { 58 | data = [NSData data]; 59 | } else { 60 | data = _data; 61 | _done = YES; 62 | } 63 | return data; 64 | } 65 | 66 | - (NSString*)description { 67 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 68 | [description appendString:@"\n\n"]; 69 | [description appendString:GCDWebServerDescribeData(_data, self.contentType)]; 70 | return description; 71 | } 72 | 73 | @end 74 | 75 | @implementation GCDWebServerDataResponse (Extensions) 76 | 77 | + (instancetype)responseWithText:(NSString*)text { 78 | return [(GCDWebServerDataResponse*)[self alloc] initWithText:text]; 79 | } 80 | 81 | + (instancetype)responseWithHTML:(NSString*)html { 82 | return [(GCDWebServerDataResponse*)[self alloc] initWithHTML:html]; 83 | } 84 | 85 | + (instancetype)responseWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables { 86 | return [(GCDWebServerDataResponse*)[self alloc] initWithHTMLTemplate:path variables:variables]; 87 | } 88 | 89 | + (instancetype)responseWithJSONObject:(id)object { 90 | return [(GCDWebServerDataResponse*)[self alloc] initWithJSONObject:object]; 91 | } 92 | 93 | + (instancetype)responseWithJSONObject:(id)object contentType:(NSString*)type { 94 | return [(GCDWebServerDataResponse*)[self alloc] initWithJSONObject:object contentType:type]; 95 | } 96 | 97 | - (instancetype)initWithText:(NSString*)text { 98 | NSData* data = [text dataUsingEncoding:NSUTF8StringEncoding]; 99 | if (data == nil) { 100 | GWS_DNOT_REACHED(); 101 | return nil; 102 | } 103 | return [self initWithData:data contentType:@"text/plain; charset=utf-8"]; 104 | } 105 | 106 | - (instancetype)initWithHTML:(NSString*)html { 107 | NSData* data = [html dataUsingEncoding:NSUTF8StringEncoding]; 108 | if (data == nil) { 109 | GWS_DNOT_REACHED(); 110 | return nil; 111 | } 112 | return [self initWithData:data contentType:@"text/html; charset=utf-8"]; 113 | } 114 | 115 | - (instancetype)initWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables { 116 | NSMutableString* html = [[NSMutableString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL]; 117 | [variables enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSString* value, BOOL* stop) { 118 | [html replaceOccurrencesOfString:[NSString stringWithFormat:@"%%%@%%", key] withString:value options:0 range:NSMakeRange(0, html.length)]; 119 | }]; 120 | return [self initWithHTML:html]; 121 | } 122 | 123 | - (instancetype)initWithJSONObject:(id)object { 124 | return [self initWithJSONObject:object contentType:@"application/json"]; 125 | } 126 | 127 | - (instancetype)initWithJSONObject:(id)object contentType:(NSString*)type { 128 | NSData* data = [NSJSONSerialization dataWithJSONObject:object options:0 error:NULL]; 129 | if (data == nil) { 130 | GWS_DNOT_REACHED(); 131 | return nil; 132 | } 133 | return [self initWithData:data contentType:type]; 134 | } 135 | 136 | @end 137 | -------------------------------------------------------------------------------- /Classes/m3u8/BNM3U8Manager.m: -------------------------------------------------------------------------------- 1 | // 2 | // BNM3U8Manager.m 3 | // m3u8Demo 4 | // 5 | // Created by liangzeng on 6/14/19. 6 | // Copyright © 2019 liangzeng. All rights reserved. 7 | // 8 | 9 | #import "BNM3U8Manager.h" 10 | #import "BNM3U8DownloadOperation.h" 11 | #import "AFNetworking.h" 12 | 13 | #define LOCK(lock) dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER); 14 | #define UNLOCK(lock) dispatch_semaphore_signal(lock); 15 | 16 | @implementation BNM3U8ManagerConfig 17 | @end 18 | 19 | @interface BNM3U8Manager() 20 | @property (nonatomic, strong) BNM3U8ManagerConfig *config; 21 | @property (nonatomic, strong) NSMutableDictionary *downloadOperationsMap; 22 | @property (nonatomic, strong) dispatch_semaphore_t operationSemaphore; 23 | @property (nonatomic, strong) NSOperationQueue *downloadQueue; 24 | @property (nonatomic, strong) AFURLSessionManager *sessionManager; 25 | @end 26 | 27 | @implementation BNM3U8Manager 28 | 29 | + (instancetype)shareInstance{ 30 | static BNM3U8Manager *manager; 31 | static dispatch_once_t onceToken; 32 | dispatch_once(&onceToken, ^{ 33 | manager = BNM3U8Manager.new; 34 | manager.operationSemaphore = dispatch_semaphore_create(1); 35 | manager.downloadQueue = [[NSOperationQueue alloc]init]; 36 | manager.downloadQueue.qualityOfService = NSQualityOfServiceUtility; 37 | manager.downloadOperationsMap = NSMutableDictionary.new; 38 | }); 39 | return manager; 40 | } 41 | 42 | - (void)fillConfig:(BNM3U8ManagerConfig*)config{ 43 | if (!_config) { 44 | _config = config; 45 | _downloadQueue.maxConcurrentOperationCount = _config.videoMaxConcurrenceCount; 46 | } 47 | else{ 48 | NSAssert(0, @"config不允许重新赋值"); 49 | } 50 | } 51 | 52 | #pragma mark - 53 | - (void)downloadVideoWithConfig:(BNM3U8DownloadConfig *)config progressBlock:(BNM3U8DownloadProgressBlock)progressBlock resultBlock:(BNM3U8DownloadResultBlock)resultBlock{ 54 | 55 | NSParameterAssert(config.url); 56 | LOCK(_operationSemaphore); 57 | if([_downloadOperationsMap.allKeys containsObject:config.url]){ 58 | NSLog(@"任务已经存在!"); 59 | UNLOCK(_operationSemaphore); 60 | return; 61 | } 62 | UNLOCK(_operationSemaphore); 63 | __weak __typeof(self) weakSelf= self; 64 | BNM3U8DownloadOperation *operation = [[BNM3U8DownloadOperation alloc]initWithConfig:config downloadDstRootPath:self.config.downloadDstRootPath sessionManager:self.sessionManager progressBlock:^(CGFloat progress) { 65 | if(progressBlock) progressBlock(progress); 66 | }resultBlock:^(NSError * _Nullable error, NSString * _Nullable localPlayUrlString) { 67 | ///下载回调 68 | if(resultBlock) resultBlock(error,localPlayUrlString); 69 | LOCK(weakSelf.operationSemaphore); 70 | [weakSelf.downloadOperationsMap removeObjectForKey:config.url]; 71 | UNLOCK(weakSelf.operationSemaphore); 72 | }]; 73 | LOCK(_operationSemaphore); 74 | [_downloadOperationsMap setValue:operation forKey:config.url]; 75 | [_downloadQueue addOperation:operation]; 76 | UNLOCK(_operationSemaphore); 77 | } 78 | 79 | - (void)cannel:(NSString *)url{ 80 | [self _cannel:url]; 81 | } 82 | 83 | - (void)_cannel:(NSString *)url{ 84 | LOCK(_operationSemaphore); 85 | BNM3U8DownloadOperation *operation = [_downloadOperationsMap valueForKey:url]; 86 | UNLOCK(_operationSemaphore); 87 | if(!operation)return; 88 | NSParameterAssert(operation); 89 | if (!operation.isCancelled) { 90 | [operation cancel]; 91 | } 92 | ///remove 93 | LOCK(_operationSemaphore); 94 | [_downloadOperationsMap removeObjectForKey:url]; 95 | UNLOCK(_operationSemaphore); 96 | } 97 | 98 | /*全部取消,遍历operation cnnel. queue的cannel all operation 只能在创建/重新创建或者 dealloc时执行*/ 99 | - (void)cancelAll{ 100 | LOCK(_operationSemaphore); 101 | NSArray *urls = _downloadOperationsMap.allKeys; 102 | UNLOCK(_operationSemaphore); 103 | [urls enumerateObjectsUsingBlock:^(NSString * _Nonnull url, NSUInteger idx, BOOL * _Nonnull stop) { 104 | [self _cannel:url]; 105 | }]; 106 | } 107 | 108 | - (void)suspend{ 109 | if(_downloadQueue.suspended) return; 110 | _downloadQueue.suspended = YES; 111 | LOCK(_operationSemaphore); 112 | NSArray *urls = _downloadOperationsMap.allKeys; 113 | [urls enumerateObjectsUsingBlock:^(NSString * _Nonnull url, NSUInteger idx, BOOL * _Nonnull stop) { 114 | BNM3U8DownloadOperation *operation = [self.downloadOperationsMap valueForKey:url]; 115 | [operation suspend]; 116 | }]; 117 | UNLOCK(_operationSemaphore); 118 | } 119 | 120 | - (void)resume{ 121 | if(!_downloadQueue.suspended) return; 122 | _downloadQueue.suspended = NO; 123 | LOCK(_operationSemaphore); 124 | NSArray *urls = _downloadOperationsMap.allKeys; 125 | [urls enumerateObjectsUsingBlock:^(NSString * _Nonnull url, NSUInteger idx, BOOL * _Nonnull stop) { 126 | BNM3U8DownloadOperation *operation = [self.downloadOperationsMap valueForKey:url]; 127 | [operation resume]; 128 | }]; 129 | UNLOCK(_operationSemaphore); 130 | } 131 | 132 | - (AFURLSessionManager *)sessionManager 133 | { 134 | if (!_sessionManager) { 135 | _sessionManager = [[AFURLSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; 136 | _sessionManager.completionQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 137 | } 138 | return _sessionManager; 139 | } 140 | 141 | @end 142 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Core/GCDWebServerHTTPStatusCodes.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2019, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 29 | // http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml 30 | 31 | #import 32 | 33 | /** 34 | * Convenience constants for "informational" HTTP status codes. 35 | */ 36 | typedef NS_ENUM(NSInteger, GCDWebServerInformationalHTTPStatusCode) { 37 | kGCDWebServerHTTPStatusCode_Continue = 100, 38 | kGCDWebServerHTTPStatusCode_SwitchingProtocols = 101, 39 | kGCDWebServerHTTPStatusCode_Processing = 102 40 | }; 41 | 42 | /** 43 | * Convenience constants for "successful" HTTP status codes. 44 | */ 45 | typedef NS_ENUM(NSInteger, GCDWebServerSuccessfulHTTPStatusCode) { 46 | kGCDWebServerHTTPStatusCode_OK = 200, 47 | kGCDWebServerHTTPStatusCode_Created = 201, 48 | kGCDWebServerHTTPStatusCode_Accepted = 202, 49 | kGCDWebServerHTTPStatusCode_NonAuthoritativeInformation = 203, 50 | kGCDWebServerHTTPStatusCode_NoContent = 204, 51 | kGCDWebServerHTTPStatusCode_ResetContent = 205, 52 | kGCDWebServerHTTPStatusCode_PartialContent = 206, 53 | kGCDWebServerHTTPStatusCode_MultiStatus = 207, 54 | kGCDWebServerHTTPStatusCode_AlreadyReported = 208 55 | }; 56 | 57 | /** 58 | * Convenience constants for "redirection" HTTP status codes. 59 | */ 60 | typedef NS_ENUM(NSInteger, GCDWebServerRedirectionHTTPStatusCode) { 61 | kGCDWebServerHTTPStatusCode_MultipleChoices = 300, 62 | kGCDWebServerHTTPStatusCode_MovedPermanently = 301, 63 | kGCDWebServerHTTPStatusCode_Found = 302, 64 | kGCDWebServerHTTPStatusCode_SeeOther = 303, 65 | kGCDWebServerHTTPStatusCode_NotModified = 304, 66 | kGCDWebServerHTTPStatusCode_UseProxy = 305, 67 | kGCDWebServerHTTPStatusCode_TemporaryRedirect = 307, 68 | kGCDWebServerHTTPStatusCode_PermanentRedirect = 308 69 | }; 70 | 71 | /** 72 | * Convenience constants for "client error" HTTP status codes. 73 | */ 74 | typedef NS_ENUM(NSInteger, GCDWebServerClientErrorHTTPStatusCode) { 75 | kGCDWebServerHTTPStatusCode_BadRequest = 400, 76 | kGCDWebServerHTTPStatusCode_Unauthorized = 401, 77 | kGCDWebServerHTTPStatusCode_PaymentRequired = 402, 78 | kGCDWebServerHTTPStatusCode_Forbidden = 403, 79 | kGCDWebServerHTTPStatusCode_NotFound = 404, 80 | kGCDWebServerHTTPStatusCode_MethodNotAllowed = 405, 81 | kGCDWebServerHTTPStatusCode_NotAcceptable = 406, 82 | kGCDWebServerHTTPStatusCode_ProxyAuthenticationRequired = 407, 83 | kGCDWebServerHTTPStatusCode_RequestTimeout = 408, 84 | kGCDWebServerHTTPStatusCode_Conflict = 409, 85 | kGCDWebServerHTTPStatusCode_Gone = 410, 86 | kGCDWebServerHTTPStatusCode_LengthRequired = 411, 87 | kGCDWebServerHTTPStatusCode_PreconditionFailed = 412, 88 | kGCDWebServerHTTPStatusCode_RequestEntityTooLarge = 413, 89 | kGCDWebServerHTTPStatusCode_RequestURITooLong = 414, 90 | kGCDWebServerHTTPStatusCode_UnsupportedMediaType = 415, 91 | kGCDWebServerHTTPStatusCode_RequestedRangeNotSatisfiable = 416, 92 | kGCDWebServerHTTPStatusCode_ExpectationFailed = 417, 93 | kGCDWebServerHTTPStatusCode_UnprocessableEntity = 422, 94 | kGCDWebServerHTTPStatusCode_Locked = 423, 95 | kGCDWebServerHTTPStatusCode_FailedDependency = 424, 96 | kGCDWebServerHTTPStatusCode_UpgradeRequired = 426, 97 | kGCDWebServerHTTPStatusCode_PreconditionRequired = 428, 98 | kGCDWebServerHTTPStatusCode_TooManyRequests = 429, 99 | kGCDWebServerHTTPStatusCode_RequestHeaderFieldsTooLarge = 431 100 | }; 101 | 102 | /** 103 | * Convenience constants for "server error" HTTP status codes. 104 | */ 105 | typedef NS_ENUM(NSInteger, GCDWebServerServerErrorHTTPStatusCode) { 106 | kGCDWebServerHTTPStatusCode_InternalServerError = 500, 107 | kGCDWebServerHTTPStatusCode_NotImplemented = 501, 108 | kGCDWebServerHTTPStatusCode_BadGateway = 502, 109 | kGCDWebServerHTTPStatusCode_ServiceUnavailable = 503, 110 | kGCDWebServerHTTPStatusCode_GatewayTimeout = 504, 111 | kGCDWebServerHTTPStatusCode_HTTPVersionNotSupported = 505, 112 | kGCDWebServerHTTPStatusCode_InsufficientStorage = 507, 113 | kGCDWebServerHTTPStatusCode_LoopDetected = 508, 114 | kGCDWebServerHTTPStatusCode_NotExtended = 510, 115 | kGCDWebServerHTTPStatusCode_NetworkAuthenticationRequired = 511 116 | }; 117 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIProgressView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import "AFURLSessionManager.h" 29 | 30 | static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; 31 | static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; 32 | 33 | #pragma mark - 34 | 35 | @implementation UIProgressView (AFNetworking) 36 | 37 | - (BOOL)af_uploadProgressAnimated { 38 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; 39 | } 40 | 41 | - (void)af_setUploadProgressAnimated:(BOOL)animated { 42 | objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 43 | } 44 | 45 | - (BOOL)af_downloadProgressAnimated { 46 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; 47 | } 48 | 49 | - (void)af_setDownloadProgressAnimated:(BOOL)animated { 50 | objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 51 | } 52 | 53 | #pragma mark - 54 | 55 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 56 | animated:(BOOL)animated 57 | { 58 | if (task.state == NSURLSessionTaskStateCompleted) { 59 | return; 60 | } 61 | 62 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 63 | [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 64 | 65 | [self af_setUploadProgressAnimated:animated]; 66 | } 67 | 68 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 69 | animated:(BOOL)animated 70 | { 71 | if (task.state == NSURLSessionTaskStateCompleted) { 72 | return; 73 | } 74 | 75 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 76 | [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 77 | 78 | [self af_setDownloadProgressAnimated:animated]; 79 | } 80 | 81 | #pragma mark - NSKeyValueObserving 82 | 83 | - (void)observeValueForKeyPath:(NSString *)keyPath 84 | ofObject:(id)object 85 | change:(__unused NSDictionary *)change 86 | context:(void *)context 87 | { 88 | if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { 89 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { 90 | if ([object countOfBytesExpectedToSend] > 0) { 91 | dispatch_async(dispatch_get_main_queue(), ^{ 92 | [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; 93 | }); 94 | } 95 | } 96 | 97 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { 98 | if ([object countOfBytesExpectedToReceive] > 0) { 99 | dispatch_async(dispatch_get_main_queue(), ^{ 100 | [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; 101 | }); 102 | } 103 | } 104 | 105 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { 106 | if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { 107 | @try { 108 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; 109 | 110 | if (context == AFTaskCountOfBytesSentContext) { 111 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; 112 | } 113 | 114 | if (context == AFTaskCountOfBytesReceivedContext) { 115 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; 116 | } 117 | } 118 | @catch (NSException * __unused exception) {} 119 | } 120 | } 121 | } 122 | } 123 | 124 | @end 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. 34 | 35 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: 36 | 37 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 38 | 39 | By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. 40 | 41 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 42 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 43 | */ 44 | NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") 45 | @interface AFNetworkActivityIndicatorManager : NSObject 46 | 47 | /** 48 | A Boolean value indicating whether the manager is enabled. 49 | 50 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 51 | */ 52 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 53 | 54 | /** 55 | A Boolean value indicating whether the network activity indicator manager is currently active. 56 | */ 57 | @property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 58 | 59 | /** 60 | A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds. 61 | 62 | Apple's HIG describes the following: 63 | 64 | > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence. 65 | 66 | */ 67 | @property (nonatomic, assign) NSTimeInterval activationDelay; 68 | 69 | /** 70 | A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds. 71 | */ 72 | 73 | @property (nonatomic, assign) NSTimeInterval completionDelay; 74 | 75 | /** 76 | Returns the shared network activity indicator manager object for the system. 77 | 78 | @return The systemwide network activity indicator manager. 79 | */ 80 | + (instancetype)sharedManager; 81 | 82 | /** 83 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 84 | */ 85 | - (void)incrementActivityCount; 86 | 87 | /** 88 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. 89 | */ 90 | - (void)decrementActivityCount; 91 | 92 | /** 93 | Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward. 94 | 95 | @param block A block to be executed when the network activity indicator status changes. 96 | */ 97 | - (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block; 98 | 99 | @end 100 | 101 | NS_ASSUME_NONNULL_END 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /BNM3u8Cache.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint BNM3u8Cache.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "BNM3u8Cache" 19 | s.version = "1.0.2" 20 | s.summary = "a m3u8 downloader" 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = <<-DESC 28 | Implement m3u8 local caching and playback using operation. Can control the number of media concurrency, a single media file download concurrency; Support task suspend restore, support task cancel. 29 | DESC 30 | 31 | s.homepage = "https://github.com/zmubai/BNM3u8Cache" 32 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 33 | 34 | 35 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 36 | # 37 | # Licensing your code is important. See http://choosealicense.com for more info. 38 | # CocoaPods will detect a license file if there is a named LICENSE* 39 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 40 | # 41 | 42 | # s.license = "MIT (example)" 43 | # s.license = { :type => "MIT", :file => "LICENSE" } 44 | s.license = 'MIT' 45 | 46 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 47 | # 48 | # Specify the authors of the library, with email addresses. Email addresses 49 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 50 | # accepts just a name if you'd rather not provide an email address. 51 | # 52 | # Specify a social_media_url where others can refer to, for example a twitter 53 | # profile URL. 54 | # 55 | 56 | s.author = { "zmubai" => "634825162@qq.com" } 57 | # Or just: s.author = "zmubai" 58 | # s.authors = { "zmubai" => "634825162@qq.com" } 59 | # s.social_media_url = "http://twitter.com/zmubai" 60 | 61 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 62 | # 63 | # If this Pod runs only on iOS or OS X, then specify the platform and 64 | # the deployment target. You can optionally include the target after the platform. 65 | # 66 | 67 | # s.platform = :ios 68 | # s.platform = :ios, "8.0" 69 | s.platform = :ios, "9.0" 70 | 71 | # When using multiple platforms 72 | s.ios.deployment_target = "9.0" 73 | # s.osx.deployment_target = "10.7" 74 | # s.watchos.deployment_target = "2.0" 75 | # s.tvos.deployment_target = "9.0" 76 | 77 | 78 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 79 | # 80 | # Specify the location from where the source should be retrieved. 81 | # Supports git, hg, bzr, svn and HTTP. 82 | # 83 | 84 | s.source = { :git => "https://github.com/zmubai/BNM3u8Cache.git", :tag => "#{s.version}" } 85 | 86 | 87 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 88 | # 89 | # CocoaPods is smart about how it includes source code. For source files 90 | # giving a folder will include any swift, h, m, mm, c & cpp files. 91 | # For header files it will include any header in the folder. 92 | # Not including the public_header_files will make all headers public. 93 | # 94 | 95 | s.source_files = "Classes/m3u8/*.{h,m}", "Classes/m3u8/**/*.{h,m}" 96 | # s.exclude_files = "Classes/Exclude" 97 | 98 | s.public_header_files = "Classes/m3u8/*.{h}" 99 | 100 | 101 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 102 | # 103 | # A list of resources included with the Pod. These are copied into the 104 | # target bundle with a build phase script. Anything else will be cleaned. 105 | # You can preserve files from being cleaned, please don't preserve 106 | # non-essential files like tests, examples and documentation. 107 | # 108 | 109 | # s.resource = "icon.png" 110 | # s.resources = "Resources/*.png" 111 | 112 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 113 | 114 | 115 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 116 | # 117 | # Link your library with frameworks, or libraries. Libraries do not include 118 | # the lib prefix of their name. 119 | # 120 | 121 | # s.framework = "SomeFramework" 122 | # s.frameworks = "SomeFramework", "AnotherFramework" 123 | 124 | # s.library = "iconv" 125 | # s.libraries = "iconv", "xml2" 126 | 127 | 128 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 129 | # 130 | # If your library depends on compiler flags you can set them in the xcconfig hash 131 | # where they will only apply to your library. If you depend on other Podspecs 132 | # you can include multiple dependencies to ensure it works. 133 | 134 | s.requires_arc = true 135 | 136 | s.xcconfig = { "HEADER_SEARCH_PATHS" => ["${PODS_ROOT}/AFNetworking/AFNetworking","${PODS_ROOT}/GCDWebServer/GCDWebServer/Core","${SRCRoot}/Classes/m3u8/*"] } 137 | # s.dependency "JSONKit", "~> 1.4" 138 | s.dependency "AFNetworking", "~> 3.0" 139 | s.dependency "GCDWebServer", "~> 3.5.3" 140 | end 141 | --------------------------------------------------------------------------------