Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The following native app is created using the Sonus Generic Code. The application page is used to login, enter user information to call, answer, hangup the call on iOS platform.

Figure : iOS Native Screen

The application UI code is explained as follows:

<subviews>
                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="eXT-dW-E2Q">
                                <rect key="frame" x="92" y="102" width="149" height="32"/>
                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <animations/>
                                <color key="backgroundColor" white="0.49547697369999999" alpha="1" colorSpace="calibratedWhite"/>
                                <fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
                                <state key="normal" title="Launch Call"/>
                                <connections>
                                    <action selector="startConversationAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="tU4-6f-GXg"/>
                                </connections>
                            </button>
                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="gGH-ZT-CZQ">
                                <rect key="frame" x="92" y="142" width="67" height="30"/>
                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <animations/>
                                <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
                                <state key="normal" title="Hangup">
                                    <color key="titleColor" red="0.76781331806282727" green="0.10856112018749546" blue="0.1290137232364551" alpha="1" colorSpace="calibratedRGB"/>
                                </state>
                                <connections>
                                    <action selector="OnHangupButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="5qo-wY-fcy"/>
                                </connections>
                            </button>
                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Enter phone number or email" textAlignment="center" clearsOnBeginEditing="YES" minimumFontSize="17" id="mv2-uP-MMG">
                                <rect key="frame" x="32" y="56" width="268" height="30"/>
                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <animations/>
                                <accessibility key="accessibilityConfiguration" label="eMail">
                                    <accessibilityTraits key="traits" none="YES"/>
                                </accessibility>
                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                <textInputTraits key="textInputTraits" returnKeyType="done" enablesReturnKeyAutomatically="YES"/>
                                <connections>
                                    <outlet property="delegate" destination="BYZ-38-t0r" id="C2X-nK-ois"/>
                                </connections>
                            </textField>
                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sonus IOS Basic Call Demo" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fcf-y6-F9g">
                                <rect key="frame" x="65" y="20" width="224" height="21"/>
                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <animations/>
                                <fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
                                <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                <nil key="highlightedColor"/>
                            </label>
                            <view contentMode="scaleToFill" id="W5F-NE-ywr">
                                <rect key="frame" x="20" y="191" width="280" height="194"/>
                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <animations/>
                                <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
                            </view>
                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="Zva-3L-f6W">
                                <rect key="frame" x="185" y="142" width="56" height="30"/>
                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <animations/>
                                <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
                                <state key="normal" title="Answer">
                                    <color key="titleColor" red="0.18110528049999999" green="0.43545484290000003" blue="0.27067778819999999" alpha="1" colorSpace="calibratedRGB"/>
                                </state>
                                <connections>
                                    <action selector="OnAnswerButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="xwU-h1-TJj"/>
                                </connections>
                            </button>
                        </subviews>

The corresponding android native code is as follows:

//Start conversation:
=============================================================
-(IBAction)startConversationAction:(id)sender
{
    NSString *to = [self.eMailEntered text];
    if(nil == to || [to length] < 1)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sonus IOS demo" message:@"Enter email or phone" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        return;
    }    
    [[AppDelegate sharedInstance] startConversation:self.videoView to:to];
}
-(void) startConversation : (UIView *) videoContainer to:(NSString *) to
{
    
    self.localMedia = [[LocalMedia alloc ] init];
    [self.localMedia start:videoContainer callback:^(NSString *msg)
     {
         // Create a WebRTC audio stream description (requires a
         // reference to the local audio feed).
         self.audioStream = [[SonusIceLinkWebRTCAudioStream alloc] initWithLocalStream:_localMedia.localMediaStream];
         
         // Create a WebRTC video stream description (requires a
         // reference to the local video feed). Whenever a P2P link
         // initializes using this description, position and display
         // the remote video control on-screen by passing it to the
         // layout manager created above. Whenever a P2P link goes
         // down, remove it.
         self.videoStream = [[SonusIceLinkWebRTCVideoStream alloc] initWithLocalStream:_localMedia.localMediaStream];
         
         SonusWRTCMakeCallArgs *callArgs = [SonusWRTCMakeCallArgs makeCallArgsWithType: SonusWRTCSessionTypeVideo to:to localMedia: self.localMedia];
         
         // sipHeaders : this is used to send context or tokens end to end (web->sip)
         // sipHeaders is a json arraycin the format:
         // [
         //  {"HeaderName": "Name1", "HeaderValue": "Value1"},
         //  {"HeaderName": "Name2", "HeaderValue": "Value2"},
         //  ]
         // HeaderName - name for SIP header to include in Invite Message
         // HeaderValue - string value, may contain valid sip ABNF parameter values
         
         [callArgs setSipHeaders:[NSString stringWithFormat:@"[{\"%@\":\"%@\",\"%@\":\"%@\"}]", @"HeaderName", @"SessionContext", @"HeaderValue", @"Sonus SDK IOS"]];
         [SonusLog debugWithMessage:[NSString stringWithFormat:@"sip headers val->%@",[callArgs sipHeaders]]];
         
         // Setup Callbacks
         [callArgs setOnFailure:[SonusCallback callback:@selector(callBackForCallFail:) target:self]];
         [callArgs setOnComplete:[SonusCallback callback:@selector(callBackForCallComplete:) target:self]];
         [callArgs setOnRejected:[SonusCallback callback:@selector(callBackForCallRejected:) target:self]];
         [callArgs setOnRinging:[SonusCallback callback:@selector(callBackForCallRinging:) target:self]];
         [callArgs setOnSuccess:[SonusCallback callback:@selector(callBackForCallSuccess:) target:self]];
         [callArgs setOnTimeout:[SonusCallback callback:@selector(callBackForCallTimeout:) target:self]];
         [callArgs setOnTrying:[SonusCallback callback:@selector(callBackForCallTrying:) target:self]];
         
         self.session = [self.client makeCallWithArgs:callArgs ];
         if(self.session != nil)
         {
             [self.session addOnParticipantAdded:[SonusCallback callback:@selector(callBackForParticipantAdded:) target:self]];
             [self.session addOnParticipantDropped:[SonusCallback callback:@selector(callBackForParticipantDropped:) target:self]];
             [self.session addOnReceiveParticipantList:[SonusCallback callback:@selector(callBackForReceivedParticipantList:) target:self]];
             [self.session addOnSessionEnded:[SonusCallback callback:@selector(callBackForSessionEnded:) target:self]];
             [self.session addOnSessionEstablished:[SonusCallback callback:@selector(callBackForSessionEstablished:) target:self]];
         }
     }
     ];
}
// Hangup pressed on UI
============================================================
-(void) OnHangupButton
{
    if(nil != self.session)
    {
        SonusWRTCHangUpArgs* hangupArgs = [SonusWRTCHangUpArgs hangUpArgsWithSessionId:[self.session id]];
        [hangupArgs setOnFailure:[SonusCallback callback:@selector(callBackForHangupFail:) target:self]];
        [hangupArgs setOnComplete:[SonusCallback callback:@selector(callBackForHangupComplete:) target:self]];
        [hangupArgs setOnSuccess:[SonusCallback callback:@selector(callBackForHangupSuccess:) target:self]];
        [self.client hangUpWithArgs:hangupArgs];
    }
} 

 


  • No labels