WIP - send all video types

This commit is contained in:
Michael Kirk 2017-12-11 13:51:36 -05:00
parent 4ce2eb3c6c
commit 90e9b4a4f2
7 changed files with 68 additions and 15 deletions

View File

@ -291,6 +291,7 @@
45CB2FA81CB7146C00E1B343 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 45CB2FA71CB7146C00E1B343 /* Launch Screen.storyboard */; };
45CD81EF1DC030E7004C9430 /* SyncPushTokensJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CD81EE1DC030E7004C9430 /* SyncPushTokensJob.swift */; };
45D231771DC7E8F10034FA89 /* SessionResetJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D231761DC7E8F10034FA89 /* SessionResetJob.swift */; };
45D55A231FDF08C6003767F0 /* NSItemProvider+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 45D55A221FDF08C6003767F0 /* NSItemProvider+OWS.m */; };
45DF5DF21DDB843F00C936C7 /* CompareSafetyNumbersActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DF5DF11DDB843F00C936C7 /* CompareSafetyNumbersActivity.swift */; };
45E547201FD755E700DFC09E /* AttachmentApprovalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45E5471F1FD755E700DFC09E /* AttachmentApprovalViewController.swift */; };
45E5A6991F61E6DE001E4A8A /* MarqueeLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45E5A6981F61E6DD001E4A8A /* MarqueeLabel.swift */; };
@ -823,6 +824,8 @@
45CB2FA71CB7146C00E1B343 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = "Launch Screen.storyboard"; path = "Signal/src/util/Launch Screen.storyboard"; sourceTree = SOURCE_ROOT; };
45CD81EE1DC030E7004C9430 /* SyncPushTokensJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SyncPushTokensJob.swift; sourceTree = "<group>"; };
45D231761DC7E8F10034FA89 /* SessionResetJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionResetJob.swift; sourceTree = "<group>"; };
45D55A211FDF08C6003767F0 /* NSItemProvider+OWS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSItemProvider+OWS.h"; sourceTree = "<group>"; };
45D55A221FDF08C6003767F0 /* NSItemProvider+OWS.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSItemProvider+OWS.m"; sourceTree = "<group>"; };
45DF5DF11DDB843F00C936C7 /* CompareSafetyNumbersActivity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompareSafetyNumbersActivity.swift; sourceTree = "<group>"; };
45E282DE1D08E67800ADD4C8 /* gl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = gl; path = translations/gl.lproj/Localizable.strings; sourceTree = "<group>"; };
45E282DF1D08E6CC00ADD4C8 /* id */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = id; path = translations/id.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -1074,6 +1077,8 @@
children = (
34480B341FD0929200BC14EF /* ShareAppExtensionContext.h */,
34480B351FD0929200BC14EF /* ShareAppExtensionContext.m */,
45D55A211FDF08C6003767F0 /* NSItemProvider+OWS.h */,
45D55A221FDF08C6003767F0 /* NSItemProvider+OWS.m */,
);
path = utils;
sourceTree = "<group>";
@ -2714,6 +2719,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
45D55A231FDF08C6003767F0 /* NSItemProvider+OWS.m in Sources */,
4535186B1FC635DD00210559 /* ShareViewController.swift in Sources */,
34480B361FD0929200BC14EF /* ShareAppExtensionContext.m in Sources */,
3461284B1FD0B94000532771 /* SAELoadViewController.swift in Sources */,

View File

@ -464,11 +464,21 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
@objc
public func playVideo() {
guard let dataUrl = attachment.dataUrl else {
owsFail("\(self.logTag) attachment is missing dataUrl")
return
}
let filePath = dataUrl.path
guard FileManager.default.fileExists(atPath: filePath) else {
owsFail("\(self.logTag) file at \(filePath) doesn't exist")
return
}
guard let videoPlayer = MPMoviePlayerController(contentURL: dataUrl) else {
owsFail("\(self.logTag) unable to build moview player controller")
return
}
videoPlayer.prepareToPlay()
NotificationCenter.default.addObserver(forName: .MPMoviePlayerWillExitFullscreen, object: nil, queue: nil) { [weak self] _ in

View File

@ -240,7 +240,13 @@ public class SignalAttachment: NSObject {
}
do {
let asset = AVURLAsset(url:mediaUrl)
let filePath = mediaUrl.path
guard FileManager.default.fileExists(atPath: filePath) else {
owsFail("asset at \(filePath) doesn't exist")
return nil
}
let asset = AVURLAsset(url: mediaUrl)
let generator = AVAssetImageGenerator(asset: asset)
generator.appliesPreferredTrackTransform = true
let cgImage = try generator.copyCGImage(at: CMTimeMake(0, 1), actualTime: nil)
@ -784,9 +790,9 @@ public class SignalAttachment: NSObject {
if !isInputVideoValidOutputVideo(dataSource: dataSource, dataUTI: dataUTI) {
// Most people won't hit this because we convert video when picked from the media picker
// But the current API allos sending videos that some Signal clients will not
// But the current API allows sending videos that some Signal clients will not
// be able to view. (e.g. when picked from document picker)
owsFail("building video with invalid output, migrate to async API using compressVideoAsMp4")
// owsFail("building video with invalid output, migrate to async API using compressVideoAsMp4")
}
return newAttachment(dataSource: dataSource,

View File

@ -488,6 +488,8 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
return promise
}
// DO NOT COMMIT
// specificUTIType = "com.apple.quicktime-movie"
let attachment = SignalAttachment.attachment(dataSource: dataSource, dataUTI: specificUTIType)
return Promise(value: attachment)
}

View File

@ -6,19 +6,20 @@
#import <UIKit/UIKit.h>
// Separate iOS Frameworks from other imports.
#import "DebugLogger.h"
#import "Environment.h"
#import "OWSContactsManager.h"
#import "OWSContactsSyncing.h"
#import "OWSLogger.h"
#import "OWSMath.h"
#import "OWSPreferences.h"
#import "Release.h"
#import "NSItemProvider+OWS.h"
#import "ShareAppExtensionContext.h"
#import "UIColor+OWS.h"
#import "UIFont+OWS.h"
#import "UIView+OWS.h"
#import "VersionMigrations.h"
#import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSContactsManager.h>
#import <SignalMessaging/OWSContactsSyncing.h>
#import <SignalMessaging/OWSLogger.h>
#import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSPreferences.h>
#import <SignalMessaging/Release.h>
#import <SignalMessaging/UIColor+OWS.h>
#import <SignalMessaging/UIFont+OWS.h>
#import <SignalMessaging/UIView+OWS.h>
#import <SignalMessaging/VersionMigrations.h>
#import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/AppVersion.h>
#import <SignalServiceKit/Asserts.h>

View File

@ -0,0 +1,11 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
typedef void (^OWSItemProviderDataCompletionHandler)(NSData *_Nullable data, NSError *_Nullable error);
@implementation NSItemProvider (OWS)
- (void)loadItemForTypeIdentifier:(NSString *)typeIdentifier options:(nullable NSDictionary *)options dataCompletionHandler:(nullable OWSItemProviderDataCompletionHandler)completionHandler;
@end

View File

@ -0,0 +1,17 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "NSItemProvider+OWS.h"
@implementation NSItemProvider (OWS)
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end