Review Record

Version Recorder date judges Review content
1.0.20 江朝柱 2019/5/29

Filing Approval

Version Recorder date Approval confirmation

[TOC]

1 Overview

1.1 Aim

Used to guide the development of Android sender applications using Porsche SDK

1.2 Target

This document applies to developers and testers of Android sender applications

1.3 Abbreviations definition

Abbreviations definition
BJCast_v2 BiJie wireless screen shooting protocol

2 Scope

2.1 SDK description

The overall framework is divided into two layers

  • SDK layer: bjcast_sender_lib-1.0.20.aar is an Android Module, provided in aarmode. The screen control protocol, screen recording function, media transmission and processing protocol are realized.
  • Application layer: The specific APP application part of the development, our company delivers DEMO APP, which is integrated with the customer application and can be targeted development. Users can refer to the modification or directly. It depends on bjcast_sender_lib-1.0.20.aar.

2.2 SDK deliverables

  • bjcast_sender_lib-1.0.20.aar is an Android Module
  • DEMO APP source code, ScreenShare APP based on bjcast_sender_lib-1.0.20.aar, provided as a reference implementation to customers
  • SDK Interface document

3 Interface

bjcast_sender_lib-1.0.20.aar contains two parts of the external interface.

  • The first part of the interface is the session control part. Defined in the BJCastSender class
  • The second part is the callback interface, which is defined in the BJCastSenderListener interface and requires the client to implement the relevant interface.
    Applications should not use interfaces in any other class.

3.1 Control Interface Description

3.1.1 BJCastSenderListener

BJcastSenderListener is an interface class, which is a callback interface, which is called by the SDK JNI layer and needs to be implemented by the client. The BJCastSender class defines the interface that the BJCast sender protocol stack provides for application layer calls. BJCastSender class interface description initialization function public boolean init(Context context, BJCastSenderListener callback, BJCastSenderPara para)

  • Input
    • Context: context
    • callbackBJCastSenderListener is implementation class implemented for the client.
    • BJCastSenderPara: Transmitter information, where the parameters are:BJCastSenderPara(String name, TranType tranType, PlayMode playerMode, int frameRate, int bitrate, Resolution resolution,Boolean autodiscover)
  • Description:

    This interface will call the JNI interface to initialize the BJCast Transmitter Protocol Stack.

3.1.1.1 Creating a Screening Session
public  void createCtrlSession 

(String serviceIP, int port,String name, MediaProjection mediaProjection,

 String pass);
  • Input:
    • serviceIP:Receiver IP address
    • port:Receiver service port
    • name:Identifies the name of the transmitter, which can be used to display on the receiving end
    • mediaProjection:Android 5.0 or above Android MediaProjection instance created through the screen recording interface, specific reference demo.
    • pass:Screen PIN code, if it does not support pin code, set to empty string
    • return : 0
  • Description:
    This function is used to initiate a Bjcast projection
3.1.1.2 End the screencast session

public native void destroyCtrlSession()

  • Input: null
  • Description: End the screencast session
3.1.1.3 Automatically search for the receiving end inside the LAN

public void discoverRender(String localIp)

  • Input:
    • localIp: The transmitting end IP
  • Description:
    The SDK will use this IP address to send probe information, and the BJCast receiver will respond to the probe response when it receives the probe message.
    If the probe is successful, the onDiscoverRender method in BJCastSenderListener will be called.
3.1.1.4 Detecting Whether an IP Address Is Available on the Receiving End

public void probe(String peerIp)

  • Input:
    • peerIp: Peer device IP
  • Description

    The SDK sends probe information to the peer IP address, and the BJCast receiver receives the probe message and responds to the probe response.
    If the probe is successful, the onDiscoverRender method in BJCastSenderListener will be called.

3.1.1.5 CodeRate setting

public void setConfBitrate(int confBitrate)

  • Input:
    • confBitrate: Coderate, such as 2000000 for 2mbps
3.1.1.6 Resolution setting

public void setConfResolution(String confResolution)

  • Input parameters:
    • confResolution: Resolution, format “width high” example: “1920 1080″ means 1080P. The average mobile phone supports 1080P and 720P.
3.1.1.7 Play mode setting

public void setPlayerMode(PlayMode mode)

  • Playmode:
    • Real-time mode: Low latency during receiver-to-screen processing
    • Normal mode: The receiver processing has a higher latency than real-time mode but better smoothness
    • Audio mode: Suit for video, best smoothness but high latency
3.1.1.8 Transfer Mode Settings

public void setTranType(TranType tranType)

  • Input: transfer mode, divided into “TCP”,“UDP”
3.1.1.9 Deinitialize

public void uninit()

3.1.2 BJCastSenderListener Interface Description

3.1.2.1 Screening failure notification interface

public abstract void onCreateCtrlSessionFailed(int err);

  • Input:
  • err: error code
  • Description:

    After launching the screen failed, the SDK notifies the application that the screen failed.
    The meaning of the error code:

    • E_OK = 0;
    • E_FAILURE = -1;
    • E_NULL_POINTER = -2;
    • E_NOT_INITIALIZED = -3;
    • E_ALREADY_INITIALIZED = -4;
    • E_NOT_IMPLEMENTED = -5;
    • E_NETWORK_FAILURE = -6;
    • E_TIMEOUT = -7;
    • E_INVALID_PARAMETER = -8;
    • E_AUTHENTICATION_REQUIRED = -9;
    • E_AUTHENTICATION_FAILED = -10;
    • E_DECODE_MESSAGE_FAILURE = -11;
    • E_ENCODE_MESSAGE_FAILURE = -12;
    • E_CALL_NOT_FOUND = -13;
    • E_CALL_REJECTED = -14;
    • E_CALL_NO_SCREEN_RESOURCE = -15;
    • E_AUTH_FAILED = -16;

The common error code is
-6 the receiving end fails, check if the network is correct.
-14 connection refused
-16 Screening code is incorrect

3.1.2.2 Detecting the Receiver Notification Interface

onDiscoverRender(BJCastRender render);

You can call the BJCastRender.get() method on this interface to get the IP, port, devicename, mask, etc. of the discovered device.
Device IP: Get device IP using bjCastRender.getIp()
Device port number: Use bjCastRender.getPort() to get the device port number

device name : Use bjCastRender.getDeviceName() to get device name
The remote device needs to screen the pin code: judge whether the pin code is needed by judging ((bjCastRender.getMask() & 0x01) == 0x01) (mask & 0x01 == 0x01 need pin code mask & 0x01 == 0x00 does not require a pin code)

3.1.2.3 Stop Recording Notification Interface

public abstract void onCaptureStop();

Stop recording notifications. This interface will be called when the screen is over.

3.1.2.4 Start Recording Notification Interface

public abstract void onCaptureStart();

Start recording notifications. This interface will be called when the screen is started.

3.1.2.5 Receive device information removal

The interface is called when the receiving device restarts or disconnects the wifi, and the device name is modified.

public abstract void onLostRender(BJCastRender render);

4 Import arr

The import steps are as follows:

(1)Put the aar file in the libs directory under the app directory, and create a new libs directory if the directory does not exist;

(2)Add following in the app’s build.gradle file

repositories {
        flatDir {

dirs 'libs'
        }
    }

(3)After that, you only need to add gradle dependency.

dependencies {
    compile(name:'bjcast_sender_lib-1.0.20', ext:'aar')
  }