1. Wireless Display SDK of Miracast

1.1 Purpose

It is used to guide the developers who use the Miracast SDK also called WiDi SDK run on Android of BiJie to develop and test.

1.2 Target Readers

This document is applicable to the developers who develop the receiver of Android miracast.

1.2 Definition Of Abbreviations

AbbreviationEnglishChinese
MiracastThe wireless display standard is based on Wi Fi direct, developed by the Wi Fi Alliance in 2012.

2. Content Scope

2.1 Function

This SDK can accept the screen from miracast on Android and miracast on windows 10 or 8 and WiDi and windows 10 or 8 , and provide interfaces for the application layer to call processing.

2.2 SDK Framework

BJMiracast Receiver SDK is generally divided into two layers

  • cast_base_lib-1.0.20-release.aar: It is a Android Module,It defines the interfaces for the MediaChannel class.

  • bj_miracast_lib-1.0.19-release.aar: It is a Android Module,It defines the interfaces for the MiraProxyBaseImp, MiraProxyModule and JNI。 In principle, the application should not modify the contents of cast_base_lib-1.0.20-release.aar and bj_miracast_lib-1.0.19-release.aar

2.3 Demo Implementation Of SDK

Castdemo is a reference implementation of the receiver. It implements the functions of the receiver based on bj_miracast_lib-1.0.19-release.aar and cast_base_lib-1.0.20-release.aar. MiraProxyModuleImp implements the MiraProxyBaseImp class and realizes the control of the Miracast audio session. MiraRenderChannel implements the MediaChannel class and realizes the processing of the Miracast audio session.

2.4 SDK Deliverables

  • SDK libraries(Two AAR files)

  • DEMO source code

  • SDK interface document

3. Interface

The interfaces are mainly defined in the MiraProxyModule, MiraProxyBaseImp and MediaChannel classes.

The MiraProxyModule class provides interfaces for initializing SDK, deinitializing SDK, and stopping a session.

The MiraProxyBaseImp class is an interface class, which needs to be implemented by the user. The SDK informs the user program of the start and end of miracast screen throwing session through the interface class. The user program needs to create corresponding MediaChannel implementation classes and corresponding player applications according to different session types.

The MediaChannel class is an interface class, which needs to be implemented by user program. Through this interface class, the SDK informs the application program of control events such as audio and video data, volume control, video rotation, etc., and the application program processes them in the corresponding player.

Users need to implement the relevant interfaces of the MediaChannel class and the MiraProxyBaseImp class, or refer to the demo source code provided by our company.

3.1 Interface of the MiraProxyModule class

3.1.1 setProxyImp

public void setProxyImp(MiraProxyBaseImp proxyImp);

  • Input: An interface instance of the MiraProxyModuleImp class implemented by the user.

3.1.2 init

public native boolean init(Properties var1); The init method of the MiraProxyModule class initializes the miracast receiver module. The MiraProxyModule object should be designed to have only one global when the app is started for initialization.

The return value is 1, indicating successful initialization. The return value is 0, indicating failed initialization.

3.1.3 fini

public native void fini(); The fini method of the MiraProxyModule class deinitializes the miracast module. Called when the app destroys the miracast receiver service.

3.1.4 stop a miracast session

public void hangup(int channelid);

  • Input: The channelid is the ID of the corresponding MediaChannel created by the reqMediaChannel method of the MiraProxyBaseImp class.

3.1.5 Keyframe request

public void reqKeyFrame(int channelid);

3.1.6 Delay keyframe request

public void advReqKeyFrame(int channelId);

3.2 Interface in the MiraProxyBaseImp

3.2.1 Interface for Session access

public abstract MediaChannel reqMediaChannel(MediaChannelInfo var1, UserInfo var2, int var3)

  • Input: Session information,Describe business type. MediaChannelInfo: Describes the type information of the current session. UserInfo: Describes the IP, device model, device name and other information of the sender. sessionId: Describes the session id of the current session.

  • Output: Created an object of the MediaChannel class. This is a callback interface. When the miracast protocol stack finds that there is session access, the JNI layer will actively call this interface. The application layer needs to implement the relevant logic, which needs to be implemented in the implementation class of the MiraProxyModuleImp class of the customer. The specific implementation can refer to the demo source code.

3.2.2 stop a session

public abstract void hangup(int var1);

  • Input: The channelid is the ID of the corresponding MediaChannel created by the reqMediaChannel method of the MiraProxyBaseImp class.

3.2.3 notify for no data

public abstract void noMediaNotify(int var1)

  • Input: The channelid is the ID of the corresponding MediaChannel created by the reqMediaChannel method of the MiraProxyBaseImp class.

3.2.4 keyframe request

public abstract void reqKeyFrame(int var1);

  • Input: The channelid is the ID of the corresponding MediaChannel created by the reqMediaChannel method of the MiraProxyBaseImp class.

3.3 Interface in the MediaChannel class

When the session is established successfully, the protocol stack will call the corresponding interface in the MediaChannel class to call back the data or get the status. The following interfaces need to be implemented in the MediaChannel subclass. Customers need to implement the following interfaces according to their own actual situations. The important interfaces in the MediaChannel subclass are as follows, and the miracast receiver needs to focus on the following interfaces.

3.3.1 Set window handle

public void setSurface(Surface surface); Configure the window handle for MiraRenderChannel output. The surface is obtained by the player view created by the user. Refer to the implementation in demo.

3.3.2 audio data callback

public void onAudioFrame(byte[] buffer, int len, long ts); JNI returns audio data. Audio is data in PCM format. User needs to process audio data. For specific implementation, please refer to demo source code in SDK. Buffer is the audio data array, len is the data length, ts is the time stamp.

3.3.3 video data callback

public void onVideoFrame(byte[] buffer, int len, long ts); Mirror video data interface, which spits out H264 video data, the user needs to decode and play. Buffer is the audio data array, len is the data length, ts is the time stamp. For specific implementation, please refer to demo source code in SDK.

3.3.4 Bound buffer pool size

public ComBuffer reqBuffer(int size)

3.3.5 open MediaChannel

public abstract boolean open(); User is required to implement specific the MediaChannel functions for ‘open’. Refer to the implementation in demo.

3.3.6 close MediaChannel

public abstract void close(); User is required to implement specific the MediaChannel functions for ‘close’. Refer to the implementation in demo.

3.3.7 Set up audio information

public void notifyTrackCodecInfo(int trackId, AudioTrackInfo audioTrackInfo); Set up audio information through AudioTrackInfo.

4. Demo Explain

In demo, MiraProxyModuleImp implements interfaces of the MiraProxyBaseImp class and the methods of the reqMediaChannel class. In reqMediaChannel, the implementation of the MediaChannel corresponding to the session type is created, the view related to playback is started, and the surface for playback is created. MiraRenderChannel implements the relevant functional interfaces in the MediaChannel class.

5. How to use SDK for customers

  1. Import aar, create a new libs directory in the app directory and put aar files in this directory, then add the following code above and inside dependencies in build.gradle(app,Refer to demo.):

repositories{ flatDir { dirs 'libs '} }, 
compile (name: 'bj_miracast_lib-1.0.19-release.aar', ext: 'aar'),
compile (name: 'cast_base_lib-1.0.20-release.aar', ext: 'aar')
  1. To implement the interface of the MiraProxyBaseImp class, refer to MiraProxyModuleImp.java. The interface of the reqMediaChannel class returns an instance of the customized implementation class of the MediaChannel class and starts the playback interface.

  2. Implement relevant functional interfaces of the MediaChannel class. Refer to MiraRenderChannel

  3. To realize its own playback interface, refer to the implementation of view in the view package, and set the surface of the playback interface to the MediaChannel class.

About BiJie

BiJie is a high-tech R&D enterprise focusing on the wireless display and interactive. It is committed to provide leading wireless display and interactive product and solution of smart meeting room and classroom. 

BiJie can supply Wireless Display SDK such as Miracast, WiDi, Airplay, DLNA, Google Cast and BJCast.

At present, BiJie Networks has established cooperation with hundreds of well-known companies and institutions in the world, including Haier(SEHK1169) , JD.com(NASDAQJD) , 58.com(NYSEWUBA), PetroChina(NYSEPTR), MCC, Accenture(NYSEACN), Osram(FWBOSR) and many other industry-level head enterprises.

Categories: Document of SDK