"Turn" water boiled tcpmp

Source: Internet
Author: User

At the end of last year to help others to do a project, understand the TCPMP, think the structure of the software is well written to do some records, today accidentally turned out to see that may be the people who are studying the software a little help to post it. If reproduced please indicate the source, thank you. TCPMP is a powerful open source multimedia player that consists mainly of core framework modules (common engineering) and decoder splitter plug-ins. TCPMP plug-ins are very many, Libmad we combine a few of the most common plug-ins (FFmpeg, splitter) to illustrate, where interface plug-in implementation of TCPMP interface, because he and the media play no relationship, this part can be completely replaced, Replace it with your own interface. FFMPEG Engineering is the main system of audio and video decoding module, FFmpeg is a set of recording, conversion, audio/video encoding and decoding functions as one of the complete open source solution. The development of FFmpeg is based on the Linux operating system, but it can be compiled and used in most operating systems. FFmpeg support MPEG, DivX, MPEG4, AC3, DV, FLV and more than 40 kinds of encoding, AVI, MPEG, OGG, Matroska, ASF and more than 90 kinds of decoding. Many open source players use the ffmpeg. But the FFMPEG program decoding efficiency is not very high, the system only uses the FFmpeg partial decoding function. FFmpeg main directory has libavcodec, Libavformat and Libavutil subdirectories. Wherein the LIBAVCODEC is used for storing each Encode/decode module, Libavformat for storing muxer/demuxer module, libavutil for storing memory operation and other common modules. The system's media file splitter has a separate splitter module complete so no Libavformat subdirectories are required. FFmpeg directory libavcodec, libavutil reserved subdirectories. Libmad works for MP3 file decoding, the project contains two function modules, one is responsible for parsing the MP3 file format, including MPEG1 audio files (Mp1,mp2,mp3,mpa), reading each frame of audio data, the other is responsible for decoding the MPEG1 audio data, The decoding code is in the Libmad subdirectory. Libmad is an open source, high-precision MPEG1 audio decoding library that supports MPEG-1 (layer I, layer II, and LAYERIII, which is MP3). The Libmad provides a 24-bit PCM output that is fully fixed-point and is ideal for use on platforms without floating-point support. Using a series of APIs provided by Libmad, it is very simple to implement the MP3 data decoderFor In the Mad.h file under the source code file directory of Libmad, you can see most of the data structure and API of the library. Libmad is used Fixed-integer, by integer analog decimal calculation, precision can only be guaranteed to the 9th digit after the decimal point (greater than 0 of the minimum 0.00000000372529), although the decoding accuracy will have a loss, but greatly improved the decoding efficiency, Especially in the embedded device can also achieve high bitrate MP3 file decoding. Splitter engineering is used to parse multiple audio and video file formats. The file formats that can be parsed include: ASF media files, video files (AVI,DIVX), Windows waveform files (WAV,RMP), MPEG movie Files (MPEG,MPG,MPV), MPEG4 files (mp4,3gp,m4a,m4b,k3g). The above format can be parsed but the data encoding does not necessarily decode correctly, it needs to rely on the decoder of the system. Common engineering is the core module, is an open set of data input, conversion, audio/video decoding, signal output and other functions as one of the complete multimedia playback framework. The framework itself does not contain any decode and split functions, these functions are implemented by plug-ins, the core module in a tree structure to manage all functional modules and plug-in modules, to achieve data render function, the input, conversion, output process Control, accept the playback process and processing of events, At the same time, it also realizes some common functions commonly used in the system operation, such as inverse discrete cosine transform, memory operation, multi-language character processing which is used in the interface. The main contents of the common project are as follows: Blit, Dyncode, overlay, PCM, SOFTIDCT, Win32, Zlib and other sub-directories. wherein Blit and overlay storage is a video signal rendering module, PCM storage PCM audio signal conversion module, SOFTIDCT storage inverse discrete cosine transform function, Win32 storage memory operation and other common modules, Dyncode This directory code is more obscure, Store is the program run is dynamically generated code module, for different CPU instruction set, PCM data channel and sampling rate different, video rendering data format and color depth, and other different situations dynamically generated different optimization code (this code is very exciting, not to let people admire TCPMP author's superb level). The core module has a context object, the object in the initialization function bool_t context_init (...) An instance of the object is created in the middle. This object instance record manages each function module, which can be used by the user interface to interact with the core module and manage the playback process. Context Object Description: typedef struct context{INT Version;  Version information uint32_t ProgramID;  Const tchar_t* ProgramName; Application name Const tchar_t* programversion;   Program version number, string const tchar_t* cmdline;   program command line information void* Wnd;  Video rendering window handle void* nodelock;   Function module access critical section mutex variable array Node;  Function module data Object array Nodeclass; The function module defines an array of objects and organizes the array Nodeclasspri according to the system logical relationship;  The function module defines an array of objects, arranged in accordance with system logic and module precedence array nodemodule;  External plug-in module array int loadmoduleno; The number of external plug-ins currently being loaded void* LoadModule;  Array strtable[2]; String resource array, the string is divided into//to the underlying use of the standard string resources and//to the interface using the display string resources, two resources with two arrays to represent the array strbuffer;  Array Strmodule;  void* Strlock not used;   String array access critical section mutex variable uint32_t Lang;   Currently using the language flag int CodePage; Currently using code page flag struct pcm_soft* PCM; PCM audio signal Conversion module struct blitpack* Blit; Video signal Rendering module struct node* Platform; Get platform-related information struct node* advanced;  Get the Player module advanced information struct node* player;   Playback control module Notify Error; Information Error callback function//screen rotation information, in some systems the screen can be rotated 90 degrees or 180 degrees int (*hworientation) (void*); void *hworientationcontext;  bool_t trydynamic;   int settingspage not used;  size_t startupmemory not used; CanTo use the number of valid memory bool_t inhibernate;   Whether to enter the dormant state bool_t waitdisable;     int Ftrid not used;  bool_t lowmemory not used; Can use the number of valid memory is less than the minimum requirements of the system//dynamic code Generation intermediate state and data bool_t codefailed; bool_t Codemoveback; bool_t Codedelayslot; void* Codelock; void* Codeinstbegin; void* Codeinstend; int Nextcond; bool_t Nextset; bool_t Nextbyte; bool_t nexthalf;  bool_t nextsign;  uint32_t* Flushcache; void* CharConvertUTF8 not used; void* Charconvertcustom not used;  int customcodepage not used; void* charconvertascii not used; void* application not used;    void* Logger;  bool_t Keepdisplay not used; Whether to keep the backlight long bright int disableoutofmemory; The core module context pointer can be obtained by global function context* context (); The global function that initializes the context object is bool_t context_init (const tchar_t* Name,const tchar_t* version,int id,const tchar_t* cmdline,void* application), where the name parameter is the application name and version is the release information string. The global function that releases the context object is void Context_done (); void Context_wnd (void*); the function initializes the video playback window handle to the device context. The function module contains the definition object and the data object, defines the logical structure of the function module, and the data Object records the module properties and methods. All the function module structure is organized by a tree structure, the structure is as follows, node is the root node of the whole structure, under the Sub-node, the node can be divided into real node by type, global node, set node, abstract node. #define Cf_size 0x00ffffff#define cf_global 0x01000000#define cf_settings 0x02000000#define CF_ABSTRACT 0x08000000 Abstract Section Points do not have corresponding object instances, such as C + + 's abstract base class, in order to logically relate to the organization system structure, such as node is the abstract nodes. Global nodes have only one instance of an object globally, such as the playback control module PLAYER_ID. Set the node representation and system playback settings related, such as the Sound Equalizer module equalizer_id, Color control module COLOR_ID. The real node is different from the abstract node, that is, the node that can generate the object instance, the real node does not have a special identity, usually the data object occupies memory size to indicate whether it is a real node, when the node is created to allocate memory unit according to this information, the real node can have child nodes, for example: mms_id parent node is http_id. Global node, the set node and the real node can be combined, such as the playback control node is also a global node, set node and real node.    The node name is the real node after the _id, otherwise it is the abstract node.   Node (root node) ├─flow (Flow control Module) │├─CODEC (decoding module) ││├─equalizer_id (sound Equalizer module) ││├─vbuffer_id (video buffer module) ││  ├─DMO (DirectX Media Object) │││├─wmv_id│││├─wms_id│││├─wmva_id│││├─wma_id│  ││└─wmav_id││├─ffmpeg VIDEO (FFMPEG decoding module) ││└─libmad_id (Libmad Mp3 decoding module) │├─out (signal rendering module) ││    ├─aout (audio signal rendering) │││├─nullaudio_id│││└─waveout_id││└─vout (video signal rendering) ││├─nullvideo_id ││└─OVERLAY│├─IDCT (Discrete cosine decoding module) ││└─SOFTIDCT_ID│└─CODECIDCT (Discrete cosine decoding module, less function than IDCT) │└─mpeg1_id├─media (media file format Encoding parsing module) │├─format (Format parsing module)  ││└─formatbase││├─rawaudio│││└─mp3_id││├─rawimage││├─asf_id│ │├─avi_id││├─mp4_id││├─mpg_id││├─nsv_id││└─wav_id│├─playlist ( Playlist module) ││├─asx_id││├─m3u_id││└─pls_id│└─streamprocess (Data stream processing module) ├─stream (data input module) │ ─MEMSTREAM_ID (Memory data stream module) │├─file_id (file IO module) │└─http_id (Network data Acquisition module) ├─timer (Timer module) │└─systimer_id├─as  sociation_id (File extension auto-correlation module) ├─advanced_id (Advanced Setup module) ├─color_id (Color control module) ├─platform_id (Platform information module) ├─xscaledriver_id        (Intel xscale CPU information Module) ├─player_id (playback control module) └─player_buffer_id (playback buffer module) The node tree structure is implemented by several statically defined object (NODEDEF) instances.   typedef struct NODEDEF {int Flags;   int Class;   int ParentClass;   int priority;   Nodecreate Create; Nodedelete Delete; } nodedef; Flags represents the type of the current node: abstract, real node, global, setting. class represents the identity of the current node, such as Media_class or asf_id, and so on. ParentClass represents the parent node identity of the current node, such as the parent node of the Systimer_id object is Timer_class. Priority indicates the current node precedence. Create and delete are two function pointers that represent the creation and destruction functions of the node. If the structure definition of the playback control module is static const nodedef player = {sizeof (player_base) | cf_global|  Cf_settings, player_id, Node_class, pri_maximum+600, (Nodecreate) Create, (Nodedelete) Delete,}; Most nodes have a corresponding data object, record the data and methods of the node, each child node object is a parent node object as an element of that node, similar to C + + encapsulation inheritance mechanism. If the parent node of a child node does not have a data object, the node can inherit directly from node nodes.    Each node can be viewed as a direct or indirect child node of a node, so all nodes nod to the same node structure, and the child nodes may have their own attributes, which are the child nodes ' own elements after inheriting the parent object.  typedef struct Node {int Class;  Nodeenum Enum;  Nodeget Get; NodeSet Set; } node; class represents the identity of the object, such as player_id. An enum is a function pointer to a function that enumerates the properties of the current node. Get is a function pointer that gets the value of a property of the current node.  Set is a function pointer that sets the value of a property of the current node. The attribute value data attribute of a node is in a static const datatable xxxparams[] = {...}; is defined in the static array.  typedef struct DataTable {int No;  int Type;  int Flags;  int FORMAT1; int Format2;   } DataTable; No indicates that the identity of the property, such as the # define Player_play 0x32 of the playback control module, indicates that the player is playing or pausing. Type represents the data type of the property, the available values are in nodDefined in E.h. Flags are flags of attribute data, indicating whether the data is read-only, has a maximum minimum, and so on, and the available values are defined in node.h, and if the flag contains Df_setup and does not contain df_nosave and df_rdonly attributes, the property is recorded in the registry. Initialize the property with data from the registry the next time it is started.  FORMAT1 and FORMAT2 are optional flags for use with flags, such as if flags indicates that the attribute has a maximum minimum value, FORMAT1 and FORMAT2 can represent the minimum and maximum values, respectively. In the System context object, there are two elements that record the node information, and array nodeclass;,array is the array data type, node is an array of nodes data objects, an array of Nodeclass node objects, organized according to the system logic relationship. When you create a node, you pass in the Nodedef object-to-node creation function, which generates a corresponding Nodeclass object based on the Nodedef information and adds it to the Nodeclass array, allocating the memory space of the data object based on the Nodedef information. The node's data object is initialized inside the CREATE function of the node. In all function modules and interface interaction is mainly the playback control module struct node* player; Use the following method: context* p = context ();p layer* myplayer = null;if (p) Myplayer = (play er*) (P->player), control playback parameters using Set (void* this,int no,const void* data,int Size), function, the first argument is the play module pointer, the second parameter is the control code, that is, what to do, The third parameter is the value that needs to be assigned to the control code, and the last parameter is the size of the memory used for the assigned value. For example, the code to start playing is: Myplayer->set (myplayer,player_play,1,sizeof (int)); Player_play is the control code, which indicates that the playback pause function is currently controlled, and a value of 1 means that playback is 0 for pause. Get a control property using Get (void* this,int no,void* data,int Size); function, the parameter means the same as the set function. The control code is a set of macros defined in the Player.h file. More important control parameters are//play or pause (bool_t) #define Player_play 0x32//position inFraction (fraction) #define Player_percent 0x25//position in time (tick_t) #define PLAYER_POSITION 0x28//current format (format*) #define PLAYER_FORMAT 0x2b//current file in playlist (int.) #define PLAYER_LIST_CURRENT 0x2f//Current File ind  EX (suffled) in playlist (int) #define PLAYER_LIST_CURRIDX 0xa2//fullscreen mode (bool_t) #define Player_fullscreen 0x3e//  Stop#define player_stop 0xb2//Skin viewport Rectangle (rect) #define PLAYER_SKIN_VIEWPORT 0x3c playback control module all available parameters see static const DataTable playerparams[] structure. Add a media file to the playback module using int playeradd (player* player,int Index, const tchar_t* Path, const tchar_t* Title); The first argument is the play module pointer, The second parameter is the ordinal that is added to the playlist file queue, if the parameter is set to 0, the third parameter is the directory and name of the media file, and the fourth parameter is the media file title, which can be ignored. The core module also manages multi-language strings, using the function const tchar_t* LANGSTR (int class, int id), and the const tchar_t* langstrdef (int class, int id) to get the corresponding string, There are two types of system string resources, standard strings and special character set strings. The standard string resource file is the Lang_std.txt file under the project directory, which is an ASCII character that can be compatible with other code page characters. This file records the strings that are required for the core module to run, and the encoding format and file format that the decode and Splite modules can handle are also recorded in this file, such as mp3_0001=audio/in the Lang_std.txt file.mpegmp3_0002=mp1:a;mp2:a;mp3:a;mpa:amp3_0200=acodec/0x0055 records the file types, extensions, and file signatures of the MP3 file splitter. To get a standard string using the function Langstrdef, the first parameter represents the character category, and the second parameter represents the character ID. The interface is related to a special character set string, using the function Langstr, the first parameter represents the character category, and the second parameter represents the character ID.  The meaning of the structure of the string resource file is described in a later document. Transferred from: http://blog.csdn.net/navi_dx/archive/2007/11/14/1885780.aspx

"Turn" water boiled tcpmp

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.