Phenix Mobile SDK v2020.1.56 Pre-release Notes
Release Date: 2020.08.31
Issues addressed in this release:
Added support for subscribing to messages based on mime-types
Fix to properly expose API in support for configurable sampling rate for BlueTooth SCO capability in Android
Added client side timeouts for member updates
To get the Android SDK:
Update the Phenix SDK version in build.gradle file to `2020.1.56`
To get the iOS SDK:
Update the Phenix SDK version in Podfile to `2020.1.56-beta`
Or contact Phenix for the iOS SDK download location.
Notes on Integrating the Android SDK
In order to support BlueTooth SCO headsets
1. Configure the sample rate overrides for recording and playback to values that are required by SCO:
try {
Os.setenv("PHENIX_AUDIO_PLAYBACK_SAMPLE_RATE_OVERRIDE", "16000", true);
Os.setenv("PHENIX_AUDIO_RECORDING_SAMPLE_RATE_OVERRIDE", "8000", true);
} catch (ErrnoException e) {
// handle exception
}
2. Enable SCO in the AudioManager (this example assumes the code is placed in your Application subclass):
AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
// call at appropriate time - detection of BT on
audioManager.startBluetoothSco();
// call at appropriate time - detection of BT off
audioManager.stopBluetoothSco();
3. For both publishing and subscribing, make sure that audio echo cancellation is enabled in the respective options:
// publishing
final UserMediaOptions mediaConstraints = new UserMediaOptions();
mediaConstraints.getAudioOptions().capabilityConstraints.put(
DeviceCapability.AUDIO_ECHO_CANCELATION_MODE,
singletonList(new DeviceConstraint(AudioEchoCancelationMode.ON)));
PublishOptions publishOptions = PCastExpressFactory.createPublishOptionsBuilder()
.withMediaConstraints(mediaConstraints)
// add any other options
.buildPublishOptions();
// subscribing
final RendererOptions rendererOptions = new RendererOptions();
rendererOptions.audioEchoCancelationMode = AudioEchoCancelationMode.ON;
JoinChannelOptionsBuilder joinChannelOptionsBuilder = ChannelExpressFactory
.createJoinChannelOptionsBuilder()
.withRendererOptions(rendererOptions)
// add any other options
.buildJoinChannelOptions()
4. Note that only mono streams are supported by SCO.
In order to subscribe to messages by mime-type
import com.phenixrts.chat.RoomChatServiceFactory;
import com.phenixrts.room.RoomService;
final int batchSize = ...
final RoomService roomService = ...; // previously obtained
final HashSet<String> wantedMimeTypes = new HashSet<String>();
wantedMimeTypes.add(“text/javascript”);
final RoomChatService chatService =
RoomChatServiceFactory.createRoomChatService(
roomService,
batchSize,
wantedMimeTypes
);
// “chatService” retrieves only messages of “wantedMimeTypes”
final Disposable subscriptionLastChatMessage =
chatService.getObservableLastChatMessage().subscribe((change) -> {
final ChatMessage message = (ChatMessage)change;
assert message.getObservableMimeType().getValue() == “text/javascript”;
});
final Disposable subscriptionChatMessages =
chatService.getObservableChatMessages().subscribe((change) -> {
final ChatMessage[] messages = (ChatMessage[])change;
for (int i = 0; i < messages.length; ++i) {
assert message.getObservableMimeType().getValue() ==
“text/javascript”;
}
});
chatService.getMessages(
batchSize,
afterMessageId,
beforeMessageId,
(RoomChatService service, ChatMessage[] messages, RequestStatus status) -> {
for (int i = 0; i < messages.length; ++i) {
assert message.getObservableMimeType().getValue() ==
“text/javascript”;
}
});
// send message with a specific MIME type
// with just the message, MIME type defaults to “text/plain”:
chatService.sendMessageToRoom("My First Message");
// with message and MIME type, but using default callback
chatService.sendMessageToRoom("My First Message", "text/javascript");
// with message, MIME type, and callback
chatService.sendMessageToRoom(
"My First Message",
"text/javascript",
(RequestStatus status, String message) -> { ... }
);
Notes on Integrating the iOS SDK
In order to specify the iOS release in the pod spec
In order to pick up that latest version, you may need to run this pod command:
pod install --repo-update
To change this in the Podfile:
def phenix
pod 'PhenixSdk', '~> 2020.1.56-beta'
end
In order to subscribe to messages by mime-type
import PhenixSdk
import PhenixRoomChatServiceFactory
var wantedMimeTypes = Set<String>()
wantedMimeTypes.insert(“text/javascript”)
var chatService = PhenixRoomChatService.createRoomChatService(
roomService, // previously obtained
batchSize, // previously obtained
wantedMimeTypes
);
var subscriptionLastChatMessage =
chatService.getObservableLastChatMessage().subscribe({
change in
if let change = change, let chatMessage = change.value {
assert(
chatMessage.getObservableMimeType().value == “text/javascript”,
“chatService will only get messages with wanted MIME types”
)
})
var subscriptionLastChatMessage =
chatService.getObservableLastChatMessage().subscribe({
change in
if let change = change {
let messages = change.value as! [PhenixChatMessage]
for message in messages {
assert(
chatMessage.getObservableMimeType().value ==“text/javascript”,
“chatService will only get messages with wanted MIME types”
)
}
}
})
chatService.getMessages(batchSize, afterMessageId, beforeMessageId) {
(chatService: PhenixRoomChatService?,
messages: [PhenixChatMessage]?,
status: PhenixRequestStatus) in
if status == .ok, let messages = messages {
for message in messages {
assert(
chatMessage.getObservableMimeType().value ==“text/javascript”,
“chatService will only get messages with wanted MIME types”
)
}
}
}
// send message with a specific MIME type
// with just the message, MIME type defaults to “text/plain”:
chatService.sendMessageToRoom("My First Message");
// with message and MIME type, but using default callback
chatService.sendMessageToRoom("My First Message", "text/javascript");
// with message, MIME type, and callback
chatService.sendMessageToRoom(
"My First Message",
"text/javascript") {
(status: PhenixRequestStatus, message: String?) in {
...
}
}
©2020-2021 Phenix Real Time Solutions, Inc.