Skip to content

Commit 06defbb

Browse files
committed
Various fixes
1 parent 27ae295 commit 06defbb

File tree

3 files changed

+84
-4
lines changed

3 files changed

+84
-4
lines changed

submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,10 @@ public class CameraScreenImpl: ViewController, CameraScreen {
25902590
view.layer.animateScale(from: 1.0, to: 0.1, duration: 0.2)
25912591
transition.setAlpha(view: view, alpha: 0.0)
25922592
}
2593+
if let view = self.componentHost.findTaggedView(tag: collageButtonTag) {
2594+
view.layer.animateScale(from: 1.0, to: 0.1, duration: 0.2)
2595+
transition.setAlpha(view: view, alpha: 0.0)
2596+
}
25932597
if let view = self.componentHost.findTaggedView(tag: zoomControlTag) {
25942598
transition.setAlpha(view: view, alpha: 0.0)
25952599
}
@@ -2680,6 +2684,10 @@ public class CameraScreenImpl: ViewController, CameraScreen {
26802684
view.layer.animateScale(from: 0.1, to: 1.0, duration: 0.2)
26812685
transition.setAlpha(view: view, alpha: 1.0)
26822686
}
2687+
if let view = self.componentHost.findTaggedView(tag: collageButtonTag) {
2688+
view.layer.animateScale(from: 0.1, to: 1.0, duration: 0.2)
2689+
transition.setAlpha(view: view, alpha: 1.0)
2690+
}
26832691
if let view = self.componentHost.findTaggedView(tag: zoomControlTag) {
26842692
view.layer.animateScale(from: 0.1, to: 1.0, duration: 0.2)
26852693
transition.setAlpha(view: view, alpha: 1.0)

submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditorVideoExport.swift

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ public final class MediaEditorVideoExport {
216216
}
217217

218218
var skippingUpdate = false
219+
var initialized = false
219220
}
220221
private var additionalVideoOutput: [Int: VideoOutput] = [:]
221222

@@ -761,10 +762,32 @@ public final class MediaEditorVideoExport {
761762
for i in 0 ..< self.additionalVideoOutput.count {
762763
if let additionalVideoOutput = self.additionalVideoOutput[i] {
763764
if let mainTimestamp, mainTimestamp < additionalVideoOutput.startTime {
764-
765+
if !self.configuration.values.collage.isEmpty && !additionalVideoOutput.initialized {
766+
additionalVideoOutput.initialized = true
767+
if case let .videoOutput(videoOutput) = additionalVideoOutput.output {
768+
if let _ = videoOutput.copyNextSampleBuffer(), let sampleBuffer = videoOutput.copyNextSampleBuffer() {
769+
if let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) {
770+
additionalInput.append(.videoBuffer(VideoPixelBuffer(
771+
pixelBuffer: pixelBuffer,
772+
rotation: additionalVideoOutput.textureRotation,
773+
timestamp: .zero
774+
), additionalVideoOutput.rect))
775+
} else {
776+
additionalInput.append(nil)
777+
}
778+
} else {
779+
additionalInput.append(nil)
780+
}
781+
} else {
782+
additionalInput.append(nil)
783+
}
784+
} else {
785+
additionalInput.append(nil)
786+
}
765787
} else {
766788
if additionalVideoOutput.skippingUpdate {
767789
additionalVideoOutput.skippingUpdate = false
790+
additionalInput.append(nil)
768791
} else {
769792
switch additionalVideoOutput.output {
770793
case let .image(image):
@@ -787,14 +810,18 @@ public final class MediaEditorVideoExport {
787810
self.statusValue = .progress(Float(progress))
788811
updatedProgress = true
789812
}
813+
} else {
814+
additionalInput.append(nil)
790815
}
791816
if let mainComposeFramerate = self.mainComposeFramerate {
792817
let additionalFrameRate = round(additionalVideoOutput.frameRate / 30.0) * 30.0
793818
if Int(mainComposeFramerate) == Int(additionalFrameRate) * 2 {
794819
additionalVideoOutput.skippingUpdate = true
795820
}
796821
}
797-
}
822+
} else {
823+
additionalInput.append(nil)
824+
}
798825
}
799826
}
800827
}

submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7747,8 +7747,53 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID
77477747
let asset = AVURLAsset(url: NSURL(fileURLWithPath: path) as URL)
77487748
exportSubject = .single(.video(asset: asset, isStory: true))
77497749
case let .videoCollage(items):
7750-
let _ = items
7751-
exportSubject = .complete()
7750+
var maxDurationItem: (Double, Subject.VideoCollageItem)?
7751+
for item in items {
7752+
switch item.content {
7753+
case .image:
7754+
break
7755+
case let .video(_, duration):
7756+
if let (maxDuration, _) = maxDurationItem {
7757+
if duration > maxDuration {
7758+
maxDurationItem = (duration, item)
7759+
}
7760+
} else {
7761+
maxDurationItem = (duration, item)
7762+
}
7763+
case let .asset(asset):
7764+
if let (maxDuration, _) = maxDurationItem {
7765+
if asset.duration > maxDuration {
7766+
maxDurationItem = (asset.duration, item)
7767+
}
7768+
} else {
7769+
maxDurationItem = (asset.duration, item)
7770+
}
7771+
}
7772+
}
7773+
guard let (_, mainItem) = maxDurationItem else {
7774+
fatalError()
7775+
}
7776+
let assetSignal: Signal<AVAsset, NoError>
7777+
switch mainItem.content {
7778+
case let .video(path, _):
7779+
assetSignal = .single(AVURLAsset(url: NSURL(fileURLWithPath: path) as URL))
7780+
case let .asset(asset):
7781+
assetSignal = Signal { subscriber in
7782+
PHImageManager.default().requestAVAsset(forVideo: asset, options: nil) { avAsset, _, _ in
7783+
if let avAsset {
7784+
subscriber.putNext(avAsset)
7785+
subscriber.putCompletion()
7786+
}
7787+
}
7788+
return EmptyDisposable
7789+
}
7790+
default:
7791+
fatalError()
7792+
}
7793+
exportSubject = assetSignal
7794+
|> map { asset in
7795+
return .video(asset: asset, isStory: true)
7796+
}
77527797
case let .image(image, _, _, _):
77537798
exportSubject = .single(.image(image: image))
77547799
case let .asset(asset):

0 commit comments

Comments
 (0)