Skip to content

NCG-5940: added interface for call recording #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: M123
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions modules/audio_device/audio_device_generic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,15 @@ int AudioDeviceGeneric::GetRecordAudioParameters(
}
#endif // WEBRTC_IOS

// MARK: Nicegram NCG-5828 call recording

void AudioDeviceGeneric::StartNicegramRecording(const CompletionRecorderCallback& callback, const RecorderErrorCallback &errorCallback) {
RTC_LOG_F(LS_ERROR) << "Not supported on this platform";
}

void AudioDeviceGeneric::StopNicegramRecording(bool synchronous) {
RTC_LOG_F(LS_ERROR) << "Not supported on this platform";
}
//

} // namespace webrtc
12 changes: 12 additions & 0 deletions modules/audio_device/audio_device_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ namespace webrtc {

class AudioDeviceGeneric {
public:
// MARK: Nicegram NCG-5828 call recording
using CompletionRecorderCallback = std::function<void(const std::string& outputFilePath,
double durationInSeconds,
size_t rawDataSize)>;

using RecorderErrorCallback = std::function<void(const std::string& error)>;
//
// For use with UMA logging. Must be kept in sync with histograms.xml in
// Chrome, located at
// https://cs.chromium.org/chromium/src/tools/metrics/histograms/histograms.xml
Expand Down Expand Up @@ -135,6 +142,11 @@ class AudioDeviceGeneric {
virtual int GetRecordAudioParameters(AudioParameters* params) const;
#endif // WEBRTC_IOS

// MARK: Nicegram NCG-5828 call recording
virtual void StartNicegramRecording(const CompletionRecorderCallback& callback, const RecorderErrorCallback &errorCallback);
virtual void StopNicegramRecording(bool synchronous = false);
//

virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) = 0;

virtual ~AudioDeviceGeneric() {}
Expand Down
12 changes: 12 additions & 0 deletions modules/audio_device/include/audio_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class AudioDeviceModuleForTest;

class AudioDeviceModule : public webrtc::RefCountInterface {
public:
// MARK: Nicegram NCG-5828 call recording
using CompletionRecorderCallback = std::function<void(const std::string& outputFilePath,
double durationInSeconds,
size_t rawDataSize)>;

using RecorderErrorCallback = std::function<void(const std::string& error)>;
//
enum AudioLayer {
kPlatformDefaultAudio = 0,
kWindowsCoreAudio,
Expand Down Expand Up @@ -171,6 +178,11 @@ class AudioDeviceModule : public webrtc::RefCountInterface {
virtual int GetRecordAudioParameters(AudioParameters* params) const = 0;
#endif // WEBRTC_IOS

// MARK: Nicegram NCG-5828 call recording
virtual void StartNicegramRecording(const CompletionRecorderCallback& callback, const RecorderErrorCallback &errorCallback) {}
virtual void StopNicegramRecording(bool synchronous = false) {}
//

protected:
~AudioDeviceModule() override {}
};
Expand Down
2 changes: 1 addition & 1 deletion modules/video_coding/codecs/h264/h264.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bool H264Encoder::SupportsScalabilityMode(ScalabilityMode scalability_mode) {

std::unique_ptr<H264Decoder> H264Decoder::Create() {
RTC_DCHECK(H264Decoder::IsSupported());
#if defined(WEBRTC_USE_H264)
#if defined(WEBRTC_USE_H264) && defined(WEBRTC_USE_H264_DECODER)
RTC_CHECK(g_rtc_use_h264);
RTC_LOG(LS_INFO) << "Creating H264DecoderImpl.";
return std::make_unique<H264DecoderImpl>();
Expand Down
2 changes: 2 additions & 0 deletions modules/video_coding/codecs/h264/h264_decoder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// build with H264 support, please do not move anything out of the
// #ifdef unless needed and tested.
#ifdef WEBRTC_USE_H264
#ifdef WEBRTC_USE_H264_DECODER

#include "modules/video_coding/codecs/h264/h264_decoder_impl.h"

Expand Down Expand Up @@ -658,4 +659,5 @@ void H264DecoderImpl::ReportError() {

} // namespace webrtc

#endif // WEBRTC_USE_H264_DECODER
#endif // WEBRTC_USE_H264
2 changes: 2 additions & 0 deletions modules/video_coding/codecs/h264/h264_decoder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// build with H264 support, please do not move anything out of the
// #ifdef unless needed and tested.
#ifdef WEBRTC_USE_H264
#ifdef WEBRTC_USE_H264_DECODER

#if defined(WEBRTC_WIN) && !defined(__clang__)
#error "See: bugs.webrtc.org/9213#c13."
Expand Down Expand Up @@ -104,6 +105,7 @@ class H264DecoderImpl : public H264Decoder {

} // namespace webrtc

#endif // WEBRTC_USE_H264_DECODER
#endif // WEBRTC_USE_H264

#endif // MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_
9 changes: 6 additions & 3 deletions p2p/base/ice_transport_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ RTCError VerifyCandidate(const Candidate& cand) {
return RTCError::OK();
}
if (port < 1024) {
if ((port != 80) && (port != 443)) {
return RTCError(RTCErrorType::INVALID_PARAMETER,
"candidate has port below 1024, but not 80 or 443");
if (absl::EndsWith(cand.address().hostname(), ".reflector")) {
} else {
if ((port != 80) && (port != 443)) {
return RTCError(RTCErrorType::INVALID_PARAMETER,
"candidate has port below 1024, but not 80 or 443");
}
}

if (cand.address().IsPrivateIP()) {
Expand Down
50 changes: 21 additions & 29 deletions sdk/objc/components/network/RTCNetworkMonitor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

#import "RTCNetworkMonitor+Private.h"

#import <Network/Network.h>

#import "base/RTCLogging.h"
#import "helpers/RTCDispatcher+Private.h"

#include "rtc_base/string_utils.h"

namespace {

rtc::AdapterType AdapterTypeFromInterfaceType(nw_interface_type_t interfaceType) {
rtc::AdapterType AdapterTypeFromInterfaceType(
nw_interface_type_t interfaceType) {
rtc::AdapterType adapterType = rtc::ADAPTER_TYPE_UNKNOWN;
switch (interfaceType) {
case nw_interface_type_other:
Expand All @@ -43,18 +38,16 @@
}
return adapterType;
}

} // namespace

@implementation RTCNetworkMonitor {
webrtc::NetworkMonitorObserver *_observer;
nw_path_monitor_t _pathMonitor;
dispatch_queue_t _monitorQueue;
}

- (instancetype)initWithObserver:(webrtc::NetworkMonitorObserver *)observer {
RTC_DCHECK(observer);
if (self = [super init]) {
self = [super init];
if (self) {
_observer = observer;
if (@available(iOS 12, *)) {
_pathMonitor = nw_path_monitor_create();
Expand All @@ -65,10 +58,10 @@ - (instancetype)initWithObserver:(webrtc::NetworkMonitorObserver *)observer {
RTCLog(@"NW path monitor created.");
__weak RTCNetworkMonitor *weakSelf = self;
nw_path_monitor_set_update_handler(_pathMonitor, ^(nw_path_t path) {
if (weakSelf == nil) {
RTCNetworkMonitor *strongSelf = weakSelf;
if (strongSelf == nil) {
return;
}
RTCNetworkMonitor *strongSelf = weakSelf;
RTCLog(@"NW path monitor: updated.");
nw_path_status_t status = nw_path_get_status(path);
if (status == nw_path_status_invalid) {
Expand All @@ -80,33 +73,34 @@ - (instancetype)initWithObserver:(webrtc::NetworkMonitorObserver *)observer {
} else if (status == nw_path_status_satisfiable) {
RTCLog(@"NW path monitor status: satisfiable.");
}
std::map<std::string, rtc::AdapterType, rtc::AbslStringViewCmp> *map =
new std::map<std::string, rtc::AdapterType, rtc::AbslStringViewCmp>();
nw_path_enumerate_interfaces(
path, (nw_path_enumerate_interfaces_block_t) ^ (nw_interface_t interface) {
const char *name = nw_interface_get_name(interface);
nw_interface_type_t interfaceType = nw_interface_get_type(interface);
RTCLog(@"NW path monitor available interface: %s", name);
rtc::AdapterType adapterType = AdapterTypeFromInterfaceType(interfaceType);
map->insert(std::pair<std::string, rtc::AdapterType>(name, adapterType));
});
std::map<std::string, rtc::AdapterType, rtc::AbslStringViewCmp>
owned_map;
auto map = &owned_map; // Capture raw pointer for Objective-C block
nw_path_enumerate_interfaces(path, ^(nw_interface_t interface) {
const char *name = nw_interface_get_name(interface);
nw_interface_type_t interfaceType = nw_interface_get_type(interface);
RTCLog(@"NW path monitor available interface: %s", name);
rtc::AdapterType adapterType =
AdapterTypeFromInterfaceType(interfaceType);
map->emplace(name, adapterType);
return true;
});
@synchronized(strongSelf) {
webrtc::NetworkMonitorObserver *observer = strongSelf->_observer;
if (observer) {
observer->OnPathUpdate(std::move(*map));
observer->OnPathUpdate(std::move(owned_map));
}
}
delete map;
});
nw_path_monitor_set_queue(
_pathMonitor,
[RTC_OBJC_TYPE(RTCDispatcher) dispatchQueueForType:RTCDispatcherTypeNetworkMonitor]);
[RTC_OBJC_TYPE(RTCDispatcher)
dispatchQueueForType:RTCDispatcherTypeNetworkMonitor]);
nw_path_monitor_start(_pathMonitor);
}
}
return self;
}

- (void)cancel {
if (@available(iOS 12, *)) {
nw_path_monitor_cancel(_pathMonitor);
Expand All @@ -118,9 +112,7 @@ - (void)stop {
_observer = nil;
}
}

- (void)dealloc {
[self cancel];
}

@end
2 changes: 1 addition & 1 deletion video/rtp_video_stream_receiver2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
}

// Only construct the encrypted receiver if frame encryption is enabled.
if (config_.crypto_options.sframe.require_frame_encryption) {
if (config_.crypto_options.sframe.require_frame_encryption || frame_decryptor) {
buffered_frame_decryptor_ =
std::make_unique<BufferedFrameDecryptor>(this, this, field_trials_);
if (frame_decryptor != nullptr) {
Expand Down