About the h264 client on the Android platform

Source: Internet
Author: User

I have developed a client for decoding h264 on the Android platform. Now let's summarize it:

1. Interface

There is nothing to say about it. It is very simple on any platform...

2. decoder porting

I found an h264 decoding library cropped from FFMPEG and transplanted it to the Android platform. Here I want to learn about JNI.

3. Java Multithreading

I understand several methods of Java multithreading. Here I use two threads, one receiving data from the server to the shared buffer, and the other taking data from the buffer to the decoder for decoding and outputting the image.

4. Android Network Programming

It is quite simple to directly use the socket for sending and receiving, and then the mobile phone communicates with the server via wifi. We just need to do the socket for sending and receiving, we don't have to worry about how to send data via wifi. If you are interested, you can understand it.

 

Notes:

1. to set the shared buffer, we need to think of a better mechanism based on the actual situation. I opened up a piece of memory and then divided the memory into 1000 small blocks to form a large ring, then, the flag is used to determine whether data exists in each small block.

2. The setting of the data size received by the socket is also worth noting. It has something to do with your network environment. What I set at that time was to receive 4096 bytes each time, and the result showed that it could work normally on the simulator, but it would not work on the real machine, and it was OK after it was changed to 2048.

3. I don't know much about Java multithreading, because I have been engaged in many projects on C and I still need to learn.

4. Android can be debugged on a real machine. This is really great. Buying a mobile phone is like buying a Development Board, happy...

 

Finally, I would like to thank eoeandroid. The Forum has helped me solve many problems, and the special publications are also very valuable...

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.