Skip to content

Commit

Permalink
1.8.1 (314)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Sep 12, 2024
1 parent 592fdee commit 2573fe3
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 24 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ jobs:
runs-on: macos-14

steps:
- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_KEY }}

- name: Add SSH known hosts
run: |
ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
- uses: actions/checkout@v2
with:
submodules: 'recursive'
Expand All @@ -31,14 +39,8 @@ jobs:
cp -R $GITHUB_WORKSPACE /Users/telegram/
mv /Users/telegram/$(basename $GITHUB_WORKSPACE) /Users/telegram/telegram-ios
- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_KEY }}

- name: New testflight build
run: |
ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
set -x
mkdir -p $BUILD_WORKING_DIR
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ jobs:
runs-on: macos-14

steps:
- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_KEY }}

- name: Add SSH known hosts
run: |
ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
- uses: actions/checkout@v2
with:
submodules: 'recursive'
Expand All @@ -28,14 +36,8 @@ jobs:
cp -R $GITHUB_WORKSPACE /Users/telegram/
mv /Users/telegram/$(basename $GITHUB_WORKSPACE) /Users/telegram/telegram-ios
- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_KEY }}

- name: New testflight build
run: |
ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
set -x
mkdir -p $BUILD_WORKING_DIR
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
url = https://github.com/telegramdesktop/libtgvoip.git
[submodule "submodules/TgVoipWebrtc/tgcalls"]
path = submodules/TgVoipWebrtc/tgcalls
url = https://github.com/TelegramMessenger/tgcalls.git
url = git@bitbucket.org:mobyrix/tgcalls.git
[submodule "third-party/libvpx/libvpx"]
path = third-party/libvpx/libvpx
url = https://github.com/webmproject/libvpx.git
Expand All @@ -26,7 +26,7 @@
# Perhaps the crash is related to the minimum version of iOS (we have iOS 14, telegram has iOS 12).
[submodule "third-party/webrtc/webrtc"]
path = third-party/webrtc/webrtc
url = https://github.com/denis15yo/webrtc.git
url = https://github.com/nicegram/webrtc.git
[submodule "third-party/libx264/x264"]
path = third-party/libx264/x264
url = https://github.com/mirror/x264.git
Expand Down
16 changes: 8 additions & 8 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions submodules/TelegramCallsUI/Sources/PresentationCall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ public final class PresentationCallImpl: PresentationCall {
self.audioSessionShouldBeActive.set(true)
}
case let .active(id, key, _, connections, maxLayer, version, customParameters, allowsP2P):
// MARK: Nicegram NCG-5828 call recording
self.sharedAudioDevice?.startNicegramRecording()
//
self.audioSessionShouldBeActive.set(true)
if let _ = audioSessionControl, !wasActive || previousControl == nil {
let logName = "\(id.id)_\(id.accessHash)"
Expand Down Expand Up @@ -627,6 +630,11 @@ public final class PresentationCallImpl: PresentationCall {
}
}
case let .terminated(_, _, options):
// MARK: Nicegram NCG-5828 call recording
self.sharedAudioDevice?.stopNicegramRecording { [weak self] path, duration, data in
self?.saveCall(with: path, duration: duration, data: data)
}
//
self.audioSessionShouldBeActive.set(true)
if wasActive {
let debugLogValue = Promise<String?>()
Expand Down Expand Up @@ -1068,4 +1076,59 @@ public final class PresentationCallImpl: PresentationCall {
self.useFrontCamera = !self.useFrontCamera
self.videoCapturer?.switchVideoInput(isFront: self.useFrontCamera)
}

// MARK: Nicegram NCG-5828 call recording
private func saveCall(with path: String, duration: Double, data: Data) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd_HH:mm:ss"

let date = Date()

let peerId = self.context.account.peerId

let id = Int64.random(in: 0 ... Int64.max)
let resource = LocalFileReferenceMediaResource(
localFilePath: path,
randomId: id
)

let file = TelegramMediaFile(
fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id),
partialReference: nil,
resource: resource,
previewRepresentations: [],
videoThumbnails: [],
immediateThumbnailData: nil,
mimeType: "audio/ogg", //if change to this mime type audio show as voice file
// mimeType: "audio/wav", if change to this mime type audio show as audio file
size: nil,
attributes: [.Audio(
isVoice: true,
duration: Int(duration),
title: dateFormatter.string(from: date),
performer: nil,
waveform: data)
]
)

let message: EnqueueMessage = .message(
text: "",
attributes: [],
inlineStickers: [:],
mediaReference: .standalone(media: file),
threadId: nil,
replyToMessageId: nil,
replyToStoryId: nil,
localGroupingKey: nil,
correlationId: nil,
bubbleUpEmojiOrStickersets: []
)

let _ = enqueueMessages(
account: context.account,
peerId: peerId,
messages: [message]
).start()
}
//
}
18 changes: 18 additions & 0 deletions submodules/TelegramVoip/Sources/OngoingCallContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,24 @@ public final class OngoingCallContext {
CallAudioTone(samples: tone.samples, sampleRate: tone.sampleRate, loopCount: tone.loopCount)
})
}

// MARK: Nicegram NCG-5828 call recording
public func initNicegramCallRecording(path: String) {
self.impl.initNicegramCallRecording(path)
}

public func startNicegramRecording() {
self.impl.startNicegramRecording()
}

public func stopNicegramRecording(callback: ((String, Double, Data) -> Void)?) {
self.impl.stopNicegramRecording(callback)
}

public func setRecordOutputFolder(path: String) {
self.impl.setRecordOutputFolder(path)
}
//
}

public static func setupAudioSession() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@

- (void)setTone:(CallAudioTone * _Nullable)tone;

// MARK: Nicegram NCG-5828 call recording
-(void)InitNicegramCallRecording:(NSString* _Nonnull)path;
-(void)StartNicegramRecording;
-(void)StopNicegramRecording:(void(^_Nullable)(NSString* _Nonnull, double, NSData* _Nonnull))completion;
-(void)SetRecordOutputFolder:(NSString* _Nonnull)path;
//
@end

@interface OngoingCallConnectionDescriptionWebrtc : NSObject
Expand Down
45 changes: 45 additions & 0 deletions submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ virtual void start() override {
_audioDeviceModule->InternalStartPlayout();
}
//_audioDeviceModule->InternalStartRecording();
// MARK: Nicegram NCG-5828 call recording
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* path = [NSString stringWithFormat:@"%@/%@",
documentsDirectory,
@"nicegram_saved_calls"
];
_audioDeviceModule->InitNicegramCallRecording([path cStringUsingEncoding: NSUTF8StringEncoding]);
//
}
}

Expand Down Expand Up @@ -149,6 +158,42 @@ - (void)setTone:(CallAudioTone * _Nullable)tone {
});
}

// MARK: Nicegram NCG-5828 call recording
-(void)InitNicegramCallRecording:(NSString* _Nonnull)path {
_audioDeviceModule->perform([path](tgcalls::SharedAudioDeviceModule *audioDeviceModule) {
const char *utfPath = [path UTF8String];
audioDeviceModule->audioDeviceModule()->InitNicegramCallRecording(utfPath);
});
}

-(void)StartNicegramRecording {
_audioDeviceModule->perform([](tgcalls::SharedAudioDeviceModule *audioDeviceModule) {
audioDeviceModule->audioDeviceModule()->StartNicegramRecording();
});
}

-(void)StopNicegramRecording:(void(^_Nullable)(NSString* _Nonnull, double, NSData* _Nonnull))completion {
_audioDeviceModule->perform([completion](tgcalls::SharedAudioDeviceModule *audioDeviceModule) {
audioDeviceModule->audioDeviceModule()->StopNicegramRecording([completion](const std::string& outputFilePath,
double durationInSeconds,
std::vector<int16_t> rawData) {
NSString *path = [NSString stringWithUTF8String: outputFilePath.c_str()];
NSData *data = [NSData dataWithBytes: rawData.data() length: sizeof(rawData)];
if (completion != NULL) {
completion(path, durationInSeconds, data);
}
});
});
}

-(void)SetRecordOutputFolder:(NSString* _Nonnull)path {
_audioDeviceModule->perform([path](tgcalls::SharedAudioDeviceModule *audioDeviceModule) {
const char *utfPath = [path UTF8String];
audioDeviceModule->audioDeviceModule()->SetRecordOutputFolder(utfPath);
});
}
//

- (std::shared_ptr<tgcalls::ThreadLocalObject<tgcalls::SharedAudioDeviceModule>>)getAudioDeviceModule {
return _audioDeviceModule;
}
Expand Down
2 changes: 1 addition & 1 deletion submodules/TgVoipWebrtc/tgcalls
Submodule tgcalls updated from 8344f8 to c879c0

0 comments on commit 2573fe3

Please sign in to comment.