Talk about the development of video chat room several views?

Source: Internet
Author: User

Now online video chat room, video conference software, visual IP telephony hardware everywhere, do you want to do a play? This kind of hardware is nothing more than video plus network built. If you understand the video capture and network transmission skills, it is difficult to fail you. This article describes in detail how to use the SDK that outsiders need to develop video chat rooms.
First, a brief introduction of video chat room development technology development process
1, c/s structure of video chat room hardware or plug-ins. This is the earliest video chat room production skills, has been eliminated.
2. Video chat room hardware or plug-in form. This is the number of years before and before many heavy video chat items means secondary application skills. is also a lot of medium-sized video chat room making use of skills.
3, based on the form of peer-to +c/s form mixed. For the moment, the most functional skill set-up form. such as QQ chat software, such as video chat function. It is the use of C/S form under the condition of slow progress in the situation of the peer network link.
4, pure web, based on the video server build b/s Construction video chat room website. This is the first 1-2 years of video skills in the secondary study location. This form is precisely the C/s structure that is being used on the website. And the first stage of C/s structure function difference is not big, but the strength of the cross-balcony disadvantage. Because its function is helpless and 2nd, the 3rd stage function compares, but incurs the research more, but the application is few, the goods are few.
5, pure web based on the video service device b/s structure + plus flash peer-to structure. This stage is the main research location of the video function in front of you. However, the immediate flash peer-to complete data dissemination, forwarding and other performance, the adoption of 1 collective and multi-collective simultaneous construction of the form of peer-connected transmission data, because, when the population compared to more than the time, this form will be very large consumption of the bandwidth of the depositors. Because, this form demand and B/S form stop collocation. When the population of the time, the use of video services, when the population of less time, the use of peer.
Then it will be used to open up the machine and what words to open up the introduction, in order to allow themselves to better develop my needs and audio and video communication related to the fragmented. I introduce myself to introduce how to use an SDK back and forth to explore, I can understand the development of change guide it!
first, the initialization ofUse
The whole is the first to be implemented, to install the SDK for some of the lines, including the installation of the expected callback dependent variable, install the SDK components, installation can produce birthday records, etc., general initialization of the Anychat SDK code as follows (c + +):
1.01.//Opening (open) SDK Diary recording performance
2.02.brac_activecalllog (TRUE);
4.04.//Install SDK Center components in the program
5.05.CHAR Szcoresdkpath[max_path] = {0};
6.06.GetModuleFileName (null,szcoresdkpath,sizeof (Szcoresdkpath));
7.07. (STRRCHR (szcoresdkpath, ' \ \ ')) [1] = 0;
8.08.brac_setsdkoption (Brac_so_coresdk_path,szcoresdkpath,strlen (Szcoresdkpath));
9.10.//according to the second parameter of BRAC_INITSDK: Dwfuncmode, to inform the SDK how to solve the relevant mission (overview, please refer to the development document)
11.DWORD Dwfuncmode = brac_func_video_cbdata brac_func_audio_autoplay brac_func_chkdependmodule BRAC_FUNC_AUDIO_ Volumecalc Brac_func_net_supportupnp Brac_func_firewall_open
One. 12.brac_func_audio_autovolume Brac_func_config_localini;
13.BRAC_INITSDK (This->getsafehwnd ()/*null*/,dwfuncmode);
13.15.//installation Video Temporary data destruction
16.CHAR Szrecorddirectory[max_path] = {0};
17.::getmodulefilename (Null,szrecorddirectory,max_path);
16.18. (STRRCHR (szrecorddirectory, ' \ \ ')) [1] = 0;
19.strcat (Szrecorddirectory, "Record");
20.brac_setsdkoption (Brac_so_record_tmpdir,szrecorddirectory,strlen (szrecorddirectory));
19.//installation video Data quality parameters
23.DWORD dwvideobitrate = 200 * 1000; 200kbps
24.brac_setsdkoption (BRAC_SO_RECORD_VIDEOBR, (PCHAR) &dwvideobitrate,sizeof (DWORD));
25.DWORD dwaudiobitrate = 96 * 1000; 96kbps
26.brac_setsdkoption (BRAC_SO_RECORD_AUDIOBR, (PCHAR) &dwaudiobitrate,sizeof (DWORD));
24. Installation snapshot temporary data destruction
25.CHAR Szsnapshotdirectory[max_path] = {0};
26.GetModuleFileName (Null,szsnapshotdirectory,max_path);
(STRRCHR (szsnapshotdirectory, ' \ \ ')) [1] = 0;
28.strcat (Szsnapshotdirectory, "SnapShot");
29.brac_setsdkoption (Brac_so_snapshot_tmpdir,szsnapshotdirectory,strlen (szsnapshotdirectory));
30. Installing the SDK Temporary information
31.CHAR Sztemppath[max_path] = {0};
32.GetModuleFileName (Null,sztemppath,max_path);
(STRRCHR (sztemppath, ' \ \ ')) [1] = 0;
34.strcat (Sztemppath, "Temp");
35.brac_setsdkoption (Brac_so_coresdk_tmpdir,sztemppath,strlen (Sztemppath));
36.//enable audio active parameter performance (tacit open)
37.DWORD Baudioautoparam = TRUE;
38.brac_setsdkoption (Brac_so_audio_autoparam, (PCHAR) &baudioautoparam,sizeof (DWORD));
Second, login fragmented
When the first step of initialization implementation, you can link the server, textual research user identity. General call code as follows (c + +):
1.1.//Join Server
2.2.brac_connect ("211.155.25.90″,8906");
3.3.//Login Fragmented
4.4.brac_login ("TestUser", "", 0);
Both the join server and the logon fragmented process are once asynchronous, and immediately after the call, they are:
A, connecting the server smoothly, or losing, will trigger the asynchronous message
b, login fragmented, or lose, will trigger the asynchronous message
Because of the use of sequential requirements to echo the department's asynchronous information capabilities know how to join the server, login fragmented can be smooth.
After the login fragmented smoothly, if the need to complete the immediate communication using the list of friends (Anychat acquiescence is not completed), then the need to apply Anychat expansion API interface and the server SDK to cooperate, detailed completion of the plan can be referenced in the SDK package: Doc\server\ program under the " The 6th chapter of the Anychat Server SDK Development Guide.
After the login fragmented smoothly, the server will go to a once 32-bit user ID, if the login did not pass the plaintext parameters, the fragmented will be considered to be a visitor login, and the deployment of a once foot user ID (such as 1, 2, etc.), if the login to pass the plaintext parameters, the login requirements will be given to the "SDK Filter Plus "interface, or" Server SDK "for the interface, the user can open up the server plug-in" SDK Filter Plus ", or call the" server SDK "for the API to solve the user identity textual requirements, to achieve the user ID governance, Complete with its three-party fragmented interconnect closely linked, detailed form can be referenced in the SDK package: Doc\server\ program under the relevant documents.
Third, enter the room
After the second step of the login fragmented smoothly, you will be able to enter the room, as long as you are in the room, the ability to achieve voice and video interaction. General call code as follows (c + +):
1.1.//into the room
2.2.brac_enterroom (1, "", 0);
The room by the server static governance, by the 32-bit room ID number to be unique, when the depositor named Room ID number does not have, the server will be actively created. Enter the room is also once asynchronous process, whether the smooth will trigger asynchronous information, enter the room smoothly, service device will be in the future of the room's online user list to the depositor side, the transmission is implemented, will trigger the asynchronous message (this information is triggered only once), as long as the server's online user list is received, Ability for users in the room to stop the audio and video of the operation.
When I entered the room smoothly, and received the server is online user information, there are new users into the room, or the old users separate rooms, will trigger asynchronous information, this mold I know who entered, or separate the room.
1. Turn on my audio and video
After entering the room smoothly, will be able to open my audio and video facilities, general call code as follows (c + +):
1.1.//opened my video facilities
2.2.brac_usercameracontrol ( -1,true);
3.3.//opened my audio facilities
4.4.brac_userspeakcontrol ( -1,true);
Opened my facilities, and did not immediately upload audio and video streaming, as long as other users require my audio and video data (can be common requirements of the stream, or video streaming) only for the evaluation of transmission, opened my audio and video facilities, tacit consent is the configuration of the service device to initialize the facility (such as sampling rate, video frame rate, Frequency of audio sampling, etc.)
2, require other users of the audio and video
If the demand shows other users of the audio and video, it is necessary to receive the room user list information, demand for the side of the audio and video stream, and then for just the sound as good news avalanche scandals broadcast past, generally require other users of the audio and video data call code as follows (c + +):
1.1.//requires a video stream for the party
2.2.brac_usercameracontrol (dwuserid,true);
3.3.//requires an audio stream for the party
4.4.brac_userspeakcontrol (dwuserid,true);
Data transmission priority to the form, as long as the peer is not available, only by the service device forwarding, peer NAT hole process, as well as the data transmission strategy are controlled by the server, only require, and for Fang has opened my audio and video facilities, you can receive audio and video streaming data for the party.
3. Playback and display of audio and video
When you receive audio data from another user:
A) If the "Brac_func_audio_autoplay" tag is installed when initializing, the external SDK will play actively, the active mix;
b) If the "Brac_func_audio_cbdata" flag is installed while initializing, the SDK will pass the decoded audio data (PCM style) back to the lower level using the callback dependent variable.
When you receive video data from another user:
A) If the "BRAC_FUNC_VIDEO_AUTODISP" flag is installed while initializing, and the API is called, the External SDK will show the video to the named form's naming status (the video window is actively superimposed on the naming status);
b) If the "Brac_func_video_cbdata" flag is installed when initializing, the SDK will pass the decoded video data (RGB, YUV) through callback dependent variable callback to the lower layer, using the lower layer to map, or render, which is suitable for DirectX, Hge such as no window in the form of the use of the order, or the lower-level use of the need for video to stop the special solution to the site, such as text, logo and so on.
4. Text interaction
After entering the room, you can call the API interface to send text messages to the named user, or to all users in the room:
1.1.//Send text message
2.2.CString strinput = "Hello World";
3.3.brac_sendtextmessage ( -1,false,strinput.getbuffer (0), strinput.getlength ());
When other users receive the text message, they will trigger the callback dependent variable, resolve the callback information, and then display the text information received on the interface, to complete the interaction of the text.
5, Business logic solution
Anychat SDK built-in fundamental logic is: when I opened the audio and video facilities, other users have requirements, will stream the media data to the party, and there is no business logic.
A) If you want to complete the video banquet fragmented, then users enter the room, the need to know who is in charge of people, and then opened the control of People's video;
b) If you want to complete video chat fragmented, then users enter the room, the need to know how many of the room after the public, who is on the public wheat, and then opened for the public to the user's video and so on;
c) ...
The operational logic requirements of the Agency are in collaboration with the "SDK filter Plus" or "Anychat Server SDK" on the service side, and the detailed completion plan can be consulted in the SDK package: the Anychat Server SDK Development Guide under the Doc\server\ program The 6th chapter of the book.
Iv. release of resources
Join the server with the back, login fragmented, enter the room for the right, to join the fragmented process is: separate rooms, register fragmented, release resources, general call code as follows (c + +):
1.1.//Separate rooms
2.2.brac_leaveroom (-1);
3.3.//Register fragmented (open network connection)
4.4.brac_logout ();
5.5.//Release Resources
6.6.brac_release ();
After separating the room, be able to enter the new room, after the fragmented registration, can again invoke the interface of the API to join the service, however, after releasing the resources, the SDK will not re-task.

Talk about the development of video chat room several views?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.