CN107544799A - A kind of method being packaged to built-in function - Google Patents

A kind of method being packaged to built-in function Download PDF

Info

Publication number
CN107544799A
CN107544799A CN201710718373.6A CN201710718373A CN107544799A CN 107544799 A CN107544799 A CN 107544799A CN 201710718373 A CN201710718373 A CN 201710718373A CN 107544799 A CN107544799 A CN 107544799A
Authority
CN
China
Prior art keywords
function
state machine
built
data
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201710718373.6A
Other languages
Chinese (zh)
Inventor
李诗瑶
张晓萍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Clear Victory Technology Co Ltd
Original Assignee
Shenzhen Clear Victory Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Clear Victory Technology Co Ltd filed Critical Shenzhen Clear Victory Technology Co Ltd
Priority to CN201710718373.6A priority Critical patent/CN107544799A/en
Publication of CN107544799A publication Critical patent/CN107544799A/en
Pending legal-status Critical Current

Links

Abstract

The present invention relates to the present invention relates to computer technology, Software Industry FIELD OF THE INVENTIONThe, a kind of method being packaged to built-in function is disclosed, it is characterised in that:Using two data structures and a state machine interface routine, the function of built-in function is realized by state machine interface routine, application program tells what this state machine interface routine will do by one of data structure(Function), state machine interface routine go it is specific complete how to do, and responded by another data structure be made whether success or failure;The method of this encapsulation realizes the loose coupling of application program and built-in function, avoids caused by application program largely calls built-in function and safeguards with debugging the problem of difficult so that connection interface is clear between program, and is easy to asynchronous development, upgrading and transplanting convenient.

Description

A kind of method being packaged to built-in function
Technical field
The present invention relates to computer technology, Software Industry field, more particularly to a kind of method being packaged to built-in function 。
Background technology
In field of software development, some outside storehouses introduced are often used(Commonly referred to as third party library function).It is logical It is often with static library(Lib)Or dynamic base(DLL)Form provide, and with can call this storehouse external function one or More header files(h).In this or these header file h, the built-in function that can be called is provided(Commonly referred to as API functions)'s Data structure and data definition that function name, function parameter description and built-in function use etc..These different API built-in functions Function and the effect in this storehouse are completed jointly, but from the point of view of function category, can be divided into the function of different stage.Some are most The function on basis(Such as the 3rd grade of function of Fig. 1);Some are the functions in intermediate layer(Such as the 2nd grade of function of Fig. 1);Some are close to existing The power function applied in fact(Such as Fig. 1 the 1st grade of function).Intergrade function can call wherein one or more most basic letters Number, and closest to practical application the 1st grade of function may calling section centre layer functions, even can also call some bottoms Function(Fun_1 functions such as Fig. 1 had both called middle layer functions Fun_11, Fun_12, also called most basic function Fun_121).
In the h header files in storehouse, the data corresponding to the API functions of the above-mentioned different stage in this storehouse can be provided and enumerated and determined Justice, data structure definition and each can API Function return type, function name, function parameter(One function is sometimes Time is the multiple parameters of different pieces of information structure or type).Product development software engineer is common to do after these storehouses are taken Method is these contents by analyzing h header files, and these storehouses and its header file are covered to the software project work of oneself product Cheng Zhong, and according to the function name defined in header file h, function parameter and its data definition, in the software program of oneself Quote or directly invoke these built-in functions(Including its 1st grade of function, middle layer functions or underlying basis function).As Fig. 2 shows Meaning, it can be seen that the incidence relation between application program and built-in function is extremely complex, that is, so-called " tight coupling occurs Close ";If this storehouse is very simple, only a small amount of built-in function, and data parameters, data structure and the technology in this storehouse If background is all fairly simple, then this method directly invoked or feasible.But if the technical background in this storehouse is very It is deep, can not ensure all related product development software engineers digest in a short time this storehouse background and data structure, If relation inside built-in function, then call these built-in functions in large quantities in consumer products program, be just difficult to avoid that appearance The problem of parameter uses mistake or function call order mistake etc. a large amount of.It will be apparent that so in different application programs The method for directly invoking storehouse API functions, it is a difficulty by the exploitation debugging to application software and maintenance.
The content of the invention
It is an object of the invention to provide a kind of method being packaged based on user function angle to built-in function, it is intended to solves Certainly the problems of the prior art.
The present invention is achieved in that a kind of method being packaged to built-in function, it is characterised in that:Using two data Structure and a state machine interface routine, the function of built-in function is realized by state machine interface routine, and application program passes through wherein One data structure tells what this state machine interface routine will do(Function), state machine interface routine go it is specific complete Into how doing, and responded by another data structure be made whether success or failure.
Further, the user's request that a data structure storage application program is sent(Command function)And parameter, with Data necessary to expressing " what does ".At least one argument table of the data structure reaches user's request(Command function)Volume Code, the quantity n of corresponding user's request.Its coded format is arranged by consulting, and does not limit whether digital, letter or other codings; I.e. this coding can be continuous, can also be discontinuous, but must be unique corresponding.
Further, the result that a data structure storage configuration machine interface routine performs to some command function, with Data necessary to expression " how be made ".User's request performed by least one variable of the data structure is corresponding(Function Order)Coding, the quantity n of corresponding user's request.Its coded format through negotiation arrange, do not limit whether numeral, letter or Other codings;I.e. this coding can be continuous, can also be discontinuous, but must be unique corresponding.
Further, data structure A is the data of application program write-in, and data structure B is state machine interface journey The data of sequence write-in.Application program may only read but cannot write data to data structure B;State machine interface routine It may only read but data structure A cannot be write data to.
Further, state machine interface routine is made up of at least 1 " listening state ", n " functional status ".Prison Listen state to be responsible for monitoring and check whether upper level applications send new command function request, and this command request is analyzed After reasonability, the functional status of one of this n request is jumped to.Different functional statuses then completes the calling to built-in function, real The command request of this existing function.
Further, application program is not to directly invoke built-in function, but is interacted with the two data structures.By One bank interface state machine program goes specifically to call storehouse API functions.In order to which maintenance is convenient, this storehouse can generally be connect Mouth state machine program is individually write in a file, is programmed by expert engineer or is safeguarded.Can also be by this bank interface State machine program is write as new storehouse compiled format.If bank interface state machine program to be compiled into new storehouse, this storehouse just unlike Common storehouse, it does not have any API functions for being available for calling, can only see two data structures A and B of both sides' interaction.
Compared with prior art, the method for this encapsulation realizes the loose coupling of application program and built-in function, and avoiding should Maintenance is with debugging the problem of difficult caused by built-in function is largely called with program.The method for packing makes interface circle between calling program Face is clear, and is easy to asynchronous development, upgrading and transplanting convenient.
Brief description of the drawings
Fig. 1 is the schematic diagram of prior art;
Fig. 2 is the schematic diagram of prior art;
Fig. 3 is the schematic diagram of the interface state machine program description figure of the present invention;
Fig. 4 is the schematic diagram of the package shelf composition of the present invention;
Fig. 5 is the schematic diagram of the bank interface state machine program figure of the present invention.
Embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, it is right below in conjunction with drawings and Examples The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and It is not used in the restriction present invention.
The method of built-in function encapsulation provided by the invention, is adapted to computer, tablet personal computer, smart mobile phone, various insertions Formula smart machine.With reference to the embodiment of a media player, the present invention is described in detail.
Shown in reference picture 3, Fig. 4 and Fig. 5, preferred embodiment is provided for the present invention.
Media player is a popular electronic product.Videocorder, CD machines, MP3, MP4 of early stage, and intelligent hand Machine can be referred to as the media player of different times.With advances in technology, there is the media data of various coded formats Deposit file, or the form of different encoding and decoding performances.Such as the form of audio has CD, VOB, 3GP, WAV, MP1/MP2/ MP3, APE, MIDI, WMA, RealAudio, VQF etc..Video similarly has a large amount of different forms, such as AVI, MPEG/ MPG/DAT, JPEG, RM, WMV, MOV, H.264, H.265 etc..In fact, most products PHP also is difficult to The form of audios all in the world, video data file is distinguished clear.With the continuous progress of technology, compression there is also Than bigger, the good video/audio encoding and decoding algorithm of fidelity.If different program points goes to call some in the application Algorithm built-in function, the basic function how played with recording is not only handled, format analysis, broadcasting ginseng also to played file Several settings(Including sampled voice frequency, sound channel, sound velocity, intelligent echo cancellor, wave filter etc.), then this product is soft Part development and maintenance workload is very huge.
In fact, from the user perspective finally used, it is indifferent to or is unfamiliar with these forms, only it is expected to accomplish pair Some file carries out normal play, quickly plays, suspends, continuing the demand that plays, record;The data file file of broadcasting exists Where deposit, which device resource source is the equipment of broadcasting be on.
According to the spirit of patent of the present invention, we can define following data structure A:
typedef struct
{
MEDIA_CMD cmd;// user function demand(Order)Coding
MEDIA_FILE file;// it is to be played or record file name(Deposit path)
MEDIA_SOURCE source;// broadcasting or the setting resource name in path
}A;
Amedia_A;// definition data structure body A global variable media_A
With following enumeration definition user's request(Order)Coding:(Additionally one idle commands IDLE of increase)
typedef enum
{
PLAY=0, // normal play
FAST_PLAY, // quickly play
PAUSE, // pause play
CONTINUE, // continue to play
RECORD, // record
IDLE // free time
} MEDIA_CMD;// user function demand(Order)Coding
File f ile is the path deposited with string representation:
typedef unsigned char* MEDIA_FILE;
The device resource source of broadcasting, expressed with a device id:
typedef unsigned short MEDIA_SOURCE;
Similarly, according to the spirit of patent of the present invention, we can define following data structure B:
typedef struct
{
MEDIA_CMD exec_cmd;// it is carrying out user function demand(Order)Coding
EXEC_STATE exec_state;// the functional status being carrying out
OK_ERROR exec_result;// run succeeded or failure flags
ERROR_CODE error_code;// perform the error code to fail
} B;
B media_B;// definition data structure body B global variable media_B
EXEC_STATE is enumerated in definition, expresses following state machine:
typedef enum
{
WAIT_STATE=0, // listening state
PLAY_STATE, // normal playing status
FAST_PLAY_STATE, // quick broadcast state
PAUSE_PLAY_STATE, // pause broadcast state
CONTINUE_STATE, // continue broadcast state
RECORD_STATE // recording state
} EXEC_STATE;
OK_ERROR is enumerated in definition:
typedef enum
{
ERROR = 0,
OK = 1
}
Definition performs the error code of failure(Citing):
typedef enum
{
ERROR_FILE_NOFOUND=0, // file can not find
ERROR_SOURCE_NOOPEN=1, // device resource are not switched on
ERROR_UNKNOWN_FORMAT=2, // file format are not supported
}
Fig. 3 is shown in interface state machine program description:
Interface state machine program(Assuming that entitled StateMachine ()), it runs in the major cycle of application program.Initially Change media_B. exec_state=WAIT_STATE(If it is necessary, it can also additionally increase an init state). Its " listening state " WAIT_STATE, constantly read data structure A command request(media_A.cmd)Whether it is one Individual effective order(PLAY、FAST_PLAY、PAUSE、CONTINUE、RECORD), then one is gone to corresponding to the effective order Functional status(PLAY_STATE、FAST_PLAY_STATE 、PAUSE_STATE、CONTINUE_STATE、RECORD_ STATE).In these functional statuses, according to the API functions of audio frequency and video algorithm place offer(Such as check and read to be played File f ile function Open_file, Study document form function Analyse_Format, the function for playing different-format PLAY_CD/PLAY_WAV/Play_MP3/Play_APE/Play_MIDI/Play_WMA etc., sampled voice frequency, sound are set Road, the function Set_Parameter of sound velocity, the intelligent echo cancellor function Set_Echo of setting, wave filter Set_Filter Deng).When these functions perform normal, then state, the order for telling media_B to be carrying out are responded to data structure B exec_cmd(Its corresponding media_A. cmd), be carrying out functional status exec_state, run succeeded or failure mark Will exec_result simultaneously provides corresponding error code to error_code in failure.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all essences in the present invention All any modification, equivalent and improvement made within refreshing and principle etc., should be included in the scope of the protection.

Claims (6)

  1. A kind of 1. method being packaged to built-in function, it is characterised in that:Connect using two data structures and a state machine Mouth program, the function of built-in function is realized by state machine interface routine, and application program tells this by one of data structure What individual state machine interface routine will do(Function), state machine interface routine go it is specific complete how to do, and by addition One data structure respond be made whether success or failure.
  2. A kind of 2. method being packaged to built-in function as claimed in claim 1, it is characterised in that:One data structure is deposited Put the user's request that application program is sent(Command function)And parameter, to express data necessary to " what does ", the data knot At least one argument table of structure body reaches user's request(Command function)Coding, the quantity n of corresponding user's request, its coded format By consulting to arrange, whether digital, letter or other codings are not limited;I.e. this coding can be continuous, can also be not Continuously, but must be unique corresponding.
  3. A kind of 3. method being packaged to built-in function as claimed in claim 1, it is characterised in that:One data structure is deposited The result that state machine interface routine performs to some command function is put, with data, the data necessary to expression " how be made " User's request performed by least one variable of structure is corresponding(Command function)Coding, the quantity n of corresponding user's request, its Coded format is arranged by consulting, and does not limit whether digital, letter or other codings;I.e. this coding can be it is continuous, It can be discontinuous, but must be unique corresponding.
  4. A kind of 4. method being packaged to built-in function as claimed in claim 1, it is characterised in that:Data structure A is should With program write data, data structure B be state machine interface routine write-in data, application program may only read but Data structure B cannot be write data to;State machine interface routine may only read but cannot write data to data knot Structure body A.
  5. A kind of 5. method being packaged to built-in function as claimed in claim 1, it is characterised in that:State machine interface routine is It is made up of at least 1 " listening state ", n " functional status ", listening state is responsible for monitoring and checking upper level applications New command function request whether is sent, and by after this command request analysis reasonability, jumps to one of this n request Functional status, different functional statuses then complete the calling to built-in function, realize the command request of this function.
  6. A kind of 6. method being packaged to built-in function as claimed in claim 1, it is characterised in that:Application program is not direct Built-in function is called, but is interacted with the two data structures, is gone specifically to call storehouse by a bank interface state machine program API functions, in order to which maintenance is convenient, generally this bank interface state machine program can be individually write in a file, by Expert engineer is programmed or safeguarded, this bank interface state machine program can also be write as to new storehouse compiled format, if Bank interface state machine program is compiled into new storehouse, just unlike common storehouse, it does not have any API for being available for calling in this storehouse Function, it can only see two data structures A and B of both sides' interaction.
CN201710718373.6A 2017-08-21 2017-08-21 A kind of method being packaged to built-in function Pending CN107544799A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710718373.6A CN107544799A (en) 2017-08-21 2017-08-21 A kind of method being packaged to built-in function

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710718373.6A CN107544799A (en) 2017-08-21 2017-08-21 A kind of method being packaged to built-in function

Publications (1)

Publication Number Publication Date
CN107544799A true CN107544799A (en) 2018-01-05

Family

ID=60958371

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710718373.6A Pending CN107544799A (en) 2017-08-21 2017-08-21 A kind of method being packaged to built-in function

Country Status (1)

Country Link
CN (1) CN107544799A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101980167A (en) * 2010-10-19 2011-02-23 上海富士施乐有限公司 Operation mode of task state machine management mechanism of embedded real-time operating system
CN103166824A (en) * 2011-12-13 2013-06-19 华为技术有限公司 Interconnection method, device and system
CN103885782A (en) * 2014-04-03 2014-06-25 南京南瑞继保电气有限公司 Visual programming page program library function packaging and reusing method
WO2016186975A1 (en) * 2015-05-15 2016-11-24 Virsec Systems, Inc. Detection of sql injection attacks
CN106453536A (en) * 2016-09-29 2017-02-22 车智互联(北京)科技有限公司 Network request processing method and system and server

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101980167A (en) * 2010-10-19 2011-02-23 上海富士施乐有限公司 Operation mode of task state machine management mechanism of embedded real-time operating system
CN103166824A (en) * 2011-12-13 2013-06-19 华为技术有限公司 Interconnection method, device and system
CN103885782A (en) * 2014-04-03 2014-06-25 南京南瑞继保电气有限公司 Visual programming page program library function packaging and reusing method
WO2016186975A1 (en) * 2015-05-15 2016-11-24 Virsec Systems, Inc. Detection of sql injection attacks
CN106453536A (en) * 2016-09-29 2017-02-22 车智互联(北京)科技有限公司 Network request processing method and system and server

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
GCCZHONGDUAN: "软件设计之状态机", 《HTTPS://WWW.CNBLOGS.COM/GCCZHONGDUAN/P/5341998.HTML》 *

Similar Documents

Publication Publication Date Title
JP4907653B2 (en) Aspects of media content rendering
CN101416139B (en) Systems and methods for enhanced haptic effects
US7028127B2 (en) Method of controlling portable personal device having facilities for storing and playing digital contents by computer and portable personal device operation method therefor
US7861150B2 (en) Timing aspects of media content rendering
JPH09503070A (en) Object-oriented MIDI system
JPH09503081A (en) Object-oriented video system
JPH09503080A (en) Multimedia data routing system
CN101447994A (en) Method for downloading and playing multimedia file and equipment thereof
CN107251009A (en) Digital audio frequency filter for variable sample rates
EP1908072A2 (en) State-based timing for interactive multimedia presentations
CN103914312B (en) The processing method of application program, device and electronic equipment
CN106528040A (en) Method and apparatus for improving audio quality of android device
CN102799432A (en) Game video recording and replaying method based on recorded drawing instruction
CN105138625B (en) A kind of method cooperateing with art music and the cloud system for musical composition
JP2014520352A (en) Enhanced media recording and playback
JP5335416B2 (en) System for abstracting audio / video codecs
CN102819851A (en) Method for implementing sound pictures by using computer
Thalmann et al. The semantic music player: A smart mobile player based on ontological structures and analytical feature metadata
CN107544799A (en) A kind of method being packaged to built-in function
CN107783866A (en) The method of testing and device of a kind of multimedia equipment
CN104616679B (en) A kind of method and device for improving Android system audio recording and reproducing quality
US9762704B2 (en) Service based media player
US20130204413A1 (en) Audio Hyperlinking
CN112883220A (en) Audio processing method, audio processing apparatus, and readable storage medium
KR102340350B1 (en) System and method for preserving digitized material

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20180105