Recently, because the company is doing digital TV, players and modules sold by the supplier packaging together, the drive is tuned, but the player to hardware decoding, and platform differences, the original and no related documents, he tried to see a system of the player process, by the way, and convenient later query, I hope that the development of the hard decoding of the player can play a role. Because of the video also do not understand, so inevitably there are many mistakes, welcome master guidance.
1: Create a DataSource (DataSource) by a file or device (which can be a file descriptor fd, URI, HTTP)
2: Create an instance of the Mediaextractor (that is, the video splitter Paser) via DataSource
3: Created two mediasource by Mediaextractor instance (video to contain two, one for video mvideotrack, one for audio Maudiotrack), it is important that the read function is used to decode the original video data for the decoder
4: Create a Omxclient instance and connect (call its connect () method specifically, and check if it returns successfully)
5: Create the appropriate decoder instance for example:
Momxsource = Omxcodec::create (
Mclient.interface (), Maudiotrack->getformat (),
False,//Createencoder
Maudiotrack);
Mvideosource = Omxcodec::create (
Mclient.interface (), Mvideotrack->getformat (),
False,//Createencoder
Mvideotrack,
NULL, Flags,
Mnativewindow);
Maudiotrack Mvideotrack is a two MediaSource instance representing the original data source respectively
Note that both return an instance of MediaSource (Momxsource and Mvideosource), both of which are used for the user to obtain the decoded audio and video data and play it.
Mnativewindow (Anativewindow) is the lower layer of the upper surface, the surface to be used for display on the upper layer
Ways to create Anativewindow:
1: From the Java layer, a Jsurface object is passed to JNI via JNI, and JNI can get igraphicbufferproducer through this object by:
Sp<surface> Surface;
Sp<igraphicbufferproducer> GBP;
if (jsurface) {
Surface = Android_view_surface_getsurface (env, jsurface);
if (surface! = NULL) {
GBP = Surface->getigraphicbufferproducer ();
}
}
Finally get an example of a igraphicbufferproducer GBP
2: The upper layer provides a reference to a sp<igraphicbufferproducer> &bufferproducer and can be used to create anativewindow Mnativewindow = new Surface ( Bufferproducer)//Some reference AwesomePlayer.cpp
6: Call 5 to return two MediaSource instances of the Read method (mainly used to get a Mediabuffer instance Mvideobuffer) to obtain the decoded data (that is, in mediabuffer) and processed accordingly (that is, playing)
7: Display image via Anativewindow
status_t err = Mnativewindow->queuebuffer (Mnativewindow.get (), Mvideobuffer->graphicbuffer (). Get (),-1);
sp<metadata> MetaData = Mvideobuffer->meta_data ();
Metadata->setint32 (kkeyrendered, 1); Main set a render mark, description already displayed (guessed)