Summary of the invention
The invention provides a kind of control method and device of the storage of recording a video, during the speed of the storage data that the speed that is used for writing data at encoder to network storage equipment IPSAN produces less than encoder, guarantee the memory integrity of video recording.
For achieving the above object, the invention provides a kind of control method of the storage of recording a video, be applied to comprise in the network of encoding device, the network storage equipment and client that described encoding device sends code stream to the described network storage equipment and client simultaneously, described method comprises:
Encoding device detects to the take situation of described network storage equipment transmitted stream to local cache;
Described encoding device is judged described when taking situation and surpassing the preset alarm threshold value, selects one receiving the client of described code stream, and notifies described client to begin the code stream that receives is recorded a video;
Described encoding device is judged described when taking situation and being lower than default alarm threshold, notifies described client of recording a video to stop video recording, triggers the content that described client will record and sends to the described network storage equipment; Described alarm threshold is lower than described alarm threshold.
Wherein, described selection one client that receiving described code stream comprises:
Described encoding device obtains the client that receives described code stream;
When described client was a plurality of, described encoding device was selected the client that network condition is best according to the network condition of described a plurality of clients.
Wherein, described encoding device selects a best client of network condition to comprise according to the network condition of described a plurality of clients:
For each client, described encoding device obtains accumulation packet loss in its RR message divided by the merchant of the classified counting in its SR message;
Described encoding device is selected and petty dealer's clients corresponding, as the best client of network condition.
Wherein, describedly notify described client to begin the code stream that receives recorded a video to comprise: described encoding device sends the APP message that carries first sign to described client, triggers described client and begins the code stream that receives is recorded a video;
Describedly notify described client of recording a video to stop video recording comprising: described encoding device sends the APP message that carries second sign to described client of recording a video, and triggers described client of recording a video and stops the code stream that receives is recorded a video.
Wherein, the content that will record of described client sends to the described network storage equipment and comprises:
Described client is obtained the network condition of the described network storage equipment after stopping the code stream that receives recorded a video;
When described client meets the demands in the network condition of the described network storage equipment, the content of having recorded is sent to the described network storage equipment, when receiving playback request, described content is called for the described network storage equipment.
The present invention also provides a kind of recording control device, is applied on the encoding device, and described encoding device is the network storage equipment in network and client transmission code stream simultaneously, and described recording control device comprises:
The buffer memory detecting unit is used to detect to the take situation of described network storage equipment transmitted stream to the encoding device buffer memory; Judging that the described situation that takies surpasses the preset alarm threshold value or judges that the described situation that takies is when being lower than default alarm threshold by surpassing the preset alarm changes of threshold, notice client control unit, described alarm threshold is lower than described alarm threshold;
The client control unit is used for judging at described buffer memory detecting unit described when taking situation and surpassing the preset alarm threshold value, selects one receiving the client of described code stream, and notifies described client to begin the code stream that receives is recorded a video; Judge that at described buffer memory detecting unit the described situation that takies is when being lower than default alarm threshold by surpassing the preset alarm changes of threshold, notify described client of recording a video to stop video recording, trigger the content that described client will record and send to the described network storage equipment.
Wherein, described client control unit specifically comprises:
Client chooser unit is used for judging at described buffer memory detecting unit described when taking situation and surpassing the preset alarm threshold value, obtains the client that receives described code stream; When described client is a plurality of,, select the client that network condition is best according to the network condition of described a plurality of clients;
Video recording begins to notify subelement, and the client that is used for selecting to described client chooser unit sends the APP message that carries first sign, triggers described client and begins the code stream that receives is recorded a video;
Video recording expiry notification subelement, be used for judging that at described buffer memory detecting unit the described situation that takies is when being lower than default alarm threshold by surpassing the preset alarm changes of threshold, send the APP message that carries second sign to described client of recording a video, trigger described client of recording a video and stop the code stream that receives is recorded a video.
Wherein, described client chooser unit specifically is used for: when the client that receives described code stream that gets access to is a plurality of, for each client, obtain accumulation packet loss in its RR message divided by the merchant of the classified counting in its SR message; Select and petty dealer's clients corresponding, as the best client of network condition.
The present invention also provides a kind of client, comprising:
The video recording unit is used for according to the notice that receives from encoding device, and the code stream that receives is recorded a video or stopped video recording;
Video recording unit transmitting element is used for after described video recording unit stops the code stream that receives recorded a video, and the content of having recorded is sent to the network storage equipment in the network.
Wherein, also comprise:
The network condition acquiring unit is used for obtaining the network condition of the described network storage equipment after described video recording unit stops the code stream that receives recorded a video; When the network condition of the described network storage equipment meets the demands, notify the described video recording unit content that transmitting element will have been recorded to send to the described network storage equipment, described content is called when receiving playback request for the described network storage equipment.
Compared with prior art, the present invention has the following advantages:
Writing to the network storage equipment under the slack situation of data, the control client storage data of partly recording a video, and recover just often to stop the video recording to be undertaken by client writing data to the network storage equipment, and send to the network equipment by the video recording that client will be preserved and store, guaranteed the integrality of video recording storage.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
A kind of control method of the storage of recording a video is provided among the present invention, has been applied to comprise in the network of encoding device, the network storage equipment and client, this encoding device sends code stream to the network storage equipment and client simultaneously, and this method comprises as shown in Figure 2:
Step s201, encoding device detect to the take situation of network storage equipment transmitted stream to local cache.
Step s202, encoding device are judged when the situation that takies surpasses the preset alarm threshold value, select one receiving the client of code stream, and notify client to begin the code stream that receives is recorded a video.
When step s203, encoding device judged that taking situation is lower than default alarm threshold, the client that notice is being recorded a video stopped video recording, and the content that the triggering client will have been recorded sends to the network storage equipment; Alarm threshold is lower than alarm threshold.
Below in conjunction with a concrete application scenarios, the embodiment of video recording storage controlling method among the present invention is described.
The basic thought of video recording storage is in the prior art, video server is that each passage distributes a storage resources in the network storage equipment, by after the upper-layer protocol carrying, the plan by network based configuration writes I frame group in the storage resources of the network storage equipment after the encoder encodes.With I frame group is unit when writing the network storage equipment, and I frame group storage organization as shown in Figure 3.
In the application scenarios of the present invention, encoder sends to the bit stream data bag that the network storage equipment stores with needs and carries out buffer memory, operating position to encoder buffer is monitored in real time, when judging that according to the buffer memory operating position throughput of the network storage equipment is lower than the alarm threshold of certain predetermined, encoder is chosen one and is being received the client of identical code stream, and notifies the code stream that receives is recorded a video.When the storage throughput of the network storage equipment is gone up, after the buffer memory use amount of encoder descends, notify client to stop video recording.The client data of will recording a video send among the network storage equipment IPSAN and store, and guarantee the property finished of video recording content in the network storage equipment.Concrete, the control flow of this video recording storage comprises as shown in Figure 4:
Step s401, alarm threshold X is set on encoder, alarm threshold Y and buffer memory alarm sign.
Concrete, by alarm threshold X and alarm threshold Y the situation that takies of encoder buffer to be weighed, the situation that takies of buffer memory can represent by the buffer memory occupancy, i.e. the ratio of packet size of having stored in the buffer memory and buffer memory total capacity.For alarm threshold X and alarm threshold Y, alarm threshold X needs greater than alarm threshold Y, and it is 80% that alarm threshold X for example is set, and alarm threshold Y is 50%.
And buffer memory alarm sign (following represent with flag) is used for according to preset alarm threshold X and the default residing state of alarm threshold Y tag encoder buffer memory, when the situation that takies of buffer memory surpasses alarm threshold X, buffer memory is alarmed flag set (following 1 describe so that flag to be set), need to trigger specific client this moment the code stream that receives is recorded a video; When the situation that takies of buffer memory is changed to when being lower than alarm threshold Y by surpassing alarm threshold X, buffer memory alarm sign is resetted (following 0 describe so that flag to be set) needs to trigger the client of recording a video this moment and stops video recording.
Behind step s402, the system initialization, encoder detects to the take situation of network storage equipment transmitted stream to local cache.
Step s403, judge whether the operating position of current cache is higher than alarm threshold X, and buffer memory alarm sign flag is 0; Be then to carry out step s404, otherwise carry out step s407.
Step s404, buffer memory alarm sign flag is set is 1.
Step s405, selection one are receiving the client of code stream.
Step s406, notify selected client to begin the code stream that receives is recorded a video, return step s403.The notified back of client distributes a block space to carry out the video recording storage of code stream in this locality when receiving live code stream.
Step s407, judge whether the operating position of current cache is lower than alarm threshold Y, is then to carry out step s408, otherwise carry out step s403.
Step s408, judge buffer memory alarm sign flags whether 1, be then to carry out step s409, otherwise carry out step s403.
Step s409, send the notice that stops to record a video to the client of recording a video.
Step s410, buffer memory alarm sign flag is set is 0, returns step s403.
Concrete, below the specific implementation of step s405 is elaborated.
When encoder writes data in buffer memory, when network is bad when causing the use of buffer memory to surpass the alarm watermark threshold, encoder selects this passage to be carried out the best monitor client of network condition of live monitoring, sends the notice that begins to record a video to this client.
Concrete, encoder selects the concrete grammar of the best client of network condition to be:
The encoder traversal is receiving the client of this code stream, obtain based on rtcp protocol (Real-time Transmission Control Protocol for each client, RTCP Real-time Transport Control Protocol) RR (Receiver Report, the receiving terminal report) the accumulative total packet loss (cumulative number ofpackets lost) in the message, divided by SR (Sender Report, the result of sender report) the sender's classified counting in the message (Sender ' s packet count), the client that will have the minimum value result is as the best client of network condition.In the prior art, the structure of SR message is shown in Fig. 5 A, and the structure of RR message is shown in Fig. 5 B.
Concrete, among step s406 that relates in the above-mentioned flow process and the step s409, encoder to client begin record a video/control that stops to record a video can realize that by the APP order of rtcp protocol the form of APP order as shown in Figure 6 in the prior art.Should be with in the scene, encoder is when sending the APP order, and indicate the video recording of recording a video/stop of beginning of client in the name territory by the APP order, and when send name to client be 1 APP order, expression notice client began video recording; When client transmission name is 0 APP order, expression notice client stops video recording.
When client begins to record a video according to the notice of encoder, can store receiving packet according to the moment that receives notice from encoder, realize video recording to code stream.For this reason, client need be provided with a storage area in this locality, and ensuing I frame group storage in the code stream of I frame group in the local cache and encoder reception is arrived local storage area.Need write down the time and the original position of I frame group data in local storage region of the I frame group of storage during storage.Concrete storage organization one for example shown in Figure 7.
Client stops video recording and finishes according to the notice of encoder after, need survey the network condition of network storage equipment IPSAN, if network condition is better, then monitor client stores video recording in the file storage zone of IPSAN into.When network storage equipment IPSAN receives client when video recording is carried out the request of playback, network storage equipment IPSAN with in the file storage zone correlation time section content send to client.
The method that the application of the invention provides, writing to the network storage equipment under the slack situation of data, the control client storage data of partly recording a video, and recover just often to stop the video recording to be undertaken by client writing data to the network storage equipment, and send to the network equipment by the video recording that client will be preserved and store, guaranteed the integrality of video recording storage.
The present invention also provides a kind of recording control device, as shown in Figure 8, is applied on the encoding device, and this encoding device is the network storage equipment in network and client transmission code stream simultaneously, and this recording control device comprises:
Buffer memory detecting unit 10 is used to detect to the take situation of network storage equipment transmitted stream to the encoding device buffer memory; Take situation in judgement and surpass the preset alarm threshold value or judge that the situation that takies is when being lower than default alarm threshold by surpassing the preset alarm changes of threshold, notice client control unit, alarm threshold is lower than alarm threshold;
Client control unit 20 is used for selecting one receiving the client of code stream, and notifying client to begin the code stream that receives is recorded a video when buffer memory detecting unit 10 judges that the situation that takies surpasses the preset alarm threshold value; Judge that at buffer memory detecting unit 10 situation that takies is when being lower than default alarm threshold by surpassing the preset alarm changes of threshold, the client that notice is being recorded a video stops video recording, and the content that the triggering client will have been recorded sends to the network storage equipment.
This client control unit 20 specifically can comprise:
Client chooser unit 21 is used for obtaining the client that receives code stream when buffer memory detecting unit 10 judges that the situation that takies surpasses the preset alarm threshold value; When client is a plurality of,, select the client that network condition is best according to the network condition of a plurality of clients.Concrete, when the client that receives code stream that gets access to when being a plurality of,, obtain accumulation packet loss in its RR message divided by the merchant of the classified counting in its SR message for each client; Select and petty dealer's clients corresponding, as the best client of network condition.
Video recording begins to notify subelement 22, is used for sending the APP message that carries first sign to the client that client chooser unit 21 is selected, and triggers client and begins the code stream that receives is recorded a video;
Video recording expiry notification subelement 23, be used for judging that at buffer memory detecting unit 10 situation that takies is when being lower than default alarm threshold by surpassing the preset alarm changes of threshold, send the APP message that carries second sign to the client of recording a video, trigger the client of recording a video and stop the code stream that receives is recorded a video.
A kind of client also is provided among the present invention, as shown in Figure 9, comprises:
Video recording unit 50 is used for according to the notice that receives from encoding device, and the code stream that receives is recorded a video or stopped video recording;
Video recording unit transmitting element 60 is used for after video recording unit 50 stops the code stream that receives recorded a video, and the content of having recorded is sent to the network storage equipment in the network.
Network condition acquiring unit 70 is used for obtaining the network condition of the network storage equipment after video recording unit 50 stops the code stream that receives recorded a video; When the network condition of the network storage equipment met the demands, the content that notice video recording unit transmitting element 60 will have been recorded sent to the network storage equipment, content is called when receiving playback request for the network storage equipment.
The device that the application of the invention provides, writing to the network storage equipment under the slack situation of data, the control client storage data of partly recording a video, and recover just often to stop the video recording to be undertaken by client writing data to the network storage equipment, and send to the network equipment by the video recording that client will be preserved and store, guaranteed the integrality of video recording storage.
Through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize by hardware, also can realize by the mode that software adds necessary general hardware platform.Based on such understanding, technical scheme of the present invention can embody with the form of software product, it (can be CD-ROM that this software product can be stored in a non-volatile memory medium, USB flash disk, portable hard drive etc.) in, comprise some instructions with so that computer equipment (can be personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the present invention.
It will be appreciated by those skilled in the art that accompanying drawing is the schematic diagram of a preferred embodiment, unit in the accompanying drawing or flow process might not be that enforcement the present invention is necessary.
It will be appreciated by those skilled in the art that the unit in the device among the embodiment can be distributed in the device of embodiment according to the embodiment description, also can carry out respective change and be arranged in the one or more devices that are different from present embodiment.A unit can be merged in the unit of the foregoing description, also can further split into a plurality of subelements.
The invention described above embodiment sequence number is not represented the quality of embodiment just to description.