to work for a new company, the first project received was a video conferencing system, based on Anychat Two-time development, downloaded on the official website Demo after understanding, found missing a Send file function, so oneself in the original Demo modified to add a Send file function.
Anychatwith buffer and file transfer function, file transferAPIInterface:Brac_transfile,A,Btwo when the user logs on to the server, the file transfer can be usedAPIinterface to transfer files whenAUseAPIInterface:Brac_transfiletoBwhen you send a file,Bwhen a file is received, it triggersBthe callback function:File Transfer callback function.
Transfer File Interface Description:
int transfile (int userid, String filepath, int wparam, int lparam,int flags, Anychatoutparam outparam);
Function: Transfer files to a specified user
return Value: 0 indicates a successful function call, otherwise an error code
Parameters:
userid: Target user number, only for one user, cannot be -1 (Everyone)
filepath : Local file name, with path
WParam : Included Parameters 1 for upper-level application expansion
LParam : Included Parameters 2
DwFlags : Special function mark, reference: " Transbufferex " Method
Outparam : If the function call succeeds, the kernel outputs the task through this parameter ID
In use, the accompanying parameters and special function identification are reserved parameters, do not need to use, the assignment value of 0 is possible. Initially set to NULL when setting the Outparam parameter, the program has an exception, after reviewing the official documentation, it is found that when the function call succeeds, the kernel sets the task ID (TaskId) through the Outparam Setintvalue method.
B two tasks are required for the user to implement the receive file transfer callback function.
1 , implementing the Anychattransdataevent interface in classes that need to be received
2 , set callback receive function Settransdataevent
(Note: anychattransdataevent and Settransdataevent are APIs provided by Anychat)
File Transfer callback function Description:
Public void onanychattransfile (int dwuserid, String filename,string tempfilepath, int dwfilelength, int wParam, int lParam, int DW TASKID);
Parameters:
Dwuserid : User ID , indicating that the sending user
FileName : File name (with extension, no path included)
TempFilePath: After receiving is complete, theSDK Temporary files saved locally (full path included)
Dwfilelength : Total file length
WParam :
LParam :
Dwtaskid : The task number that corresponds to the file
The main code is as follows, and the comments are quite clear. Refer to the "Anychat forAndroid SDK Development Manual" for details. (anychat for Android SDK:http://www.anychat.cn/download.html)
Roomactivity.java
During transmission, you can also use the Querytranstaskinfo Interface Query Transfer task related information, need to user-descendants ID and Tasks ID and other parameters.
Query Transport task related information interface Description:
int querytranstaskinfo (int Userid, int taskid,int infoname, Anychatoutparam outparam);
Function: Query the information related to the transfer task, such as transmission progress, transmission status, transmission code rate, etc.
return Value: 0 indicates a successful query, otherwise an error code
Parameters:
Dwuserid : Task Initiator user number (not transfer target user number)
Dwtaskid : task number that needs to be queried
InfoName information code that needs to be queried (see Schedule for notes)
Outparam : if the function call succeeds, the kernel outputs the query result by this parameter
. Querytranstaskinfo ( ,anychatdefine.
anychatdefine. brac_transtask_status 3 outparam.getintvalue () Get task status value, 2 3
a detailed reference to the anychat for Android SDK Development Manual "
This article is from the "Audio and video" blog, be sure to keep this source http://2343338.blog.51cto.com/2333338/1578955
Android mobile video Conferencing system development