The basic process of using OpenMAX programming in Android

Source: Internet
Author: User

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)

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.