Anychat is an open real-time communication solution for audio and video. in earlier versions, the input and output interfaces of raw data have been opened: 1. The client callback function can be used to output the user's original video sample frame data (YUV, RGB): video data callback function 2. External video frames can be transmitted to anychat for encoding through the external data input interface: How to Use the external audio/video data input function?
For some specific scenarios, upper-layer applications want to obtain the original H. 264 encode the data, or you want. 264 encoded data is transmitted to anychat. This feature is supported since anychat r00008. This feature gives anychat more flexibility and scalability, including: 1. It facilitates data exchange between anychat and other platforms to achieve interconnection with other platforms, such as sip communication terminals; 2. By writing access pages, you can access data such as surveillance cameras and video-on-demand platforms;
The new version adds a constant definition: brac_pix_fmt_h264, And the API interface has not changed. 1. When you need to use the callback function to obtain the user's H.264 encoded data, you can input constants when setting the callback function, such:
// Set the callback function
Brac_setvideodataexcallback (brac_pix_fmt_h264, onvideodataexcallback, this );
// Callback function implementation
Void callback onvideodataexcallback (DWORD dwuserid, lpvoid lpbuf, DWORD dwlen, bitmapinfoheader bmiheader, DWORD dwtimestamp, lpvoid lpuservalue)
{
}
Copy code
2. When you want to pass the encoded H.264 data to anychat, you can use the external data input interface, for example:
// Initialization
Brac_setinputvideoformat (brac_pix_fmt_h264, 320,240, 25, 0 );
// Input data
Brac_inputvideodata (lph1_frame, dwsize, dwtimestamp );
Copy code
Instructions: 1. The input and output H.264 encoded frame data are all NAL units, including the starting frame MARK: 00 00 00 01, and each input and output is a nal unit; 2. The key frame must contain a sequence parameter set (SPS: sequence parameter set) and an image parameter set (PPS: picture parameter set ); 3. The timestamp is a millisecond value. The difference between the two timestamps indicates the interval between two frames (unit: milliseconds) |
Open video encoding (H.264) encoding/decoding data input and output Interfaces