Processing of RTSP Streaming Media buffer Filling

Source: Internet
Author: User

The buffer filling and clearing Mechanism of RTP packets obtained from the network in the nuplayer Streaming Media Player for decoding and display is similar to the processing process of playing a local video in the stagefright framework.

All are implemented through the callback functions fillbuffer and emptybuffer.

The acodec in nuplayer is similar to the omxcodec in stagefright.

The following describes how to fill the buffer to be decoded in RTSP Streaming Media and send the decoded buffer to the display and clear process:

1. acodec: uninitializedstate: onsetup

Call status_t err = OMX-> allocatenode (componentname. c_str (), observer, & node );

2. OMX: allocatenode

Status_t OMX: allocatenode (const char * Name, const sp <iomxobserver> & observer, node_id * node) {mutex: autolock (mlock); * node = 0; omxnodeinstance * instance = new omxnodeinstance (this, observer); // omxnodeinstance is the omx_componenttype * handle created in the OMX class; omx_errortype err = mmaster-> makecomponentinstance (name, & omxnodeinstance :: kcallbacks, // registers the kcallbacks callback function, instance, & handle );

3. omxnodeinstance: kcallbacks

// Staticomx_callbacktype omxnodeinstance: kcallbacks ={& onevent, & onemptybufferdone, & onfillbufferdone // callback function onemptybufferdone, onfillbufferdone };

4. omxnodeinstance: onemptybufferdone // after data decoding, you can take the data for display and then clear the buffer.

Call instance-> owner ()-> onemptybufferdone (instance-> nodeid (), pbuffer) // The owner () returns the OMX pointer object mowner.
The process is as follows:
(1) Send the omx_message: empty_buffer_done message in OMX: onempty_buffer_done, and set the decoded buffer.
(2) First, the onmessage method of the codecobserver struct in the acodec. cpp file receives the message omx_message: empty_buffer_done.
(3) Then acodec: basestate: onomxmessage receives the omx_message: empty_buffer_done message and calls onomxemptybufferdone to continue processing.
(4) In the acodec: basestate: onomxemptybufferdone function, if the portmode value is resubmit_buffers, The postfillthisbuffer function is called.
(5) In the acodec: basestate: postfillthisbuffer function, the kwhatinputbufferfilled message is sent and the "what" parameter is set to acodec: kwhatfillthisbuffer.
(6) After receiving the kwhatinputbufferfilled message, call the oninputbufferfilled function.
(7) In the acodec: basestate: oninputbufferfilled Function
1) The value of portmode is resubmit_buffers, and buffer! = Info-> mdata, the memory is copied, And the decoded data is copied from buffer-> data () to Info-> mdata-> data ().
Memcpy (Info-> mdata-> data (), buffer-> data (), buffer-> size ());
2) then call the mcodec-> momx-> emptybuffer function and call the omxnodeinstance: emptybuffer function.
3) Call the getmoreinputdataifpossible function to obtain the decoded data. However, when eligible = NULL is executed, the returned action is executed, and the postfillthisbuffer (eligible) function is not called for further processing.

5. omxnodeinstance: onfillbufferdone // The data is ready and can be sent to the decoder for decoding.
Call instance-> owner ()-> onfillbufferdone (instance-> nodeid (), pbuffer)

---------------------------------------------------------------------------------

In the OMX: allocatenode function, the callbackdispatcher object is created, that is
The callbackdispatcher constructor creates the callbackdispatcherthread object and calls the run function. In the run operation, thread ::_ threadloop is called and threadloop is called.
->
Bool OMX: callbackdispatcherthread: threadloop (){
Return mdispatcher-> loop ();
}
->
OMX: callbackdispatcher: loop ()
->
OMX: callbackdispatcher: Dispatch
->
Omxnodeinstance: onmessage
Mobserver-> onmessage (MSG); // iomxobserver is passed in the constructors omxnodeinstance, that is, the parameter observer passed in OMX: allocatenode,
// While OMX: allocatenode is called in the acodec: uninitializedstate: onsetup function, that is, the observer type is codecobserver.
Codecobserver inherits from the bnomxobserver class, while bnomxobserver is a subclass of iomxobserver.
Therefore, in the OMX: callbackdispatcher: Dispatch, execute mowner-> onmessage (MSG ),
Finally, the onmessage method of the codecobserver is called. The acodec: kwhatomxmessage message is sent in the onmessage method of the codecobserver.

Related Article

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.