Android platform-based streaming media player design - turn

2010-09-17  来源:本站原创  分类:OS  人气:811 

1 Introduction Along with mobile communication technology and the rapid development of multimedia technology, Fusion phone, Internet, multimedia technology as one of the video surveillance technology has made great strides, through the mobile communication network to provide streaming media services have become possible. Very large number of global mobile users, so mobile streaming media service with great market potential for mobile services is also one of the focus. In this context, mobile terminals for mobile networks and the characteristics of proposed mobile streaming media solutions for clients of great significance.
This thesis FFmpeg open source code decoding process, proposed mobile streaming media player based on hierarchical architecture design. The design is characterized by different types of documents in the bottom screen of the media stream decoding the difference, and provides equipment for external camera control functions, and eventually Android platform [1] to achieve the player.
2 player overall design of both players play a local file or network stream media files need to have access to media data, decoding audio and video media streams, the decoded media data to the user the three stages of processing, according to documents play 0 process in three distinct stages of processing, this paper presents the structure based on player level design.
As the local file and network streaming media files De data acquisition approach is not the same, to maintain the consistency of the upper decoder, need for pretreatment of the two documents formed the same format of the data available to Shangceng decoding. According to the above features, combined with file decoding process in this article for real-time monitoring of player designed with hierarchical structure, each layer independent tasks, so that the coupling is low and conducive to the independent expansion of each layer without affecting the upper and lower layers of the application. Bottom layer followed by data extraction, data pre-processing layer, audio and video decoding layer and user interface. The streaming media player hierarchy shown in Figure 1.
User interface layer mainly provides the user and the interaction between the player interface, such as playing a local file can be achieved when the pause, fast forward, rewind and other functions, in watch streaming media files by the number keys, navigation keys, or the direction of player buttons control the camera focal length, direction and other information.
There are audio and video decoder decoding layer of select components, all major audio and video format decoder and synchronization between multiple media streams function. Decode select components from a local file or streaming media file header to get the information to the media decoding formats, according to the format of information on selecting the appropriate decoder to decode compressed media streams. The part is optimized by the pruning FFmpeg as the player decoding module. Synchronization between multiple media, including streaming video and audio streams simultaneously, playing local files may also need to synchronize subtitles.
Data preprocessing layer on the local file format solution in accordance with their media package, access to files or subtitles, audio and video information and its top by the frame to be decoded into the appropriate buffer. RTP streaming media file will remove the header information, and video information Alto RTP framing, will complete the top frame to pass the buffer to be decoded. The package control information component in accordance with the PELCO-D / P agreement text format package user's control input, and control information to the lower deck.
Data access layer functions, including local files, streaming media files and camera control access to the information sent, the former can only read local files, streaming media files for streaming media server needs to access the media data. Streaming media files, including pre-session consultations to obtain some part of the data and the data buffer to send some parts. Some of them need to use the media information consultation RTSP protocol [2] consultations stream general information, such as media type (video and audio), transport protocol (RTP / UDP / IP ...) and media format (H263, mpeg ...) and media delivery port and other information.
3 FFmpeg FFmpeg to the Android platform is a set of recording migration, conversion, audio / video encoding and decoding functions as one complete open source solutions. However, only player in this article FFmpeg package solution on paper and some audio and video decoding features that if all the transplantation FFmpeg entire solution to the target platform will cause a lot of code redundancy. FFmpeg code development time, and Linux-based operating system, and do not take into account the processing power of a small mobile platform, lack of energy restriction, specific functional requirements for mobile phones will FFmpeg code to pruning and optimization is very important.
3.1 FFmpeg pruning and optimization of the code from FFmpeg so large and complex structure of the source code of the code needed to find out this is indeed a very difficult task. Compile and run under the Linux FFmpeg code to go through configure, make, make install three steps can be compiled into the Linux FFmpeg correct systems. Stage which will generate a configure.h configure and make files, these two documents can be compiled to find out the views of those files are compiled.
The study found that when the configure source code can be many configuration parameters, which parameters are divided into basic option parameter, the Advanced Options parameters are dedicated to the optimization of parameters. Optimization of parameters configured at compile time is mainly responsible for the content of compiling required. Pruning are exactly on the FFmpeg is a document of this system does not require removal, so this paper select the appropriate method to find optimal parameters of the required documents player. After careful study of these parameters obtained at compile time to set the parameters as follows:
. / Configure - enable-version3 - disable-encoders - enable-encoder = h263 - enable-encoder = amr_nb - disable-parsers - disable-bsfs - enable-muxer = tgp - disable-protocols - -enable-protocol = file.
With the parameters shown above configuration compile the source file, the system only h263, amr_nb coding and 3gp file format and all of the decoding package format, solution package file to compile the source code of some of the link library.
Then be compiled into a collection of links to library source code shall be required for the source code for this set, by looking configure.h and make the file name suffix. O file name suffix. O files are compiled. C code generated object files, each to be compiled. c files are generated. o files, so named by looking at all the suffix. o The file name can be traced in the configuration parameters, which are compiled source files Therefore, this article can be drawn the necessary minimum set of source file to compile.
While FFmpeg open source code to compile and run cross-platform, but the code are designed for the PC, for the purposes of, PC machines and mobile phones from the CPU processing power, energy, memory and other aspects of resources had a lot of big differences, this paper features for mobile phones in the main optimization of the code from the following aspects:
1. Remove redundant code, structure, standardized procedures to reduce the if-else's to judge, adjust the local and global variables, local variables instead of using register variables, to reduce unnecessary code redundancy, the process of removing FFmpeg debugging print statement;
2. With a logical shift operation instead of multiplication and division operations, as multiplication and division operation instruction execution time is much larger than the logical shift instructions, especially the division command, use the logical shift operation can reduce the running time of instruction;
3. Note that the function of the call cycle, to minimize the use of multi-cycle, write code, weakened as much as possible the last cycle and the relevance of the next cycle, to reduce unnecessary computation code;
4. Set reasonable cache. FFmpeg transplantation for the target platform Android platform, set for this cache size of the station;.
Specific code changes here will not repeat them one by one.
3.2 FFmpeg transplantation Google released NDK's makefile file that file makefile file syntax and common there are many differences in the cross-platform compile FFmpeg source code and makefile can not use the original file. Therefore, a prerequisite for transplantation is to document all the FFmpeg in the makefile replace NDK in file.
By analyzing the structure of that avutil FFmpeg module is the foundation module, avcodec compiled modules have been compiled based on avutil module, avformat based on the first two, in accordance with this compile the module structure of the order of transplantation avutil, avcoedec, avformat, compiled steps are detailed below:
1. On the config.h and config.mak
First of all, explain makefile that comes with the framework FFmpeg, FFmpeg after configure command will then generate a config.h file and a config.mak file, these two documents combined total of 600-700 macro definitions used to describe the compiled all Fangmian code parameter setting, which on systemic framework, compiler, link libraries, header files, version, codec related to the macro definition of Deng Deng. In this part of the need to revise the definition of areas on different platforms, such as architecture must change the Android platform ARMv5TE, then the compiled file will select the ARM instruction set when the X86 instruction set, rather than the instruction set. These two documents are important, since many documents have to include config.h this file, the compiler will be selective on the basis of this document and compile the code.
2. Compile libavutil.a
In a libavutil file, libavutil in the makefile file you need to call subdir.mak, this is actually a real compiler, but writing in, this make file can not be, but need the source files directly to the corresponding the introduction of the standard makefile is specified. o object file, but directly specified in the need. c source file, file as follows:
LOCAL_PATH: = $ (call my-dir)
include $ (CLEAR_VARS)
LOCAL_MODULE: = avutil
LOCAL_SRC_FILES: = adler32.c \
... ... \
Compile-time may be many errors, but the question boils down mostly because some header file does not introduce the problems arising, as long as after the introduction of the appropriate header files do. Does not recognize certain documents such as size_t keyword in the document include stdio.h not after the error, and other similar mistakes will not enumerate the.
Other modules by the same method of writing file, ported to Android platform, the most players in this article the decoding module.
4 layers of data acquisition module Xiangjie 4.1 to complete the main function layer of the layer with the streaming media server, media information details of the consultation and, based on results of the consultation for streaming media from a server-side data, streaming data into the buffer, the buffer according to this article strategy to send packets to the data pre-processing layer, the structure shown in Figure 2:
The total level in this article start five threads, one thread to start TCP connection for RTSP session negotiation, and RTP data transfer period, the TCP connection must be kept. Two threads were to receive audio and video RTP data thread, the other two threads were to receive and send audio and video RTCP packets.
4.2 Data Preprocessing layer of this layer to local files pretreatment completely dependent on the functionality provided documentation solution FFmpeg package features, and streaming media files to one or more of pretreatment required to RTP packets together, this part of the technology has been relatively mature, this will not repeat them.
This streaming media player is different from other common streaming media player, the maximum shall be able to feature the external camera with PTZ control, such as focal length, up, down, left, right, etc. settings. Therefore, use this article as PELCO-D protocol PTZ control protocol.
The first byte for the synchronization word, said start symbol, usually 0xFF. Byte is used to detect the symbols used in sending and receiving the correct way or not. Fill the second byte target device address, 1 byte in the command word for the camera aperture and focal length control. 2 bytes in the command word for the focus and zoom control, which Bit4, Bit3, Bit2, Bitl for the vertical and horizontal control of position, the last Bit0 bit is always 0. 1 byte of data, the horizontal speed (00-3F). 2 bytes of data, vertical velocity, its value with the data byte 1. Checksum byte for the first six bytes of the sum.
This design PELCO-D text of the agreement, the initial default bit command word 1 word 2 all of the command is 0, data, and data word 1 word 2 = 20H. Key message sent by the upper modify the corresponding command word 1, the corresponding 2-bit command word.
At present this only provides streaming media player for more than six kinds of control functions, the module's key information under the upper departure set the corresponding bit is 1, calculate the value of bytes to form a seven-byte text to send to an external device, when receiving the upper button Stop the news, unified send (0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,) to stop the command.
4.3 decode and display the main application layer decoding layer migrate to Android platform FFmpeg code decoding module as a player, that part of the code support, including avi, 3gp, MPEG-4 format and decoding such as more than 90 kinds of file formats, and optimized through pruning the FFmpeg code efficiency and effectiveness have been greatly improved.
This paper shows application layer of the SDL library open-source implementation, SDL (Simple DirectMedia Layer) is a cross platform, free open source software. The C language development software applications, providing a variety of platforms on the external image, sound and other input devices simple interface. Often used for games and other multimedia applications development, the open-source software can run on multiple operating systems, including Linux, PSP, Windows, Mac OS X and so on. SDL also has the same video, audio, threading, timers, events and other functions.
5 Summary This article describes the Android platform-based streaming media player designed hierarchical structure and the detailed design of each layer, the player's decoder library optimized FFmpeg from the cutting through the source code, and the players in this article provide for external camera control functions, is more extensive range of applications.
Although the completion of this article with a control function of the streaming media player, a prototype implementation of function, but many such as QoS, code optimization problems require further study.

  • Android platform-based streaming media player design - turn 2010-09-17

    Original: 1 Introduction Along with mobile communication technology and the rapid development of multimedia technology, Fusion phone, Internet, multimedia technology as one of the video surveil

  • Android platform-based streaming media player design 2010-07-14

    1 Introduction <br /> As mobile communication technology and the rapid development of multimedia technology, Fusion phone, Internet, multimedia technology as one of the video surveillance technology has made great strides, through the mobile communi

  • FMS3 Series (3): Creating Streaming Media Player Based on FMS program, to help see the cottage cottage Legend 2010-07-19

    This paper describes how to create streaming media player based on FMS program, Flash client through the network load FMS server video streaming file (. Flv,. Mp4, etc.), broadcast video stream to achieve. To achieve the broadcast media stream file i

  • android streaming media player 2010-09-17

    More happy today to see the forum many people are asking how to write network streaming media player? Whether the two players take turns? Because Android does not provide that kind of flow like J2me created in the form of short or not very good writi

  • FMS3 Series (3): Creating Streaming Media Player Based on FMS program, to help the cottage to see the legendary cottage 2010-09-21

    This paper describes how to create streaming media player based on FMS program, Flash client through the network load FMS server video streaming file (. Flv,. Mp4, etc.), to achieve the broadcast video stream. To achieve the broadcast media stream fi

  • FMS3 series (c): Creating FMS streaming media player to see the cottage cottage legendary help 2010-09-21

    This paper describes how to create streaming media player based on FMS program, Flash client through the network loading on the FMS server, video streaming file (. Flv,. Mp4, etc.) for video stream playback. To achieve media stream file playback is v

  • FMS3 series (c): Creating FMS streaming media player to see the cottage cottage to help the legendary [transfer] 2010-12-25

    This paper describes how to create streaming media player based on FMS program, Flash client through the network loading on the FMS server, video streaming file (. Flv,. Mp4, etc.) for video stream playback. To achieve media stream file playback is v

  • RSTP protocol based on streaming media player 2010-12-16

    This switched: RTP sdfs Real-time Transport Protocol) is used for multimedia streaming on the Internet as a transport layer protocol. RTP, described in detail on the Internet aud

  • Research Notes streaming media player (non-technical) 2010-08-16

    The need for work, I started streaming video of. Began to receive tasks, although do not understand anything, but you can check that does not, then Google and Baidu in the sea on the election-style operations, often one-off open 10 or so pages, then

  • Research Notes streaming media player (once told me the resources to help summary) 2010-08-30

    I knew I would forget, but still do not want hands-on summary to see if I've set up the environment, do not know what to do in the. The following is a streaming media has been set up on my player, helpful resources: 1) Windows environment, configurat

  • OGG file format of streaming media 2010-03-30

    Taken from: Summary of streaming media file format streaming media system plays an important role, designed the file format is to improve the efficiency of streaming media servers and Zuiyou Xiao Zhi

  • Streaming media server diagram 2010-04-21

    Rapid development in the information society of today, the network has become an important means of mass media, ordinary day we ignore the action and has been used to imply that we are constantly network. When we sit in the computer , I opened IE, th

  • DRM for streaming media on the "Cashier" 2011-01-24

    DRM is Digital Rights Management (Digital Right Management) technology, referred to, it is a safe on the Internet to distribute and sell digital media technology. Have you encountered this scenario: Sign the online music retail site, you can buy musi

  • Page Player Windows Media Player control method Daquan 2011-05-27 Microsoft Windows Media Player is a program of the company's current play an important part of the Media Service, is a universal media player. In the Media Service solution, Media Pla

  • Anti-anti-Daolian streaming media download 2010-04-21

    Is thousands of years have not been completely resolved. I think in the final analysis was because of the streaming media player stream the file itself can be the reasons for the address, so a simple encryption in the web page address has been less f

  • What is streaming media? 2010-06-18

    The so-called streaming media, streaming is the way used in the Internet / Intranet broadcast media formats such as audio, video or multimedia files. Streaming media player does not download the entire file before, only part of the contents into memo

  • Openi BI platform based on open source data warehouse system design and development 2010-10-08

    Now we compare the recognized business intelligence system is divided into reporting, OLAP, data warehousing, data mining, and five large ad hoc query, business intelligence system itself is only a relatively new concept, perhaps with the development

  • Android Streaming Media 2010-03-29

    Example, under the simple implementation of the android streaming media, a simple realization of the flow cache

  • Platform based on the fine analog clock Ophone.Android 2011-05-16

    This is a based on OPhone / Android platform, analog clock program clock interface is quite beautiful, in the main program uses a custom android View, graphics, multi-threaded, the date of operation of class. The following is the running effect diagr

  • Mobile Streaming Media Technology Overview 2010-03-29

    The positioning of a mobile streaming media Streaming media is simply the application of streaming technology in the network transmission of multimedia files; and streaming technology is the continuous image and sound compressed processed on the webs