Skip to content
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

Fix missing RTC_OBJC_TYPE macros #100

Merged
merged 13 commits into from
Oct 11, 2023
Prev Previous commit
Next Next commit
RTCNetworkMonitor
  • Loading branch information
hiroshihorie committed Oct 4, 2023
commit 22ff0e56c12608d55e2e2bfc473cfe7d47bc0377
7 changes: 6 additions & 1 deletion sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,12 @@ if (is_ios || is_mac) {
"objc/components/network/RTCNetworkMonitor.mm",
]

configs += [ ":used_from_extension" ]
configs += [
"..:common_objc",
":used_from_extension",
]

public_configs = [ ":common_config_objc" ]

frameworks = [ "Network.framework" ]

Expand Down
14 changes: 8 additions & 6 deletions sdk/objc/components/network/RTCNetworkMonitor+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
*/

#import "RTCNetworkMonitor.h"
#import "RTCMacros.h"

#include "sdk/objc/native/src/network_monitor_observer.h"

@interface RTCNetworkMonitor ()
@interface RTC_OBJC_TYPE (RTCNetworkMonitor)
()

/** `observer` is a raw pointer and should be kept alive
* for this object's lifetime.
*/
- (instancetype)initWithObserver:(webrtc::NetworkMonitorObserver *)observer
NS_DESIGNATED_INITIALIZER;
/** `observer` is a raw pointer and should be kept alive
* for this object's lifetime.
*/
- (instancetype)initWithObserver
: (webrtc::NetworkMonitorObserver *)observer NS_DESIGNATED_INITIALIZER;

/** Stops the receiver from posting updates to `observer`. */
- (void)stop;
Expand Down
4 changes: 3 additions & 1 deletion sdk/objc/components/network/RTCNetworkMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

#import <Foundation/Foundation.h>

#import "RTCMacros.h"

NS_ASSUME_NONNULL_BEGIN

/** Listens for NWPathMonitor updates and forwards the results to a C++
* observer.
*/
@interface RTCNetworkMonitor : NSObject
@interface RTC_OBJC_TYPE (RTCNetworkMonitor): NSObject

- (instancetype)init NS_UNAVAILABLE;

Expand Down
6 changes: 3 additions & 3 deletions sdk/objc/components/network/RTCNetworkMonitor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

} // namespace

@implementation RTCNetworkMonitor {
@implementation RTC_OBJC_TYPE (RTCNetworkMonitor) {
webrtc::NetworkMonitorObserver *_observer;
nw_path_monitor_t _pathMonitor;
dispatch_queue_t _monitorQueue;
Expand All @@ -63,12 +63,12 @@ - (instancetype)initWithObserver:(webrtc::NetworkMonitorObserver *)observer {
return nil;
}
RTCLog(@"NW path monitor created.");
__weak RTCNetworkMonitor *weakSelf = self;
__weak RTC_OBJC_TYPE(RTCNetworkMonitor) *weakSelf = self;
nw_path_monitor_set_update_handler(_pathMonitor, ^(nw_path_t path) {
if (weakSelf == nil) {
return;
}
RTCNetworkMonitor *strongSelf = weakSelf;
RTC_OBJC_TYPE(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 Down
2 changes: 1 addition & 1 deletion sdk/objc/native/src/objc_network_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ObjCNetworkMonitor : public rtc::NetworkMonitorInterface,
std::map<std::string, rtc::AdapterType, rtc::AbslStringViewCmp>
adapter_type_by_name_ RTC_GUARDED_BY(thread_);
rtc::scoped_refptr<PendingTaskSafetyFlag> safety_flag_;
RTCNetworkMonitor* network_monitor_ = nil;
RTC_OBJC_TYPE(RTCNetworkMonitor) * network_monitor_ = nil;
};

} // namespace webrtc
Expand Down
2 changes: 1 addition & 1 deletion sdk/objc/native/src/objc_network_monitor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
thread_ = rtc::Thread::Current();
RTC_DCHECK_RUN_ON(thread_);
safety_flag_->SetAlive();
network_monitor_ = [[RTCNetworkMonitor alloc] initWithObserver:this];
network_monitor_ = [[RTC_OBJC_TYPE(RTCNetworkMonitor) alloc] initWithObserver:this];
if (network_monitor_ == nil) {
RTC_LOG(LS_WARNING) << "Failed to create RTCNetworkMonitor; not available on this OS?";
}
Expand Down