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...