Review Record

Version Recorder Date Judges Content
0.9 吴刚 2018/4
1.0 吴刚 2018/11

Filing Approval

Version Approver Date Approval confirmation
[TOC]

 

1 Overview

1.1 purpose

Used to guide the development of Windows sender applications using the BJ wireless projection screen SDK

1.2 Reader object

This document is intended for developers and testers of Windows sender applications.

1.3 Abbreviation definition

Abbreviated name Chinese
BJCast BJ wireless projection screen protocol

2 Basic concept

2.1 Sender in wireless projection system

The sender end is the video source of the wireless projection system. It finds the receiving device through the discovery protocol, initiates the screening session through the BJCast protocol, and is responsible for recording the local screen video and sound of windows , which is encoded and transmitted to the receiving end for playing and rendering. .

2.2 Receiver in wireless projection system

The receiving end is responsible for accessing the wireless projection session initiated by the sender end, receiving the audio and video data of the sender end, and decoding and presenting.

Receiver type :

BiJie’s projection hardware box: BiJie series projection equipment developed by BiJie Networks . The BJcast ‘s receiving end function is realized, and the BiJie network has a custom device discovery protocol.

An application or hardware device developed based on the BJCast receiver SDK : The screencast can be initiated using the BJCast projection protocol.

2.3 Discovery protocol

When the sender end initiates the screening session to the receiving end, it is first necessary to determine the communication IP and communication port of the receiving end . The discovery protocol is used to automatically discover the receiving device at the wireless projection system.

A discovery protocol is predefined in the BJCast SDK and can be used to discover BJCast receivers on the same LAN .

Customers can also customize the screencasting protocol according to the needs of their business systems.

2.4 BJCast wireless projection protocol

The BJCast wireless projection protocol includes the BJCast Discovery Protocol and the BJCas Screening Protocol. The interface of the BJCast discovery protocol will be described in 4.2 , and the BJCas projection protocol is described in 4.3 .

 

3 Scope

3.1 BJCast Screening Application Description

The overall framework is divided into two layers

BJCast SDK : Implements the screencast control protocol and media transport and processing protocol components. Use c / c ++ development, provision of services in the form of dynamic link libraries.

Application layer: The specific application part of development, our company delivers DEMO source code, specifically integrates with customer application, and can do targeted development.

This document mainly describes the interface of the BJCast SDK .

3.2 SDK deliverable

  • Dll library
  • head File
  • SDK interface documentation

4 interface

The API interface of the BJCast SDK includes the following sections:

  1. Discovery Protocol Interface: Implemented the BJCast Discovery Protocol. Refer to 4.2 , and its related interfaces are defined in the ControlManagerIntf class.
  2. screen projection protocol interface: Screening session control interface provided by SDK . Refer to 4.3 , and its related interfaces are defined in the ControlManagerIntf class.
  3. user callback interface: The ControlManagerNotify class in the SDK defines the notification callback interface related to the screencast session, and the user program needs to implement the interface. Refer to 4.4 .

The above interfaces are all defined in ControlManagerIntf.h .

4.1 SDK initialization

ControlManagerIntf *createControlManager(ControlManagerNotify *);

  • Function :

    Create a BJCast SDK management instance

  • Input:

    ControlManagerNotify *: the user-implemented ControlManagerNotify interface instance .

  • Output:

    null

  • Return parameters:

The ControlManagerIntf instance , all subsequent screencast protocol interfaces need to call the member method of the instance . The application needs to maintain the instance. The instance is destructed when the application exits.

  • Other:

    This function cannot be called multiple times. Only one ControlManagerIntf instance is allowed globally .

4.2 BJCast discovery protocol interface

When selecting the discovery protocol, the user can select the BJCast discovery protocol that comes with the SDK , or choose not to enable the BJCast discovery protocol. Currently, the BJCast discovery protocol can only find the receiving device in the same LAN subnet. The application scenarios such as inter-LAN are not applicable.

Users can decide whether to enable the BJCast discovery protocol according to their own business needs . For example:

A group needs to integrate the screen-casting function into the existing office management system, and manage the screen-casting box through a unified management platform. In this scenario, the customer can customize the management and discovery protocol of the screen-casting device. The existing management platform uniformly manages the projection screen equipment.

If the user does not need to use the BJCast discovery protocol, then there is no need to care about this part of the interface.

The BJCast discovery protocol interface is defined in the ControlManagerIntf class. The following interfaces are member functions of the ControlManagerIntf class. The user needs to use the instance returned by createControlManager to call the relevant interface .

4.2.1 Start automatic discovery

S32 startServerDetecting()

  • Features:

    After the transmitter invokes the interface, the SDK internally sends a probe message periodically to detect whether there is a BJCast receiver. After receiving the probe message, the BJCast receiver will reply to the probe response message. After receiving the probe response message, the BJCast transmitter notifies the discovered receiver information through the onServerDetected () interface.

  • Input:

    null

  • Output:

    null

  • return value: 0 : success

4.2.2 Stop automatic discovery

S32 stopServerDetecting()

  • Function :

    After the transmitter invokes the interface, the SDK will stop automatically discovering the receiving device.

  • Input :

    null

  • Output :

    null

  • return value : 0 : successful

4.2.3 Probe receiver

S32 probe(const ServerInfo &info)

  • Function :

    After the IP , PORT, etc. information is known , a probe packet is sent to the port to detect whether the BJCast receiver service is running on the IP and the port . Can be used to detect whether the receiving end is currently running normally. After receiving the probe response message, the BJCast transmitter notifies the discovered receiver information through the onServerDetected () interface.

  • Input:

    null

  • Output parameters:

    null

  • return value: 0 : successful

4.3 BJCast projection interface

The BJCast projection protocol interface is defined in the ControlManagerIntf class. The following interfaces are member functions of the ControlManagerIntf class. The user needs to use the instance returned by createControlManager to call the relevant interface .

4.3.1 Login receiver

S32 login(const S8 *ip, U16 port, Const S 8 * Pin = NULL)

  • Features:

    Used to log in and connect to the receiving end.

  • Input:
    • Ip: Receiver IP address
    • Port: BJCast service port. By default, the BJCast receiver uses the port 8188 to provide the screen access service.
    • Pin : Screen PIN code. If there is no PIN code, this parameter will input NULL or an empty string. The default is NULL .
  • Output:

    null

  • return value:

    0 : Success Other: Failure

4.3.2 Set the screen mode

S32 setMirrorMode(ControlManagerMirrorMode mode)

  • Function :
  • Set the screen mode , The screencast modes are as follows :
CMMM_Custom, // normal mode 

CMMM_Screensharing, // Office mode, suitable for playing PPT applications , such as low latency 

CMMM_RealtimeVideo, // Video mode , showing smooth playback 

CMMM_Performance / / high performance mode , showing a higher frame rate 
  • Input:

    null

  • Output:

    null

  • return value: 0 : successful

4.3.3 Resolution change notification interface mode

S32 onDisplayChange()

  • Function:

    The application monitors the desktop resolution change, etc., and needs to call the interface to notify the SDK to process accordingly.

  • Input:

    null

  • Output:

    null

  • return value: 0 : successful

4.3.4 Get the number of screens

int screenCount()

  • Function:

    Get the number of the recording screen, typically 1, then if a dual display of 2

  • Input:

    null

  • Output:

    null

  • return value:

    The number of screens is generally 1 , if it is double display, it is 2

4.3.5 Setup screen

void setScreen(S32 screen)

  • Function:

    Set which screen is recorded on the current transmitter , and this interface can be dynamically activated. The default is the main screen.

  • Input:
    • Screen : the screen index , which has a value range of 0(screenCount() -1)
    • When there are multiple screens, 0 is the main screen and 1 is the auxiliary screen.
  • Output parameters:

    null

  • return value:

    null

4.3.6 Get the number of audio collection interfaces

S32 micphoneCount()

  • Function:

    Get the number of audio collection interfaces

  • Input:

    null

  • Output:

    null

  • return value:

    Number of audio collection interfaces, the value range is >=0

4.3.7 Get the audio capture interface name

void micphoneName(S32 index, char name[128])

  • Function :

    Get the name of an audio capture device

  • Input :
    • Index : the audio capture device index , which has a value range of 0( micphoneCount()-1)
  • Output :
  • Name : the name of the audio capture device
  • return value:

    null

4.3.8 Select audio collection port

void selectMicphone(S32 index)

  • Features:

    The screencast function is used to select the audio data of a specific audio capture interface.

  • Input:

    Index : the audio capture device index , which has a value range of 0( micphoneCount()-1)

  • Output:

    null

  • return value:

    null

4.3.9 Launch screen

void startMirror()

  • Features:

    The screencast function is used to select the audio data of a specific audio capture interface.

  • Input :

    null

  • Output :

    null

  • return value:

    null

  • other:

    If the launch failed, the application notification interface onCallEnd will notify the application of the end of the screen session.

4.3.10 End screen

void stopMirror()

  • Features:

    End the screencast session

  • Input parameters:

    Index : audio capture device index

  • Output parameters:

    null

  • return value:

    null

4.3.11 Apply full screen

S32 requestFullscreen()

  • Features:

    Apply for full screen. If the receiving end is a BTS screen and the multi-channel projection function is implemented, in the case of multi-channel projection, the full screen can be applied through the interface, and the corresponding screen of the sender end will occupy all the screens at the receiving end.

  • Input :

    null

  • Output :

    null

  • return value:

    0 : Success

    Other : Failure

  • other:

    If there is no multi-channel transmitter that simultaneously screens to a receiver, the transmitter does not need to pay attention to this interface. If the full-screen control logic is not implemented on the receiving end, the interface may not take effect.

4.3.12 Exit Full Screen

S32 exitFullscreen()

  • Features:

    Exit Full Screen. If the receiving end is a BTS screenbox and the multi-channel projection function is implemented, when the multi-channel projection mode has been applied and the full-screen interface has been applied, the full screen can be exited through the interface, and the corresponding screen of the sender end will be at the receiving end. Exit the full screen state.

  • Input :

    null

  • Output :

    null

  • return value:

    0 : Success

    Other : Failure

  • other:

    If no multi-channel transmitter is simultaneously projected to a receiving end scene, the sender end does not need to pay attention to this interface. If the full-screen control logic is not implemented on the receiving end, the interface may not take effect.

4.4 Application notification interface

The application notification interface is defined in the ControlManagerNotify class. The following interfaces are member functions of the ControlManagerNotify class. The user needs to implement the interface and pass in its instance when the SDK is initialized. The member method of the instance is called inside the SDK to notify the application session state.

4.4.1 Found to the receiver notification

Void onServerDetected(ServerInfo *info)

  • Features:

    After discovering the receiver , Notify the application layer interface , May search to multiple receivers, the function will be called multiple times.

  • Input :

    ServerInfo * : Receiver’s IP address , service port , version number, etc.

  • Output :

    null

  • return value:

    null

  • other:

    If the user does not enable BJCast’s default discovery protocol, then do not care about the interface.

4.4.2 Screening end notification

void onCallEnd(const Reason &)

  • Features:

    Notify the end of the current screencast session. The application needs to perform corresponding processing according to the interface, such as ending the bottom projection session and updating the interface state.

  • Input :
    • Reason : Reason is the reason for the end of the screencast session . Refer to Chapter 6 Error Code Description.
  • Output :

    null

  • return value:

    null

4.4.3 Full screen notification interface

void onCallUpdate(bool flag )

  • Features:

    Full screen notification interface status , Tells the reflector whether it is in full screen state. The application needs to update the interface state and full screen control related state based on this status.

  • Input :
    • flag : true indicates that the current transmitter screen is in full screen state, false indicates that the current transmitter screen exits full screen state.
  • Output :

    null

  • return value:

    null

  • other:

    If no multi-channel transmitter is projected to a receiving end scene at the same time, the sender end does not need to pay attention to and implement this interface. If the receiver does not implement multi-screen projection and full-screen control logic, the interface may not take effect.

5 The simplest DEMO code description

#include "ControlManagerIntf.h" // Contains ControlManagerIntf.h  

#include <string>
#include <stdint.h>

#define TEST_ServerDetecting 1#define TEST_ServerDetecting 1 

class CMN : public ControlManagerNotify// CMN class implements ControlManagerNotify interface 
{
public:
    void onServerDetected(ServerInfo *info) // Return to the receiving end information will be returned through this interface 
    { 
        printf("%s %s %d %s %u\n", info->serial, info->ip, info->port, info->name, info->version);
    } 

    void onCallEnd(const Reason &reason) 
    { // End of session 
        cm -> stopMirror (); / / whether the SDK internal projection resources 
    } 

    void onCallUpdate(bool fullscreen) {}

    ControlManagerIntf *cm; 
}; 

 
int main(int argc, char **argv)
{ 
    std::string svc_ip("192.168.9.147"); // Specify the receiving IP 
    if (argc > 1)If (argc > 1) 
    {
        svc_ip.assign(argv[1]);
    } 

    printf("svc_ip is %s\n", svc_ip.c_str());

    uint16_t svc_port = 8188; // Receiver port 
    CMN c;

    ControlManagerIntf *cm = createControlManager(&c); // SDK initialization 

#if TEST_ServerDetecting // Enable when the macro switch is 1 . 
    ServerInfo i;ServerInfo i; 
    i.port = svc_port; 
    strcpy(i.ip, svc_ip.c_str());

    for (;;)
    { 
        cm->startServerDetecting();
        // cm->probe(i); 
        System("pause"); 

        break; 
    } 
#endif 

    cm->setMirrorMode(CMMM_Performance); // Set to video mode 
    
    // Access the receiving end, fill in "" or NULL without PIN code , otherwise fill in the actual PIN code 
    S32 ret = cm->login(svc_ip.c_str(), svc_port,""); 

    if (ret != E_OK)
    {
        printf("login svc_ip %s failed\n", svc_ip.c_str());

        delete cm; 
        return 0;
    } 

    //Start to launch screencast 
   	cm->startMirror();

    system("pause");
	
    // End the screen 
    cm->stopMirror();Cm->stopMirror(); 

    delete cm;//program exits, release the SDK control instance 
    return 0;
} 

Referring to the demo , the typical process of a screencast is as follows:

  • The user needs to implement the ControlManagerNotify interface, such as CMN , whose instance is used as the input to the createControlManager method .
  • Call the createControlManager method to initialize the SDK and get the ControlManagerIntf instance.
  • Call the login interface to initiate the connection session of the receiver
  • Call startMirror to launch the screen
  • Call stopMirror to end the screen
  • Destruct the ControlManagerIntf instance and exit the application

6 Error code description

Error code value description Scene
0 success Normally ending the screen
-1 Unknown reason failed
-6 Failed to connect to the receiving end, check if the network is correct network anomaly
-7 Session timeout After Login , the screencast session is not initiated within 15 seconds, and a timeout occurs.
-14 Screening session rejected Receiver rejects screencast session access
-15 The receiving screen is full and cannot be accessed. The receiving screen is full and access is not allowed.
-16 Screening code is incorrect Screening code error