Skip to content

Commit

Permalink
Re #1757: Add example to display video in ipjsua (require ffmpeg libr…
Browse files Browse the repository at this point in the history
…aries)

git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4813 74dad513-b988-da41-8d7b-12977e46ad98
  • Loading branch information
ming committed Apr 8, 2014
1 parent 6d4d857 commit 218d4ca
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 53 deletions.
112 changes: 86 additions & 26 deletions pjsip-apps/src/pjsua/ios/ipjsua.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

22 changes: 17 additions & 5 deletions pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
//
// ipjsuaAppDelegate.h
// ipjsua
//
// Created by Liong Sauw Ming on 13/3/13.
// Copyright (c) 2013 Teluu. All rights reserved.
//

/*
* Copyright (C) 2013-2014 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#import <UIKit/UIKit.h>

@class ipjsuaViewController;
Expand Down
54 changes: 42 additions & 12 deletions pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
//
// ipjsuaAppDelegate.m
// ipjsua
//
// Created by Liong Sauw Ming on 13/3/13.
// Copyright (c) 2013 Teluu. All rights reserved.
//

/*
* Copyright (C) 2013-2014 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#import "ipjsuaAppDelegate.h"
#import <pjlib.h>
#import <pjsua.h>
Expand Down Expand Up @@ -33,8 +45,8 @@ @implementation ipjsuaAppDelegate
static void displayMsg(const char *msg)
{
NSString *str = [NSString stringWithFormat:@"%s", msg];
[app performSelectorOnMainThread:@selector(displayMsg:) withObject:str
waitUntilDone:NO];
dispatch_async(dispatch_get_main_queue(),
^{app.viewController.textLabel.text = str;});
}

static void pjsuaOnStartedCb(pj_status_t status, const char* msg)
Expand Down Expand Up @@ -73,11 +85,6 @@ static void pjsuaOnAppConfigCb(pjsua_app_config *cfg)
PJ_UNUSED_ARG(cfg);
}

- (void)displayMsg:(NSString *)str
{
app.viewController.textLabel.text = str;
}

- (void)pjsuaStart
{
// TODO: read from config?
Expand Down Expand Up @@ -215,4 +222,27 @@ pj_bool_t showNotification(pjsua_call_id call_id)
return PJ_FALSE;
}

void displayWindow(pjsua_vid_win_id wid)
{
#if PJSUA_HAS_VIDEO
pjsua_vid_win_info wi;

if (wid != PJSUA_INVALID_ID &&
pjsua_vid_win_get_info(wid, &wi) == PJ_SUCCESS)
{
UIView *view = (__bridge UIView *)wi.hwnd.info.ios.window;
if (view) {
dispatch_async(dispatch_get_main_queue(), ^{
UIView *parent = app.viewController.view;
/* Add the video window as subview */
[parent addSubview:view];
/* Center it */
view.center = CGPointMake(parent.bounds.size.width/2.0,
parent.bounds.size.height/2.0);
});
}
}
#endif
}

@end
22 changes: 17 additions & 5 deletions pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaViewController.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
//
// ipjsuaViewController.h
// ipjsua
//
// Created by Liong Sauw Ming on 13/3/13.
// Copyright (c) 2013 Teluu. All rights reserved.
//

/*
* Copyright (C) 2013-2014 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#import <UIKit/UIKit.h>

@interface ipjsuaViewController : UIViewController
Expand Down
22 changes: 17 additions & 5 deletions pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaViewController.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
//
// ipjsuaViewController.m
// ipjsua
//
// Created by Liong Sauw Ming on 13/3/13.
// Copyright (c) 2013 Teluu. All rights reserved.
//

/*
* Copyright (C) 2013-2014 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#import "ipjsuaViewController.h"

@interface ipjsuaViewController ()
Expand Down
3 changes: 3 additions & 0 deletions pjsip-apps/src/pjsua/pjsua_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ static void on_call_video_state(pjsua_call_info *ci, unsigned mi,
return;

arrange_window(ci->media[mi].stream.vid.win_in);
#ifdef USE_GUI
displayWindow(ci->media[mi].stream.vid.win_in);
#endif

PJ_UNUSED_ARG(has_error);
}
Expand Down

0 comments on commit 218d4ca

Please sign in to comment.