Skip to content

Commit 8402c3d

Browse files
committed
Merge branches 'master' and 'master' of gitlab.com:peter-iakovlev/telegram-ios
2 parents 490d0f8 + 6783239 commit 8402c3d

24 files changed

+1509
-98
lines changed

submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegAVFormatContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern int FFMpegCodecIdH264;
2828
extern int FFMpegCodecIdHEVC;
2929
extern int FFMpegCodecIdMPEG4;
3030
extern int FFMpegCodecIdVP9;
31+
extern int FFMpegCodecIdAV1;
3132

3233
@class FFMpegAVCodecContext;
3334

submodules/FFMpegBinding/Sources/FFMpegAVFormatContext.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
int FFMpegCodecIdHEVC = AV_CODEC_ID_HEVC;
1212
int FFMpegCodecIdMPEG4 = AV_CODEC_ID_MPEG4;
1313
int FFMpegCodecIdVP9 = AV_CODEC_ID_VP9;
14+
int FFMpegCodecIdAV1 = AV_CODEC_ID_AV1;
1415

1516
@interface FFMpegAVFormatContext () {
1617
AVFormatContext *_impl;

submodules/GalleryUI/Sources/GalleryControllerNode.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ open class GalleryControllerNode: ASDisplayNode, ASScrollViewDelegate, ASGesture
488488
return
489489
}
490490

491+
if distanceFromEquilibrium < -1.0, let centralItemNode = self.pager.centralItemNode(), centralItemNode.maybePerformActionForSwipeDownDismiss() {
492+
}
493+
491494
if let backgroundColor = self.backgroundNode.backgroundColor {
492495
self.backgroundNode.layer.animate(from: backgroundColor, to: UIColor(white: 0.0, alpha: 0.0).cgColor, keyPath: "backgroundColor", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: 0.2, removeOnCompletion: false)
493496
}

submodules/GalleryUI/Sources/GalleryItemNode.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ open class GalleryItemNode: ASDisplayNode {
109109
return false
110110
}
111111

112+
open func maybePerformActionForSwipeDownDismiss() -> Bool {
113+
return false
114+
}
115+
112116
open func contentSize() -> CGSize? {
113117
return nil
114118
}

submodules/GalleryUI/Sources/GalleryRateToastComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ final class GalleryRateToastComponent: Component {
177177
content: LottieComponent.AppBundleContent(name: "video_toast_speedup"),
178178
color: .white,
179179
startingPosition: .begin,
180-
loop: true
180+
loop: false
181181
)),
182182
environment: {},
183183
containerSize: CGSize(width: 60.0, height: 60.0)

submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
17831783
if let item = strongSelf.item, let _ = item.content as? PlatformVideoContent {
17841784
strongSelf.videoNode?.play()
17851785
} else {
1786-
strongSelf.videoNode?.playOnceWithSound(playAndRecord: false, actionAtEnd: isAnimated ? .loop : strongSelf.actionAtEnd)
1786+
strongSelf.videoNode?.playOnceWithSound(playAndRecord: false, seek: .none, actionAtEnd: isAnimated ? .loop : strongSelf.actionAtEnd)
17871787
}
17881788

17891789
if let playbackRate = strongSelf.playbackRate {
@@ -1837,7 +1837,14 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
18371837
return
18381838
}
18391839

1840-
if let status = status, status.duration >= 60.0 * 10.0 {
1840+
if let status = status {
1841+
let shouldStorePlaybacksState: Bool
1842+
#if DEBUG
1843+
shouldStorePlaybacksState = status.duration >= 10.0
1844+
#else
1845+
shouldStorePlaybacksState = status.duration >= 60.0 * 10.0
1846+
#endif
1847+
18411848
var timestamp: Double?
18421849
if status.timestamp > 5.0 && status.timestamp < status.duration - 5.0 {
18431850
timestamp = status.timestamp
@@ -2763,19 +2770,32 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
27632770
}
27642771

27652772
override func maybePerformActionForSwipeDismiss() -> Bool {
2766-
if let data = self.context.currentAppConfiguration.with({ $0 }).data, let _ = data["ios_killswitch_disable_swipe_pip"] {
2767-
return false
2773+
if let data = self.context.currentAppConfiguration.with({ $0 }).data {
2774+
if let _ = data["ios_killswitch_disable_swipe_pip"] {
2775+
return false
2776+
}
2777+
if let value = data["video_swipe_up_to_close"] as? Double, value == 1.0 {
2778+
addAppLogEvent(postbox: self.context.account.postbox, type: "swipe_up_close", peerId: self.context.account.peerId)
2779+
2780+
return false
2781+
}
27682782
}
27692783

27702784
if #available(iOS 15.0, *) {
27712785
if let nativePictureInPictureContent = self.nativePictureInPictureContent as? NativePictureInPictureContentImpl {
2786+
addAppLogEvent(postbox: self.context.account.postbox, type: "swipe_up_pip", peerId: self.context.account.peerId)
27722787
nativePictureInPictureContent.beginPictureInPicture()
27732788
return true
27742789
}
27752790
}
27762791
return false
27772792
}
27782793

2794+
override func maybePerformActionForSwipeDownDismiss() -> Bool {
2795+
addAppLogEvent(postbox: self.context.account.postbox, type: "swipe_down_close", peerId: self.context.account.peerId)
2796+
return false
2797+
}
2798+
27792799
override func title() -> Signal<String, NoError> {
27802800
return self._title.get()
27812801
}
@@ -2981,6 +3001,8 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
29813001
if !didExpand {
29823002
self.activePictureInPictureController = nil
29833003
self.activePictureInPictureNavigationController = nil
3004+
3005+
addAppLogEvent(postbox: self.context.account.postbox, type: "pip_close_btn", peerId: self.context.account.peerId)
29843006
}
29853007
}, expand: { [weak self] completion in
29863008
didExpand = true
@@ -3013,6 +3035,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
30133035
@objc func pictureInPictureButtonPressed() {
30143036
if #available(iOS 15.0, *) {
30153037
if let nativePictureInPictureContent = self.nativePictureInPictureContent as? NativePictureInPictureContentImpl {
3038+
addAppLogEvent(postbox: self.context.account.postbox, type: "pip_btn", peerId: self.context.account.peerId)
30163039
nativePictureInPictureContent.beginPictureInPicture()
30173040
return
30183041
}

submodules/MediaPlayer/Sources/ChunkMediaPlayer.swift

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,18 @@ public final class ChunkMediaPlayerPart {
120120
public let endTime: Double
121121
public let file: TempBoxFile
122122
public let clippedStartTime: Double?
123+
public let codecName: String?
123124

124125
public var id: Id {
125126
return Id(rawValue: self.file.path)
126127
}
127128

128-
public init(startTime: Double, clippedStartTime: Double? = nil, endTime: Double, file: TempBoxFile) {
129+
public init(startTime: Double, clippedStartTime: Double? = nil, endTime: Double, file: TempBoxFile, codecName: String?) {
129130
self.startTime = startTime
130131
self.clippedStartTime = clippedStartTime
131132
self.endTime = endTime
132133
self.file = file
134+
self.codecName = codecName
133135
}
134136
}
135137

@@ -666,7 +668,8 @@ private final class ChunkMediaPlayerContext {
666668
startTime: part.startTime,
667669
clippedStartTime: partStartTime == part.startTime ? nil : partStartTime,
668670
endTime: part.endTime,
669-
file: part.file
671+
file: part.file,
672+
codecName: part.codecName
670673
))
671674
minStartTime = max(minStartTime, partEndTime)
672675
}
@@ -687,7 +690,8 @@ private final class ChunkMediaPlayerContext {
687690
startTime: part.startTime,
688691
clippedStartTime: partStartTime == part.startTime ? nil : partStartTime,
689692
endTime: part.endTime,
690-
file: part.file
693+
file: part.file,
694+
codecName: part.codecName
691695
))
692696
minStartTime = max(minStartTime, partEndTime)
693697
break
@@ -1040,7 +1044,26 @@ private final class ChunkMediaPlayerContext {
10401044
}
10411045
}
10421046

1043-
public final class ChunkMediaPlayer {
1047+
public protocol ChunkMediaPlayer: AnyObject {
1048+
var status: Signal<MediaPlayerStatus, NoError> { get }
1049+
var audioLevelEvents: Signal<Float, NoError> { get }
1050+
var actionAtEnd: ChunkMediaPlayerActionAtEnd { get set }
1051+
1052+
func play()
1053+
func playOnceWithSound(playAndRecord: Bool, seek: MediaPlayerSeek)
1054+
func setSoundMuted(soundMuted: Bool)
1055+
func continueWithOverridingAmbientMode(isAmbient: Bool)
1056+
func continuePlayingWithoutSound(seek: MediaPlayerSeek)
1057+
func setContinuePlayingWithoutSoundOnLostAudioSession(_ value: Bool)
1058+
func setForceAudioToSpeaker(_ value: Bool)
1059+
func setKeepAudioSessionWhilePaused(_ value: Bool)
1060+
func pause()
1061+
func togglePlayPause(faded: Bool)
1062+
func seek(timestamp: Double, play: Bool?)
1063+
func setBaseRate(_ baseRate: Double)
1064+
}
1065+
1066+
public final class ChunkMediaPlayerImpl: ChunkMediaPlayer {
10441067
private let queue = Queue()
10451068
private var contextRef: Unmanaged<ChunkMediaPlayerContext>?
10461069

@@ -1081,7 +1104,8 @@ public final class ChunkMediaPlayer {
10811104
keepAudioSessionWhilePaused: Bool = false,
10821105
continuePlayingWithoutSoundOnLostAudioSession: Bool = false,
10831106
isAudioVideoMessage: Bool = false,
1084-
onSeeked: (() -> Void)? = nil
1107+
onSeeked: (() -> Void)? = nil,
1108+
playerNode: MediaPlayerNode
10851109
) {
10861110
let audioLevelPipe = self.audioLevelPipe
10871111
self.queue.async {
@@ -1109,6 +1133,8 @@ public final class ChunkMediaPlayer {
11091133
)
11101134
self.contextRef = Unmanaged.passRetained(context)
11111135
}
1136+
1137+
self.attachPlayerNode(playerNode)
11121138
}
11131139

11141140
deinit {
@@ -1126,7 +1152,7 @@ public final class ChunkMediaPlayer {
11261152
}
11271153
}
11281154

1129-
public func playOnceWithSound(playAndRecord: Bool, seek: MediaPlayerSeek = .start) {
1155+
public func playOnceWithSound(playAndRecord: Bool, seek: MediaPlayerSeek) {
11301156
self.queue.async {
11311157
if let context = self.contextRef?.takeUnretainedValue() {
11321158
context.playOnceWithSound(playAndRecord: playAndRecord, seek: seek)
@@ -1150,7 +1176,7 @@ public final class ChunkMediaPlayer {
11501176
}
11511177
}
11521178

1153-
public func continuePlayingWithoutSound(seek: MediaPlayerSeek = .start) {
1179+
public func continuePlayingWithoutSound(seek: MediaPlayerSeek) {
11541180
self.queue.async {
11551181
if let context = self.contextRef?.takeUnretainedValue() {
11561182
context.continuePlayingWithoutSound(seek: seek)
@@ -1190,15 +1216,15 @@ public final class ChunkMediaPlayer {
11901216
}
11911217
}
11921218

1193-
public func togglePlayPause(faded: Bool = false) {
1219+
public func togglePlayPause(faded: Bool) {
11941220
self.queue.async {
11951221
if let context = self.contextRef?.takeUnretainedValue() {
11961222
context.togglePlayPause(faded: faded)
11971223
}
11981224
}
11991225
}
12001226

1201-
public func seek(timestamp: Double, play: Bool? = nil) {
1227+
public func seek(timestamp: Double, play: Bool?) {
12021228
self.queue.async {
12031229
if let context = self.contextRef?.takeUnretainedValue() {
12041230
if let play {

0 commit comments

Comments
 (0)