Summary of the invention
In order to protect the safety of audio file to the full extent, improve the stability of audio file, reach the purpose that data are recovered, the embodiment of the invention provides a kind of recording method for synchronous, device and equipment.Described technical scheme is as follows:
First aspect, a kind of recording method for synchronous, described method comprises:
In Recording Process, obtain audio data stream;
The audio data stream that gets access to is encoded according to the preset coding form, and the data that coding is generated write audio file;
From the audio file that is writing, read data;
To server, make described server carry out synchronously according to receiving data the data upload that at every turn reads.
From the audio file that is writing, read data, comprising:
The position of data in described audio file that reads according to the last time, the reading location of transaction file;
Be set to the starting point that this reads with the read bit after upgrading in the described audio file that is writing, continue to read data.
The data upload that at every turn reads to server, being comprised:
During the recording beginning, send upload request to described server, make that described server is described audio file allocate file sign;
According to the file identification of described server-assignment, the end of file of the described file identification corresponding audio files that data upload to the server that at every turn reads is preserved.
To server, described method also comprises with the data upload that reads at every turn:
When the end of file that reads described audio file and when determining that this recording stops, end data is uploaded.
Read data packet is drawn together from the audio file that is writing:
The described audio file that is writing is divided into a plurality of file fragments, described a plurality of file fragments are read respectively.
Second aspect, a kind of recording synchronizer, described device comprises:
The audio data stream acquisition module is used in Recording Process, obtains audio data stream;
Writing module is used for the audio data stream that gets access to is encoded according to the preset coding form,, the data that coding is generated write audio file;
Data read module is used for reading data from the audio file that is writing;
Last transmission module, the data upload that is used at every turn reading make described server carry out synchronously according to receiving data to server.
The data that described data read module is used for reading according to the last time are in the position of described audio file, the reading location of transaction file; Be set to the starting point that this reads with the read bit after upgrading in the described audio file that is writing, continue to read data.
The described transmission module of going up is used for recording when beginning, and sends upload request to described server, makes that described server is described audio file allocate file sign; According to the file identification of described server-assignment, the end of file of the described file identification corresponding audio files that data upload to the server that at every turn reads is preserved.
The described transmission module of going up also is used for when the end of file that reads described audio file and definite this recording stop, and end data is uploaded.
Described data read module is used for the described audio file that is writing is divided into a plurality of file fragments, and described a plurality of file fragments are read respectively.
The third aspect, a kind of terminal equipment, terminal equipment includes memory, and one or more than one program, one of them or an above procedure stores and are configured to be carried out by the above processor of or and state one or an above program and comprise be used to the instruction of carrying out following operation in memory:
In Recording Process, obtain audio data stream;
The audio data stream that gets access to is encoded, and the data that coding is generated write audio file;
From the audio file that is writing, read data;
To server, make described server carry out synchronously according to receiving data the data upload that at every turn reads.
The beneficial effect that the technical scheme that the embodiment of the invention provides is brought is:
By in the recording audio file; data in the audio file are uploaded; realized that real-time recording is synchronous; namely can reach with record with depositing with the effect of uploading; can also make and not finish to be interrupted by accident or during unexpected deletion in recording, can recover recording substance synchronously and to greatest extent according to what on server, carried out, protect the safety of audio file; improve the stability of audio file, reach the purpose that data are recovered.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, embodiment of the present invention is described further in detail below in conjunction with accompanying drawing.
Fig. 1 is the flow chart of a kind of method for synchronous of recording that the embodiment of the invention provides.Referring to Fig. 1, described method comprises:
101, in Recording Process, obtain audio data stream;
102, the audio data stream that gets access to is encoded according to the preset coding form,, the data that coding is generated write audio file;
Wherein, the coded format of preset coding form for encoding according to frame.
103, from the audio file that is writing, read data;
104, the data upload that will at every turn read makes described server carry out synchronously according to receiving data to server.
In order to allow the fail safe of the relieved own data of user; recover user's local data to the full extent; also in order to tackle the generation of various fortuitous events; can carry out in real time synchronously recording file; namely in the process of recording, adopt with record and come backup file with the method for depositing with uploading; when having to delete the file of having stored even run into unpredictable situation like this, file that also can be after user platform recovers to delete, protected file safety to the full extent.
By in the recording audio file; data in the audio file are uploaded; realized that real-time recording is synchronous; namely can reach with record with depositing with the effect of uploading; can also make and not finish to be interrupted by accident or during unexpected deletion in recording, can recover recording substance synchronously and to greatest extent according to what on server, carried out, protect the safety of audio file; improve the stability of audio file, reach the purpose that data are recovered.
Preferable, from the audio file that is writing, read data, comprising:
The position of data in described audio file that reads according to the last time, the reading location of transaction file;
Be set to the starting point that this reads with the read bit after upgrading in the described audio file that is writing, continue to read data.
Preferable, the data upload that at every turn reads to server, being comprised:
During the recording beginning, send upload request to described server, make that described server is described audio file allocate file sign;
According to the file identification of described server-assignment, the end of file of the described file identification corresponding audio files that data upload to the server that at every turn reads is preserved.
Preferable, to server, described method also comprises with the data upload that reads at every turn:
When the end of file that reads described audio file and when determining that this recording stops, end data is uploaded.
Preferable, read data packet is drawn together from the audio file that is writing:
The described audio file that is writing is divided into a plurality of file fragments, described a plurality of file fragments are read respectively.
Fig. 2 is the flow chart of a kind of synchronous method of recording that the embodiment of the invention provides.Referring to Fig. 2, this embodiment specifically comprises:
200, terminal equipment starts sound-recording function, respectively execution in step 201 and 204;
When starting sound-recording function, the terminal equipment initialization of recording, and begin to gather sound by microphone, to obtain audio data stream, at this moment, send upload request to the server that is data synchronization service, this upload request is used for request and uploads the current audio file of recording in real time, and request server is this audio file allocate file sign of recording.
201, in Recording Process, terminal equipment obtains audio data stream;
After starting sound-recording function and the initialization of recording, need check whether the user wishes to continue recording, if, then continue to obtain obtaining of audio data stream, if not, then withdraw from sound-recording function.
202, the audio data stream that gets access to is encoded according to the preset coding form, the terminal equipment data that generate of will encoding write audio file;
Particularly, when getting access to audio data stream, terminal equipment carries out the MP3 format coding to the audio data stream that gets access to, and the data that coding is generated write audio file.
The embodiment of the invention when getting access to audio data stream, audio data stream is carried out the MP3 format coding, the audio file that the PCM data that collect is encoded to MP3 format is preserved, and constantly repeats this process and the audio-frequency information in the external world can be converted to MP3 audio file continuously.
203, when Recording Process finishes, terminal equipment replenishes the end-of-file of the audio file that gets access to, and the audio file after output replenishes finishes.
Need to prove that the cataloged procedure of this MP3 format namely is constantly to obtain audio data stream, the process of constantly encoding constantly repeats this process and the audio-frequency information in the external world can be converted to the MP3 audio file that comprises successive frame.Because the audio compression rate height of MP3 storage format, and distortion is little, therefore uses the coded format of MP3 can make things convenient for storage and the use of user to audio frequency to a great extent.And because the particularity of MP3 coded format; its coding is that a frame one frame carries out; therefore in the audio recording process; when even recording takes place to suspend; the frame of Bao Cuning is not lost before; the frame of preserving before can not losing because of the time-out of recording or interrupting device power down etc. is compared with recording of forms such as amr or 3gpp, has advantages of higher stability.
204, terminal equipment sends upload request to server;
Preferable, when detecting the terminal equipment access network, open this and upload flow process.Or, when detecting terminal equipment not during access network, the prompting user open network connection in case record synchronously, when detecting the user and open network connection, open this and upload flow process.
This upload request is used for request and uploads the current audio file of recording in real time, and request server is this audio file allocate file sign of recording.Server is the audio file allocate file sign of this recording according to the upload request of terminal equipment.
In embodiments of the present invention, server is when receiving the upload request of terminal equipment, can be the audio file allocate file sign of this recording at random, this document sign is used for terminal equipment carries when uploading data, so that server carries out corresponding preservation according to this document sign to the data that receive.
205, after terminal equipment got access to the file identification of server-assignment, the zero byte location of file was set to file reading location;
Wherein, file reading location be used for data that the current audio file of sign read and uploaded in the position of this audio file.
Preferable, when recording beginning and reading data for the first time for terminal equipment, can carry out initial setting to file reading location, the zero byte location that is about to this audio file is set to file reading location.
206, terminal equipment is set to the starting point that this reads with file read bit, reads data from the audio file that is writing;
Wherein, the size of data that at every turn reads can be default value, and this default value can be arranged when developing by the technical staff, can also be adjusted according to demand by the user, and the embodiment of the invention is not done restriction to this.
207, terminal equipment is according to the file identification of described server-assignment, the end of file of the described file identification corresponding audio files that data upload to the server that at every turn reads is preserved;
When terminal equipment carries out data upload, in the data of uploading, carry the file identification of server-assignment, when server receives the data that this carries file identification, determine the file identification corresponding audio files according to file identification, and the data that this receives are saved to the end of file of this document sign corresponding audio files, guaranteed the continuity that server side is preserved voice data.
The data upload failure need to prove, if then need continue to attempt uploading up to uploading success.
208, the position of data in described audio file that read according to the last time of terminal equipment, the reading location of transaction file;
For example, the data that last time reads are 1024 bytes of audio file, then 1024 bytes are updated to file reading location, and when this reads, be this starting point that reads with this 1024 byte location, read the later data of 1024 bytes in this audio file.
209, read before the data, terminal equipment judges whether the reading location after the current renewal is the end of file of audio file at every turn, if, execution in step 210; If not, according to the file after upgrading reading location, execution in step 206.
Preferable, because in Recording Process, need carry out reading and uploading of data at least one times, therefore, in order to guarantee reading and upload and not interrupting of data, before reading, judge whether to read the end of file of audio file according to current file reading location at every turn, whether also have data to upload to know, be the end of file of audio file when file reading location, then can end data upload, and when file reading location be not the end of file of audio file, need to continue from audio file, to read data and to upload.
Particularly, read before the data at every turn, terminal equipment judges whether the reading location after the current renewal is the end of file of audio file, if then think End of Tape, end data is uploaded, and if not, think that then recording does not finish as yet, according to the file after upgrading reading location, be set to the starting point that this reads with the read bit in the described audio file that is writing, resume studies from the audio file relaying that is writing and fetch data.
In addition, the embodiment of the invention is to read the data in the audio file and upload data instance to describe, in another implementation that the embodiment of the invention provides, the described audio file that is writing can also be divided into a plurality of file fragments, described a plurality of file fragments are read respectively, because the coding of this audio file is that a frame one frame carries out, therefore in data read and upload procedure, also can carry out segmentation to this audio file, each file fragment is a complete audio file, when terminal equipment reads a plurality of file fragments respectively and uploads onto the server, server carries out order to a plurality of file fragments and preserves, also can finish to recording synchronously, realize the purpose that the audio file of recording is backed up in realtime.
210, judge whether this recording stops, if end data is uploaded; If not, execution in step 206.
Need to prove, if uploading speed is faster than the speed of recording, might upload to the position of end-of-file so, but recording is also continuing to add new recording substance to tail of file, so need judge whether to judge also whether recording stops after the end-of-file, if recording stops, finishing the current task of uploading.
The method that the embodiment of the invention provides; by in the recording audio file; data in the audio file are uploaded; realized that real-time recording is synchronous, namely can reach with record with depositing with the effect of uploading, can also make and not finish to be interrupted by accident or during unexpected deletion in recording; can recover recording substance synchronously and to greatest extent according to what on server, carried out; protect the safety of audio file, improved the stability of audio file, reached the purpose that data are recovered.
Fig. 3 is the structural representation of a kind of synchronizer of recording that the embodiment of the invention provides.Referring to Fig. 3, described device comprises: audio data stream acquisition module 301, writing module 302, data read module 303 and last transmission module 304,
Audio data stream acquisition module 301 is used in Recording Process, obtains audio data stream; Audio data stream acquisition module 301 links with writing module 302, and this writing module 302 is used for the audio data stream that gets access to is encoded according to the preset coding form, and the data that coding is generated write audio file; This writing module 302 links with data read module 303, and this data read module 303 is used for reading data from the audio file that is writing; This data read module 303 links with last transmission module 304, and the data upload that transmission module 304 is used for reading at every turn on this makes described server carry out synchronously according to receiving data to server.
Preferable, the data that described data read module 303 is used for reading according to the last time are in the position of described audio file, the reading location of transaction file; Be set to the starting point that this reads with the read bit after upgrading in the described audio file that is writing, continue to read data.
Preferable, the described transmission module 304 of going up is used for recording when beginning, and sends upload request to described server, makes that described server is described audio file allocate file sign; According to the file identification of described server-assignment, the end of file of the described file identification corresponding audio files that data upload to the server that at every turn reads is preserved.
Preferable, the described transmission module 304 of going up also is used for when the end of file that reads described audio file and definite this recording stop, and end data is uploaded.
Preferable, described data read module 303 is used for the described audio file that is writing is divided into a plurality of file fragments, and described a plurality of file fragments are read respectively.
The device that the embodiment of the invention provides; by in the recording audio file; data in the audio file are uploaded; realized that real-time recording is synchronous, namely can reach with record with depositing with the effect of uploading, can also make and not finish to be interrupted by accident or during unexpected deletion in recording; can recover recording substance synchronously and to greatest extent according to what on server, carried out; protect the safety of audio file, improved the stability of audio file, reached the purpose that data are recovered.
Need to prove: the recording synchronizer that above-described embodiment provides is when recording is synchronous, only the division with above-mentioned each functional module is illustrated, in the practical application, can as required the above-mentioned functions distribution be finished by different functional modules, the internal structure of the equipment of being about to is divided into different functional modules, to finish all or part of function described above.In addition, the recording synchronizer that above-described embodiment provides belongs to same design with recording method for synchronous embodiment, and its specific implementation process sees method embodiment for details, repeats no more here.
The all or part of step that one of ordinary skill in the art will appreciate that realization above-described embodiment can be finished by hardware, also can instruct relevant hardware to finish by program, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium of mentioning can be read-only memory, disk or CD etc.
Fig. 4 is the structural representation of the related terminal equipment of the embodiment of the invention, and this terminal equipment can be used for implementing the recording method for synchronous that above-described embodiment provides.Specifically:
Terminal equipment 400 can comprise RF(Radio Frequency, radio frequency) parts such as circuit 110, the memory 120 that includes one or more computer-readable recording mediums, input unit 130, display unit 140, transducer 150, voicefrequency circuit 160, WiFi (wireless fidelity, Wireless Fidelity) module 170, the processor 180 that includes processing core more than or and power supply 190.It will be understood by those skilled in the art that the terminal equipment structure shown in Fig. 4 does not constitute the restriction to terminal equipment, can comprise than the more or less parts of diagram, perhaps make up some parts, perhaps different arrangements of components.Wherein:
RF circuit 110 can be used for receiving and sending messages or communication process in, the reception of signal and transmission especially, after the downlink information of base station received, are transferred to one or an above processor 180 and are handled; In addition, will be referred to up data and send to the base station.Usually, RF circuit 110 includes but not limited to antenna, at least one amplifier, tuner, one or more oscillator, subscriber identity module (SIM) card, transceiver, coupler, LNA(Low Noise Amplifier, low noise amplifier), duplexer etc.In addition, RF circuit 110 can also be by radio communication and network and other devices communicatings.Described radio communication can be used arbitrary communication standard or agreement, include but not limited to GSM (Global System of Mobile communication, global system for mobile communications), GPRS (General Packet Radio Service, general packet radio service), CDMA (Code Division Multiple Access, code division multiple access), WCDMA (Wideband Code Division Multiple Access, Wideband Code Division Multiple Access (WCDMA)), LTE (Long Term Evolution, Long Term Evolution), Email, SMS (Short Messaging Service, Short Message Service) etc.
Memory 120 can be used for storing software program and module, and processor 180 is stored in software program and the module of memory 120 by operation, and various functions are used and data are handled thereby carry out.Memory 120 can mainly comprise storage program area and storage data field, wherein, but the required application program (such as sound-playing function, image playing function etc.) of storage program area storage operating system, at least one function etc.; The data (such as voice data, phone directory etc.) created according to the use of terminal equipment 400 etc. can be stored in the storage data field.In addition, memory 120 can comprise high-speed random access memory, can also comprise nonvolatile memory, for example at least one disk memory, flush memory device or other volatile solid-state parts.Correspondingly, memory 120 can also comprise Memory Controller, so that the visit of processor 180 and 130 pairs of memories 120 of input unit to be provided.
Input unit 130 can be used for receiving numeral or the character information of input, and generation is imported with the user arranges and function control is relevant keyboard, mouse, action bars, optics or trace ball signal.Particularly, input unit 130 can comprise tactile sensitive surfaces 131 and other input equipments 132.Touch sensitive surfaces 131, be also referred to as touch display screen or Trackpad, can collect the user or near touch operation (using any suitable object such as finger, stylus or annex touching on the sensitive surfaces 131 or touching near the sensitive surfaces 131 operation such as the user) thereon, and drive corresponding jockey according to predefined formula.Optionally, touch sensitive surfaces 131 and can comprise touch detecting apparatus and two parts of touch controller.Wherein, touch detecting apparatus detects user's touch orientation, and detects the signal that touch operation is brought, and sends signal to touch controller; Touch controller receives touch information from touch detecting apparatus, and converts it to contact coordinate, gives processor 180 again, and the order that energy receiving processor 180 is sent is also carried out.In addition, can adopt polytypes such as resistance-type, condenser type, infrared ray and surface acoustic wave to realize touching sensitive surfaces 131.Except touching sensitive surfaces 131, input unit 130 can also comprise other input equipments 132.Particularly, other input equipments 132 can include but not limited to one or more in physical keyboard, function key (such as volume control button, switch key etc.), trace ball, mouse, the action bars etc.
Display unit 140 can be used for showing the information of being imported by the user or offer user's information and the various graphical user interface of terminal equipment 400 that these graphical user interface can be made of figure, text, icon, video and its combination in any.Display unit 140 can comprise display floater 141, optionally, can adopt LCD (Liquid Crystal Display, LCD), OLED forms such as (Organic Light-Emitting Diode, Organic Light Emitting Diodes) to dispose display floater 141.Further, touch sensitive surfaces 131 and can cover display floater 141, when touch that sensitive surfaces 131 detects thereon or near touch operation after, send processor 180 to determining the type of touch event, provide corresponding vision output according to the type of touch event at display floater 141 with preprocessor 180.Though in Fig. 4, touch sensitive surfaces 131 and display floater 141 and be as two independently parts realize input and input function, in certain embodiments, can will touch the integrated and realization input and output function of sensitive surfaces 131 and display floater 141.
Terminal equipment 400 also can comprise at least a transducer 150, such as optical sensor, motion sensor and other transducers.Particularly, optical sensor can comprise ambient light sensor and proximity transducer, and wherein, ambient light sensor can be regulated the brightness of display floater 141 according to the light and shade of ambient light, proximity transducer can cut out display floater 141 and/or backlight when terminal equipment 400 moves in one's ear.A kind of as motion sensor, the acceleration of gravity transducer can detect the size of the acceleration that (is generally three) on all directions, size and the direction of gravity be can detect when static, the application (such as shielding switching, dependent game, the calibration of magnetometer attitude anyhow), Vibration identification correlation function (such as pedometer, knock) etc. of mobile phone attitude can be used for identifying; As for terminal equipment 400 other transducers such as configurable gyroscope, barometer, hygrometer, thermometer, infrared ray sensor also, do not repeat them here.
Voicefrequency circuit 160, loud speaker 161, microphone 162 can provide the audio interface between user and the terminal equipment 400.Voicefrequency circuit 160 can be transferred to loud speaker 161 with the signal of telecommunication after the voice data conversion that receives, and is converted to voice signal output by loud speaker 161; On the other hand, microphone 162 is converted to the signal of telecommunication with the voice signal of collecting, by being converted to voice data after voicefrequency circuit 160 receptions, after again voice data output processor 180 being handled, to send to such as another terminal equipment, perhaps export voice data to memory 120 in order to further handle through RF circuit 110.Voicefrequency circuit 160 also may comprise earphone jack, so that communicating by letter of peripheral hardware earphone and terminal equipment 400 to be provided.
WiFi belongs to the short range wireless transmission technology, terminal equipment 400 by WiFi module 170 can help that the user sends and receive e-mail, browsing page and visit streaming video etc., it provides wireless broadband internet visit for the user.Though Fig. 4 shows WiFi module 170, be understandable that it does not belong to must constituting of terminal equipment 400, fully can be as required in the scope of the essence that does not change invention and omit.
Processor 180 is control centres of terminal equipment 400, utilize various interface to be connected the various piece of whole mobile phone with circuit, by moving or carry out software program and/or the module that is stored in the memory 120, and call the data that are stored in the memory 120, carry out various functions and the deal with data of terminal equipment 400, thereby mobile phone is carried out integral monitoring.Optionally, processor 180 can comprise one or more processing cores; Preferably, processor 180 can integrated application processor and modem processor, and wherein, application processor is mainly handled operating system, user interface and application program etc., and modem processor is mainly handled radio communication.Be understandable that above-mentioned modem processor also can not be integrated in the processor 180.
Terminal equipment 400 comprises that also the power supply 190(that powers to each parts is such as battery), preferably, power supply can link to each other with processor 180 logics by power-supply management system, thereby realizes functions such as management charging, discharge and power managed by power-supply management system.Power supply 190 can also comprise one or more direct current or random component such as AC power, recharging system, power failure detection circuit, power supply changeover device or inverter, power supply status indicator.
Although not shown, terminal equipment 400 can also comprise camera, bluetooth module etc., does not repeat them here.Specifically in the present embodiment, the display unit of terminal equipment is touch-screen display, terminal equipment also includes memory, and one or more than one program, one of them or an above procedure stores and are configured to be carried out by the above processor of or and state one or an above program and comprise be used to the instruction of carrying out following operation in memory:
In Recording Process, obtain audio data stream;
The audio data stream that gets access to is encoded according to the preset coding form, and the data that coding is generated write audio file;
From the audio file that is writing, read data;
To server, make described server carry out synchronously according to receiving data the data upload that at every turn reads.
Alternatively, in the memory of described terminal, also comprise for the instruction of carrying out following operation:
The position of data in described audio file that reads according to the last time, the reading location of transaction file;
Be set to the starting point that this reads with the read bit after upgrading in the described audio file that is writing, continue to read data.
Alternatively, in the memory of described terminal, also comprise for the instruction of carrying out following operation:
During the recording beginning, send upload request to described server, make that described server is described audio file allocate file sign;
According to the file identification of described server-assignment, the end of file of the described file identification corresponding audio files that data upload to the server that at every turn reads is preserved.
Alternatively, in the memory of described terminal, also comprise for the instruction of carrying out following operation:
When the end of file that reads described audio file and when determining that this recording stops, end data is uploaded.
Alternatively, in the memory of described terminal, also comprise for the instruction of carrying out following operation:
The described audio file that is writing is divided into a plurality of file fragments, described a plurality of file fragments are read respectively.
The terminal equipment that the embodiment of the invention provides; by in the recording audio file; data in the audio file are uploaded; realized that real-time recording is synchronous, namely can reach with record with depositing with the effect of uploading, can also make and not finish to be interrupted by accident or during unexpected deletion in recording; can recover recording substance synchronously and to greatest extent according to what on server, carried out; protect the safety of audio file, improved the stability of audio file, reached the purpose that data are recovered.
The above only is preferred embodiment of the present invention, and is in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.