Giter Site home page Giter Site logo

flutter_pjsip's Introduction

flutter_pjsip

A new Flutter plugin.

Flutter插件集成PJSIP说明文档(iOS及Android 端) @[TOC](Flutter插件集成PJSIP说明文档(iOS及Android 端))

实现方式

本PJSIP插件是以flutter的Dart语言实现页面功能,iOS和Android以原生方式集成PJSIP的SDK,flutter与原生之间以信号通道的方式进行交互,已实现PJSIP的网络拨打电话功能。

Flutter调原生信号通道

信号通道名称

/** 信号通道*/
flutter_pjsip

Flutter 传值给原生方法名

方法名

1./** pjsip初始化*/
method_pjsip_init
2./** pjsip登录*/
method_pjsip_login
3./** pjsip拨打电话*/
method_pjsip_call
4./** pjsip登出*/
method_pjsip_logout
5./** pjsip销毁*/
method_pjsip_deinit
6./** 接收电话*/
method_pjsip_receive
7./** 挂断&&拒接*/
method_pjsip_refuse
8./** 免提*/
method_pjsip_audioSession
9./** 静音*/
method_pjsip_muteMicrophone

原生调Flutter信号通道

信号通道名称

/** 信号通道*/
native_pjsip

原生传值给Flutter

PJSIP里所有的回调状态

/**
* This enumeration describes invite session state.
*/
typedef enum pjsip_inv_state
{
   PJSIP_INV_STATE_NULL,	    /**< Before INVITE is sent or received  */
   PJSIP_INV_STATE_CALLING,	    /**< After INVITE is sent		    */
   PJSIP_INV_STATE_INCOMING,	    /**< After INVITE is received.	    */
   PJSIP_INV_STATE_EARLY,	    /**< After response with To tag.	    */
   PJSIP_INV_STATE_CONNECTING,	    /**< After 2xx is sent/received.	    */
   PJSIP_INV_STATE_CONFIRMED,	    /**< After ACK is sent/received.	    */
   PJSIP_INV_STATE_DISCONNECTED,   /**< Session is terminated.		    */
} pjsip_inv_state;

这里原生会以json串的形式传值给Flutter,Flutter会根据不同的value值处理相应的事件

例如:{  callStatusChanged: @(PJSIP_INV_STATE_CONNECTING) }
这里对应的key值有七个状态,都包含:
  PJSIP_INV_STATE_NULL,	    		/**< 在发送或接收邀请之前  */
  PJSIP_INV_STATE_CALLING,	   		 /**< 发送邀请后		    */
  PJSIP_INV_STATE_INCOMING,		 /**< 来电中	    */
  PJSIP_INV_STATE_EARLY,	   		 /**< 来电之前	    */
  PJSIP_INV_STATE_CONNECTING,	    /**响铃中	    */
  PJSIP_INV_STATE_CONFIRMED,	    /**<已确认	    */
  PJSIP_INV_STATE_DISCONNECTED,   /**已挂断或已拒绝    */

PJSIP插件iOS端集成说明

1.配置本地依赖库

CoreTelephony.framework AVFoundation.framework

2 在APPdelegate里引入头文件并调用

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#import "MainViewController.h"
#import "FlutterAppDelegate+Pjsip.h" /** 需要导入的头文件*/
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   [GeneratedPluginRegistrant registerWithRegistry:self];
   /** 设置主控制器继承FlutterViewController*/
   MainViewController * VC = [[MainViewController alloc]init];
   UINavigationController * NVC = [[UINavigationController alloc]initWithRootViewController:VC];
   [self.window setRootViewController:NVC];
   [self setupPjsip:application rootController:VC];/** 需要调用的方法*/
 return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end

3.运行cocoaPods

pod install --verbose --no-repo-update

4.手动配置flutter的flutter_pjsip.xcconfig文件

需要保证flutter_pjsip.xcconfig文件与Pods-Runner.debug.xcconfig文件的'GCC_PREPROCESSOR_DEFINITIONS''HEADER_SEARCH_PATHS' 的配置高度一致,否者会报#include <pjsua-lib/pjsua.h>头文件找不到的错。

Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

flutter_pjsip's People

Contributors

jackzhang1994 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.