Beijing University of Technology's 20981 Chen xiao3g is now (although I still don't know the future ), however, as the on-line application of mobile phones has become a little popular, the arrival of 3G will surely bring a great impact to the mobile software development industry. This is like when we all use a 56 K modem for dial-up Internet access, no one can even use a computer to download several G-level high-definition movies and play 3D games online, you can watch TV online. So let's take a look at it for a rainy day. Let's make a demo to verify whether online streaming media playing on this legendary mobile phone is so mysterious. What is the threshold for the so-called "Core Technology. Because I do not have 3G network conditions, I have to go back to the next step. I have used the existing GPRS network for online streaming media, and it is not long to come into contact with this technology, if there is something wrong with it, please make sure that you are correct. I 've probably read the video materials. Currently, MPEG4 compression is quite mature. Algorithm In fact, many people confuse the MP4 file format with the MPEG4 compression algorithm. MPEG4 can only compress video data (the "video" data here refers to image data in the YUV format, which does not contain sound ), the related files indicate that the maximum compression ratio of MPEG4 can reach: 1. MPEG4 is just like WinZip, which we usually use. WinRAR is just a common compression algorithm. The difference is that WinZip or WinRAR is used for conventional File compression, MPEG4 is particularly effective in compressing dynamic images, which greatly reduces the storage size of image data. Now the MPEG4 algorithm has a Part 10, which is a relatively advanced compression algorithm. The unofficial name is H.264. The compression ratio is higher, just like the 7z on the PC. But of course, if there is a benefit, there will be a disadvantage. A higher compression ratio will naturally lead to an increase in the amount of computing. 264 of the computing workload is more than twice that of MPEG4. However, given the limited bandwidth of the current GPRS Service, we have to use H. 264 is the preferred codec solution. After all, it consumes less bandwidth. Let's take a look at the MP4 file format. In fact, the MP4 file format is the same as the 3GP file format, and all files comply with the ISO standard format. For specific format definitions, see ISO/IEC 14496-14 MP4 file format. Actually, after reading this format, I feel like an HTML webpage, but the tags in MP4 files are binary, while HTML webpages are in the form of readable ASCII code, the rest is that the tags are defined differently. In the MP4/3GP file, it is no longer called a tag, but a "box" or a box. MP4 and 3GP files are composed of a series of "Boxes" containing different audio and video data. Therefore, you only need to open these "Boxes" to retrieve data during decoding and playback, then decode the display and play the video. So don't be surprised if you hear the 3GP file encoded with MPEG4. This is normal. The boxes are all the same, but the content in them can be MPEG4 encoded video data, it can also be h264-encoded video data, or h263-encoded video data used by early mobile phones. Of course, the sound can be AAC, amrnb, or something else. All of these are OK as long as the decoder supports them. This is like <mytag> XYZ </mytag> in an HTML webpage. The XYZ between two tags can be changed at will. In any case, as long as the compound HTML standard writes tags, no error will occur. The same is true for videos. As long as the box definition complies with the ISO standard, No matter what data is installed in it. Hoho: Since the encoder and decoder are both written by themselves, you can simply forget what is installed in the box. This is why many commercial codec instances are paired, A decoder must have a corresponding encoder. No matter how much audio is selected, the higher the compression ratio, the better the quality... This is just an experimental verification. Therefore, amrnb is selected as the audio compression standard. At present, it seems that the sound is compressed at a low bit rate. The most ideal thing is it, in addition, the Symbian mobile phone itself has AMR codec, which saves you the effort to write. Alas, unfortunately, there is no ready-made video decoder available on the mobile phone. We strongly recommend that Symbian provide a built-in video decoder. I do not need to call third-party applications.Program , Or a decoder. Then, you can randomly draw a streaming media Video Frame Design Diagram on your mobile phone: The figure below shows the muti-media stream format, which is the internal appearance of the streaming media file where the video and audio that the design encoder should encode are mixed. Then, the SABS and vabs represent the audio and video data information, such as the total number of frames, the playback duration, and the encoding method, what is the baud rate under ideal conditions? The audio information also includes the sampling rate, number of channels, and other information. Because it is only an experiment, there is no need to introduce the concept of VBR dynamic bit rate, and mobile phone estimation is also difficult to process this, so both audio and video adopt static bit rate CBR. This makes synchronization easier. The next step is the specific data. vdat indicates the "box" containing the video data, and Adat indicates the "box" containing the audio data ", the box records the size and synchronization information of audio and video data, such as the frame number and the nal header. The framework is composed of a net engine and a stream player engine. In the debugging phase, the net engine can be temporarily replaced with a file engine for simulation, after all, it is not easy to adjust the network part of Symbian. The general workflow is that the net engine downloads video streams from the network through GPRS. Here I directly applied the parts of the breakpoint resume engine posted on the blog. Code Download video data directly from the HTTP server using the resumable data transfer technology and download it to the media queue. If the download is full, the download will be paused. If the media queue data is insufficient, you can use resumable download to continue downloading from where you just stopped. Then, we enter the stream divider module. This so-called divider is used to stream data that is mixed with audio and video for shunting. This may also be called a filter, introduce video data into h264 queue, introduce audio data into amrnb queue, and then decode the audio data by their respective decoders. H264 codec can use libavcodec In the open-source FFMPEG project. This libavcodec is too powerful and can be used after proper cropping (this is an understatement, huh, a friend who has done so should be closely related to me here: P ); AMR codec can either use the built-in AMR codec on your mobile phone or port it on your own. Hoho, I am not even lazy. I transplanted an amrnb decoder myself. I think this is a lot of work, but if I think it means that I can run it on win mobile, it is worth it. As for those queue, it is estimated that those who have read Richard Stevens's "UNIX network programming" will naturally be confused. Finally, this display problem occurs. All the images decoded from libavcodec are in the YUV format. A Conversion Program is required to convert the YUV format into the rgb565 format (in fact, Symbian mobile phones also support rgb32, the rgb565 method is adopted, however, because it saves time and energy ). Then, we use the cdirectscreenaccess class to speed up the display. If you are not clear, you can refer to the SDK help of symiban 3rd. In retrospect, the voice is very convenient on Symbian. The system directly provides an interface for playing audio in the pcm16 format, cmdaaudiooutputstream. This class needs to be said. To use this class, you must implement three pure virtual functions: void maoscopencomplete (tint aerror ); Void maoscbuffercopied (tint aerror, const tdesc8 & abuffer ); Void maoscplaycomplete (tint aerror); here, the maoscbuffercopied function is very important. After each data read, the mobile phone system will automatically callback this function. You must send the data to the system, otherwise, an error occurs. Fortunately, Symbian provides a willresumeplay () function, if no PCM data can be used for callback of the callback function (you must have it when you are a landlord ), you can call this function to get rid of the requested data. If there is enough data next time, you can execute the write operation to start the callback function to request data. This makes it possible to play the video again when the network condition is poor. The last step is the synchronization policy. The basic idea is to focus on audio, supplemented by video, and the audio can be heard with a slight latency. For videos, because video frames are continuous, it is no problem to discard one or two frames. After more than a week of hard work, we finally achieved the entire framework shown above, and finally played the MP3 streaming. Passed the test on the Symbian 3rd n81 platform. During debugging: The server will be turned off from time to time. Before using the mobile phone program for testing, make sure that the following URL can be accessed: http: // 211.94.72.20./ test/B .mp3 http: // 211.94.72.20./ test/B. ms then installs the program. Here, only one sis package with no sign is provided. If you need to test it, you can sign it yourself and only use the following capability: readuserdata writeuserdata readdevicedata writedevicedata localservices networkservices networkcontrol commdd trustedui userenvironment installation package download (there is no sign over sis here, you need to sign it yourself)
|
file: |
mp3test_s60_3_x_v_1_0_0.rar |
size: |
344kb |
download: |
download |
|
Usage: (1) change the name of the cmnet access point to "Internet" (Note: All values must be capitalized) (2) change the name of the cmwap access point to "WAP over GPRS" (note, the case must be the same.) These two points cannot help you. During the test, you can easily write them into the program. (3) Open the program and you can use it at will. (4) When cmwap h264 or cmwap h264 is selected, the video will be automatically played online (cmwap takes a little longer) (5). You can choose pause to pause playing during playback, select resume to Resume playback. (6) you can download the MS file and MP3 file from the above link to your mobile phone and play the video using local h264 or local MP3. Here, the local mode is played in "loop" mode. After playing, the local mode starts playing again. (7) pause and resume are also valid for local playback. (8) The left and right arrow keys can adjust the volume, the left arrow keys reduce the volume, and the right arrow keys increase the volume. The biggest advantage of this test is that the server deployment is extremely convenient and requires no complicated video server configurations (of course, the complexity has complicated advantages to achieve more precise positioning and control ), A common Apache or Tomcat instance can be used. It can also be used with free WAP. By using MDL or similar association technology, you can click a video on the WAP webpage, you can directly call the online playback effect of the player. |