Nowadays, most people communicate with each other through instant messaging tools, which have the basic functions of file transmission. This function is used after self-development through instant messaging tools. the following uses AnyChat interactive development platform, which is a leading audio and video technology in China, as an example to implement the file transmission function. AnyChat SDK V4.1.0.1 and later versions support file transmission speed limiting. By default, AnyChat's file transmission and buffer transmission automatically detect available network bandwidth and perform network transmission based on the principle of "transmission at the shortest time and speed, this principle can adapt to most applications. However, in some applications, some bandwidth needs to be reserved for other modules, and AnyChat file transmission does not require all network bandwidth, in this case, the speed limit function can be used. The speed limit function of AnyChat file transmission is to set the upload speed of local files and control the total upload speed. if the speed limit is set to 500 kbps, when one file is transmitted simultaneously, the maximum upload speed is 500 kbps. if two files are uploaded simultaneously, the maximum upload speed of each file is 250 kbps. BRAC_TransFile,BRAC_TransBufferExBoth APIs are subject to the transmission speed limit function. The transmission speed limit interface is defined as follows: 1. // transmission buffer, maximum file bit rate control (the parameter is int type, 0 is not limited, transmission at the fastest speed [default], otherwise it indicates the maximum bit rate, unit: bps) 2. # defineBRAC_SO_NETWORK_TRANSBUFMAXBITRATE 46 By default, the transmission speed limit function is disabled on the AnyChat platform. to enable the function, refer to the following code (the call is valid after SDK initialization is successful and can be called as needed and dynamically adjusted ): 1. // Set the upload speed to 500 kbps (62 kBps) 2. DWORD dwMaxUpRate = 500*1000; 3. BRAC_SetSDKOption (BRAC_SO_NETWORK_TRANSBUFMAXBITRATE, (constchar *) & dwMaxUpRate, sizeof (DWORD )); To cancel the transmission speed limit function, refer to the following code: 1. // cancel the speed limit function 2. DWORD dwMaxUpRate = 0; 3. BRAC_SetSDKOption (BRAC_SO_NETWORK_TRANSBUFMAXBITRATE, (constchar *) & dwMaxUpRate, sizeof (DWORD ));
|