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

add Logger of mediasoupclient #30

Open
wants to merge 5 commits into
base: master
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
2 changes: 2 additions & 0 deletions Example/MediasoupExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ final class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// debug
Logger.setLogLevel(with: 3)

guard AVCaptureDevice.authorizationStatus(for: .audio) == .authorized else {
self.label.text = "accept all permission requests and restart the app"
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- Mediasoup-Client-Swift (0.8.0)
- Mediasoup-Client-Swift (0.8.1)

DEPENDENCIES:
- Mediasoup-Client-Swift (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
Mediasoup-Client-Swift: c6c318be2f5940a25eac32ee983840603de7a56e
Mediasoup-Client-Swift: 3137c3db16de07aab3a9f771bc31254372f7b0bb

PODFILE CHECKSUM: d4fe3294dd9c7fc46519b6a7b26527f1f545e8d3

Expand Down
2 changes: 1 addition & 1 deletion Mediasoup-Client-Swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pod::Spec.new do |spec|
}

spec.name = "Mediasoup-Client-Swift"
spec.version = "0.8.0"
spec.version = "0.8.1"
spec.platform = :ios, "14.0"
spec.module_name = "Mediasoup"
spec.module_map = "Mediasoup/Mediasoup.modulemap"
Expand Down
20 changes: 20 additions & 0 deletions Mediasoup.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
/* End PBXAggregateTarget section */

/* Begin PBXBuildFile section */
22DEF8D22BBBCC900082149D /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22DEF8D12BBBCC900082149D /* Logger.swift */; };
22DEF8D52BBBCCAA0082149D /* LoggerWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 22DEF8D32BBBCCAA0082149D /* LoggerWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
22DEF8D62BBBCCAA0082149D /* LoggerWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 22DEF8D42BBBCCAA0082149D /* LoggerWrapper.mm */; };
FF1E63582A5655830022A44A /* DataConsumerWrapper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = FF1E63522A5655830022A44A /* DataConsumerWrapper.hpp */; settings = {ATTRIBUTES = (Private, ); }; };
FF1E635A2A5655830022A44A /* DataConsumerWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FF1E63542A5655830022A44A /* DataConsumerWrapper.mm */; };
FF1E635B2A5655830022A44A /* DataConsumerWrapperDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = FF1E63552A5655830022A44A /* DataConsumerWrapperDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -87,6 +90,9 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
22DEF8D12BBBCC900082149D /* Logger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
22DEF8D32BBBCCAA0082149D /* LoggerWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoggerWrapper.h; sourceTree = "<group>"; };
22DEF8D42BBBCCAA0082149D /* LoggerWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggerWrapper.mm; sourceTree = "<group>"; };
FF1E63522A5655830022A44A /* DataConsumerWrapper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DataConsumerWrapper.hpp; sourceTree = "<group>"; };
FF1E63532A5655830022A44A /* DataConsumerListenerAdapterDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataConsumerListenerAdapterDelegate.h; sourceTree = "<group>"; };
FF1E63542A5655830022A44A /* DataConsumerWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataConsumerWrapper.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -181,6 +187,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2269118E2BBBB35C007DB207 /* Logger */ = {
isa = PBXGroup;
children = (
22DEF8D32BBBCCAA0082149D /* LoggerWrapper.h */,
22DEF8D42BBBCCAA0082149D /* LoggerWrapper.mm */,
);
path = Logger;
sourceTree = "<group>";
};
FF1E63512A56555F0022A44A /* DataConsumer */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -217,6 +232,7 @@
FF3AEE0227F2CDD1001A81AB /* Mediasoup */ = {
isa = PBXGroup;
children = (
22DEF8D12BBBCC900082149D /* Logger.swift */,
FF49F0E72804049300B64D36 /* Consumer.swift */,
FF49F0E9280404E400B64D36 /* ConsumerDelegate.swift */,
FF1E635E2A566C500022A44A /* DataConsumer.swift */,
Expand Down Expand Up @@ -285,6 +301,7 @@
FF89EFCF27F5C51500EEF5CD /* Mediasoup_Private */ = {
isa = PBXGroup;
children = (
2269118E2BBBB35C007DB207 /* Logger */,
FF1E63512A56555F0022A44A /* DataConsumer */,
FFB7DDB5282289AD00FE2CC2 /* Consumer */,
FF7FA6C827FE9661000B6470 /* Producer */,
Expand Down Expand Up @@ -371,6 +388,7 @@
FF7FA6CE27FE9A4B000B6470 /* ProducerWrapper.hpp in Headers */,
FF1E635B2A5655830022A44A /* DataConsumerWrapperDelegate.h in Headers */,
FFB7DDC22823989A00FE2CC2 /* ReceiveTransportListenerAdapter.hpp in Headers */,
22DEF8D52BBBCCAA0082149D /* LoggerWrapper.h in Headers */,
FF61457527F30FDC0067B2C4 /* DeviceWrapper.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -508,7 +526,9 @@
FFF0050D2B5A631D007BA500 /* RTPEncodingParameters+Internal.mm in Sources */,
FFF0050B2B5A62FD007BA500 /* RTPEncodingParameters.mm in Sources */,
FFC5AC72282500A500C92A96 /* TransportConnectionState.swift in Sources */,
22DEF8D62BBBCCAA0082149D /* LoggerWrapper.mm in Sources */,
FF7FA69A27FAACEE000B6470 /* SendTransportWrapper.mm in Sources */,
22DEF8D22BBBCC900082149D /* Logger.swift in Sources */,
FF7FA69527FAA930000B6470 /* SendTransport.swift in Sources */,
FF49F0EA280404E400B64D36 /* ConsumerDelegate.swift in Sources */,
FF7FA69127FAA8E9000B6470 /* SendTransportDelegate.swift in Sources */,
Expand Down
20 changes: 20 additions & 0 deletions Mediasoup/Logger.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation
import Mediasoup_Private

public class Logger {
public static func setLogLevel(with level: UInt8) {
LoggerWrapper.setLogLevel(level)
}

public static func error(_ log: String) {
LoggerWrapper.error(withLog: log)
}

public static func warn(_ log: String) {
LoggerWrapper.warn(withLog: log)
}

public static func debug(_ log: String) {
LoggerWrapper.debug(withLog: log)
}
}
13 changes: 13 additions & 0 deletions Mediasoup_Private/Logger/LoggerWrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef LoggerWrapper_h
#define LoggerWrapper_h

#import <Foundation/Foundation.h>

@interface LoggerWrapper : NSObject
+ (void)setLogLevel:(uint8_t)level;
+ (void)errorWithLog:(NSString *_Nonnull)log;
+ (void)warnWithLog:(NSString *_Nonnull)log;
+ (void)debugWithLog:(NSString *_Nonnull)log;
@end

#endif
72 changes: 72 additions & 0 deletions Mediasoup_Private/Logger/LoggerWrapper.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#define MSC_CLASS "LoggerWrapper"

#import <Logger.hpp>
#import "LoggerWrapper.h"

#import <string>
#import <iostream>

using namespace mediasoupclient;

class DefaultLogHandler final : public mediasoupclient::Logger::LogHandlerInterface {
public:
DefaultLogHandler() {
}

void OnLog(mediasoupclient::Logger::LogLevel level, char *payload, size_t len) override {
std::string message(payload, len);
switch (level) {
case mediasoupclient::Logger::LogLevel::LOG_ERROR:
std::cout << message << std::endl;
break;
case mediasoupclient::Logger::LogLevel::LOG_WARN:
std::cout << message << std::endl;
break;
case mediasoupclient::Logger::LogLevel::LOG_DEBUG:
std::cout << message << std::endl;
break;
case mediasoupclient::Logger::LogLevel::LOG_TRACE:
std::cout << message << std::endl;
break;
default:
break;
}
}

mediasoupclient::Logger::LogLevel toEnum(uint8_t level) {
switch (level) {
case 1:
return mediasoupclient::Logger::LogLevel::LOG_ERROR;
case 2:
return mediasoupclient::Logger::LogLevel::LOG_WARN;
case 3:
return mediasoupclient::Logger::LogLevel::LOG_DEBUG;
case 4:
return mediasoupclient::Logger::LogLevel::LOG_TRACE;
default:
return mediasoupclient::Logger::LogLevel::LOG_NONE;
}
}
};

DefaultLogHandler *globalLogHandler = new DefaultLogHandler();

@implementation LoggerWrapper
+ (void)setLogLevel:(uint8_t)level {
mediasoupclient::Logger::LogLevel logLevel = globalLogHandler->toEnum(level);
mediasoupclient::Logger::SetLogLevel(logLevel);
mediasoupclient::Logger::SetHandler(globalLogHandler);
}

+ (void)errorWithLog:(NSString *)log {
MSC_ERROR("%s", log.UTF8String);
}

+ (void)warnWithLog:(NSString *)log {
MSC_WARN("%s", log.UTF8String);
}

+ (void)debugWithLog:(NSString *)log {
MSC_DEBUG("%s", log.UTF8String);
}
@end
1 change: 1 addition & 0 deletions Mediasoup_Private/Mediasoup_Private.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ module Mediasoup_Private {
private header "PrivateHeaders/DataConsumerWrapper.hpp"
private header "PrivateHeaders/DataConsumerWrapperDelegate.h"
private header "PrivateHeaders/ScalabilityMode.h"
private header "PrivateHeaders/LoggerWrapper.h"
}
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import PackageDescription


let version = "0.8.0"
let mediasoupChecksum = "cad81c6d038021ebe98edb5ff8876e658d253f9d4a721d6ba028616cab32a754"
let webrtcChecksum = "b2186d4cc9f940432d4751f56f657d1d571be39470e3061c47cbbd36fc26383d"
let version = "0.8.1"
let mediasoupChecksum = "d791d60fce826b7efd041c33b8576f0ccefb87c2f31fb216431b7ac294503a0e"
let webrtcChecksum = "6fd8501746d1de14cc2b2aa86d1ea4e081d8ad50ad190c99fb12fdbfdf3257bf"


let package = Package(
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Swift wrapper for libmediasoupclient with iOS support
If you don't need to customize Mediasoup-Client-Swift itself or its dependencies, just use Swift Package Manager or CocoaPods:

```Ruby
pod 'Mediasoup-Client-Swift', '0.8.0'
pod 'Mediasoup-Client-Swift', '0.8.1'
```

3. **Ease of building from scratch**
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
</data>
<key>Info.plist</key>
<data>
nRi2EjqFnDODwy09IKFHivrl7DA=
5G2KKnbHdTDrTylaZRSgSjTMsEU=
</data>
<key>Modules/Mediasoup.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo</key>
<data>
ZSnoC3NsYHNe3/T+1nGuZb0cFI8=
xmXY62TQvmJQCStVDugnakUv1Ss=
</data>
<key>Modules/Mediasoup.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo</key>
<data>
wU5UMWPWPv7+LHY6Ko4g7TF1BvU=
uzwRua7XNqKWUIVIOurM5RlbZiw=
</data>
<key>Modules/Mediasoup.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
<data>
Expand Down Expand Up @@ -162,14 +162,14 @@
<dict>
<key>hash2</key>
<data>
NgBFl0peSUfxj+G3rieIjbK6J3XOIBy7hBgjLO9fJdk=
hn9/7gz40ncsuM0LziqRuVzMEXZrQXZjppnzhJi/MY0=
</data>
</dict>
<key>Modules/Mediasoup.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo</key>
<dict>
<key>hash2</key>
<data>
2xhuqvadOgV1gYuZMaJEUqhogxKoTwBXrWka6LXX+jk=
wD4YYMuiw0wM/SJwjuM6E/AFBsI0MnHewZw3ZRLrR1g=
</data>
</dict>
<key>Modules/Mediasoup.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
Expand Down
Binary file modified bin/WebRTC.xcframework/ios-arm64/WebRTC.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file modified bin/mediasoupclient.xcframework/ios-arm64/libmediasoupclient.a
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions bin/sdptransform.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@
<key>BinaryPath</key>
<string>libsdptransform.a</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>libsdptransform.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>libsdptransform.a</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>libsdptransform.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file modified bin/sdptransform.xcframework/ios-arm64/libsdptransform.a
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function refetchLibmediasoupclient() {
echo 'Cloning libmediasoupclient'
cd $WORK_DIR
rm -rf libmediasoupclient
git clone -b vl-3.4.1 --depth 1 https://github.com/VLprojects/libmediasoupclient.git
git clone -b vl-m120 --depth 1 https://github.com/VLprojects/libmediasoupclient.git
}

if [ -d $WORK_DIR/libmediasoupclient ]
Expand Down