Commit 17170823 authored by jehan's avatar jehan

add mediastream for IOS

parent 188a7363
......@@ -463,7 +463,7 @@ extern MSSndCardDesc aq_card_desc;
extern MSSndCardDesc pulse_card_desc;
#endif
#ifdef __MACIOUNIT_ENABLED__
#ifdef __IOSIOUNIT_ENABLED__
extern MSSndCardDesc au_card_desc;
#endif
......@@ -500,7 +500,7 @@ static MSSndCardDesc * ms_snd_card_descs[]={
&pulse_card_desc,
#endif
#ifdef __MACIOUNIT_ENABLED__
#ifdef __IOSIOUNIT_ENABLED__
&au_card_desc,
#endif
#ifdef ANDROID
......
/* Localized versions of Info.plist keys */
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.linphone.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
<string>MainWindow</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIApplicationExitsOnSuspend</key>
<true/>
</dict>
</plist>
//
// Prefix header for all source files of the 'mediastream' target in the 'mediastream' project
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
//
// mediastreamAppDelegate.h
// mediastream
//
// Created by jehan on 15/06/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@class mediastreamViewController;
@interface mediastreamAppDelegate : NSObject <UIApplicationDelegate> {
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet mediastreamViewController *viewController;
@end
//
// mediastreamAppDelegate.m
// mediastream
//
// Created by jehan on 15/06/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "mediastreamAppDelegate.h"
#import "mediastreamViewController.h"
@implementation mediastreamAppDelegate
@synthesize window=_window;
@synthesize viewController=_viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
}
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
@end
//
// mediastreamViewController.h
// mediastream
//
// Created by jehan on 15/06/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface mediastreamViewController : UIViewController {
UIView* imageView;
UIView* preview;
}
@property (nonatomic, retain) IBOutlet UIView* imageView;
@property (nonatomic, retain) IBOutlet UIView* preview;
@end
//
// mediastreamViewController.m
// mediastream
//
// Created by jehan on 15/06/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "mediastreamViewController.h"
#include "mediastream.h"
#ifdef VIDEO_ENABLE
#include "iosdisplay.h"
#endif
static UIView* sImageView=0;
static UIView* spreview=0;
@implementation mediastreamViewController
@synthesize imageView;
@synthesize preview;
void ms_set_video_stream(VideoStream* video) {
#ifdef VIDEO_ENABLED
ms_filter_call_method(video->output,MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID,&sImageView);
ms_filter_call_method(video->source,MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID,&spreview);
#endif
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
sImageView=imageView;
spreview=preview;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
......@@ -45,6 +45,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifdef __APPLE__
#include <CoreFoundation/CFRunLoop.h>
#endif
#ifdef TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
extern void ms_set_video_stream(VideoStream* video);
#ifdef HAVE_X264
extern void libmsx264_init();
#endif
#endif
#ifdef ANDROID
#include <android/log.h>
......@@ -158,7 +165,38 @@ const char *usage="mediastream --local <port> --remote <ip:port> \n"
#ifndef ANDROID
#ifndef __APPLE__
int main(int argc, char * argv[])
#else /*Main thread is blocked by cocoa UI framework*/
int g_argc;
char** g_argv;
static int _main(int argc, char * argv[]);
static void* apple_main(void* data) {
_main(g_argc,g_argv);
return NULL;
}
int main(int argc, char * argv[]) {
pthread_t main_thread;
g_argc=argc;
g_argv=argv;
pthread_create(&main_thread,NULL,apple_main,NULL);
#ifdef TARGET_OS_MACOSX
CFRunLoopRun();
return 0;
#elif TARGET_OS_IPHONE
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int value = UIApplicationMain(0, nil, nil, nil);
[pool release];
return value;
#endif
cond=0;
pthread_join(main_thread,NULL);
}
static int _main(int argc, char * argv[])
#endif
{
MediastreamDatas* args;
cond = 1;
......@@ -364,10 +402,6 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) {
void setup_media_streams(MediastreamDatas* args) {
#ifdef VIDEO_ENABLED
MSWebCam *cam=NULL;
#endif
/*create the rtp session */
ortp_init();
if (args->is_verbose) {
......@@ -383,6 +417,9 @@ void setup_media_streams(MediastreamDatas* args) {
rtp_profile_set_payload(&av_profile,114,args->custom_pt);
rtp_profile_set_payload(&av_profile,115,&payload_type_lpc1015);
#ifdef VIDEO_ENABLED
#if defined (TARGET_OS_IPHONE) && defined (HAVE_X264)
libmsx264_init(); /*no plugin on IOS*/
#endif
rtp_profile_set_payload(&av_profile,26,&payload_type_jpeg);
rtp_profile_set_payload(&av_profile,98,&payload_type_h263_1998);
rtp_profile_set_payload(&av_profile,97,&payload_type_theora);
......@@ -394,6 +431,7 @@ void setup_media_streams(MediastreamDatas* args) {
#ifdef VIDEO_ENABLED
args->video=NULL;
MSWebCam *cam=NULL;
#endif
args->profile=rtp_profile_clone_full(&av_profile);
args->q=ortp_ev_queue_new();
......@@ -453,12 +491,14 @@ void setup_media_streams(MediastreamDatas* args) {
}
}
#ifndef TARGET_OS_IPHONE
if (args->zrtp_id != NULL) {
OrtpZrtpParams params;
params.zid=args->zrtp_id;
params.zid_file=args->zrtp_secrets;
audio_stream_enable_zrtp(args->audio,&params);
}
#endif
args->session=args->audio->session;
}
......@@ -476,6 +516,11 @@ void setup_media_streams(MediastreamDatas* args) {
#endif
video_stream_set_sent_video_size(args->video,args->vs);
video_stream_use_preview_video_window(args->video,args->two_windows);
#ifdef TARGET_OS_IPHONE
NSBundle* myBundle = [NSBundle mainBundle];
const char* nowebcam = [[myBundle pathForResource:@"nowebcamCIF"ofType:@"jpg"] cStringUsingEncoding:[NSString defaultCStringEncoding]];
ms_static_image_set_default_image(nowebcam);
#endif
if (args->camera)
cam=ms_web_cam_manager_get_cam(ms_web_cam_manager_get(),args->camera);
......@@ -536,9 +581,10 @@ void run_interactive_loop(MediastreamDatas* args) {
void run_non_interactive_loop(MediastreamDatas* args) {
rtp_session_register_event_queue(args->session,args->q);
#ifdef __APPLE__
CFRunLoopRun();
#else
#if TARGET_OS_IPHONE==1 && defined(VIDEO_ENABLED)
ms_set_video_stream(args->video); /*for IOS*/
#endif
while(cond)
{
int n;
......@@ -570,7 +616,6 @@ void run_non_interactive_loop(MediastreamDatas* args) {
ms_message("Quality indicator : %f\n",args->audio ? audio_stream_get_quality_rating(args->audio) : -1);
}
}
#endif // target MAC
}
void clear_mediastreams(MediastreamDatas* args) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment